@passui/tanstack 0.2.5 → 0.2.6
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/types/src/route-boundary/default-loader.d.ts +6 -1
- package/package.json +3 -3
- package/src/route-boundary/default-loader.tsx +15 -5
- package/dist/client/chunks/form-fields-DlWu70u5.js +0 -630
- package/dist/client/src/solid/auth-shell/index.js +0 -15
- package/dist/client/src/solid/document/index.js +0 -51
- package/dist/client/src/solid/form-fields/index.js +0 -1
- package/dist/client/src/solid/forms/index.js +0 -33
- package/dist/client/src/solid/mutation/index.js +0 -46
- package/dist/client/src/solid/route-boundary/index.js +0 -73
- package/dist/client/src/solid/settings/index.js +0 -173
- package/dist/client/src/solid/tables/index.js +0 -500
- package/dist/server/src/solid/auth-shell/index.js +0 -15
- package/dist/server/src/solid/document/index.js +0 -55
- package/dist/server/src/solid/form-fields/index.js +0 -598
- package/dist/server/src/solid/forms/index.js +0 -33
- package/dist/server/src/solid/mutation/index.js +0 -46
- package/dist/server/src/solid/route-boundary/index.js +0 -73
- package/dist/server/src/solid/settings/index.js +0 -169
- package/dist/server/src/solid/tables/index.js +0 -480
|
@@ -1,598 +0,0 @@
|
|
|
1
|
-
import { createFormHookContexts } from "@tanstack/solid-form";
|
|
2
|
-
import { createComponent, escape, memo, mergeProps, ssr, ssrAttribute, ssrHydrationKey } from "solid-js/web";
|
|
3
|
-
import { For, Show, createContext, createEffect, createSignal, onCleanup, splitProps, useContext } from "solid-js";
|
|
4
|
-
import { TextField } from "@passui/solid/text-field";
|
|
5
|
-
import { TextEditor } from "@passui/solid/text-editor";
|
|
6
|
-
import { Toggle } from "@passui/solid/toggle";
|
|
7
|
-
import { cn } from "@passui/solid/cn";
|
|
8
|
-
import { Ambient, Button, ProfileImage, ProfileImageContent, ProfileImageFallback, Sheet } from "@passui/solid";
|
|
9
|
-
import { Button as Button$1 } from "@passui/solid/button";
|
|
10
|
-
//#region src/solid/forms/contexts.ts
|
|
11
|
-
var { fieldContext, formContext, useFieldContext, useFormContext } = createFormHookContexts();
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/solid/form-fields/fields.tsx
|
|
14
|
-
/** @jsxImportSource solid-js */
|
|
15
|
-
var _tmpl$$1 = [
|
|
16
|
-
"<p",
|
|
17
|
-
" class=\"text-footnote text-label-secondary\">",
|
|
18
|
-
"</p>"
|
|
19
|
-
];
|
|
20
|
-
var _tmpl$2$1 = [
|
|
21
|
-
"<div",
|
|
22
|
-
" class=\"flex items-center justify-between gap-4\"><div class=\"text-subheadline\"><!--$-->",
|
|
23
|
-
"<!--/--><!--$-->",
|
|
24
|
-
"<!--/--></div><!--$-->",
|
|
25
|
-
"<!--/--></div>"
|
|
26
|
-
];
|
|
27
|
-
var _tmpl$3$1 = [
|
|
28
|
-
"<p",
|
|
29
|
-
" id=\"",
|
|
30
|
-
"\" role=\"alert\" class=\"text-footnote text-danger\">",
|
|
31
|
-
"</p>"
|
|
32
|
-
];
|
|
33
|
-
var _tmpl$4$1 = [
|
|
34
|
-
"<div",
|
|
35
|
-
" class=\"flex flex-col gap-2\"><label",
|
|
36
|
-
" class=\"text-subheadline font-semibold\"><!--$-->",
|
|
37
|
-
"<!--/--><!--$-->",
|
|
38
|
-
"<!--/--></label><!--$-->",
|
|
39
|
-
"<!--/--><!--$-->",
|
|
40
|
-
"<!--/--></div>"
|
|
41
|
-
];
|
|
42
|
-
var _tmpl$5$1 = [
|
|
43
|
-
"<fieldset",
|
|
44
|
-
"",
|
|
45
|
-
" class=\"flex flex-col gap-2\"><legend class=\"text-subheadline font-semibold\">",
|
|
46
|
-
"</legend><!--$-->",
|
|
47
|
-
"<!--/--><div",
|
|
48
|
-
">",
|
|
49
|
-
"</div></fieldset>"
|
|
50
|
-
];
|
|
51
|
-
var _tmpl$6$1 = [
|
|
52
|
-
"<span",
|
|
53
|
-
" class=\"block text-footnote text-label-secondary\">",
|
|
54
|
-
"</span>"
|
|
55
|
-
];
|
|
56
|
-
var _tmpl$7$1 = [
|
|
57
|
-
"<label",
|
|
58
|
-
"><input type=\"radio\"",
|
|
59
|
-
"",
|
|
60
|
-
"",
|
|
61
|
-
" class=\"mt-1 accent-accent-text\"><!--$-->",
|
|
62
|
-
"<!--/--><span class=\"text-subheadline\"><!--$-->",
|
|
63
|
-
"<!--/--><!--$-->",
|
|
64
|
-
"<!--/--></span></label>"
|
|
65
|
-
];
|
|
66
|
-
var _tmpl$8 = [
|
|
67
|
-
"<fieldset",
|
|
68
|
-
" class=\"flex flex-col gap-3\"><legend class=\"text-subheadline font-semibold\">",
|
|
69
|
-
"</legend><!--$-->",
|
|
70
|
-
"<!--/--><!--$-->",
|
|
71
|
-
"<!--/--></fieldset>"
|
|
72
|
-
];
|
|
73
|
-
var _tmpl$9 = [
|
|
74
|
-
"<p",
|
|
75
|
-
" class=\"pl-8 text-footnote text-label-secondary\">",
|
|
76
|
-
"</p>"
|
|
77
|
-
];
|
|
78
|
-
var _tmpl$0 = [
|
|
79
|
-
"<div",
|
|
80
|
-
"><!--$-->",
|
|
81
|
-
"<!--/--><!--$-->",
|
|
82
|
-
"<!--/--></div>"
|
|
83
|
-
];
|
|
84
|
-
var PeachFieldLabels = createContext();
|
|
85
|
-
function errors(values) {
|
|
86
|
-
return values.flatMap((error) => typeof error === "string" ? [error] : error && typeof error === "object" && "message" in error ? [String(error.message)] : []);
|
|
87
|
-
}
|
|
88
|
-
function FieldInput(props) {
|
|
89
|
-
const field = useFieldContext(), reveal = useContext(PeachFieldLabels);
|
|
90
|
-
return createComponent(TextField, mergeProps({ revealLabels: reveal }, props, {
|
|
91
|
-
get name() {
|
|
92
|
-
return field().name;
|
|
93
|
-
},
|
|
94
|
-
get value() {
|
|
95
|
-
return field().state.value;
|
|
96
|
-
},
|
|
97
|
-
onInput: (event) => field().handleChange(event.currentTarget.value),
|
|
98
|
-
onBlur: () => field().handleBlur(),
|
|
99
|
-
get errors() {
|
|
100
|
-
return memo(() => !!field().state.meta.isTouched)() ? errors(field().state.meta.errors) : [];
|
|
101
|
-
}
|
|
102
|
-
}));
|
|
103
|
-
}
|
|
104
|
-
function FieldCheckbox(props) {
|
|
105
|
-
const field = useFieldContext();
|
|
106
|
-
return createComponent(Toggle, {
|
|
107
|
-
style: "checkbox",
|
|
108
|
-
get label() {
|
|
109
|
-
return props.label;
|
|
110
|
-
},
|
|
111
|
-
get disabled() {
|
|
112
|
-
return props.disabled;
|
|
113
|
-
},
|
|
114
|
-
get checked() {
|
|
115
|
-
return field().state.value;
|
|
116
|
-
},
|
|
117
|
-
onChange: (checked) => {
|
|
118
|
-
field().handleChange(checked);
|
|
119
|
-
field().handleBlur();
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
function FieldSwitch(props) {
|
|
124
|
-
const field = useFieldContext();
|
|
125
|
-
return ssr(_tmpl$2$1, ssrHydrationKey(), escape(props.label), escape(createComponent(Show, {
|
|
126
|
-
get when() {
|
|
127
|
-
return props.description;
|
|
128
|
-
},
|
|
129
|
-
get children() {
|
|
130
|
-
return ssr(_tmpl$$1, ssrHydrationKey(), escape(props.description));
|
|
131
|
-
}
|
|
132
|
-
})), escape(createComponent(Toggle, {
|
|
133
|
-
get label() {
|
|
134
|
-
return props.label;
|
|
135
|
-
},
|
|
136
|
-
get checked() {
|
|
137
|
-
return field().state.value;
|
|
138
|
-
},
|
|
139
|
-
get disabled() {
|
|
140
|
-
return props.disabled;
|
|
141
|
-
},
|
|
142
|
-
onChange: (checked) => {
|
|
143
|
-
field().handleChange(checked);
|
|
144
|
-
field().handleBlur();
|
|
145
|
-
}
|
|
146
|
-
})));
|
|
147
|
-
}
|
|
148
|
-
function FieldTextarea(props) {
|
|
149
|
-
const [local, rest] = splitProps(props, ["label", "icon"]), field = useFieldContext();
|
|
150
|
-
const messages = () => field().state.meta.isTouched ? errors(field().state.meta.errors) : [];
|
|
151
|
-
return ssr(_tmpl$4$1, ssrHydrationKey(), ssrAttribute("for", escape(field().name, true), false), escape(local.icon), escape(local.label), escape(createComponent(TextEditor, mergeProps(rest, {
|
|
152
|
-
get id() {
|
|
153
|
-
return field().name;
|
|
154
|
-
},
|
|
155
|
-
get name() {
|
|
156
|
-
return field().name;
|
|
157
|
-
},
|
|
158
|
-
get ["aria-invalid"]() {
|
|
159
|
-
return messages().length > 0;
|
|
160
|
-
},
|
|
161
|
-
get ["aria-describedby"]() {
|
|
162
|
-
return memo(() => !!messages().length)() ? `${field().name}-errors` : void 0;
|
|
163
|
-
},
|
|
164
|
-
get value() {
|
|
165
|
-
return field().state.value;
|
|
166
|
-
},
|
|
167
|
-
onBlur: () => field().handleBlur(),
|
|
168
|
-
onInput: (event) => field().handleChange(event.currentTarget.value)
|
|
169
|
-
}))), escape(createComponent(Show, {
|
|
170
|
-
get when() {
|
|
171
|
-
return messages().length;
|
|
172
|
-
},
|
|
173
|
-
get children() {
|
|
174
|
-
return ssr(_tmpl$3$1, ssrHydrationKey(), `${escape(field().name, true)}-errors`, escape(Array.from(new Set(messages())).join(". ")));
|
|
175
|
-
}
|
|
176
|
-
})));
|
|
177
|
-
}
|
|
178
|
-
function FieldOtp(props) {
|
|
179
|
-
const field = useFieldContext();
|
|
180
|
-
return createComponent(TextField, {
|
|
181
|
-
get label() {
|
|
182
|
-
return props.label;
|
|
183
|
-
},
|
|
184
|
-
get name() {
|
|
185
|
-
return field().name;
|
|
186
|
-
},
|
|
187
|
-
get value() {
|
|
188
|
-
return field().state.value;
|
|
189
|
-
},
|
|
190
|
-
inputmode: "numeric",
|
|
191
|
-
autocomplete: "one-time-code",
|
|
192
|
-
pattern: "[0-9]*",
|
|
193
|
-
get maxLength() {
|
|
194
|
-
return props.maxLength ?? 6;
|
|
195
|
-
},
|
|
196
|
-
onBlur: () => field().handleBlur(),
|
|
197
|
-
onInput: (event) => {
|
|
198
|
-
const value = event.currentTarget.value.replace(/\D/g, "").slice(0, props.maxLength ?? 6);
|
|
199
|
-
field().handleChange(value);
|
|
200
|
-
if (value.length === (props.maxLength ?? 6)) props.onComplete?.(value);
|
|
201
|
-
},
|
|
202
|
-
get errors() {
|
|
203
|
-
return memo(() => !!field().state.meta.isTouched)() ? errors(field().state.meta.errors) : [];
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
function FieldRadioCard(props) {
|
|
208
|
-
const field = useFieldContext();
|
|
209
|
-
return ssr(_tmpl$5$1, ssrHydrationKey(), ssrAttribute("disabled", props.disabled, true), escape(props.label), escape(createComponent(Show, {
|
|
210
|
-
get when() {
|
|
211
|
-
return props.description;
|
|
212
|
-
},
|
|
213
|
-
get children() {
|
|
214
|
-
return ssr(_tmpl$$1, ssrHydrationKey(), escape(props.description));
|
|
215
|
-
}
|
|
216
|
-
})), ssrAttribute("class", escape(cn("grid gap-2", props.columns === 2 && "md:grid-cols-2"), true), false), escape(createComponent(For, {
|
|
217
|
-
get each() {
|
|
218
|
-
return props.options;
|
|
219
|
-
},
|
|
220
|
-
children: (option) => ssr(_tmpl$7$1, ssrHydrationKey() + ssrAttribute("class", escape(cn("flex items-start gap-3 rounded-xl border p-3", field().state.value === option.value ? "border-accent-text bg-accent/10" : "border-separator bg-elevated", (props.disabled || option.disabled) && "opacity-40"), true), false), ssrAttribute("name", escape(field().name, true), false) + ssrAttribute("value", escape(option.value, true), false), ssrAttribute("checked", field().state.value === option.value, true), ssrAttribute("disabled", option.disabled, true), escape(option.icon), escape(option.label), escape(createComponent(Show, {
|
|
221
|
-
get when() {
|
|
222
|
-
return option.description;
|
|
223
|
-
},
|
|
224
|
-
get children() {
|
|
225
|
-
return ssr(_tmpl$6$1, ssrHydrationKey(), escape(option.description));
|
|
226
|
-
}
|
|
227
|
-
})))
|
|
228
|
-
})));
|
|
229
|
-
}
|
|
230
|
-
function FieldMultiselect(props) {
|
|
231
|
-
const field = useFieldContext();
|
|
232
|
-
return ssr(_tmpl$8, ssrHydrationKey(), escape(props.label), escape(createComponent(Show, {
|
|
233
|
-
get when() {
|
|
234
|
-
return props.description;
|
|
235
|
-
},
|
|
236
|
-
get children() {
|
|
237
|
-
return ssr(_tmpl$$1, ssrHydrationKey(), escape(props.description));
|
|
238
|
-
}
|
|
239
|
-
})), escape(createComponent(For, {
|
|
240
|
-
get each() {
|
|
241
|
-
return props.options;
|
|
242
|
-
},
|
|
243
|
-
children: (option) => ssr(_tmpl$0, ssrHydrationKey(), escape(createComponent(Toggle, {
|
|
244
|
-
style: "checkbox",
|
|
245
|
-
get label() {
|
|
246
|
-
return option.label;
|
|
247
|
-
},
|
|
248
|
-
get disabled() {
|
|
249
|
-
return option.disabled;
|
|
250
|
-
},
|
|
251
|
-
get checked() {
|
|
252
|
-
return field().state.value.includes(option.value);
|
|
253
|
-
},
|
|
254
|
-
onChange: (checked) => {
|
|
255
|
-
field().handleChange(checked ? Array.from(/* @__PURE__ */ new Set([...field().state.value, option.value])) : field().state.value.filter((value) => value !== option.value));
|
|
256
|
-
field().handleBlur();
|
|
257
|
-
}
|
|
258
|
-
})), escape(createComponent(Show, {
|
|
259
|
-
get when() {
|
|
260
|
-
return option.description;
|
|
261
|
-
},
|
|
262
|
-
get children() {
|
|
263
|
-
return ssr(_tmpl$9, ssrHydrationKey(), escape(option.description));
|
|
264
|
-
}
|
|
265
|
-
})))
|
|
266
|
-
})));
|
|
267
|
-
}
|
|
268
|
-
//#endregion
|
|
269
|
-
//#region src/solid/form-fields/avatar.tsx
|
|
270
|
-
/** @jsxImportSource solid-js */
|
|
271
|
-
var _tmpl$ = [
|
|
272
|
-
"<p",
|
|
273
|
-
" class=\"text-footnote text-label-secondary\">",
|
|
274
|
-
"</p>"
|
|
275
|
-
];
|
|
276
|
-
var _tmpl$2 = [
|
|
277
|
-
"<div",
|
|
278
|
-
" class=\"flex gap-2\"><!--$-->",
|
|
279
|
-
"<!--/--><!--$-->",
|
|
280
|
-
"<!--/--></div>"
|
|
281
|
-
];
|
|
282
|
-
var _tmpl$3 = [
|
|
283
|
-
"<div",
|
|
284
|
-
" class=\"flex flex-col items-center gap-3\"><button type=\"button\" aria-label=\"",
|
|
285
|
-
"\" class=\"rounded-full focus-visible:ring-2 focus-visible:ring-accent\">",
|
|
286
|
-
"</button><!--$-->",
|
|
287
|
-
"<!--/--></div>"
|
|
288
|
-
];
|
|
289
|
-
var _tmpl$4 = [
|
|
290
|
-
"<input",
|
|
291
|
-
" hidden type=\"file\"",
|
|
292
|
-
">"
|
|
293
|
-
];
|
|
294
|
-
var _tmpl$5 = [
|
|
295
|
-
"<p",
|
|
296
|
-
" role=\"alert\">",
|
|
297
|
-
"</p>"
|
|
298
|
-
];
|
|
299
|
-
var _tmpl$6 = [
|
|
300
|
-
"<div",
|
|
301
|
-
" class=\"flex flex-col gap-3 p-5\"><p>",
|
|
302
|
-
"</p><!--$-->",
|
|
303
|
-
"<!--/--><!--$-->",
|
|
304
|
-
"<!--/--><!--$-->",
|
|
305
|
-
"<!--/--><!--$-->",
|
|
306
|
-
"<!--/--><!--$-->",
|
|
307
|
-
"<!--/--><!--$-->",
|
|
308
|
-
"<!--/--><!--$-->",
|
|
309
|
-
"<!--/--></div>"
|
|
310
|
-
];
|
|
311
|
-
var _tmpl$7 = [
|
|
312
|
-
"<div",
|
|
313
|
-
" class=\"flex flex-col gap-3\"><video muted playsinline class=\"max-h-64 rounded-xl\"></video><!--$-->",
|
|
314
|
-
"<!--/--></div>"
|
|
315
|
-
];
|
|
316
|
-
function FieldAvatar(props) {
|
|
317
|
-
const field = useFieldContext();
|
|
318
|
-
const [pending, setPending] = createSignal(null), [open, setOpen] = createSignal(false), [camera, setCamera] = createSignal(false), [preview, setPreview] = createSignal(), [error, setError] = createSignal("");
|
|
319
|
-
let input;
|
|
320
|
-
const labels = () => ({
|
|
321
|
-
edit: "Edit",
|
|
322
|
-
remove: "Remove",
|
|
323
|
-
confirmHint: "Press Enter to use this photo, Esc to cancel",
|
|
324
|
-
save: "Use photo",
|
|
325
|
-
cancel: "Cancel",
|
|
326
|
-
photo: "Photo",
|
|
327
|
-
photoDescription: "Choose how you appear.",
|
|
328
|
-
choosePhoto: "Choose Photo…",
|
|
329
|
-
takePhoto: "Take Photo",
|
|
330
|
-
capture: "Take photo",
|
|
331
|
-
monogram: "Monogram",
|
|
332
|
-
removePhoto: "Remove Photo",
|
|
333
|
-
...props.labels
|
|
334
|
-
});
|
|
335
|
-
createEffect(() => {
|
|
336
|
-
const shown = pending() ?? field().state.value;
|
|
337
|
-
if (!(shown instanceof File)) {
|
|
338
|
-
setPreview(void 0);
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
const url = URL.createObjectURL(shown);
|
|
342
|
-
setPreview(url);
|
|
343
|
-
onCleanup(() => URL.revokeObjectURL(url));
|
|
344
|
-
});
|
|
345
|
-
const image = () => field().state.value === false && !pending() ? void 0 : preview() ?? props.existingImage ?? void 0;
|
|
346
|
-
function keep() {
|
|
347
|
-
const file = pending();
|
|
348
|
-
if (file) {
|
|
349
|
-
field().handleChange(file);
|
|
350
|
-
field().handleBlur();
|
|
351
|
-
setPending(null);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
createEffect(() => {
|
|
355
|
-
if (!pending()) return;
|
|
356
|
-
const key = (event) => {
|
|
357
|
-
if (event.key === "Enter") {
|
|
358
|
-
event.preventDefault();
|
|
359
|
-
keep();
|
|
360
|
-
}
|
|
361
|
-
if (event.key === "Escape") setPending(null);
|
|
362
|
-
};
|
|
363
|
-
window.addEventListener("keydown", key);
|
|
364
|
-
onCleanup(() => window.removeEventListener("keydown", key));
|
|
365
|
-
});
|
|
366
|
-
async function monogram() {
|
|
367
|
-
const canvas = document.createElement("canvas");
|
|
368
|
-
canvas.width = canvas.height = 512;
|
|
369
|
-
const context = canvas.getContext("2d");
|
|
370
|
-
if (!context) return;
|
|
371
|
-
const style = getComputedStyle(input.parentElement);
|
|
372
|
-
context.fillStyle = style.getPropertyValue("--color-accent").trim() || style.color;
|
|
373
|
-
context.fillRect(0, 0, 512, 512);
|
|
374
|
-
context.fillStyle = "white";
|
|
375
|
-
context.font = "240px system-ui";
|
|
376
|
-
context.textAlign = "center";
|
|
377
|
-
context.textBaseline = "middle";
|
|
378
|
-
context.fillText(props.label.trim().split(/\s+/).map((word) => word[0]).slice(0, 2).join("").toUpperCase(), 256, 270);
|
|
379
|
-
const blob = await new Promise((resolve) => canvas.toBlob(resolve, "image/png"));
|
|
380
|
-
if (blob) {
|
|
381
|
-
field().handleChange(new File([blob], "monogram.png", { type: "image/png" }));
|
|
382
|
-
field().handleBlur();
|
|
383
|
-
setOpen(false);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
return createComponent(Ambient, {
|
|
387
|
-
get src() {
|
|
388
|
-
return memo(() => !!(props.caption && !props.compact))() ? image() : void 0;
|
|
389
|
-
},
|
|
390
|
-
get ["class"]() {
|
|
391
|
-
return props.compact ? "flex flex-wrap items-center gap-4" : "flex flex-col items-center gap-4";
|
|
392
|
-
},
|
|
393
|
-
get children() {
|
|
394
|
-
return [
|
|
395
|
-
ssr(_tmpl$3, ssrHydrationKey(), `${escape(labels().edit, true)} ${escape(props.label, true)}`, escape(createComponent(ProfileImage, {
|
|
396
|
-
get ["class"]() {
|
|
397
|
-
return props.compact ? "size-16" : "size-43";
|
|
398
|
-
},
|
|
399
|
-
get children() {
|
|
400
|
-
return [createComponent(ProfileImageContent, {
|
|
401
|
-
get src() {
|
|
402
|
-
return image();
|
|
403
|
-
},
|
|
404
|
-
get alt() {
|
|
405
|
-
return props.label;
|
|
406
|
-
}
|
|
407
|
-
}), createComponent(ProfileImageFallback, { get children() {
|
|
408
|
-
return props.label.slice(0, 1).toUpperCase();
|
|
409
|
-
} })];
|
|
410
|
-
}
|
|
411
|
-
})), escape(createComponent(Show, {
|
|
412
|
-
get when() {
|
|
413
|
-
return pending();
|
|
414
|
-
},
|
|
415
|
-
get children() {
|
|
416
|
-
return [ssr(_tmpl$, ssrHydrationKey(), escape(labels().confirmHint)), ssr(_tmpl$2, ssrHydrationKey(), escape(createComponent(Button, {
|
|
417
|
-
variant: "secondary",
|
|
418
|
-
onClick: () => setPending(null),
|
|
419
|
-
get children() {
|
|
420
|
-
return labels().cancel;
|
|
421
|
-
}
|
|
422
|
-
})), escape(createComponent(Button, {
|
|
423
|
-
onClick: keep,
|
|
424
|
-
get children() {
|
|
425
|
-
return labels().save;
|
|
426
|
-
}
|
|
427
|
-
})))];
|
|
428
|
-
}
|
|
429
|
-
}))),
|
|
430
|
-
createComponent(Show, {
|
|
431
|
-
get when() {
|
|
432
|
-
return !pending();
|
|
433
|
-
},
|
|
434
|
-
get children() {
|
|
435
|
-
return props.caption;
|
|
436
|
-
}
|
|
437
|
-
}),
|
|
438
|
-
ssr(_tmpl$4, ssrHydrationKey(), ssrAttribute("accept", escape(props.accept ?? "image/png,image/webp,image/jpeg,image/svg+xml", true), false)),
|
|
439
|
-
createComponent(Sheet, {
|
|
440
|
-
get open() {
|
|
441
|
-
return open();
|
|
442
|
-
},
|
|
443
|
-
get label() {
|
|
444
|
-
return labels().photo;
|
|
445
|
-
},
|
|
446
|
-
onClose: () => {
|
|
447
|
-
setOpen(false);
|
|
448
|
-
setCamera(false);
|
|
449
|
-
},
|
|
450
|
-
get children() {
|
|
451
|
-
return ssr(_tmpl$6, ssrHydrationKey(), escape(labels().photoDescription), escape(createComponent(Button, {
|
|
452
|
-
variant: "secondary",
|
|
453
|
-
onClick: () => {
|
|
454
|
-
setOpen(false);
|
|
455
|
-
input.click();
|
|
456
|
-
},
|
|
457
|
-
get children() {
|
|
458
|
-
return labels().choosePhoto;
|
|
459
|
-
}
|
|
460
|
-
})), escape(createComponent(Button, {
|
|
461
|
-
variant: "secondary",
|
|
462
|
-
onClick: () => {
|
|
463
|
-
setError("");
|
|
464
|
-
setCamera(true);
|
|
465
|
-
},
|
|
466
|
-
get children() {
|
|
467
|
-
return labels().takePhoto;
|
|
468
|
-
}
|
|
469
|
-
})), escape(createComponent(Button, {
|
|
470
|
-
variant: "secondary",
|
|
471
|
-
onClick: () => void monogram().catch((error) => setError(String(error))),
|
|
472
|
-
get children() {
|
|
473
|
-
return labels().monogram;
|
|
474
|
-
}
|
|
475
|
-
})), escape(createComponent(Show, {
|
|
476
|
-
get when() {
|
|
477
|
-
return memo(() => !!props.clearable)() && image();
|
|
478
|
-
},
|
|
479
|
-
get children() {
|
|
480
|
-
return createComponent(Button, {
|
|
481
|
-
variant: "destructive",
|
|
482
|
-
onClick: () => {
|
|
483
|
-
field().handleChange(false);
|
|
484
|
-
field().handleBlur();
|
|
485
|
-
setOpen(false);
|
|
486
|
-
},
|
|
487
|
-
get children() {
|
|
488
|
-
return labels().removePhoto;
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
})), escape(createComponent(Show, {
|
|
493
|
-
get when() {
|
|
494
|
-
return camera();
|
|
495
|
-
},
|
|
496
|
-
get children() {
|
|
497
|
-
return createComponent(Camera, {
|
|
498
|
-
get captureLabel() {
|
|
499
|
-
return labels().capture;
|
|
500
|
-
},
|
|
501
|
-
onError: setError,
|
|
502
|
-
onCapture: (file) => {
|
|
503
|
-
setPending(file);
|
|
504
|
-
setCamera(false);
|
|
505
|
-
setOpen(false);
|
|
506
|
-
}
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
|
-
})), escape(createComponent(Show, {
|
|
510
|
-
get when() {
|
|
511
|
-
return error();
|
|
512
|
-
},
|
|
513
|
-
get children() {
|
|
514
|
-
return ssr(_tmpl$5, ssrHydrationKey(), escape(error()));
|
|
515
|
-
}
|
|
516
|
-
})), escape(createComponent(Button, {
|
|
517
|
-
variant: "ghost",
|
|
518
|
-
onClick: () => {
|
|
519
|
-
setOpen(false);
|
|
520
|
-
setCamera(false);
|
|
521
|
-
},
|
|
522
|
-
get children() {
|
|
523
|
-
return labels().cancel;
|
|
524
|
-
}
|
|
525
|
-
})));
|
|
526
|
-
}
|
|
527
|
-
})
|
|
528
|
-
];
|
|
529
|
-
}
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
function Camera(props) {
|
|
533
|
-
let video, stream, disposed = false;
|
|
534
|
-
createEffect(() => {
|
|
535
|
-
navigator.mediaDevices.getUserMedia({ video: { facingMode: "user" } }).then((value) => {
|
|
536
|
-
if (disposed) {
|
|
537
|
-
value.getTracks().forEach((track) => {
|
|
538
|
-
track.stop();
|
|
539
|
-
});
|
|
540
|
-
return;
|
|
541
|
-
}
|
|
542
|
-
stream = value;
|
|
543
|
-
video.srcObject = value;
|
|
544
|
-
video.play();
|
|
545
|
-
}).catch((error) => props.onError(String(error)));
|
|
546
|
-
onCleanup(() => {
|
|
547
|
-
disposed = true;
|
|
548
|
-
stream?.getTracks().forEach((track) => {
|
|
549
|
-
track.stop();
|
|
550
|
-
});
|
|
551
|
-
});
|
|
552
|
-
});
|
|
553
|
-
function capture() {
|
|
554
|
-
if (!video.videoWidth) return;
|
|
555
|
-
const canvas = document.createElement("canvas");
|
|
556
|
-
canvas.width = video.videoWidth;
|
|
557
|
-
canvas.height = video.videoHeight;
|
|
558
|
-
canvas.getContext("2d")?.drawImage(video, 0, 0);
|
|
559
|
-
canvas.toBlob((blob) => {
|
|
560
|
-
if (blob && !disposed) props.onCapture(new File([blob], "photo.jpg", { type: "image/jpeg" }));
|
|
561
|
-
}, "image/jpeg", .92);
|
|
562
|
-
}
|
|
563
|
-
return ssr(_tmpl$7, ssrHydrationKey(), escape(createComponent(Button, {
|
|
564
|
-
onClick: capture,
|
|
565
|
-
get children() {
|
|
566
|
-
return props.captureLabel;
|
|
567
|
-
}
|
|
568
|
-
})));
|
|
569
|
-
}
|
|
570
|
-
//#endregion
|
|
571
|
-
//#region src/solid/form-fields/submit.tsx
|
|
572
|
-
/** @jsxImportSource solid-js */
|
|
573
|
-
function Submit(props) {
|
|
574
|
-
const form = useFormContext();
|
|
575
|
-
return createComponent(form.Subscribe, {
|
|
576
|
-
selector: (state) => ({
|
|
577
|
-
pending: state.isSubmitting,
|
|
578
|
-
valid: state.canSubmit,
|
|
579
|
-
dirty: state.isDirty,
|
|
580
|
-
touched: state.isTouched
|
|
581
|
-
}),
|
|
582
|
-
children: (state) => createComponent(Button$1, {
|
|
583
|
-
type: "submit",
|
|
584
|
-
get isPending() {
|
|
585
|
-
return state().pending;
|
|
586
|
-
},
|
|
587
|
-
get disabled() {
|
|
588
|
-
return !state().valid || !state().dirty || !state().touched;
|
|
589
|
-
},
|
|
590
|
-
"class": "w-full",
|
|
591
|
-
get children() {
|
|
592
|
-
return props.label;
|
|
593
|
-
}
|
|
594
|
-
})
|
|
595
|
-
});
|
|
596
|
-
}
|
|
597
|
-
//#endregion
|
|
598
|
-
export { FieldAvatar, FieldCheckbox, FieldInput, FieldMultiselect, FieldOtp, FieldRadioCard, FieldSwitch, FieldTextarea, PeachFieldLabels, Submit, formContext as n, fieldContext as t };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { FieldAvatar, FieldCheckbox, FieldInput, FieldMultiselect, FieldOtp, FieldRadioCard, FieldSwitch, FieldTextarea, PeachFieldLabels, Submit, n as formContext, t as fieldContext } from "../form-fields/index.js";
|
|
2
|
-
import { createFormHook, useSelector, useStore } from "@tanstack/solid-form";
|
|
3
|
-
import { escape, ssr, ssrAttribute, ssrHydrationKey } from "solid-js/web";
|
|
4
|
-
import { cn } from "@passui/solid/cn";
|
|
5
|
-
//#region src/solid/forms/form-alert.tsx
|
|
6
|
-
var _tmpl$ = [
|
|
7
|
-
"<div",
|
|
8
|
-
" role=\"alert\"",
|
|
9
|
-
"><span class=\"min-w-0\">",
|
|
10
|
-
"</span></div>"
|
|
11
|
-
];
|
|
12
|
-
function FormAlert(props) {
|
|
13
|
-
return ssr(_tmpl$, ssrHydrationKey(), ssrAttribute("class", escape(cn("flex items-start gap-2.5 rounded-2xl bg-danger/12 px-4 py-3 text-subheadline font-medium text-danger ring-1 ring-danger/25 motion-safe:animate-in motion-safe:fade-in-0", props.className), true), false), escape(props.children));
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/solid/forms/index.ts
|
|
17
|
-
var { useAppForm, withForm } = createFormHook({
|
|
18
|
-
fieldContext,
|
|
19
|
-
formContext,
|
|
20
|
-
fieldComponents: {
|
|
21
|
-
input: FieldInput,
|
|
22
|
-
avatar: FieldAvatar,
|
|
23
|
-
checkbox: FieldCheckbox,
|
|
24
|
-
textarea: FieldTextarea,
|
|
25
|
-
switch: FieldSwitch,
|
|
26
|
-
otp: FieldOtp,
|
|
27
|
-
radioCard: FieldRadioCard,
|
|
28
|
-
multiselect: FieldMultiselect
|
|
29
|
-
},
|
|
30
|
-
formComponents: { submit: Submit }
|
|
31
|
-
});
|
|
32
|
-
//#endregion
|
|
33
|
-
export { FieldAvatar, FieldCheckbox, FieldInput, FieldMultiselect, FieldOtp, FieldRadioCard, FieldSwitch, FieldTextarea, FormAlert, PeachFieldLabels, Submit, useAppForm as createAppForm, useAppForm, useSelector, useStore, withForm };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { useMutation, useQueryClient } from "@tanstack/solid-query";
|
|
2
|
-
import { toast } from "@passui/solid/toast";
|
|
3
|
-
//#region src/shared/optimistic.ts
|
|
4
|
-
/** Restore only the snapshot this mutation wrote, preserving newer concurrent writes. */
|
|
5
|
-
function shouldRestoreOptimisticSnapshot(current, expected) {
|
|
6
|
-
return current === expected;
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/solid/mutation/use-app-mutation.ts
|
|
10
|
-
function useAppMutation(getOptions) {
|
|
11
|
-
const q = useQueryClient();
|
|
12
|
-
return useMutation(() => {
|
|
13
|
-
const { invalidates = [], optimisticUpdate, successMessage, successDescription, errorMessage, onSuccess, onError, ...options } = getOptions();
|
|
14
|
-
return {
|
|
15
|
-
...options,
|
|
16
|
-
onMutate: async (variables) => {
|
|
17
|
-
if (!optimisticUpdate) return void 0;
|
|
18
|
-
const { queryKey, updater } = optimisticUpdate;
|
|
19
|
-
await q.cancelQueries({ queryKey });
|
|
20
|
-
const previous = q.getQueryData(queryKey);
|
|
21
|
-
const next = updater(previous, variables);
|
|
22
|
-
q.setQueryData(queryKey, next);
|
|
23
|
-
return {
|
|
24
|
-
previous,
|
|
25
|
-
next
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
onSuccess: (data, variables) => {
|
|
29
|
-
if (successMessage) toast.success(typeof successMessage === "function" ? successMessage(data, variables) : successMessage, { description: typeof successDescription === "function" ? successDescription(data, variables) : successDescription });
|
|
30
|
-
onSuccess?.(data, variables);
|
|
31
|
-
},
|
|
32
|
-
onError: (error, variables, context) => {
|
|
33
|
-
if (optimisticUpdate && context) {
|
|
34
|
-
if (shouldRestoreOptimisticSnapshot(q.getQueryData(optimisticUpdate.queryKey), context.next)) q.setQueryData(optimisticUpdate.queryKey, context.previous);
|
|
35
|
-
}
|
|
36
|
-
toast.error(errorMessage ?? "Something went wrong", { description: error.message });
|
|
37
|
-
onError?.(error, variables);
|
|
38
|
-
},
|
|
39
|
-
onSettled: () => {
|
|
40
|
-
for (const queryKey of invalidates) q.invalidateQueries({ queryKey });
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
//#endregion
|
|
46
|
-
export { useAppMutation as createAppMutation, useAppMutation, shouldRestoreOptimisticSnapshot };
|