instantsearch-ui-components 0.10.0 → 0.11.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.
@@ -11,7 +11,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
11
11
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
12
  var _lib = require("../lib");
13
13
  var _recommendShared = require("./recommend-shared");
14
- var _excluded = ["listRef", "nextButtonRef", "previousButtonRef", "carouselIdRef", "classNames", "itemComponent", "previousIconComponent", "nextIconComponent", "items", "translations"];
14
+ var _excluded = ["listRef", "nextButtonRef", "previousButtonRef", "carouselIdRef", "classNames", "itemComponent", "previousIconComponent", "nextIconComponent", "items", "translations", "sendEvent"];
15
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
16
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
17
  var lastCarouselId = 0;
@@ -67,6 +67,7 @@ function createCarouselComponent(_ref3) {
67
67
  NextIconComponent = _userProps$nextIconCo === void 0 ? NextIconDefaultComponent : _userProps$nextIconCo,
68
68
  items = userProps.items,
69
69
  userTranslations = userProps.translations,
70
+ sendEvent = userProps.sendEvent,
70
71
  props = (0, _objectWithoutProperties2.default)(userProps, _excluded);
71
72
  var translations = _objectSpread({
72
73
  listLabel: 'Items',
@@ -141,9 +142,16 @@ function createCarouselComponent(_ref3) {
141
142
  key: item.objectID,
142
143
  className: (0, _lib.cx)(cssClasses.item),
143
144
  "aria-roledescription": "slide",
144
- "aria-label": "".concat(index + 1, " of ").concat(items.length)
145
+ "aria-label": "".concat(index + 1, " of ").concat(items.length),
146
+ onClick: function onClick() {
147
+ sendEvent('click:internal', item, 'Item Clicked');
148
+ },
149
+ onAuxClick: function onAuxClick() {
150
+ sendEvent('click:internal', item, 'Item Clicked');
151
+ }
145
152
  }, createElement(ItemComponent, {
146
- item: item
153
+ item: item,
154
+ sendEvent: sendEvent
147
155
  }));
148
156
  })), createElement("button", {
149
157
  ref: nextButtonRef,
@@ -20,10 +20,15 @@ function createListComponent(_ref) {
20
20
  return createElement("li", {
21
21
  key: item.objectID,
22
22
  className: classNames.item,
23
- onClick: sendEvent,
24
- onAuxClick: sendEvent
23
+ onClick: function onClick() {
24
+ sendEvent('click:internal', item, 'Item Clicked');
25
+ },
26
+ onAuxClick: function onAuxClick() {
27
+ sendEvent('click:internal', item, 'Item Clicked');
28
+ }
25
29
  }, createElement(ItemComponent, {
26
- item: item
30
+ item: item,
31
+ sendEvent: sendEvent
27
32
  }));
28
33
  })));
29
34
  };
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = exports.default = '0.10.0';
7
+ var _default = exports.default = '0.11.1';
@@ -1,4 +1,4 @@
1
- import type { ComponentProps, MutableRef, RecommendItemComponentProps, RecordWithObjectID, Renderer } from '../types';
1
+ import type { ComponentProps, MutableRef, RecommendItemComponentProps, RecordWithObjectID, Renderer, SendEventForHits } from '../types';
2
2
  export type CarouselProps<TObject, TComponentProps extends Record<string, unknown> = Record<string, unknown>> = ComponentProps<'div'> & {
3
3
  listRef: MutableRef<HTMLOListElement | null>;
4
4
  nextButtonRef: MutableRef<HTMLButtonElement | null>;
@@ -10,6 +10,7 @@ export type CarouselProps<TObject, TComponentProps extends Record<string, unknow
10
10
  nextIconComponent?: () => JSX.Element;
11
11
  classNames?: Partial<CarouselClassNames>;
12
12
  translations?: Partial<CarouselTranslations>;
13
+ sendEvent: SendEventForHits;
13
14
  };
