@constructor-io/constructorio-ui-asa 1.1.1 → 1.2.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.
@@ -5,8 +5,18 @@ const react_1 = require("react");
5
5
  exports.AsaContext = (0, react_1.createContext)(null);
6
6
  exports.AsaContext.displayName = 'AsaContext';
7
7
  /**
8
- * React Hook to access state provided by CioAsa provider.
9
- * Note: Should only be used by components nested under a CioAsa provider
8
+ * React Hook to access the state provided by the CioAsa provider.
9
+ *
10
+ * Returns `null` when called from a component that is not nested under a
11
+ * `CioAsaProvider`, so guard the result before reading from it:
12
+ *
13
+ * ```tsx
14
+ * const context = useCioAsaContext();
15
+ * const tracking = useAsaTracking({
16
+ * tracker: context?.cioClient?.tracker ?? undefined,
17
+ * section: context?.section,
18
+ * });
19
+ * ```
10
20
  */
11
21
  function useCioAsaContext() {
12
22
  return (0, react_1.useContext)(exports.AsaContext);
package/lib/cjs/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ConstructorIOClient = exports.normalizeItemToProduct = exports.useAsaTracking = exports.useAsaResults = exports.Button = exports.ResultsBlock = exports.Chat = exports.CioAsaProvider = void 0;
6
+ exports.ConstructorIOClient = exports.normalizeItemToProduct = exports.useCioAsaContext = exports.useAsaTracking = exports.useAsaResults = exports.Button = exports.ResultsBlock = exports.Chat = exports.CioAsaProvider = void 0;
7
7
  // Components
8
8
  var CioAsaProvider_1 = require("./components/CioAsaProvider/CioAsaProvider");
9
9
  Object.defineProperty(exports, "CioAsaProvider", { enumerable: true, get: function () { return __importDefault(CioAsaProvider_1).default; } });
@@ -18,6 +18,8 @@ var useAsaResults_1 = require("./hooks/useAsaResults");
18
18
  Object.defineProperty(exports, "useAsaResults", { enumerable: true, get: function () { return __importDefault(useAsaResults_1).default; } });
19
19
  var useAsaTracking_1 = require("./hooks/useAsaTracking");
20
20
  Object.defineProperty(exports, "useAsaTracking", { enumerable: true, get: function () { return __importDefault(useAsaTracking_1).default; } });
21
+ var useCioAsaContext_1 = require("./hooks/useCioAsaContext");
22
+ Object.defineProperty(exports, "useCioAsaContext", { enumerable: true, get: function () { return __importDefault(useCioAsaContext_1).default; } });
21
23
  // Utils
22
24
  var productNormalizer_1 = require("./utils/productNormalizer");
23
25
  Object.defineProperty(exports, "normalizeItemToProduct", { enumerable: true, get: function () { return productNormalizer_1.normalizeItemToProduct; } });
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.1.1';
3
+ exports.default = '1.2.0';
@@ -2,8 +2,18 @@ import { createContext, useContext } from 'react';
2
2
  export const AsaContext = createContext(null);
3
3
  AsaContext.displayName = 'AsaContext';
4
4
  /**
5
- * React Hook to access state provided by CioAsa provider.
6
- * Note: Should only be used by components nested under a CioAsa provider
5
+ * React Hook to access the state provided by the CioAsa provider.
6
+ *
7
+ * Returns `null` when called from a component that is not nested under a
8
+ * `CioAsaProvider`, so guard the result before reading from it:
9
+ *
10
+ * ```tsx
11
+ * const context = useCioAsaContext();
12
+ * const tracking = useAsaTracking({
13
+ * tracker: context?.cioClient?.tracker ?? undefined,
14
+ * section: context?.section,
15
+ * });
16
+ * ```
7
17
  */
8
18
  export function useCioAsaContext() {
9
19
  return useContext(AsaContext);
package/lib/mjs/index.js CHANGED
@@ -6,6 +6,7 @@ export { default as Button } from './components/Button/Button';
6
6
  // Hooks
7
7
  export { default as useAsaResults } from './hooks/useAsaResults';
8
8
  export { default as useAsaTracking } from './hooks/useAsaTracking';
9
+ export { default as useCioAsaContext } from './hooks/useCioAsaContext';
9
10
  // Utils
10
11
  export { normalizeItemToProduct } from './utils/productNormalizer';
11
12
  // Re-exported client value from the JS client (used to construct/type a cioClient)
@@ -1 +1 @@
1
- export default '1.1.1';
1
+ export default '1.2.0';
@@ -1,9 +1,19 @@
1
1
  /// <reference types="react" />
2
- import { AsaContextValue } from '../types';
2
+ import { AsaContextValue, Nullable } from '../types';
3
3
  export declare const AsaContext: import("react").Context<AsaContextValue | null>;
4
4
  /**
5
- * React Hook to access state provided by CioAsa provider.
6
- * Note: Should only be used by components nested under a CioAsa provider
5
+ * React Hook to access the state provided by the CioAsa provider.
6
+ *
7
+ * Returns `null` when called from a component that is not nested under a
8
+ * `CioAsaProvider`, so guard the result before reading from it:
9
+ *
10
+ * ```tsx
11
+ * const context = useCioAsaContext();
12
+ * const tracking = useAsaTracking({
13
+ * tracker: context?.cioClient?.tracker ?? undefined,
14
+ * section: context?.section,
15
+ * });
16
+ * ```
7
17
  */
8
- export declare function useCioAsaContext(): AsaContextValue;
18
+ export declare function useCioAsaContext(): Nullable<AsaContextValue>;
9
19
  export default useCioAsaContext;
@@ -7,6 +7,7 @@ export { default as Button } from './components/Button/Button';
7
7
  export type { ButtonProps } from './components/Button/Button';
8
8
  export { default as useAsaResults } from './hooks/useAsaResults';
9
9
  export { default as useAsaTracking } from './hooks/useAsaTracking';
10
+ export { default as useCioAsaContext } from './hooks/useCioAsaContext';
10
11
  export type { UseAsaTrackingProps, UseAsaTrackingReturn } from './hooks/useAsaTracking';
11
12
  export { normalizeItemToProduct } from './utils/productNormalizer';
12
13
  export type { Product, NormalizeOptions } from './utils/productNormalizer';
@@ -1,2 +1,2 @@
1
- declare const _default: "1.1.1";
1
+ declare const _default: "1.2.0";
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-ui-asa",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Constructor.io AI Shopping Agent UI library for web applications",
5
5
  "author": "constructor.io",
6
6
  "license": "MIT",