@commercelayer/react-components 4.6.0-beta.0 → 4.6.0-beta.1

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.
@@ -1,8 +1,24 @@
1
1
  import type { DefaultChildrenType } from '../../typings/globals';
2
2
  interface Props {
3
+ /**
4
+ * Accept a React node as children.
5
+ */
3
6
  children: DefaultChildrenType;
7
+ /**
8
+ * The access token to authenticate the API calls.
9
+ */
4
10
  accessToken: string;
5
- endpoint: string;
11
+ /**
12
+ * The endpoint to make the API calls. e.g. https://yourdomain.commercelayer.io
13
+ */
14
+ endpoint?: string;
15
+ /**
16
+ * The domain to make the API calls. e.g. commercelayer.io
17
+ */
18
+ domain?: string;
6
19
  }
20
+ /**
21
+ * CommerceLayer component
22
+ */
7
23
  export declare function CommerceLayer(props: Props): JSX.Element;
8
24
  export default CommerceLayer;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CommerceLayer=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),ErrorBoundary_1=tslib_1.__importDefault(require("../utils/ErrorBoundary"));function CommerceLayer(props){const{children}=props,p=tslib_1.__rest(props,["children"]);return(0,jsx_runtime_1.jsx)(ErrorBoundary_1.default,{children:(0,jsx_runtime_1.jsx)(CommerceLayerContext_1.default.Provider,{value:Object.assign({},p),children})})}exports.CommerceLayer=CommerceLayer,exports.default=CommerceLayer;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CommerceLayer=void 0;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),ErrorBoundary_1=tslib_1.__importDefault(require("../utils/ErrorBoundary")),jwt_1=tslib_1.__importDefault(require("../../utils/jwt"));function CommerceLayer(props){var _a;const{children}=props,p=tslib_1.__rest(props,["children"]);if(!p.endpoint){const{organization}=(0,jwt_1.default)(p.accessToken);p.endpoint=`https://${organization.slug}.${(_a=p.domain)!==null&&_a!==void 0?_a:"commercelayer.io"}`}return(0,jsx_runtime_1.jsx)(ErrorBoundary_1.default,{children:(0,jsx_runtime_1.jsx)(CommerceLayerContext_1.default.Provider,{value:Object.assign({},p),children})})}exports.CommerceLayer=CommerceLayer,exports.default=CommerceLayer;
@@ -7,9 +7,28 @@ interface PriceChildrenProps extends Omit<PriceProps, 'children'> {
7
7
  }
8
8
  export interface PriceProps extends Omit<JSX.IntrinsicElements['span'], 'children'> {
9
9
  children?: ChildrenFunction<PriceChildrenProps>;
10
+ /**
11
+ * CSS class name to be added for the compare price
12
+ */
10
13
  compareClassName?: string;
14
+ /**
15
+ * When `false` the compare_at price will not be displayed
16
+ * @default true
17
+ */
11
18
  showCompare?: boolean;
19
+ /**
20
+ * The `sku_code` of the price to be fetched
21
+ */
12
22
  skuCode?: string | null;
13
23
  }
24
+ /**
25
+ * To display the price of your products with localized currency, discounts, and personalization rules, as shown in the code snippets below.
26
+ *
27
+ * Each price has an amount (the actual selling price) and an optional compare-at amount (the full price that you want to display to the customer — typically with a strikethrough).
28
+ * This component is the owner of the price information. It fetches the price of the specified SKU and dispatches it to the cl-price-amount children.
29
+ * <span type='info'>
30
+ * By default it shows the `formatted_amount` and `formatted_compare_at_amount` of the first price object, but it also allows to access to the full `Price`object via children props.
31
+ * </span>
32
+ */
14
33
  export declare function Price(props: PriceProps): JSX.Element;
15
34
  export default Price;
@@ -1,8 +1,24 @@
1
1
  import type { DefaultChildrenType } from '../../typings/globals';
2
2
  interface Props {
3
+ /**
4
+ * Accept a React node as children.
5
+ */
3
6
  children: DefaultChildrenType;
7
+ /**
8
+ * The access token to authenticate the API calls.
9
+ */
4
10
  accessToken: string;
5
- endpoint: string;
11
+ /**
12
+ * The endpoint to make the API calls. e.g. https://yourdomain.commercelayer.io
13
+ */
14
+ endpoint?: string;
15
+ /**
16
+ * The domain to make the API calls. e.g. commercelayer.io
17
+ */
18
+ domain?: string;
6
19
  }
20
+ /**
21
+ * CommerceLayer component
22
+ */
7
23
  export declare function CommerceLayer(props: Props): JSX.Element;
8
24
  export default CommerceLayer;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as _jsx}from"react/jsx-runtime";import CommerceLayerContext from"../../context/CommerceLayerContext";import ErrorBoundary from"../utils/ErrorBoundary";export function CommerceLayer(props){const{children,...p}=props;return _jsx(ErrorBoundary,{children:_jsx(CommerceLayerContext.Provider,{value:{...p},children})})}export default CommerceLayer;
2
+ import{jsx as _jsx}from"react/jsx-runtime";import CommerceLayerContext from"../../context/CommerceLayerContext";import ErrorBoundary from"../utils/ErrorBoundary";import jwt from"../../utils/jwt";export function CommerceLayer(props){const{children,...p}=props;if(!p.endpoint){const{organization}=jwt(p.accessToken);p.endpoint=`https://${organization.slug}.${p.domain??"commercelayer.io"}`}return _jsx(ErrorBoundary,{children:_jsx(CommerceLayerContext.Provider,{value:{...p},children})})}export default CommerceLayer;
@@ -7,9 +7,28 @@ interface PriceChildrenProps extends Omit<PriceProps, 'children'> {
7
7
  }
8
8
  export interface PriceProps extends Omit<JSX.IntrinsicElements['span'], 'children'> {
9
9
  children?: ChildrenFunction<PriceChildrenProps>;
10
+ /**
11
+ * CSS class name to be added for the compare price
12
+ */
10
13
  compareClassName?: string;
14
+ /**
15
+ * When `false` the compare_at price will not be displayed
16
+ * @default true
17
+ */
11
18
  showCompare?: boolean;
19
+ /**
20
+ * The `sku_code` of the price to be fetched
21
+ */
12
22
  skuCode?: string | null;
13
23
  }
24
+ /**
25
+ * To display the price of your products with localized currency, discounts, and personalization rules, as shown in the code snippets below.
26
+ *
27
+ * Each price has an amount (the actual selling price) and an optional compare-at amount (the full price that you want to display to the customer — typically with a strikethrough).
28
+ * This component is the owner of the price information. It fetches the price of the specified SKU and dispatches it to the cl-price-amount children.
29
+ * <span type='info'>
30
+ * By default it shows the `formatted_amount` and `formatted_compare_at_amount` of the first price object, but it also allows to access to the full `Price`object via children props.
31
+ * </span>
32
+ */
14
33
  export declare function Price(props: PriceProps): JSX.Element;
15
34
  export default Price;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercelayer/react-components",
3
- "version": "4.6.0-beta.0",
3
+ "version": "4.6.0-beta.1",
4
4
  "description": "The Official Commerce Layer React Components",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/esm/index.js",