react-unified-auth 1.0.1 → 1.0.2

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 CHANGED
@@ -220,14 +220,77 @@ const { formConfig, loading, error } = useDynamicForm(formId);
220
220
  - `POST /auth/logout` - 用户登出
221
221
  - `GET /auth/me` - 获取当前用户信息
222
222
 
223
- ## 样式自定义
224
-
225
- 组件使用了Tailwind CSS的类名,你可以通过以下方式自定义样式:
226
-
227
- 1. 在你的项目中配置Tailwind CSS
228
- 2. 通过`className` prop传递自定义类名
229
- 3. 覆盖默认样式
230
-
223
+ ## 样式自定义
224
+
225
+ 组件使用了Tailwind CSS的类名,你可以通过以下方式自定义样式:
226
+
227
+ ### 1. 基本配置
228
+
229
+ 确保你的项目中已正确配置Tailwind CSS:
230
+
231
+ ```bash
232
+ # 安装依赖
233
+ npm install -D tailwindcss postcss autoprefixer
234
+
235
+ # 初始化配置
236
+ npx tailwindcss init -p
237
+ ```
238
+
239
+ ### 2. 更新tailwind.config.js
240
+
241
+ 在配置中包含组件库的文件路径:
242
+
243
+ ```js
244
+ // tailwind.config.js
245
+ module.exports = {
246
+ content: [
247
+ "./src/**/*.{js,ts,jsx,tsx}",
248
+ "./node_modules/react-unified-auth/dist/**/*.{js,ts,jsx,tsx}", // 必须包含此行
249
+ ],
250
+ theme: {
251
+ extend: {},
252
+ },
253
+ plugins: [],
254
+ }
255
+ ```
256
+
257
+ ### 3. 导入Tailwind CSS
258
+
259
+ 在项目入口文件中导入:
260
+
261
+ ```css
262
+ /* src/index.css */
263
+ @tailwind base;
264
+ @tailwind components;
265
+ @tailwind utilities;
266
+ ```
267
+
268
+ ```jsx
269
+ // src/index.jsx
270
+ import './index.css';
271
+ ```
272
+
273
+ ### 4. 自定义样式
274
+
275
+ - **通过className覆盖**:
276
+ ```jsx
277
+ <Button className="bg-red-600 hover:bg-red-700" />
278
+ ```
279
+
280
+ - **在Tailwind配置中扩展**:
281
+ ```js
282
+ // tailwind.config.js
283
+ module.exports = {
284
+ theme: {
285
+ extend: {
286
+ colors: {
287
+ primary: '#1d4ed8',
288
+ },
289
+ },
290
+ },
291
+ }
292
+ ```
293
+
231
294
  ## 开发
232
295
 
233
296
  ```bash
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
- import React, { createContext, useContext, useState, useEffect } from 'react';
2
+ import { createContext, useContext, useState, useEffect } from 'react';
3
3
 
4
4
  const AuthContext = createContext(undefined);
5
5
  function AuthProvider({ config, children }) {
@@ -4189,7 +4189,7 @@ function DynamicForm({ fields, onSubmit, submitText = 'Submit', submitVariant =
4189
4189
  function LoginForm({ formId, onSuccess, onError }) {
4190
4190
  const config = useAuthConfig();
4191
4191
  const { formConfig, loading: formLoading, error: formError } = useDynamicForm(formId);
4192
- const [submitting, setSubmitting] = React.useState(false);
4192
+ const [submitting, setSubmitting] = useState(false);
4193
4193
  const handleSubmit = async (values) => {
4194
4194
  if (!formConfig)
4195
4195
  return;