@doubao-apps/ai 0.0.35-rc.0 → 0.0.35

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 (118) hide show
  1. package/README.md +2 -0
  2. package/dist/cli.js +1 -1
  3. package/dist/index.d.ts +4 -1
  4. package/dist/index.js +33 -1
  5. package/dist/{manifest.json → public/manifest.json} +7 -2
  6. package/dist/{skills → public/skills}/doubao-apps-dev/SKILL.md +11 -10
  7. package/dist/{skills → public/skills}/doubao-apps-dev/references/examples/common-patterns.md +2 -2
  8. package/dist/{skills/doubao-apps-dev/references/examples/component-basics.md → public/skills/doubao-apps-dev/references/examples/page-widget-basics.md} +1 -1
  9. package/dist/{skills/doubao-apps-dev/references/examples/component-recipes.md → public/skills/doubao-apps-dev/references/examples/page-widget-recipes.md} +2 -3
  10. package/dist/{skills → public/skills}/doubao-apps-dev/references/guides/component-development.md +2 -2
  11. package/dist/public/skills/doubao-apps-dev/references/reference/open-api/01-/345/237/272/347/241/200.md +270 -0
  12. package/dist/public/skills/doubao-apps-dev/references/reference/open-api/02-/347/263/273/347/273/237.md +438 -0
  13. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/03-/345/256/232/344/275/215.md +32 -55
  14. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/04-/345/255/230/345/202/250.md +18 -0
  15. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/05-/350/267/257/347/224/261.md +8 -0
  16. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/06-/344/272/244/344/272/222.md +49 -3
  17. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/07-/350/276/223/345/205/245.md +47 -0
  18. package/dist/public/skills/doubao-apps-dev/references/reference/open-api/08-/347/275/221/347/273/234.md +238 -0
  19. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/09-/345/252/222/344/275/223.md +81 -1
  20. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/10-/344/270/232/345/212/241/350/203/275/345/212/233.md +143 -13
  21. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/11-/347/231/273/345/275/225.md +11 -0
  22. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/14-/350/223/235/347/211/231.md +212 -1
  23. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/15-wi-fi.md +104 -27
  24. package/dist/public/skills/doubao-apps-dev/references/reference/open-api/16-/345/212/240/351/200/237/345/272/246/350/256/241.md +122 -0
  25. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/17-ibeacon.md +38 -0
  26. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/18-/347/275/227/347/233/230.md +45 -22
  27. package/dist/public/skills/doubao-apps-dev/references/reference/open-api/19-/350/256/276/345/244/207/346/226/271/345/220/221.md +120 -0
  28. package/dist/public/skills/doubao-apps-dev/references/reference/open-api/20-/351/231/200/350/236/272/344/273/252.md +122 -0
  29. package/dist/public/skills/doubao-apps-dev/references/reference/open-api/21-/350/256/276/345/244/207-/347/275/221/347/273/234.md +153 -0
  30. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/23-/346/227/240/351/232/234/347/242/215.md +11 -0
  31. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/24-/345/237/272/347/241/200/344/277/241/346/201/257.md +19 -0
  32. package/dist/public/skills/doubao-apps-dev/references/reference/open-api/25-/347/224/265/346/261/240.md +92 -0
  33. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/26-/346/227/245/345/216/206.md +11 -0
  34. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/27-/345/211/252/350/264/264/346/235/277.md +11 -0
  35. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/28-/350/201/224/347/263/273/344/272/272.md +13 -0
  36. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/29-/345/212/240/345/257/206.md +11 -0
  37. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/31-/346/211/253/347/240/201.md +51 -0
  38. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/32-/345/261/217/345/271/225.md +60 -20
  39. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/33-/351/234/207/345/212/250.md +11 -0
  40. package/dist/public/skills/doubao-apps-dev/references/reference/open-api/34-/346/226/207/344/273/266/347/263/273/347/273/237.md +334 -0
  41. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/README.md +4 -4
  42. package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api.md +14 -12
  43. package/dist/public/skills/doubao-components-api/SKILL.md +50 -0
  44. package/dist/public/skills/doubao-components-api/references/reference/form.md +146 -0
  45. package/dist/public/skills/doubao-components-api/references/reference/interactive.md +120 -0
  46. package/dist/public/skills/doubao-components-api/references/reference/layout-overlay.md +131 -0
  47. package/dist/public/skills/doubao-components-api/references/reference/layout-scroll.md +149 -0
  48. package/dist/public/skills/doubao-components-api/references/reference/map-canvas.md +107 -0
  49. package/dist/public/skills/doubao-components-api/references/reference/media.md +195 -0
  50. package/dist/{skills → public/skills}/douyin-to-doubao/SKILL.md +1 -1
  51. package/dist/{skills → public/skills}/h5-to-doubao/SKILL.md +2 -2
  52. package/dist/{skills → public/skills}/quality-gate/scripts/collect-doubao-page-data.js +3 -3
  53. package/dist/{skills → public/skills}/uniapp-to-doubao/SKILL.md +1 -1
  54. package/dist/{skills → public/skills}/weixin-to-doubao/SKILL.md +1 -1
  55. package/package.json +5 -5
  56. package/dist/733.js +0 -33
  57. package/dist/skills/doubao-apps-dev/references/reference/components-quick-ref.md +0 -114
  58. package/dist/skills/doubao-apps-dev/references/reference/open-api/01-/345/237/272/347/241/200.md +0 -136
  59. package/dist/skills/doubao-apps-dev/references/reference/open-api/02-/347/263/273/347/273/237.md +0 -257
  60. package/dist/skills/doubao-apps-dev/references/reference/open-api/08-/347/275/221/347/273/234.md +0 -124
  61. package/dist/skills/doubao-apps-dev/references/reference/open-api/16-/345/212/240/351/200/237/345/272/246/350/256/241.md +0 -87
  62. package/dist/skills/doubao-apps-dev/references/reference/open-api/19-/350/256/276/345/244/207/346/226/271/345/220/221.md +0 -86
  63. package/dist/skills/doubao-apps-dev/references/reference/open-api/20-/351/231/200/350/236/272/344/273/252.md +0 -87
  64. package/dist/skills/doubao-apps-dev/references/reference/open-api/21-/350/256/276/345/244/207-/347/275/221/347/273/234.md +0 -102
  65. package/dist/skills/doubao-apps-dev/references/reference/open-api/25-/347/224/265/346/261/240.md +0 -63
  66. package/dist/skills/doubao-apps-dev/references/reference/open-api/34-/346/226/207/344/273/266/347/263/273/347/273/237.md +0 -73
  67. /package/dist/{skills → public/skills}/doubao-apps-dev/references/examples/open-api-recipes.md +0 -0
  68. /package/dist/{skills → public/skills}/doubao-apps-dev/references/guides/best-practices.md +0 -0
  69. /package/dist/{skills → public/skills}/doubao-apps-dev/references/guides/expired-widget.md +0 -0
  70. /package/dist/{skills → public/skills}/doubao-apps-dev/references/guides/mcp-ui.md +0 -0
  71. /package/dist/{skills → public/skills}/doubao-apps-dev/references/guides/performance-optimization.md +0 -0
  72. /package/dist/{skills → public/skills}/doubao-apps-dev/references/guides/troubleshooting.md +0 -0
  73. /package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/framework-api-quick-ref.md +0 -0
  74. /package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/12-/346/224/257/344/273/230.md" +0 -0
  75. /package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/13-/346/225/260/346/215/256/345/210/206/346/236/220.md" +0 -0
  76. /package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/22-/347/237/255/344/277/241.md" +0 -0
  77. /package/dist/{skills → public/skills}/doubao-apps-dev/references/reference/open-api/30-/347/224/265/350/257/235.md" +0 -0
  78. /package/dist/{skills → public/skills}/doubao-apps-dev/references/rules/dos-and-donts.md +0 -0
  79. /package/dist/{skills → public/skills}/douyin-to-doubao/assets/migration-checklist-template.md +0 -0
  80. /package/dist/{skills → public/skills}/douyin-to-doubao/references/mapping/component-mapping.md +0 -0
  81. /package/dist/{skills → public/skills}/douyin-to-doubao/references/mapping/core-api-mapping.md +0 -0
  82. /package/dist/{skills → public/skills}/douyin-to-doubao/references/mapping/event-mapping.md +0 -0
  83. /package/dist/{skills → public/skills}/douyin-to-doubao/references/mapping/lifecycle-mapping.md +0 -0
  84. /package/dist/{skills → public/skills}/douyin-to-doubao/references/mapping/style-mapping.md +0 -0
  85. /package/dist/{skills → public/skills}/douyin-to-doubao/references/source-framework/api-reference.md +0 -0
  86. /package/dist/{skills → public/skills}/douyin-to-doubao/references/source-framework/components.md +0 -0
  87. /package/dist/{skills → public/skills}/h5-to-doubao/references/common/troubleshooting.md +0 -0
  88. /package/dist/{skills → public/skills}/h5-to-doubao/references/source-framework/react-to-doubao.md +0 -0
  89. /package/dist/{skills → public/skills}/h5-to-doubao/references/source-framework/vue-to-doubao.md +0 -0
  90. /package/dist/{skills → public/skills}/quality-gate/SKILL.md +0 -0
  91. /package/dist/{skills → public/skills}/quality-gate/gates/bronze.md +0 -0
  92. /package/dist/{skills → public/skills}/quality-gate/gates/gold-phase1.md +0 -0
  93. /package/dist/{skills → public/skills}/quality-gate/gates/gold-phase2.md +0 -0
  94. /package/dist/{skills → public/skills}/quality-gate/gates/gold-phase3.md +0 -0
  95. /package/dist/{skills → public/skills}/quality-gate/gates/silver.md +0 -0
  96. /package/dist/{skills → public/skills}/quality-gate/runtime-fix.md +0 -0
  97. /package/dist/{skills → public/skills}/quality-gate/screenshots/doubao-faq.md +0 -0
  98. /package/dist/{skills → public/skills}/quality-gate/screenshots/doubao.md +0 -0
  99. /package/dist/{skills → public/skills}/quality-gate/screenshots/h5-react.md +0 -0
  100. /package/dist/{skills → public/skills}/quality-gate/screenshots/weixin.md +0 -0
  101. /package/dist/{skills → public/skills}/quality-gate/scripts/phase2-normalized-compare.py +0 -0
  102. /package/dist/{skills → public/skills}/quality-gate/scripts/run-doubao-screenshots.sh +0 -0
  103. /package/dist/{skills → public/skills}/uniapp-to-doubao/assets/migration-checklist-template.md +0 -0
  104. /package/dist/{skills → public/skills}/uniapp-to-doubao/references/mapping/component-mapping.md +0 -0
  105. /package/dist/{skills → public/skills}/uniapp-to-doubao/references/mapping/core-api-mapping.md +0 -0
  106. /package/dist/{skills → public/skills}/uniapp-to-doubao/references/mapping/event-mapping.md +0 -0
  107. /package/dist/{skills → public/skills}/uniapp-to-doubao/references/mapping/lifecycle-mapping.md +0 -0
  108. /package/dist/{skills → public/skills}/uniapp-to-doubao/references/mapping/style-mapping.md +0 -0
  109. /package/dist/{skills → public/skills}/uniapp-to-doubao/references/source-framework/api-reference.md +0 -0
  110. /package/dist/{skills → public/skills}/uniapp-to-doubao/references/source-framework/components.md +0 -0
  111. /package/dist/{skills → public/skills}/weixin-to-doubao/assets/migration-checklist-template.md +0 -0
  112. /package/dist/{skills → public/skills}/weixin-to-doubao/references/mapping/component-mapping.md +0 -0
  113. /package/dist/{skills → public/skills}/weixin-to-doubao/references/mapping/core-api-mapping.md +0 -0
  114. /package/dist/{skills → public/skills}/weixin-to-doubao/references/mapping/event-mapping.md +0 -0
  115. /package/dist/{skills → public/skills}/weixin-to-doubao/references/mapping/lifecycle-mapping.md +0 -0
  116. /package/dist/{skills → public/skills}/weixin-to-doubao/references/mapping/style-mapping.md +0 -0
  117. /package/dist/{skills → public/skills}/weixin-to-doubao/references/source-framework/api-reference.md +0 -0
  118. /package/dist/{skills → public/skills}/weixin-to-doubao/references/source-framework/components.md +0 -0
