@doubao-dev/taro-runtime 0.9.0 → 0.10.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 (185) hide show
  1. package/README.md +117 -0
  2. package/assets/refresh-loading.png +0 -0
  3. package/dist/api/base/can-i-use.d.ts +3 -0
  4. package/dist/api/base/can-i-use.js +12 -0
  5. package/dist/api/base/event-center.d.ts +12 -0
  6. package/dist/api/base/event-center.js +52 -0
  7. package/dist/api/base/index.d.ts +1 -1
  8. package/dist/api/base/index.js +1 -1
  9. package/dist/api/base/next-tick.d.ts +3 -0
  10. package/dist/api/base/next-tick.js +11 -0
  11. package/dist/api/canvas/index.d.ts +17 -0
  12. package/dist/api/canvas/index.js +29 -0
  13. package/dist/api/create-animation.d.ts +47 -0
  14. package/dist/api/create-animation.js +98 -0
  15. package/dist/api/create-intersection-observer/index.d.ts +7 -0
  16. package/dist/api/create-intersection-observer/index.js +126 -0
  17. package/dist/api/create-selector-query/index.js +284 -109
  18. package/dist/api/device/accelerometer.js +1 -1
  19. package/dist/api/device/accessibility.js +1 -1
  20. package/dist/api/device/battery.js +1 -1
  21. package/dist/api/device/beacon.js +1 -1
  22. package/dist/api/device/bluetooth.js +1 -1
  23. package/dist/api/device/clipboard.js +1 -1
  24. package/dist/api/device/compass.js +1 -1
  25. package/dist/api/device/crypto.js +1 -1
  26. package/dist/api/device/device-motion.js +1 -1
  27. package/dist/api/device/gyroscope.js +1 -1
  28. package/dist/api/device/keyboard.js +1 -1
  29. package/dist/api/device/scan.js +1 -1
  30. package/dist/api/device/screen.js +1 -1
  31. package/dist/api/device/sms.js +1 -1
  32. package/dist/api/device/vibration.js +1 -1
  33. package/dist/api/device/wifi.js +1 -1
  34. package/dist/api/index.d.ts +8 -1
  35. package/dist/api/index.js +8 -1
  36. package/dist/api/interaction/index.js +1 -1
  37. package/dist/api/location/index.d.ts +2 -2
  38. package/dist/api/location/index.js +1 -1
  39. package/dist/api/media/image.d.ts +9 -0
  40. package/dist/api/media/image.js +21 -1
  41. package/dist/api/media/index.d.ts +2 -0
  42. package/dist/api/media/index.js +2 -0
  43. package/dist/api/media/inner-audio.d.ts +5 -0
  44. package/dist/api/media/inner-audio.js +7 -0
  45. package/dist/api/media/media.d.ts +6 -0
  46. package/dist/api/media/media.js +9 -0
  47. package/dist/api/px-transform.d.ts +11 -0
  48. package/dist/api/px-transform.js +31 -0
  49. package/dist/api/request/index.js +1 -1
  50. package/dist/api/request/websocket.js +1 -1
  51. package/dist/api/router/current-instance.d.ts +17 -0
  52. package/dist/api/router/current-instance.js +28 -0
  53. package/dist/api/router/exit-mini-program.js +1 -1
  54. package/dist/api/router/get-current-pages.d.ts +13 -1
  55. package/dist/api/router/get-current-pages.js +5 -3
  56. package/dist/api/router/index.d.ts +1 -0
  57. package/dist/api/router/index.js +1 -0
  58. package/dist/api/router/navigate-back.js +1 -1
  59. package/dist/api/router/navigate-to.js +1 -1
  60. package/dist/api/router/re-launch.js +1 -1
  61. package/dist/api/router/redirect-to.js +1 -1
  62. package/dist/api/runtime/download.d.ts +11 -0
  63. package/dist/api/runtime/download.js +18 -0
  64. package/dist/api/runtime/resize.d.ts +7 -0
  65. package/dist/api/runtime/resize.js +26 -0
  66. package/dist/api/runtime/system.d.ts +8 -0
  67. package/dist/api/runtime/system.js +10 -0
  68. package/dist/api/show-toast/index.js +1 -1
  69. package/dist/api/storage/index.d.ts +1 -1
  70. package/dist/api/storage/index.js +1 -1
  71. package/dist/api/system/index.js +1 -1
  72. package/dist/components/Block/index.d.ts +3 -0
  73. package/dist/components/Block/index.jsx +4 -0
  74. package/dist/components/Button/index.d.ts +7 -0
  75. package/dist/components/Button/index.jsx +28 -0
  76. package/dist/components/Canvas/index.d.ts +4 -0
  77. package/dist/components/Canvas/index.jsx +25 -0
  78. package/dist/components/Checkbox/index.d.ts +3 -0
  79. package/dist/components/Checkbox/index.jsx +17 -0
  80. package/dist/components/CheckboxGroup/index.d.ts +3 -0
  81. package/dist/components/CheckboxGroup/index.jsx +13 -0
  82. package/dist/components/CoverView/index.d.ts +6 -1
  83. package/dist/components/CoverView/index.js +5 -1
  84. package/dist/components/Form/index.d.ts +4 -0
  85. package/dist/components/Form/index.jsx +39 -0
  86. package/dist/components/Form/use-form-field.d.ts +5 -0
  87. package/dist/components/Form/use-form-field.js +40 -0
  88. package/dist/components/Icon/index.d.ts +3 -0
  89. package/dist/components/Icon/index.jsx +40 -0
  90. package/dist/components/Image/index.d.ts +3 -1
  91. package/dist/components/Image/index.jsx +15 -4
  92. package/dist/components/Input/index.d.ts +1 -1
  93. package/dist/components/Input/index.jsx +9 -5
  94. package/dist/components/Input/map.d.ts +1 -1
  95. package/dist/components/Label/control.d.ts +6 -0
  96. package/dist/components/Label/control.js +29 -0
  97. package/dist/components/Label/index.d.ts +3 -0
  98. package/dist/components/Label/index.jsx +15 -0
  99. package/dist/components/LivePlayer/index.d.ts +3 -0
  100. package/dist/components/LivePlayer/index.jsx +8 -0
  101. package/dist/components/Map/bridge.d.ts +1 -1
  102. package/dist/components/Map/index.jsx +10 -6
  103. package/dist/components/Movable/index.d.ts +4 -0
  104. package/dist/components/Movable/index.jsx +26 -0
  105. package/dist/components/NavigationBar/index.d.ts +3 -0
  106. package/dist/components/NavigationBar/index.jsx +16 -0
  107. package/dist/components/Navigator/index.d.ts +3 -0
  108. package/dist/components/Navigator/index.jsx +32 -0
  109. package/dist/components/OpenData/index.d.ts +3 -0
  110. package/dist/components/OpenData/index.js +4 -0
  111. package/dist/components/Picker/index.d.ts +6 -0
  112. package/dist/components/Picker/index.jsx +155 -0
  113. package/dist/components/Picker/popup.d.ts +18 -0
  114. package/dist/components/Picker/popup.jsx +105 -0
  115. package/dist/components/PickerView/index.d.ts +1 -1
  116. package/dist/components/PickerView/index.jsx +1 -1
  117. package/dist/components/PickerView/map.d.ts +1 -1
  118. package/dist/components/Progress/index.d.ts +3 -0
  119. package/dist/components/Progress/index.jsx +14 -0
  120. package/dist/components/Radio/index.jsx +9 -5
  121. package/dist/components/Radio/shared.d.ts +1 -1
  122. package/dist/components/RadioGroup/context.js +1 -1
  123. package/dist/components/RadioGroup/index.jsx +8 -4
  124. package/dist/components/RadioGroup/map.d.ts +1 -1
  125. package/dist/components/RichText/index.d.ts +3 -0
  126. package/dist/components/RichText/index.jsx +7 -0
  127. package/dist/components/ScrollView/index.d.ts +4 -1
  128. package/dist/components/ScrollView/index.jsx +44 -14
  129. package/dist/components/ScrollView/map.d.ts +4 -2
  130. package/dist/components/ScrollView/map.js +19 -1
  131. package/dist/components/ScrollView/refresh-types.d.ts +25 -0
  132. package/dist/components/ScrollView/refresh-types.js +2 -0
  133. package/dist/components/ScrollView/refresh.d.ts +10 -0
  134. package/dist/components/ScrollView/refresh.jsx +29 -0
  135. package/dist/components/ScrollView/use-refresher.d.ts +19 -0
  136. package/dist/components/ScrollView/use-refresher.js +214 -0
  137. package/dist/components/Slider/index.d.ts +3 -0
  138. package/dist/components/Slider/index.jsx +13 -0
  139. package/dist/components/Swiper/index.d.ts +3 -0
  140. package/dist/components/Swiper/index.jsx +79 -0
  141. package/dist/components/SwiperItem/index.d.ts +3 -0
  142. package/dist/components/SwiperItem/index.jsx +18 -0
  143. package/dist/components/Switch/index.d.ts +3 -0
  144. package/dist/components/Switch/index.jsx +32 -0
  145. package/dist/components/Text/format.d.ts +5 -0
  146. package/dist/components/Text/format.js +51 -0
  147. package/dist/components/Text/index.d.ts +4 -3
  148. package/dist/components/Text/index.jsx +3 -2
  149. package/dist/components/Text/map.js +9 -4
  150. package/dist/components/Textarea/index.d.ts +3 -0
  151. package/dist/components/Textarea/index.jsx +30 -0
  152. package/dist/components/Video/index.d.ts +3 -0
  153. package/dist/components/Video/index.jsx +22 -0
  154. package/dist/components/View/index.d.ts +5 -5
  155. package/dist/components/View/index.jsx +11 -13
  156. package/dist/components/View/map.js +5 -0
  157. package/dist/components/base/change-event.d.ts +18 -0
  158. package/dist/components/base/change-event.js +13 -0
  159. package/dist/components/base/wrap-text-node.d.ts +3 -0
  160. package/dist/components/base/wrap-text-node.jsx +34 -0
  161. package/dist/components/index.d.ts +24 -1
  162. package/dist/components/index.js +24 -1
  163. package/dist/exports/app.d.ts +2 -1
  164. package/dist/exports/app.js +3 -1
  165. package/dist/exports/common.d.ts +1 -0
  166. package/dist/exports/common.js +1 -0
  167. package/dist/exports/view-core.d.ts +2 -1
  168. package/dist/exports/view-core.js +2 -1
  169. package/dist/exports/view.d.ts +2 -1
  170. package/dist/exports/view.js +3 -1
  171. package/dist/hooks/lifecycle/app.js +1 -1
  172. package/dist/hooks/use-animation.d.ts +9 -0
  173. package/dist/hooks/use-animation.js +151 -0
  174. package/dist/internal/class-components.d.ts +11 -0
  175. package/dist/internal/class-components.js +42 -0
  176. package/dist/internal/index.d.ts +1 -0
  177. package/dist/internal/index.js +1 -0
  178. package/dist/internal/map-context/index.d.ts +1 -1
  179. package/dist/internal/query-node.d.ts +9 -0
  180. package/dist/internal/query-node.js +35 -0
  181. package/dist/internal/selector-id.d.ts +6 -0
  182. package/dist/internal/selector-id.js +18 -0
  183. package/dist/react.d.ts +4 -0
  184. package/dist/react.js +4 -0
  185. package/package.json +23 -1
