@inploi/plugin-job-search 0.22.2 → 0.23.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/index.cjs CHANGED
@@ -5547,12 +5547,17 @@ const JobCardSkeleton = ({
5547
5547
  const LoadMore = ({
5548
5548
  state,
5549
5549
  fetchNextPage,
5550
- config
5550
+ config,
5551
+ analytics
5551
5552
  }) => {
5552
5553
  if (state === "revalidating") {
5553
5554
  return /* @__PURE__ */ u$2("ul", { class: "flex flex-col gap-3", "aria-hidden": true, children: Array.from({ length: PAGE_SIZE }).map((_2, i2) => /* @__PURE__ */ u$2("li", { children: /* @__PURE__ */ u$2(JobCardSkeleton, { seed: i2, animationDelay: (i2 - 4) * 0.1, config }) }, i2)) });
5554
5555
  } else {
5555
- return /* @__PURE__ */ u$2("button", { class: btnClass({ variant: "neutral", class: "py-2" }), onClick: fetchNextPage, children: "Load More" });
5556
+ const handleClick = () => {
5557
+ analytics.log({ event: "SEARCH_PAGINATE" });
5558
+ fetchNextPage();
5559
+ };
5560
+ return /* @__PURE__ */ u$2("button", { class: btnClass({ variant: "neutral", class: "py-2" }), onClick: handleClick, children: "Load More" });
5556
5561
  }
5557
5562
  };
5558
5563
  const getResultsCount = ({ pagination }) => {
@@ -5566,7 +5571,8 @@ const ResultsSection = ({
5566
5571
  apiClient,
5567
5572
  logger,
5568
5573
  jobCardConfig,
5569
- initialData
5574
+ initialData,
5575
+ analytics
5570
5576
  }) => {
5571
5577
  const [page, setPage] = h$1(1);
5572
5578
  return /* @__PURE__ */ u$2(k$3, { children: Array.from({ length: page }).map((_2, index) => {
@@ -5582,7 +5588,8 @@ const ResultsSection = ({
5582
5588
  isLast,
5583
5589
  fetchNextPage: () => setPage(page + 1),
5584
5590
  jobCardConfig,
5585
- initialData
5591
+ initialData,
5592
+ analytics
5586
5593
  },
5587
5594
  index
5588
5595
  ) }, index);
@@ -5597,7 +5604,8 @@ const ResultsPage = ({
5597
5604
  isLast,
5598
5605
  fetchNextPage,
5599
5606
  jobCardConfig,
5600
- initialData
5607
+ initialData,
5608
+ analytics
5601
5609
  }) => {
5602
5610
  const fallbackData = page === 1 ? initialData : void 0;
5603
5611
  const { keyword$ } = store;
@@ -5654,7 +5662,7 @@ const ResultsPage = ({
5654
5662
  job.id
5655
5663
  );
5656
5664
  }) }),
5657
- hasMore && isLast && /* @__PURE__ */ u$2(LoadMore, { state, fetchNextPage, config: jobCardConfig })
5665
+ hasMore && isLast && /* @__PURE__ */ u$2(LoadMore, { state, fetchNextPage, config: jobCardConfig, analytics })
5658
5666
  ] });
5659
5667
  }
5660
5668
  default:
@@ -5703,6 +5711,25 @@ const JobSearch = ({
5703
5711
  filters: getFilterDefaults(properties, "defaultValue")
5704
5712
  }));
5705
5713
  const { keyword$ } = store;