@@ -0,0 +1,146 @@
1
+ # 表单组件
2
+
3
+ ## `<input>`
4
+
5
+ | 属性 | 类型 | 默认值 | 说明 |
6
+ |------|------|--------|------|
7
+ | ref | Ref\<InputRef\> | - | 实例 ref |
8
+ | value | string | - | 受控值 |
9
+ | defaultValue | string | - | 非受控默认值 |
10
+ | placeholder | string | - | 占位文本 |
11
+ | type | `'text' \| 'number' \| 'digit' \| 'password' \| 'tel' \| 'email'` | `'text'` | 输入类型 |
12
+ | maxlength | number | 140 | 最大长度 |
13
+ | disabled | boolean | false | 禁用 |
14
+ | readonly | boolean | false | 只读 |
15
+ | confirmType | `'send' \| 'search' \| 'go' \| 'done' \| 'next'` | `'send'` | 键盘确认按钮类型 |
16
+ | showSoftInputOnFocus | boolean | true | 聚焦时是否显示软键盘 |
17
+ | onInput | (e: BaseEvent\<'bindinput', InputInputEvent\>) => void | - | 输入变化,取值 `e.detail.value` |
18
+ | onFocus | (e: BaseEvent\<'bindfocus', InputFocusEvent\>) => void | - | 聚焦 |
19
+ | onBlur | (e: BaseEvent\<'bindblur', InputBlurEvent\>) => void | - | 失焦 |
20
+ | onConfirm | (e: BaseEvent\<'bindconfirm', InputConfirmEvent\>) => void | - | 点击确认按钮 |
21
+ | className | string | - | 样式类名 |
22
+ | style | CSSProperties | - | 内联样式 |
23
+
24
+ ### InputRef 方法
25
+
26
+ | 方法 | 类型 | 说明 |
27
+ |------|------|------|
28
+ | setValue | (value: string) => Promise\<void\> | 设置值 |
29
+ | getValue | () => Promise\<{ value: string; selectionStart: number; selectionEnd: number }\> | 获取值和选区 |
30
+ | focus | () => Promise\<void\> | 聚焦 |
31
+ | blur | () => Promise\<void\> | 失焦 |
32
+
33
+ ```tsx
34
+ import type { InputRef } from '@doubao-apps/framework/components';
35
+ import { useState, useRef } from '@byted-lynx/react';
36
+
37
+ // 受控
38
+ const [val, setVal] = useState('');
39
+ <input value={val} onInput={(e) => setVal(e.detail.value)} placeholder="请输入" />
40
+
41
+ // 通过 ref 控制
42
+ const inputRef = useRef<InputRef>(null);
43
+ <input ref={inputRef} placeholder="请输入" />
44
+ <button onClick={() => inputRef.current?.focus()}>聚焦</button>
45
+
46
+ // 密码输入
47
+ <input type="password" maxlength={20} placeholder="请输入密码" />
48
+ ```
49
+
50
+ ---
51
+
52
+ ## `<textarea>`
53
+
54
+ | 属性 | 类型 | 默认值 | 说明 |
55
+ |------|------|--------|------|
56
+ | placeholder | string | - | 占位文本 |
57
+ | maxlength | number | 140 | 最大长度 |
58
+ | maxlines | number | - | 最大行数 |
59
+ | lineSpacing | number \| `${number}px` \| `${number}rpx` | - | 行间距 |
60
+ | disabled | boolean | false | 禁用 |
61
+ | readonly | boolean | false | 只读 |
62
+ | confirmType | `'send' \| 'search' \| 'go' \| 'done' \| 'next'` | `'done'` | 确认按钮类型 |
63
+ | showSoftInputOnFocus | boolean | true | 聚焦时显示软键盘 |
64
+ | bounces | boolean | true | iOS 弹性效果 |
65
+ | onInput | (e: TextAreaInputEvent) => void | - | 输入变化 |
66
+ | onFocus | (e: TextAreaFocusEvent) => void | - | 聚焦 |
67
+ | onBlur | (e: TextAreaBlurEvent) => void | - | 失焦 |
68
+ | onConfirm | (e: TextAreaConfirmEvent) => void | - | 点击确认按钮 |
69
+ | className | string | - | 样式类名 |
70
+ | style | CSSProperties | - | 内联样式 |
71
+
72
+ ```tsx
73
+ <textarea
74
+ placeholder="请输入内容"
75
+ maxlength={500}
76
+ maxlines={5}
77
+ onInput={(e) => console.log(e.detail.value)}
78
+ />
79
+ ```
80
+
81
+ ---
82
+
83
+ ## `<picker-view>` / `<picker-column>` / `<picker-divider>`
84
+
85
+ 嵌入页面的滚动选择器。
86
+
87
+ **关键约束:**
88
+ - `picker-view` 高度必须用 **inline `style.height`** 传入,不能只写在 CSS class 中,否则内部 JS 无法同步读取高度,offset 回退为 108px
89
+ - `itemHeight` 要与 `style.height` 配合设置
90
+
91
+ ### picker-view 属性
92
+
93
+ | 属性 | 类型 | 默认值 | 说明 |
94
+ |------|------|--------|------|
95
+ | style | CSSProperties | - | **height 必须 inline 传入** |
96
+ | itemHeight | number | 36 | 单个选项高度 (px) |
97
+ | theme | `'light' \| 'dark'` | - | 未传时跟随宿主主题 |
98
+ | onChange | (values: (string \| number)[], options: PickerColumnOption[]) => void | - | 所有列选中项变化 |
99
+ | className | string | - | 样式类名 |
100
+
101
+ ### picker-column 属性
102
+
103
+ | 属性 | 类型 | 说明 |
104
+ |------|------|------|
105
+ | options | `{ label: string; value: string \| number; disabled?: boolean }[]` | 列数据 |
106
+ | value | string \| number | 受控当前值 |
107
+ | defaultValue | string \| number | 非受控默认值 |
108
+ | onChange | (value: string \| number, option: PickerColumnOption) => void | 当前列变化 |
109
+ | className | string | 列的类名 |
110
+ | style | CSSProperties | 列的样式 |
111
+
112
+ ### picker-divider 属性
113
+
114
+ | 属性 | 类型 | 说明 |
115
+ |------|------|------|
116
+ | text | string | 展示文本 |
117
+ | children | ReactNode | 自定义内容,优先级高于 text |
118
+ | className | string | 类名 |
119
+ | style | CSSProperties | 样式 |
120
+
121
+ `picker-divider` 不参与值计算,不会出现在 `onChange` 的 values/options 中。
122
+
123
+ ```tsx
124
+ const hours = Array.from({ length: 24 }, (_, i) => ({ label: String(i).padStart(2, '0'), value: i }));
125
+ const minutes = ['00', '15', '30', '45'].map(v => ({ label: v, value: v }));
126
+
127
+ // 时间选择器(带分隔符)
128
+ <picker-view
129
+ style={{ height: '216px' }}
130
+ itemHeight={36}
131
+ onChange={(values) => console.log('选中:', values)}
132
+ >
133
+ <picker-column options={hours} defaultValue={10} />
134
+ <picker-divider text=":" />
135
+ <picker-column options={minutes} defaultValue="00" />
136
+ </picker-view>
137
+
138
+ // 年月日选择器
139
+ const years = Array.from({ length: 10 }, (_, i) => ({ label: `${2020 + i}年`, value: 2020 + i }));
140
+ const months = Array.from({ length: 12 }, (_, i) => ({ label: `${i + 1}月`, value: i + 1 }));
141
+
142
+ <picker-view style={{ height: '216px' }} itemHeight={36}>
143
+ <picker-column options={years} defaultValue={2024} />
144
+ <picker-column options={months} defaultValue={1} />
145
+ </picker-view>
146
+ ```
@@ -0,0 +1,120 @@
1
+ # 交互控件组件
2
+
3
+ ## `<button>`
4
+
5
+ | 属性 | 类型 | 默认值 | 说明 |
6
+ |------|------|--------|------|
7
+ | text | string | - | 按钮文字 |
8
+ | type | `'primary' \| 'default' \| 'plain'` | `'primary'` | 样式类型 |
9
+ | size | `'default' \| 'large' \| 'mini'` | `'default'` | 尺寸 |
10
+ | disabled | boolean | false | 禁用 |
11
+ | loading | boolean | false | 加载中状态 |
12
+ | icon | ReactNode | - | 文字前的图标 |
13
+ | children | ReactNode | - | 自定义内容,优先级高于 icon/text |
14
+ | throttle | number | 500 | onClick 节流时间 (ms) |
15
+ | onClick | (e?: TouchEvent) => void | - | 点击回调 |
16
+ | onDisabledClick | (e?: TouchEvent) => void | - | 禁用状态下点击回调 |
17
+ | openType | `'getPhoneNumber' \| 'agreePrivacyAuthorization' \| 'agreePrivacyAuthorization\|getPhoneNumber'` | - | 开放能力 |
18
+ | onGetPhoneNumber | (e: GetPhoneNumberResult) => void | - | 获取手机号回调,openType 包含 getPhoneNumber 时有效 |
19
+ | onAgreePrivacyAuthorization | (e: AgreePrivacyResult) => void | - | 隐私授权回调,openType 包含 agreePrivacyAuthorization 时有效 |
20
+ | className | string | - | 样式类名 |
21
+ | style | CSSProperties | - | 内联样式 |
22
+
23
+ ```tsx
24
+ // 基础按钮
25
+ <button text="提交" type="primary" onClick={() => handleSubmit()} />
26
+
27
+ // 加载状态
28
+ <button text="加载中" loading />
29
+
30
+ // 自定义内容
31
+ <button>
32
+ <image src="icon.png" style={{ width: '16px', height: '16px' }} />
33
+ <text>自定义按钮</text>
34
+ </button>
35
+
36
+ // 开放能力:获取手机号
37
+ <button
38
+ openType="getPhoneNumber"
39
+ onGetPhoneNumber={(e) => console.log(e)}
40
+ />
41
+ ```
42
+
43
+ ---
44
+
45
+ ## `<switch>`
46
+
47
+ | 属性 | 类型 | 默认值 | 说明 |
48
+ |------|------|--------|------|
49
+ | checked | boolean | - | 受控值;设置后 defaultChecked 被忽略 |
50
+ | defaultChecked | boolean | false | 非受控默认值 |
51
+ | disabled | boolean | false | 禁用 |
52
+ | size | `'default' \| 'large'` | `'large'` | 尺寸 |
53
+ | onChange | (checked: boolean) => void | - | 状态变化,直接接收 boolean,不是事件对象 |
54
+ | className | string | - | 样式类名 |
55
+ | style | CSSProperties | - | 内联样式 |
56
+
57
+ ```tsx
58
+ // 非受控
59
+ <switch defaultChecked onChange={(checked) => console.log(checked)} />
60
+
61
+ // 受控
62
+ const [on, setOn] = useState(false);
63
+ <switch checked={on} onChange={setOn} />
64
+ ```
65
+
66
+ ---
67
+
68
+ ## `<slider>`
69
+
70
+ **仅支持受控用法,必须传 `value`。**
71
+
72
+ | 属性 | 类型 | 默认值 | 说明 |
73
+ |------|------|--------|------|
74
+ | value | number | - | **必填**,当前值 |
75
+ | min | number | 0 | 最小值 |
76
+ | max | number | 100 | 最大值 |
77
+ | showValue | boolean | true | 是否显示当前数值 |
78
+ | disabled | boolean | false | 禁用 |
79
+ | onChange | (value: number) => void | - | 数值变化,直接接收 number |
80
+ | className | string | - | 样式类名 |
81
+ | style | CSSProperties | - | 内联样式 |
82
+
83
+ ```tsx
84
+ const [volume, setVolume] = useState(50);
85
+ <slider value={volume} min={0} max={100} onChange={setVolume} />
86
+ ```
87
+
88
+ ---
89
+
90
+ ## `<radio-group>` / `<radio>`
91
+
92
+ ```tsx
93
+ const [selected, setSelected] = useState('a');
94
+
95
+ <radio-group value={selected} onChange={(v) => setSelected(v)}>
96
+ <radio value="a">选项 A</radio>
97
+ <radio value="b">选项 B</radio>
98
+ <radio value="c" disabled>选项 C(禁用)</radio>
99
+ </radio-group>
100
+ ```
101
+
102
+ ### radio-group 属性
103
+
104
+ | 属性 | 类型 | 说明 |
105
+ |------|------|------|
106
+ | value | string \| number | 当前选中值(受控) |
107
+ | defaultValue | string \| number | 默认值(非受控) |
108
+ | onChange | (value: string \| number) => void | 选中变化回调 |
109
+ | className | string | 样式类名 |
110
+ | style | CSSProperties | 内联样式 |
111
+
112
+ ### radio 属性
113
+
114
+ | 属性 | 类型 | 说明 |
115
+ |------|------|------|
116
+ | value | string \| number | 该项的值 |
117
+ | disabled | boolean | 禁用 |
118
+ | children | ReactNode | 标签内容 |
119
+ | className | string | 样式类名 |
120
+ | style | CSSProperties | 内联样式 |
@@ -0,0 +1,131 @@
1
+ # 容器与覆层组件
2
+
3
+ ## `<view>`
4
+
5
+ 基础布局容器,最常用。
6
+
7
+ | 属性 | 类型 | 默认值 | 说明 |
8
+ |------|------|--------|------|
9
+ | className | string | - | 样式类名 |
10
+ | style | CSSProperties | - | 内联样式 |
11
+ | flatten | boolean | true | 扁平化节点,避免创建真实渲染对象,提升性能 |
12
+ | onClick | (e: TouchEvent) => void | - | 点击 |
13
+ | onLongPress | (e: TouchEvent) => void | - | 长按 |
14
+ | onTouchStart / onTouchEnd / onTouchMove | (e: TouchEvent) => void | - | 触摸事件 |
15
+ | onAppear | (e: UIAppearanceEvent) => void | - | 进入可视区域 |
16
+ | onDisappear | (e: UIAppearanceEvent) => void | - | 离开可视区域 |
17
+
18
+ ---
19
+
20
+ ## `<popup>`
21
+
22
+ 支持拖拽、多位置停靠的弹窗。
23
+
24
+ ```tsx
25
+ import type { PopupRef } from '@doubao-apps/framework/components';
26
+ import { useRef } from '@doubao-apps/framework';
27
+
28
+ const popupRef = useRef<PopupRef>(null);
29
+
30
+ // 打开弹窗
31
+ popupRef.current?.open(); // 默认中心
32
+ popupRef.current?.open(1); // 顶部
33
+ popupRef.current?.open(-1); // 底部
34
+ popupRef.current?.close();
35
+
36
+ <popup
37
+ ref={popupRef}
38
+ scrollContainerId="popup-scroll"
39
+ maxHeight={lynx.__globalProps.screenHeight}
40
+ closeOnMaskClick
41
+ enableDrag
42
+ onPopupPositionChange={(pos) => {
43
+ // 0=中心, 1=顶部, -1=底部, 4=关闭
44
+ }}
45
+ >
46
+ {({ 'main-thread:gesture': gesture }) => (
47
+ <view id="popup-scroll" style={{ height: '100%' }}>
48
+ <text>弹窗内容</text>
49
+ </view>
50
+ )}
51
+ </popup>
52
+ ```
53
+
54
+ ### PopupRef 方法
55
+
56
+ | 方法 | 参数 | 说明 |
57
+ |------|------|------|
58
+ | open | position?: 0 \| 1 \| -1 | 打开弹窗。0 中心 / 1 顶部 / -1 底部,默认中心 |
59
+ | close | - | 关闭弹窗 |
60
+ | translateTo | position: number \| string | 移动到指定位置,支持数字或 "px" / "%" / "rpx" |
61
+
62
+ ### PopupProps
63
+
64
+ | 属性 | 类型 | 默认值 | 说明 |
65
+ |------|------|--------|------|
66
+ | scrollContainerId | string | - | **必填**,内部滚动容器 ID |
67
+ | children | (prop: RenderFunction) => ReactElement | - | 渲染函数 |
68
+ | autoHeight | boolean | false | 根据内容高度自动调整 |
69
+ | contentId | string | - | autoHeight 为 true 时需要设置 |
70
+ | enableDrag | boolean | true | 启用拖拽 |
71
+ | enableBounces | boolean | true | 松手回弹 |
72
+ | closeOnMaskClick | boolean | true | 点击遮罩关闭 |
73
+ | maxHeight | number | screenHeight | 最大高度 |
74
+ | heightPercent | HeightPercent | - | `{ init, top, bottom, boundaryArea, flingThreshold }` |
75
+ | bottomNode | ReactElement | - | 固定在弹窗底部的节点,不受拖动影响 |
76
+ | enterDuration / exitDuration | number | 300 | 进入/退出动画时长 (ms) |
77
+ | onPopupPositionChange | (position: number) => void | - | 位置变化回调 |
78
+ | onPopupTopChange | (height: number) => void | - | 高度变化回调 |
79
+
80
+ ---
81
+
82
+ ## `<movable-area>` / `<movable-view>`
83
+
84
+ ```tsx
85
+ <movable-area style={{ width: '100%', height: '300px' }}>
86
+ <movable-view direction="all" scale outOfBounds inertia friction={2} damping={20}>
87
+ <text>拖我 / 双指缩放</text>
88
+ </movable-view>
89
+ </movable-area>
90
+ ```
91
+
92
+ ### movable-view 属性
93
+
94
+ | 属性 | 类型 | 默认值 | 说明 |
95
+ |------|------|--------|------|
96
+ | direction | `'all' \| 'vertical' \| 'horizontal' \| 'none'` | `'all'` | 移动方向 |
97
+ | disabled | boolean | false | 禁用 |
98
+ | x / y | number | 0 | 初始偏移 |
99
+ | scale | boolean | false | 双指缩放 |
100
+ | scaleValue | number | 1 | 初始缩放值 |
101
+ | scaleMin / scaleMax | number | 0.5 / 10 | 缩放范围 |
102
+ | outOfBounds | boolean | false | 允许超出区域(松手回弹) |
103
+ | animation | boolean | true | 回弹动画 |
104
+ | damping | number | 20 | 阻尼系数,值越大回弹越快 |
105
+ | inertia | boolean | false | 惯性滑动 |
106
+ | friction | number | 2 | 摩擦系数,值越大越快停止(必须 > 0) |
107
+ | onDrag | (x: number, y: number) => void | - | 拖拽回调 |
108
+ | onScale | (scale: number) => void | - | 缩放回调 |
109
+
110
+ ---
111
+
112
+ ## `<theme-provider>`
113
+
114
+ 让子树消费 `--bg-*` / `--neutral-*` / `--primary-*` 等 CSS 变量时跟随宿主主题(light/dark)。
115
+
116
+ 内置组件会自动应用主题,只在业务自定义内容需要主题变量时才需要包裹。
117
+
118
+ ```tsx
119
+ <theme-provider>
120
+ <view style={{ background: 'var(--bg-1)' }}>
121
+ <text style={{ color: 'var(--neutral-text-1)' }}>跟随主题的文字</text>
122
+ </view>
123
+ </theme-provider>
124
+ ```
125
+
126
+ | 属性 | 类型 | 默认值 | 说明 |
127
+ |------|------|--------|------|
128
+ | children | ReactNode | - | 子元素 |
129
+ | className | string | - | 样式类名 |
130
+ | style | CSSProperties | - | 内联样式 |
131
+ | flatten | boolean | false | 默认 false,因为该容器需作为 CSS 变量作用域 |
@@ -0,0 +1,149 @@
1
+ # 滚动与列表组件
2
+
3
+ ## `<scroll-view>`
4
+
5
+ | 属性 | 类型 | 默认值 | 说明 |
6
+ |------|------|--------|------|
7
+ | scrollOrientation | `'vertical' \| 'horizontal'` | `'vertical'` | 滚动方向 |
8
+ | bounces | boolean | true | iOS 弹性回弹 |
9
+ | enableScroll | boolean | true | 是否允许滚动 |
10
+ | scrollBarEnable | boolean | true | 是否显示滚动条 |
11
+ | upperThreshold | number | 0 | 触发 onScrollToUpper 的距离阈值 (px) |
12
+ | lowerThreshold | number | 0 | 触发 onScrollToLower 的距离阈值 (px) |
13
+ | initialScrollOffset | number | 0 | 初始滚动偏移 (px),仅首屏有效 |
14
+ | onScrollToUpper | (e: ScrollToUpperEvent) => void | - | 滚动到顶/左 |
15
+ | onScrollToLower | (e: ScrollToLowerEvent) => void | - | 滚动到底/右 |
16
+ | onScroll | (e: ScrollEvent) => void | - | 滚动中 |
17
+ | onScrollEnd | (e: ScrollEndEvent) => void | - | 滚动结束 |
18
+ | onContentSizeChanged | (e: ContentSizeChangedEvent) => void | - | 内容尺寸变化 |
19
+
20
+ ```tsx
21
+ // 垂直滚动 + 上拉加载
22
+ <scroll-view
23
+ style={{ height: '100vh' }}
24
+ lowerThreshold={50}
25
+ onScrollToLower={() => loadMore()}
26
+ >
27
+ {items.map(item => <view key={item.id}>{/* ... */}</view>)}
28
+ </scroll-view>
29
+
30
+ // 水平滚动
31
+ <scroll-view scrollOrientation="horizontal" style={{ width: '100%' }}>
32
+ {images.map(img => <image key={img.id} src={img.url} style={{ width: '100px', height: '100px' }} />)}
33
+ </scroll-view>
34
+ ```
35
+
36
+ ---
37
+
38
+ ## `<list>` / `list-item`
39
+
40
+ 高性能列表,支持多列/瀑布流。
41
+
42
+ **`<list>` 必须显式指定 height**,不支持自适应高度。
43
+
44
+ `list-item` 是原生 Lynx 元素,属性名使用连字符(`item-key`、`sticky-top`),不是驼峰。
45
+
46
+ ### list 属性
47
+
48
+ | 属性 | 类型 | 默认值 | 说明 |
49
+ |------|------|--------|------|
50
+ | style | CSSProperties | - | **必须包含 height** |
51
+ | scrollOrientation | `'vertical' \| 'horizontal'` | `'vertical'` | 方向 |
52
+ | listType | `'single' \| 'flow' \| 'waterfall'` | `'single'` | 布局类型 |
53
+ | spanCount | number | 1 | 列数,flow/waterfall 时有效 |
54
+ | enableScroll | boolean | true | 是否允许滚动 |
55
+ | bounces | boolean | true | iOS 弹性回弹 |
56
+ | initialScrollIndex | number | 0 | 渲染后自动滚动到的节点位置 |
57
+ | lowerThresholdItemCount | number | 0 | 触发底部事件的剩余子节点数阈值 |
58
+ | upperThresholdItemCount | number | 0 | 触发顶部事件的剩余子节点数阈值 |
59
+ | scrollEventThrottle | number | 200 | 滚动事件节流间隔 (ms) |
60
+ | onScroll | (e: ListScrollEvent) => void | - | 滚动 |
61
+ | onScrollToUpper | (e: ListScrollToUpperEvent) => void | - | 滚动到顶部 |
62
+ | onScrollToLower | (e: ListScrollToLowerEvent) => void | - | 滚动到底部 |
63
+ | onLayoutComplete | (e: ListLayoutCompleteEvent) => void | - | 首屏渲染完成 |
64
+
65
+ ### list-item 属性
66
+
67
+ | 属性 | 类型 | 默认值 | 说明 |
68
+ |------|------|--------|------|
69
+ | item-key | string | - | **必填**,唯一标识 |
70
+ | sticky-top | boolean | false | 吸顶 |
71
+ | sticky-bottom | boolean | false | 吸底 |
72
+ | full-span | boolean | false | 多列时占满一行 |
73
+ | estimated-main-axis-size-px | number | -1 | 预估主轴尺寸 (px),瀑布流时建议填 |
74
+ | recyclable | boolean | true | 是否可回收 |
75
+
76
+ ```tsx
77
+ // 基础列表
78
+ <list style={{ height: '400px' }}>
79
+ {data.map(item => (
80
+ <list-item key={item.id} item-key={item.id}>
81
+ <view style={{ padding: '16px' }}><text>{item.title}</text></view>
82
+ </list-item>
83
+ ))}
84
+ </list>
85
+
86
+ // 吸顶 header
87
+ <list style={{ height: '400px' }}>
88
+ <list-item item-key="header" sticky-top>
89
+ <view style={{ padding: '12px', background: '#f5f5f5' }}><text>吸顶标题</text></view>
90
+ </list-item>
91
+ {data.map(item => (
92
+ <list-item key={item.id} item-key={item.id}>
93
+ <view style={{ padding: '16px' }}><text>{item.title}</text></view>
94
+ </list-item>
95
+ ))}
96
+ </list>
97
+
98
+ // 瀑布流
99
+ <list style={{ height: '100vh' }} listType="waterfall" spanCount={2}>
100
+ {items.map(item => (
101
+ <list-item key={item.id} item-key={item.id} estimated-main-axis-size-px={item.height}>
102
+ <view style={{ height: `${item.height}px` }}><text>{item.title}</text></view>
103
+ </list-item>
104
+ ))}
105
+ </list>
106
+ ```
107
+
108
+ ---
109
+
110
+ ## `<swiper>` / `<swiper-item>`
111
+
112
+ | 属性 | 类型 | 默认值 | 说明 |
113
+ |------|------|--------|------|
114
+ | data | T[] | - | 轮播数据 |
115
+ | itemWidth | number | - | 每项宽度 |
116
+ | itemHeight | number \| `'auto'` | - | 每项高度 |
117
+ | children | (prop: RenderFunctionProps\<T\>) => ReactElement | - | 渲染函数,返回 swiper-item |
118
+ | containerWidth | number | screenWidth | 容器宽度 |
119
+ | initialIndex | number | 0 | 初始索引,仅首屏有效 |
120
+ | loop | boolean | false | 循环 |
121
+ | duration | number | 500 | 动画时长 (ms) |
122
+ | onChange | (current: number) => void | - | 索引变化 |
123
+ | onSwipeStart | (current: number) => void | - | 开始滑动 |
124
+ | onSwipeStop | (current: number) => void | - | 停止滑动 |
125
+
126
+ ### swiper-item 属性
127
+
128
+ | 属性 | 类型 | 默认值 | 说明 |
129
+ |------|------|--------|------|
130
+ | index | number | - | 当前索引 |
131
+ | real-index | number | index | 真实索引,循环模式下与 index 不同 |
132
+ | style | CSSProperties | - | 样式 |
133
+ | overlap | boolean | false | 透明度有问题时使用 |
134
+
135
+ ```tsx
136
+ <swiper
137
+ data={images}
138
+ itemWidth={375}
139
+ itemHeight={200}
140
+ loop
141
+ onChange={(current) => console.log('current:', current)}
142
+ >
143
+ {({ item, index }) => (
144
+ <swiper-item index={index}>
145
+ <image src={item.url} style={{ width: '100%', height: '100%' }} mode="aspectFill" />
146
+ </swiper-item>
147
+ )}
148
+ </swiper>
149
+ ```
@@ -0,0 +1,107 @@
1
+ # 地图与画布组件
2
+
3
+ ## `<map>` / `<map-marker>`
4
+
5
+ 完整文档见 SDK 的 `map.md`。
6
+
7
+ ### map 核心属性
8
+
9
+ | 属性 | 类型 | 默认值 | 说明 |
10
+ |------|------|--------|------|
11
+ | ref | Ref\<MapRef\> | - | 实例 ref |
12
+ | center | `{ longitude: number; latitude: number }` | - | 地图中心 |
13
+ | scale | number | 16 | 缩放级别(3-20) |
14
+ | minScale / maxScale | number | 3 / 20 | 缩放范围 |
15
+ | polyline | Polyline[] | [] | 路线数组 |
16
+ | polygons | Polygon[] | [] | 多边形数组 |
17
+ | circles | Circle[] | [] | 圆数组 |
18
+ | rotate | number | 0 | 旋转角度(度) |
19
+ | showScale | boolean | false | 显示比例尺 |
20
+ | enableScale | boolean | true | 允许缩放 |
21
+ | enableDrag | boolean | true | 允许拖动 |
22
+ | enableRotate | boolean | false | 允许旋转 |
23
+ | mapStyle | `'normal-light' \| 'normal-dark' \| 'simple-light' \| 'simple-dark'` | `'normal-light'` | 地图主题 |
24
+ | onClick | (e: { point: { latitude: number; longitude: number } }) => void | - | 点击地图 |
25
+ | onMapLoaded | () => void | - | 地图加载完成 |
26
+ | onRegionChange | (e) => void | - | 视野变化 |
27
+ | className | string | - | 样式类名 |
28
+ | style | CSSProperties | - | 内联样式 |
29
+
30
+ ### MapRef 方法
31
+
32
+ | 方法 | 参数 | 说明 |
33
+ |------|------|------|
34
+ | setCenter | (center, scale?) | 设置中心点 |
35
+ | getCenter | () | 获取当前中心点 |
36
+ | getScale | () | 获取当前缩放级别 |
37
+ | setScale | (scale) | 设置缩放级别 |
38
+ | getBound | () | 获取可见区域边界 |
39
+ | setBound | (bounds) | 设置可见区域边界 |
40
+ | fitPoints | (points, padding?) | 视野适配点集,padding 顺序 `[left, right, top, bottom]` |
41
+ | setAnchor | (position) | 设置地图锚点 |
42
+
43
+ ### map-marker 核心属性
44
+
45
+ | 属性 | 类型 | 默认值 | 说明 |
46
+ |------|------|--------|------|
47
+ | position | `{ longitude: number; latitude: number }` | - | 坐标(必填) |
48
+ | children | ReactNode | - | 自定义标记点 UI(必填) |
49
+ | anchor | [number, number] | [0.5, 1] | 经纬度在图标上的锚点 |
50
+ | alpha | number | 1 | 透明度(0-1) |
51
+ | rotation | number | 0 | 旋转角度(0-360) |
52
+ | clickable | boolean | true | 是否可点击 |
53
+ | draggable | boolean | false | 是否可拖拽 |
54
+ | onClick | () => void | - | 点击回调 |
55
+
56
+ ```tsx
57
+ import type { MapRef } from '@doubao-apps/framework/components';
58
+ import { useRef } from '@doubao-apps/framework';
59
+
60
+ const mapRef = useRef<MapRef>(null);
61
+
62
+ <map
63
+ ref={mapRef}
64
+ center={{ longitude: 116.397, latitude: 39.916 }}
65
+ scale={15}
66
+ style={{ width: '100%', height: '300px' }}
67
+ onMapLoaded={() => mapRef.current?.fitPoints([
68
+ { longitude: 116.39, latitude: 39.91 },
69
+ { longitude: 116.40, latitude: 39.92 },
70
+ ])}
71
+ >
72
+ <map-marker position={{ longitude: 116.397, latitude: 39.916 }} onClick={() => console.log('clicked')}>
73
+ <view style={{ width: '24px', height: '24px', background: '#FF3B30', borderRadius: '50%' }} />
74
+ </map-marker>
75
+ </map>
76
+ ```
77
+
78
+ ---
79
+
80
+ ## `<canvas>`
81
+
82
+ | 属性 | 类型 | 说明 |
83
+ |------|------|------|
84
+ | ref | Ref\<CanvasRef\> | 实例 ref,获取绘图上下文 |
85
+ | style | CSSProperties | 内联样式(设置宽高) |
86
+ | className | string | 样式类名 |
87
+ | onResize | (e: CanvasResizeEvent) => void | 尺寸变化回调 |
88
+
89
+ ### CanvasRef 方法
90
+
91
+ 通过 ref 获取实例后调用 `getContext('2d')` 获取 2D 绘图上下文,API 与 Web Canvas 基本一致。
92
+
93
+ ```tsx
94
+ import type { CanvasRef } from '@doubao-apps/framework/components';
95
+ import { useRef, useEffect } from '@doubao-apps/framework';
96
+
97
+ const canvasRef = useRef<CanvasRef>(null);
98
+
99
+ useEffect(() => {
100
+ const ctx = canvasRef.current?.getContext('2d');
101
+ if (!ctx) return;
102
+ ctx.fillStyle = '#FF3B30';
103
+ ctx.fillRect(10, 10, 100, 100);
104
+ }, []);
105
+
106
+ <canvas ref={canvasRef} style={{ width: '300px', height: '300px' }} />
107
+ ```