@searchcraft/react-sdk 0.1.0 → 0.1.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.
- package/README.md +154 -1
- package/dist/index.d.ts +22 -18
- package/dist/index.js +414 -345
- 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
|
|
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, e, s) => e in t ? U(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s, N = (t, e, s) => H(t, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
+
class Jn {
|
|
5
5
|
constructor(e) {
|
|
6
|
-
if (
|
|
6
|
+
if (N(this, "config"), N(this, "search", async (s) => {
|
|
7
7
|
try {
|
|
8
|
-
this.config.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
mode: c,
|
|
8
|
+
const i = this.config.index.join(","), o = `${this.config.endpointURL}/index/${i}/search`, r = {
|
|
9
|
+
query: s.query,
|
|
10
|
+
mode: s.mode,
|
|
12
11
|
app: this.config.index
|
|
13
12
|
}, a = {
|
|
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(o, a)).json();
|
|
22
|
+
} catch (i) {
|
|
23
|
+
return i;
|
|
26
24
|
}
|
|
27
|
-
}), !e.
|
|
28
|
-
throw new Error(
|
|
29
|
-
|
|
30
|
-
);
|
|
31
|
-
this.config = e, this.searchResult = null;
|
|
25
|
+
}), !e.endpointURL || !e.index)
|
|
26
|
+
throw new Error("Endpoint URL and Index value(s) must be provided");
|
|
27
|
+
this.config = e;
|
|
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: e
|
|
45
41
|
}) => {
|
|
46
|
-
const s =
|
|
47
|
-
()
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}),
|
|
52
|
-
[e]
|
|
53
|
-
), [c, o] = y(""), [r, a] = y(!1), i = {
|
|
42
|
+
const [s, i] = g(""), [o, r] = g(!1), [a, l] = g(null), c = async () => {
|
|
43
|
+
r(!0);
|
|
44
|
+
const _ = await e.search({ query: s, mode: "fuzzy" });
|
|
45
|
+
l(_), r(!1);
|
|
46
|
+
}, h = {
|
|
54
47
|
error: null,
|
|
55
|
-
index:
|
|
56
|
-
isRequesting:
|
|
48
|
+
index: e.config.index,
|
|
49
|
+
isRequesting: o,
|
|
57
50
|
mode: "fuzzy",
|
|
58
|
-
query:
|
|
59
|
-
search:
|
|
60
|
-
|
|
61
|
-
setQuery:
|
|
51
|
+
query: s,
|
|
52
|
+
search: c,
|
|
53
|
+
searchResults: a,
|
|
54
|
+
setQuery: i
|
|
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
|
|
@@ -80,12 +73,12 @@ var F = { exports: {} };
|
|
|
80
73
|
var e = {}.hasOwnProperty;
|
|
81
74
|
function s() {
|
|
82
75
|
for (var r = "", a = 0; a < arguments.length; a++) {
|
|
83
|
-
var
|
|
84
|
-
|
|
76
|
+
var l = arguments[a];
|
|
77
|
+
l && (r = o(r, i(l)));
|
|
85
78
|
}
|
|
86
79
|
return r;
|
|
87
80
|
}
|
|
88
|
-
function
|
|
81
|
+
function i(r) {
|
|
89
82
|
if (typeof r == "string" || typeof r == "number")
|
|
90
83
|
return r;
|
|
91
84
|
if (typeof r != "object")
|
|
@@ -95,8 +88,8 @@ var F = { exports: {} };
|
|
|
95
88
|
if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
|
|
96
89
|
return r.toString();
|
|
97
90
|
var a = "";
|
|
98
|
-
for (var
|
|
99
|
-
e.call(r,
|
|
91
|
+
for (var l in r)
|
|
92
|
+
e.call(r, l) && r[l] && (a = o(a, l));
|
|
100
93
|
return a;
|
|
101
94
|
}
|
|
102
95
|
function o(r, a) {
|
|
@@ -104,79 +97,149 @@ var F = { exports: {} };
|
|
|
104
97
|
}
|
|
105
98
|
t.exports ? (s.default = s, t.exports = s) : window.classNames = s;
|
|
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", on = "_rightandback_8jqm2_1", b = {
|
|
103
|
+
button: nn,
|
|
104
|
+
spinnerMarginRight: tn,
|
|
105
|
+
spinnerMarginLeft: en,
|
|
106
|
+
buttonLabel: rn,
|
|
107
|
+
rightandback: on
|
|
108
|
+
}, sn = "_spinnerContainer_1noam_1", an = "_spinnerDark_1noam_7", cn = "_spinning_1noam_1", ln = "_spinnerLight_1noam_16", S = {
|
|
109
|
+
spinnerContainer: sn,
|
|
110
|
+
spinnerDark: an,
|
|
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
115
|
iconElement: e,
|
|
123
116
|
iconOnly: s = !1,
|
|
124
|
-
iconPosition:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
117
|
+
iconPosition: i = "left",
|
|
118
|
+
label: o = "Search",
|
|
119
|
+
onClick: r
|
|
120
|
+
}) => {
|
|
121
|
+
const { isRequesting: a } = v();
|
|
122
|
+
return /* @__PURE__ */ u(k, { children: [
|
|
123
|
+
s && /* @__PURE__ */ n(
|
|
124
|
+
"button",
|
|
125
|
+
{
|
|
126
|
+
className: p(
|
|
127
|
+
b.button,
|
|
128
|
+
t,
|
|
129
|
+
".searchcraft-button"
|
|
130
|
+
),
|
|
131
|
+
onClick: r,
|
|
132
|
+
type: "submit",
|
|
133
|
+
children: a ? /* @__PURE__ */ n(I, {}) : e
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
!s && /* @__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
|
+
i === "left" && a ? /* @__PURE__ */ n("div", { className: b.spinnerMarginRight, children: /* @__PURE__ */ n(I, {}) }) : e,
|
|
148
|
+
/* @__PURE__ */ n(
|
|
149
|
+
"span",
|
|
150
|
+
{
|
|
151
|
+
className: p(
|
|
152
|
+
a && b.buttonLabel,
|
|
153
|
+
t,
|
|
154
|
+
".searchcraft-button-label"
|
|
155
|
+
),
|
|
156
|
+
children: o
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
i === "right" && a ? /* @__PURE__ */ n("div", { className: b.spinnerMarginLeft, children: /* @__PURE__ */ n(I, {}) }) : e
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
] });
|
|
164
|
+
}, un = "_errorMessage_12dc9_5", pn = {
|
|
165
|
+
errorMessage: un
|
|
166
|
+
}, hn = ({ className: t, errorMessage: e }) => /* @__PURE__ */ n("p", { className: p(pn.errorMessage, t), children: e || "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" }),
|
|
178
|
+
/* @__PURE__ */ n(
|
|
179
|
+
"path",
|
|
180
|
+
{
|
|
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",
|
|
183
|
+
strokeWidth: "1.5",
|
|
184
|
+
strokeLinecap: "round",
|
|
185
|
+
strokeLinejoin: "round"
|
|
186
|
+
}
|
|
187
|
+
)
|
|
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" }),
|
|
190
|
+
/* @__PURE__ */ n(
|
|
191
|
+
"path",
|
|
192
|
+
{
|
|
193
|
+
d: "M7.5 15.0444L12.5 10.0444L7.5 5.04443",
|
|
194
|
+
stroke: "#737373",
|
|
195
|
+
strokeWidth: "1.5",
|
|
196
|
+
strokeLinecap: "round",
|
|
197
|
+
strokeLinejoin: "round"
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
] }), B = ({
|
|
201
|
+
onClearInput: t,
|
|
202
|
+
rightToLeftOrientation: e = !1
|
|
203
|
+
}) => {
|
|
204
|
+
const { isRequesting: s } = v();
|
|
205
|
+
return e ? /* @__PURE__ */ n(
|
|
130
206
|
"button",
|
|
131
207
|
{
|
|
132
|
-
className:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
208
|
+
className: p(
|
|
209
|
+
E.inputClearButtonRTL,
|
|
210
|
+
".sc-clear-input-button-rtl"
|
|
211
|
+
),
|
|
212
|
+
onClick: t,
|
|
213
|
+
type: "button",
|
|
214
|
+
children: s ? /* @__PURE__ */ n(x, {}) : /* @__PURE__ */ n(M, {})
|
|
136
215
|
}
|
|
137
|
-
)
|
|
138
|
-
!s && /* @__PURE__ */ l(
|
|
216
|
+
) : /* @__PURE__ */ n(
|
|
139
217
|
"button",
|
|
140
218
|
{
|
|
141
|
-
className:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
{
|
|
149
|
-
className: _(
|
|
150
|
-
o && b.buttonLabel,
|
|
151
|
-
t
|
|
152
|
-
),
|
|
153
|
-
children: r
|
|
154
|
-
}
|
|
155
|
-
),
|
|
156
|
-
c === "right" && o ? /* @__PURE__ */ n("div", { className: b.spinnerMarginLeft, children: /* @__PURE__ */ n(k, {}) }) : e
|
|
157
|
-
]
|
|
219
|
+
className: p(
|
|
220
|
+
E.inputClearButtonLTR,
|
|
221
|
+
".sc-clear-input-button-ltr"
|
|
222
|
+
),
|
|
223
|
+
onClick: t,
|
|
224
|
+
type: "button",
|
|
225
|
+
children: s ? /* @__PURE__ */ n(x, {}) : /* @__PURE__ */ n(M, {})
|
|
158
226
|
}
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
inputCaption: dn,
|
|
167
|
-
inputCaptionError: _n,
|
|
168
|
-
inputCaptionRTL: mn,
|
|
169
|
-
inputCaptionErrorRTL: Cn
|
|
170
|
-
}, M = ({
|
|
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 = ({
|
|
171
234
|
error: t = !1,
|
|
172
235
|
inputCaptionClassName: e,
|
|
173
236
|
inputCaptionValue: s = "Enter Search",
|
|
174
|
-
rightToLeftOrientation:
|
|
175
|
-
}) =>
|
|
237
|
+
rightToLeftOrientation: i = !1
|
|
238
|
+
}) => i ? /* @__PURE__ */ n(
|
|
176
239
|
"p",
|
|
177
240
|
{
|
|
178
|
-
className:
|
|
179
|
-
t ?
|
|
241
|
+
className: p(
|
|
242
|
+
t ? T.inputCaptionErrorRTL : T.inputCaptionRTL,
|
|
180
243
|
e
|
|
181
244
|
),
|
|
182
245
|
children: s
|
|
@@ -184,16 +247,16 @@ const _ = /* @__PURE__ */ V(O), nn = "_spinnerContainer_1noam_1", tn = "_spinner
|
|
|
184
247
|
) : /* @__PURE__ */ n(
|
|
185
248
|
"p",
|
|
186
249
|
{
|
|
187
|
-
className:
|
|
188
|
-
t ?
|
|
250
|
+
className: p(
|
|
251
|
+
t ? T.inputCaptionErrorLTR : T.inputCaptionLTR,
|
|
189
252
|
e
|
|
190
253
|
),
|
|
191
254
|
children: s
|
|
192
255
|
}
|
|
193
|
-
),
|
|
194
|
-
|
|
195
|
-
inputIconRTL:
|
|
196
|
-
},
|
|
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: [
|
|
197
260
|
/* @__PURE__ */ n("title", { children: "Searchcraft Search Icon" }),
|
|
198
261
|
/* @__PURE__ */ n(
|
|
199
262
|
"path",
|
|
@@ -205,7 +268,7 @@ const _ = /* @__PURE__ */ V(O), nn = "_spinnerContainer_1noam_1", tn = "_spinner
|
|
|
205
268
|
strokeLinejoin: "round"
|
|
206
269
|
}
|
|
207
270
|
)
|
|
208
|
-
] }),
|
|
271
|
+
] }), Nn = () => /* @__PURE__ */ u("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: [
|
|
209
272
|
/* @__PURE__ */ n("title", { children: "Searchcraft Error Search Icon" }),
|
|
210
273
|
/* @__PURE__ */ n(
|
|
211
274
|
"path",
|
|
@@ -217,246 +280,224 @@ const _ = /* @__PURE__ */ V(O), nn = "_spinnerContainer_1noam_1", tn = "_spinner
|
|
|
217
280
|
strokeLinejoin: "round"
|
|
218
281
|
}
|
|
219
282
|
)
|
|
220
|
-
] }),
|
|
283
|
+
] }), $ = ({
|
|
221
284
|
error: t = !1,
|
|
222
285
|
rightToLeftOrientation: e = !1
|
|
223
286
|
}) => t ? /* @__PURE__ */ n(
|
|
224
287
|
"div",
|
|
225
288
|
{
|
|
226
|
-
className: e ?
|
|
227
|
-
children: /* @__PURE__ */ n(
|
|
289
|
+
className: e ? y.inputIconRTL : y.inputIconLTR,
|
|
290
|
+
children: /* @__PURE__ */ n(Nn, {})
|
|
228
291
|
}
|
|
229
292
|
) : /* @__PURE__ */ n(
|
|
230
293
|
"div",
|
|
231
294
|
{
|
|
232
|
-
className: e ?
|
|
233
|
-
children: /* @__PURE__ */ n(
|
|
234
|
-
}
|
|
235
|
-
), w = () => /* @__PURE__ */ l("svg", { width: "22", height: "22", viewBox: "0 0 22 22", fill: "none", children: [
|
|
236
|
-
/* @__PURE__ */ n("title", { children: "Searchcraft Clear Input Icon" }),
|
|
237
|
-
/* @__PURE__ */ n(
|
|
238
|
-
"path",
|
|
239
|
-
{
|
|
240
|
-
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",
|
|
241
|
-
stroke: "black",
|
|
242
|
-
strokeWidth: "1.5",
|
|
243
|
-
strokeLinecap: "round",
|
|
244
|
-
strokeLinejoin: "round"
|
|
245
|
-
}
|
|
246
|
-
)
|
|
247
|
-
] }), j = () => /* @__PURE__ */ l("svg", { width: "20", height: "21", viewBox: "0 0 20 21", fill: "none", children: [
|
|
248
|
-
/* @__PURE__ */ n("title", { children: "Searchcraft Arrow Right Icon" }),
|
|
249
|
-
/* @__PURE__ */ n(
|
|
250
|
-
"path",
|
|
251
|
-
{
|
|
252
|
-
d: "M7.5 15.0444L12.5 10.0444L7.5 5.04443",
|
|
253
|
-
stroke: "#737373",
|
|
254
|
-
strokeWidth: "1.5",
|
|
255
|
-
strokeLinecap: "round",
|
|
256
|
-
strokeLinejoin: "round"
|
|
257
|
-
}
|
|
258
|
-
)
|
|
259
|
-
] }), vn = "_inputClearButton_xi5sa_5", Rn = "_inputClearButtonRTL_xi5sa_19", q = {
|
|
260
|
-
inputClearButton: vn,
|
|
261
|
-
inputClearButtonRTL: Rn
|
|
262
|
-
}, B = ({
|
|
263
|
-
isAutoSearch: t = !1,
|
|
264
|
-
isRequesting: e = !1,
|
|
265
|
-
onClearInput: s,
|
|
266
|
-
rightToLeftOrientation: c = !1
|
|
267
|
-
}) => c ? /* @__PURE__ */ n(
|
|
268
|
-
"button",
|
|
269
|
-
{
|
|
270
|
-
className: q.inputClearButtonRTL,
|
|
271
|
-
onClick: s,
|
|
272
|
-
type: "button",
|
|
273
|
-
children: e ? /* @__PURE__ */ n(N, {}) : /* @__PURE__ */ n(w, {})
|
|
295
|
+
className: e ? y.inputIconRTL : y.inputIconLTR,
|
|
296
|
+
children: /* @__PURE__ */ n(kn, {})
|
|
274
297
|
}
|
|
275
|
-
)
|
|
276
|
-
"button",
|
|
277
|
-
{
|
|
278
|
-
className: q.inputClearButton,
|
|
279
|
-
onClick: s,
|
|
280
|
-
type: "button",
|
|
281
|
-
children: e ? /* @__PURE__ */ n(N, {}) : /* @__PURE__ */ n(w, {})
|
|
282
|
-
}
|
|
283
|
-
), yn = "_inputContainer_17hag_5", In = "_inputContainerRTL_17hag_9", Sn = "_input_17hag_5", kn = "_inputRTL_17hag_35", Tn = "_inputError_17hag_57", Nn = "_inputErrorRTL_17hag_82", f = {
|
|
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
300
|
formClassName: e = "",
|
|
293
301
|
inputCaptionClassName: s = "",
|
|
294
|
-
inputClassName:
|
|
302
|
+
inputClassName: i = "",
|
|
295
303
|
inputCaptionValue: o = "",
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
rightToLeftOrientation: u = !1,
|
|
304
|
+
onClearInput: r,
|
|
305
|
+
onSearchInputChange: a,
|
|
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
|
+
e,
|
|
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
|
+
i,
|
|
326
|
+
"searchcraft-input"
|
|
327
|
+
),
|
|
328
|
+
id: "searchcraft-input-id",
|
|
329
|
+
onChange: a,
|
|
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
|
+
o && /* @__PURE__ */ n(
|
|
336
|
+
j,
|
|
337
|
+
{
|
|
338
|
+
inputCaptionClassName: s,
|
|
339
|
+
inputCaptionValue: o,
|
|
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
|
+
i,
|
|
364
|
+
"searchcraft-input"
|
|
365
|
+
),
|
|
366
|
+
id: "searchcraft-input-id",
|
|
367
|
+
onChange: a,
|
|
368
|
+
placeholder: l,
|
|
369
|
+
type: "text",
|
|
370
|
+
value: h
|
|
371
|
+
}
|
|
372
|
+
),
|
|
373
|
+
o && /* @__PURE__ */ n(
|
|
374
|
+
j,
|
|
375
|
+
{
|
|
376
|
+
inputCaptionClassName: s,
|
|
377
|
+
inputCaptionValue: o,
|
|
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
396
|
label: e = "Enter Search"
|
|
380
|
-
}) => /* @__PURE__ */ n(
|
|
397
|
+
}) => /* @__PURE__ */ n(
|
|
398
|
+
"label",
|
|
399
|
+
{
|
|
400
|
+
className: p(wn.label, t),
|
|
401
|
+
htmlFor: "searchcraft-input-id",
|
|
402
|
+
children: e
|
|
403
|
+
}
|
|
404
|
+
), Vn = ({
|
|
381
405
|
errorMessage: t,
|
|
382
406
|
handleSubmit: e,
|
|
383
407
|
labelForInput: s = "Search",
|
|
384
|
-
placeholderValue:
|
|
408
|
+
placeholderValue: i = "Enter Search Term",
|
|
385
409
|
rightToLeftOrientation: o = !1
|
|
386
410
|
}) => {
|
|
387
|
-
const { query: r,
|
|
388
|
-
|
|
389
|
-
},
|
|
390
|
-
return /* @__PURE__ */
|
|
411
|
+
const { query: r, setQuery: a } = v(), [l, c] = g(!1), h = (C) => {
|
|
412
|
+
C.preventDefault(), r.trim() === "" ? c(!0) : (c(!1), e(r));
|
|
413
|
+
}, _ = (C) => a(C.target.value), f = () => a("");
|
|
414
|
+
return /* @__PURE__ */ u(
|
|
391
415
|
"form",
|
|
392
416
|
{
|
|
393
|
-
className: o ?
|
|
417
|
+
className: o ? L.formRTL : L.formLTR,
|
|
394
418
|
onSubmit: h,
|
|
395
419
|
children: [
|
|
396
|
-
/* @__PURE__ */ n(
|
|
397
|
-
/* @__PURE__ */
|
|
398
|
-
o && /* @__PURE__ */ n(
|
|
420
|
+
/* @__PURE__ */ n(z, { label: s }),
|
|
421
|
+
/* @__PURE__ */ u("div", { className: L.searchContainer, children: [
|
|
422
|
+
o && /* @__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: i,
|
|
406
430
|
query: r,
|
|
407
431
|
rightToLeftOrientation: o
|
|
408
432
|
}
|
|
409
433
|
),
|
|
410
|
-
!o && /* @__PURE__ */ n(
|
|
434
|
+
!o && /* @__PURE__ */ n(w, {})
|
|
411
435
|
] }),
|
|
412
|
-
|
|
436
|
+
l && /* @__PURE__ */ n(hn, { errorMessage: t })
|
|
413
437
|
]
|
|
414
438
|
}
|
|
415
439
|
);
|
|
416
|
-
},
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
440
|
+
}, Xn = ({
|
|
441
|
+
autoSearchFormClass: t = "",
|
|
442
|
+
handleSubmit: e,
|
|
443
|
+
inputCaptionValue: s = "",
|
|
444
|
+
labelForInput: i = "Search",
|
|
445
|
+
onClearedInput: o = () => {
|
|
421
446
|
},
|
|
422
|
-
placeholderValue:
|
|
423
|
-
rightToLeftOrientation:
|
|
447
|
+
placeholderValue: r = "Search here",
|
|
448
|
+
rightToLeftOrientation: a = !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(""), o();
|
|
429
455
|
};
|
|
430
|
-
|
|
431
|
-
if (
|
|
432
|
-
|
|
456
|
+
K(() => {
|
|
457
|
+
if (_)
|
|
458
|
+
e(c), f(!1);
|
|
433
459
|
else
|
|
434
460
|
return;
|
|
435
|
-
}, [
|
|
461
|
+
}, [_, e, c]);
|
|
462
|
+
const W = a ? 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: i }),
|
|
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: s,
|
|
488
|
+
onClearInput: P,
|
|
489
|
+
onSearchInputChange: C,
|
|
490
|
+
placeholderValue: r,
|
|
491
|
+
query: c,
|
|
492
|
+
rightToLeftOrientation: a
|
|
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
527
|
buttonLabel: e = "",
|
|
487
528
|
callbackFn: s = () => {
|
|
488
529
|
},
|
|
489
|
-
keyDownCallbackFn:
|
|
530
|
+
keyDownCallbackFn: i = () => {
|
|
490
531
|
},
|
|
491
532
|
imageAltText: o = "",
|
|
492
533
|
interactiveResult: r = !1,
|
|
493
534
|
imageSrc: a = "",
|
|
494
|
-
resultBodyContent:
|
|
495
|
-
resultHeading:
|
|
496
|
-
resultSubheading:
|
|
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
|
s();
|
|
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: i,
|
|
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: o, className: d.image, src: a }) }),
|
|
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(
|
|
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, {}),
|
|
526
567
|
/* @__PURE__ */ n("span", { children: e })
|
|
527
568
|
] })
|
|
528
569
|
] })
|
|
529
570
|
]
|
|
530
571
|
}
|
|
531
572
|
);
|
|
573
|
+
}, Zn = "_resultsContainer_pfxt4_5", Kn = {
|
|
574
|
+
resultsContainer: Zn
|
|
575
|
+
}, Yn = () => {
|
|
576
|
+
var e;
|
|
577
|
+
const { searchResults: t } = v();
|
|
578
|
+
return /* @__PURE__ */ n("div", { className: Kn.resultsContainer, children: t != null && t.hits ? (e = t == null ? void 0 : t.hits) == null ? void 0 : e.map((s, i) => {
|
|
579
|
+
const { doc: o } = s;
|
|
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: o == null ? void 0 : o.poster,
|
|
592
|
+
resultBodyContent: o == null ? void 0 : o.overview,
|
|
593
|
+
resultHeading: o == null ? void 0 : o.title,
|
|
594
|
+
resultSubheading: o == null ? void 0 : o.release_date
|
|
595
|
+
},
|
|
596
|
+
`${o == null ? void 0 : o.id}-${i}`
|
|
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
|