ublo-lib 1.36.14 → 1.36.16

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.
@@ -52,7 +52,7 @@ export default function PeriodPicker({ setClosed = undefined, force = false, onC
52
52
  setSelected((previousWeek) => {
53
53
  if (previousWeek !== undefined &&
54
54
  previousWeek !== null &&
55
- previousWeek !== week) {
55
+ Number(previousWeek) !== Number(week)) {
56
56
  window.sessionStorage.removeItem("cartId");
57
57
  }
58
58
  setWarn(false);
@@ -0,0 +1,10 @@
1
+ import { GoogleSearchResults } from "./services/google-search-api";
2
+ type Props = {
3
+ products: GoogleSearchResults["items"];
4
+ loading: boolean;
5
+ sendPlausibleGoal: (path: string) => void;
6
+ faqsMaximized: boolean;
7
+ };
8
+ export default function GoogleProducts({ products, loading, sendPlausibleGoal, faqsMaximized, }: Props): import("react/jsx-runtime").JSX.Element;
9
+ export {};
10
+ //# sourceMappingURL=google-results.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-results.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/instant-search/google-results.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAKnE,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,EAAE,OAAO,CAAC;IAEjB,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAIF,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,QAAQ,EACR,OAAO,EACP,iBAAiB,EACjB,aAAa,GACd,EAAE,KAAK,2CAmEP"}
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Image from "next/image";
3
+ import Link from "ublo/link";
4
+ import Loader from "dt-design-system/es/loader";
5
+ import * as Ripple from "dt-design-system/es/ripple";
6
+ import getConfig from "next/config";
7
+ import css from "./products.module.css";
8
+ const { publicRuntimeConfig } = getConfig();
9
+ const { site, portalUrl } = publicRuntimeConfig;
10
+ const PLACEHOLDERS = [...new Array(2)];
11
+ export default function GoogleProducts({ products, loading, sendPlausibleGoal, faqsMaximized, }) {
12
+ if (faqsMaximized)
13
+ return null;
14
+ const createRipple = (e) => {
15
+ Ripple.create(e);
16
+ };
17
+ return (_jsxs("div", { className: css.products, children: [loading &&
18
+ PLACEHOLDERS.map((_, i) => {
19
+ return (_jsx("div", { className: css.loaderContainer, children: _jsx(Loader, { className: css.loader, variant: "overlay" }) }, i));
20
+ }), !loading &&
21
+ products.map((product, i) => {
22
+ const { htmlTitle, link, displayLink: productPageTitle, htmlSnippet, pageMap, } = product;
23
+ const productTitle = htmlTitle.replaceAll("b>", "mark>");
24
+ const productText = htmlSnippet.replaceAll("b>", "mark>");
25
+ const image = pageMap.cse_image?.[0]?.src;
26
+ return (_jsxs(Link, { className: css.product, href: link, target: "_blank", onClick: sendPlausibleGoal(link), onMouseDown: createRipple, children: [_jsx(Image, { className: css.productImage, src: image, alt: htmlTitle, width: 220, height: 180, placeholder: "empty" }), _jsxs("div", { className: css.productContent, children: [_jsx("div", { className: css.productPageTitle, dangerouslySetInnerHTML: { __html: productPageTitle } }), _jsx("div", { className: css.productTitle, dangerouslySetInnerHTML: { __html: productTitle } }), _jsx("div", { className: css.productText, dangerouslySetInnerHTML: { __html: productText } })] })] }, i));
27
+ })] }));
28
+ }
@@ -0,0 +1,164 @@
1
+ .products {
2
+ flex: 1 1 100%;
3
+ display: grid;
4
+ grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
5
+ align-content: flex-start;
6
+ gap: 16px;
7
+ padding: 12px;
8
+ }
9
+
10
+ div + .products {
11
+ padding-top: 4px;
12
+ }
13
+
14
+ .products.empty {
15
+ position: absolute;
16
+ top: 0;
17
+ left: 0;
18
+ width: 100%;
19
+ height: 100%;
20
+ align-content: center;
21
+ padding-bottom: 120px;
22
+ pointer-events: none;
23
+ }
24
+
25
+ .noProduct {
26
+ grid-column: 1 / -1;
27
+ display: flex;
28
+ flex-direction: column;
29
+ align-items: center;
30
+ justify-content: center;
31
+ gap: 18px;
32
+ color: var(--ds-grey-400, #9d9d9d);
33
+ text-align: center;
34
+ font-size: 17px;
35
+ }
36
+
37
+ .noProductIcon {
38
+ flex: 0 0 140px;
39
+ width: 140px;
40
+ height: 140px;
41
+ }
42
+
43
+ .loaderContainer {
44
+ position: relative;
45
+ width: 100%;
46
+ height: 290px;
47
+ border-radius: var(--ds-input-radius, var(--ds-radius-200, 8px));
48
+ }
49
+
50
+ .loader {
51
+ background: linear-gradient(
52
+ -45deg,
53
+ var(--ds-grey-300, #d4d4d4),
54
+ var(--ds-grey-400, #d2d2d2),
55
+ var(--ds-grey-200, #efefef),
56
+ var(--ds-grey-400, #d2d2d2)
57
+ );
58
+ background-size: 400% 400%;
59
+ background-position: 0% 50%;
60
+ }
61
+
62
+ .product {
63
+ position: relative;
64
+ display: flex;
65
+ flex-direction: column;
66
+ color: var(--ds-grey-500, #484848);
67
+ background-color: var(--ds-grey-000, #fff);
68
+ border-radius: var(--ds-input-radius, var(--ds-radius-200, 8px));
69
+ border: var(--ds-input-border, 1px solid var(--ds-grey-300, #d7d7d7));
70
+ }
71
+
72
+ .product mark {
73
+ position: relative;
74
+ display: inline-block;
75
+ font-weight: 700;
76
+ color: var(--ds-secondary, var(--ds-blue-400, #4177f6));
77
+ background-color: transparent;
78
+ }
79
+
80
+ .product mark::before {
81
+ content: "";
82
+ position: absolute;
83
+ top: 0;
84
+ left: 0;
85
+ width: 100%;
86
+ height: 100%;
87
+ background-color: var(--ds-secondary, var(--ds-blue-400, #4177f6));
88
+ border-radius: calc(var(--ds-radius-100, 6px) / 3);
89
+ opacity: 0.15;
90
+ }
91
+
92
+ .productImage {
93
+ width: 100%;
94
+ height: 180px;
95
+ object-fit: cover;
96
+ border-radius: var(--ds-input-radius, var(--ds-radius-200, 8px))
97
+ var(--ds-input-radius, var(--ds-radius-200, 8px)) 0 0;
98
+ }
99
+
100
+ .productContent {
101
+ flex: 1 1 auto;
102
+ display: flex;
103
+ flex-direction: column;
104
+ gap: 6px;
105
+ padding: 8px;
106
+ }
107
+
108
+ .productParent {
109
+ text-transform: uppercase;
110
+ font-size: 10px;
111
+ }
112
+
113
+ .productPageTitle {
114
+ font-weight: 700;
115
+ font-size: 14px;
116
+ line-height: 1;
117
+ }
118
+
119
+ .productTitle {
120
+ font-weight: 700;
121
+ font-size: 13px;
122
+ line-height: 1;
123
+ }
124
+
125
+ .productText {
126
+ font-size: 11px;
127
+ }
128
+
129
+ .productPrice {
130
+ position: absolute;
131
+ top: 6px;
132
+ left: 6px;
133
+ max-width: calc(100% - 12px);
134
+ padding: 4px;
135
+ color: var(--ds-grey-100, #f5f5f5);
136
+ background-color: var(--ds-secondary, var(--ds-blue-400, #4177f6));
137
+ font-weight: 700;
138
+ font-size: 12px;
139
+ border-radius: var(--ds-radius-100, 6px);
140
+ }
141
+
142
+ .productPrice:emtpy {
143
+ display: none;
144
+ }
145
+
146
+ .productTime {
147
+ font-size: 8px;
148
+ text-transform: uppercase;
149
+ font-weight: 700;
150
+ }
151
+
152
+ .otherProducts {
153
+ grid-column: 1 / -1;
154
+ position: sticky;
155
+ bottom: 16px;
156
+ display: flex;
157
+ justify-content: center;
158
+ }
159
+
160
+ @media (min-width: 730px) {
161
+ .otherProducts {
162
+ display: none;
163
+ }
164
+ }
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ export default function useGoogleSearch(): {
3
+ text: string;
4
+ setText: import("react").Dispatch<import("react").SetStateAction<string>>;
5
+ facet: number;
6
+ setFacet: import("react").Dispatch<import("react").SetStateAction<number>>;
7
+ search: import("react-async-hook").UseAsyncReturn<any, any[]>;
8
+ };
9
+ //# sourceMappingURL=use-google-search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-google-search.d.ts","sourceRoot":"","sources":["../../../../../src/lbm/components/instant-search/hooks/use-google-search.ts"],"names":[],"mappings":";AAGA,MAAM,CAAC,OAAO,UAAU,eAAe;;;;;;EAItC"}
@@ -0,0 +1,7 @@
1
+ import useDebouncedSearch from "./use-debounced-search";
2
+ import * as GoogleAPI from "../services/google-search-api";
3
+ export default function useGoogleSearch() {
4
+ return useDebouncedSearch(async (query) => {
5
+ return GoogleAPI.fetchOTResults(query);
6
+ });
7
+ }
@@ -55,22 +55,23 @@ type RequestParams = {
55
55
  per_page: number;
56
56
  q: string;
57
57
  };
58
+ type SiteResults = {
59
+ facet_counts?: any[];
60
+ found?: number;
61
+ found_docs?: number;
62
+ grouped_hits?: GroupedHit[];
63
+ out_of?: number;
64
+ page?: number;
65
+ request_params?: RequestParams;
66
+ search_cutoff?: boolean;
67
+ search_time_ms?: number;
68
+ };
58
69
  type Props = {
59
70
  lang: string;
60
71
  text: string;
61
72
  facet: number;
62
73
  setFacet: (facet: number) => void;
63
- results: {
64
- facet_counts?: any[];
65
- found?: number;
66
- found_docs?: number;
67
- grouped_hits?: GroupedHit[];
68
- out_of?: number;
69
- page?: number;
70
- request_params?: RequestParams;
71
- search_cutoff?: boolean;
72
- search_time_ms?: number;
73
- };
74
+ results: SiteResults;
74
75
  sendPlausibleGoal: (path: string) => void;
75
76
  loading: boolean;
76
77
  };
@@ -1 +1 @@
1
- {"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/instant-search/results.tsx"],"names":[],"mappings":"AASA,KAAK,QAAQ,GAAG;IACd,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KA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G;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,EAAE,GAAG,EAAE,CAAC;CACb,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IAEd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,OAAO,EAAE;QACP,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;QAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,cAAc,CAAC,EAAE,aAAa,CAAC;QAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IAEF,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAC9B,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,OAAO,EACP,OAAO,EACP,iBAAiB,GAClB,EAAE,KAAK,2CAuGP"}
1
+ {"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/instant-search/results.tsx"],"names":[],"mappings":"AAWA,KAAK,QAAQ,GAAG;IACd,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ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message from "./services/messages";
7
7
  import css from "./results.module.css";
8
8
  import Faqs from "./faqs";
9
9
  import Widgets from "./widgets";
10
+ import useGoogleSearch from "./hooks/use-google-search";
11
+ import GoogleProducts from "./google-results";
10
12
  export default function Results({ lang, text, facet, setFacet, results, loading, sendPlausibleGoal, }) {
11
13
  const ref = React.useRef(null);
12
14
  const [faqsMaximized, setFaqsMaximized] = React.useState(false);
15
+ const { setText: setGoogleText, search: googleSearch } = useGoogleSearch();
13
16
  const { grouped_hits: groupedHits = [] } = results || {};
14
17
  const flattenedHits = groupedHits.reduce((acc, group) => {
15
18
  return [...acc, ...group.hits];
@@ -27,8 +30,19 @@ export default function Results({ lang, text, facet, setFacet, results, loading,
27
30
  document: [],
28
31
  "msem-widget": [],
29
32
  });
33
+ React.useEffect(() => {
34
+ const runEffect = () => {
35
+ if (sortedHits.product.length < 4) {
36
+ setGoogleText(text);
37
+ }
38
+ else {
39
+ setGoogleText("");
40
+ }
41
+ };
42
+ runEffect();
43
+ }, [text, sortedHits, setGoogleText]);
30
44
  const { page: pages, product: products, information, faq: faqs, widget: widgets, document: documents, "msem-widget": msemWidgets, lodging: lodgings, } = sortedHits;
31
45
  const isOtherResultsEmpty = !(pages.length || information.length);
32
46
  const countLabel = message(lang, "results");
33
- return (_jsx("div", { className: css.results, children: (loading || text.length > 0) && (_jsxs("div", { className: css.inner, children: [_jsxs("div", { ref: ref, className: css.left, children: [_jsxs("div", { className: css.facet, children: [countLabel, " ", _jsx(FacetSwitch, { lang: lang, facet: facet, setFacet: setFacet })] }), _jsx(Links, { linksTitle: message(lang, "pages"), icon: "File", links: pages, loading: loading, sendPlausibleGoal: sendPlausibleGoal }), _jsx(Links, { linksTitle: message(lang, "documents"), icon: "FileText", links: documents, loading: loading, sendPlausibleGoal: sendPlausibleGoal }), _jsx(Links, { linksTitle: message(lang, "information"), icon: "Info", links: information, loading: loading, sendPlausibleGoal: sendPlausibleGoal })] }), _jsxs("div", { className: css.right, children: [_jsx(Widgets, { lang: lang, widgets: [...widgets, ...msemWidgets, ...lodgings], loading: loading, sendPlausibleGoal: sendPlausibleGoal, faqsMaximized: faqsMaximized }), _jsx(Products, { lang: lang, products: products, loading: loading, sendPlausibleGoal: sendPlausibleGoal, otherResultsRef: ref, isOtherResultsEmpty: isOtherResultsEmpty, faqsMaximized: faqsMaximized }), _jsx(Faqs, { lang: lang, faqs: faqs, loading: loading, sendPlausibleGoal: sendPlausibleGoal, maximized: faqsMaximized, setMaximized: setFaqsMaximized })] })] })) }));
47
+ return (_jsx("div", { className: css.results, children: (loading || text.length > 0) && (_jsxs("div", { className: css.inner, children: [_jsxs("div", { ref: ref, className: css.left, children: [_jsxs("div", { className: css.facet, children: [countLabel, " ", _jsx(FacetSwitch, { lang: lang, facet: facet, setFacet: setFacet })] }), _jsx(Links, { linksTitle: message(lang, "pages"), icon: "File", links: pages, loading: loading, sendPlausibleGoal: sendPlausibleGoal }), _jsx(Links, { linksTitle: message(lang, "documents"), icon: "FileText", links: documents, loading: loading, sendPlausibleGoal: sendPlausibleGoal }), _jsx(Links, { linksTitle: message(lang, "information"), icon: "Info", links: information, loading: loading, sendPlausibleGoal: sendPlausibleGoal })] }), _jsxs("div", { className: css.right, children: [_jsx(Widgets, { lang: lang, widgets: [...widgets, ...msemWidgets, ...lodgings], loading: loading, sendPlausibleGoal: sendPlausibleGoal, faqsMaximized: faqsMaximized }), _jsx(Products, { lang: lang, products: products, loading: loading, sendPlausibleGoal: sendPlausibleGoal, otherResultsRef: ref, isOtherResultsEmpty: isOtherResultsEmpty, faqsMaximized: faqsMaximized }), _jsx(GoogleProducts, { products: googleSearch.result, loading: googleSearch.loading, sendPlausibleGoal: sendPlausibleGoal, faqsMaximized: faqsMaximized }), _jsx(Faqs, { lang: lang, faqs: faqs, loading: loading, sendPlausibleGoal: sendPlausibleGoal, maximized: faqsMaximized, setMaximized: setFaqsMaximized })] })] })) }));
34
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../../src/lbm/components/instant-search/services/api.ts"],"names":[],"mappings":"AAgCA,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAW,EACvB,OAAO,GAAE,MAA8B,EACvC,cAAc,CAAC,EAAE,MAAM,EACvB,QAAQ,CAAC,EAAE,OAAO,gBAenB;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAW,EACvB,OAAO,GAAE,MAA8B,EACvC,cAAc,CAAC,EAAE,MAAM,EACvB,QAAQ,CAAC,EAAE,OAAO,gBAanB"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../../src/lbm/components/instant-search/services/api.ts"],"names":[],"mappings":"AAkCA,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAW,EACvB,OAAO,GAAE,MAA8B,EACvC,cAAc,CAAC,EAAE,MAAM,EACvB,QAAQ,CAAC,EAAE,OAAO,gBAenB;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAW,EACvB,OAAO,GAAE,MAA8B,EACvC,cAAc,CAAC,EAAE,MAAM,EACvB,QAAQ,CAAC,EAAE,OAAO,gBAanB"}
@@ -1,5 +1,7 @@
1
1
  import * as Fetcher from "../../../../common/utils/fetcher";
2
- const api = "https://search.ublo.app/api";
2
+ import getConfig from "next/config";
3
+ const { publicRuntimeConfig } = getConfig();
4
+ const { searchApi: api } = publicRuntimeConfig;
3
5
  const QUERY_ITEMS = [
4
6
  "title",
5
7
  "text",
@@ -0,0 +1,18 @@
1
+ export type GoogleSearchResults = {
2
+ items: {
3
+ htmlTitle: string;
4
+ link: string;
5
+ displayLink: string;
6
+ htmlSnippet: string;
7
+ pageMap: {
8
+ cse_image: {
9
+ src: string;
10
+ }[];
11
+ cse_thumbnail: {
12
+ src: string;
13
+ }[];
14
+ };
15
+ }[];
16
+ };
17
+ export declare function fetchOTResults(query: string): Promise<any[] | GoogleSearchResults>;
18
+ //# sourceMappingURL=google-search-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-search-api.d.ts","sourceRoot":"","sources":["../../../../../src/lbm/components/instant-search/services/google-search-api.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE;QACL,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE;YACP,SAAS,EAAE;gBACT,GAAG,EAAE,MAAM,CAAC;aACb,EAAE,CAAC;YACJ,aAAa,EAAE;gBACb,GAAG,EAAE,MAAM,CAAC;aACb,EAAE,CAAC;SACL,CAAC;KACH,EAAE,CAAC;CACL,CAAC;AAEF,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,wCAYjD"}
@@ -0,0 +1,18 @@
1
+ import * as Fetcher from "../../../../common/utils/fetcher";
2
+ import getConfig from "next/config";
3
+ const { serverRuntimeConfig, publicRuntimeConfig } = getConfig();
4
+ const { googleApiKey, googleApiCx } = serverRuntimeConfig;
5
+ const { googleApi, googleSites } = publicRuntimeConfig;
6
+ export async function fetchOTResults(query) {
7
+ if (googleSites.length === 0 || !googleApi || !googleApiCx || !googleApiKey)
8
+ return [];
9
+ const endpoint = `${googleApi}/customsearch/v1`;
10
+ return Fetcher.get(endpoint, {
11
+ q: query,
12
+ key: googleApiKey,
13
+ cx: googleApiCx,
14
+ siteSearch: googleSites[0],
15
+ siteSearchType: "i",
16
+ num: 3,
17
+ });
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.36.14",
3
+ "version": "1.36.16",
4
4
  "peerDependencies": {
5
5
  "dt-design-system": "^3.9.9",
6
6
  "leaflet": "^1.9.1",