@fjyueke/bify-mcp 1.0.0

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.
Files changed (210) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +248 -0
  5. package/metaData/components/action-sheet/api.md +74 -0
  6. package/metaData/components/action-sheet/doc.md +243 -0
  7. package/metaData/components/action-sheet/example/index.tsx +116 -0
  8. package/metaData/components/area-picker/api.md +25 -0
  9. package/metaData/components/area-picker/doc.md +132 -0
  10. package/metaData/components/area-picker/example/index.tsx +60 -0
  11. package/metaData/components/avatar/api.md +19 -0
  12. package/metaData/components/avatar/doc.md +170 -0
  13. package/metaData/components/avatar/example/index.tsx +76 -0
  14. package/metaData/components/back-top/api.md +21 -0
  15. package/metaData/components/back-top/doc.md +142 -0
  16. package/metaData/components/back-top/example/index.tsx +96 -0
  17. package/metaData/components/backdrop/api.md +20 -0
  18. package/metaData/components/backdrop/doc.md +98 -0
  19. package/metaData/components/backdrop/example/index.tsx +33 -0
  20. package/metaData/components/badge/api.md +10 -0
  21. package/metaData/components/badge/doc.md +169 -0
  22. package/metaData/components/badge/example/index.tsx +81 -0
  23. package/metaData/components/button/api.md +31 -0
  24. package/metaData/components/button/doc.md +235 -0
  25. package/metaData/components/button/example/index.tsx +235 -0
  26. package/metaData/components/calendar/api.md +62 -0
  27. package/metaData/components/calendar/doc.md +516 -0
  28. package/metaData/components/calendar/example/index.tsx +501 -0
  29. package/metaData/components/cascader/api.md +55 -0
  30. package/metaData/components/cascader/doc.md +358 -0
  31. package/metaData/components/cascader/example/index.tsx +159 -0
  32. package/metaData/components/cell/api.md +37 -0
  33. package/metaData/components/cell/doc.md +158 -0
  34. package/metaData/components/cell/example/index.tsx +44 -0
  35. package/metaData/components/checkbox/api.md +35 -0
  36. package/metaData/components/checkbox/doc.md +203 -0
  37. package/metaData/components/checkbox/example/index.tsx +94 -0
  38. package/metaData/components/circle/api.md +17 -0
  39. package/metaData/components/circle/doc.md +123 -0
  40. package/metaData/components/circle/example/index.tsx +81 -0
  41. package/metaData/components/collapse/api.md +31 -0
  42. package/metaData/components/collapse/doc.md +142 -0
  43. package/metaData/components/collapse/example/index.tsx +81 -0
  44. package/metaData/components/config-provider/api.md +7 -0
  45. package/metaData/components/config-provider/doc.md +193 -0
  46. package/metaData/components/config-provider/example/index.tsx +54 -0
  47. package/metaData/components/countdown/api.md +46 -0
  48. package/metaData/components/countdown/doc.md +167 -0
  49. package/metaData/components/countdown/example/index.tsx +70 -0
  50. package/metaData/components/datetime-picker/api.md +25 -0
  51. package/metaData/components/datetime-picker/doc.md +317 -0
  52. package/metaData/components/datetime-picker/example/index.tsx +265 -0
  53. package/metaData/components/dialog/api.md +66 -0
  54. package/metaData/components/dialog/doc.md +292 -0
  55. package/metaData/components/dialog/example/index.tsx +138 -0
  56. package/metaData/components/divider/api.md +15 -0
  57. package/metaData/components/divider/doc.md +108 -0
  58. package/metaData/components/divider/example/index.tsx +45 -0
  59. package/metaData/components/dropdown-menu/api.md +37 -0
  60. package/metaData/components/dropdown-menu/doc.md +279 -0
  61. package/metaData/components/dropdown-menu/example/index.tsx +182 -0
  62. package/metaData/components/empty/api.md +20 -0
  63. package/metaData/components/empty/doc.md +126 -0
  64. package/metaData/components/empty/example/index.tsx +66 -0
  65. package/metaData/components/field/api.md +10 -0
  66. package/metaData/components/field/doc.md +274 -0
  67. package/metaData/components/field/example/index.tsx +203 -0
  68. package/metaData/components/fixed-nav/api.md +21 -0
  69. package/metaData/components/fixed-nav/doc.md +196 -0
  70. package/metaData/components/fixed-nav/example/index.tsx +80 -0
  71. package/metaData/components/fixed-view/api.md +10 -0
  72. package/metaData/components/fixed-view/doc.md +25 -0
  73. package/metaData/components/fixed-view/example/index.tsx +12 -0
  74. package/metaData/components/flex/api.md +18 -0
  75. package/metaData/components/flex/doc.md +103 -0
  76. package/metaData/components/flex/example/index.tsx +58 -0
  77. package/metaData/components/floating-bubble/api.md +18 -0
  78. package/metaData/components/floating-bubble/doc.md +94 -0
  79. package/metaData/components/floating-bubble/example/index.tsx +55 -0
  80. package/metaData/components/floating-panel/api.md +19 -0
  81. package/metaData/components/floating-panel/doc.md +174 -0
  82. package/metaData/components/floating-panel/example/index.tsx +131 -0
  83. package/metaData/components/form/api.md +124 -0
  84. package/metaData/components/form/doc.md +759 -0
  85. package/metaData/components/form/example/index.tsx +222 -0
  86. package/metaData/components/grid/api.md +28 -0
  87. package/metaData/components/grid/doc.md +167 -0
  88. package/metaData/components/grid/example/index.tsx +80 -0
  89. package/metaData/components/image/api.md +42 -0
  90. package/metaData/components/image/doc.md +117 -0
  91. package/metaData/components/image/example/index.tsx +76 -0
  92. package/metaData/components/index-list/api.md +39 -0
  93. package/metaData/components/index-list/doc.md +176 -0
  94. package/metaData/components/index-list/example/index.tsx +110 -0
  95. package/metaData/components/list/api.md +30 -0
  96. package/metaData/components/list/doc.md +317 -0
  97. package/metaData/components/list/example/index.tsx +218 -0
  98. package/metaData/components/loading/api.md +10 -0
  99. package/metaData/components/loading/doc.md +113 -0
  100. package/metaData/components/loading/example/index.tsx +47 -0
  101. package/metaData/components/navbar/api.md +26 -0
  102. package/metaData/components/navbar/doc.md +85 -0
  103. package/metaData/components/navbar/example/index.tsx +28 -0
  104. package/metaData/components/notice-bar/api.md +28 -0
  105. package/metaData/components/notice-bar/doc.md +154 -0
  106. package/metaData/components/notice-bar/example/index.tsx +107 -0
  107. package/metaData/components/notify/api.md +28 -0
  108. package/metaData/components/notify/doc.md +140 -0
  109. package/metaData/components/notify/example/index.tsx +89 -0
  110. package/metaData/components/number-keyboard/api.md +21 -0
  111. package/metaData/components/number-keyboard/doc.md +247 -0
  112. package/metaData/components/number-keyboard/example/index.tsx +201 -0
  113. package/metaData/components/pagination/api.md +18 -0
  114. package/metaData/components/pagination/doc.md +113 -0
  115. package/metaData/components/pagination/example/index.tsx +73 -0
  116. package/metaData/components/password-input/api.md +25 -0
  117. package/metaData/components/password-input/doc.md +126 -0
  118. package/metaData/components/password-input/example/index.tsx +124 -0
  119. package/metaData/components/picker/api.md +61 -0
  120. package/metaData/components/picker/doc.md +336 -0
  121. package/metaData/components/picker/example/index.tsx +232 -0
  122. package/metaData/components/popup/api.md +48 -0
  123. package/metaData/components/popup/doc.md +150 -0
  124. package/metaData/components/popup/example/index.tsx +214 -0
  125. package/metaData/components/progress/api.md +11 -0
  126. package/metaData/components/progress/doc.md +105 -0
  127. package/metaData/components/progress/example/index.tsx +58 -0
  128. package/metaData/components/pull-refresh/api.md +18 -0
  129. package/metaData/components/pull-refresh/doc.md +198 -0
  130. package/metaData/components/pull-refresh/example/index.tsx +153 -0
  131. package/metaData/components/radio/api.md +26 -0
  132. package/metaData/components/radio/doc.md +201 -0
  133. package/metaData/components/radio/example/index.tsx +103 -0
  134. package/metaData/components/rate/api.md +23 -0
  135. package/metaData/components/rate/doc.md +122 -0
  136. package/metaData/components/rate/example/index.tsx +36 -0
  137. package/metaData/components/rolling-text/api.md +23 -0
  138. package/metaData/components/rolling-text/doc.md +153 -0
  139. package/metaData/components/rolling-text/example/index.tsx +150 -0
  140. package/metaData/components/safe-area/api.md +8 -0
  141. package/metaData/components/safe-area/doc.md +30 -0
  142. package/metaData/components/safe-area/example/index.tsx +16 -0
  143. package/metaData/components/search/api.md +35 -0
  144. package/metaData/components/search/doc.md +185 -0
  145. package/metaData/components/search/example/index.tsx +101 -0
  146. package/metaData/components/share-sheet/api.md +48 -0
  147. package/metaData/components/share-sheet/doc.md +215 -0
  148. package/metaData/components/share-sheet/example/index.tsx +143 -0
  149. package/metaData/components/sidebar/api.md +28 -0
  150. package/metaData/components/sidebar/doc.md +122 -0
  151. package/metaData/components/sidebar/example/index.tsx +58 -0
  152. package/metaData/components/signature/api.md +19 -0
  153. package/metaData/components/signature/doc.md +115 -0
  154. package/metaData/components/signature/example/index.tsx +56 -0
  155. package/metaData/components/skeleton/api.md +45 -0
  156. package/metaData/components/skeleton/doc.md +131 -0
  157. package/metaData/components/skeleton/example/index.tsx +80 -0
  158. package/metaData/components/slider/api.md +28 -0
  159. package/metaData/components/slider/doc.md +151 -0
  160. package/metaData/components/slider/example/index.tsx +54 -0
  161. package/metaData/components/space/api.md +12 -0
  162. package/metaData/components/space/doc.md +125 -0
  163. package/metaData/components/space/example/index.tsx +75 -0
  164. package/metaData/components/stepper/api.md +37 -0
  165. package/metaData/components/stepper/doc.md +152 -0
  166. package/metaData/components/stepper/example/index.tsx +45 -0
  167. package/metaData/components/steps/api.md +9 -0
  168. package/metaData/components/steps/doc.md +143 -0
  169. package/metaData/components/steps/example/index.tsx +93 -0
  170. package/metaData/components/sticky/api.md +16 -0
  171. package/metaData/components/sticky/doc.md +87 -0
  172. package/metaData/components/sticky/example/index.tsx +62 -0
  173. package/metaData/components/swipe-cell/api.md +19 -0
  174. package/metaData/components/swipe-cell/doc.md +105 -0
  175. package/metaData/components/swipe-cell/example/index.tsx +62 -0
  176. package/metaData/components/swiper/api.md +22 -0
  177. package/metaData/components/swiper/doc.md +228 -0
  178. package/metaData/components/swiper/example/index.tsx +118 -0
  179. package/metaData/components/switch/api.md +17 -0
  180. package/metaData/components/switch/doc.md +110 -0
  181. package/metaData/components/switch/example/index.tsx +57 -0
  182. package/metaData/components/tabbar/api.md +27 -0
  183. package/metaData/components/tabbar/doc.md +160 -0
  184. package/metaData/components/tabbar/example/index.tsx +99 -0
  185. package/metaData/components/tabs/api.md +36 -0
  186. package/metaData/components/tabs/doc.md +307 -0
  187. package/metaData/components/tabs/example/index.tsx +231 -0
  188. package/metaData/components/tag/api.md +17 -0
  189. package/metaData/components/tag/doc.md +162 -0
  190. package/metaData/components/tag/example/index.tsx +84 -0
  191. package/metaData/components/text-ellipsis/api.md +26 -0
  192. package/metaData/components/text-ellipsis/doc.md +135 -0
  193. package/metaData/components/text-ellipsis/example/index.tsx +44 -0
  194. package/metaData/components/timeline/api.md +20 -0
  195. package/metaData/components/timeline/doc.md +210 -0
  196. package/metaData/components/timeline/example/index.tsx +145 -0
  197. package/metaData/components/toast/api.md +39 -0
  198. package/metaData/components/toast/doc.md +256 -0
  199. package/metaData/components/toast/example/index.tsx +136 -0
  200. package/metaData/components/tree-select/api.md +19 -0
  201. package/metaData/components/tree-select/doc.md +185 -0
  202. package/metaData/components/tree-select/example/index.tsx +112 -0
  203. package/metaData/components/uploader/api.md +32 -0
  204. package/metaData/components/uploader/doc.md +340 -0
  205. package/metaData/components/uploader/example/index.tsx +222 -0
  206. package/metaData/components/watermark/api.md +18 -0
  207. package/metaData/components/watermark/doc.md +97 -0
  208. package/metaData/components/watermark/example/index.tsx +62 -0
  209. package/metaData/components-index.json +274 -0
  210. package/package.json +56 -0
