@fldr/ui 0.3.8 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -448
- package/ai/component-registry.json +27 -14
- package/ai/component-registry.md +3 -3
- package/dist/.build-complete +1 -1
- package/dist/blocks-source/auth-card/auth-card.test.tsx +20 -14
- package/dist/blocks-source/auth-card/auth-card.tsx +73 -55
- package/dist/blocks-source/file-table/file-table.tsx +197 -150
- package/dist/blocks-source/login-page/login-page.tsx +3 -1
- package/dist/blocks-source/share-dialog/share-dialog.test.tsx +9 -3
- package/dist/blocks-source/share-dialog/share-dialog.tsx +50 -35
- package/dist/blocks.d.ts +24 -5
- package/dist/blocks.js +250 -197
- package/dist/brands.d.ts +143 -0
- package/dist/brands.js +92 -0
- package/dist/{button-DzavLWXm.d.ts → button-CS82eT0x.d.ts} +1 -1
- package/dist/chunks/{checkbox-eifiwbw34xwsikvf.js → checkbox-d5epe4dl78bzy4f8.js} +8 -8
- package/dist/chunks/{dropdown-e5zk0ez21busnt0b.js → dropdown-oec4g1w9kbsjsg15.js} +1 -1
- package/dist/chunks/highlighter-kb7huz24pcziin6d.js +57 -0
- package/dist/chunks/{layer-dialog-m8qb0wzfg3k7406a.js → layer-dialog-ioa3r4ayemppsspx.js} +4 -3
- package/dist/chunks/{table-ngl1b5yc8mcur662.js → table-bdye068ekayq3u1n.js} +1 -1
- package/dist/chunks/table-n5yarooiknhc18ln.js +448 -0
- package/dist/chunks/{table-of-contents-gkjv9ck8etbz64ej.js → table-of-contents-d3pmkrk223umdz9h.js} +1 -1
- package/dist/code/server.js +1 -1
- package/dist/code.js +4 -131
- package/dist/components/banner.d.ts +1 -1
- package/dist/components/button.d.ts +2 -2
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/dropdown.js +1 -1
- package/dist/components/input-group.d.ts +2 -1
- package/dist/components/input.d.ts +2 -2
- package/dist/components/layer-dialog.js +1 -1
- package/dist/components/link.d.ts +2 -67
- package/dist/components/sidebar.d.ts +2 -1
- package/dist/components/table-of-contents.js +1 -1
- package/dist/components/table.d.ts +1 -1
- package/dist/components/table.js +1 -1
- package/dist/components/toast.d.ts +1 -1
- package/dist/components/toolbar.d.ts +1 -1
- package/dist/form.d.ts +207 -0
- package/dist/form.js +317 -0
- package/dist/hotkeys.d.ts +135 -0
- package/dist/hotkeys.js +203 -0
- package/dist/index-9LwQy84o.d.ts +1 -0
- package/dist/index-B7iG0qDU.d.ts +1 -0
- package/dist/{index-B6JNUfG9.d.ts → index-BMXHK-3k.d.ts} +2 -2
- package/dist/{index-B6Wo_iiN.d.ts → index-B_ug9XY7.d.ts} +1 -1
- package/dist/{index-RP_rt8vB.d.ts → index-Bh9kuAvN.d.ts} +1 -1
- package/dist/{index-DjSGDESy.d.ts → index-CAUjUp2G.d.ts} +1 -1
- package/dist/{index-NnHba-T1.d.ts → index-DK28YxxP.d.ts} +2 -2
- package/dist/{index-aahL-0Zw.d.ts → index-DOVlARA6.d.ts} +2 -2
- package/dist/index-DTj6M6kA.d.ts +1 -0
- package/dist/index.d.ts +14 -12
- package/dist/index.js +5 -6
- package/dist/{input-group-8gEtPiKw.d.ts → input-group-Swzit45o.d.ts} +1 -1
- package/dist/link-CoVXE5W2.d.ts +68 -0
- package/dist/query.d.ts +156 -0
- package/dist/query.js +204 -0
- package/dist/router.d.ts +95 -0
- package/dist/router.js +146 -0
- package/dist/skeleton.d.ts +3 -0
- package/dist/skeleton.js +4 -0
- package/dist/styles/kumo-binding.css +36 -0
- package/dist/styles/kumo-standalone.css +1 -1
- package/dist/styles/theme-fldr.css +18 -18
- package/dist/table.d.ts +245 -0
- package/dist/table.js +3 -0
- package/dist/theming.d.ts +4 -4
- package/dist/theming.js +2 -2
- package/package.json +46 -1
- package/dist/chunks/highlighter-mouttug0tu8xg1i8.js +0 -1364
- package/dist/index-DL1-uSuH.d.ts +0 -1
- /package/dist/{index-BkTAB4wj.d.ts → sidebar-BkTAB4wj.d.ts} +0 -0
package/dist/query.d.ts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { n as KumoToastManagerAddOptions } from "./index-BMXHK-3k.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { DefaultError, QueryClient, QueryClient as QueryClient$1, QueryClientConfig, QueryClientProvider, UseMutationOptions, UseMutationResult } from "@tanstack/react-query";
|
|
4
|
+
//#region src/query/query-state.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The subset of a query result `QueryState` reads. Any `UseQueryResult`
|
|
7
|
+
* (or `UseSuspenseQueryResult`, `UseInfiniteQueryResult`) satisfies it.
|
|
8
|
+
*/
|
|
9
|
+
interface QueryLike<TData, TError = Error> {
|
|
10
|
+
status: "pending" | "error" | "success";
|
|
11
|
+
data: TData | undefined;
|
|
12
|
+
error: TError | null;
|
|
13
|
+
isFetching?: boolean;
|
|
14
|
+
refetch?: () => unknown;
|
|
15
|
+
}
|
|
16
|
+
/** Overridable copy for i18n. */
|
|
17
|
+
interface QueryStateLabels {
|
|
18
|
+
/** Accessible label for the loading skeleton. @default "Loading" */
|
|
19
|
+
loading: string;
|
|
20
|
+
/** Error banner title. @default "Something went wrong" */
|
|
21
|
+
errorTitle: string;
|
|
22
|
+
/** Retry button label. @default "Retry" */
|
|
23
|
+
retry: string;
|
|
24
|
+
/** Default empty state title. @default "Nothing here yet" */
|
|
25
|
+
emptyTitle: string;
|
|
26
|
+
/** Accessible label for the refreshing indicator. @default "Refreshing" */
|
|
27
|
+
refreshing: string;
|
|
28
|
+
}
|
|
29
|
+
interface QueryStateBaseProps<TData, TError> {
|
|
30
|
+
/** Renders the loaded data. `data` is never `undefined` here. */
|
|
31
|
+
children: (data: TData) => ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* Sample data rendered through `children` and measured by skullet, so the
|
|
34
|
+
* loading skeleton matches the real content.
|
|
35
|
+
*/
|
|
36
|
+
sample?: TData;
|
|
37
|
+
/** Remembers the skeleton's shape across visits under this key (skullet `id`). */
|
|
38
|
+
skeletonId?: string;
|
|
39
|
+
/** Loading fallback, replacing the measured skeleton. @default SkeletonBox rows when there's no `sample` or `skeletonId` */
|
|
40
|
+
loading?: ReactNode;
|
|
41
|
+
/** Number of rows in the default SkeletonBox fallback. @default 3 */
|
|
42
|
+
skeletonRows?: number;
|
|
43
|
+
/** Error fallback; a function receives the error and a retry callback. */
|
|
44
|
+
error?: ReactNode | ((error: TError, retry: () => void) => ReactNode);
|
|
45
|
+
/** Treat loaded data as empty. @default empty arrays are empty */
|
|
46
|
+
isEmpty?: (data: TData) => boolean;
|
|
47
|
+
/** Empty fallback. @default `<Empty size="sm" title={labels.emptyTitle} />` */
|
|
48
|
+
empty?: ReactNode;
|
|
49
|
+
/** Show a small Loader above the content while refetching existing data. @default false */
|
|
50
|
+
showRefreshing?: boolean;
|
|
51
|
+
/** Overridable copy for i18n. */
|
|
52
|
+
labels?: Partial<QueryStateLabels>;
|
|
53
|
+
/** Classes for the loading / error / empty wrappers. */
|
|
54
|
+
className?: string;
|
|
55
|
+
}
|
|
56
|
+
/** Props for {@link QueryState}. */
|
|
57
|
+
interface QueryStateProps<TData, TError = Error> extends QueryStateBaseProps<Exclude<TData, undefined>, TError> {
|
|
58
|
+
/** A query result, e.g. the return value of `useQuery`. */
|
|
59
|
+
query: QueryLike<TData, TError>;
|
|
60
|
+
}
|
|
61
|
+
type QueriesData<Q extends readonly QueryLike<unknown, unknown>[]> = { -readonly [K in keyof Q]: Q[K] extends QueryLike<infer D, unknown> ? Exclude<D, undefined> : never; };
|
|
62
|
+
type QueriesError<Q extends readonly QueryLike<unknown, unknown>[]> = Q[number] extends QueryLike<unknown, infer E> ? E : never;
|
|
63
|
+
/** Props for {@link QueryStates}. */
|
|
64
|
+
interface QueryStatesProps<Q extends readonly QueryLike<unknown, unknown>[]> extends QueryStateBaseProps<QueriesData<Q>, QueriesError<Q>> {
|
|
65
|
+
/** Query results; children render once all have succeeded. */
|
|
66
|
+
queries: Q;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Renders the loading, error, empty or success state of a TanStack Query
|
|
70
|
+
* result with fldr UI defaults. Each fallback is overridable.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx
|
|
74
|
+
* const files = useQuery({ queryKey: ["files", id], queryFn: fetchFiles });
|
|
75
|
+
*
|
|
76
|
+
* <QueryState query={files} sample={SAMPLE_FILES} empty={<Empty title="No files" />}>
|
|
77
|
+
* {(files) => <FileTable files={files} />}
|
|
78
|
+
* </QueryState>
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function QueryState<TData, TError = Error>({ query, ...props }: QueryStateProps<TData, TError>): ReactNode;
|
|
82
|
+
/**
|
|
83
|
+
* Like {@link QueryState} for several queries: shows the first error (Retry
|
|
84
|
+
* refetches every failed query), loading while any is pending, then renders
|
|
85
|
+
* children with a tuple of all data.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```tsx
|
|
89
|
+
* <QueryStates queries={[folder, files] as const}>
|
|
90
|
+
* {([folder, files]) => <FolderView folder={folder} files={files} />}
|
|
91
|
+
* </QueryStates>
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare function QueryStates<const Q extends readonly QueryLike<unknown, unknown>[]>({ queries, ...props }: QueryStatesProps<Q>): ReactNode;
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/query/use-toast-mutation.d.ts
|
|
97
|
+
/** A toast title, full toast options, or a function producing either. `false` disables the toast. */
|
|
98
|
+
type MutationToast<TArgs extends unknown[]> = false | string | KumoToastManagerAddOptions<object> | ((...args: TArgs) => string | KumoToastManagerAddOptions<object> | false);
|
|
99
|
+
/** Toast options for {@link useToastMutation}. */
|
|
100
|
+
interface MutationToasts<TData, TError, TVariables> {
|
|
101
|
+
/** Toast shown on success. @default `{ title: "Saved" }` */
|
|
102
|
+
success?: MutationToast<[data: TData, variables: TVariables]>;
|
|
103
|
+
/** Toast shown on error. @default `{ title: "Something went wrong", description: error.message }` */
|
|
104
|
+
error?: MutationToast<[error: TError, variables: TVariables]>;
|
|
105
|
+
}
|
|
106
|
+
/** Options for {@link useToastMutation}: `useMutation` options plus `toasts`. */
|
|
107
|
+
interface UseToastMutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends UseMutationOptions<TData, TError, TVariables, TOnMutateResult> {
|
|
108
|
+
toasts?: MutationToasts<TData, TError, TVariables>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* `useMutation` that shows a Kumo toast on success and error. Requires a
|
|
112
|
+
* `<Toasty>` ancestor. Your own `onSuccess` / `onError` still run.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```tsx
|
|
116
|
+
* const rename = useToastMutation({
|
|
117
|
+
* mutationFn: renameFile,
|
|
118
|
+
* toasts: {
|
|
119
|
+
* success: (file) => `Renamed to ${file.name}`,
|
|
120
|
+
* error: (error) => ({ title: "Rename failed", description: error.message }),
|
|
121
|
+
* },
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare function useToastMutation<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown>({ toasts, ...options }: UseToastMutationOptions<TData, TError, TVariables, TOnMutateResult>, queryClient?: QueryClient$1): UseMutationResult<TData, TError, TVariables, TOnMutateResult>;
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/query/query-client.d.ts
|
|
128
|
+
/** Default options applied by {@link createFldrQueryClient}. */
|
|
129
|
+
export declare const fldrQueryDefaults: {
|
|
130
|
+
queries: {
|
|
131
|
+
staleTime: number;
|
|
132
|
+
retry: number;
|
|
133
|
+
refetchOnWindowFocus: false;
|
|
134
|
+
};
|
|
135
|
+
mutations: {
|
|
136
|
+
retry: number;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Creates a `QueryClient` with fldr defaults (30s `staleTime`, one retry, no
|
|
141
|
+
* refetch on window focus). Your `defaultOptions` are merged over them.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```tsx
|
|
145
|
+
* const queryClient = createFldrQueryClient({
|
|
146
|
+
* defaultOptions: { queries: { staleTime: 60_000 } },
|
|
147
|
+
* });
|
|
148
|
+
*
|
|
149
|
+
* <QueryClientProvider client={queryClient}>
|
|
150
|
+
* <App />
|
|
151
|
+
* </QueryClientProvider>
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
export declare function createFldrQueryClient(config?: QueryClientConfig): QueryClient$1;
|
|
155
|
+
//#endregion
|
|
156
|
+
export { type MutationToast, type MutationToasts, QueryClient, QueryClientProvider, type QueryLike, type QueryStateLabels, type QueryStateProps, type QueryStatesProps, type UseToastMutationOptions };
|
package/dist/query.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as Loader } from "./chunks/loader-kv5nk8j8tsuesxqo.js";
|
|
3
|
+
import { t as Banner } from "./chunks/banner-mo1xl9ww734kgsqh.js";
|
|
4
|
+
import { i as useKumoToastManager } from "./chunks/toast-ljpenshot856xqq4.js";
|
|
5
|
+
import { t as Empty } from "./chunks/empty-ijs6kgnd72lv3u94.js";
|
|
6
|
+
import { Skeleton, SkeletonBox } from "./skeleton.js";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { QueryClient, QueryClient as QueryClient$1, QueryClientProvider, useMutation } from "@tanstack/react-query";
|
|
9
|
+
//#region src/query/query-state.tsx
|
|
10
|
+
const DEFAULT_LABELS = {
|
|
11
|
+
loading: "Loading",
|
|
12
|
+
errorTitle: "Something went wrong",
|
|
13
|
+
retry: "Retry",
|
|
14
|
+
emptyTitle: "Nothing here yet",
|
|
15
|
+
refreshing: "Refreshing"
|
|
16
|
+
};
|
|
17
|
+
function errorMessage(error) {
|
|
18
|
+
if (error instanceof Error) return error.message;
|
|
19
|
+
if (typeof error === "string") return error;
|
|
20
|
+
}
|
|
21
|
+
const defaultIsEmpty = (data) => Array.isArray(data) && data.length === 0;
|
|
22
|
+
function renderState(queries, data, props) {
|
|
23
|
+
const labels = {
|
|
24
|
+
...DEFAULT_LABELS,
|
|
25
|
+
...props.labels
|
|
26
|
+
};
|
|
27
|
+
const failed = queries.filter((q) => q.status === "error");
|
|
28
|
+
if (failed.length > 0) {
|
|
29
|
+
const retry = () => failed.forEach((q) => q.refetch?.());
|
|
30
|
+
const error = failed[0].error;
|
|
31
|
+
if (typeof props.error === "function") return props.error(error, retry);
|
|
32
|
+
if (props.error !== void 0) return props.error;
|
|
33
|
+
return /* @__PURE__ */ jsx(Banner, {
|
|
34
|
+
variant: "error",
|
|
35
|
+
size: "sm",
|
|
36
|
+
className: props.className,
|
|
37
|
+
title: labels.errorTitle,
|
|
38
|
+
description: errorMessage(error),
|
|
39
|
+
action: /* @__PURE__ */ jsx(Banner.Action, {
|
|
40
|
+
onClick: retry,
|
|
41
|
+
children: labels.retry
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const pending = queries.some((q) => q.status === "pending");
|
|
46
|
+
const value = pending ? null : data();
|
|
47
|
+
if (value !== null && (props.isEmpty ?? defaultIsEmpty)(value)) return props.empty ?? /* @__PURE__ */ jsx(Empty, {
|
|
48
|
+
size: "sm",
|
|
49
|
+
className: props.className,
|
|
50
|
+
title: labels.emptyTitle
|
|
51
|
+
});
|
|
52
|
+
const measured = props.sample !== void 0 || props.skeletonId !== void 0;
|
|
53
|
+
const fallback = props.loading ?? (measured ? void 0 : /* @__PURE__ */ jsx("div", {
|
|
54
|
+
className: "flex flex-col gap-2 py-2",
|
|
55
|
+
children: Array.from({ length: props.skeletonRows ?? 3 }, (_, i) => /* @__PURE__ */ jsx(SkeletonBox, {
|
|
56
|
+
height: "0.75rem",
|
|
57
|
+
width: i % 2 ? "60%" : "100%"
|
|
58
|
+
}, i))
|
|
59
|
+
}));
|
|
60
|
+
const refreshing = props.showRefreshing && !pending && queries.some((q) => q.isFetching === true);
|
|
61
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [refreshing && /* @__PURE__ */ jsx("div", {
|
|
62
|
+
className: "flex justify-end",
|
|
63
|
+
children: /* @__PURE__ */ jsx(Loader, {
|
|
64
|
+
size: "sm",
|
|
65
|
+
"aria-label": labels.refreshing
|
|
66
|
+
})
|
|
67
|
+
}), /* @__PURE__ */ jsx(Skeleton, {
|
|
68
|
+
data: value,
|
|
69
|
+
sample: props.sample,
|
|
70
|
+
id: props.skeletonId,
|
|
71
|
+
label: labels.loading,
|
|
72
|
+
skeleton: fallback,
|
|
73
|
+
className: pending ? props.className : void 0,
|
|
74
|
+
children: props.children
|
|
75
|
+
})] });
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Renders the loading, error, empty or success state of a TanStack Query
|
|
79
|
+
* result with fldr UI defaults. Each fallback is overridable.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```tsx
|
|
83
|
+
* const files = useQuery({ queryKey: ["files", id], queryFn: fetchFiles });
|
|
84
|
+
*
|
|
85
|
+
* <QueryState query={files} sample={SAMPLE_FILES} empty={<Empty title="No files" />}>
|
|
86
|
+
* {(files) => <FileTable files={files} />}
|
|
87
|
+
* </QueryState>
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
function QueryState({ query, ...props }) {
|
|
91
|
+
return renderState([query], () => query.data, props);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Like {@link QueryState} for several queries: shows the first error (Retry
|
|
95
|
+
* refetches every failed query), loading while any is pending, then renders
|
|
96
|
+
* children with a tuple of all data.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```tsx
|
|
100
|
+
* <QueryStates queries={[folder, files] as const}>
|
|
101
|
+
* {([folder, files]) => <FolderView folder={folder} files={files} />}
|
|
102
|
+
* </QueryStates>
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
function QueryStates({ queries, ...props }) {
|
|
106
|
+
return renderState(queries, () => queries.map((q) => q.data), props);
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/query/use-toast-mutation.ts
|
|
110
|
+
function resolve(toast, fallback, args) {
|
|
111
|
+
const value = typeof toast === "function" ? toast(...args) : toast;
|
|
112
|
+
if (value === void 0) return fallback;
|
|
113
|
+
if (typeof value === "string") return {
|
|
114
|
+
...fallback,
|
|
115
|
+
title: value
|
|
116
|
+
};
|
|
117
|
+
return value && {
|
|
118
|
+
variant: fallback.variant,
|
|
119
|
+
...value
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* `useMutation` that shows a Kumo toast on success and error. Requires a
|
|
124
|
+
* `<Toasty>` ancestor. Your own `onSuccess` / `onError` still run.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```tsx
|
|
128
|
+
* const rename = useToastMutation({
|
|
129
|
+
* mutationFn: renameFile,
|
|
130
|
+
* toasts: {
|
|
131
|
+
* success: (file) => `Renamed to ${file.name}`,
|
|
132
|
+
* error: (error) => ({ title: "Rename failed", description: error.message }),
|
|
133
|
+
* },
|
|
134
|
+
* });
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
function useToastMutation({ toasts, ...options }, queryClient) {
|
|
138
|
+
const toastManager = useKumoToastManager();
|
|
139
|
+
return useMutation({
|
|
140
|
+
...options,
|
|
141
|
+
onSuccess: (data, variables, ...rest) => {
|
|
142
|
+
const toast = resolve(toasts?.success, {
|
|
143
|
+
variant: "success",
|
|
144
|
+
title: "Saved"
|
|
145
|
+
}, [data, variables]);
|
|
146
|
+
if (toast) toastManager.add(toast);
|
|
147
|
+
return options.onSuccess?.(data, variables, ...rest);
|
|
148
|
+
},
|
|
149
|
+
onError: (error, variables, ...rest) => {
|
|
150
|
+
const toast = resolve(toasts?.error, {
|
|
151
|
+
variant: "error",
|
|
152
|
+
title: "Something went wrong",
|
|
153
|
+
description: error instanceof Error ? error.message : void 0
|
|
154
|
+
}, [error, variables]);
|
|
155
|
+
if (toast) toastManager.add(toast);
|
|
156
|
+
return options.onError?.(error, variables, ...rest);
|
|
157
|
+
}
|
|
158
|
+
}, queryClient);
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/query/query-client.ts
|
|
162
|
+
/** Default options applied by {@link createFldrQueryClient}. */
|
|
163
|
+
const fldrQueryDefaults = {
|
|
164
|
+
queries: {
|
|
165
|
+
staleTime: 3e4,
|
|
166
|
+
retry: 1,
|
|
167
|
+
refetchOnWindowFocus: false
|
|
168
|
+
},
|
|
169
|
+
mutations: { retry: 0 }
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Creates a `QueryClient` with fldr defaults (30s `staleTime`, one retry, no
|
|
173
|
+
* refetch on window focus). Your `defaultOptions` are merged over them.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```tsx
|
|
177
|
+
* const queryClient = createFldrQueryClient({
|
|
178
|
+
* defaultOptions: { queries: { staleTime: 60_000 } },
|
|
179
|
+
* });
|
|
180
|
+
*
|
|
181
|
+
* <QueryClientProvider client={queryClient}>
|
|
182
|
+
* <App />
|
|
183
|
+
* </QueryClientProvider>
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
function createFldrQueryClient(config = {}) {
|
|
187
|
+
const { defaultOptions, ...rest } = config;
|
|
188
|
+
return new QueryClient$1({
|
|
189
|
+
...rest,
|
|
190
|
+
defaultOptions: {
|
|
191
|
+
...defaultOptions,
|
|
192
|
+
queries: {
|
|
193
|
+
...fldrQueryDefaults.queries,
|
|
194
|
+
...defaultOptions?.queries
|
|
195
|
+
},
|
|
196
|
+
mutations: {
|
|
197
|
+
...fldrQueryDefaults.mutations,
|
|
198
|
+
...defaultOptions?.mutations
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
204
|
+
export { QueryClient, QueryClientProvider, QueryState, QueryStates, createFldrQueryClient, fldrQueryDefaults, useToastMutation };
|
package/dist/router.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { b as SidebarMenuButtonProps } from "./sidebar-BkTAB4wj.js";
|
|
2
|
+
import { i as KumoButtonVariantsProps } from "./button-CS82eT0x.js";
|
|
3
|
+
import { i as KumoLinkVariantsProps } from "./link-CoVXE5W2.js";
|
|
4
|
+
import { AnchorHTMLAttributes, ReactNode } from "react";
|
|
5
|
+
//#region src/router/router-link.d.ts
|
|
6
|
+
type AnchorProps = AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
7
|
+
/** Props TanStack Router hands to the host when the link is active. */
|
|
8
|
+
type RouterStateProps = {
|
|
9
|
+
"data-status"?: "active";
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Type-safe TanStack Router link styled as a Kumo `Link`.
|
|
13
|
+
*
|
|
14
|
+
* Accepts every TanStack `Link` prop (`to`, `params`, `search`, `preload`, …)
|
|
15
|
+
* plus Kumo's `variant`.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <RouterLink to="/posts/$postId" params={{ postId: "42" }} variant="plain">
|
|
20
|
+
* Read post
|
|
21
|
+
* </RouterLink>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const RouterLink: import("@tanstack/react-router").LinkComponent<import("react").ForwardRefExoticComponent<AnchorProps & KumoLinkVariantsProps & import("react").RefAttributes<HTMLAnchorElement>>, string>;
|
|
25
|
+
/**
|
|
26
|
+
* Type-safe TanStack Router link styled as a Kumo `LinkButton`.
|
|
27
|
+
*
|
|
28
|
+
* Takes Button `variant`, `size`, `shape` and `icon`. TanStack's `disabled`
|
|
29
|
+
* renders LinkButton's disabled state.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* <RouterLinkButton to="/settings" variant="primary" icon={GearIcon}>
|
|
34
|
+
* Settings
|
|
35
|
+
* </RouterLinkButton>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare const RouterLinkButton: import("@tanstack/react-router").LinkComponent<import("react").ForwardRefExoticComponent<AnchorHTMLAttributes<HTMLAnchorElement> & KumoButtonVariantsProps & {
|
|
39
|
+
children?: React.ReactNode;
|
|
40
|
+
className?: string;
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
icon?: import("@phosphor-icons/react").Icon | React.ReactNode;
|
|
43
|
+
external?: boolean;
|
|
44
|
+
linksExternal?: boolean;
|
|
45
|
+
} & import("react").RefAttributes<HTMLAnchorElement>>, string>;
|
|
46
|
+
/**
|
|
47
|
+
* Type-safe TanStack Router link rendered as `Sidebar.MenuButton`.
|
|
48
|
+
*
|
|
49
|
+
* `active` comes from the router (`data-active` + `aria-current="page"`).
|
|
50
|
+
* Tune matching with `activeOptions`, e.g. `{ exact: true }` for index routes.
|
|
51
|
+
* Must sit inside `Sidebar.Provider`.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* <Sidebar.Menu>
|
|
56
|
+
* <RouterSidebarLink to="/" icon={HouseIcon} activeOptions={{ exact: true }}>
|
|
57
|
+
* Home
|
|
58
|
+
* </RouterSidebarLink>
|
|
59
|
+
* <RouterSidebarLink to="/projects" icon={FolderIcon}>Projects</RouterSidebarLink>
|
|
60
|
+
* </Sidebar.Menu>
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare const RouterSidebarLink: import("@tanstack/react-router").LinkComponent<import("react").ForwardRefExoticComponent<Omit<SidebarMenuButtonProps, "active"> & RouterStateProps & import("react").RefAttributes<HTMLButtonElement>>, string>;
|
|
64
|
+
/**
|
|
65
|
+
* Type-safe TanStack Router link rendered as `Breadcrumbs.Link`.
|
|
66
|
+
*
|
|
67
|
+
* The mobile trail only collapses `Breadcrumbs.Link` children, so on narrow
|
|
68
|
+
* screens a trail of `RouterBreadcrumbLink`s shows every crumb.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```tsx
|
|
72
|
+
* <Breadcrumbs>
|
|
73
|
+
* <RouterBreadcrumbLink to="/projects">Projects</RouterBreadcrumbLink>
|
|
74
|
+
* <Breadcrumbs.Separator />
|
|
75
|
+
* <Breadcrumbs.Current>Settings</Breadcrumbs.Current>
|
|
76
|
+
* </Breadcrumbs>
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare const RouterBreadcrumbLink: import("@tanstack/react-router").LinkComponent<import("react").ForwardRefExoticComponent<AnchorProps & {
|
|
80
|
+
icon?: ReactNode;
|
|
81
|
+
} & import("react").RefAttributes<HTMLAnchorElement>>, string>;
|
|
82
|
+
/**
|
|
83
|
+
* Routes every href-based Kumo link (`Link`, `LinkButton`,
|
|
84
|
+
* `Sidebar.MenuSubButton`, `Breadcrumbs.Link`, …) through TanStack Router.
|
|
85
|
+
* Hrefs are plain strings, so prefer the typed `Router*` links where you can.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```tsx
|
|
89
|
+
* const router = createRouter({ routeTree, InnerWrap: RouterLinkProvider });
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare function RouterLinkProvider({ children }: {
|
|
93
|
+
children: ReactNode;
|
|
94
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
95
|
+
//#endregion
|
package/dist/router.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as cn } from "./chunks/vendor-styling-gs32v7xt5znc8kg0.js";
|
|
3
|
+
import { t as LinkProvider } from "./chunks/link-provider-kbwllpbo24fvgioj.js";
|
|
4
|
+
import { r as Link$1 } from "./chunks/link-h84bkh8eem39p529.js";
|
|
5
|
+
import { n as LinkButton } from "./chunks/button-hzvowfkbathmx8yg.js";
|
|
6
|
+
import { t as Breadcrumb } from "./chunks/breadcrumbs-z1jo40oxlw8e4eh4.js";
|
|
7
|
+
import { i as Sidebar } from "./chunks/sidebar-mhlgvpawixxoey2k.js";
|
|
8
|
+
import { createContext, forwardRef, useContext } from "react";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
import { Link, createLink } from "@tanstack/react-router";
|
|
11
|
+
//#region src/router/router-link.tsx
|
|
12
|
+
const KumoLinkAnchor = forwardRef(function KumoLinkAnchor(props, ref) {
|
|
13
|
+
return /* @__PURE__ */ jsx(Link$1, {
|
|
14
|
+
ref,
|
|
15
|
+
render: /* @__PURE__ */ jsx("a", {}),
|
|
16
|
+
...props
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Type-safe TanStack Router link styled as a Kumo `Link`.
|
|
21
|
+
*
|
|
22
|
+
* Accepts every TanStack `Link` prop (`to`, `params`, `search`, `preload`, …)
|
|
23
|
+
* plus Kumo's `variant`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <RouterLink to="/posts/$postId" params={{ postId: "42" }} variant="plain">
|
|
28
|
+
* Read post
|
|
29
|
+
* </RouterLink>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
const RouterLink = createLink(KumoLinkAnchor);
|
|
33
|
+
const KumoLinkButtonAnchor = forwardRef(function KumoLinkButtonAnchor(props, ref) {
|
|
34
|
+
return /* @__PURE__ */ jsx(LinkProvider, { children: /* @__PURE__ */ jsx(LinkButton, {
|
|
35
|
+
ref,
|
|
36
|
+
...props
|
|
37
|
+
}) });
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* Type-safe TanStack Router link styled as a Kumo `LinkButton`.
|
|
41
|
+
*
|
|
42
|
+
* Takes Button `variant`, `size`, `shape` and `icon`. TanStack's `disabled`
|
|
43
|
+
* renders LinkButton's disabled state.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <RouterLinkButton to="/settings" variant="primary" icon={GearIcon}>
|
|
48
|
+
* Settings
|
|
49
|
+
* </RouterLinkButton>
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
const RouterLinkButton = createLink(KumoLinkButtonAnchor);
|
|
53
|
+
const SidebarMenuAnchor = forwardRef(function SidebarMenuAnchor(props, ref) {
|
|
54
|
+
return /* @__PURE__ */ jsx(LinkProvider, { children: /* @__PURE__ */ jsx(Sidebar.MenuButton, {
|
|
55
|
+
ref,
|
|
56
|
+
active: props["data-status"] === "active",
|
|
57
|
+
...props
|
|
58
|
+
}) });
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Type-safe TanStack Router link rendered as `Sidebar.MenuButton`.
|
|
62
|
+
*
|
|
63
|
+
* `active` comes from the router (`data-active` + `aria-current="page"`).
|
|
64
|
+
* Tune matching with `activeOptions`, e.g. `{ exact: true }` for index routes.
|
|
65
|
+
* Must sit inside `Sidebar.Provider`.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```tsx
|
|
69
|
+
* <Sidebar.Menu>
|
|
70
|
+
* <RouterSidebarLink to="/" icon={HouseIcon} activeOptions={{ exact: true }}>
|
|
71
|
+
* Home
|
|
72
|
+
* </RouterSidebarLink>
|
|
73
|
+
* <RouterSidebarLink to="/projects" icon={FolderIcon}>Projects</RouterSidebarLink>
|
|
74
|
+
* </Sidebar.Menu>
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
const RouterSidebarLink = createLink(SidebarMenuAnchor);
|
|
78
|
+
const RouterAnchorContext = createContext(null);
|
|
79
|
+
/** Anchor that layers the enclosing router props over Kumo's own props. */
|
|
80
|
+
const RouterAnchor = forwardRef(function RouterAnchor({ to: _to, className, ...props }, ref) {
|
|
81
|
+
const routerProps = useContext(RouterAnchorContext);
|
|
82
|
+
return /* @__PURE__ */ jsx("a", {
|
|
83
|
+
ref,
|
|
84
|
+
...props,
|
|
85
|
+
...routerProps,
|
|
86
|
+
className: cn(className, routerProps?.className)
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
const BreadcrumbAnchor = forwardRef(function BreadcrumbAnchor({ icon, children, href, ...props }, ref) {
|
|
90
|
+
return /* @__PURE__ */ jsx(RouterAnchorContext.Provider, {
|
|
91
|
+
value: {
|
|
92
|
+
...props,
|
|
93
|
+
href,
|
|
94
|
+
ref
|
|
95
|
+
},
|
|
96
|
+
children: /* @__PURE__ */ jsx(LinkProvider, {
|
|
97
|
+
component: RouterAnchor,
|
|
98
|
+
children: /* @__PURE__ */ jsx(Breadcrumb.Link, {
|
|
99
|
+
href: href ?? "",
|
|
100
|
+
icon,
|
|
101
|
+
children
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
/**
|
|
107
|
+
* Type-safe TanStack Router link rendered as `Breadcrumbs.Link`.
|
|
108
|
+
*
|
|
109
|
+
* The mobile trail only collapses `Breadcrumbs.Link` children, so on narrow
|
|
110
|
+
* screens a trail of `RouterBreadcrumbLink`s shows every crumb.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```tsx
|
|
114
|
+
* <Breadcrumbs>
|
|
115
|
+
* <RouterBreadcrumbLink to="/projects">Projects</RouterBreadcrumbLink>
|
|
116
|
+
* <Breadcrumbs.Separator />
|
|
117
|
+
* <Breadcrumbs.Current>Settings</Breadcrumbs.Current>
|
|
118
|
+
* </Breadcrumbs>
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
const RouterBreadcrumbLink = createLink(BreadcrumbAnchor);
|
|
122
|
+
const HrefLink = forwardRef(function HrefLink({ href, to, ...props }, ref) {
|
|
123
|
+
return /* @__PURE__ */ jsx(Link, {
|
|
124
|
+
ref,
|
|
125
|
+
to: href ?? to,
|
|
126
|
+
...props
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
/**
|
|
130
|
+
* Routes every href-based Kumo link (`Link`, `LinkButton`,
|
|
131
|
+
* `Sidebar.MenuSubButton`, `Breadcrumbs.Link`, …) through TanStack Router.
|
|
132
|
+
* Hrefs are plain strings, so prefer the typed `Router*` links where you can.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```tsx
|
|
136
|
+
* const router = createRouter({ routeTree, InnerWrap: RouterLinkProvider });
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
function RouterLinkProvider({ children }) {
|
|
140
|
+
return /* @__PURE__ */ jsx(LinkProvider, {
|
|
141
|
+
component: HrefLink,
|
|
142
|
+
children
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
export { RouterBreadcrumbLink, RouterLink, RouterLinkButton, RouterLinkProvider, RouterSidebarLink };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Skeleton, SkeletonBox, SkeletonBoxProps, SkeletonProps, SkeletonSuspense, SkeletonSuspenseProps, SkulletConfig as SkeletonProviderProps, SkulletProvider as SkeletonProvider, useReveal } from "skullet/react";
|
|
2
|
+
import { forgetShapes } from "skullet";
|
|
3
|
+
export { Skeleton, SkeletonBox, type SkeletonBoxProps, type SkeletonProps, SkeletonProvider, type SkeletonProviderProps, SkeletonSuspense, type SkeletonSuspenseProps, forgetShapes, useReveal };
|
package/dist/skeleton.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Skeleton, SkeletonBox, SkeletonSuspense, SkulletProvider as SkeletonProvider, useReveal } from "skullet/react";
|
|
3
|
+
import { forgetShapes } from "skullet";
|
|
4
|
+
export { Skeleton, SkeletonBox, SkeletonProvider, SkeletonSuspense, forgetShapes, useReveal };
|
|
@@ -46,6 +46,42 @@
|
|
|
46
46
|
[data-mode="dark"] {
|
|
47
47
|
color-scheme: dark;
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
/* skullet skeletons (@fldr/ui/skeleton) follow the active theme. Redeclared
|
|
51
|
+
wherever a theme or mode can change, since var() resolves where declared. */
|
|
52
|
+
:root,
|
|
53
|
+
[data-theme],
|
|
54
|
+
[data-mode] {
|
|
55
|
+
--skullet-base: color-mix(in oklab, var(--text-color-kumo-default) 9%, transparent);
|
|
56
|
+
--skullet-highlight: color-mix(in oklab, var(--text-color-kumo-default) 5%, transparent);
|
|
57
|
+
--skullet-radius: 0.375rem;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Themed brand logos (@fldr/ui/brands) render both variants; show one.
|
|
61
|
+
Order matters: system scheme first, then an explicit data-mode wins. */
|
|
62
|
+
.fldr-brand-dark {
|
|
63
|
+
display: none;
|
|
64
|
+
}
|
|
65
|
+
@media (prefers-color-scheme: dark) {
|
|
66
|
+
.fldr-brand-light {
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
69
|
+
.fldr-brand-dark {
|
|
70
|
+
display: inline;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
[data-mode="light"] .fldr-brand-light {
|
|
74
|
+
display: inline;
|
|
75
|
+
}
|
|
76
|
+
[data-mode="light"] .fldr-brand-dark {
|
|
77
|
+
display: none;
|
|
78
|
+
}
|
|
79
|
+
[data-mode="dark"] .fldr-brand-light {
|
|
80
|
+
display: none;
|
|
81
|
+
}
|
|
82
|
+
[data-mode="dark"] .fldr-brand-dark {
|
|
83
|
+
display: inline;
|
|
84
|
+
}
|
|
49
85
|
}
|
|
50
86
|
|
|
51
87
|
@layer utilities {
|