@@ -0,0 +1,155 @@
1
+ import { useEffect, useState } from '@doubao-dev/framework';
2
+ import { useFormField } from '../Form/use-form-field.js';
3
+ import { View } from '../View/index.jsx';
4
+ import { changeEvent } from '../base/change-event.js';
5
+ import { warnUnsupported } from '../base/warn-unsupported.js';
6
+ import { PickerPopup } from './popup.jsx';
7
+ const pad = (value) => String(value).padStart(2, '0');
8
+ const range = (start, end) => Number.isInteger(start) && Number.isInteger(end) && end >= start && end - start <= 9999
9
+ ? Array.from({ length: end - start + 1 }, (_, i) => start + i)
10
+ : [];
11
+ const numericColumn = (start, end, value) => ({
12
+ options: range(start, end).map((value) => ({ value, label: pad(value) })),
13
+ value: Math.max(start, Math.min(end, Number.isFinite(value) ? Math.trunc(value) : start))
14
+ });
15
+ function defaultValue(props) {
16
+ if ('defaultValue' in props && props.defaultValue !== undefined) {
17
+ return Array.isArray(props.defaultValue) ? props.defaultValue.map(Number) : props.defaultValue;
18
+ }
19
+ if (props.mode === 'date') {
20
+ const now = new Date();
21
+ return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
22
+ }
23
+ if (props.mode === 'time') {
24
+ return '00:00';
25
+ }
26
+ return props.mode === 'multiSelector' ? [] : 0;
27
+ }
28
+ function toDraft(mode, value) {
29
+ return {
30
+ mode,
31
+ value: mode === 'date' || mode === 'time'
32
+ ? String(value)
33
+ : (Array.isArray(value) ? value : [value]).map((item) => {
34
+ const index = Number(item);
35
+ return Number.isFinite(index) ? Math.max(0, Math.trunc(index)) : 0;
36
+ })
37
+ };
38
+ }
39
+ function dateColumns(value, start, end, fields) {
40
+ const [startYear, startMonth = 1, startDay = 1] = start.split('-').map(Number);
41
+ const [endYear, endMonth = 12, endDay = 31] = end.split('-').map(Number);
42
+ const [year, month = 1, day = 1] = value.split('-').map(Number);
43
+ const yearColumn = numericColumn(startYear, endYear, year);
44
+ if (fields === 'year') {
45
+ return [yearColumn];
46
+ }
47
+ const monthColumn = numericColumn(yearColumn.value === startYear ? startMonth : 1, yearColumn.value === endYear ? endMonth : 12, month);
48
+ if (fields === 'month') {
49
+ return [yearColumn, monthColumn];
50
+ }
51
+ const days = new Date(yearColumn.value, monthColumn.value, 0).getDate();
52
+ const dayColumn = numericColumn(yearColumn.value === startYear && monthColumn.value === startMonth ? startDay : 1, yearColumn.value === endYear && monthColumn.value === endMonth ? Math.min(days, endDay) : days, day);
53
+ return [yearColumn, monthColumn, dayColumn];
54
+ }
55
+ export function Picker(props) {
56
+ const { id, className, style, disabled, children, onCancel, headerText, textProps } = props;
57
+ const [draft, setDraft] = useState();
58
+ const [committed, setCommitted] = useState(() => ({
59
+ mode: props.mode ?? 'selector',
60
+ value: defaultValue(props)
61
+ }));
62
+ const mode = props.mode ?? 'selector';
63
+ const resolvedValue = props.value ?? (committed.mode === mode ? committed.value : defaultValue(props));
64
+ const updateForm = useFormField(props.name, resolvedValue);
65
+ const controlledKey = props.value === undefined ? undefined : JSON.stringify(toDraft(mode, props.value));
66
+ warnUnsupported('Picker', mode === 'region' ? ['mode=region'] : []);
67
+ useEffect(() => {
68
+ if (disabled || mode === 'region') {
69
+ setDraft(undefined);
70
+ return;
71
+ }
72
+ setDraft((current) => {
73
+ if (!current || current.mode !== mode) {
74
+ return undefined;
75
+ }
76
+ return controlledKey === undefined ? current : JSON.parse(controlledKey);
77
+ });
78
+ }, [controlledKey, disabled, mode]);
79
+ function open() {
80
+ if (disabled || mode === 'region' || draft) {
81
+ return;
82
+ }
83
+ setDraft(toDraft(mode, resolvedValue));
84
+ }
85
+ let columns = [];
86
+ if (draft?.mode === mode) {
87
+ if (props.mode === 'date') {
88
+ columns = dateColumns(String(draft.value), props.start ?? '1900-01-01', props.end ?? '2100-12-31', props.fields ?? 'day');
89
+ }
90
+ else if (props.mode === 'time') {
91
+ const [hour, minute] = String(draft.value).split(':').map(Number);
92
+ const [firstHour, firstMinute] = (props.start ?? '00:00').split(':').map(Number);
93
+ const [lastHour, lastMinute] = (props.end ?? '23:59').split(':').map(Number);
94
+ const hourColumn = numericColumn(firstHour, lastHour, hour);
95
+ columns = [
96
+ hourColumn,
97
+ numericColumn(hourColumn.value === firstHour ? firstMinute : 0, hourColumn.value === lastHour ? lastMinute : 59, minute)
98
+ ];
99
+ }
100
+ else if (props.mode !== 'region') {
101
+ const ranges = props.mode === 'multiSelector' ? (props.range ?? []) : [props.range ?? []];
102
+ columns = ranges.map((items, index) => {
103
+ const options = items.map((item, value) => ({
104
+ value,
105
+ label: String(typeof item === 'object' && item !== null && props.rangeKey ? item[props.rangeKey] : item)
106
+ }));
107
+ const selected = Array.isArray(draft.value) ? draft.value[index] : 0;
108
+ return { options, value: Math.max(0, Math.min(options.length - 1, selected ?? 0)) };
109
+ });
110
+ }
111
+ }
112
+ function change(column, nextValue) {
113
+ const indices = columns.map(({ value }, index) => (index === column ? nextValue : value));
114
+ if (mode === 'date' || mode === 'time') {
115
+ setDraft({ mode, value: indices.map(pad).join(mode === 'date' ? '-' : ':') });
116
+ }
117
+ else {
118
+ setDraft({ mode, value: indices });
119
+ if (props.mode === 'multiSelector') {
120
+ props.onColumnChange?.(changeEvent('picker', id, { column, value: nextValue }, 'columnchange'));
121
+ }
122
+ }
123
+ }
124
+ function confirm() {
125
+ if (columns.length === 0 || columns.some(({ options }) => options.length === 0)) {
126
+ return;
127
+ }
128
+ const indices = columns.map(({ value }) => value);
129
+ const value = mode === 'date' || mode === 'time'
130
+ ? indices.map(pad).join(mode === 'date' ? '-' : ':')
131
+ : mode === 'multiSelector'
132
+ ? indices
133
+ : indices[0];
134
+ setDraft(undefined);
135
+ if (props.value === undefined) {
136
+ setCommitted({ mode, value });
137
+ }
138
+ updateForm?.(value);
139
+ props.onChange?.(changeEvent('picker', id, { value }));
140
+ }
141
+ function cancel() {
142
+ setDraft(undefined);
143
+ onCancel?.(changeEvent('picker', id, {}, 'cancel'));
144
+ }
145
+ return (<>
146
+ <View id={id} className={className} style={style} onTap={(event) => {
147
+ props.onClick?.(event);
148
+ open();
149
+ }}>
150
+ {children}
151
+ </View>
152
+ {draft?.mode === mode && !disabled && mode !== 'region' && (<PickerPopup columns={columns} title={headerText} confirmText={textProps?.okText} cancelText={textProps?.cancelText} onColumnChange={change} onConfirm={confirm} onCancel={cancel}/>)}
153
+ </>);
154
+ }
155
+ //# sourceMappingURL=index.jsx.map
@@ -0,0 +1,18 @@
1
+ export interface PickerColumnData {
2
+ options: {
3
+ value: number;
4
+ label: string;
5
+ }[];
6
+ value: number;
7
+ }
8
+ /** Internal presentation for Taro Picker; all mode and value conversion stays in its adapter. */
9
+ export declare function PickerPopup({ columns, title, confirmText, cancelText, onColumnChange, onConfirm, onCancel }: {
10
+ columns: PickerColumnData[];
11
+ title?: string;
12
+ confirmText?: string;
13
+ cancelText?: string;
14
+ onColumnChange: (columnIndex: number, value: number) => void;
15
+ onConfirm: () => void;
16
+ onCancel: () => void;
17
+ }): any;
18
+ //# sourceMappingURL=popup.d.ts.map
@@ -0,0 +1,105 @@
1
+ import { PickerColumn, PickerView, Popup, useThemeClassName } from '@doubao-dev/framework/components';
2
+ import { useEffect, useRef } from '@doubao-dev/framework';
3
+ const stops = { init: 100, top: 100, bottom: 0 };
4
+ const actionStyle = {
5
+ display: 'flex',
6
+ alignItems: 'center',
7
+ justifyContent: 'center',
8
+ height: '56px',
9
+ padding: '0 12px',
10
+ flexShrink: 0
11
+ };
12
+ const textStyle = {
13
+ fontFamily: 'sans-serif',
14
+ fontSize: '16px',
15
+ lineHeight: '24px',
16
+ color: 'var(--neutral-100)'
17
+ };
18
+ /** Internal presentation for Taro Picker; all mode and value conversion stays in its adapter. */
19
+ export function PickerPopup({ columns, title, confirmText = '确定', cancelText = '取消', onColumnChange, onConfirm, onCancel }) {
20
+ const themeClassName = useThemeClassName();
21
+ const popupRef = useRef(null);
22
+ const finished = useRef(false);
23
+ const canConfirm = columns.length > 0 && columns.every(({ options }) => options.length > 0);
24
+ useEffect(() => {
25
+ finished.current = false;
26
+ popupRef.current?.open(0);
27
+ return () => {
28
+ finished.current = true;
29
+ };
30
+ }, []);
31
+ function finish(confirm, popupClosed = false) {
32
+ if (finished.current || (confirm && !canConfirm)) {
33
+ return;
34
+ }
35
+ finished.current = true;
36
+ if (!popupClosed) {
37
+ popupRef.current?.close();
38
+ }
39
+ if (confirm) {
40
+ onConfirm();
41
+ }
42
+ else {
43
+ onCancel();
44
+ }
45
+ }
46
+ return (<Popup ref={popupRef} scrollContainerId="" maxHeight={276} heightPercent={stops} contentStyle={{ height: '276px' }} enableDrag={false} enableScrollContainerDraggable={false} closeOnMaskClick maskStyle={{ backgroundColor: 'var(--static-black)', opacity: 0.45 }} onRequestClose={() => finish(false)} onPopupPositionChange={(position) => {
47
+ if (position === 4) {
48
+ finish(false, true);
49
+ }
50
+ }}>
51
+ {() => (<view className={themeClassName} data-taro-picker-panel="true" style={{
52
+ display: 'flex',
53
+ flexDirection: 'column',
54
+ width: '100%',
55
+ backgroundColor: 'var(--bg-base-2)',
56
+ borderTopLeftRadius: '16px',
57
+ borderTopRightRadius: '16px',
58
+ overflow: 'hidden'
59
+ }} catchtap={() => { }}>
60
+ <view style={{
61
+ display: 'flex',
62
+ flexDirection: 'row',
63
+ alignItems: 'center',
64
+ height: '56px',
65
+ padding: '0 8px'
66
+ }}>
67
+ <view style={actionStyle} bindtap={() => finish(false)} accessibility-label={cancelText}>
68
+ <text style={textStyle}>{cancelText}</text>
69
+ </view>
70
+ <text style={{ ...textStyle, flex: 1, fontWeight: '500', textAlign: 'center' }}>
71
+ {title ?? ''}
72
+ </text>
73
+ <view style={actionStyle} bindtap={() => finish(true)} accessibility-label={confirmText} accessibility-traits={canConfirm ? 'button' : 'disabled'}>
74
+ <text style={{ ...textStyle, color: canConfirm ? 'var(--primary-50)' : 'var(--neutral-30)' }}>
75
+ {confirmText}
76
+ </text>
77
+ </view>
78
+ </view>
79
+ <PickerView style={{ height: '220px' }} itemHeight={44}>
80
+ {columns.length > 0 ? (columns.map(({ options, value }, index) => options.length > 0 ? (<PickerColumn key={index} options={options} value={value} onChange={(nextValue) => {
81
+ if (!finished.current && nextValue !== value) {
82
+ onColumnChange(index, Number(nextValue));
83
+ }
84
+ }}/>) : (<view key={index} style={{
85
+ display: 'flex',
86
+ flex: 1,
87
+ height: '100%',
88
+ alignItems: 'center',
89
+ justifyContent: 'center'
90
+ }}>
91
+ <text style={{ ...textStyle, color: 'var(--neutral-30)' }}>暂无选项</text>
92
+ </view>))) : (<view style={{
93
+ display: 'flex',
94
+ flex: 1,
95
+ height: '100%',
96
+ alignItems: 'center',
97
+ justifyContent: 'center'
98
+ }}>
99
+ <text style={{ ...textStyle, color: 'var(--neutral-30)' }}>暂无选项</text>
100
+ </view>)}
101
+ </PickerView>
102
+ </view>)}
103
+ </Popup>);
104
+ }
105
+ //# sourceMappingURL=popup.jsx.map
@@ -1,4 +1,4 @@
1
- import type { PickerColumnOption } from '@byted-doubao-apps/framework/components';
1
+ import type { PickerColumnOption } from '@doubao-dev/framework/components';
2
2
  import { type TaroPickerViewProps, type TaroPickerViewColumnProps } from './map.js';
