@envive-ai/react-widgets 0.1.0-arthur-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/dist/index-BPfKr14f.d.ts +6 -0
- package/dist/index-VWNd4lyI.d.cts +6 -0
- package/dist/index.cjs +714 -0
- package/dist/index.js +689 -0
- package/package.json +78 -0
- package/src/SearchResults/SearchResults.tsx +144 -0
- package/src/SearchResults/SearchResultsWidget.tsx +43 -0
- package/src/SearchResults/index.ts +1 -0
- package/src/SearchResults/types.ts +19 -0
- package/src/SearchResults/withSearchResults.tsx +22 -0
- package/src/config/BaseWidgetConfig.ts +7 -0
- package/src/config/WidgetType.ts +18 -0
- package/src/stories/SearchResults.stories.tsx +29 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,714 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
let react = require("react");
|
|
25
|
+
react = __toESM(react);
|
|
26
|
+
let __envive_ai_react_hooks_atoms_globalSearch = require("@envive-ai/react-hooks/atoms/globalSearch");
|
|
27
|
+
let __envive_ai_react_hooks_atoms_search = require("@envive-ai/react-hooks/atoms/search");
|
|
28
|
+
let __envive_ai_react_hooks_hooks_NewOrgConfig = require("@envive-ai/react-hooks/hooks/NewOrgConfig");
|
|
29
|
+
let classnames = require("classnames");
|
|
30
|
+
classnames = __toESM(classnames);
|
|
31
|
+
let __envive_ai_react_toolkit_SearchResultsContent = require("@envive-ai/react-toolkit/SearchResultsContent");
|
|
32
|
+
let __envive_ai_react_toolkit_SearchResultsFilterModal = require("@envive-ai/react-toolkit/SearchResultsFilterModal");
|
|
33
|
+
let __envive_ai_react_toolkit_SearchResultsToolbar = require("@envive-ai/react-toolkit/SearchResultsToolbar");
|
|
34
|
+
let __envive_ai_react_toolkit_util = require("@envive-ai/react-toolkit/util");
|
|
35
|
+
let __envive_ai_react_hooks_hooks_Search = require("@envive-ai/react-hooks/hooks/Search");
|
|
36
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
+
|
|
38
|
+
//#region ../../node_modules/jotai/esm/vanilla/internals.mjs
|
|
39
|
+
function hasInitialValue(atom) {
|
|
40
|
+
return "init" in atom;
|
|
41
|
+
}
|
|
42
|
+
function isActuallyWritableAtom(atom) {
|
|
43
|
+
return !!atom.write;
|
|
44
|
+
}
|
|
45
|
+
function isAtomStateInitialized(atomState) {
|
|
46
|
+
return "v" in atomState || "e" in atomState;
|
|
47
|
+
}
|
|
48
|
+
function returnAtomValue(atomState) {
|
|
49
|
+
if ("e" in atomState) throw atomState.e;
|
|
50
|
+
if (({}.env ? {}.env.MODE : void 0) !== "production" && !("v" in atomState)) throw new Error("[Bug] atom state is not initialized");
|
|
51
|
+
return atomState.v;
|
|
52
|
+
}
|
|
53
|
+
const promiseStateMap = /* @__PURE__ */ new WeakMap();
|
|
54
|
+
function isPendingPromise(value) {
|
|
55
|
+
var _a;
|
|
56
|
+
return isPromiseLike(value) && !!((_a = promiseStateMap.get(value)) == null ? void 0 : _a[0]);
|
|
57
|
+
}
|
|
58
|
+
function abortPromise(promise) {
|
|
59
|
+
const promiseState = promiseStateMap.get(promise);
|
|
60
|
+
if (promiseState == null ? void 0 : promiseState[0]) {
|
|
61
|
+
promiseState[0] = false;
|
|
62
|
+
promiseState[1].forEach((fn) => fn());
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function registerAbortHandler(promise, abortHandler) {
|
|
66
|
+
let promiseState = promiseStateMap.get(promise);
|
|
67
|
+
if (!promiseState) {
|
|
68
|
+
promiseState = [true, /* @__PURE__ */ new Set()];
|
|
69
|
+
promiseStateMap.set(promise, promiseState);
|
|
70
|
+
const settle = () => {
|
|
71
|
+
promiseState[0] = false;
|
|
72
|
+
};
|
|
73
|
+
promise.then(settle, settle);
|
|
74
|
+
}
|
|
75
|
+
promiseState[1].add(abortHandler);
|
|
76
|
+
}
|
|
77
|
+
function isPromiseLike(p) {
|
|
78
|
+
return typeof (p == null ? void 0 : p.then) === "function";
|
|
79
|
+
}
|
|
80
|
+
function addPendingPromiseToDependency(atom, promise, dependencyAtomState) {
|
|
81
|
+
if (!dependencyAtomState.p.has(atom)) {
|
|
82
|
+
dependencyAtomState.p.add(atom);
|
|
83
|
+
const cleanup = () => dependencyAtomState.p.delete(atom);
|
|
84
|
+
promise.then(cleanup, cleanup);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function getMountedOrPendingDependents(atom, atomState, mountedMap) {
|
|
88
|
+
var _a;
|
|
89
|
+
const dependents = /* @__PURE__ */ new Set();
|
|
90
|
+
for (const a of ((_a = mountedMap.get(atom)) == null ? void 0 : _a.t) || []) if (mountedMap.has(a)) dependents.add(a);
|
|
91
|
+
for (const atomWithPendingPromise of atomState.p) dependents.add(atomWithPendingPromise);
|
|
92
|
+
return dependents;
|
|
93
|
+
}
|
|
94
|
+
const atomRead = (_store, atom, ...params) => atom.read(...params);
|
|
95
|
+
const atomWrite = (_store, atom, ...params) => atom.write(...params);
|
|
96
|
+
const atomOnInit = (store, atom) => {
|
|
97
|
+
var _a;
|
|
98
|
+
return (_a = atom.unstable_onInit) == null ? void 0 : _a.call(atom, store);
|
|
99
|
+
};
|
|
100
|
+
const atomOnMount = (_store, atom, setAtom) => {
|
|
101
|
+
var _a;
|
|
102
|
+
return (_a = atom.onMount) == null ? void 0 : _a.call(atom, setAtom);
|
|
103
|
+
};
|
|
104
|
+
const ensureAtomState = (store, atom) => {
|
|
105
|
+
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
106
|
+
const atomStateMap = buildingBlocks[0];
|
|
107
|
+
const atomOnInit2 = buildingBlocks[9];
|
|
108
|
+
if (({}.env ? {}.env.MODE : void 0) !== "production" && !atom) throw new Error("Atom is undefined or null");
|
|
109
|
+
let atomState = atomStateMap.get(atom);
|
|
110
|
+
if (!atomState) {
|
|
111
|
+
atomState = {
|
|
112
|
+
d: /* @__PURE__ */ new Map(),
|
|
113
|
+
p: /* @__PURE__ */ new Set(),
|
|
114
|
+
n: 0
|
|
115
|
+
};
|
|
116
|
+
atomStateMap.set(atom, atomState);
|
|
117
|
+
atomOnInit2?.(store, atom);
|
|
118
|
+
}
|
|
119
|
+
return atomState;
|
|
120
|
+
};
|
|
121
|
+
const flushCallbacks = (store) => {
|
|
122
|
+
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
123
|
+
const mountedMap = buildingBlocks[1];
|
|
124
|
+
const changedAtoms = buildingBlocks[3];
|
|
125
|
+
const mountCallbacks = buildingBlocks[4];
|
|
126
|
+
const unmountCallbacks = buildingBlocks[5];
|
|
127
|
+
const storeHooks = buildingBlocks[6];
|
|
128
|
+
const recomputeInvalidatedAtoms2 = buildingBlocks[13];
|
|
129
|
+
const errors = [];
|
|
130
|
+
const call = (fn) => {
|
|
131
|
+
try {
|
|
132
|
+
fn();
|
|
133
|
+
} catch (e) {
|
|
134
|
+
errors.push(e);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
do {
|
|
138
|
+
if (storeHooks.f) call(storeHooks.f);
|
|
139
|
+
const callbacks = /* @__PURE__ */ new Set();
|
|
140
|
+
const add = callbacks.add.bind(callbacks);
|
|
141
|
+
changedAtoms.forEach((atom) => {
|
|
142
|
+
var _a;
|
|
143
|
+
return (_a = mountedMap.get(atom)) == null ? void 0 : _a.l.forEach(add);
|
|
144
|
+
});
|
|
145
|
+
changedAtoms.clear();
|
|
146
|
+
unmountCallbacks.forEach(add);
|
|
147
|
+
unmountCallbacks.clear();
|
|
148
|
+
mountCallbacks.forEach(add);
|
|
149
|
+
mountCallbacks.clear();
|
|
150
|
+
callbacks.forEach(call);
|
|
151
|
+
if (changedAtoms.size) recomputeInvalidatedAtoms2(store);
|
|
152
|
+
} while (changedAtoms.size || unmountCallbacks.size || mountCallbacks.size);
|
|
153
|
+
if (errors.length) throw new AggregateError(errors);
|
|
154
|
+
};
|
|
155
|
+
const recomputeInvalidatedAtoms = (store) => {
|
|
156
|
+
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
157
|
+
const mountedMap = buildingBlocks[1];
|
|
158
|
+
const invalidatedAtoms = buildingBlocks[2];
|
|
159
|
+
const changedAtoms = buildingBlocks[3];
|
|
160
|
+
const ensureAtomState2 = buildingBlocks[11];
|
|
161
|
+
const readAtomState2 = buildingBlocks[14];
|
|
162
|
+
const mountDependencies2 = buildingBlocks[17];
|
|
163
|
+
const topSortedReversed = [];
|
|
164
|
+
const visiting = /* @__PURE__ */ new WeakSet();
|
|
165
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
166
|
+
const stack = Array.from(changedAtoms);
|
|
167
|
+
while (stack.length) {
|
|
168
|
+
const a = stack[stack.length - 1];
|
|
169
|
+
const aState = ensureAtomState2(store, a);
|
|
170
|
+
if (visited.has(a)) {
|
|
171
|
+
stack.pop();
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (visiting.has(a)) {
|
|
175
|
+
if (invalidatedAtoms.get(a) === aState.n) topSortedReversed.push([a, aState]);
|
|
176
|
+
else if (({}.env ? {}.env.MODE : void 0) !== "production" && invalidatedAtoms.has(a)) throw new Error("[Bug] invalidated atom exists");
|
|
177
|
+
visited.add(a);
|
|
178
|
+
stack.pop();
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
visiting.add(a);
|
|
182
|
+
for (const d of getMountedOrPendingDependents(a, aState, mountedMap)) if (!visiting.has(d)) stack.push(d);
|
|
183
|
+
}
|
|
184
|
+
for (let i = topSortedReversed.length - 1; i >= 0; --i) {
|
|
185
|
+
const [a, aState] = topSortedReversed[i];
|
|
186
|
+
let hasChangedDeps = false;
|
|
187
|
+
for (const dep of aState.d.keys()) if (dep !== a && changedAtoms.has(dep)) {
|
|
188
|
+
hasChangedDeps = true;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
if (hasChangedDeps) {
|
|
192
|
+
readAtomState2(store, a);
|
|
193
|
+
mountDependencies2(store, a);
|
|
194
|
+
}
|
|
195
|
+
invalidatedAtoms.delete(a);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
const readAtomState = (store, atom) => {
|
|
199
|
+
var _a, _b;
|
|
200
|
+
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
201
|
+
const mountedMap = buildingBlocks[1];
|
|
202
|
+
const invalidatedAtoms = buildingBlocks[2];
|
|
203
|
+
const changedAtoms = buildingBlocks[3];
|
|
204
|
+
const storeHooks = buildingBlocks[6];
|
|
205
|
+
const atomRead2 = buildingBlocks[7];
|
|
206
|
+
const ensureAtomState2 = buildingBlocks[11];
|
|
207
|
+
const flushCallbacks2 = buildingBlocks[12];
|
|
208
|
+
const recomputeInvalidatedAtoms2 = buildingBlocks[13];
|
|
209
|
+
const readAtomState2 = buildingBlocks[14];
|
|
210
|
+
const writeAtomState2 = buildingBlocks[16];
|
|
211
|
+
const mountDependencies2 = buildingBlocks[17];
|
|
212
|
+
const atomState = ensureAtomState2(store, atom);
|
|
213
|
+
if (isAtomStateInitialized(atomState)) {
|
|
214
|
+
if (mountedMap.has(atom) && invalidatedAtoms.get(atom) !== atomState.n) return atomState;
|
|
215
|
+
if (Array.from(atomState.d).every(([a, n]) => readAtomState2(store, a).n === n)) return atomState;
|
|
216
|
+
}
|
|
217
|
+
atomState.d.clear();
|
|
218
|
+
let isSync = true;
|
|
219
|
+
function mountDependenciesIfAsync() {
|
|
220
|
+
if (mountedMap.has(atom)) {
|
|
221
|
+
mountDependencies2(store, atom);
|
|
222
|
+
recomputeInvalidatedAtoms2(store);
|
|
223
|
+
flushCallbacks2(store);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function getter(a) {
|
|
227
|
+
var _a2;
|
|
228
|
+
if (a === atom) {
|
|
229
|
+
const aState2 = ensureAtomState2(store, a);
|
|
230
|
+
if (!isAtomStateInitialized(aState2)) if (hasInitialValue(a)) setAtomStateValueOrPromise(store, a, a.init);
|
|
231
|
+
else throw new Error("no atom init");
|
|
232
|
+
return returnAtomValue(aState2);
|
|
233
|
+
}
|
|
234
|
+
const aState = readAtomState2(store, a);
|
|
235
|
+
try {
|
|
236
|
+
return returnAtomValue(aState);
|
|
237
|
+
} finally {
|
|
238
|
+
atomState.d.set(a, aState.n);
|
|
239
|
+
if (isPendingPromise(atomState.v)) addPendingPromiseToDependency(atom, atomState.v, aState);
|
|
240
|
+
(_a2 = mountedMap.get(a)) == null || _a2.t.add(atom);
|
|
241
|
+
if (!isSync) mountDependenciesIfAsync();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
let controller;
|
|
245
|
+
let setSelf;
|
|
246
|
+
const options = {
|
|
247
|
+
get signal() {
|
|
248
|
+
if (!controller) controller = new AbortController();
|
|
249
|
+
return controller.signal;
|
|
250
|
+
},
|
|
251
|
+
get setSelf() {
|
|
252
|
+
if (({}.env ? {}.env.MODE : void 0) !== "production" && !isActuallyWritableAtom(atom)) console.warn("setSelf function cannot be used with read-only atom");
|
|
253
|
+
if (!setSelf && isActuallyWritableAtom(atom)) setSelf = (...args) => {
|
|
254
|
+
if (({}.env ? {}.env.MODE : void 0) !== "production" && isSync) console.warn("setSelf function cannot be called in sync");
|
|
255
|
+
if (!isSync) try {
|
|
256
|
+
return writeAtomState2(store, atom, ...args);
|
|
257
|
+
} finally {
|
|
258
|
+
recomputeInvalidatedAtoms2(store);
|
|
259
|
+
flushCallbacks2(store);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
return setSelf;
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
const prevEpochNumber = atomState.n;
|
|
266
|
+
try {
|
|
267
|
+
const valueOrPromise = atomRead2(store, atom, getter, options);
|
|
268
|
+
setAtomStateValueOrPromise(store, atom, valueOrPromise);
|
|
269
|
+
if (isPromiseLike(valueOrPromise)) {
|
|
270
|
+
registerAbortHandler(valueOrPromise, () => controller == null ? void 0 : controller.abort());
|
|
271
|
+
valueOrPromise.then(mountDependenciesIfAsync, mountDependenciesIfAsync);
|
|
272
|
+
}
|
|
273
|
+
(_a = storeHooks.r) == null || _a.call(storeHooks, atom);
|
|
274
|
+
return atomState;
|
|
275
|
+
} catch (error) {
|
|
276
|
+
delete atomState.v;
|
|
277
|
+
atomState.e = error;
|
|
278
|
+
++atomState.n;
|
|
279
|
+
return atomState;
|
|
280
|
+
} finally {
|
|
281
|
+
isSync = false;
|
|
282
|
+
if (prevEpochNumber !== atomState.n && invalidatedAtoms.get(atom) === prevEpochNumber) {
|
|
283
|
+
invalidatedAtoms.set(atom, atomState.n);
|
|
284
|
+
changedAtoms.add(atom);
|
|
285
|
+
(_b = storeHooks.c) == null || _b.call(storeHooks, atom);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
const invalidateDependents = (store, atom) => {
|
|
290
|
+
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
291
|
+
const mountedMap = buildingBlocks[1];
|
|
292
|
+
const invalidatedAtoms = buildingBlocks[2];
|
|
293
|
+
const ensureAtomState2 = buildingBlocks[11];
|
|
294
|
+
const stack = [atom];
|
|
295
|
+
while (stack.length) {
|
|
296
|
+
const a = stack.pop();
|
|
297
|
+
const aState = ensureAtomState2(store, a);
|
|
298
|
+
for (const d of getMountedOrPendingDependents(a, aState, mountedMap)) {
|
|
299
|
+
const dState = ensureAtomState2(store, d);
|
|
300
|
+
invalidatedAtoms.set(d, dState.n);
|
|
301
|
+
stack.push(d);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
const writeAtomState = (store, atom, ...args) => {
|
|
306
|
+
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
307
|
+
const changedAtoms = buildingBlocks[3];
|
|
308
|
+
const storeHooks = buildingBlocks[6];
|
|
309
|
+
const atomWrite2 = buildingBlocks[8];
|
|
310
|
+
const ensureAtomState2 = buildingBlocks[11];
|
|
311
|
+
const flushCallbacks2 = buildingBlocks[12];
|
|
312
|
+
const recomputeInvalidatedAtoms2 = buildingBlocks[13];
|
|
313
|
+
const readAtomState2 = buildingBlocks[14];
|
|
314
|
+
const invalidateDependents2 = buildingBlocks[15];
|
|
315
|
+
const mountDependencies2 = buildingBlocks[17];
|
|
316
|
+
let isSync = true;
|
|
317
|
+
const getter = (a) => returnAtomValue(readAtomState2(store, a));
|
|
318
|
+
const setter = (a, ...args2) => {
|
|
319
|
+
var _a;
|
|
320
|
+
const aState = ensureAtomState2(store, a);
|
|
321
|
+
try {
|
|
322
|
+
if (a === atom) {
|
|
323
|
+
if (!hasInitialValue(a)) throw new Error("atom not writable");
|
|
324
|
+
const prevEpochNumber = aState.n;
|
|
325
|
+
const v = args2[0];
|
|
326
|
+
setAtomStateValueOrPromise(store, a, v);
|
|
327
|
+
mountDependencies2(store, a);
|
|
328
|
+
if (prevEpochNumber !== aState.n) {
|
|
329
|
+
changedAtoms.add(a);
|
|
330
|
+
(_a = storeHooks.c) == null || _a.call(storeHooks, a);
|
|
331
|
+
invalidateDependents2(store, a);
|
|
332
|
+
}
|
|
333
|
+
return;
|
|
334
|
+
} else return writeAtomState(store, a, ...args2);
|
|
335
|
+
} finally {
|
|
336
|
+
if (!isSync) {
|
|
337
|
+
recomputeInvalidatedAtoms2(store);
|
|
338
|
+
flushCallbacks2(store);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
try {
|
|
343
|
+
return atomWrite2(store, atom, getter, setter, ...args);
|
|
344
|
+
} finally {
|
|
345
|
+
isSync = false;
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
const mountDependencies = (store, atom) => {
|
|
349
|
+
var _a;
|
|
350
|
+
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
351
|
+
const mountedMap = buildingBlocks[1];
|
|
352
|
+
const changedAtoms = buildingBlocks[3];
|
|
353
|
+
const storeHooks = buildingBlocks[6];
|
|
354
|
+
const ensureAtomState2 = buildingBlocks[11];
|
|
355
|
+
const invalidateDependents2 = buildingBlocks[15];
|
|
356
|
+
const mountAtom2 = buildingBlocks[18];
|
|
357
|
+
const unmountAtom2 = buildingBlocks[19];
|
|
358
|
+
const atomState = ensureAtomState2(store, atom);
|
|
359
|
+
const mounted = mountedMap.get(atom);
|
|
360
|
+
if (mounted && !isPendingPromise(atomState.v)) {
|
|
361
|
+
for (const [a, n] of atomState.d) if (!mounted.d.has(a)) {
|
|
362
|
+
const aState = ensureAtomState2(store, a);
|
|
363
|
+
mountAtom2(store, a).t.add(atom);
|
|
364
|
+
mounted.d.add(a);
|
|
365
|
+
if (n !== aState.n) {
|
|
366
|
+
changedAtoms.add(a);
|
|
367
|
+
(_a = storeHooks.c) == null || _a.call(storeHooks, a);
|
|
368
|
+
invalidateDependents2(store, a);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
for (const a of mounted.d || []) if (!atomState.d.has(a)) {
|
|
372
|
+
mounted.d.delete(a);
|
|
373
|
+
unmountAtom2(store, a)?.t.delete(atom);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
const mountAtom = (store, atom) => {
|
|
378
|
+
var _a;
|
|
379
|
+
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
380
|
+
const mountedMap = buildingBlocks[1];
|
|
381
|
+
const mountCallbacks = buildingBlocks[4];
|
|
382
|
+
const storeHooks = buildingBlocks[6];
|
|
383
|
+
const atomOnMount2 = buildingBlocks[10];
|
|
384
|
+
const ensureAtomState2 = buildingBlocks[11];
|
|
385
|
+
const flushCallbacks2 = buildingBlocks[12];
|
|
386
|
+
const recomputeInvalidatedAtoms2 = buildingBlocks[13];
|
|
387
|
+
const readAtomState2 = buildingBlocks[14];
|
|
388
|
+
const writeAtomState2 = buildingBlocks[16];
|
|
389
|
+
const atomState = ensureAtomState2(store, atom);
|
|
390
|
+
let mounted = mountedMap.get(atom);
|
|
391
|
+
if (!mounted) {
|
|
392
|
+
readAtomState2(store, atom);
|
|
393
|
+
for (const a of atomState.d.keys()) mountAtom(store, a).t.add(atom);
|
|
394
|
+
mounted = {
|
|
395
|
+
l: /* @__PURE__ */ new Set(),
|
|
396
|
+
d: new Set(atomState.d.keys()),
|
|
397
|
+
t: /* @__PURE__ */ new Set()
|
|
398
|
+
};
|
|
399
|
+
mountedMap.set(atom, mounted);
|
|
400
|
+
(_a = storeHooks.m) == null || _a.call(storeHooks, atom);
|
|
401
|
+
if (isActuallyWritableAtom(atom)) {
|
|
402
|
+
const processOnMount = () => {
|
|
403
|
+
let isSync = true;
|
|
404
|
+
const setAtom = (...args) => {
|
|
405
|
+
try {
|
|
406
|
+
return writeAtomState2(store, atom, ...args);
|
|
407
|
+
} finally {
|
|
408
|
+
if (!isSync) {
|
|
409
|
+
recomputeInvalidatedAtoms2(store);
|
|
410
|
+
flushCallbacks2(store);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
try {
|
|
415
|
+
const onUnmount = atomOnMount2(store, atom, setAtom);
|
|
416
|
+
if (onUnmount) mounted.u = () => {
|
|
417
|
+
isSync = true;
|
|
418
|
+
try {
|
|
419
|
+
onUnmount();
|
|
420
|
+
} finally {
|
|
421
|
+
isSync = false;
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
} finally {
|
|
425
|
+
isSync = false;
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
mountCallbacks.add(processOnMount);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return mounted;
|
|
432
|
+
};
|
|
433
|
+
const unmountAtom = (store, atom) => {
|
|
434
|
+
var _a;
|
|
435
|
+
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
436
|
+
const mountedMap = buildingBlocks[1];
|
|
437
|
+
const unmountCallbacks = buildingBlocks[5];
|
|
438
|
+
const storeHooks = buildingBlocks[6];
|
|
439
|
+
const ensureAtomState2 = buildingBlocks[11];
|
|
440
|
+
const unmountAtom2 = buildingBlocks[19];
|
|
441
|
+
const atomState = ensureAtomState2(store, atom);
|
|
442
|
+
let mounted = mountedMap.get(atom);
|
|
443
|
+
if (mounted && !mounted.l.size && !Array.from(mounted.t).some((a) => {
|
|
444
|
+
var _a2;
|
|
445
|
+
return (_a2 = mountedMap.get(a)) == null ? void 0 : _a2.d.has(atom);
|
|
446
|
+
})) {
|
|
447
|
+
if (mounted.u) unmountCallbacks.add(mounted.u);
|
|
448
|
+
mounted = void 0;
|
|
449
|
+
mountedMap.delete(atom);
|
|
450
|
+
(_a = storeHooks.u) == null || _a.call(storeHooks, atom);
|
|
451
|
+
for (const a of atomState.d.keys()) unmountAtom2(store, a)?.t.delete(atom);
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
return mounted;
|
|
455
|
+
};
|
|
456
|
+
const setAtomStateValueOrPromise = (store, atom, valueOrPromise) => {
|
|
457
|
+
const ensureAtomState2 = getInternalBuildingBlocks(store)[11];
|
|
458
|
+
const atomState = ensureAtomState2(store, atom);
|
|
459
|
+
const hasPrevValue = "v" in atomState;
|
|
460
|
+
const prevValue = atomState.v;
|
|
461
|
+
if (isPromiseLike(valueOrPromise)) for (const a of atomState.d.keys()) addPendingPromiseToDependency(atom, valueOrPromise, ensureAtomState2(store, a));
|
|
462
|
+
atomState.v = valueOrPromise;
|
|
463
|
+
delete atomState.e;
|
|
464
|
+
if (!hasPrevValue || !Object.is(prevValue, atomState.v)) {
|
|
465
|
+
++atomState.n;
|
|
466
|
+
if (isPromiseLike(prevValue)) abortPromise(prevValue);
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
const storeGet = (store, atom) => {
|
|
470
|
+
const readAtomState2 = getInternalBuildingBlocks(store)[14];
|
|
471
|
+
return returnAtomValue(readAtomState2(store, atom));
|
|
472
|
+
};
|
|
473
|
+
const storeSet = (store, atom, ...args) => {
|
|
474
|
+
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
475
|
+
const flushCallbacks2 = buildingBlocks[12];
|
|
476
|
+
const recomputeInvalidatedAtoms2 = buildingBlocks[13];
|
|
477
|
+
const writeAtomState2 = buildingBlocks[16];
|
|
478
|
+
try {
|
|
479
|
+
return writeAtomState2(store, atom, ...args);
|
|
480
|
+
} finally {
|
|
481
|
+
recomputeInvalidatedAtoms2(store);
|
|
482
|
+
flushCallbacks2(store);
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
const storeSub = (store, atom, listener) => {
|
|
486
|
+
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
487
|
+
const flushCallbacks2 = buildingBlocks[12];
|
|
488
|
+
const mountAtom2 = buildingBlocks[18];
|
|
489
|
+
const unmountAtom2 = buildingBlocks[19];
|
|
490
|
+
const listeners = mountAtom2(store, atom).l;
|
|
491
|
+
listeners.add(listener);
|
|
492
|
+
flushCallbacks2(store);
|
|
493
|
+
return () => {
|
|
494
|
+
listeners.delete(listener);
|
|
495
|
+
unmountAtom2(store, atom);
|
|
496
|
+
flushCallbacks2(store);
|
|
497
|
+
};
|
|
498
|
+
};
|
|
499
|
+
const buildingBlockMap = /* @__PURE__ */ new WeakMap();
|
|
500
|
+
const getInternalBuildingBlocks = (store) => {
|
|
501
|
+
const buildingBlocks = buildingBlockMap.get(store);
|
|
502
|
+
if (({}.env ? {}.env.MODE : void 0) !== "production" && !buildingBlocks) throw new Error("Store must be created by buildStore to read its building blocks");
|
|
503
|
+
return buildingBlocks;
|
|
504
|
+
};
|
|
505
|
+
function buildStore(...buildArgs) {
|
|
506
|
+
const store = {
|
|
507
|
+
get(atom) {
|
|
508
|
+
const storeGet2 = getInternalBuildingBlocks(store)[21];
|
|
509
|
+
return storeGet2(store, atom);
|
|
510
|
+
},
|
|
511
|
+
set(atom, ...args) {
|
|
512
|
+
const storeSet2 = getInternalBuildingBlocks(store)[22];
|
|
513
|
+
return storeSet2(store, atom, ...args);
|
|
514
|
+
},
|
|
515
|
+
sub(atom, listener) {
|
|
516
|
+
const storeSub2 = getInternalBuildingBlocks(store)[23];
|
|
517
|
+
return storeSub2(store, atom, listener);
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
const buildingBlocks = [
|
|
521
|
+
/* @__PURE__ */ new WeakMap(),
|
|
522
|
+
/* @__PURE__ */ new WeakMap(),
|
|
523
|
+
/* @__PURE__ */ new WeakMap(),
|
|
524
|
+
/* @__PURE__ */ new Set(),
|
|
525
|
+
/* @__PURE__ */ new Set(),
|
|
526
|
+
/* @__PURE__ */ new Set(),
|
|
527
|
+
{},
|
|
528
|
+
atomRead,
|
|
529
|
+
atomWrite,
|
|
530
|
+
atomOnInit,
|
|
531
|
+
atomOnMount,
|
|
532
|
+
ensureAtomState,
|
|
533
|
+
flushCallbacks,
|
|
534
|
+
recomputeInvalidatedAtoms,
|
|
535
|
+
readAtomState,
|
|
536
|
+
invalidateDependents,
|
|
537
|
+
writeAtomState,
|
|
538
|
+
mountDependencies,
|
|
539
|
+
mountAtom,
|
|
540
|
+
unmountAtom,
|
|
541
|
+
setAtomStateValueOrPromise,
|
|
542
|
+
storeGet,
|
|
543
|
+
storeSet,
|
|
544
|
+
storeSub,
|
|
545
|
+
void 0
|
|
546
|
+
].map((fn, i) => buildArgs[i] || fn);
|
|
547
|
+
buildingBlockMap.set(store, Object.freeze(buildingBlocks));
|
|
548
|
+
return store;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
//#endregion
|
|
552
|
+
//#region ../../node_modules/jotai/esm/vanilla.mjs
|
|
553
|
+
let overiddenCreateStore;
|
|
554
|
+
function createStore() {
|
|
555
|
+
if (overiddenCreateStore) return overiddenCreateStore();
|
|
556
|
+
return buildStore();
|
|
557
|
+
}
|
|
558
|
+
let defaultStore;
|
|
559
|
+
function getDefaultStore() {
|
|
560
|
+
if (!defaultStore) {
|
|
561
|
+
defaultStore = createStore();
|
|
562
|
+
if (({}.env ? {}.env.MODE : void 0) !== "production") {
|
|
563
|
+
globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = defaultStore);
|
|
564
|
+
if (globalThis.__JOTAI_DEFAULT_STORE__ !== defaultStore) console.warn("Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044");
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
return defaultStore;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
//#endregion
|
|
571
|
+
//#region ../../node_modules/jotai/esm/react.mjs
|
|
572
|
+
const StoreContext = (0, react.createContext)(void 0);
|
|
573
|
+
function useStore(options) {
|
|
574
|
+
const store = (0, react.useContext)(StoreContext);
|
|
575
|
+
return (options == null ? void 0 : options.store) || store || getDefaultStore();
|
|
576
|
+
}
|
|
577
|
+
const attachPromiseStatus = (promise) => {
|
|
578
|
+
if (!promise.status) {
|
|
579
|
+
promise.status = "pending";
|
|
580
|
+
promise.then((v) => {
|
|
581
|
+
promise.status = "fulfilled";
|
|
582
|
+
promise.value = v;
|
|
583
|
+
}, (e) => {
|
|
584
|
+
promise.status = "rejected";
|
|
585
|
+
promise.reason = e;
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
const use = react.default.use || ((promise) => {
|
|
590
|
+
if (promise.status === "pending") throw promise;
|
|
591
|
+
else if (promise.status === "fulfilled") return promise.value;
|
|
592
|
+
else if (promise.status === "rejected") throw promise.reason;
|
|
593
|
+
else {
|
|
594
|
+
attachPromiseStatus(promise);
|
|
595
|
+
throw promise;
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
function useSetAtom(atom, options) {
|
|
599
|
+
const store = useStore(options);
|
|
600
|
+
return (0, react.useCallback)((...args) => {
|
|
601
|
+
if (({}.env ? {}.env.MODE : void 0) !== "production" && !("write" in atom)) throw new Error("not writable atom");
|
|
602
|
+
return store.set(atom, ...args);
|
|
603
|
+
}, [store, atom]);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region src/SearchResults/withSearchResults.tsx
|
|
608
|
+
function withSearchResults(Component) {
|
|
609
|
+
return function SearchResultsHoc(props) {
|
|
610
|
+
const searchHookResult = (0, __envive_ai_react_hooks_hooks_Search.useSearch)();
|
|
611
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
|
|
612
|
+
...props,
|
|
613
|
+
...searchHookResult,
|
|
614
|
+
productList: searchHookResult.searchData?.products || []
|
|
615
|
+
});
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
//#endregion
|
|
620
|
+
//#region src/SearchResults/SearchResults.tsx
|
|
621
|
+
const SearchResultsComponent = ({ widgetConfig, productCardConfig, merchantShortName, productList, autocompleteResults, searchFilters, availableDynamicFilters, selectedFilterOptions, searchText, query, searchResultsState, isFilterOpen, shouldShowAutocomplete, focusedIndex, focusedOptionId, recommendedProducts, filterButtonText, onSearchInputChange, onSubmitSearch, onAutocompleteSelect, onKeyDown, onSearchInputFocus, onSearchInputBlur, onToggleDynamicFilter, onSelectFilterItem, onRemoveFilter, onClearAllFilters, setIsFilterOpen, searchResultsRef }) => {
|
|
622
|
+
const { searchInputVariant, searchFilterSidebarVariant, productGridVariant, searchBoxPlaceholder, noResultsFoundText, isSearchInputSticky = false } = widgetConfig;
|
|
623
|
+
const { toolbarRef: ref, isVisible, toolbarHeight: height } = (0, __envive_ai_react_toolkit_util.useStickyVisibility)();
|
|
624
|
+
const toolbarRef = isSearchInputSticky ? ref : null;
|
|
625
|
+
const finalIsVisible = isSearchInputSticky ? isVisible : true;
|
|
626
|
+
const toolbarHeight = isSearchInputSticky ? height : 0;
|
|
627
|
+
const stickyToolbarClasses = (0, classnames.default)("spiffy-tw-fixed", "spiffy-tw-top-0", "spiffy-tw-left-0", "spiffy-tw-right-0", "spiffy-tw-transition-transform", "spiffy-tw-duration-300", "spiffy-tw-py-[8px]");
|
|
628
|
+
const containerXPaddingClasses = (0, classnames.default)("spiffy-tw-px-[16px]", "sm:spiffy-tw-px-[46px]");
|
|
629
|
+
(0, react.useEffect)(() => {
|
|
630
|
+
window.scrollTo({
|
|
631
|
+
top: 0,
|
|
632
|
+
behavior: "smooth"
|
|
633
|
+
});
|
|
634
|
+
}, [productList]);
|
|
635
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
|
|
636
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__envive_ai_react_toolkit_SearchResultsFilterModal.SearchResultsFilterModal, {
|
|
637
|
+
isOpen: isFilterOpen,
|
|
638
|
+
setIsOpen: setIsFilterOpen,
|
|
639
|
+
searchFilters,
|
|
640
|
+
productCount: productList.length,
|
|
641
|
+
onSelectFilterItem,
|
|
642
|
+
onClearAllFilters,
|
|
643
|
+
searchFilterSidebarVariant,
|
|
644
|
+
filterButtonText
|
|
645
|
+
}),
|
|
646
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__envive_ai_react_toolkit_SearchResultsToolbar.SearchResultsToolbar, {
|
|
647
|
+
className: isSearchInputSticky ? stickyToolbarClasses : "spiffy-tw-py-[8px]",
|
|
648
|
+
toolbarRef,
|
|
649
|
+
searchInputVariant,
|
|
650
|
+
searchBoxPlaceholder,
|
|
651
|
+
searchText,
|
|
652
|
+
focusedIndex,
|
|
653
|
+
focusedOptionId,
|
|
654
|
+
autocompleteResults,
|
|
655
|
+
filterButtonText,
|
|
656
|
+
onKeyDown,
|
|
657
|
+
onSearchInputChange,
|
|
658
|
+
onSubmitSearch,
|
|
659
|
+
onAutocompleteSelect,
|
|
660
|
+
onSearchInputFocus,
|
|
661
|
+
onSearchInputBlur,
|
|
662
|
+
shouldShowAutocomplete,
|
|
663
|
+
setIsFilterOpen,
|
|
664
|
+
containerXPaddingClasses,
|
|
665
|
+
isVisible: finalIsVisible
|
|
666
|
+
}),
|
|
667
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__envive_ai_react_toolkit_SearchResultsContent.SearchResultsContent, {
|
|
668
|
+
searchResultsState,
|
|
669
|
+
productList,
|
|
670
|
+
recommendedProducts,
|
|
671
|
+
productCardConfig,
|
|
672
|
+
merchantShortName,
|
|
673
|
+
searchFilterSidebarVariant,
|
|
674
|
+
noResultsFoundText,
|
|
675
|
+
productGridVariant,
|
|
676
|
+
containerXPaddingClasses,
|
|
677
|
+
selectedFilterOptions,
|
|
678
|
+
availableDynamicFilters,
|
|
679
|
+
onRemoveFilter,
|
|
680
|
+
onToggleDynamicFilter,
|
|
681
|
+
searchResultsRef,
|
|
682
|
+
toolbarHeight,
|
|
683
|
+
query
|
|
684
|
+
})
|
|
685
|
+
] });
|
|
686
|
+
};
|
|
687
|
+
const SearchResults = withSearchResults(SearchResultsComponent);
|
|
688
|
+
|
|
689
|
+
//#endregion
|
|
690
|
+
//#region src/SearchResults/SearchResultsWidget.tsx
|
|
691
|
+
const SearchResultsWidget = () => {
|
|
692
|
+
const setIsSearchResultsOpen = useSetAtom(__envive_ai_react_hooks_atoms_globalSearch.isSearchResultsOpenAtom);
|
|
693
|
+
const setSearchSystem = useSetAtom(__envive_ai_react_hooks_atoms_search.searchSystemAtom);
|
|
694
|
+
const newConfig = (0, __envive_ai_react_hooks_hooks_NewOrgConfig.useNewOrgConfig)();
|
|
695
|
+
(0, react.useEffect)(() => {
|
|
696
|
+
setSearchSystem(true);
|
|
697
|
+
return () => setSearchSystem(false);
|
|
698
|
+
}, [setSearchSystem]);
|
|
699
|
+
(0, react.useEffect)(() => {
|
|
700
|
+
setIsSearchResultsOpen(true);
|
|
701
|
+
return () => {
|
|
702
|
+
setIsSearchResultsOpen(false);
|
|
703
|
+
};
|
|
704
|
+
}, [setIsSearchResultsOpen]);
|
|
705
|
+
const widgetConfig = (0, react.useMemo)(() => {
|
|
706
|
+
if (newConfig && newConfig.frontendConfig?.widgetConfigs) return { ...(newConfig.frontendConfig?.widgetConfigs).find((widget) => widget.key === "searchResultsEntryPoint").config };
|
|
707
|
+
return null;
|
|
708
|
+
}, [newConfig]);
|
|
709
|
+
if (!widgetConfig) return null;
|
|
710
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SearchResults, { widgetConfig });
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
//#endregion
|
|
714
|
+
exports.SearchResultsWidget = SearchResultsWidget;
|