@yimingliao/cms 0.0.79 → 0.0.81

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.
@@ -5,6 +5,7 @@ import { QueryClient, UseMutationOptions, UseQueryOptions } from '@tanstack/reac
5
5
  import * as _tanstack_query_core from '@tanstack/query-core';
6
6
  import * as react_jsx_runtime from 'react/jsx-runtime';
7
7
  import { c as createVerifyAction } from '../create-verify-action-DBwWOXPO.js';
8
+ import { ComponentProps } from 'react';
8
9
  import '../types-J25u1G6t.js';
9
10
  import '../types-0oS1A2K5.js';
10
11
  import 'jsonwebtoken';
@@ -324,4 +325,6 @@ declare function createAdminInitializer({ useAdmin, useQuery, verifyAction, }: {
324
325
  verifyAction: ReturnType<typeof createVerifyAction>;
325
326
  }): () => null;
326
327
 
327
- export { AdminProvider, type ShowToastOption, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin };
328
+ declare function Form({ onSubmit, className, ...props }: ComponentProps<"form">): react_jsx_runtime.JSX.Element;
329
+
330
+ export { AdminProvider, Form, type ShowToastOption, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin };
@@ -3,6 +3,8 @@ import { toast } from 'sonner';
3
3
  import { jsx, jsxs } from 'react/jsx-runtime';
4
4
  import { useMutation, useQuery } from '@tanstack/react-query';
5
5
  import { createContext, useState, useContext, useEffect } from 'react';
6
+ import { clsx } from 'clsx';
7
+ import { twMerge } from 'tailwind-merge';
6
8
 
7
9
  // src/client/infrastructure/fetch/smart-fetch.ts
8
10
  function createSmartFetch({
@@ -227,12 +229,27 @@ function createAdminInitializer({
227
229
  }
228
230
  );
229
231
  useEffect(() => {
230
- if (isFetching || !admin) return;
231
- setAdmin(admin);
232
+ if (isFetching) return;
233
+ if (admin) setAdmin(admin);
232
234
  setIsLoading(false);
233
235
  }, [isFetching, admin, setAdmin, setIsLoading]);
234
236
  return null;
235
237
  };
236
238
  }
239
+ var cn = (...inputs) => {
240
+ return twMerge(clsx(inputs));
241
+ };
242
+ function Form({
243
+ onSubmit,
244
+ className,
245
+ ...props
246
+ }) {
247
+ const handleSubmit = (e) => {
248
+ if (!onSubmit) return;
249
+ e.preventDefault();
250
+ void onSubmit(e);
251
+ };
252
+ return /* @__PURE__ */ jsx("form", { className: cn(className), onSubmit: handleSubmit, ...props });
253
+ }
237
254
 
238
- export { AdminProvider, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin };
255
+ export { AdminProvider, Form, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yimingliao/cms",
3
- "version": "0.0.79",
3
+ "version": "0.0.81",
4
4
  "author": "Yiming Liao",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -45,12 +45,14 @@
45
45
  "dependencies": {
46
46
  "@keyv/redis": "^5.1.6",
47
47
  "argon2": "^0.44.0",
48
+ "clsx": "^2.1.1",
48
49
  "jsonwebtoken": "^9.0.3",
49
50
  "keyv": "^5.6.0",
50
51
  "logry": "^2.1.6",
51
52
  "mime-types": "^3.0.2",
52
53
  "nodemailer": "^8.0.1",
53
54
  "sonner": "^2.0.7",
55
+ "tailwind-merge": "^3.5.0",
54
56
  "ulid": "^3.0.2"
55
57
  },
56
58
  "devDependencies": {