3
3
  export declare function PickerView(props: TaroPickerViewProps): any;
4
4
  export declare function PickerViewColumn(_props: TaroPickerViewColumnProps & {
@@ -1,4 +1,4 @@
1
- import { PickerView as DoubaoPickerView, PickerColumn as DoubaoPickerColumn } from '@byted-doubao-apps/components';
1
+ import { PickerView as DoubaoPickerView, PickerColumn as DoubaoPickerColumn } from '@doubao-dev/framework/components';
2
2
  import { warnUnsupported } from '../base/warn-unsupported.js';
3
3
  import { buildOptionsFromChildren, buildOptionsFromRange, mapPickerViewColumnProps, mapPickerViewProps, resolveExplicitItemHeight, resolveItemHeightFromChildren, resolveSelectedIndexValue, toPickerViewChangeEvent } from './map.js';
4
4
  const PICKER_VIEW_COLUMN_TYPE = 'taro-picker-view-column';
@@ -1,4 +1,4 @@
1
- import type { PickerViewProps as LynxPickerViewProps, PickerColumnOption } from '@byted-doubao-apps/framework/components';
1
+ import type { PickerViewProps as LynxPickerViewProps, PickerColumnOption } from '@doubao-dev/framework/components';
2
2
  import type { CSSProperties } from '@lynx-js/types';
3
3
  import type { PickerViewProps as TaroPickerViewPropsBase } from '@tarojs/components';
4
4
  import type { ReactNode } from 'react';
@@ -0,0 +1,3 @@
1
+ import type { ProgressProps } from '@tarojs/components';
2
+ export declare function Progress({ id, className, style, percent, showInfo, borderRadius, fontSize, strokeWidth, color, activeColor, backgroundColor, active }: ProgressProps): any;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { warnUnsupported } from '../base/warn-unsupported.js';
2
+ export function Progress({ id, className, style, percent = 0, showInfo, borderRadius = 0, fontSize = 16, strokeWidth = 6, color, activeColor = color ?? '#09bb07', backgroundColor = '#ebebeb', active }) {
3
+ warnUnsupported('Progress', active ? ['active'] : []);
4
+ const value = Math.max(0, Math.min(100, percent));
5
+ return (<view id={id} className={className} style={style}>
6
+ <view style={{ flexDirection: 'row', alignItems: 'center' }}>
7
+ <view style={{ flex: 1, height: strokeWidth, borderRadius, backgroundColor, overflow: 'hidden' }}>
8
+ <view style={{ width: `${value}%`, height: '100%', backgroundColor: activeColor }}/>
9
+ </view>
10
+ {showInfo && <text style={{ fontSize, marginLeft: 8 }}>{value}%</text>}
11
+ </view>
12
+ </view>);
13
+ }
14
+ //# sourceMappingURL=index.jsx.map
@@ -1,7 +1,9 @@
1
- import { useCallback, useContext, useEffect, useRef, useState } from '@byted-doubao-apps/framework';
1
+ import { useCallback, useContext, useEffect, useRef, useState } from '@doubao-dev/framework';
2
2
  import { RadioGroupRuntimeContext } from '../RadioGroup/context.js';
3
3
  import { warnUnsupported } from '../base/warn-unsupported.js';
4
+ import { wrapTextNode } from '../base/wrap-text-node.jsx';
4
5
  import { mapRadioProps, resolveLynxRadioValue, resolveStandaloneSelectedValue, shouldDispatchStandaloneRadioChange, toRadioChangeEvent } from './map.js';
6
+ import { useLabelControl } from '../Label/control.js';
5
7
  import { markRuntimeRadio } from './shared.js';
6
8
  function RadioImpl(props) {
7
9
  const { children, onChange, ...nonEventProps } = props;
@@ -50,10 +52,12 @@ function RadioImpl(props) {
50
52
  setUncontrolledChecked(true);
51
53
  }
52
54
  }, [isStandaloneChecked, isStandaloneControlled, onChange, radioId, resolvedDisabled, resolvedValue]);
55
+ const insideLabel = useLabelControl(radioId, groupContext ? handleGroupLabelTap : handleStandaloneSelect);
56
+ const stopLabelTap = insideLabel ? { catchtap: () => { } } : {};
53
57
  if (groupContext) {
54
- return (<view {...mapped}>
58
+ return (<view {...mapped} {...stopLabelTap}>
55
59
  <radio value={valueForLynx} disabled={resolvedDisabled || groupContext.disabled}/>
56
- {children !== undefined ? <view bindtap={handleGroupLabelTap}>{children}</view> : null}
60
+ {children !== undefined ? <view bindtap={handleGroupLabelTap}>{wrapTextNode(children)}</view> : null}
57
61
  </view>);
58
62
  }
59
63
  const standaloneSelectedValue = resolveStandaloneSelectedValue(isStandaloneChecked ?? false, valueForLynx);
@@ -62,11 +66,11 @@ function RadioImpl(props) {
62
66
  onValueChange: handleStandaloneSelect,
63
67
  value: standaloneSelectedValue
64
68
  };
65
- return (<view {...mapped}>
69
+ return (<view {...mapped} {...stopLabelTap}>
66
70
  <radio-group {...lynxStandaloneGroupProps}>
67
71
  <radio value={valueForLynx} disabled={resolvedDisabled}/>
68
72
  </radio-group>
69
- {children !== undefined ? <view bindtap={handleStandaloneSelect}>{children}</view> : null}
73
+ {children !== undefined ? <view bindtap={handleStandaloneSelect}>{wrapTextNode(children)}</view> : null}
70
74
  </view>);
71
75
  }
72
76
  export const Radio = markRuntimeRadio(RadioImpl);
@@ -1,4 +1,4 @@
1
- import type { ReactElement } from '@byted-doubao-apps/framework';
1
+ import type { ReactElement } from '@doubao-dev/framework';
2
2
  export declare const RUNTIME_RADIO_MARK: unique symbol;
3
3
  export declare function markRuntimeRadio<T extends object>(component: T): T;
4
4
  export declare function isRuntimeRadioElement(element: ReactElement | {
@@ -1,3 +1,3 @@
1
- import { createContext } from '@byted-doubao-apps/framework';
1
+ import { createContext } from '@doubao-dev/framework';
2
2
  export const RadioGroupRuntimeContext = createContext(null);
3
3
  //# sourceMappingURL=context.js.map
@@ -1,9 +1,11 @@
1
- import { useCallback, useMemo, useRef, useState } from '@byted-doubao-apps/framework';
1
+ import { useCallback, useMemo, useRef, useState } from '@doubao-dev/framework';
2
2
  import { warnUnsupported } from '../base/warn-unsupported.js';
3
+ import { wrapTextNode } from '../base/wrap-text-node.jsx';
3
4
  import { RadioGroupRuntimeContext } from './context.js';
4
5
  import { mapRadioGroupProps, resolveCheckedRadioSelection, resolveGroupSelectedValue, shouldDispatchGroupChange, toRadioGroupChangeEvent } from './map.js';
6
+ import { useFormField } from '../Form/use-form-field.js';
5
7
  export function RadioGroup(props) {
6
- const { children, onChange, ...nonEventProps } = props;
8
+ const { children, name, onChange, ...nonEventProps } = props;
7
9
  const { mapped, unsupported, groupId, resolvedDisabled } = mapRadioGroupProps(nonEventProps);
8
10
  const checkedSelection = resolveCheckedRadioSelection(children);
9
11
  const { hasCheckedRadio, selectedValue: checkedValue, missingValueCount } = checkedSelection;
@@ -12,6 +14,7 @@ export function RadioGroup(props) {
12
14
  const [uncontrolledValue, setUncontrolledValue] = useState(checkedValue);
13
15
  const radioChangeHandlersRef = useRef(new Map());
14
16
  const selectedValue = resolveGroupSelectedValue(hasCheckedRadio, checkedValue, uncontrolledValue);
17
+ const updateForm = useFormField(name, selectedValue ?? '');
15
18
  const registerRadioOnChange = useCallback((value, handler) => {
16
19
  const handlerMap = radioChangeHandlersRef.current;
17
20
  const bucket = handlerMap.get(value) ?? new Set();
@@ -44,9 +47,10 @@ export function RadioGroup(props) {
44
47
  if (!hasCheckedRadio) {
45
48
  setUncontrolledValue(nextValue);
46
49
  }
50
+ updateForm?.(nextValue);
47
51
  onChange?.(toRadioGroupChangeEvent({ value: nextValue }, 'change', groupId));
48
52
  triggerRadioChange(nextValue);
49
- }, [groupId, hasCheckedRadio, onChange, resolvedDisabled, selectedValue, triggerRadioChange]);
53
+ }, [groupId, hasCheckedRadio, onChange, resolvedDisabled, selectedValue, triggerRadioChange, updateForm]);
50
54
  const contextValue = useMemo(() => ({
51
55
  groupId,
52
56
  selectedValue,
@@ -61,7 +65,7 @@ export function RadioGroup(props) {
61
65
  };
62
66
  return (<RadioGroupRuntimeContext.Provider value={contextValue}>
63
67
  <view {...mapped}>
64
- <radio-group {...lynxGroupProps}>{children}</radio-group>
68
+ <radio-group {...lynxGroupProps}>{wrapTextNode(children)}</radio-group>
65
69
  </view>
66
70
  </RadioGroupRuntimeContext.Provider>);
67
71
  }
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from '@byted-doubao-apps/framework';
1
+ import type { ReactNode } from '@doubao-dev/framework';
2
2
  import type { RadioGroupProps as TaroRadioGroupProps } from '@tarojs/components';
3
3
  export type MappableTaroRadioGroupProps = Omit<TaroRadioGroupProps, 'children' | 'onChange'> & {
4
4
  disabled?: boolean;
@@ -0,0 +1,3 @@
1
+ import type { RichTextProps } from '@tarojs/components';
2
+ export declare function RichText({ id, className, style, nodes, space, onClick }: RichTextProps): any;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { RichText as SDKRichText } from '@doubao-dev/framework/components';
2
+ export function RichText({ id, className, style, nodes, space, onClick }) {
3
+ return (<view id={id} bindtap={onClick}>
4
+ <SDKRichText className={className} style={style} nodes={nodes} space={space}/>
5
+ </view>);
6
+ }
7
+ //# sourceMappingURL=index.jsx.map
@@ -1,9 +1,12 @@
1
1
  import type { NodesRef } from '@lynx-js/types';
2
2
  import type { ScrollViewProps as TaroScrollViewProps } from '@tarojs/components';
3
+ import type { AnimationData } from '../../api/create-animation.js';
3
4
  import { type ScrollViewEvent } from './map.js';
4
5
  type NativeScrollViewEventProps = {
5
6
  onContentSizeChanged?: (event: ScrollViewEvent) => void;
6
7
  };
7
- export declare const ScrollView: (props: TaroScrollViewProps & NativeScrollViewEventProps & import("react").RefAttributes<NodesRef>) => React.ReactElement | null;
8
+ export declare const ScrollView: (props: TaroScrollViewProps & NativeScrollViewEventProps & {
9
+ animation?: AnimationData;
10
+ } & import("react").RefAttributes<NodesRef>) => React.ReactElement | null;
8
11
  export {};
9
12
  //# sourceMappingURL=index.d.ts.map
@@ -1,12 +1,24 @@
1
- import { forwardRef, useCallback, useEffect, useRef } from '@byted-doubao-apps/framework';
2
- import { Text } from '../Text/index.jsx';
3
- import { mapScrollViewProps, toScrollViewEvent } from './map.js';
1
+ import { forwardRef, useCallback, useEffect, useRef } from '@doubao-dev/framework';
2
+ import { useAnimation } from '../../hooks/use-animation.js';
3
+ import { useQueryNodeProps } from '../../internal/query-node.js';
4
+ import { wrapTextNode } from '../base/wrap-text-node.jsx';
5
+ import { mapScrollViewProps, toRefresherEvent, toScrollViewEvent } from './map.js';
6
+ import { ScrollViewRefresh } from './refresh.jsx';
7
+ import { supportsNativeRefresh } from './use-refresher.js';
4
8
  export const ScrollView = forwardRef(ScrollViewImpl);
5
9
  function ScrollViewImpl(props, ref) {
6
- const { children, onScrollToUpper, onScrollToLower, onScroll, onScrollEnd, onContentSizeChanged, ...nonEventProps } = props;
10
+ const { animation, children, onScrollToUpper, onScrollToLower, onScroll, onScrollEnd, onContentSizeChanged, refresherEnabled, refresherTriggered, onRefresherPulling, onRefresherRefresh, onRefresherRestore, onRefresherAbort, ...nonEventProps } = props;
11
+ useQueryNodeProps(nonEventProps.id, { scrollX: false, scrollY: false, ...props });
12
+ const animationBindings = useAnimation(animation);
7
13
  const { mapped, scrollViewId, scrollOffset, scrollWithAnimation } = mapScrollViewProps(nonEventProps);
8
14
  const scrollViewRef = useRef(null);
9
15
  const previousScrollOffsetRef = useRef(scrollOffset);
16
+ const refreshConfigured = useRef(false);
17
+ if (refresherEnabled !== undefined || refresherTriggered !== undefined) {
18
+ refreshConfigured.current = true;
19
+ }
20
+ const withRefresh = supportsNativeRefresh && refreshConfigured.current;
21
+ const scrollProps = mapped;
10
22
  const assignRef = useCallback((instance) => {
11
23
  scrollViewRef.current = instance;
12
24
  assignForwardedRef(ref, instance);
@@ -17,6 +29,11 @@ function ScrollViewImpl(props, ref) {
17
29
  return;
18
30
  }
19
31
  previousScrollOffsetRef.current = scrollOffset;
32
+ // Consume offset changes while an anchor owns the position. Clearing the
33
+ // anchor later must not replay an old scrollTop/scrollLeft command.
34
+ if (nonEventProps.scrollIntoView) {
35
+ return;
36
+ }
20
37
  scrollViewRef.current
21
38
  ?.invoke({
22
39
  method: 'scrollTo',
@@ -26,7 +43,7 @@ function ScrollViewImpl(props, ref) {
26
43
  }
27
44
  })
28
45
  .exec();
29
- }, [scrollOffset, scrollWithAnimation]);
46
+ }, [scrollOffset, scrollWithAnimation, nonEventProps.scrollIntoView]);
30
47
  const handleScrollToUpper = useCallback((event) => {
31
48
  onScrollToUpper?.(toScrollViewEvent(event, 'scrolltoupper', scrollViewId));
32
49
  }, [onScrollToUpper, scrollViewId]);
@@ -42,18 +59,31 @@ function ScrollViewImpl(props, ref) {
42
59
  const handleContentSizeChanged = useCallback((event) => {
43
60
  onContentSizeChanged?.(toScrollViewEvent(event, 'contentsizechanged', scrollViewId));
44
61
  }, [onContentSizeChanged, scrollViewId]);
45
- return (<scroll-view {...mapped} ref={assignRef} {...(onScrollToUpper ? { onScrollToUpper: handleScrollToUpper } : {})} {...(onScrollToLower ? { onScrollToLower: handleScrollToLower } : {})} {...(onScroll ? { onScroll: handleScroll } : {})} {...(onScrollEnd ? { onScrollEnd: handleScrollEnd } : {})} {...(onContentSizeChanged ? { onContentSizeChanged: handleContentSizeChanged } : {})}>
62
+ const handleRefresher = (event) => {
63
+ const handlers = {
64
+ refresherpulling: onRefresherPulling,
65
+ refresherrefresh: onRefresherRefresh,
66
+ refresherrestore: onRefresherRestore,
67
+ refresherabort: onRefresherAbort
68
+ };
69
+ handlers[event.type]?.(toRefresherEvent(event, scrollViewId));
70
+ };
71
+ const scrollView = (<scroll-view {...scrollProps} {...animationBindings} ref={assignRef} className={withRefresh ? undefined : scrollProps.className} style={withRefresh ? { width: '100%', height: '100%', minWidth: 0, minHeight: 0 } : scrollProps.style} {...(onScrollToUpper ? { onScrollToUpper: handleScrollToUpper } : {})} {...(onScrollToLower ? { onScrollToLower: handleScrollToLower } : {})} {...(onScroll ? { onScroll: handleScroll } : {})} {...(onScrollEnd ? { onScrollEnd: handleScrollEnd } : {})} {...(onContentSizeChanged ? { onContentSizeChanged: handleContentSizeChanged } : {})}>
46
72
  {wrapTextNode(children)}
47
73
  </scroll-view>);
48
- }
49
- function wrapTextNode(child) {
50
- if (typeof child === 'string' || typeof child === 'number') {
51
- return <Text>{child}</Text>;
52
- }
53
- if (Array.isArray(child)) {
54
- return child.map((item) => wrapTextNode(item));
74
+ if (!withRefresh) {
75
+ return scrollView;
55
76
  }
56
- return child;
77
+ return (<ScrollViewRefresh style={scrollProps.style} className={scrollProps.className} enabled={refresherEnabled === true && scrollProps.scrollOrientation === 'vertical'} scrollProps={scrollProps} refresh={{
78
+ id: scrollViewId,
79
+ refresherTriggered,
80
+ onRefresherPulling: onRefresherPulling ? handleRefresher : undefined,
81
+ onRefresherRefresh: onRefresherRefresh ? handleRefresher : undefined,
82
+ onRefresherRestore: onRefresherRestore ? handleRefresher : undefined,
83
+ onRefresherAbort: onRefresherAbort ? handleRefresher : undefined
84
+ }}>
85
+ {scrollView}
86
+ </ScrollViewRefresh>);
57
87
  }
58
88
  function assignForwardedRef(ref, value) {
59
89
  if (typeof ref === 'function') {
@@ -1,5 +1,6 @@
1
1
  import type { ContentSizeChangedEvent as LynxContentSizeChangedEvent, ScrollEndEvent as LynxScrollEndEvent, ScrollEvent as LynxScrollEvent, ScrollToLowerEvent as LynxScrollToLowerEvent, ScrollToUpperEvent as LynxScrollToUpperEvent } from '@lynx-js/types';
2
2
  import type { ScrollViewProps as TaroScrollViewProps } from '@tarojs/components';
3
+ import type { RefresherEvent } from './refresh-types.js';
3
4
  type ScrollOrientation = 'vertical' | 'horizontal';
4
5
  type LynxScrollViewEvent = LynxScrollToUpperEvent | LynxScrollToLowerEvent | LynxScrollEvent | LynxScrollEndEvent | LynxContentSizeChangedEvent;
5
6
  export type MappableTaroScrollViewProps = Omit<TaroScrollViewProps, 'children' | 'onScrollToUpper' | 'onScrollToLower' | 'onScroll' | 'onScrollEnd'> & {
@@ -11,7 +12,7 @@ export type MappableTaroScrollViewProps = Omit<TaroScrollViewProps, 'children' |
11
12
  onContentSizeChanged?: (event: ScrollViewEvent) => void;
12
13
  };
13
14
  export type ScrollViewEventDetail = TaroScrollViewProps.onScrollDetail;
14
- export type ScrollViewEvent = {
15
+ export type ScrollViewEvent<Detail = ScrollViewEventDetail> = {
15
16
  type: string;
16
17
  timeStamp: number;
17
18
  target: {
@@ -24,7 +25,7 @@ export type ScrollViewEvent = {
24
25
  tagName: string;
25
26
  dataset: Record<string, unknown>;
26
27
  };
27
- detail: ScrollViewEventDetail;
28
+ detail: Detail;
28
29
  preventDefault: () => void;
29
30
  stopPropagation: () => void;
30
31
  };
@@ -37,5 +38,6 @@ type MapScrollViewPropsResult = {
37
38
  export declare function mapScrollViewProps(props: MappableTaroScrollViewProps): MapScrollViewPropsResult;
38
39
  export declare function toScrollViewEvent(event: LynxScrollViewEvent, type: string, scrollViewId: string): ScrollViewEvent;
39
40
  export declare function toScrollViewEventDetail(event: LynxScrollViewEvent): ScrollViewEventDetail;
41
+ export declare function toRefresherEvent(event: RefresherEvent, scrollViewId: string): ScrollViewEvent<RefresherEvent['detail']>;
40
42
  export {};
41
43
  //# sourceMappingURL=map.d.ts.map
@@ -1,5 +1,5 @@
1
1
  export function mapScrollViewProps(props) {
2
- const { id, className, style, scrollX, scrollY, scrollTop, scrollLeft, scrollWithAnimation, scrollOrientation, enableScroll, scrollBarEnable, showScrollbar, upperThreshold, lowerThreshold, bounces, initialScrollOffset, initialScrollToIndex } = props;
2
+ const { id, className, style, scrollX, scrollY, scrollTop, scrollLeft, scrollWithAnimation, scrollIntoView, scrollOrientation, enableScroll, scrollBarEnable, showScrollbar, upperThreshold, lowerThreshold, bounces, initialScrollOffset, initialScrollToIndex } = props;
3
3
  const orientation = scrollOrientation ?? (scrollX ? 'horizontal' : 'vertical');
4
4
  const scrollOffset = orientation === 'horizontal' ? scrollLeft : scrollTop;
5
5
  const resolvedInitialScrollOffset = initialScrollOffset ?? scrollOffset;
@@ -8,6 +8,8 @@ export function mapScrollViewProps(props) {
8
8
  className,
9
9
  style,
10
10
  bounces,
11
+ ...(scrollIntoView !== undefined ? { scrollIntoView } : {}),
12
+ ...(scrollWithAnimation !== undefined ? { scrollWithAnimation } : {}),
11
13
  upperThreshold,
12
14
  lowerThreshold,
13
15
  scrollBarEnable: scrollBarEnable ?? showScrollbar,
@@ -16,6 +18,11 @@ export function mapScrollViewProps(props) {
16
18
  enableScroll: enableScroll ?? Boolean(scrollX || scrollY),
17
19
  initialScrollOffset: resolvedInitialScrollOffset
18
20
  };
21
+ for (const [key, value] of Object.entries(props)) {
22
+ if (key.startsWith('data-')) {
23
+ mapped[key] = value;
24
+ }
25
+ }
19
26
  return {
20
27
  mapped,
21
28
  scrollViewId: String(mapped.id ?? ''),
@@ -55,5 +62,16 @@ function toEventTarget(target, fallbackId) {
55
62
  dataset: target.dataset ?? {}
56
63
  };
57
64
  }
65
+ export function toRefresherEvent(event, scrollViewId) {
66
+ return {
67
+ type: event.type,
68
+ timeStamp: event.timestamp ?? Date.now(),
69
+ target: toEventTarget(event.target, scrollViewId),
70
+ currentTarget: toEventTarget(event.currentTarget, scrollViewId),
71
+ detail: event.detail,
72
+ preventDefault: noop,
73
+ stopPropagation: noop
74
+ };
75
+ }
58
76
  function noop() { }
59
77
  //# sourceMappingURL=map.js.map
@@ -0,0 +1,25 @@
1
+ import type { BaseEvent } from '@lynx-js/types';
2
+ type RefresherTarget = Pick<BaseEvent['target'], 'id' | 'dataset'>;
3
+ type RefresherEventBase = BaseEvent<'refresherpulling' | 'refresherrefresh' | 'refresherrestore' | 'refresherabort', {
4
+ /** 是否由用户手势触发刷新,仅 refresh 事件提供。 */
5
+ isManual?: boolean;
6
+ /** 是否正在拖动,仅 pulling 事件提供。 */
7
+ isDragging?: boolean;
8
+ /** 下拉距离相对刷新头高度的比例,仅 pulling 事件提供。 */
9
+ offsetPercent?: number;
10
+ }>;
11
+ /** 下拉刷新事件。事件目标包含所属 ScrollView 的 id 和 dataset。 */
12
+ export type RefresherEvent = Omit<RefresherEventBase, 'target' | 'currentTarget'> & {
13
+ target: RefresherTarget;
14
+ currentTarget: RefresherTarget;
15
+ };
16
+ export interface ScrollViewRefreshProps {
17
+ id?: string;
18
+ refresherTriggered?: boolean;
19
+ onRefresherPulling?: (event: RefresherEvent) => void;
20
+ onRefresherRefresh?: (event: RefresherEvent) => void;
21
+ onRefresherRestore?: (event: RefresherEvent) => void;
22
+ onRefresherAbort?: (event: RefresherEvent) => void;
23
+ }
24
+ export {};
25
+ //# sourceMappingURL=refresh-types.d.ts.map