dirk-cfx-react 1.1.93 → 1.1.95
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/chunk-3T2CCW5E.cjs +150 -0
- package/dist/chunk-3T2CCW5E.cjs.map +1 -0
- package/dist/chunk-4DE2IREA.cjs +9 -0
- package/dist/chunk-4DE2IREA.cjs.map +1 -0
- package/dist/chunk-E2SFEBBB.cjs +449 -0
- package/dist/chunk-E2SFEBBB.cjs.map +1 -0
- package/dist/chunk-GKSP5RIA.js +3 -0
- package/dist/chunk-GKSP5RIA.js.map +1 -0
- package/dist/chunk-HAB6H274.js +6646 -0
- package/dist/chunk-HAB6H274.js.map +1 -0
- package/dist/chunk-K3GDU6EY.cjs +6717 -0
- package/dist/chunk-K3GDU6EY.cjs.map +1 -0
- package/dist/chunk-KGLO3ZAS.js +431 -0
- package/dist/chunk-KGLO3ZAS.js.map +1 -0
- package/dist/chunk-LRGCBNZ7.cjs +4 -0
- package/dist/chunk-LRGCBNZ7.cjs.map +1 -0
- package/dist/chunk-MYNNCLMA.js +1375 -0
- package/dist/chunk-MYNNCLMA.js.map +1 -0
- package/dist/chunk-NVMOGS7Y.js +437 -0
- package/dist/chunk-NVMOGS7Y.js.map +1 -0
- package/dist/chunk-QOQQ3ERZ.cjs +445 -0
- package/dist/chunk-QOQQ3ERZ.cjs.map +1 -0
- package/dist/chunk-V6TY7KAL.js +7 -0
- package/dist/chunk-V6TY7KAL.js.map +1 -0
- package/dist/chunk-VKYONY7E.cjs +112 -0
- package/dist/chunk-VKYONY7E.cjs.map +1 -0
- package/dist/chunk-YA2PXBP6.cjs +1430 -0
- package/dist/chunk-YA2PXBP6.cjs.map +1 -0
- package/dist/chunk-Z7N5AQJW.js +146 -0
- package/dist/chunk-Z7N5AQJW.js.map +1 -0
- package/dist/chunk-ZPFW7C2A.js +108 -0
- package/dist/chunk-ZPFW7C2A.js.map +1 -0
- package/dist/components/index.cjs +282 -7760
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +39 -1
- package/dist/components/index.d.ts +39 -1
- package/dist/components/index.js +6 -7699
- package/dist/components/index.js.map +1 -1
- package/dist/hooks/index.cjs +75 -749
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.js +5 -732
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +572 -9091
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9 -8953
- package/dist/index.js.map +1 -1
- package/dist/modelNames-QIAIYORH.cjs +53910 -0
- package/dist/modelNames-QIAIYORH.cjs.map +1 -0
- package/dist/modelNames-WAUYJLL3.js +53908 -0
- package/dist/modelNames-WAUYJLL3.js.map +1 -0
- package/dist/providers/index.cjs +11 -590
- package/dist/providers/index.cjs.map +1 -1
- package/dist/providers/index.js +5 -590
- package/dist/providers/index.js.map +1 -1
- package/dist/utils/index.cjs +186 -1361
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +41 -1
- package/dist/utils/index.d.ts +41 -1
- package/dist/utils/index.js +2 -1324
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
package/dist/hooks/index.cjs
CHANGED
|
@@ -1,758 +1,84 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var zod = require('zod');
|
|
9
|
-
var reactQuery = require('@tanstack/react-query');
|
|
3
|
+
var chunkVKYONY7E_cjs = require('../chunk-VKYONY7E.cjs');
|
|
4
|
+
var chunkE2SFEBBB_cjs = require('../chunk-E2SFEBBB.cjs');
|
|
5
|
+
var chunk3T2CCW5E_cjs = require('../chunk-3T2CCW5E.cjs');
|
|
6
|
+
require('../chunk-YA2PXBP6.cjs');
|
|
7
|
+
require('../chunk-4DE2IREA.cjs');
|
|
10
8
|
|
|
11
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
9
|
|
|
13
|
-
var clickSoundUrl__default = /*#__PURE__*/_interopDefault(clickSoundUrl);
|
|
14
|
-
var hoverSoundUrl__default = /*#__PURE__*/_interopDefault(hoverSoundUrl);
|
|
15
10
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const sounds = {
|
|
20
|
-
click: clickSoundUrl__default.default,
|
|
21
|
-
hover: hoverSoundUrl__default.default
|
|
22
|
-
};
|
|
23
|
-
for (const [key, src] of Object.entries(sounds)) {
|
|
24
|
-
audioRefs[key] = new Audio(src);
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
play: (sound) => {
|
|
28
|
-
const audio = audioRefs[sound];
|
|
29
|
-
if (!audio) return console.warn(`Sound '${sound}' not found.`);
|
|
30
|
-
audio.currentTime = 0;
|
|
31
|
-
audio.volume = 0.1;
|
|
32
|
-
audio.play();
|
|
33
|
-
},
|
|
34
|
-
stop: (sound) => {
|
|
35
|
-
const audio = audioRefs[sound];
|
|
36
|
-
if (!audio) return console.warn(`Sound '${sound}' not found.`);
|
|
37
|
-
audio.pause();
|
|
38
|
-
audio.currentTime = 0;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
11
|
+
Object.defineProperty(exports, "TornEdgeSVGFilter", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkVKYONY7E_cjs.TornEdgeSVGFilter; }
|
|
41
14
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const fields = [];
|
|
110
|
-
for (let i = 0; i < maxLen; i++) {
|
|
111
|
-
const nextPrefix = prefix ? `${prefix}.${i}` : `${i}`;
|
|
112
|
-
fields.push(...collectChangedPaths(values?.[i], initial?.[i], nextPrefix));
|
|
113
|
-
}
|
|
114
|
-
return fields;
|
|
115
|
-
}
|
|
116
|
-
if (valuesIsObj || initialIsObj) {
|
|
117
|
-
const keys = /* @__PURE__ */ new Set([
|
|
118
|
-
...Object.keys(values ?? {}),
|
|
119
|
-
...Object.keys(initial ?? {})
|
|
120
|
-
]);
|
|
121
|
-
const fields = [];
|
|
122
|
-
for (const key of keys) {
|
|
123
|
-
const nextPrefix = prefix ? `${prefix}.${key}` : key;
|
|
124
|
-
fields.push(...collectChangedPaths(values?.[key], initial?.[key], nextPrefix));
|
|
125
|
-
}
|
|
126
|
-
return fields;
|
|
127
|
-
}
|
|
128
|
-
return prefix ? [prefix] : [];
|
|
129
|
-
}
|
|
130
|
-
function computeChangedState(values, initialVals) {
|
|
131
|
-
const fields = collectChangedPaths(values, initialVals);
|
|
132
|
-
let partial = {};
|
|
133
|
-
for (const path of fields) {
|
|
134
|
-
partial = setNested(partial, path, getNested(values, path));
|
|
135
|
-
}
|
|
136
|
-
return { fields, partial };
|
|
137
|
-
}
|
|
138
|
-
function flattenRules(rules, prefix = "") {
|
|
139
|
-
const result = {};
|
|
140
|
-
for (const key in rules) {
|
|
141
|
-
const fullPath = prefix ? `${prefix}.${key}` : key;
|
|
142
|
-
const val = rules[key];
|
|
143
|
-
if (typeof val === "function") result[fullPath] = val;
|
|
144
|
-
else if (typeof val === "object")
|
|
145
|
-
Object.assign(result, flattenRules(val, fullPath));
|
|
146
|
-
}
|
|
147
|
-
return result;
|
|
148
|
-
}
|
|
149
|
-
async function runRule(rule, value, values) {
|
|
150
|
-
const result = rule(value, values);
|
|
151
|
-
return result instanceof Promise ? await result : result;
|
|
152
|
-
}
|
|
153
|
-
function createFormStore(initialValues, validationRules, onSubmit) {
|
|
154
|
-
const flatRules = validationRules ? flattenRules(validationRules) : {};
|
|
155
|
-
const history = [];
|
|
156
|
-
const future = [];
|
|
157
|
-
const changed = /* @__PURE__ */ new Set();
|
|
158
|
-
return zustand.createStore((set, get) => ({
|
|
159
|
-
initialValues,
|
|
160
|
-
values: initialValues,
|
|
161
|
-
errors: {},
|
|
162
|
-
partialChanged: {},
|
|
163
|
-
canBack: false,
|
|
164
|
-
canForward: false,
|
|
165
|
-
changedFields: [],
|
|
166
|
-
changedCount: 0,
|
|
167
|
-
onSubmit,
|
|
168
|
-
submit: async () => {
|
|
169
|
-
const state = get();
|
|
170
|
-
const isValid = await state.validate();
|
|
171
|
-
if (isValid && state.onSubmit) {
|
|
172
|
-
state.onSubmit(get());
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
getInputProps: (path) => {
|
|
176
|
-
return {
|
|
177
|
-
value: getNested(get().values, path) ?? "",
|
|
178
|
-
error: get().errors[path],
|
|
179
|
-
onChange: (e) => {
|
|
180
|
-
get().setValue(path, e.target.value, { validate: true });
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
},
|
|
184
|
-
resetChangeCount: () => {
|
|
185
|
-
changed.clear();
|
|
186
|
-
set({ changedFields: [], changedCount: 0, partialChanged: {} });
|
|
187
|
-
},
|
|
188
|
-
setInitialValues: (newInitialValues) => set({ initialValues: newInitialValues }),
|
|
189
|
-
setValue: (path, value, options) => {
|
|
190
|
-
const state = get();
|
|
191
|
-
const currentValues = state.values;
|
|
192
|
-
const newValues = setNested(currentValues, path, value);
|
|
193
|
-
const oldValue = getNested(state.initialValues, path);
|
|
194
|
-
const hasChanged = value !== oldValue;
|
|
195
|
-
history.push(currentValues);
|
|
196
|
-
future.length = 0;
|
|
197
|
-
let newPartial = state.partialChanged;
|
|
198
|
-
if (hasChanged) {
|
|
199
|
-
changed.add(path);
|
|
200
|
-
newPartial = setNested(newPartial, path, value);
|
|
201
|
-
} else {
|
|
202
|
-
changed.delete(path);
|
|
203
|
-
newPartial = deleteNested(newPartial, path);
|
|
204
|
-
}
|
|
205
|
-
set({
|
|
206
|
-
values: newValues,
|
|
207
|
-
partialChanged: newPartial,
|
|
208
|
-
canBack: history.length > 0,
|
|
209
|
-
canForward: false,
|
|
210
|
-
changedFields: Array.from(changed),
|
|
211
|
-
changedCount: changed.size
|
|
212
|
-
});
|
|
213
|
-
if (!options?.validate) return;
|
|
214
|
-
const rule = flatRules[path];
|
|
215
|
-
if (!rule) return;
|
|
216
|
-
Promise.resolve(runRule(rule, value, newValues)).then((error) => {
|
|
217
|
-
if (error)
|
|
218
|
-
set((s) => ({ errors: setNested(s.errors, path, error) }));
|
|
219
|
-
else
|
|
220
|
-
set((s) => ({ errors: deleteNested(s.errors, path) }));
|
|
221
|
-
});
|
|
222
|
-
},
|
|
223
|
-
setError: (path, message) => set((s) => ({ errors: setNested(s.errors, path, message) })),
|
|
224
|
-
clearError: (path) => set((s) => ({ errors: deleteNested(s.errors, path) })),
|
|
225
|
-
validateField: async (path) => {
|
|
226
|
-
const state = get();
|
|
227
|
-
const rule = flatRules[path];
|
|
228
|
-
if (!rule) return true;
|
|
229
|
-
const value = getNested(state.values, path);
|
|
230
|
-
const error = await runRule(rule, value, state.values);
|
|
231
|
-
if (error) {
|
|
232
|
-
set((s) => ({ errors: setNested(s.errors, path, error) }));
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
set((s) => ({ errors: deleteNested(s.errors, path) }));
|
|
236
|
-
return true;
|
|
237
|
-
},
|
|
238
|
-
validate: async () => {
|
|
239
|
-
const state = get();
|
|
240
|
-
let isValid = true;
|
|
241
|
-
let newErrors = {};
|
|
242
|
-
for (const path in flatRules) {
|
|
243
|
-
const rule = flatRules[path];
|
|
244
|
-
const value = getNested(state.values, path);
|
|
245
|
-
const error = await runRule(rule, value, state.values);
|
|
246
|
-
if (error) {
|
|
247
|
-
isValid = false;
|
|
248
|
-
newErrors = setNested(newErrors, path, error);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
set({ errors: newErrors });
|
|
252
|
-
return isValid;
|
|
253
|
-
},
|
|
254
|
-
reset: () => {
|
|
255
|
-
history.length = 0;
|
|
256
|
-
future.length = 0;
|
|
257
|
-
changed.clear();
|
|
258
|
-
set({
|
|
259
|
-
values: get().initialValues,
|
|
260
|
-
errors: {},
|
|
261
|
-
partialChanged: {},
|
|
262
|
-
canBack: false,
|
|
263
|
-
canForward: false,
|
|
264
|
-
changedFields: [],
|
|
265
|
-
changedCount: 0
|
|
266
|
-
});
|
|
267
|
-
},
|
|
268
|
-
reinitialize: (newValues) => {
|
|
269
|
-
history.length = 0;
|
|
270
|
-
future.length = 0;
|
|
271
|
-
changed.clear();
|
|
272
|
-
set({
|
|
273
|
-
values: newValues,
|
|
274
|
-
initialValues: newValues,
|
|
275
|
-
errors: {},
|
|
276
|
-
partialChanged: {},
|
|
277
|
-
canBack: false,
|
|
278
|
-
canForward: false,
|
|
279
|
-
changedFields: [],
|
|
280
|
-
changedCount: 0
|
|
281
|
-
});
|
|
282
|
-
},
|
|
283
|
-
back: () => {
|
|
284
|
-
if (!history.length) return;
|
|
285
|
-
const prev = history.pop();
|
|
286
|
-
future.push(get().values);
|
|
287
|
-
const { fields, partial } = computeChangedState(prev, get().initialValues);
|
|
288
|
-
set({
|
|
289
|
-
values: prev,
|
|
290
|
-
partialChanged: partial,
|
|
291
|
-
canBack: history.length > 0,
|
|
292
|
-
canForward: true,
|
|
293
|
-
changedFields: fields,
|
|
294
|
-
changedCount: fields.length
|
|
295
|
-
});
|
|
296
|
-
},
|
|
297
|
-
forward: () => {
|
|
298
|
-
if (!future.length) return;
|
|
299
|
-
const next = future.pop();
|
|
300
|
-
history.push(get().values);
|
|
301
|
-
const { fields, partial } = computeChangedState(next, get().initialValues);
|
|
302
|
-
set({
|
|
303
|
-
values: next,
|
|
304
|
-
partialChanged: partial,
|
|
305
|
-
canBack: true,
|
|
306
|
-
canForward: future.length > 0,
|
|
307
|
-
changedFields: fields,
|
|
308
|
-
changedCount: fields.length
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
}));
|
|
312
|
-
}
|
|
313
|
-
var FormContext = react.createContext(null);
|
|
314
|
-
function FormProvider({
|
|
315
|
-
initialValues,
|
|
316
|
-
validate,
|
|
317
|
-
onSubmit,
|
|
318
|
-
children
|
|
319
|
-
}) {
|
|
320
|
-
const storeRef = react.useRef(
|
|
321
|
-
createFormStore(initialValues, validate, onSubmit)
|
|
322
|
-
);
|
|
323
|
-
return /* @__PURE__ */ jsxRuntime.jsx(FormContext.Provider, { value: storeRef.current, children });
|
|
324
|
-
}
|
|
325
|
-
function useForm() {
|
|
326
|
-
const store2 = react.useContext(FormContext);
|
|
327
|
-
if (!store2) {
|
|
328
|
-
throw new Error("useForm must be used inside <FormProvider>");
|
|
329
|
-
}
|
|
330
|
-
const state = zustand.useStore(store2);
|
|
331
|
-
const changedFields = react.useMemo(() => {
|
|
332
|
-
return collectChangedPaths(state.values, state.initialValues);
|
|
333
|
-
}, [state.values, state.initialValues]);
|
|
334
|
-
return { ...state, changedFields, changedCount: changedFields.length };
|
|
335
|
-
}
|
|
336
|
-
function useFormField(path) {
|
|
337
|
-
const store2 = react.useContext(FormContext);
|
|
338
|
-
if (!store2) {
|
|
339
|
-
throw new Error("useFormField must be used inside <FormProvider>");
|
|
340
|
-
}
|
|
341
|
-
return zustand.useStore(store2, (s) => getNested(s.values, path));
|
|
342
|
-
}
|
|
343
|
-
function useFormFields(...paths) {
|
|
344
|
-
const store2 = react.useContext(FormContext);
|
|
345
|
-
if (!store2) {
|
|
346
|
-
throw new Error("useFormFields must be used inside <FormProvider>");
|
|
347
|
-
}
|
|
348
|
-
return zustand.useStore(store2, (s) => {
|
|
349
|
-
const result = {};
|
|
350
|
-
for (const path of paths) {
|
|
351
|
-
result[path] = getNested(s.values, path);
|
|
352
|
-
}
|
|
353
|
-
return result;
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
function useFormError(path) {
|
|
357
|
-
const store2 = react.useContext(FormContext);
|
|
358
|
-
if (!store2) {
|
|
359
|
-
throw new Error("useFormError must be used inside <FormProvider>");
|
|
360
|
-
}
|
|
361
|
-
return zustand.useStore(store2, (s) => s.errors[path]);
|
|
362
|
-
}
|
|
363
|
-
function useFormErrors(...paths) {
|
|
364
|
-
const store2 = react.useContext(FormContext);
|
|
365
|
-
if (!store2) {
|
|
366
|
-
throw new Error("useFormErrors must be used inside <FormProvider>");
|
|
367
|
-
}
|
|
368
|
-
return zustand.useStore(store2, (s) => {
|
|
369
|
-
const result = {};
|
|
370
|
-
for (const path of paths) {
|
|
371
|
-
result[path] = s.errors[path];
|
|
372
|
-
}
|
|
373
|
-
return result;
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
function useFormActions() {
|
|
377
|
-
const store2 = react.useContext(FormContext);
|
|
378
|
-
if (!store2) {
|
|
379
|
-
throw new Error("useFormActions must be used inside <FormProvider>");
|
|
380
|
-
}
|
|
381
|
-
return store2.getState();
|
|
382
|
-
}
|
|
383
|
-
var DEFAULT_PALETTE = [
|
|
384
|
-
"#f0f4ff",
|
|
385
|
-
"#d9e3ff",
|
|
386
|
-
"#bfcfff",
|
|
387
|
-
"#a6bbff",
|
|
388
|
-
"#8ca7ff",
|
|
389
|
-
"#7393ff",
|
|
390
|
-
"#5a7fff",
|
|
391
|
-
"#406bff",
|
|
392
|
-
"#2547ff",
|
|
393
|
-
"#0b33ff"
|
|
394
|
-
];
|
|
395
|
-
zod.z.object({
|
|
396
|
-
useOverride: zod.z.boolean(),
|
|
397
|
-
primaryColor: zod.z.string(),
|
|
398
|
-
primaryShade: zod.z.number(),
|
|
399
|
-
customTheme: zod.z.array(zod.z.string())
|
|
15
|
+
Object.defineProperty(exports, "useTornEdges", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkVKYONY7E_cjs.useTornEdges; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "useValidModels", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkVKYONY7E_cjs.useValidModels; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "FormProvider", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkE2SFEBBB_cjs.FormProvider; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "clearAdminState", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunkE2SFEBBB_cjs.clearAdminState; }
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "createFormStore", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return chunkE2SFEBBB_cjs.createFormStore; }
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, "useAdminState", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () { return chunkE2SFEBBB_cjs.useAdminState; }
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "useAudio", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return chunkE2SFEBBB_cjs.useAudio; }
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "useForm", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () { return chunkE2SFEBBB_cjs.useForm; }
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(exports, "useFormActions", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function () { return chunkE2SFEBBB_cjs.useFormActions; }
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(exports, "useFormError", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () { return chunkE2SFEBBB_cjs.useFormError; }
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, "useFormErrors", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () { return chunkE2SFEBBB_cjs.useFormErrors; }
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(exports, "useFormField", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function () { return chunkE2SFEBBB_cjs.useFormField; }
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(exports, "useFormFields", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function () { return chunkE2SFEBBB_cjs.useFormFields; }
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(exports, "usePlayers", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function () { return chunkE2SFEBBB_cjs.usePlayers; }
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(exports, "createScriptConfig", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
get: function () { return chunk3T2CCW5E_cjs.createScriptConfig; }
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(exports, "getScriptConfigInstance", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function () { return chunk3T2CCW5E_cjs.getScriptConfigInstance; }
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(exports, "useNuiEvent", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () { return chunk3T2CCW5E_cjs.useNuiEvent; }
|
|
400
82
|
});
|
|
401
|
-
|
|
402
|
-
// src/utils/useSettings.ts
|
|
403
|
-
var useSettings = zustand.create(() => ({
|
|
404
|
-
currency: "$",
|
|
405
|
-
game: "fivem",
|
|
406
|
-
primaryColor: "dirk",
|
|
407
|
-
primaryShade: 9,
|
|
408
|
-
itemImgPath: "",
|
|
409
|
-
resourceVersion: "dev",
|
|
410
|
-
customTheme: DEFAULT_PALETTE
|
|
411
|
-
}));
|
|
412
|
-
function useTornEdges() {
|
|
413
|
-
const game = useSettings((state) => state.game);
|
|
414
|
-
return game === "rdr3" ? "torn-edge-wrapper" : "";
|
|
415
|
-
}
|
|
416
|
-
function TornEdgeSVGFilter() {
|
|
417
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
418
|
-
"svg",
|
|
419
|
-
{
|
|
420
|
-
style: { position: "absolute", width: 0, height: 0, pointerEvents: "none" },
|
|
421
|
-
"aria-hidden": "true",
|
|
422
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("filter", { id: "torn-edge-filter", x: "-50%", y: "-50%", width: "200%", height: "200%", children: [
|
|
423
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
424
|
-
"feTurbulence",
|
|
425
|
-
{
|
|
426
|
-
type: "fractalNoise",
|
|
427
|
-
baseFrequency: "0.018 0.022",
|
|
428
|
-
numOctaves: "5",
|
|
429
|
-
seed: "9",
|
|
430
|
-
result: "noise1"
|
|
431
|
-
}
|
|
432
|
-
),
|
|
433
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
434
|
-
"feTurbulence",
|
|
435
|
-
{
|
|
436
|
-
type: "fractalNoise",
|
|
437
|
-
baseFrequency: "0.08 0.12",
|
|
438
|
-
numOctaves: "2",
|
|
439
|
-
seed: "3",
|
|
440
|
-
result: "noise2"
|
|
441
|
-
}
|
|
442
|
-
),
|
|
443
|
-
/* @__PURE__ */ jsxRuntime.jsx("feBlend", { in: "noise1", in2: "noise2", mode: "multiply", result: "combinedNoise" }),
|
|
444
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
445
|
-
"feDisplacementMap",
|
|
446
|
-
{
|
|
447
|
-
in: "SourceGraphic",
|
|
448
|
-
in2: "combinedNoise",
|
|
449
|
-
scale: "52",
|
|
450
|
-
xChannelSelector: "R",
|
|
451
|
-
yChannelSelector: "G",
|
|
452
|
-
result: "displaced"
|
|
453
|
-
}
|
|
454
|
-
),
|
|
455
|
-
/* @__PURE__ */ jsxRuntime.jsx("feGaussianBlur", { stdDeviation: "0.8", in: "displaced", result: "blurred" }),
|
|
456
|
-
/* @__PURE__ */ jsxRuntime.jsx("feComponentTransfer", { in: "blurred", result: "alphaFade", children: /* @__PURE__ */ jsxRuntime.jsx("feFuncA", { type: "gamma", amplitude: "1", exponent: "1.3", offset: "-0.05" }) }),
|
|
457
|
-
/* @__PURE__ */ jsxRuntime.jsx("feMorphology", { operator: "erode", radius: "0.4", in: "alphaFade", result: "eroded" }),
|
|
458
|
-
/* @__PURE__ */ jsxRuntime.jsx("feMerge", { children: /* @__PURE__ */ jsxRuntime.jsx("feMergeNode", { in: "eroded" }) })
|
|
459
|
-
] }) })
|
|
460
|
-
}
|
|
461
|
-
);
|
|
462
|
-
}
|
|
463
|
-
async function fetchNui(eventName, data, mockData) {
|
|
464
|
-
const options = {
|
|
465
|
-
method: "post",
|
|
466
|
-
headers: {
|
|
467
|
-
"Content-Type": "application/json; charset=UTF-8"
|
|
468
|
-
},
|
|
469
|
-
body: JSON.stringify(data)
|
|
470
|
-
};
|
|
471
|
-
if (isEnvBrowser() && mockData !== void 0) return mockData;
|
|
472
|
-
if (isEnvBrowser() && mockData === void 0) {
|
|
473
|
-
console.warn(
|
|
474
|
-
`[fetchNui] Called fetchNui for event "${eventName}" in browser environment without mockData. Returning empty object.`
|
|
475
|
-
);
|
|
476
|
-
return {};
|
|
477
|
-
}
|
|
478
|
-
const overrideResourceName = useSettings.getState().overideResourceName;
|
|
479
|
-
const hasResourceContext = typeof window.GetParentResourceName === "function" || !!overrideResourceName;
|
|
480
|
-
if (!hasResourceContext) {
|
|
481
|
-
return mockData ?? {};
|
|
482
|
-
}
|
|
483
|
-
const resourceName = window.GetParentResourceName ? window.GetParentResourceName() : overrideResourceName;
|
|
484
|
-
try {
|
|
485
|
-
const resp = await fetch(`https://${resourceName}/${eventName}`, options);
|
|
486
|
-
return await resp.json();
|
|
487
|
-
} catch {
|
|
488
|
-
return mockData ?? {};
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
function isPlainObject2(v) {
|
|
492
|
-
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
493
|
-
}
|
|
494
|
-
function deepMerge(base, patch) {
|
|
495
|
-
if (!isPlainObject2(base) || !isPlainObject2(patch)) {
|
|
496
|
-
return patch ?? base;
|
|
497
|
-
}
|
|
498
|
-
const out = { ...base };
|
|
499
|
-
for (const key of Object.keys(patch)) {
|
|
500
|
-
const patchVal = patch[key];
|
|
501
|
-
const baseVal = out[key];
|
|
502
|
-
out[key] = isPlainObject2(baseVal) && isPlainObject2(patchVal) ? deepMerge(baseVal, patchVal) : patchVal;
|
|
503
|
-
}
|
|
504
|
-
return out;
|
|
505
|
-
}
|
|
506
|
-
function changedTopLevelSections(changedFields) {
|
|
507
|
-
if (!changedFields || changedFields.length === 0) return [];
|
|
508
|
-
const sections = /* @__PURE__ */ new Set();
|
|
509
|
-
for (const path of changedFields) {
|
|
510
|
-
if (typeof path !== "string" || path.length === 0) continue;
|
|
511
|
-
const dot = path.indexOf(".");
|
|
512
|
-
sections.add(dot === -1 ? path : path.slice(0, dot));
|
|
513
|
-
}
|
|
514
|
-
return Array.from(sections);
|
|
515
|
-
}
|
|
516
|
-
var _instance = null;
|
|
517
|
-
function getScriptConfigInstance() {
|
|
518
|
-
if (!_instance) throw new Error("[dirk-cfx-react] createScriptConfig must be called before using ConfigPanel");
|
|
519
|
-
return _instance;
|
|
520
|
-
}
|
|
521
|
-
function createScriptConfig(defaultValue) {
|
|
522
|
-
const store2 = zustand.create(() => defaultValue);
|
|
523
|
-
let clientVersion = 0;
|
|
524
|
-
const useScriptConfigHooks = () => {
|
|
525
|
-
useNuiEvent(
|
|
526
|
-
"UPDATE_SCRIPT_CONFIG",
|
|
527
|
-
(data) => {
|
|
528
|
-
if (!data) return;
|
|
529
|
-
if (typeof data.clientVersion === "number") {
|
|
530
|
-
clientVersion = data.clientVersion;
|
|
531
|
-
}
|
|
532
|
-
if (data.config && typeof data.config === "object") {
|
|
533
|
-
store2.setState((prev) => ({ ...prev, ...data.config }));
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
);
|
|
537
|
-
};
|
|
538
|
-
const fetchScriptConfig = async () => {
|
|
539
|
-
try {
|
|
540
|
-
const response = await fetchNui("GET_FULL_SCRIPT_CONFIG");
|
|
541
|
-
if (response?.success && response.data?.config) {
|
|
542
|
-
store2.setState(() => response.data.config);
|
|
543
|
-
if (typeof response.data.clientVersion === "number") {
|
|
544
|
-
clientVersion = response.data.clientVersion;
|
|
545
|
-
}
|
|
546
|
-
return response.data.config;
|
|
547
|
-
}
|
|
548
|
-
} catch {
|
|
549
|
-
}
|
|
550
|
-
return null;
|
|
551
|
-
};
|
|
552
|
-
const fetchServerOnlyScriptConfig = async () => {
|
|
553
|
-
try {
|
|
554
|
-
const response = await fetchNui(
|
|
555
|
-
"GET_SERVER_ONLY_SCRIPT_CONFIG"
|
|
556
|
-
);
|
|
557
|
-
if (response?.success && response.data) {
|
|
558
|
-
if (typeof response.data.clientVersion === "number") {
|
|
559
|
-
clientVersion = response.data.clientVersion;
|
|
560
|
-
}
|
|
561
|
-
const sliver = response.data.serverOnly;
|
|
562
|
-
const merged = deepMerge(store2.getState(), sliver ?? {});
|
|
563
|
-
store2.setState(() => merged);
|
|
564
|
-
return merged;
|
|
565
|
-
}
|
|
566
|
-
} catch {
|
|
567
|
-
}
|
|
568
|
-
return null;
|
|
569
|
-
};
|
|
570
|
-
const updateScriptConfig = async (newConfig, changedFields) => {
|
|
571
|
-
store2.setState((prev) => ({ ...prev, ...newConfig }));
|
|
572
|
-
const sections = changedTopLevelSections(changedFields);
|
|
573
|
-
let payload;
|
|
574
|
-
if (sections.length > 0) {
|
|
575
|
-
const current = store2.getState();
|
|
576
|
-
const delta = {};
|
|
577
|
-
for (const key of sections) delta[key] = current[key];
|
|
578
|
-
payload = { data: delta, expectedVersion: clientVersion, sectionReplace: true };
|
|
579
|
-
} else {
|
|
580
|
-
payload = { data: newConfig, expectedVersion: clientVersion };
|
|
581
|
-
}
|
|
582
|
-
const response = await fetchNui("UPDATE_SCRIPT_CONFIG", payload);
|
|
583
|
-
if (response?.meta?.client_version != null) {
|
|
584
|
-
clientVersion = response.meta.client_version;
|
|
585
|
-
}
|
|
586
|
-
if (response?.success === false && response?.meta?.latestData) {
|
|
587
|
-
store2.setState((prev) => ({ ...prev, ...response.meta.latestData }));
|
|
588
|
-
}
|
|
589
|
-
return response;
|
|
590
|
-
};
|
|
591
|
-
const getScriptConfigHistory = async (params = {}) => {
|
|
592
|
-
return fetchNui("GET_SCRIPT_CONFIG_HISTORY", params);
|
|
593
|
-
};
|
|
594
|
-
const resetConfig = async () => {
|
|
595
|
-
const response = await fetchNui("RESET_SCRIPT_CONFIG");
|
|
596
|
-
if (response?.success) {
|
|
597
|
-
await fetchServerOnlyScriptConfig();
|
|
598
|
-
}
|
|
599
|
-
return response;
|
|
600
|
-
};
|
|
601
|
-
_instance = {
|
|
602
|
-
store: store2,
|
|
603
|
-
updateConfig: updateScriptConfig,
|
|
604
|
-
resetConfig,
|
|
605
|
-
getHistory: getScriptConfigHistory,
|
|
606
|
-
fetchConfig: fetchScriptConfig,
|
|
607
|
-
fetchServerOnly: fetchServerOnlyScriptConfig
|
|
608
|
-
};
|
|
609
|
-
return { store: store2, updateScriptConfig, resetConfig, getScriptConfigHistory, useScriptConfigHooks, fetchScriptConfig, fetchServerOnlyScriptConfig };
|
|
610
|
-
}
|
|
611
|
-
var moduleCache = /* @__PURE__ */ new Map();
|
|
612
|
-
function useValidModels(names) {
|
|
613
|
-
const cacheKey = react.useMemo(() => {
|
|
614
|
-
const unique = Array.from(new Set(names.filter((n) => typeof n === "string" && n.length > 0)));
|
|
615
|
-
unique.sort();
|
|
616
|
-
return unique.join("|");
|
|
617
|
-
}, [names]);
|
|
618
|
-
const [version, setVersion] = react.useState(0);
|
|
619
|
-
const inflight = react.useRef(/* @__PURE__ */ new Set());
|
|
620
|
-
react.useEffect(() => {
|
|
621
|
-
if (!cacheKey) return;
|
|
622
|
-
const all = cacheKey.split("|").filter(Boolean);
|
|
623
|
-
const missing = all.filter((n) => !moduleCache.has(n) && !inflight.current.has(n));
|
|
624
|
-
if (missing.length === 0) return;
|
|
625
|
-
missing.forEach((n) => inflight.current.add(n));
|
|
626
|
-
let cancelled = false;
|
|
627
|
-
fetchNui(
|
|
628
|
-
"ADMIN_TOOL_QUERY",
|
|
629
|
-
{ id: "validateModels", value: missing },
|
|
630
|
-
// Fallback when running outside FiveM (browser dev) — assume valid so the
|
|
631
|
-
// dev shell doesn't grey out every row.
|
|
632
|
-
Object.fromEntries(missing.map((n) => [n, true]))
|
|
633
|
-
).then((result) => {
|
|
634
|
-
if (cancelled) return;
|
|
635
|
-
const map = result && typeof result === "object" ? result : {};
|
|
636
|
-
missing.forEach((n) => {
|
|
637
|
-
moduleCache.set(n, !!map[n]);
|
|
638
|
-
inflight.current.delete(n);
|
|
639
|
-
});
|
|
640
|
-
setVersion((v) => v + 1);
|
|
641
|
-
}).catch(() => {
|
|
642
|
-
if (cancelled) return;
|
|
643
|
-
missing.forEach((n) => {
|
|
644
|
-
inflight.current.delete(n);
|
|
645
|
-
});
|
|
646
|
-
});
|
|
647
|
-
return () => {
|
|
648
|
-
cancelled = true;
|
|
649
|
-
};
|
|
650
|
-
}, [cacheKey]);
|
|
651
|
-
return react.useMemo(() => {
|
|
652
|
-
const out = /* @__PURE__ */ new Set();
|
|
653
|
-
if (!cacheKey) return out;
|
|
654
|
-
for (const n of cacheKey.split("|")) {
|
|
655
|
-
if (n && moduleCache.get(n) === true) out.add(n);
|
|
656
|
-
}
|
|
657
|
-
return out;
|
|
658
|
-
}, [cacheKey, version]);
|
|
659
|
-
}
|
|
660
|
-
var store = /* @__PURE__ */ new Map();
|
|
661
|
-
var listeners = /* @__PURE__ */ new Map();
|
|
662
|
-
function notify(key) {
|
|
663
|
-
const ls = listeners.get(key);
|
|
664
|
-
if (!ls) return;
|
|
665
|
-
ls.forEach((fn) => fn());
|
|
666
|
-
}
|
|
667
|
-
function useAdminState(key, initial) {
|
|
668
|
-
const [, setTick] = react.useState(0);
|
|
669
|
-
react.useEffect(() => {
|
|
670
|
-
const set = listeners.get(key) ?? /* @__PURE__ */ new Set();
|
|
671
|
-
listeners.set(key, set);
|
|
672
|
-
const handler = () => setTick((t) => t + 1);
|
|
673
|
-
set.add(handler);
|
|
674
|
-
return () => {
|
|
675
|
-
set.delete(handler);
|
|
676
|
-
if (set.size === 0) listeners.delete(key);
|
|
677
|
-
};
|
|
678
|
-
}, [key]);
|
|
679
|
-
const value = store.has(key) ? store.get(key) : initial;
|
|
680
|
-
const setValue = (v) => {
|
|
681
|
-
const next = typeof v === "function" ? v(value) : v;
|
|
682
|
-
store.set(key, next);
|
|
683
|
-
notify(key);
|
|
684
|
-
};
|
|
685
|
-
return [value, setValue];
|
|
686
|
-
}
|
|
687
|
-
function clearAdminState(key) {
|
|
688
|
-
if (key) {
|
|
689
|
-
store.delete(key);
|
|
690
|
-
notify(key);
|
|
691
|
-
} else {
|
|
692
|
-
const keys = Array.from(store.keys());
|
|
693
|
-
store.clear();
|
|
694
|
-
keys.forEach(notify);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
function usePlayers(opts = {}) {
|
|
698
|
-
const {
|
|
699
|
-
includeOffline = false,
|
|
700
|
-
search = "",
|
|
701
|
-
limit = 50,
|
|
702
|
-
staleTimeMs,
|
|
703
|
-
refetchIntervalMs
|
|
704
|
-
} = opts;
|
|
705
|
-
const query = reactQuery.useQuery({
|
|
706
|
-
queryKey: includeOffline ? ["dirk:players", "search", search.trim().toLowerCase(), limit] : ["dirk:players", "online"],
|
|
707
|
-
queryFn: async () => {
|
|
708
|
-
const toolId = includeOffline ? "searchPlayers" : "getOnlinePlayers";
|
|
709
|
-
const payload = includeOffline ? { id: toolId, value: { search: search.trim(), limit } } : { id: toolId };
|
|
710
|
-
const result = await fetchNui(
|
|
711
|
-
"ADMIN_TOOL_QUERY",
|
|
712
|
-
payload,
|
|
713
|
-
// Browser-dev fallback. Returns a couple of mock players so the
|
|
714
|
-
// dev shell isn't blank.
|
|
715
|
-
includeOffline ? [
|
|
716
|
-
{ id: 1, citizenId: "ABC12345", name: "Dev User", charName: "John Doe", online: true },
|
|
717
|
-
{ id: null, citizenId: "DEF67890", name: "", charName: "Jane Offline", online: false }
|
|
718
|
-
] : [
|
|
719
|
-
{ id: 1, citizenId: "ABC12345", name: "Dev User", charName: "John Doe", online: true }
|
|
720
|
-
]
|
|
721
|
-
);
|
|
722
|
-
return Array.isArray(result) ? result : [];
|
|
723
|
-
},
|
|
724
|
-
staleTime: staleTimeMs ?? (includeOffline ? 3e4 : 5e3),
|
|
725
|
-
gcTime: 5 * 6e4,
|
|
726
|
-
refetchInterval: refetchIntervalMs ?? false,
|
|
727
|
-
refetchOnWindowFocus: false,
|
|
728
|
-
placeholderData: includeOffline ? reactQuery.keepPreviousData : void 0
|
|
729
|
-
});
|
|
730
|
-
return {
|
|
731
|
-
players: query.data ?? [],
|
|
732
|
-
isLoading: query.isLoading,
|
|
733
|
-
isFetching: query.isFetching,
|
|
734
|
-
error: query.error ?? null,
|
|
735
|
-
refresh: () => query.refetch()
|
|
736
|
-
};
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
exports.FormProvider = FormProvider;
|
|
740
|
-
exports.TornEdgeSVGFilter = TornEdgeSVGFilter;
|
|
741
|
-
exports.clearAdminState = clearAdminState;
|
|
742
|
-
exports.createFormStore = createFormStore;
|
|
743
|
-
exports.createScriptConfig = createScriptConfig;
|
|
744
|
-
exports.getScriptConfigInstance = getScriptConfigInstance;
|
|
745
|
-
exports.useAdminState = useAdminState;
|
|
746
|
-
exports.useAudio = useAudio;
|
|
747
|
-
exports.useForm = useForm;
|
|
748
|
-
exports.useFormActions = useFormActions;
|
|
749
|
-
exports.useFormError = useFormError;
|
|
750
|
-
exports.useFormErrors = useFormErrors;
|
|
751
|
-
exports.useFormField = useFormField;
|
|
752
|
-
exports.useFormFields = useFormFields;
|
|
753
|
-
exports.useNuiEvent = useNuiEvent;
|
|
754
|
-
exports.usePlayers = usePlayers;
|
|
755
|
-
exports.useTornEdges = useTornEdges;
|
|
756
|
-
exports.useValidModels = useValidModels;
|
|
757
83
|
//# sourceMappingURL=index.cjs.map
|
|
758
84
|
//# sourceMappingURL=index.cjs.map
|