@trypattern/sdk 0.1.31 → 0.1.33
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/bookings.d.ts +8 -8
- package/dist/bookingsStore.d.ts +24 -24
- package/dist/components/FilePicker.d.ts +13 -0
- package/dist/components/FilePicker.js +81 -0
- package/dist/components/FilePreview.d.ts +10 -0
- package/dist/components/FilePreview.js +36 -0
- package/dist/components/Image.d.ts +2 -1
- package/dist/components/Image.js +5 -2
- package/dist/components/Menu.js +2 -2
- package/dist/components/ProgressBar.d.ts +8 -0
- package/dist/components/ProgressBar.js +29 -0
- package/dist/components/SegmentedControl.js +2 -2
- package/dist/components/TableRow.d.ts +9 -0
- package/dist/components/TableRow.js +36 -0
- package/dist/components/icons.d.ts +1 -0
- package/dist/components/icons.js +5 -0
- package/dist/components/interaction.d.ts +1 -1
- package/dist/files.d.ts +11 -0
- package/dist/files.js +19 -0
- package/dist/flows/browser.js +7 -0
- package/dist/flows/flows.d.ts +7 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/media.d.ts +2 -1
- package/dist/media.js +4 -4
- package/dist/publishWire.d.ts +55 -27
- package/dist/publishWire.js +12 -0
- package/dist/react.d.ts +4 -0
- package/dist/react.js +4 -0
- package/dist/rules/lintPlugin.js +4 -0
- package/dist/schema.d.ts +1 -1
- package/dist/server/services.d.ts +2 -2
- package/dist/server/services.js +21 -4
- package/dist/server/tables.js +8 -1
- package/dist/serviceClients.js +107 -23
- package/dist/services.d.ts +28 -4
- package/dist/services.js +8 -4
- package/package.json +1 -1
package/dist/bookings.d.ts
CHANGED
|
@@ -205,7 +205,7 @@ export declare const bookingServices: {
|
|
|
205
205
|
closed: "closed";
|
|
206
206
|
full: "full";
|
|
207
207
|
}>;
|
|
208
|
-
}, z.core.$strip
|
|
208
|
+
}, z.core.$strip>>, false>>;
|
|
209
209
|
readonly windows: NoInfer<import("./services.ts").ServiceCall<"/bookings/windows", {
|
|
210
210
|
date: z.ZodString;
|
|
211
211
|
}, z.ZodArray<z.ZodObject<{
|
|
@@ -214,7 +214,7 @@ export declare const bookingServices: {
|
|
|
214
214
|
start: z.ZodString;
|
|
215
215
|
end: z.ZodString;
|
|
216
216
|
remaining: z.ZodNumber;
|
|
217
|
-
}, z.core.$strip
|
|
217
|
+
}, z.core.$strip>>, false>>;
|
|
218
218
|
readonly request: NoInfer<import("./services.ts").ServiceCall<"/bookings/requests", {
|
|
219
219
|
offering: z.ZodString;
|
|
220
220
|
date: z.ZodString;
|
|
@@ -242,7 +242,7 @@ export declare const bookingServices: {
|
|
|
242
242
|
declined: "declined";
|
|
243
243
|
cancelled: "cancelled";
|
|
244
244
|
}>;
|
|
245
|
-
}, z.core.$strip
|
|
245
|
+
}, z.core.$strip>, false>>;
|
|
246
246
|
readonly requests: NoInfer<import("./services.ts").ServiceCall<"/bookings/requests", {}, z.ZodArray<z.ZodObject<{
|
|
247
247
|
id: z.ZodString;
|
|
248
248
|
createdAt: z.ZodString;
|
|
@@ -261,7 +261,7 @@ export declare const bookingServices: {
|
|
|
261
261
|
declined: "declined";
|
|
262
262
|
cancelled: "cancelled";
|
|
263
263
|
}>;
|
|
264
|
-
}, z.core.$strip
|
|
264
|
+
}, z.core.$strip>>, false>>;
|
|
265
265
|
readonly accept: NoInfer<import("./services.ts").ServiceCall<"/bookings/requests/:id/accept", {}, z.ZodObject<{
|
|
266
266
|
id: z.ZodString;
|
|
267
267
|
createdAt: z.ZodString;
|
|
@@ -280,7 +280,7 @@ export declare const bookingServices: {
|
|
|
280
280
|
declined: "declined";
|
|
281
281
|
cancelled: "cancelled";
|
|
282
282
|
}>;
|
|
283
|
-
}, z.core.$strip
|
|
283
|
+
}, z.core.$strip>, false>>;
|
|
284
284
|
readonly decline: NoInfer<import("./services.ts").ServiceCall<"/bookings/requests/:id/decline", {}, z.ZodObject<{
|
|
285
285
|
id: z.ZodString;
|
|
286
286
|
createdAt: z.ZodString;
|
|
@@ -299,7 +299,7 @@ export declare const bookingServices: {
|
|
|
299
299
|
declined: "declined";
|
|
300
300
|
cancelled: "cancelled";
|
|
301
301
|
}>;
|
|
302
|
-
}, z.core.$strip
|
|
302
|
+
}, z.core.$strip>, false>>;
|
|
303
303
|
readonly rules: NoInfer<import("./services.ts").ServiceCall<"/bookings/rules", {}, z.ZodObject<{
|
|
304
304
|
windows: z.ZodArray<z.ZodObject<{
|
|
305
305
|
weekday: z.ZodEnum<{
|
|
@@ -323,7 +323,7 @@ export declare const bookingServices: {
|
|
|
323
323
|
date: z.ZodString;
|
|
324
324
|
reason: z.ZodString;
|
|
325
325
|
}, z.core.$strip>>;
|
|
326
|
-
}, z.core.$strip
|
|
326
|
+
}, z.core.$strip>, false>>;
|
|
327
327
|
readonly saveRules: NoInfer<import("./services.ts").ServiceCall<"/bookings/rules", {
|
|
328
328
|
windows: z.ZodArray<z.ZodObject<{
|
|
329
329
|
weekday: z.ZodEnum<{
|
|
@@ -370,7 +370,7 @@ export declare const bookingServices: {
|
|
|
370
370
|
date: z.ZodString;
|
|
371
371
|
reason: z.ZodString;
|
|
372
372
|
}, z.core.$strip>>;
|
|
373
|
-
}, z.core.$strip
|
|
373
|
+
}, z.core.$strip>, false>>;
|
|
374
374
|
};
|
|
375
375
|
};
|
|
376
376
|
export declare const FULL = "That window was just taken. Choose another window or another day.";
|
package/dist/bookingsStore.d.ts
CHANGED
|
@@ -98,7 +98,7 @@ declare const Bookings_base: import("./store.ts").StoreClass<{
|
|
|
98
98
|
closed: "closed";
|
|
99
99
|
full: "full";
|
|
100
100
|
}>;
|
|
101
|
-
}, z.core.$strip
|
|
101
|
+
}, z.core.$strip>>, false>>;
|
|
102
102
|
readonly windows: NoInfer<import("./services.ts").ServiceCall<"/bookings/windows", {
|
|
103
103
|
date: z.ZodString;
|
|
104
104
|
}, z.ZodArray<z.ZodObject<{
|
|
@@ -107,7 +107,7 @@ declare const Bookings_base: import("./store.ts").StoreClass<{
|
|
|
107
107
|
start: z.ZodString;
|
|
108
108
|
end: z.ZodString;
|
|
109
109
|
remaining: z.ZodNumber;
|
|
110
|
-
}, z.core.$strip
|
|
110
|
+
}, z.core.$strip>>, false>>;
|
|
111
111
|
readonly request: NoInfer<import("./services.ts").ServiceCall<"/bookings/requests", {
|
|
112
112
|
offering: z.ZodString;
|
|
113
113
|
date: z.ZodString;
|
|
@@ -135,7 +135,7 @@ declare const Bookings_base: import("./store.ts").StoreClass<{
|
|
|
135
135
|
declined: "declined";
|
|
136
136
|
cancelled: "cancelled";
|
|
137
137
|
}>;
|
|
138
|
-
}, z.core.$strip
|
|
138
|
+
}, z.core.$strip>, false>>;
|
|
139
139
|
readonly requests: NoInfer<import("./services.ts").ServiceCall<"/bookings/requests", {}, z.ZodArray<z.ZodObject<{
|
|
140
140
|
id: z.ZodString;
|
|
141
141
|
createdAt: z.ZodString;
|
|
@@ -154,7 +154,7 @@ declare const Bookings_base: import("./store.ts").StoreClass<{
|
|
|
154
154
|
declined: "declined";
|
|
155
155
|
cancelled: "cancelled";
|
|
156
156
|
}>;
|
|
157
|
-
}, z.core.$strip
|
|
157
|
+
}, z.core.$strip>>, false>>;
|
|
158
158
|
readonly accept: NoInfer<import("./services.ts").ServiceCall<"/bookings/requests/:id/accept", {}, z.ZodObject<{
|
|
159
159
|
id: z.ZodString;
|
|
160
160
|
createdAt: z.ZodString;
|
|
@@ -173,7 +173,7 @@ declare const Bookings_base: import("./store.ts").StoreClass<{
|
|
|
173
173
|
declined: "declined";
|
|
174
174
|
cancelled: "cancelled";
|
|
175
175
|
}>;
|
|
176
|
-
}, z.core.$strip
|
|
176
|
+
}, z.core.$strip>, false>>;
|
|
177
177
|
readonly decline: NoInfer<import("./services.ts").ServiceCall<"/bookings/requests/:id/decline", {}, z.ZodObject<{
|
|
178
178
|
id: z.ZodString;
|
|
179
179
|
createdAt: z.ZodString;
|
|
@@ -192,7 +192,7 @@ declare const Bookings_base: import("./store.ts").StoreClass<{
|
|
|
192
192
|
declined: "declined";
|
|
193
193
|
cancelled: "cancelled";
|
|
194
194
|
}>;
|
|
195
|
-
}, z.core.$strip
|
|
195
|
+
}, z.core.$strip>, false>>;
|
|
196
196
|
readonly rules: NoInfer<import("./services.ts").ServiceCall<"/bookings/rules", {}, z.ZodObject<{
|
|
197
197
|
windows: z.ZodArray<z.ZodObject<{
|
|
198
198
|
weekday: z.ZodEnum<{
|
|
@@ -216,7 +216,7 @@ declare const Bookings_base: import("./store.ts").StoreClass<{
|
|
|
216
216
|
date: z.ZodString;
|
|
217
217
|
reason: z.ZodString;
|
|
218
218
|
}, z.core.$strip>>;
|
|
219
|
-
}, z.core.$strip
|
|
219
|
+
}, z.core.$strip>, false>>;
|
|
220
220
|
readonly saveRules: NoInfer<import("./services.ts").ServiceCall<"/bookings/rules", {
|
|
221
221
|
windows: z.ZodArray<z.ZodObject<{
|
|
222
222
|
weekday: z.ZodEnum<{
|
|
@@ -263,7 +263,7 @@ declare const Bookings_base: import("./store.ts").StoreClass<{
|
|
|
263
263
|
date: z.ZodString;
|
|
264
264
|
reason: z.ZodString;
|
|
265
265
|
}, z.core.$strip>>;
|
|
266
|
-
}, z.core.$strip
|
|
266
|
+
}, z.core.$strip>, false>>;
|
|
267
267
|
};
|
|
268
268
|
}>>;
|
|
269
269
|
export declare class Bookings extends Bookings_base {
|
|
@@ -346,7 +346,7 @@ export declare const bookings: {
|
|
|
346
346
|
closed: "closed";
|
|
347
347
|
full: "full";
|
|
348
348
|
}>;
|
|
349
|
-
}, z.core.$strip
|
|
349
|
+
}, z.core.$strip>>, false>>;
|
|
350
350
|
readonly windows: NoInfer<import("./services.ts").ServiceCall<"/bookings/windows", {
|
|
351
351
|
date: z.ZodString;
|
|
352
352
|
}, z.ZodArray<z.ZodObject<{
|
|
@@ -355,7 +355,7 @@ export declare const bookings: {
|
|
|
355
355
|
start: z.ZodString;
|
|
356
356
|
end: z.ZodString;
|
|
357
357
|
remaining: z.ZodNumber;
|
|
358
|
-
}, z.core.$strip
|
|
358
|
+
}, z.core.$strip>>, false>>;
|
|
359
359
|
readonly request: NoInfer<import("./services.ts").ServiceCall<"/bookings/requests", {
|
|
360
360
|
offering: z.ZodString;
|
|
361
361
|
date: z.ZodString;
|
|
@@ -383,7 +383,7 @@ export declare const bookings: {
|
|
|
383
383
|
declined: "declined";
|
|
384
384
|
cancelled: "cancelled";
|
|
385
385
|
}>;
|
|
386
|
-
}, z.core.$strip
|
|
386
|
+
}, z.core.$strip>, false>>;
|
|
387
387
|
readonly requests: NoInfer<import("./services.ts").ServiceCall<"/bookings/requests", {}, z.ZodArray<z.ZodObject<{
|
|
388
388
|
id: z.ZodString;
|
|
389
389
|
createdAt: z.ZodString;
|
|
@@ -402,7 +402,7 @@ export declare const bookings: {
|
|
|
402
402
|
declined: "declined";
|
|
403
403
|
cancelled: "cancelled";
|
|
404
404
|
}>;
|
|
405
|
-
}, z.core.$strip
|
|
405
|
+
}, z.core.$strip>>, false>>;
|
|
406
406
|
readonly accept: NoInfer<import("./services.ts").ServiceCall<"/bookings/requests/:id/accept", {}, z.ZodObject<{
|
|
407
407
|
id: z.ZodString;
|
|
408
408
|
createdAt: z.ZodString;
|
|
@@ -421,7 +421,7 @@ export declare const bookings: {
|
|
|
421
421
|
declined: "declined";
|
|
422
422
|
cancelled: "cancelled";
|
|
423
423
|
}>;
|
|
424
|
-
}, z.core.$strip
|
|
424
|
+
}, z.core.$strip>, false>>;
|
|
425
425
|
readonly decline: NoInfer<import("./services.ts").ServiceCall<"/bookings/requests/:id/decline", {}, z.ZodObject<{
|
|
426
426
|
id: z.ZodString;
|
|
427
427
|
createdAt: z.ZodString;
|
|
@@ -440,7 +440,7 @@ export declare const bookings: {
|
|
|
440
440
|
declined: "declined";
|
|
441
441
|
cancelled: "cancelled";
|
|
442
442
|
}>;
|
|
443
|
-
}, z.core.$strip
|
|
443
|
+
}, z.core.$strip>, false>>;
|
|
444
444
|
readonly rules: NoInfer<import("./services.ts").ServiceCall<"/bookings/rules", {}, z.ZodObject<{
|
|
445
445
|
windows: z.ZodArray<z.ZodObject<{
|
|
446
446
|
weekday: z.ZodEnum<{
|
|
@@ -464,7 +464,7 @@ export declare const bookings: {
|
|
|
464
464
|
date: z.ZodString;
|
|
465
465
|
reason: z.ZodString;
|
|
466
466
|
}, z.core.$strip>>;
|
|
467
|
-
}, z.core.$strip
|
|
467
|
+
}, z.core.$strip>, false>>;
|
|
468
468
|
readonly saveRules: NoInfer<import("./services.ts").ServiceCall<"/bookings/rules", {
|
|
469
469
|
windows: z.ZodArray<z.ZodObject<{
|
|
470
470
|
weekday: z.ZodEnum<{
|
|
@@ -511,7 +511,7 @@ export declare const bookings: {
|
|
|
511
511
|
date: z.ZodString;
|
|
512
512
|
reason: z.ZodString;
|
|
513
513
|
}, z.core.$strip>>;
|
|
514
|
-
}, z.core.$strip
|
|
514
|
+
}, z.core.$strip>, false>>;
|
|
515
515
|
};
|
|
516
516
|
};
|
|
517
517
|
readonly memory: import("./services.ts").ServiceMemory<{
|
|
@@ -525,7 +525,7 @@ export declare const bookings: {
|
|
|
525
525
|
closed: "closed";
|
|
526
526
|
full: "full";
|
|
527
527
|
}>;
|
|
528
|
-
}, z.core.$strip
|
|
528
|
+
}, z.core.$strip>>, false>>;
|
|
529
529
|
readonly windows: NoInfer<import("./services.ts").ServiceCall<"/bookings/windows", {
|
|
530
530
|
date: z.ZodString;
|
|
531
531
|
}, z.ZodArray<z.ZodObject<{
|
|
@@ -534,7 +534,7 @@ export declare const bookings: {
|
|
|
534
534
|
start: z.ZodString;
|
|
535
535
|
end: z.ZodString;
|
|
536
536
|
remaining: z.ZodNumber;
|
|
537
|
-
}, z.core.$strip
|
|
537
|
+
}, z.core.$strip>>, false>>;
|
|
538
538
|
readonly request: NoInfer<import("./services.ts").ServiceCall<"/bookings/requests", {
|
|
539
539
|
offering: z.ZodString;
|
|
540
540
|
date: z.ZodString;
|
|
@@ -562,7 +562,7 @@ export declare const bookings: {
|
|
|
562
562
|
declined: "declined";
|
|
563
563
|
cancelled: "cancelled";
|
|
564
564
|
}>;
|
|
565
|
-
}, z.core.$strip
|
|
565
|
+
}, z.core.$strip>, false>>;
|
|
566
566
|
readonly requests: NoInfer<import("./services.ts").ServiceCall<"/bookings/requests", {}, z.ZodArray<z.ZodObject<{
|
|
567
567
|
id: z.ZodString;
|
|
568
568
|
createdAt: z.ZodString;
|
|
@@ -581,7 +581,7 @@ export declare const bookings: {
|
|
|
581
581
|
declined: "declined";
|
|
582
582
|
cancelled: "cancelled";
|
|
583
583
|
}>;
|
|
584
|
-
}, z.core.$strip
|
|
584
|
+
}, z.core.$strip>>, false>>;
|
|
585
585
|
readonly accept: NoInfer<import("./services.ts").ServiceCall<"/bookings/requests/:id/accept", {}, z.ZodObject<{
|
|
586
586
|
id: z.ZodString;
|
|
587
587
|
createdAt: z.ZodString;
|
|
@@ -600,7 +600,7 @@ export declare const bookings: {
|
|
|
600
600
|
declined: "declined";
|
|
601
601
|
cancelled: "cancelled";
|
|
602
602
|
}>;
|
|
603
|
-
}, z.core.$strip
|
|
603
|
+
}, z.core.$strip>, false>>;
|
|
604
604
|
readonly decline: NoInfer<import("./services.ts").ServiceCall<"/bookings/requests/:id/decline", {}, z.ZodObject<{
|
|
605
605
|
id: z.ZodString;
|
|
606
606
|
createdAt: z.ZodString;
|
|
@@ -619,7 +619,7 @@ export declare const bookings: {
|
|
|
619
619
|
declined: "declined";
|
|
620
620
|
cancelled: "cancelled";
|
|
621
621
|
}>;
|
|
622
|
-
}, z.core.$strip
|
|
622
|
+
}, z.core.$strip>, false>>;
|
|
623
623
|
readonly rules: NoInfer<import("./services.ts").ServiceCall<"/bookings/rules", {}, z.ZodObject<{
|
|
624
624
|
windows: z.ZodArray<z.ZodObject<{
|
|
625
625
|
weekday: z.ZodEnum<{
|
|
@@ -643,7 +643,7 @@ export declare const bookings: {
|
|
|
643
643
|
date: z.ZodString;
|
|
644
644
|
reason: z.ZodString;
|
|
645
645
|
}, z.core.$strip>>;
|
|
646
|
-
}, z.core.$strip
|
|
646
|
+
}, z.core.$strip>, false>>;
|
|
647
647
|
readonly saveRules: NoInfer<import("./services.ts").ServiceCall<"/bookings/rules", {
|
|
648
648
|
windows: z.ZodArray<z.ZodObject<{
|
|
649
649
|
weekday: z.ZodEnum<{
|
|
@@ -690,7 +690,7 @@ export declare const bookings: {
|
|
|
690
690
|
date: z.ZodString;
|
|
691
691
|
reason: z.ZodString;
|
|
692
692
|
}, z.core.$strip>>;
|
|
693
|
-
}, z.core.$strip
|
|
693
|
+
}, z.core.$strip>, false>>;
|
|
694
694
|
};
|
|
695
695
|
}, unknown>;
|
|
696
696
|
readonly Store: typeof Bookings;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PickedFile } from '../files.ts';
|
|
2
|
+
import type { Placement } from './Placement.ts';
|
|
3
|
+
type FilePickerProps = {
|
|
4
|
+
title: string;
|
|
5
|
+
hint?: string;
|
|
6
|
+
buttonLabel: string;
|
|
7
|
+
accept: readonly string[];
|
|
8
|
+
onPick: (file: PickedFile) => void;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
style?: Placement;
|
|
11
|
+
};
|
|
12
|
+
export declare function FilePicker({ title, hint, buttonLabel, accept, onPick, disabled, style }: FilePickerProps): import("react").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as stylex from '@stylexjs/stylex';
|
|
3
|
+
import { useRef, useState } from 'react';
|
|
4
|
+
import { rememberFile } from "../files.js";
|
|
5
|
+
import { borders, colors, motion, radii, shadows, space } from "../theme/tokens.stylex.js";
|
|
6
|
+
import { Button } from "./Button.js";
|
|
7
|
+
import { Icon } from "./Icon.js";
|
|
8
|
+
import { interact } from "./interaction.js";
|
|
9
|
+
import { Text } from "./Text.js";
|
|
10
|
+
export function FilePicker({ title, hint, buttonLabel, accept, onPick, disabled = false, style }) {
|
|
11
|
+
const input = useRef(null);
|
|
12
|
+
const [isOver, setIsOver] = useState(false);
|
|
13
|
+
const pick = (file, event) => {
|
|
14
|
+
if (file === undefined || disabled)
|
|
15
|
+
return;
|
|
16
|
+
interact({
|
|
17
|
+
primitive: 'FilePicker',
|
|
18
|
+
event: event === 'drop' ? 'change' : 'select',
|
|
19
|
+
label: title
|
|
20
|
+
});
|
|
21
|
+
onPick(rememberFile(file));
|
|
22
|
+
};
|
|
23
|
+
const over = (event) => {
|
|
24
|
+
if (disabled || !event.dataTransfer.types.includes('Files'))
|
|
25
|
+
return;
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
event.dataTransfer.dropEffect = 'copy';
|
|
28
|
+
setIsOver(true);
|
|
29
|
+
};
|
|
30
|
+
return (_jsxs("div", { onDragEnter: over, onDragOver: over, onDragLeave: () => setIsOver(false), onDrop: (event) => {
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
setIsOver(false);
|
|
33
|
+
pick(event.dataTransfer.files[0], 'drop');
|
|
34
|
+
}, ...stylex.props(styles.zone, isOver && styles.over, style), children: [_jsx("span", { ...stylex.props(styles.mark), children: _jsx(Icon, { name: "image", size: "xl", tone: "secondary" }) }), _jsxs("span", { ...stylex.props(styles.words), children: [_jsx(Text, { variant: "label", tone: "primary", align: "center", children: title }), hint === undefined ? null : (_jsx(Text, { variant: "caption", tone: "tertiary", align: "center", children: hint }))] }), _jsx(Button, { variant: "secondary", size: "md", disabled: disabled, onClick: () => input.current?.click(), children: buttonLabel }), _jsx("input", { ref: input, type: "file", accept: accept.join(','), tabIndex: -1, "aria-hidden": true, disabled: disabled, onChange: (event) => {
|
|
35
|
+
pick(event.target.files?.[0], 'choose');
|
|
36
|
+
event.target.value = '';
|
|
37
|
+
}, ...stylex.props(styles.input) })] }));
|
|
38
|
+
}
|
|
39
|
+
const styles = stylex.create({
|
|
40
|
+
zone: {
|
|
41
|
+
display: 'flex',
|
|
42
|
+
flexDirection: 'column',
|
|
43
|
+
gap: `calc(${space.sm} + ${space.xxs})`,
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
justifyContent: 'center',
|
|
46
|
+
minHeight: `calc(${space.xxxl} * 3 + ${space.xl} + ${space.sm} + ${space.xs})`,
|
|
47
|
+
padding: `calc(${space.lg} + ${space.xs})`,
|
|
48
|
+
backgroundColor: colors.containerRecessed,
|
|
49
|
+
borderColor: colors.borderStrong,
|
|
50
|
+
borderStyle: 'dashed',
|
|
51
|
+
borderWidth: `calc(${borders.thin} + ${borders.hairline})`,
|
|
52
|
+
borderRadius: radii.lg,
|
|
53
|
+
transitionTimingFunction: motion.easeOut,
|
|
54
|
+
transitionDuration: motion.fast,
|
|
55
|
+
transitionProperty: 'background-color, border-color'
|
|
56
|
+
},
|
|
57
|
+
over: {
|
|
58
|
+
backgroundColor: colors.brandSubtle,
|
|
59
|
+
borderColor: colors.brandBorderFocus
|
|
60
|
+
},
|
|
61
|
+
mark: {
|
|
62
|
+
display: 'flex',
|
|
63
|
+
flexShrink: 0,
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
justifyContent: 'center',
|
|
66
|
+
width: `calc(${space.xxl} + ${space.xs})`,
|
|
67
|
+
height: `calc(${space.xxl} + ${space.xs})`,
|
|
68
|
+
backgroundColor: colors.componentOnContainerStrong,
|
|
69
|
+
borderRadius: radii.full,
|
|
70
|
+
boxShadow: shadows.default
|
|
71
|
+
},
|
|
72
|
+
words: {
|
|
73
|
+
display: 'flex',
|
|
74
|
+
flexDirection: 'column',
|
|
75
|
+
gap: space.xxs,
|
|
76
|
+
alignItems: 'center'
|
|
77
|
+
},
|
|
78
|
+
input: {
|
|
79
|
+
display: 'none'
|
|
80
|
+
}
|
|
81
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PickedFile } from '../files.ts';
|
|
2
|
+
import type { Placement } from './Placement.ts';
|
|
3
|
+
type FilePreviewProps = {
|
|
4
|
+
file: PickedFile;
|
|
5
|
+
alt: string;
|
|
6
|
+
aspect?: number;
|
|
7
|
+
style?: Placement;
|
|
8
|
+
};
|
|
9
|
+
export declare function FilePreview({ file, alt, aspect, style }: FilePreviewProps): import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as stylex from '@stylexjs/stylex';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { pickedFileOf } from "../files.js";
|
|
5
|
+
import { colors } from "../theme/tokens.stylex.js";
|
|
6
|
+
export function FilePreview({ file, alt, aspect = 1, style }) {
|
|
7
|
+
const [shown, setShown] = useState(null);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const picked = pickedFileOf(file.id);
|
|
10
|
+
if (picked === undefined || !picked.type.startsWith('image/'))
|
|
11
|
+
return;
|
|
12
|
+
const url = URL.createObjectURL(picked);
|
|
13
|
+
setShown({ id: file.id, url });
|
|
14
|
+
return () => URL.revokeObjectURL(url);
|
|
15
|
+
}, [file.id]);
|
|
16
|
+
const url = shown?.id === file.id ? shown.url : null;
|
|
17
|
+
return (_jsx("span", { ...stylex.props(styles.frame, styles.ratio(aspect), style), children: url === null ? null : (_jsx("img", { alt: alt, src: url, ...stylex.props(styles.image) })) }));
|
|
18
|
+
}
|
|
19
|
+
const styles = stylex.create({
|
|
20
|
+
frame: {
|
|
21
|
+
position: 'relative',
|
|
22
|
+
display: 'block',
|
|
23
|
+
width: '100%',
|
|
24
|
+
overflow: 'hidden',
|
|
25
|
+
backgroundColor: colors.component
|
|
26
|
+
},
|
|
27
|
+
ratio: (ratio) => ({
|
|
28
|
+
aspectRatio: String(ratio)
|
|
29
|
+
}),
|
|
30
|
+
image: {
|
|
31
|
+
display: 'block',
|
|
32
|
+
width: '100%',
|
|
33
|
+
height: '100%',
|
|
34
|
+
objectFit: 'cover'
|
|
35
|
+
}
|
|
36
|
+
});
|
|
@@ -5,7 +5,8 @@ type ImageProps = {
|
|
|
5
5
|
sizes: string;
|
|
6
6
|
priority?: boolean;
|
|
7
7
|
aspect?: number;
|
|
8
|
+
origin?: string;
|
|
8
9
|
style?: Placement;
|
|
9
10
|
};
|
|
10
|
-
export declare function Image({ image, sizes, priority, aspect, style }: ImageProps): import("react").JSX.Element;
|
|
11
|
+
export declare function Image({ image, sizes, priority, aspect, origin, style }: ImageProps): import("react").JSX.Element;
|
|
11
12
|
export {};
|
package/dist/components/Image.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as stylex from '@stylexjs/stylex';
|
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import { imageSources, transformsOn } from "../media.js";
|
|
5
5
|
import { breakpoints, colors, motion } from "../theme/tokens.stylex.js";
|
|
6
|
-
export function Image({ image, sizes, priority = false, aspect, style }) {
|
|
6
|
+
export function Image({ image, sizes, priority = false, aspect, origin, style }) {
|
|
7
7
|
const key = image?.key ?? null;
|
|
8
8
|
const [seen, setSeen] = useState({
|
|
9
9
|
key,
|
|
@@ -19,7 +19,10 @@ export function Image({ image, sizes, priority = false, aspect, style }) {
|
|
|
19
19
|
}
|
|
20
20
|
const sources = imageSources(image, {
|
|
21
21
|
aspect,
|
|
22
|
-
transforms:
|
|
22
|
+
transforms: origin === undefined
|
|
23
|
+
? servedWithTransforms()
|
|
24
|
+
: transformsOn(new URL(origin).hostname),
|
|
25
|
+
...(origin === undefined ? {} : { origin: new URL(origin).origin })
|
|
23
26
|
});
|
|
24
27
|
return (_jsxs("span", { ...stylex.props(styles.frame, styles.ratio(ratio), style), children: [image.placeholder === null ? null : (_jsx("span", { "aria-hidden": "true", ...stylex.props(styles.placeholder(image.placeholder)) })), _jsx("img", { ref: (element) => {
|
|
25
28
|
if (status === 'loading' &&
|
package/dist/components/Menu.js
CHANGED
|
@@ -2,11 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Menu as BaseMenu } from '@base-ui/react/menu';
|
|
3
3
|
import * as stylex from '@stylexjs/stylex';
|
|
4
4
|
import { colors, controls, layers, space } from "../theme/tokens.stylex.js";
|
|
5
|
-
import { controlSizes, focusRing, transparentLook } from "./controlLook.js";
|
|
5
|
+
import { buttonCorners, controlSizes, focusRing, transparentLook } from "./controlLook.js";
|
|
6
6
|
import { MenuItems } from "./MenuItems.js";
|
|
7
7
|
import { Popup } from "./Popup.js";
|
|
8
8
|
export function Menu({ trigger, items, size = 'md', style }) {
|
|
9
|
-
return (_jsxs(BaseMenu.Root, { children: [_jsx(BaseMenu.Trigger, { className: (state) => stylex.props(styles.trigger, controlSizes[size], triggerPaddings[size], transparentLook.rest, transparentLook.hoverable, state.open && transparentLook.open, styles.triggerText, focusRing.visible, style).className, children: trigger }), _jsx(BaseMenu.Portal, { children: _jsx(BaseMenu.Positioner, { side: "bottom", align: "start", sideOffset: 4, className: stylex.props(styles.positioner).className, children: _jsx(BaseMenu.Popup, { render: (props, state) => (_jsx(Popup, { ...props, kind: "menu", isOpen: state.open, transitionStatus: state.transitionStatus })), children: _jsx(MenuItems, { items: items, primitive: "Menu" }) }) }) })] }));
|
|
9
|
+
return (_jsxs(BaseMenu.Root, { children: [_jsx(BaseMenu.Trigger, { className: (state) => stylex.props(styles.trigger, controlSizes[size], buttonCorners[size], triggerPaddings[size], transparentLook.rest, transparentLook.hoverable, state.open && transparentLook.open, styles.triggerText, focusRing.visible, style).className, children: trigger }), _jsx(BaseMenu.Portal, { children: _jsx(BaseMenu.Positioner, { side: "bottom", align: "start", sideOffset: 4, className: stylex.props(styles.positioner).className, children: _jsx(BaseMenu.Popup, { render: (props, state) => (_jsx(Popup, { ...props, kind: "menu", isOpen: state.open, transitionStatus: state.transitionStatus })), children: _jsx(MenuItems, { items: items, primitive: "Menu" }) }) }) })] }));
|
|
10
10
|
}
|
|
11
11
|
const styles = stylex.create({
|
|
12
12
|
trigger: {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as stylex from '@stylexjs/stylex';
|
|
3
|
+
import { colors, motion, radii, space } from "../theme/tokens.stylex.js";
|
|
4
|
+
export function ProgressBar({ label, value, style }) {
|
|
5
|
+
const percent = Math.round(Math.min(1, Math.max(0, value)) * 100);
|
|
6
|
+
return (_jsx("div", { role: "progressbar", "aria-label": label, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": percent, ...stylex.props(styles.track, style), children: _jsx("div", { ...stylex.props(styles.fill, fills.width(`${percent}%`)) }) }));
|
|
7
|
+
}
|
|
8
|
+
const styles = stylex.create({
|
|
9
|
+
track: {
|
|
10
|
+
display: 'flex',
|
|
11
|
+
flexShrink: 0,
|
|
12
|
+
width: '100%',
|
|
13
|
+
height: space.xs,
|
|
14
|
+
overflow: 'clip',
|
|
15
|
+
backgroundColor: colors.component,
|
|
16
|
+
borderRadius: radii.full
|
|
17
|
+
},
|
|
18
|
+
fill: {
|
|
19
|
+
height: '100%',
|
|
20
|
+
backgroundColor: colors.brandSolid,
|
|
21
|
+
borderRadius: radii.full,
|
|
22
|
+
transitionTimingFunction: motion.easeOut,
|
|
23
|
+
transitionDuration: motion.fast,
|
|
24
|
+
transitionProperty: 'width'
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const fills = stylex.create({
|
|
28
|
+
width: (width) => ({ width })
|
|
29
|
+
});
|
|
@@ -4,13 +4,13 @@ import { RadioGroup } from '@base-ui/react/radio-group';
|
|
|
4
4
|
import * as stylex from '@stylexjs/stylex';
|
|
5
5
|
import { borders, colors, fontWeights, motion, radii } from "../theme/tokens.stylex.js";
|
|
6
6
|
import { interact } from "./interaction.js";
|
|
7
|
-
import { controlSizes, focusRing } from "./controlLook.js";
|
|
7
|
+
import { buttonCorners, controlSizes, focusRing } from "./controlLook.js";
|
|
8
8
|
export function SegmentedControl({ label, value, options, size = 'md', disabled = false, onChange, style }) {
|
|
9
9
|
const index = Math.max(0, options.findIndex((option) => option.value === value));
|
|
10
10
|
return (_jsxs(RadioGroup, { "aria-label": label, value: value, disabled: disabled, onValueChange: (next) => {
|
|
11
11
|
interact({ primitive: 'SegmentedControl', event: 'change', label });
|
|
12
12
|
onChange(next);
|
|
13
|
-
}, className: stylex.props(styles.group, style).className, children: [_jsx("span", { ...stylex.props(styles.indicator(index, options.length)) }), options.map((option) => (_jsx(Radio.Root, { value: option.value, className: (state) => stylex.props(styles.option, controlSizes[size], !disabled && styles.hoverable, state.checked && styles.optionChecked, disabled && styles.disabled, focusRing.visible).className, children: option.label }, option.value)))] }));
|
|
13
|
+
}, className: stylex.props(styles.group, style).className, children: [_jsx("span", { ...stylex.props(styles.indicator(index, options.length)) }), options.map((option) => (_jsx(Radio.Root, { value: option.value, className: (state) => stylex.props(styles.option, controlSizes[size], buttonCorners[size], !disabled && styles.hoverable, state.checked && styles.optionChecked, disabled && styles.disabled, focusRing.visible).className, children: option.label }, option.value)))] }));
|
|
14
14
|
}
|
|
15
15
|
const styles = stylex.create({
|
|
16
16
|
group: {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
type TableRowProps = {
|
|
3
|
+
label: string;
|
|
4
|
+
isCurrent?: boolean;
|
|
5
|
+
onClick: () => void;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export declare function TableRow({ label, isCurrent, onClick, children }: TableRowProps): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button as BaseButton } from '@base-ui/react/button';
|
|
3
|
+
import * as stylex from '@stylexjs/stylex';
|
|
4
|
+
import { borders, colors, space } from "../theme/tokens.stylex.js";
|
|
5
|
+
import { focusRing } from "./controlLook.js";
|
|
6
|
+
import { interact } from "./interaction.js";
|
|
7
|
+
export function TableRow({ label, isCurrent = false, onClick, children }) {
|
|
8
|
+
return (_jsx(BaseButton, { "aria-label": label, "aria-pressed": isCurrent, onClick: () => {
|
|
9
|
+
interact({ primitive: 'TableRow', event: 'click', label });
|
|
10
|
+
onClick();
|
|
11
|
+
}, className: stylex.props(styles.row, isCurrent && styles.current, focusRing.visible, focusRing.inside).className, children: children }));
|
|
12
|
+
}
|
|
13
|
+
const styles = stylex.create({
|
|
14
|
+
row: {
|
|
15
|
+
display: 'flex',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
width: '100%',
|
|
18
|
+
height: `calc(${space.xxl} + ${space.xs})`,
|
|
19
|
+
paddingInline: space.xs,
|
|
20
|
+
color: colors.primaryForeground,
|
|
21
|
+
textAlign: 'start',
|
|
22
|
+
backgroundColor: {
|
|
23
|
+
default: 'transparent',
|
|
24
|
+
':hover': colors.transparentHover
|
|
25
|
+
},
|
|
26
|
+
borderBottomColor: {
|
|
27
|
+
default: colors.borderDefault,
|
|
28
|
+
':last-child': colors.transparent
|
|
29
|
+
},
|
|
30
|
+
borderBottomStyle: 'solid',
|
|
31
|
+
borderBottomWidth: borders.thin
|
|
32
|
+
},
|
|
33
|
+
current: {
|
|
34
|
+
backgroundColor: colors.transparentHover
|
|
35
|
+
}
|
|
36
|
+
});
|
package/dist/components/icons.js
CHANGED
|
@@ -46,6 +46,11 @@ const builtInIcons = {
|
|
|
46
46
|
chevronUpDown: 'M8 9.5 12 5.5l4 4M8 14.5l4 4 4-4',
|
|
47
47
|
check: 'M5 12.5 9.5 17 19 7.5',
|
|
48
48
|
plus: 'M12 5v14M5 12h14',
|
|
49
|
+
image: [
|
|
50
|
+
'M6.25 4.75h11.5a2.5 2.5 0 0 1 2.5 2.5v9.5a2.5 2.5 0 0 1-2.5 2.5H6.25a2.5 2.5 0 0 1-2.5-2.5v-9.5a2.5 2.5 0 0 1 2.5-2.5z',
|
|
51
|
+
'M7.25 10a1.75 1.75 0 1 0 3.5 0a1.75 1.75 0 1 0 -3.5 0',
|
|
52
|
+
'M4.5 17.5l4.5-4.25 3 2.75 3.5-3.75 4 4'
|
|
53
|
+
],
|
|
49
54
|
trash: [
|
|
50
55
|
'M4.75 6.75h14.5',
|
|
51
56
|
'M9.75 6.75v-1a2 2 0 0 1 2-2h.5a2 2 0 0 1 2 2v1',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
export type Interaction = {
|
|
3
|
-
primitive: 'AppFrame' | 'Button' | 'Card' | 'IconButton' | 'Link' | 'ListRow' | 'Select' | 'Switch' | 'Checkbox' | 'SegmentedControl' | 'Menu' | 'ContextMenu' | 'CommandMenu' | 'TextField' | 'Form' | 'Dialog' | 'RadioGroup' | 'ChoiceGroup' | 'Calendar' | 'Gallery';
|
|
3
|
+
primitive: 'AppFrame' | 'Button' | 'Card' | 'IconButton' | 'Link' | 'ListRow' | 'Select' | 'Switch' | 'Checkbox' | 'SegmentedControl' | 'Menu' | 'ContextMenu' | 'CommandMenu' | 'TextField' | 'Form' | 'Dialog' | 'RadioGroup' | 'ChoiceGroup' | 'Calendar' | 'Gallery' | 'FilePicker' | 'TableRow';
|
|
4
4
|
event: 'click' | 'change' | 'select' | 'open' | 'close' | 'submit' | 'navigate';
|
|
5
5
|
label: string;
|
|
6
6
|
page: string | null;
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const pickedFile: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
type: z.ZodString;
|
|
6
|
+
size: z.ZodNumber;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type PickedFile = z.output<typeof pickedFile>;
|
|
9
|
+
export declare function rememberFile(file: File): PickedFile;
|
|
10
|
+
export declare function pickedFileOf(id: string): File | undefined;
|
|
11
|
+
export declare function forgetFile(id: string): void;
|
package/dist/files.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const pickedFile = z.object({
|
|
3
|
+
id: z.string(),
|
|
4
|
+
name: z.string(),
|
|
5
|
+
type: z.string(),
|
|
6
|
+
size: z.number()
|
|
7
|
+
});
|
|
8
|
+
const picked = new Map();
|
|
9
|
+
export function rememberFile(file) {
|
|
10
|
+
const id = crypto.randomUUID();
|
|
11
|
+
picked.set(id, file);
|
|
12
|
+
return { id, name: file.name, type: file.type, size: file.size };
|
|
13
|
+
}
|
|
14
|
+
export function pickedFileOf(id) {
|
|
15
|
+
return picked.get(id);
|
|
16
|
+
}
|
|
17
|
+
export function forgetFile(id) {
|
|
18
|
+
picked.delete(id);
|
|
19
|
+
}
|