fantasia-ui 0.2.7 → 0.2.9
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.en.md +27 -11
- package/README.md +28 -12
- package/dist/index.d.ts +0 -1
- package/package.json +3 -3
package/README.en.md
CHANGED
|
@@ -240,19 +240,35 @@ The component library supports theme customization via CSS variables:
|
|
|
240
240
|
|
|
241
241
|
Fantasia UI provides complete TypeScript type definitions:
|
|
242
242
|
|
|
243
|
+
```vue
|
|
244
|
+
<script setup lang="ts">
|
|
245
|
+
import { FButton } from 'fantasia-ui'
|
|
246
|
+
|
|
247
|
+
// TypeScript will automatically infer props types
|
|
248
|
+
// No need to manually import FButtonProps
|
|
249
|
+
</script>
|
|
250
|
+
|
|
251
|
+
<template>
|
|
252
|
+
<FButton variant="primary" size="large">
|
|
253
|
+
Button
|
|
254
|
+
</FButton>
|
|
255
|
+
</template>
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### If you need component Props types
|
|
259
|
+
|
|
260
|
+
You can use TypeScript utility types to infer from components:
|
|
261
|
+
|
|
243
262
|
```typescript
|
|
244
|
-
import
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
// Use types
|
|
263
|
+
import { FButton } from 'fantasia-ui'
|
|
264
|
+
import type { ComponentProps } from 'vue'
|
|
265
|
+
|
|
266
|
+
// Infer props type from component
|
|
267
|
+
type FButtonProps = ComponentProps<typeof FButton>
|
|
268
|
+
|
|
252
269
|
const buttonProps: FButtonProps = {
|
|
253
|
-
|
|
254
|
-
size: 'large'
|
|
255
|
-
disabled: false
|
|
270
|
+
variant: 'primary',
|
|
271
|
+
size: 'large'
|
|
256
272
|
}
|
|
257
273
|
```
|
|
258
274
|
|
package/README.md
CHANGED
|
@@ -236,23 +236,39 @@ import { FRow, FCol, FSpace } from 'fantasia-ui'
|
|
|
236
236
|
}
|
|
237
237
|
```
|
|
238
238
|
|
|
239
|
-
##
|
|
239
|
+
## 📝 TypeScript 支持
|
|
240
240
|
|
|
241
241
|
Fantasia UI 提供完整的 TypeScript 类型定义:
|
|
242
242
|
|
|
243
|
+
```vue
|
|
244
|
+
<script setup lang="ts">
|
|
245
|
+
import { FButton } from 'fantasia-ui'
|
|
246
|
+
|
|
247
|
+
// TypeScript 会自动推断 props 类型
|
|
248
|
+
// 无需手动导入 FButtonProps
|
|
249
|
+
</script>
|
|
250
|
+
|
|
251
|
+
<template>
|
|
252
|
+
<FButton variant="primary" size="large">
|
|
253
|
+
按钮
|
|
254
|
+
</FButton>
|
|
255
|
+
</template>
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### 如果需要组件 Props 类型
|
|
259
|
+
|
|
260
|
+
可以使用 TypeScript 工具类型从组件推断:
|
|
261
|
+
|
|
243
262
|
```typescript
|
|
244
|
-
import
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
// 使用类型
|
|
263
|
+
import { FButton } from 'fantasia-ui'
|
|
264
|
+
import type { ComponentProps } from 'vue'
|
|
265
|
+
|
|
266
|
+
// 从组件推断 props 类型
|
|
267
|
+
type FButtonProps = ComponentProps<typeof FButton>
|
|
268
|
+
|
|
252
269
|
const buttonProps: FButtonProps = {
|
|
253
|
-
|
|
254
|
-
size: 'large'
|
|
255
|
-
disabled: false
|
|
270
|
+
variant: 'primary',
|
|
271
|
+
size: 'large'
|
|
256
272
|
}
|
|
257
273
|
```
|
|
258
274
|
|
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fantasia-ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.9",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/fantasia-ui.umd.js",
|
|
7
7
|
"module": "dist/fantasia-ui.es.js",
|
|
8
|
-
"types": "dist/
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"types": "./dist/
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/fantasia-ui.es.js",
|
|
13
13
|
"require": "./dist/fantasia-ui.umd.js"
|
|
14
14
|
},
|