14
15
  export type CarouselClassNames = {
15
16
  /**
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["listRef", "nextButtonRef", "previousButtonRef", "carouselIdRef", "classNames", "itemComponent", "previousIconComponent", "nextIconComponent", "items", "translations"];
4
+ var _excluded = ["listRef", "nextButtonRef", "previousButtonRef", "carouselIdRef", "classNames", "itemComponent", "previousIconComponent", "nextIconComponent", "items", "translations", "sendEvent"];
5
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  import { cx } from "../lib/index.js";
@@ -59,6 +59,7 @@ export function createCarouselComponent(_ref3) {
59
59
  NextIconComponent = _userProps$nextIconCo === void 0 ? NextIconDefaultComponent : _userProps$nextIconCo,
60
60
  items = userProps.items,
61
61
  userTranslations = userProps.translations,
62
+ sendEvent = userProps.sendEvent,
62
63
  props = _objectWithoutProperties(userProps, _excluded);
63
64
  var translations = _objectSpread({
64
65
  listLabel: 'Items',
@@ -133,9 +134,16 @@ export function createCarouselComponent(_ref3) {
133
134
  key: item.objectID,
134
135
  className: cx(cssClasses.item),
135
136
  "aria-roledescription": "slide",
136
- "aria-label": "".concat(index + 1, " of ").concat(items.length)
137
+ "aria-label": "".concat(index + 1, " of ").concat(items.length),
138
+ onClick: function onClick() {
139
+ sendEvent('click:internal', item, 'Item Clicked');
140
+ },
141
+ onAuxClick: function onAuxClick() {
142
+ sendEvent('click:internal', item, 'Item Clicked');
143
+ }
137
144
  }, createElement(ItemComponent, {
138
- item: item
145
+ item: item,
146
+ sendEvent: sendEvent
139
147
  }));
140
148
  })), createElement("button", {
141
149
  ref: nextButtonRef,
@@ -14,10 +14,15 @@ export function createListComponent(_ref) {
14
14
  return createElement("li", {
15
15
  key: item.objectID,
16
16
  className: classNames.item,
17
- onClick: sendEvent,
18
- onAuxClick: sendEvent
17
+ onClick: function onClick() {
18
+ sendEvent('click:internal', item, 'Item Clicked');
19
+ },
20
+ onAuxClick: function onAuxClick() {
21
+ sendEvent('click:internal', item, 'Item Clicked');
22
+ }
19
23
  }, createElement(ItemComponent, {
20
- item: item
24
+ item: item,
25
+ sendEvent: sendEvent
21
26
  }));
22
27
  })));
23
28
  };
@@ -59,9 +59,12 @@ export type RecommendInnerComponentProps<TObject> = {
59
59
  };
60
60
  export type RecordWithObjectID<TObject = Record<string, unknown>> = TObject & {
61
61
  objectID: string;
62
+ __position: number;
63
+ __queryID?: string;
62
64
  };
63
65
  export type RecommendItemComponentProps<TObject> = {
64
66
  item: TObject;
67
+ sendEvent: SendEventForHits;
65
68
  onClick?: () => void;
66
69
  onAuxClick?: () => void;
67
70
  };
@@ -1 +1,5 @@
1
- export type SendEventForHits = (...props: unknown[]) => void;
1
+ import type { RecordWithObjectID } from './Recommend';
2
+ type BuiltInSendEventForHits = (eventType: string, hits: RecordWithObjectID<any> | Array<RecordWithObjectID<any>>, eventName?: string, additionalData?: Record<string, any>) => void;
3
+ type CustomSendEventForHits = (customPayload: any) => void;
4
+ export type SendEventForHits = BuiltInSendEventForHits & CustomSendEventForHits;
5
+ export {};
@@ -1,2 +1,2 @@
1
- declare const _default: "0.10.0";
1
+ declare const _default: "0.11.1";
2
2
  export default _default;
@@ -1 +1 @@
1
- export default '0.10.0';
1
+ export default '0.11.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instantsearch-ui-components",
3
- "version": "0.10.0",
3
+ "version": "0.11.1",
4
4
  "description": "Common UI components for InstantSearch.",
5
5
  "types": "dist/es/index.d.ts",
6
6
  "main": "dist/cjs/index.js",
@@ -49,5 +49,5 @@
49
49
  "dependencies": {
50
50
  "@babel/runtime": "^7.1.2"
51
51
  },
52
- "gitHead": "8e30cd5859416a1c29e2030a69d52b601fc91fab"
52
+ "gitHead": "3d0c6cbcb894a0b38a81485bc98de6244b70b97e"
53
53
  }