@searchcraft/react-sdk 0.1.0 → 0.1.2
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/README.md +154 -1
- package/dist/index.d.ts +22 -18
- package/dist/index.js +448 -379
- package/dist/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,75 +1,68 @@
|
|
|
1
|
-
import { jsx as n, jsxs as
|
|
2
|
-
import
|
|
3
|
-
var
|
|
4
|
-
class
|
|
5
|
-
constructor(
|
|
6
|
-
if (
|
|
1
|
+
import { jsx as n, jsxs as u, Fragment as k } from "react/jsx-runtime";
|
|
2
|
+
import Q, { useState as g, useContext as Z, useEffect as K } from "react";
|
|
3
|
+
var U = Object.defineProperty, H = (t, a, o) => a in t ? U(t, a, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[a] = o, N = (t, a, o) => H(t, typeof a != "symbol" ? a + "" : a, o);
|
|
4
|
+
class Jn {
|
|
5
|
+
constructor(a) {
|
|
6
|
+
if (N(this, "config"), N(this, "search", async (o) => {
|
|
7
7
|
try {
|
|
8
|
-
this.config.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}, a = {
|
|
8
|
+
const s = this.config.index.join(","), i = `${this.config.endpointURL}/search`, r = {
|
|
9
|
+
query: o.query,
|
|
10
|
+
mode: o.mode,
|
|
11
|
+
app: s
|
|
12
|
+
}, e = {
|
|
14
13
|
method: "POST",
|
|
15
14
|
headers: {
|
|
16
15
|
"Content-Type": "application/json",
|
|
17
|
-
|
|
16
|
+
"Access-Control-Allow-Origin": "*",
|
|
17
|
+
Authorization: this.config.apiKey ? `${this.config.apiKey}` : ""
|
|
18
18
|
},
|
|
19
19
|
body: JSON.stringify(r)
|
|
20
|
-
}
|
|
21
|
-
return
|
|
22
|
-
} catch (
|
|
23
|
-
return
|
|
24
|
-
} finally {
|
|
25
|
-
this.config.setIsRequestingFalse();
|
|
20
|
+
};
|
|
21
|
+
return await (await fetch(i, e)).json();
|
|
22
|
+
} catch (s) {
|
|
23
|
+
return s;
|
|
26
24
|
}
|
|
27
|
-
}), !
|
|
28
|
-
throw new Error(
|
|
29
|
-
|
|
30
|
-
);
|
|
31
|
-
this.config = e, this.searchResult = null;
|
|
25
|
+
}), !a.endpointURL || !a.index)
|
|
26
|
+
throw new Error("Endpoint URL and Index value(s) must be provided");
|
|
27
|
+
this.config = a;
|
|
32
28
|
}
|
|
33
29
|
}
|
|
34
|
-
const
|
|
30
|
+
const J = {
|
|
35
31
|
error: null,
|
|
36
|
-
index: "",
|
|
32
|
+
index: [""],
|
|
37
33
|
isRequesting: !1,
|
|
38
34
|
mode: "fuzzy",
|
|
39
35
|
query: "",
|
|
40
36
|
setQuery: (t) => t,
|
|
41
37
|
search: async () => null
|
|
42
|
-
},
|
|
38
|
+
}, F = Q.createContext(J), Gn = ({
|
|
43
39
|
children: t,
|
|
44
|
-
|
|
40
|
+
searchcraft: a
|
|
45
41
|
}) => {
|
|
46
|
-
const s =
|
|
47
|
-
()
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}),
|
|
52
|
-
[e]
|
|
53
|
-
), [c, o] = y(""), [r, a] = y(!1), i = {
|
|
42
|
+
const [o, s] = g(""), [i, r] = g(!1), [e, l] = g(null), c = async () => {
|
|
43
|
+
r(!0);
|
|
44
|
+
const _ = await a.search({ query: o, mode: "fuzzy" });
|
|
45
|
+
l(_), r(!1);
|
|
46
|
+
}, h = {
|
|
54
47
|
error: null,
|
|
55
|
-
index:
|
|
56
|
-
isRequesting:
|
|
48
|
+
index: a.config.index,
|
|
49
|
+
isRequesting: i,
|
|
57
50
|
mode: "fuzzy",
|
|
58
|
-
query:
|
|
59
|
-
search:
|
|
60
|
-
|
|
61
|
-
setQuery:
|
|
51
|
+
query: o,
|
|
52
|
+
search: c,
|
|
53
|
+
searchResults: e,
|
|
54
|
+
setQuery: s
|
|
62
55
|
};
|
|
63
|
-
return /* @__PURE__ */ n(
|
|
64
|
-
},
|
|
65
|
-
formLTR:
|
|
66
|
-
formRTL:
|
|
67
|
-
searchContainer:
|
|
56
|
+
return /* @__PURE__ */ n(F.Provider, { value: h, children: t });
|
|
57
|
+
}, v = () => Z(F), G = "_formLTR_dvuqa_5", V = "_formRTL_dvuqa_9", X = "_searchContainer_dvuqa_13", L = {
|
|
58
|
+
formLTR: G,
|
|
59
|
+
formRTL: V,
|
|
60
|
+
searchContainer: X
|
|
68
61
|
};
|
|
69
|
-
function
|
|
62
|
+
function Y(t) {
|
|
70
63
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
71
64
|
}
|
|
72
|
-
var
|
|
65
|
+
var D = { exports: {} };
|
|
73
66
|
/*!
|
|
74
67
|
Copyright (c) 2018 Jed Watson.
|
|
75
68
|
Licensed under the MIT License (MIT), see
|
|
@@ -77,386 +70,434 @@ var F = { exports: {} };
|
|
|
77
70
|
*/
|
|
78
71
|
(function(t) {
|
|
79
72
|
(function() {
|
|
80
|
-
var
|
|
81
|
-
function
|
|
82
|
-
for (var r = "",
|
|
83
|
-
var
|
|
84
|
-
|
|
73
|
+
var a = {}.hasOwnProperty;
|
|
74
|
+
function o() {
|
|
75
|
+
for (var r = "", e = 0; e < arguments.length; e++) {
|
|
76
|
+
var l = arguments[e];
|
|
77
|
+
l && (r = i(r, s(l)));
|
|
85
78
|
}
|
|
86
79
|
return r;
|
|
87
80
|
}
|
|
88
|
-
function
|
|
81
|
+
function s(r) {
|
|
89
82
|
if (typeof r == "string" || typeof r == "number")
|
|
90
83
|
return r;
|
|
91
84
|
if (typeof r != "object")
|
|
92
85
|
return "";
|
|
93
86
|
if (Array.isArray(r))
|
|
94
|
-
return
|
|
87
|
+
return o.apply(null, r);
|
|
95
88
|
if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
|
|
96
89
|
return r.toString();
|
|
97
|
-
var
|
|
98
|
-
for (var
|
|
99
|
-
|
|
100
|
-
return
|
|
90
|
+
var e = "";
|
|
91
|
+
for (var l in r)
|
|
92
|
+
a.call(r, l) && r[l] && (e = i(e, l));
|
|
93
|
+
return e;
|
|
101
94
|
}
|
|
102
|
-
function
|
|
103
|
-
return
|
|
95
|
+
function i(r, e) {
|
|
96
|
+
return e ? r ? r + " " + e : r + e : r;
|
|
104
97
|
}
|
|
105
|
-
t.exports ? (
|
|
98
|
+
t.exports ? (o.default = o, t.exports = o) : window.classNames = o;
|
|
106
99
|
})();
|
|
107
|
-
})(
|
|
108
|
-
var O =
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
},
|
|
100
|
+
})(D);
|
|
101
|
+
var O = D.exports;
|
|
102
|
+
const p = /* @__PURE__ */ Y(O), nn = "_button_8jqm2_5", tn = "_spinnerMarginRight_8jqm2_26", en = "_spinnerMarginLeft_8jqm2_32", rn = "_buttonLabel_8jqm2_38", an = "_rightandback_8jqm2_1", b = {
|
|
103
|
+
button: nn,
|
|
104
|
+
spinnerMarginRight: tn,
|
|
105
|
+
spinnerMarginLeft: en,
|
|
106
|
+
buttonLabel: rn,
|
|
107
|
+
rightandback: an
|
|
108
|
+
}, on = "_spinnerContainer_1noam_1", sn = "_spinnerDark_1noam_7", cn = "_spinning_1noam_1", ln = "_spinnerLight_1noam_16", S = {
|
|
109
|
+
spinnerContainer: on,
|
|
110
|
+
spinnerDark: sn,
|
|
111
|
+
spinning: cn,
|
|
112
|
+
spinnerLight: ln
|
|
113
|
+
}, x = () => /* @__PURE__ */ n("div", { className: S.spinnerContainer, children: /* @__PURE__ */ n("div", { className: S.spinnerLight }) }), I = () => /* @__PURE__ */ n("div", { className: S.spinnerContainer, children: /* @__PURE__ */ n("div", { className: S.spinnerDark }) }), w = ({
|
|
121
114
|
className: t,
|
|
122
|
-
iconElement:
|
|
123
|
-
iconOnly:
|
|
124
|
-
iconPosition:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
),
|
|
138
|
-
!s && /* @__PURE__ */ l(
|
|
139
|
-
"button",
|
|
140
|
-
{
|
|
141
|
-
className: _(b.button, t),
|
|
142
|
-
onClick: a,
|
|
143
|
-
type: "submit",
|
|
144
|
-
children: [
|
|
145
|
-
c === "left" && o ? /* @__PURE__ */ n("div", { className: b.spinnerMarginRight, children: /* @__PURE__ */ n(k, {}) }) : e,
|
|
146
|
-
/* @__PURE__ */ n(
|
|
147
|
-
"span",
|
|
148
|
-
{
|
|
149
|
-
className: _(
|
|
150
|
-
o && b.buttonLabel,
|
|
151
|
-
t
|
|
152
|
-
),
|
|
153
|
-
children: r
|
|
154
|
-
}
|
|
115
|
+
iconElement: a,
|
|
116
|
+
iconOnly: o = !1,
|
|
117
|
+
iconPosition: s = "left",
|
|
118
|
+
label: i = "Search",
|
|
119
|
+
onClick: r
|
|
120
|
+
}) => {
|
|
121
|
+
const { isRequesting: e } = v();
|
|
122
|
+
return /* @__PURE__ */ u(k, { children: [
|
|
123
|
+
o && /* @__PURE__ */ n(
|
|
124
|
+
"button",
|
|
125
|
+
{
|
|
126
|
+
className: p(
|
|
127
|
+
b.button,
|
|
128
|
+
t,
|
|
129
|
+
".searchcraft-button"
|
|
155
130
|
),
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
] }), un = "_errorMessage_12dc9_5", hn = {
|
|
161
|
-
errorMessage: un
|
|
162
|
-
}, pn = ({
|
|
163
|
-
className: t,
|
|
164
|
-
errorMessage: e
|
|
165
|
-
}) => /* @__PURE__ */ n("p", { className: _(hn.errorMessage, t), children: e || "Search term is required." }), dn = "_inputCaption_hmjqk_5", _n = "_inputCaptionError_hmjqk_14", mn = "_inputCaptionRTL_hmjqk_24", Cn = "_inputCaptionErrorRTL_hmjqk_34", v = {
|
|
166
|
-
inputCaption: dn,
|
|
167
|
-
inputCaptionError: _n,
|
|
168
|
-
inputCaptionRTL: mn,
|
|
169
|
-
inputCaptionErrorRTL: Cn
|
|
170
|
-
}, M = ({
|
|
171
|
-
error: t = !1,
|
|
172
|
-
inputCaptionClassName: e,
|
|
173
|
-
inputCaptionValue: s = "Enter Search",
|
|
174
|
-
rightToLeftOrientation: c = !1
|
|
175
|
-
}) => c ? /* @__PURE__ */ n(
|
|
176
|
-
"p",
|
|
177
|
-
{
|
|
178
|
-
className: _(
|
|
179
|
-
t ? v.inputCaptionErrorRTL : v.inputCaptionRTL,
|
|
180
|
-
e
|
|
181
|
-
),
|
|
182
|
-
children: s
|
|
183
|
-
}
|
|
184
|
-
) : /* @__PURE__ */ n(
|
|
185
|
-
"p",
|
|
186
|
-
{
|
|
187
|
-
className: _(
|
|
188
|
-
t ? v.inputCaptionError : v.inputCaption,
|
|
189
|
-
e
|
|
131
|
+
onClick: r,
|
|
132
|
+
type: "submit",
|
|
133
|
+
children: e ? /* @__PURE__ */ n(I, {}) : a
|
|
134
|
+
}
|
|
190
135
|
),
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
136
|
+
!o && /* @__PURE__ */ u(
|
|
137
|
+
"button",
|
|
138
|
+
{
|
|
139
|
+
className: p(
|
|
140
|
+
b.button,
|
|
141
|
+
t,
|
|
142
|
+
".searchcraft-button"
|
|
143
|
+
),
|
|
144
|
+
onClick: r,
|
|
145
|
+
type: "submit",
|
|
146
|
+
children: [
|
|
147
|
+
s === "left" && e ? /* @__PURE__ */ n("div", { className: b.spinnerMarginRight, children: /* @__PURE__ */ n(I, {}) }) : a,
|
|
148
|
+
/* @__PURE__ */ n(
|
|
149
|
+
"span",
|
|
150
|
+
{
|
|
151
|
+
className: p(
|
|
152
|
+
e && b.buttonLabel,
|
|
153
|
+
t,
|
|
154
|
+
".searchcraft-button-label"
|
|
155
|
+
),
|
|
156
|
+
children: i
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
s === "right" && e ? /* @__PURE__ */ n("div", { className: b.spinnerMarginLeft, children: /* @__PURE__ */ n(I, {}) }) : a
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
] });
|
|
164
|
+
}, un = "_errorMessage_12dc9_5", pn = {
|
|
165
|
+
errorMessage: un
|
|
166
|
+
}, hn = ({ className: t, errorMessage: a }) => /* @__PURE__ */ n("p", { className: p(pn.errorMessage, t), children: a || "Search term is required." }), dn = "_inputContainerLTR_s1rq8_5", _n = "_inputContainerRTL_s1rq8_9", Cn = "_inputLTR_s1rq8_14", fn = "_inputRTL_s1rq8_35", mn = "_inputErrorLTR_s1rq8_57", Ln = "_inputErrorRTL_s1rq8_82", m = {
|
|
167
|
+
inputContainerLTR: dn,
|
|
168
|
+
inputContainerRTL: _n,
|
|
169
|
+
inputLTR: Cn,
|
|
170
|
+
inputRTL: fn,
|
|
171
|
+
inputErrorLTR: mn,
|
|
172
|
+
inputErrorRTL: Ln
|
|
173
|
+
}, Rn = "_inputClearButtonLTR_t63ei_5", bn = "_inputClearButtonRTL_t63ei_19", E = {
|
|
174
|
+
inputClearButtonLTR: Rn,
|
|
175
|
+
inputClearButtonRTL: bn
|
|
176
|
+
}, M = () => /* @__PURE__ */ u("svg", { width: "22", height: "22", viewBox: "0 0 22 22", fill: "none", children: [
|
|
177
|
+
/* @__PURE__ */ n("title", { children: "Searchcraft Clear Input Icon" }),
|
|
198
178
|
/* @__PURE__ */ n(
|
|
199
179
|
"path",
|
|
200
180
|
{
|
|
201
|
-
d: "
|
|
202
|
-
stroke: "
|
|
181
|
+
d: "M14 8L8 14M8 8L14 14M21 11C21 16.5228 16.5228 21 11 21C5.47715 21 1 16.5228 1 11C1 5.47715 5.47715 1 11 1C16.5228 1 21 5.47715 21 11Z",
|
|
182
|
+
stroke: "black",
|
|
203
183
|
strokeWidth: "1.5",
|
|
204
184
|
strokeLinecap: "round",
|
|
205
185
|
strokeLinejoin: "round"
|
|
206
186
|
}
|
|
207
187
|
)
|
|
208
|
-
] }),
|
|
209
|
-
/* @__PURE__ */ n("title", { children: "Searchcraft
|
|
188
|
+
] }), q = () => /* @__PURE__ */ u("svg", { width: "20", height: "21", viewBox: "0 0 20 21", fill: "none", children: [
|
|
189
|
+
/* @__PURE__ */ n("title", { children: "Searchcraft Arrow Right Icon" }),
|
|
210
190
|
/* @__PURE__ */ n(
|
|
211
191
|
"path",
|
|
212
192
|
{
|
|
213
|
-
d: "
|
|
193
|
+
d: "M7.5 15.0444L12.5 10.0444L7.5 5.04443",
|
|
214
194
|
stroke: "#737373",
|
|
215
195
|
strokeWidth: "1.5",
|
|
216
196
|
strokeLinecap: "round",
|
|
217
197
|
strokeLinejoin: "round"
|
|
218
198
|
}
|
|
219
199
|
)
|
|
220
|
-
] }),
|
|
200
|
+
] }), B = ({
|
|
201
|
+
onClearInput: t,
|
|
202
|
+
rightToLeftOrientation: a = !1
|
|
203
|
+
}) => {
|
|
204
|
+
const { isRequesting: o } = v();
|
|
205
|
+
return a ? /* @__PURE__ */ n(
|
|
206
|
+
"button",
|
|
207
|
+
{
|
|
208
|
+
className: p(
|
|
209
|
+
E.inputClearButtonRTL,
|
|
210
|
+
".sc-clear-input-button-rtl"
|
|
211
|
+
),
|
|
212
|
+
onClick: t,
|
|
213
|
+
type: "button",
|
|
214
|
+
children: o ? /* @__PURE__ */ n(x, {}) : /* @__PURE__ */ n(M, {})
|
|
215
|
+
}
|
|
216
|
+
) : /* @__PURE__ */ n(
|
|
217
|
+
"button",
|
|
218
|
+
{
|
|
219
|
+
className: p(
|
|
220
|
+
E.inputClearButtonLTR,
|
|
221
|
+
".sc-clear-input-button-ltr"
|
|
222
|
+
),
|
|
223
|
+
onClick: t,
|
|
224
|
+
type: "button",
|
|
225
|
+
children: o ? /* @__PURE__ */ n(x, {}) : /* @__PURE__ */ n(M, {})
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
}, gn = "_inputCaptionLTR_xoy9r_5", vn = "_inputCaptionErrorLTR_xoy9r_14", Tn = "_inputCaptionRTL_xoy9r_24", yn = "_inputCaptionErrorRTL_xoy9r_34", T = {
|
|
229
|
+
inputCaptionLTR: gn,
|
|
230
|
+
inputCaptionErrorLTR: vn,
|
|
231
|
+
inputCaptionRTL: Tn,
|
|
232
|
+
inputCaptionErrorRTL: yn
|
|
233
|
+
}, j = ({
|
|
221
234
|
error: t = !1,
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
235
|
+
inputCaptionClassName: a,
|
|
236
|
+
inputCaptionValue: o = "Enter Search",
|
|
237
|
+
rightToLeftOrientation: s = !1
|
|
238
|
+
}) => s ? /* @__PURE__ */ n(
|
|
239
|
+
"p",
|
|
225
240
|
{
|
|
226
|
-
className:
|
|
227
|
-
|
|
241
|
+
className: p(
|
|
242
|
+
t ? T.inputCaptionErrorRTL : T.inputCaptionRTL,
|
|
243
|
+
a
|
|
244
|
+
),
|
|
245
|
+
children: o
|
|
228
246
|
}
|
|
229
247
|
) : /* @__PURE__ */ n(
|
|
230
|
-
"
|
|
248
|
+
"p",
|
|
231
249
|
{
|
|
232
|
-
className:
|
|
233
|
-
|
|
250
|
+
className: p(
|
|
251
|
+
t ? T.inputCaptionErrorLTR : T.inputCaptionLTR,
|
|
252
|
+
a
|
|
253
|
+
),
|
|
254
|
+
children: o
|
|
234
255
|
}
|
|
235
|
-
),
|
|
236
|
-
|
|
256
|
+
), Sn = "_inputIconLTR_cusap_5", In = "_inputIconRTL_cusap_13", y = {
|
|
257
|
+
inputIconLTR: Sn,
|
|
258
|
+
inputIconRTL: In
|
|
259
|
+
}, kn = () => /* @__PURE__ */ u("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: [
|
|
260
|
+
/* @__PURE__ */ n("title", { children: "Searchcraft Search Icon" }),
|
|
237
261
|
/* @__PURE__ */ n(
|
|
238
262
|
"path",
|
|
239
263
|
{
|
|
240
|
-
d: "
|
|
241
|
-
stroke: "
|
|
264
|
+
d: "M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z",
|
|
265
|
+
stroke: "#404040",
|
|
242
266
|
strokeWidth: "1.5",
|
|
243
267
|
strokeLinecap: "round",
|
|
244
268
|
strokeLinejoin: "round"
|
|
245
269
|
}
|
|
246
270
|
)
|
|
247
|
-
] }),
|
|
248
|
-
/* @__PURE__ */ n("title", { children: "Searchcraft
|
|
271
|
+
] }), Nn = () => /* @__PURE__ */ u("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: [
|
|
272
|
+
/* @__PURE__ */ n("title", { children: "Searchcraft Error Search Icon" }),
|
|
249
273
|
/* @__PURE__ */ n(
|
|
250
274
|
"path",
|
|
251
275
|
{
|
|
252
|
-
d: "
|
|
276
|
+
d: "M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z",
|
|
253
277
|
stroke: "#737373",
|
|
254
278
|
strokeWidth: "1.5",
|
|
255
279
|
strokeLinecap: "round",
|
|
256
280
|
strokeLinejoin: "round"
|
|
257
281
|
}
|
|
258
282
|
)
|
|
259
|
-
] }),
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
isRequesting: e = !1,
|
|
265
|
-
onClearInput: s,
|
|
266
|
-
rightToLeftOrientation: c = !1
|
|
267
|
-
}) => c ? /* @__PURE__ */ n(
|
|
268
|
-
"button",
|
|
283
|
+
] }), $ = ({
|
|
284
|
+
error: t = !1,
|
|
285
|
+
rightToLeftOrientation: a = !1
|
|
286
|
+
}) => t ? /* @__PURE__ */ n(
|
|
287
|
+
"div",
|
|
269
288
|
{
|
|
270
|
-
className:
|
|
271
|
-
|
|
272
|
-
type: "button",
|
|
273
|
-
children: e ? /* @__PURE__ */ n(N, {}) : /* @__PURE__ */ n(w, {})
|
|
289
|
+
className: a ? y.inputIconRTL : y.inputIconLTR,
|
|
290
|
+
children: /* @__PURE__ */ n(Nn, {})
|
|
274
291
|
}
|
|
275
292
|
) : /* @__PURE__ */ n(
|
|
276
|
-
"
|
|
293
|
+
"div",
|
|
277
294
|
{
|
|
278
|
-
className:
|
|
279
|
-
|
|
280
|
-
type: "button",
|
|
281
|
-
children: e ? /* @__PURE__ */ n(N, {}) : /* @__PURE__ */ n(w, {})
|
|
295
|
+
className: a ? y.inputIconRTL : y.inputIconLTR,
|
|
296
|
+
children: /* @__PURE__ */ n(kn, {})
|
|
282
297
|
}
|
|
283
|
-
),
|
|
284
|
-
inputContainer: yn,
|
|
285
|
-
inputContainerRTL: In,
|
|
286
|
-
input: Sn,
|
|
287
|
-
inputRTL: kn,
|
|
288
|
-
inputError: Tn,
|
|
289
|
-
inputErrorRTL: Nn
|
|
290
|
-
}, P = ({
|
|
298
|
+
), A = ({
|
|
291
299
|
error: t = !1,
|
|
292
|
-
formClassName:
|
|
293
|
-
inputCaptionClassName:
|
|
294
|
-
inputClassName:
|
|
295
|
-
inputCaptionValue:
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
rightToLeftOrientation: u = !1,
|
|
300
|
+
formClassName: a = "",
|
|
301
|
+
inputCaptionClassName: o = "",
|
|
302
|
+
inputClassName: s = "",
|
|
303
|
+
inputCaptionValue: i = "",
|
|
304
|
+
onClearInput: r,
|
|
305
|
+
onSearchInputChange: e,
|
|
306
|
+
placeholderValue: l = "Enter Search",
|
|
307
|
+
rightToLeftOrientation: c = !1,
|
|
301
308
|
query: h = ""
|
|
302
309
|
}) => {
|
|
303
|
-
const
|
|
304
|
-
return /* @__PURE__ */ n(
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
310
|
+
const _ = c ? m.inputContainerRTL : m.inputContainerLTR;
|
|
311
|
+
return /* @__PURE__ */ n(
|
|
312
|
+
"div",
|
|
313
|
+
{
|
|
314
|
+
className: p(
|
|
315
|
+
_,
|
|
316
|
+
a,
|
|
317
|
+
"searchcraft-input-form"
|
|
318
|
+
),
|
|
319
|
+
children: c ? /* @__PURE__ */ u(k, { children: [
|
|
320
|
+
/* @__PURE__ */ n(
|
|
321
|
+
"input",
|
|
322
|
+
{
|
|
323
|
+
className: p(
|
|
324
|
+
t ? m.inputErrorRTL : m.inputRTL,
|
|
325
|
+
s,
|
|
326
|
+
"searchcraft-input"
|
|
327
|
+
),
|
|
328
|
+
id: "searchcraft-input-id",
|
|
329
|
+
onChange: e,
|
|
330
|
+
placeholder: l,
|
|
331
|
+
type: "text",
|
|
332
|
+
value: h
|
|
333
|
+
}
|
|
311
334
|
),
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
o && /* @__PURE__ */ n(
|
|
320
|
-
M,
|
|
321
|
-
{
|
|
322
|
-
inputCaptionClassName: s,
|
|
323
|
-
inputCaptionValue: o,
|
|
324
|
-
rightToLeftOrientation: u
|
|
325
|
-
}
|
|
326
|
-
),
|
|
327
|
-
h.length > 0 && /* @__PURE__ */ n(
|
|
328
|
-
B,
|
|
329
|
-
{
|
|
330
|
-
isRequesting: r,
|
|
331
|
-
onClearInput: a,
|
|
332
|
-
rightToLeftOrientation: u
|
|
333
|
-
}
|
|
334
|
-
),
|
|
335
|
-
/* @__PURE__ */ n(
|
|
336
|
-
x,
|
|
337
|
-
{
|
|
338
|
-
error: t,
|
|
339
|
-
rightToLeftOrientation: u
|
|
340
|
-
}
|
|
341
|
-
)
|
|
342
|
-
] }) : /* @__PURE__ */ l(T, { children: [
|
|
343
|
-
/* @__PURE__ */ n(
|
|
344
|
-
"input",
|
|
345
|
-
{
|
|
346
|
-
className: _(
|
|
347
|
-
t ? f.inputError : f.input,
|
|
348
|
-
c
|
|
335
|
+
i && /* @__PURE__ */ n(
|
|
336
|
+
j,
|
|
337
|
+
{
|
|
338
|
+
inputCaptionClassName: o,
|
|
339
|
+
inputCaptionValue: i,
|
|
340
|
+
rightToLeftOrientation: c
|
|
341
|
+
}
|
|
349
342
|
),
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
343
|
+
h.length > 0 && /* @__PURE__ */ n(
|
|
344
|
+
B,
|
|
345
|
+
{
|
|
346
|
+
onClearInput: r,
|
|
347
|
+
rightToLeftOrientation: c
|
|
348
|
+
}
|
|
349
|
+
),
|
|
350
|
+
/* @__PURE__ */ n(
|
|
351
|
+
$,
|
|
352
|
+
{
|
|
353
|
+
error: t,
|
|
354
|
+
rightToLeftOrientation: c
|
|
355
|
+
}
|
|
356
|
+
)
|
|
357
|
+
] }) : /* @__PURE__ */ u(k, { children: [
|
|
358
|
+
/* @__PURE__ */ n(
|
|
359
|
+
"input",
|
|
360
|
+
{
|
|
361
|
+
className: p(
|
|
362
|
+
t ? m.inputErrorLTR : m.inputLTR,
|
|
363
|
+
s,
|
|
364
|
+
"searchcraft-input"
|
|
365
|
+
),
|
|
366
|
+
id: "searchcraft-input-id",
|
|
367
|
+
onChange: e,
|
|
368
|
+
placeholder: l,
|
|
369
|
+
type: "text",
|
|
370
|
+
value: h
|
|
371
|
+
}
|
|
372
|
+
),
|
|
373
|
+
i && /* @__PURE__ */ n(
|
|
374
|
+
j,
|
|
375
|
+
{
|
|
376
|
+
inputCaptionClassName: o,
|
|
377
|
+
inputCaptionValue: i,
|
|
378
|
+
rightToLeftOrientation: c
|
|
379
|
+
}
|
|
380
|
+
),
|
|
381
|
+
h.length > 0 && /* @__PURE__ */ n(
|
|
382
|
+
B,
|
|
383
|
+
{
|
|
384
|
+
onClearInput: r,
|
|
385
|
+
rightToLeftOrientation: c
|
|
386
|
+
}
|
|
387
|
+
),
|
|
388
|
+
/* @__PURE__ */ n($, { error: t })
|
|
389
|
+
] })
|
|
390
|
+
}
|
|
391
|
+
);
|
|
392
|
+
}, xn = "_label_1euwf_5", wn = {
|
|
393
|
+
label: xn
|
|
394
|
+
}, z = ({
|
|
378
395
|
className: t,
|
|
379
|
-
label:
|
|
380
|
-
}) => /* @__PURE__ */ n(
|
|
396
|
+
label: a = "Enter Search"
|
|
397
|
+
}) => /* @__PURE__ */ n(
|
|
398
|
+
"label",
|
|
399
|
+
{
|
|
400
|
+
className: p(wn.label, t),
|
|
401
|
+
htmlFor: "searchcraft-input-id",
|
|
402
|
+
children: a
|
|
403
|
+
}
|
|
404
|
+
), Vn = ({
|
|
381
405
|
errorMessage: t,
|
|
382
|
-
handleSubmit:
|
|
383
|
-
labelForInput:
|
|
384
|
-
placeholderValue:
|
|
385
|
-
rightToLeftOrientation:
|
|
406
|
+
handleSubmit: a,
|
|
407
|
+
labelForInput: o = "Search",
|
|
408
|
+
placeholderValue: s = "Enter Search Term",
|
|
409
|
+
rightToLeftOrientation: i = !1
|
|
386
410
|
}) => {
|
|
387
|
-
const { query: r,
|
|
388
|
-
|
|
389
|
-
},
|
|
390
|
-
return /* @__PURE__ */
|
|
411
|
+
const { query: r, setQuery: e } = v(), [l, c] = g(!1), h = (C) => {
|
|
412
|
+
C.preventDefault(), r.trim() === "" ? c(!0) : (c(!1), a(r));
|
|
413
|
+
}, _ = (C) => e(C.target.value), f = () => e("");
|
|
414
|
+
return /* @__PURE__ */ u(
|
|
391
415
|
"form",
|
|
392
416
|
{
|
|
393
|
-
className:
|
|
417
|
+
className: i ? L.formRTL : L.formLTR,
|
|
394
418
|
onSubmit: h,
|
|
395
419
|
children: [
|
|
396
|
-
/* @__PURE__ */ n(
|
|
397
|
-
/* @__PURE__ */
|
|
398
|
-
|
|
420
|
+
/* @__PURE__ */ n(z, { label: o }),
|
|
421
|
+
/* @__PURE__ */ u("div", { className: L.searchContainer, children: [
|
|
422
|
+
i && /* @__PURE__ */ n(w, {}),
|
|
399
423
|
/* @__PURE__ */ n(
|
|
400
|
-
|
|
424
|
+
A,
|
|
401
425
|
{
|
|
402
|
-
error:
|
|
403
|
-
onClearInput:
|
|
404
|
-
onSearchInputChange:
|
|
405
|
-
placeholderValue:
|
|
426
|
+
error: l,
|
|
427
|
+
onClearInput: f,
|
|
428
|
+
onSearchInputChange: _,
|
|
429
|
+
placeholderValue: s,
|
|
406
430
|
query: r,
|
|
407
|
-
rightToLeftOrientation:
|
|
431
|
+
rightToLeftOrientation: i
|
|
408
432
|
}
|
|
409
433
|
),
|
|
410
|
-
!
|
|
434
|
+
!i && /* @__PURE__ */ n(w, {})
|
|
411
435
|
] }),
|
|
412
|
-
|
|
436
|
+
l && /* @__PURE__ */ n(hn, { errorMessage: t })
|
|
413
437
|
]
|
|
414
438
|
}
|
|
415
439
|
);
|
|
416
|
-
},
|
|
417
|
-
|
|
418
|
-
|
|
440
|
+
}, Xn = ({
|
|
441
|
+
autoSearchFormClass: t = "",
|
|
442
|
+
handleSubmit: a,
|
|
443
|
+
inputCaptionValue: o = "",
|
|
419
444
|
labelForInput: s = "Search",
|
|
420
|
-
onClearedInput:
|
|
445
|
+
onClearedInput: i = () => {
|
|
421
446
|
},
|
|
422
|
-
placeholderValue:
|
|
423
|
-
rightToLeftOrientation:
|
|
447
|
+
placeholderValue: r = "Search here",
|
|
448
|
+
rightToLeftOrientation: e = !1,
|
|
449
|
+
searchContainerClass: l = ""
|
|
424
450
|
}) => {
|
|
425
|
-
const {
|
|
426
|
-
|
|
427
|
-
},
|
|
428
|
-
|
|
451
|
+
const { query: c, setQuery: h } = v(), [_, f] = g(!1), C = (R) => {
|
|
452
|
+
R.preventDefault(), h(R.currentTarget.value), c !== R.currentTarget.value && f(!0);
|
|
453
|
+
}, P = () => {
|
|
454
|
+
h(""), i();
|
|
429
455
|
};
|
|
430
|
-
|
|
431
|
-
if (
|
|
432
|
-
|
|
456
|
+
K(() => {
|
|
457
|
+
if (_)
|
|
458
|
+
a(c), f(!1);
|
|
433
459
|
else
|
|
434
460
|
return;
|
|
435
|
-
}, [
|
|
461
|
+
}, [_, a, c]);
|
|
462
|
+
const W = e ? L.formRTL : L.formLTR;
|
|
463
|
+
return /* @__PURE__ */ u(
|
|
436
464
|
"form",
|
|
437
465
|
{
|
|
438
|
-
className:
|
|
439
|
-
|
|
440
|
-
|
|
466
|
+
className: p(
|
|
467
|
+
W,
|
|
468
|
+
t,
|
|
469
|
+
"searchcraft-auto-search-form"
|
|
470
|
+
),
|
|
471
|
+
onSubmit: (R) => {
|
|
472
|
+
R.preventDefault();
|
|
441
473
|
},
|
|
442
474
|
children: [
|
|
443
|
-
/* @__PURE__ */ n(
|
|
444
|
-
/* @__PURE__ */ n(
|
|
445
|
-
|
|
475
|
+
/* @__PURE__ */ n(z, { label: s }),
|
|
476
|
+
/* @__PURE__ */ n(
|
|
477
|
+
"div",
|
|
446
478
|
{
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
479
|
+
className: p(
|
|
480
|
+
L.searchContainer,
|
|
481
|
+
l,
|
|
482
|
+
"searchcraft-input-container"
|
|
483
|
+
),
|
|
484
|
+
children: /* @__PURE__ */ n(
|
|
485
|
+
A,
|
|
486
|
+
{
|
|
487
|
+
inputCaptionValue: o,
|
|
488
|
+
onClearInput: P,
|
|
489
|
+
onSearchInputChange: C,
|
|
490
|
+
placeholderValue: r,
|
|
491
|
+
query: c,
|
|
492
|
+
rightToLeftOrientation: e
|
|
493
|
+
}
|
|
494
|
+
)
|
|
454
495
|
}
|
|
455
|
-
)
|
|
496
|
+
)
|
|
456
497
|
]
|
|
457
498
|
}
|
|
458
499
|
);
|
|
459
|
-
},
|
|
500
|
+
}, En = () => /* @__PURE__ */ u("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: [
|
|
460
501
|
/* @__PURE__ */ n("title", { children: "Searchcraft Button Icon" }),
|
|
461
502
|
/* @__PURE__ */ n(
|
|
462
503
|
"path",
|
|
@@ -468,77 +509,105 @@ const _ = /* @__PURE__ */ V(O), nn = "_spinnerContainer_1noam_1", tn = "_spinner
|
|
|
468
509
|
strokeLinejoin: "round"
|
|
469
510
|
}
|
|
470
511
|
)
|
|
471
|
-
] }),
|
|
472
|
-
resultContainer:
|
|
473
|
-
interactiveResultContainer:
|
|
474
|
-
interactiveIconLarge:
|
|
475
|
-
interactiveIconSmall:
|
|
512
|
+
] }), Mn = "_resultContainer_10d68_5", qn = "_interactiveResultContainer_10d68_17", Bn = "_interactiveIconLarge_10d68_33", jn = "_interactiveIconSmall_10d68_45", $n = "_imageContainer_10d68_57", Fn = "_contentContainer_10d68_68", Dn = "_image_10d68_57", An = "_heading_10d68_86", zn = "_subheading_10d68_97", Pn = "_bodyContent_10d68_107", Wn = "_button_10d68_117", d = {
|
|
513
|
+
resultContainer: Mn,
|
|
514
|
+
interactiveResultContainer: qn,
|
|
515
|
+
interactiveIconLarge: Bn,
|
|
516
|
+
interactiveIconSmall: jn,
|
|
476
517
|
imageContainer: $n,
|
|
477
|
-
contentContainer:
|
|
478
|
-
image:
|
|
479
|
-
heading:
|
|
480
|
-
subheading:
|
|
481
|
-
bodyContent:
|
|
518
|
+
contentContainer: Fn,
|
|
519
|
+
image: Dn,
|
|
520
|
+
heading: An,
|
|
521
|
+
subheading: zn,
|
|
522
|
+
bodyContent: Pn,
|
|
482
523
|
button: Wn
|
|
483
|
-
},
|
|
524
|
+
}, Qn = ({
|
|
484
525
|
buttonCallbackFn: t = () => {
|
|
485
526
|
},
|
|
486
|
-
buttonLabel:
|
|
487
|
-
callbackFn:
|
|
527
|
+
buttonLabel: a = "",
|
|
528
|
+
callbackFn: o = () => {
|
|
488
529
|
},
|
|
489
|
-
keyDownCallbackFn:
|
|
530
|
+
keyDownCallbackFn: s = () => {
|
|
490
531
|
},
|
|
491
|
-
imageAltText:
|
|
532
|
+
imageAltText: i = "",
|
|
492
533
|
interactiveResult: r = !1,
|
|
493
|
-
imageSrc:
|
|
494
|
-
resultBodyContent:
|
|
495
|
-
resultHeading:
|
|
496
|
-
resultSubheading:
|
|
534
|
+
imageSrc: e = "",
|
|
535
|
+
resultBodyContent: l = "",
|
|
536
|
+
resultHeading: c = "",
|
|
537
|
+
resultSubheading: h = ""
|
|
497
538
|
}) => {
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
},
|
|
539
|
+
const _ = (C) => {
|
|
540
|
+
C.stopPropagation(), t();
|
|
541
|
+
}, f = () => {
|
|
501
542
|
if (r)
|
|
502
|
-
|
|
543
|
+
o();
|
|
503
544
|
else
|
|
504
545
|
return;
|
|
505
546
|
};
|
|
506
|
-
return /* @__PURE__ */
|
|
547
|
+
return /* @__PURE__ */ u(
|
|
507
548
|
"div",
|
|
508
549
|
{
|
|
509
|
-
className: r ?
|
|
550
|
+
className: r ? d.interactiveResultContainer : d.resultContainer,
|
|
510
551
|
id: "searchcraft-item",
|
|
511
|
-
onClick:
|
|
512
|
-
onKeyDown:
|
|
552
|
+
onClick: f,
|
|
553
|
+
onKeyDown: s,
|
|
513
554
|
children: [
|
|
514
|
-
r && /* @__PURE__ */ n("div", { className:
|
|
515
|
-
/* @__PURE__ */ n("div", { className:
|
|
516
|
-
/* @__PURE__ */
|
|
517
|
-
/* @__PURE__ */
|
|
518
|
-
|
|
555
|
+
r && /* @__PURE__ */ n("div", { className: d.interactiveIconLarge, children: /* @__PURE__ */ n(q, {}) }),
|
|
556
|
+
/* @__PURE__ */ n("div", { className: d.imageContainer, children: /* @__PURE__ */ n("img", { alt: i, className: d.image, src: e }) }),
|
|
557
|
+
/* @__PURE__ */ u("div", { className: d.contentContainer, children: [
|
|
558
|
+
/* @__PURE__ */ u("h2", { className: d.heading, children: [
|
|
559
|
+
c,
|
|
519
560
|
" ",
|
|
520
|
-
r && /* @__PURE__ */ n("div", { className:
|
|
561
|
+
r && /* @__PURE__ */ n("div", { className: d.interactiveIconSmall, children: /* @__PURE__ */ n(q, {}) })
|
|
521
562
|
] }),
|
|
522
|
-
/* @__PURE__ */ n("h3", { className:
|
|
523
|
-
/* @__PURE__ */ n("p", { className:
|
|
524
|
-
/* @__PURE__ */
|
|
525
|
-
/* @__PURE__ */ n(
|
|
526
|
-
/* @__PURE__ */ n("span", { children:
|
|
563
|
+
/* @__PURE__ */ n("h3", { className: d.subheading, children: h }),
|
|
564
|
+
/* @__PURE__ */ n("p", { className: d.bodyContent, children: l }),
|
|
565
|
+
/* @__PURE__ */ u("button", { className: d.button, onClick: _, type: "button", children: [
|
|
566
|
+
/* @__PURE__ */ n(En, {}),
|
|
567
|
+
/* @__PURE__ */ n("span", { children: a })
|
|
527
568
|
] })
|
|
528
569
|
] })
|
|
529
570
|
]
|
|
530
571
|
}
|
|
531
572
|
);
|
|
573
|
+
}, Zn = "_resultsContainer_pfxt4_5", Kn = {
|
|
574
|
+
resultsContainer: Zn
|
|
575
|
+
}, Yn = () => {
|
|
576
|
+
var a, o, s;
|
|
577
|
+
const { searchResults: t } = v();
|
|
578
|
+
return /* @__PURE__ */ n("div", { className: Kn.resultsContainer, children: (a = t == null ? void 0 : t.data) != null && a.hits ? (s = (o = t == null ? void 0 : t.data) == null ? void 0 : o.hits) == null ? void 0 : s.map((i, r) => {
|
|
579
|
+
const { doc: e } = i;
|
|
580
|
+
return /* @__PURE__ */ n(
|
|
581
|
+
Qn,
|
|
582
|
+
{
|
|
583
|
+
buttonLabel: "View More",
|
|
584
|
+
buttonCallbackFn: () => {
|
|
585
|
+
console.log("button callback");
|
|
586
|
+
},
|
|
587
|
+
callbackFn: () => {
|
|
588
|
+
console.log("interactive");
|
|
589
|
+
},
|
|
590
|
+
interactiveResult: !0,
|
|
591
|
+
imageSrc: e == null ? void 0 : e.poster,
|
|
592
|
+
resultBodyContent: e == null ? void 0 : e.overview,
|
|
593
|
+
resultHeading: e == null ? void 0 : e.title,
|
|
594
|
+
resultSubheading: e == null ? void 0 : e.release_date
|
|
595
|
+
},
|
|
596
|
+
`${e == null ? void 0 : e.id}-${r}`
|
|
597
|
+
);
|
|
598
|
+
}) : /* @__PURE__ */ n("div", { children: "no results found" }) });
|
|
532
599
|
};
|
|
533
600
|
export {
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
A as
|
|
541
|
-
|
|
542
|
-
|
|
601
|
+
Xn as AutoSearchForm,
|
|
602
|
+
Vn as BaseSearchForm,
|
|
603
|
+
Qn as BaseSearchResult,
|
|
604
|
+
Yn as BaseSearchResults,
|
|
605
|
+
w as Button,
|
|
606
|
+
hn as ErrorMessage,
|
|
607
|
+
A as Input,
|
|
608
|
+
z as InputLabel,
|
|
609
|
+
Jn as Searchcraft,
|
|
610
|
+
Gn as SearchcraftProvider,
|
|
611
|
+
v as useSearchcraft
|
|
543
612
|
};
|
|
544
613
|
//# sourceMappingURL=index.js.map
|