5714
+ y$1(() => {
5715
+ const timer = window.setTimeout(() => {
5716
+ console.log("settling");
5717
+ const formattedFilters = filtersToPayload(appliedFilters.filters);
5718
+ const hasInteracted = appliedFilters.default !== true;
5719
+ if (!keyword$.value && !hasInteracted)
5720
+ return;
5721
+ analytics.log({
5722
+ event: "SEARCH_SETTLE",
5723
+ properties: {
5724
+ query: keyword$.value || void 0,
5725
+ filters: hasInteracted ? formattedFilters : void 0
5726
+ }
5727
+ });
5728
+ }, 5e3);
5729
+ return () => {
5730
+ clearTimeout(timer);
5731
+ };
5732
+ }, [appliedFilters.filters, keyword$.value, analytics, appliedFilters.default]);
5706
5733
  return /* @__PURE__ */ u$2("div", { ref: appRef, class: className, id: JOB_SEARCH_SCOPE_ELEMENT_ID, children: /* @__PURE__ */ u$2("div", { class: "ijs-app bg-app rounded-app font-family-default font-weight-default font-style-default mx-auto flex min-h-screen max-w-screen-lg flex-col gap-4 py-4 md:grid md:grid-cols-3 md:px-4", children: [
5707
5734
  /* @__PURE__ */ u$2(ErrorBoundary, { Fallback: ErrorView, children: /* @__PURE__ */ u$2("div", { class: "flex flex-col gap-2", children: [
5708
5735
  params.enableKeywordSearch && /* @__PURE__ */ u$2(KeywordSearch, { onKeywordChange }),
@@ -5740,7 +5767,8 @@ const JobSearch = ({
5740
5767
  logger,
5741
5768
  apiClient,
5742
5769
  jobCardConfig: params.jobCard,
5743
- initialData: appliedFilters.default ? initialData == null ? void 0 : initialData.jobs : void 0
5770
+ initialData: appliedFilters.default ? initialData == null ? void 0 : initialData.jobs : void 0,
5771
+ analytics
5744
5772
  },
5745
5773
  cacheKey({ filter: appliedFilters.filters, baseKey: "resultsSection", keyword: keyword$.value })
5746
5774
  ) }) }) })
package/dist/index.js CHANGED
@@ -5545,12 +5545,17 @@ const JobCardSkeleton = ({
5545
5545
  const LoadMore = ({
5546
5546
  state,
5547
5547
  fetchNextPage,
5548
- config
5548
+ config,
5549
+ analytics
5549
5550
  }) => {
5550
5551
  if (state === "revalidating") {
5551
5552
  return /* @__PURE__ */ u$2("ul", { class: "flex flex-col gap-3", "aria-hidden": true, children: Array.from({ length: PAGE_SIZE }).map((_2, i2) => /* @__PURE__ */ u$2("li", { children: /* @__PURE__ */ u$2(JobCardSkeleton, { seed: i2, animationDelay: (i2 - 4) * 0.1, config }) }, i2)) });
5552
5553
  } else {
5553
- return /* @__PURE__ */ u$2("button", { class: btnClass({ variant: "neutral", class: "py-2" }), onClick: fetchNextPage, children: "Load More" });
5554
+ const handleClick = () => {
5555
+ analytics.log({ event: "SEARCH_PAGINATE" });
5556
+ fetchNextPage();
5557
+ };
5558
+ return /* @__PURE__ */ u$2("button", { class: btnClass({ variant: "neutral", class: "py-2" }), onClick: handleClick, children: "Load More" });
5554
5559
  }
5555
5560
  };
5556
5561
  const getResultsCount = ({ pagination }) => {
@@ -5564,7 +5569,8 @@ const ResultsSection = ({
5564
5569
  apiClient,
5565
5570
  logger,
5566
5571
  jobCardConfig,
5567
- initialData
5572
+ initialData,
5573
+ analytics
5568
5574
  }) => {
5569
5575
  const [page, setPage] = h$1(1);
5570
5576
  return /* @__PURE__ */ u$2(k$3, { children: Array.from({ length: page }).map((_2, index) => {
@@ -5580,7 +5586,8 @@ const ResultsSection = ({
5580
5586
  isLast,
5581
5587
  fetchNextPage: () => setPage(page + 1),
5582
5588
  jobCardConfig,
5583
- initialData
5589
+ initialData,
5590
+ analytics
5584
5591
  },
5585
5592
  index
5586
5593
  ) }, index);
@@ -5595,7 +5602,8 @@ const ResultsPage = ({
5595
5602
  isLast,
5596
5603
  fetchNextPage,
5597
5604
  jobCardConfig,
5598
- initialData
5605
+ initialData,
5606
+ analytics
5599
5607
  }) => {
5600
5608
  const fallbackData = page === 1 ? initialData : void 0;
5601
5609
  const { keyword$ } = store;
@@ -5652,7 +5660,7 @@ const ResultsPage = ({
5652
5660
  job.id
5653
5661
  );
5654
5662
  }) }),
5655
- hasMore && isLast && /* @__PURE__ */ u$2(LoadMore, { state, fetchNextPage, config: jobCardConfig })
5663
+ hasMore && isLast && /* @__PURE__ */ u$2(LoadMore, { state, fetchNextPage, config: jobCardConfig, analytics })
5656
5664
  ] });
5657
5665
  }
5658
5666
  default:
@@ -5701,6 +5709,25 @@ const JobSearch = ({
5701
5709
  filters: getFilterDefaults(properties, "defaultValue")
5702
5710
  }));
5703
5711
  const { keyword$ } = store;
5712
+ y$1(() => {
5713
+ const timer = window.setTimeout(() => {
5714
+ console.log("settling");
5715
+ const formattedFilters = filtersToPayload(appliedFilters.filters);
5716
+ const hasInteracted = appliedFilters.default !== true;
5717
+ if (!keyword$.value && !hasInteracted)
5718
+ return;
5719
+ analytics.log({
5720
+ event: "SEARCH_SETTLE",
5721
+ properties: {
5722
+ query: keyword$.value || void 0,
5723
+ filters: hasInteracted ? formattedFilters : void 0
5724
+ }
5725
+ });
5726
+ }, 5e3);
5727
+ return () => {
5728
+ clearTimeout(timer);
5729
+ };
5730
+ }, [appliedFilters.filters, keyword$.value, analytics, appliedFilters.default]);
5704
5731
  return /* @__PURE__ */ u$2("div", { ref: appRef, class: className, id: JOB_SEARCH_SCOPE_ELEMENT_ID, children: /* @__PURE__ */ u$2("div", { class: "ijs-app bg-app rounded-app font-family-default font-weight-default font-style-default mx-auto flex min-h-screen max-w-screen-lg flex-col gap-4 py-4 md:grid md:grid-cols-3 md:px-4", children: [
5705
5732
  /* @__PURE__ */ u$2(ErrorBoundary, { Fallback: ErrorView, children: /* @__PURE__ */ u$2("div", { class: "flex flex-col gap-2", children: [
5706
5733
  params.enableKeywordSearch && /* @__PURE__ */ u$2(KeywordSearch, { onKeywordChange }),
@@ -5738,7 +5765,8 @@ const JobSearch = ({
5738
5765
  logger,
5739
5766
  apiClient,
5740
5767
  jobCardConfig: params.jobCard,
5741
- initialData: appliedFilters.default ? initialData == null ? void 0 : initialData.jobs : void 0
5768
+ initialData: appliedFilters.default ? initialData == null ? void 0 : initialData.jobs : void 0,
5769
+ analytics
5742
5770
  },
5743
5771
  cacheKey({ filter: appliedFilters.filters, baseKey: "resultsSection", keyword: keyword$.value })
5744
5772
  ) }) }) })
@@ -275,6 +275,8 @@ declare const JobSearchResponseSchema: import('valibot').SchemaWithTransform<imp
275
275
  }>;
276
276
  export type JobSearchResponsePayloadInput = Input<typeof JobSearchResponseSchema>;
277
277
  export type JobSearchResponsePayloadOutput = Output<typeof JobSearchResponseSchema>;
278
+ export declare const getFilterValue: (filterValue: string | string[] | undefined) => string | string[] | null;
279
+ export declare const filtersToPayload: (filters: Record<string, FilterValue | undefined>) => Record<string, string | string[] | null>;
278
280
  export declare const getAvailableFilters: ({ apiClient, filters, keyword, logger, signal, }: {
279
281
  apiClient: ApiClient;
280
282
  logger: Logger;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inploi/plugin-job-search",
3
- "version": "0.22.2",
3
+ "version": "0.23.0",
4
4
  "type": "module",
5
5
  "main": "dist/plugin-job-search.js",
6
6
  "types": "dist/index.d.ts",