@@ -0,0 +1,58 @@
1
+ import { Flex } from "@fjyueke/bify-core"
2
+ import Block from "../../../components/block"
3
+ import Page from "../../../components/page"
4
+ import "./index.scss"
5
+
6
+ export default function FlexDemo() {
7
+ return (
8
+ <Page title="Flex 布局" className="flex-demo">
9
+ <Block title="基础用法">
10
+ <Flex>
11
+ <Flex.Item span={8}>span: 8</Flex.Item>
12
+ <Flex.Item span={8}>span: 8</Flex.Item>
13
+ <Flex.Item span={8}>span: 8</Flex.Item>
14
+ </Flex>
15
+ <Flex>
16
+ <Flex.Item span={4}>span: 4</Flex.Item>
17
+ <Flex.Item span={10} offset={4}>
18
+ offset: 4, span: 10
19
+ </Flex.Item>
20
+ </Flex>
21
+ <Flex>
22
+ <Flex.Item offset={12} span={12}>
23
+ offset: 12, span: 12
24
+ </Flex.Item>
25
+ </Flex>
26
+ </Block>
27
+ <Block title="在列元素之间增加间距">
28
+ <Flex gutter={12}>
29
+ <Flex.Item span={8}>span: 8</Flex.Item>
30
+ <Flex.Item span={8}>span: 8</Flex.Item>
31
+ <Flex.Item span={8}>span: 8</Flex.Item>
32
+ </Flex>
33
+ </Block>
34
+ <Block title="Flex 布局">
35
+ <Flex justify="center">
36
+ <Flex.Item span={6}>span: 6</Flex.Item>
37
+ <Flex.Item span={6}>span: 6</Flex.Item>
38
+ <Flex.Item span={6}>span: 6</Flex.Item>
39
+ </Flex>
40
+ <Flex justify="end">
41
+ <Flex.Item span={6}>span: 6</Flex.Item>
42
+ <Flex.Item span={6}>span: 6</Flex.Item>
43
+ <Flex.Item span={6}>span: 6</Flex.Item>
44
+ </Flex>
45
+ <Flex justify="space-between">
46
+ <Flex.Item span={6}>span: 6</Flex.Item>
47
+ <Flex.Item span={6}>span: 6</Flex.Item>
48
+ <Flex.Item span={6}>span: 6</Flex.Item>
49
+ </Flex>
50
+ <Flex justify="space-around">
51
+ <Flex.Item span={6}>span: 6</Flex.Item>
52
+ <Flex.Item span={6}>span: 6</Flex.Item>
53
+ <Flex.Item span={6}>span: 6</Flex.Item>
54
+ </Flex>
55
+ </Block>
56
+ </Page>
57
+ )
58
+ }
@@ -0,0 +1,18 @@
1
+ ## API
2
+
3
+ ### Flex Props
4
+
5
+ | 参数 | 说明 | 类型 | 默认值 |
6
+ | -------- | ------------------------------------------------------- | ---------------------------- | ---------------- |
7
+ | offset | 控制气泡位置 | OffsetType | `默认右下角坐标` |
8
+ | axis | 拖拽的方向,`xy` 代表自由拖拽,`lock` 代表禁止拖拽 | _x_ \| _y_ \| _xy_ \| _lock_ | `y` |
9
+ | magnetic | 自动磁吸的方向 | _x_ \| _y_ | `-` |
10
+ | icon | 左侧[图标](/components/icon)或[图片](/components/image) | _ReactNode_ | `-` |
11
+ | gap | 气泡与窗口的最小间距,单位为 `px` | _Number_ | `48` |
12
+
13
+ ### Events
14
+
15
+ | 事件名 | 说明 | 回调参数 |
16
+ | -------------- | ---------------------------- | ---------------------- |
17
+ | onClick | 点击组件时触发 | _ITouchEvent_ |
18
+ | onOffsetChange | 由用户拖拽导致位置改变后触发 | _x: string, y: string_ |
@@ -0,0 +1,94 @@
1
+ # FloatingBubble 浮动气泡
2
+
3
+ ### 介绍
4
+
5
+ 悬浮在页面边缘的可点击气泡。
6
+
7
+ 请升级 `taroify` 到 >= `v0.1.1-alpha.1` 版本来使用该组件。
8
+
9
+ ### 引入
10
+
11
+ ```tsx
12
+ import { FloatingBubble } from "@fjyueke/bify-core"
13
+ ```
14
+
15
+ ## 代码演示
16
+
17
+ ### 基础用法
18
+
19
+ 浮动气泡默认展示在右下角,并允许在 y 轴方向上下拖拽,你可以通过 `icon` 属性设置气泡的图标。
20
+
21
+ ```tsx
22
+ function BasicFloatingBubble() {
23
+ const onClick = () => {
24
+ showToast({
25
+ title: "点击气泡",
26
+ icon: "none",
27
+ duration: 1000,
28
+ })
29
+ }
30
+
31
+ return <FloatingBubble icon={<ChatOutlined />} onClick={onClick} />
32
+ }
33
+ ```
34
+
35
+ ### 自由拖拽和磁吸
36
+
37
+ 允许 x 和 y 轴方向拖拽,吸附到 x 轴方向最近一边。
38
+
39
+ ```tsx
40
+ function CustomFloatingBubble() {
41
+ const onOffsetChange = (x: number, y: number) => {
42
+ showToast({
43
+ title: `x: ${x.toFixed(0)}, y: ${y.toFixed(0)}`,
44
+ icon: "none",
45
+ duration: 1000,
46
+ })
47
+ }
48
+
49
+ return (
50
+ <FloatingBubble
51
+ axis="xy"
52
+ magnetic="x"
53
+ icon={<ChatOutlined />}
54
+ onOffsetChange={onOffsetChange}
55
+ />
56
+ )
57
+ }
58
+ ```
59
+
60
+ ## API
61
+
62
+ ### Flex Props
63
+
64
+ | 参数 | 说明 | 类型 | 默认值 |
65
+ | -------- | ------------------------------------------------------- | ---------------------------- | ---------------- |
66
+ | offset | 控制气泡位置 | OffsetType | `默认右下角坐标` |
67
+ | axis | 拖拽的方向,`xy` 代表自由拖拽,`lock` 代表禁止拖拽 | _x_ \| _y_ \| _xy_ \| _lock_ | `y` |
68
+ | magnetic | 自动磁吸的方向 | _x_ \| _y_ | `-` |
69
+ | icon | 左侧[图标](/components/icon)或[图片](/components/image) | _ReactNode_ | `-` |
70
+ | gap | 气泡与窗口的最小间距,单位为 `px` | _Number_ | `48` |
71
+
72
+ ### Events
73
+
74
+ | 事件名 | 说明 | 回调参数 |
75
+ | -------------- | ---------------------------- | ---------------------- |
76
+ | onClick | 点击组件时触发 | _ITouchEvent_ |
77
+ | onOffsetChange | 由用户拖拽导致位置改变后触发 | _x: string, y: string_ |
78
+
79
+ ## 主题定制
80
+
81
+ ### 样式变量
82
+
83
+ 组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider](/components/config-provider/) 组件。
84
+
85
+ | 名称 | 默认值 | 描述 |
86
+ | ------------------------------- | ---------------------- | ---- |
87
+ | --floating-bubble-size | _96px_ | - |
88
+ | --floating-bubble-initial-gap | _48px_ | - |
89
+ | --floating-bubble-background | _var(--blue, $blue)_ | - |
90
+ | --floating-bubble-color | _var(--white, $white)_ | - |
91
+ | --floating-bubble-border-radius | _999px_ | - |
92
+ | --floating-bubble-z-index | _999_ | - |
93
+ | --floating-bubble-duratio | _0.3s_ | - |
94
+ | --floating-bubble-icon-size | _56px_ | - |
@@ -0,0 +1,55 @@
1
+ import { useState } from "react"
2
+ import { showToast } from "@tarojs/taro"
3
+ import { FloatingBubble, Tabs } from "@fjyueke/bify-core"
4
+ import { ChatOutlined } from "@fjyueke/bify-icons"
5
+ import Page from "../../../components/page"
6
+
7
+ import "./index.scss"
8
+
9
+ function BasicFloatingBubble() {
10
+ const onClick = () => {
11
+ showToast({
12
+ title: "点击气泡",
13
+ icon: "none",
14
+ duration: 1000,
15
+ })
16
+ }
17
+
18
+ return <FloatingBubble icon={<ChatOutlined />} onClick={onClick} />
19
+ }
20
+
21
+ function CustomFloatingBubble() {
22
+ const onOffsetChange = (x: number, y: number) => {
23
+ showToast({
24
+ title: `x: ${x.toFixed(0)}, y: ${y.toFixed(0)}`,
25
+ icon: "none",
26
+ duration: 1000,
27
+ })
28
+ }
29
+
30
+ return (
31
+ <FloatingBubble
32
+ axis="xy"
33
+ magnetic="x"
34
+ icon={<ChatOutlined />}
35
+ onOffsetChange={onOffsetChange}
36
+ />
37
+ )
38
+ }
39
+
40
+ export default function FloatingPanelDemo() {
41
+ const [value, setValue] = useState(0)
42
+
43
+ return (
44
+ <Page className="floating-bubble-demo" title="FloatingBubble 浮动气泡">
45
+ <Tabs value={value} onChange={setValue}>
46
+ <Tabs.TabPane title="基础用法">
47
+ <BasicFloatingBubble />
48
+ </Tabs.TabPane>
49
+ <Tabs.TabPane title="自由拖拽和磁吸">
50
+ <CustomFloatingBubble />
51
+ </Tabs.TabPane>
52
+ </Tabs>
53
+ </Page>
54
+ )
55
+ }
@@ -0,0 +1,19 @@
1
+ ## API
2
+
3
+ ### Flex Props
4
+
5
+ | 参数 | 说明 | 类型 | 默认值 |
6
+ | ------------------- | --------------------------------------- | ---------- | -------------------------------- |
7
+ | height | 当前面板的显示高度 | _number_ | `0` |
8
+ | anchors | 设置自定义锚点, 单位 `px` | _number[]_ | `[100, window.innerWidth * 0.6]` |
9
+ | duration | 动画时长,单位秒,设置为 0 可以禁用动画 | _number_ | `0.3` |
10
+ | contentDraggable | 允许拖拽内容容器 | _boolean_ | `true` |
11
+ | safeAreaInsetBottom | 是否开启底部安全区适配 | _boolean_ | `true` |
12
+
13
+ ### 方法
14
+
15
+ 通过 ref 可以获取到 FloatingPanel 实例并调用实例方法。
16
+
17
+ | 方法名 | 说明 | 参数 | 返回值 |
18
+ |---------|------------------------------------------|-----|-----|
19
+ | setHieght | 设置面板高度 | _number_ | - |
@@ -0,0 +1,174 @@
1
+ # FloatingPanel 浮动面板
2
+
3
+ ### 介绍
4
+
5
+ 浮动在页面底部的面板,可以上下拖动来浏览内容,常用于提供额外的功能或信息。
6
+
7
+ 请升级 `taroify` 到 >= `v0.1.0-alpha.3` 版本来使用该组件。
8
+
9
+ ### 引入
10
+
11
+ ```tsx
12
+ import { FloatingPanel } from "@fjyueke/bify-core"
13
+ ```
14
+
15
+ ## 代码演示
16
+
17
+ ### 基础用法
18
+
19
+ FloatingPanel 的默认高度为 `100px`,用户可以拖动来展开面板,使高度达到 `60%` 的屏幕高度。
20
+
21
+ ```tsx
22
+ <FloatingPanel>
23
+ <Cell.Group>
24
+ <Cell>1</Cell>
25
+ <Cell>2</Cell>
26
+ <Cell>3</Cell>
27
+ <Cell>4</Cell>
28
+ <Cell>5</Cell>
29
+ <Cell>6</Cell>
30
+ <Cell>7</Cell>
31
+ <Cell>8</Cell>
32
+ <Cell>9</Cell>
33
+ <Cell>10</Cell>
34
+ <Cell>11</Cell>
35
+ <Cell>12</Cell>
36
+ <Cell>13</Cell>
37
+ </Cell.Group>
38
+ </FloatingPanel>
39
+ ```
40
+
41
+ ### 自定义锚点
42
+
43
+ 你可以通过 `anchors` 属性来设置 FloatingPanel 的锚点位置,并通过 `height` 来控制当前面板的显示高度。
44
+ 比如,使面板的高度在 `100px`、40% 屏幕高度和 70% 屏幕高度三个位置停靠:
45
+
46
+ ```tsx
47
+ function CustomAnchors() {
48
+ const windowHeight = useMemo(() => getWindowInfo().windowHeight, [])
49
+
50
+ const anchors = useMemo(
51
+ () => [200, Math.round(0.4 * windowHeight), Math.round(0.7 * windowHeight)],
52
+ [windowHeight],
53
+ )
54
+
55
+ return (
56
+ <FloatingPanel anchors={anchors} height={anchors[0]}>
57
+ <Cell.Group>
58
+ <Cell>1</Cell>
59
+ <Cell>2</Cell>
60
+ <Cell>3</Cell>
61
+ <Cell>4</Cell>
62
+ <Cell>5</Cell>
63
+ <Cell>6</Cell>
64
+ <Cell>7</Cell>
65
+ <Cell>8</Cell>
66
+ <Cell>9</Cell>
67
+ <Cell>10</Cell>
68
+ <Cell>11</Cell>
69
+ <Cell>12</Cell>
70
+ <Cell>13</Cell>
71
+ </Cell.Group>
72
+ </FloatingPanel>
73
+ )
74
+ }
75
+ ```
76
+
77
+ ### 仅头部拖拽
78
+
79
+ 默认情况下,FloatingPanel 的头部区域和内容区域都可以被拖拽,你可以通过 `contentDraggable` 属性来禁用内容区域的拖拽。
80
+
81
+ ```tsx
82
+ function HeadDragOnly() {
83
+ return (
84
+ <FloatingPanel contentDraggable={false}>
85
+ <Cell.Group>
86
+ <Cell>1</Cell>
87
+ <Cell>2</Cell>
88
+ <Cell>3</Cell>
89
+ <Cell>4</Cell>
90
+ <Cell>5</Cell>
91
+ <Cell>6</Cell>
92
+ <Cell>7</Cell>
93
+ <Cell>8</Cell>
94
+ <Cell>9</Cell>
95
+ <Cell>10</Cell>
96
+ <Cell>11</Cell>
97
+ <Cell>12</Cell>
98
+ <Cell>13</Cell>
99
+ </Cell.Group>
100
+ </FloatingPanel>
101
+ )
102
+ }
103
+ ```
104
+
105
+ ### 手动设置高度
106
+
107
+ 通过 `ref` 可以获取到 FloatingPanel 的实例,调用 `setHeight` 方法可以手动设置 FloatingPanel 的高度。
108
+
109
+ ```tsx
110
+ function CustomHeight() {
111
+ const floatingPanelRef = useRef<any>()
112
+ const resetHeight = () => {
113
+ floatingPanelRef.current?.setHeight(100)
114
+ }
115
+
116
+ return (<>
117
+ <Button color="default" onClick={resetHeight}>重置高度</Button>
118
+ <FloatingPanel ref={floatingPanelRef}>
119
+ <Cell.Group>
120
+ <Cell>1</Cell>
121
+ <Cell>2</Cell>
122
+ <Cell>3</Cell>
123
+ <Cell>4</Cell>
124
+ <Cell>5</Cell>
125
+ <Cell>6</Cell>
126
+ <Cell>7</Cell>
127
+ <Cell>8</Cell>
128
+ <Cell>9</Cell>
129
+ <Cell>10</Cell>
130
+ <Cell>11</Cell>
131
+ <Cell>12</Cell>
132
+ <Cell>13</Cell>
133
+ </Cell.Group>
134
+ </FloatingPanel>
135
+ </>)
136
+ }
137
+ ```
138
+
139
+ ## API
140
+
141
+ ### Flex Props
142
+
143
+ | 参数 | 说明 | 类型 | 默认值 |
144
+ | ------------------- | --------------------------------------- | ---------- | -------------------------------- |
145
+ | height | 当前面板的显示高度 | _number_ | `0` |
146
+ | anchors | 设置自定义锚点, 单位 `px` | _number[]_ | `[100, window.innerWidth * 0.6]` |
147
+ | duration | 动画时长,单位秒,设置为 0 可以禁用动画 | _number_ | `0.3` |
148
+ | contentDraggable | 允许拖拽内容容器 | _boolean_ | `true` |
149
+ | safeAreaInsetBottom | 是否开启底部安全区适配 | _boolean_ | `true` |
150
+
151
+ ### 方法
152
+
153
+ 通过 ref 可以获取到 FloatingPanel 实例并调用实例方法。
154
+
155
+ | 方法名 | 说明 | 参数 | 返回值 |
156
+ |---------|------------------------------------------|-----|-----|
157
+ | setHieght | 设置面板高度 | _number_ | - |
158
+
159
+
160
+ ## 主题定制
161
+
162
+ ### 样式变量
163
+
164
+ 组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider](/components/config-provider/) 组件。
165
+
166
+ | 名称 | 默认值 | 描述 |
167
+ | -------------------------------------- | ------------------------------- | ---- |
168
+ | --floating-panel-z-index | _1010_ | - |
169
+ | --floating-panel-rounded-border-radius | _16px \* $hd_ | - |
170
+ | --floating-panel-header-height | _60px_ | - |
171
+ | --floating-panel-bar-height | _6px_ | - |
172
+ | --floating-panel-bar-width | _40px_ | - |
173
+ | --floating-panel-bar-color | _var(--gray-5, $gray-5)_ | - |
174
+ | --floating-panel-background | _var(--background-color-light)_ | - |
@@ -0,0 +1,131 @@
1
+ import { FloatingPanel, Cell, Tabs, Button } from "@fjyueke/bify-core"
2
+ import { useState, useMemo, useRef } from "react"
3
+ import { getWindowInfo } from "@tarojs/taro"
4
+ import Page from "../../../components/page"
5
+
6
+ import "./index.scss"
7
+
8
+ function BasicFloatingPanel() {
9
+ return (
10
+ <FloatingPanel>
11
+ <Cell.Group>
12
+ <Cell>1</Cell>
13
+ <Cell>2</Cell>
14
+ <Cell>3</Cell>
15
+ <Cell>4</Cell>
16
+ <Cell>5</Cell>
17
+ <Cell>6</Cell>
18
+ <Cell>7</Cell>
19
+ <Cell>8</Cell>
20
+ <Cell>9</Cell>
21
+ <Cell>10</Cell>
22
+ <Cell>11</Cell>
23
+ <Cell>12</Cell>
24
+ <Cell>13</Cell>
25
+ </Cell.Group>
26
+ </FloatingPanel>
27
+ )
28
+ }
29
+
30
+ function CustomAnchors() {
31
+ const windowHeight = useMemo(() => getWindowInfo().windowHeight, [])
32
+
33
+ const anchors = useMemo(
34
+ () => [200, Math.round(0.4 * windowHeight), Math.round(0.7 * windowHeight)],
35
+ [windowHeight],
36
+ )
37
+
38
+ return (
39
+ <FloatingPanel anchors={anchors} height={anchors[0]}>
40
+ <Cell.Group>
41
+ <Cell>1</Cell>
42
+ <Cell>2</Cell>
43
+ <Cell>3</Cell>
44
+ <Cell>4</Cell>
45
+ <Cell>5</Cell>
46
+ <Cell>6</Cell>
47
+ <Cell>7</Cell>
48
+ <Cell>8</Cell>
49
+ <Cell>9</Cell>
50
+ <Cell>10</Cell>
51
+ <Cell>11</Cell>
52
+ <Cell>12</Cell>
53
+ <Cell>13</Cell>
54
+ </Cell.Group>
55
+ </FloatingPanel>
56
+ )
57
+ }
58
+
59
+ function HeadDragOnly() {
60
+ return (
61
+ <FloatingPanel contentDraggable={false}>
62
+ <Cell.Group>
63
+ <Cell>1</Cell>
64
+ <Cell>2</Cell>
65
+ <Cell>3</Cell>
66
+ <Cell>4</Cell>
67
+ <Cell>5</Cell>
68
+ <Cell>6</Cell>
69
+ <Cell>7</Cell>
70
+ <Cell>8</Cell>
71
+ <Cell>9</Cell>
72
+ <Cell>10</Cell>
73
+ <Cell>11</Cell>
74
+ <Cell>12</Cell>
75
+ <Cell>13</Cell>
76
+ </Cell.Group>
77
+ </FloatingPanel>
78
+ )
79
+ }
80
+
81
+ function CustomHeight() {
82
+ const floatingPanelRef = useRef<any>()
83
+
84
+ const resetHeight = () => {
85
+ floatingPanelRef.current?.setHeight(100)
86
+ }
87
+
88
+ return (<>
89
+ <Button color="default" onClick={resetHeight}>重置高度</Button>
90
+ <FloatingPanel ref={floatingPanelRef}>
91
+ <Cell.Group>
92
+ <Cell>1</Cell>
93
+ <Cell>2</Cell>
94
+ <Cell>3</Cell>
95
+ <Cell>4</Cell>
96
+ <Cell>5</Cell>
97
+ <Cell>6</Cell>
98
+ <Cell>7</Cell>
99
+ <Cell>8</Cell>
100
+ <Cell>9</Cell>
101
+ <Cell>10</Cell>
102
+ <Cell>11</Cell>
103
+ <Cell>12</Cell>
104
+ <Cell>13</Cell>
105
+ </Cell.Group>
106
+ </FloatingPanel>
107
+ </>)
108
+ }
109
+
110
+ export default function FloatingPanelDemo() {
111
+ const [value, setValue] = useState(0)
112
+
113
+ return (
114
+ <Page className="floating-panel-demo" title="FloatingPanel 浮动面板">
115
+ <Tabs value={value} onChange={setValue}>
116
+ <Tabs.TabPane title="基础用法">
117
+ <BasicFloatingPanel />
118
+ </Tabs.TabPane>
119
+ <Tabs.TabPane title="自定义锚点">
120
+ <CustomAnchors />
121
+ </Tabs.TabPane>
122
+ <Tabs.TabPane title="仅头部拖拽">
123
+ <HeadDragOnly />
124
+ </Tabs.TabPane>
125
+ <Tabs.TabPane title="手动设置高度">
126
+ <CustomHeight />
127
+ </Tabs.TabPane>
128
+ </Tabs>
129
+ </Page>
130
+ )
131
+ }
@@ -0,0 +1,124 @@
1
+ ## API
2
+
3
+ ### Form Props
4
+
5
+ | 参数 | 说明 | 类型 | 默认值 |
6
+ | ----------------------------- | ----------------------------------------------------------- | --------- | -------- |
7
+ | defaultValues | 表单默认值 | _object_ | |
8
+ | labelAlign | 表单项 label 对齐方式,可选值为 `center` `right` | _string_ | `left` |
9
+ | controlAlign | 表单项 control 对齐方式,可选值为 `center` `right` | _string_ | `left` |
10
+ | validateTrigger | 表单校验触发时机,可选值为 `onChange`、`onSubmit`,详见下表 | _string_ | `onBlur` |
11
+ | colon | 是否在 label 后面添加冒号 | _boolean_ | `false` |
12
+ | disabled <br>`v0.3.1-alpha.0` | 是否禁用表单 | _boolean_ | `false` |
13
+
14
+ ### Form Events
15
+
16
+ | 事件名 | 说明 | 回调参数 |
17
+ | -------------- | -------------------------- | ----------------------------------------------------- |
18
+ | onSubmit | 提交表单且验证通过后触发 | _event: BaseEventOrig<FormProps.onSubmitEventDetail>_ |
19
+ | onReset | 重置表单后触发 | _event: BaseEventOrig_ |
20
+ | onValidate | 提交表单且验证不通过后触发 | _errors: { name: string, errors: string[] }[]_ |
21
+ | onValuesChange | 字段值更新后触发 | _changedValues: object, allValues: object_ |
22
+
23
+ ### Form Methods
24
+
25
+ 通过 ref 可以获取到 Form 实例并调用实例方法。
26
+
27
+ | 方法名 | 说明 | 参数 | 返回值 |
28
+ | --------------------------- | ------------------------------------------------------------ | --------------------------- | ------------------ |
29
+ | setValues | 设置表单值(浅合并) | _object_ | - |
30
+ | getValues | 获得表单值,支持传入 `name` 来获得单个或部分表单项 | _name?: string \| string[]_ | _object_ |
31
+ | setErrors | 设置表单验证错误信息(浅合并) | _FormValidError[]_ | _void_ |
32
+ | getErrors | 获得表单验证错误信息,支持传入 `name` 来获得单个或部分表单项 | _name?: string \| string[]_ | _FormValidError[]_ |
33
+ | validate | 验证表单,支持传入 `name` 来验证单个或部分表单项 | _name?: string \| string[]_ | _Promise_ |
34
+ | submit <br>`v0.3.1-alpha.0` | 提交表单,与点击提交按钮的效果等价 | - | - |
35
+ | reset | 重置表单 | - | _void_ |
36
+
37
+ ### validateTrigger 可选值
38
+
39
+ 通过 `validateTrigger` 属性可以自定义表单校验的触发时机。
40
+
41
+ | 值 | 描述 |
42
+ | -------- | ------------------------------------ |
43
+ | onSubmit | 仅在提交表单时触发校验 |
44
+ | onBlur | 在提交表单和输入框失焦时触发校验 |
45
+ | onChange | 在提交表单和输入框内容变化时触发校验 |
46
+
47
+ ### Form.Item Props
48
+
49
+ | 参数 | 说明 | 类型 | 默认值 |
50
+ | --------------------------------- | ------------------------------------ | --------------------------------------------- | ------- |
51
+ | name | 表单项名称,提交表单的标识符 | _string_ | - |
52
+ | defaultValue | 表单项默认值 | _any_ | - |
53
+ | required | 是否显示表单必填星号 | _boolean_ | `false` |
54
+ | rules | 表单校验规则 | _FormRule[]_ | - |
55
+ | dependencies <br>`v0.1.6-alpha.0` | 当依赖的字段值改变时,触发自身的校验 | _string[]_ | - |
56
+ | shouldUpdate <br>`v0.1.6-alpha.0` | 当值为 true 时,触发当前区域重新渲染 | _boolean\|(prevValues, curValues) => boolean_ | - |
57
+ | noStyle <br>`v0.1.6-alpha.0` | 直接渲染 children | boolean | - |
58
+
59
+ > 属性继承自 Cell 组件,更多属性参见:[Cell 组件](/components/cell/#cell-props)
60
+
61
+ ### Rule 数据结构
62
+
63
+ 使用 Form.Item 的 `rules` 属性可以定义校验规则,可选属性如下:
64
+
65
+ | 键名 | 说明 | 类型 |
66
+ | --- | --- | --- |
67
+ | required | 是否为必选字段,当值为空字符串、空数组、`undefined`、`null` 时,校验不通过 | _boolean_ |
68
+ | message | 错误提示文案 | _string \| (value, rule) => string_ |
69
+ | validator | 通过函数进行校验 | _(value, rule) => boolean \| string \| Promise_ |
70
+ | validateFirst `v0.5.0-alpha.0` | 当某一规则校验不通过时,是否停止剩下的规则的校验。 | _boolean_ | `false` |
71
+ | pattern | 通过正则表达式进行校验 | _RegExp_ |
72
+ | trigger | 本项规则的触发时机,可选值为 `onChange`、`onBlur` | _string_ |
73
+ | formatter | 格式化函数,将表单项的值转换后进行校验 | _(value, rule) => any_ |
74
+
75
+ ### Form.Label Props
76
+
77
+ | 参数 | 说明 | 类型 | 默认值 |
78
+ | ----- | ----------------------------------- | --------- | ------- |
79
+ | align | 对齐方式,可选值为 `center` `right` | _string_ | `left` |
80
+ | colon | 是否在 label 后面添加冒号 | _boolean_ | `false` |
81
+
82
+ ### Form.Feedback Props
83
+
84
+ | 参数 | 说明 | 类型 | 默认值 |
85
+ | ------ | ---------------------------------------------- | -------- | ------ |
86
+ | align | 对齐方式,可选值为 `center` `right` | _string_ | `left` |
87
+ | status | 反馈状态,可选值为 `valid` `warning` `invalid` | _string_ | - |
88
+
89
+ ### Form.Control Props
90
+
91
+ | 参数 | 说明 | 类型 | 默认值 |
92
+ | -------- | ----------------------------------- | ----------------------------------------------------------- | ------ |
93
+ | align | 对齐方式,可选值为 `center` `right` | _string_ | `left` |
94
+ | children | 内容 | _ReactNode\|((controller: FormController<V>) => ReactNode)_ | -- |
95
+
96
+ ```tsx
97
+ interface FormController<V> {
98
+ value?: V // 当前表单项值
99
+ validateStatus?: FormValidateStatus // 当前表单项验证状态
100
+ disabled?: boolean // 当前表单项是否禁用
101
+
102
+ onChange?(value: V): void // 改变当前表单项值
103
+
104
+ onBlur?(value: V): void // 触发onBlur当前表单项校验
105
+ }
106
+ ```
107
+
108
+ > Tips: 使用 onBlur 触发表单验证,自定义表单项时,要手动调用 onBlur,才能触发校验
109
+
110
+ ### Form.List
111
+
112
+ | 参数 | 说明 | 类型 |
113
+ | ------------ | ---------------------------- | ------------------------------------------------------------------------------------ | --- |
114
+ | children | 渲染函数 | _(fields: { key: string, name: string }[], operation: { add, remove }) => ReactNode_ | \_ |
115
+ | name | 表单项名称,提交表单的标识符 | _string_ |
116
+ | defaultValue | 表单项默认值 | _any_ |
117
+
118
+ ### 类型定义
119
+
120
+ 通过`@fjyueke/bify-core/form`导入组件类型:
121
+
122
+ ```tsx
123
+ import { FormRule, FormItemInstance, FormListInstance, FormInstance } from "@fjyueke/bify-core/form"
124
+ ```