@mpxjs/webpack-plugin 2.8.25-alpha.21 → 2.8.25-alpha.22

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 (72) hide show
  1. package/lib/runtime/components/react/dist/KeyboardAvoidingView.jsx +89 -0
  2. package/lib/runtime/components/react/dist/context.js +14 -0
  3. package/lib/runtime/components/react/dist/event.config.js +27 -0
  4. package/lib/runtime/components/react/dist/getInnerListeners.js +262 -0
  5. package/lib/runtime/components/react/dist/mpx-button.jsx +271 -0
  6. package/lib/runtime/components/react/dist/mpx-canvas/Bus.js +60 -0
  7. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.js +15 -0
  8. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.js +84 -0
  9. package/lib/runtime/components/react/dist/mpx-canvas/Image.js +87 -0
  10. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.js +15 -0
  11. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.js +28 -0
  12. package/lib/runtime/components/react/dist/mpx-canvas/html.js +341 -0
  13. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +236 -0
  14. package/lib/runtime/components/react/dist/mpx-canvas/utils.jsx +89 -0
  15. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +90 -0
  16. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +131 -0
  17. package/lib/runtime/components/react/dist/mpx-form.jsx +68 -0
  18. package/lib/runtime/components/react/dist/mpx-icon/icons/cancel.png +0 -0
  19. package/lib/runtime/components/react/dist/mpx-icon/icons/clear.png +0 -0
  20. package/lib/runtime/components/react/dist/mpx-icon/icons/download.png +0 -0
  21. package/lib/runtime/components/react/dist/mpx-icon/icons/info.png +0 -0
  22. package/lib/runtime/components/react/dist/mpx-icon/icons/search.png +0 -0
  23. package/lib/runtime/components/react/dist/mpx-icon/icons/success.png +0 -0
  24. package/lib/runtime/components/react/dist/mpx-icon/icons/success_no_circle.png +0 -0
  25. package/lib/runtime/components/react/dist/mpx-icon/icons/waiting.png +0 -0
  26. package/lib/runtime/components/react/dist/mpx-icon/icons/warn.png +0 -0
  27. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +50 -0
  28. package/lib/runtime/components/react/dist/mpx-image.jsx +292 -0
  29. package/lib/runtime/components/react/dist/mpx-input.jsx +292 -0
  30. package/lib/runtime/components/react/dist/mpx-label.jsx +52 -0
  31. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +32 -0
  32. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +468 -0
  33. package/lib/runtime/components/react/dist/mpx-navigator.jsx +33 -0
  34. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +74 -0
  35. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +141 -0
  36. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +147 -0
  37. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +99 -0
  38. package/lib/runtime/components/react/dist/mpx-picker/regionData.js +6099 -0
  39. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +81 -0
  40. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +242 -0
  41. package/lib/runtime/components/react/dist/mpx-picker/type.js +1 -0
  42. package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +35 -0
  43. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +193 -0
  44. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +125 -0
  45. package/lib/runtime/components/react/dist/mpx-portal/index.jsx +30 -0
  46. package/lib/runtime/components/react/dist/mpx-portal/portal-host.jsx +112 -0
  47. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +41 -0
  48. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +86 -0
  49. package/lib/runtime/components/react/dist/mpx-radio.jsx +140 -0
  50. package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
  51. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +62 -0
  52. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +17 -0
  53. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +372 -0
  54. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
  55. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +59 -0
  56. package/lib/runtime/components/react/dist/mpx-swiper.jsx +671 -0
  57. package/lib/runtime/components/react/dist/mpx-switch.jsx +97 -0
  58. package/lib/runtime/components/react/dist/mpx-text.jsx +41 -0
  59. package/lib/runtime/components/react/dist/mpx-textarea.jsx +40 -0
  60. package/lib/runtime/components/react/dist/mpx-video.jsx +248 -0
  61. package/lib/runtime/components/react/dist/mpx-view.jsx +611 -0
  62. package/lib/runtime/components/react/dist/mpx-web-view.jsx +289 -0
  63. package/lib/runtime/components/react/dist/parser.js +218 -0
  64. package/lib/runtime/components/react/dist/pickerFaces.js +76 -0
  65. package/lib/runtime/components/react/dist/pickerVIewContext.js +14 -0
  66. package/lib/runtime/components/react/dist/pickerViewIndicator.jsx +23 -0
  67. package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
  68. package/lib/runtime/components/react/dist/useAnimationHooks.js +346 -0
  69. package/lib/runtime/components/react/dist/useNodesRef.js +16 -0
  70. package/lib/runtime/components/react/dist/utils.jsx +599 -0
  71. package/package.json +6 -3
  72. package/LICENSE +0 -433
@@ -0,0 +1,141 @@
1
+ import { View } from 'react-native';
2
+ import React, { forwardRef, useRef, useContext, useState } from 'react';
3
+ import { warn } from '@mpxjs/utils';
4
+ import useInnerProps, { getCustomEvent } from '../getInnerListeners';
5
+ import useNodesRef from '../useNodesRef'; // 引入辅助函数
6
+ import Selector from './selector';
7
+ import TimeSelector from './time';
8
+ import DateSelector from './date';
9
+ import MultiSelector from './multiSelector';
10
+ import RegionSelector from './region';
11
+ import { FormContext } from '../context';
12
+ /**
13
+ * ✔ mode
14
+ * ✔ disabled
15
+ * ✔ bindcancel
16
+ * ✔ bindchange
17
+ * ✔ range
18
+ * ✔ range-key
19
+ * ✔ value
20
+ * ✔ start
21
+ * ✔ end
22
+ * ✔ fields 有效值 year,month,day,表示选择器的粒度
23
+ * ✔ end
24
+ * ✔ custom-item
25
+ * ✔ level 选择器层级 province,city,region,<sub-district不支持>
26
+ * ✔ level
27
+ * ✘ header-text
28
+ * ✘ bindcolumnchange
29
+ */
30
+ const _Picker = forwardRef((props, ref) => {
31
+ const { mode = 'selector', value, bindcancel, bindchange, children, bindcolumnchange, style } = props;
32
+ const innerLayout = useRef({});
33
+ const nodeRef = useRef(null);
34
+ useNodesRef(props, ref, nodeRef, {
35
+ style
36
+ });
37
+ const innerProps = useInnerProps(props, {
38
+ ref: nodeRef
39
+ }, [], { layoutRef: innerLayout });
40
+ const [pickerValue, setPickerValue] = useState(value);
41
+ const defaultValues = {
42
+ selector: 0,
43
+ multiSelector: [0],
44
+ time: props.start,
45
+ date: props.start,
46
+ region: undefined
47
+ };
48
+ const formContext = useContext(FormContext);
49
+ let formValuesMap;
50
+ // 判断 context 是否存在,存在的话读取 context 中存的 formValuesMap
51
+ if (formContext) {
52
+ formValuesMap = formContext.formValuesMap;
53
+ }
54
+ const resetValue = () => {
55
+ const defalutValue = (defaultValues[mode] !== undefined ? defaultValues[mode] : value);
56
+ setPickerValue(defalutValue);
57
+ };
58
+ const getValue = () => {
59
+ return pickerValue;
60
+ };
61
+ if (formValuesMap) {
62
+ if (!props.name) {
63
+ warn('If a form component is used, the name attribute is required.');
64
+ }
65
+ else {
66
+ formValuesMap.set(props.name, { getValue, resetValue });
67
+ }
68
+ }
69
+ const getInnerLayout = (layout) => {
70
+ innerLayout.current = layout.current;
71
+ };
72
+ const onChange = (event) => {
73
+ const eventData = getCustomEvent('change', {}, { detail: event.detail, layoutRef: innerLayout });
74
+ bindchange && bindchange(eventData);
75
+ setPickerValue(event.detail.value);
76
+ };
77
+ const columnChange = (value, index) => {
78
+ // type: "columnchange", detail: {column: 1, value: 2}
79
+ const eventData = getCustomEvent('columnchange', {}, { detail: { column: index, value }, layoutRef: innerLayout });
80
+ bindcolumnchange && bindcolumnchange(eventData);
81
+ };
82
+ const commonProps = {
83
+ ...innerProps,
84
+ mode,
85
+ children,
86
+ bindchange: onChange,
87
+ bindcolumnchange: columnChange,
88
+ bindcancel,
89
+ getInnerLayout
90
+ };
91
+ const selectorProps = {
92
+ ...commonProps,
93
+ value: pickerValue,
94
+ range: props.range,
95
+ 'range-key': props['range-key']
96
+ };
97
+ const multiProps = {
98
+ ...commonProps,
99
+ value: pickerValue,
100
+ range: props.range,
101
+ 'range-key': props['range-key']
102
+ };
103
+ const timeProps = {
104
+ ...commonProps,
105
+ value: pickerValue,
106
+ start: props.start,
107
+ end: props.end
108
+ };
109
+ const dateProps = {
110
+ ...commonProps,
111
+ value: pickerValue,
112
+ start: props.start,
113
+ end: props.end,
114
+ fileds: props.fields || 'day'
115
+ };
116
+ const regionProps = {
117
+ ...commonProps,
118
+ value: pickerValue,
119
+ level: props.level || 'sub-district'
120
+ };
121
+ if (mode === 'selector') {
122
+ return <Selector {...selectorProps}></Selector>;
123
+ }
124
+ else if (mode === 'multiSelector') {
125
+ return <MultiSelector {...multiProps}></MultiSelector>;
126
+ }
127
+ else if (mode === 'time') {
128
+ return <TimeSelector {...timeProps}></TimeSelector>;
129
+ }
130
+ else if (mode === 'date') {
131
+ return <DateSelector {...dateProps}></DateSelector>;
132
+ }
133
+ else if (mode === 'region') {
134
+ return <RegionSelector {...regionProps}></RegionSelector>;
135
+ }
136
+ else {
137
+ return <View>只支持selector, multiSelector, time, date, region 这些类型</View>;
138
+ }
139
+ });
140
+ _Picker.displayName = 'mpx-picker';
141
+ export default _Picker;
@@ -0,0 +1,147 @@
1
+ import { View, TouchableWithoutFeedback } from 'react-native';
2
+ import { Picker } from '@ant-design/react-native';
3
+ import React, { forwardRef, useState, useRef, useEffect } from 'react';
4
+ import useNodesRef from '../useNodesRef'; // 引入辅助函数
5
+ function convertToObj(item, rangeKey = '') {
6
+ if (typeof item === 'object') {
7
+ return { value: item[rangeKey], label: item[rangeKey] };
8
+ }
9
+ else {
10
+ return { value: item, label: item };
11
+ }
12
+ }
13
+ // eslint-disable-next-line default-param-last
14
+ function formatRangeFun(range = [], rangeKey) {
15
+ const result = (range[0] || []).map(item => {
16
+ return convertToObj(item, rangeKey);
17
+ });
18
+ let tmp = result;
19
+ for (let i = 1; i < range.length; i++) {
20
+ const child = Array.isArray(range[i]) ? range[i] : [];
21
+ const nextColData = child.map(item => {
22
+ return convertToObj(item, rangeKey);
23
+ });
24
+ tmp.forEach(item => {
25
+ item.children = nextColData;
26
+ });
27
+ tmp = nextColData;
28
+ }
29
+ return result;
30
+ }
31
+ function getIndexByValues(range = [], value = []) {
32
+ let tmp = range;
33
+ return value.map(v => {
34
+ for (let i = 0; i < tmp.length; i++) {
35
+ if (tmp[i].value === v) {
36
+ tmp = tmp[i].children || [];
37
+ return i;
38
+ }
39
+ }
40
+ return 0;
41
+ });
42
+ }
43
+ // [1,1,2] 寻找出[]
44
+ function getInnerValueByIndex(range = [], value = []) {
45
+ let tmp = range;
46
+ return value.map(v => {
47
+ const current = tmp[v].value;
48
+ tmp = tmp[v].children;
49
+ return current;
50
+ });
51
+ }
52
+ // column = 1 value = ['无脊柱动物', '扁性动物', '吸血虫'] 根据column 和value 获取到当前列变动选择的值所在当前列的索引
53
+ function getColumnIndexByValue(range = [], column, value = []) {
54
+ let curRange = range;
55
+ let changeIndex = 0;
56
+ let tmpRange = [];
57
+ value.map((item, index) => {
58
+ if (column === index) {
59
+ curRange.map((ritem, rindex) => {
60
+ if (ritem.value === item) {
61
+ changeIndex = rindex;
62
+ }
63
+ return ritem;
64
+ });
65
+ }
66
+ else {
67
+ curRange.map((citem, cindex) => {
68
+ if (citem.value === item) {
69
+ tmpRange = citem.children;
70
+ }
71
+ return citem;
72
+ });
73
+ curRange = tmpRange;
74
+ }
75
+ return item;
76
+ });
77
+ return changeIndex;
78
+ }
79
+ const _MultiSelectorPicker = forwardRef((props, ref) => {
80
+ const { range, value, disabled, bindchange, bindcancel, children, bindcolumnchange, style } = props;
81
+ const formatRange = formatRangeFun(range, props['range-key']);
82
+ const initValue = getInnerValueByIndex(formatRange, value);
83
+ // 选中的索引值
84
+ const [selected, setSelected] = useState(initValue);
85
+ // range数据源
86
+ const [data, setData] = useState(formatRange || []);
87
+ // 存储layout布局信息
88
+ const layoutRef = useRef({});
89
+ const viewRef = useRef(null);
90
+ const nodeRef = useRef(null);
91
+ useNodesRef(props, ref, nodeRef, {
92
+ style
93
+ });
94
+ useEffect(() => {
95
+ if (range) {
96
+ const newFormatRange = formatRangeFun(range, props['range-key']);
97
+ setData(newFormatRange);
98
+ }
99
+ const newValue = getInnerValueByIndex(formatRange, value);
100
+ value && setSelected(newValue);
101
+ }, [range, value]);
102
+ const onChange = (value) => {
103
+ // e.detail.value 都是索引multi
104
+ const strIndex = getIndexByValues(data, value);
105
+ bindchange && bindchange({
106
+ detail: {
107
+ value: strIndex
108
+ }
109
+ });
110
+ };
111
+ const onPickerChange = (value, column) => {
112
+ // onPickerChange--- ["无脊柱动物", "节肢动物", "吸血虫"] 1 拿着column
113
+ const changeIndex = getColumnIndexByValue(data, column, value);
114
+ bindcolumnchange && bindcolumnchange(changeIndex, column);
115
+ };
116
+ const onElementLayout = () => {
117
+ viewRef.current?.measure((x, y, width, height, offsetLeft, offsetTop) => {
118
+ layoutRef.current = { x, y, width, height, offsetLeft, offsetTop };
119
+ props.getInnerLayout && props.getInnerLayout(layoutRef);
120
+ });
121
+ };
122
+ const antPickerProps = {
123
+ ref: nodeRef,
124
+ data,
125
+ value: selected,
126
+ cols: range.length,
127
+ defaultValue: initValue,
128
+ disabled,
129
+ itemHeight: 40,
130
+ onChange,
131
+ onDismiss: bindcancel && bindcancel,
132
+ onPickerChange: onPickerChange
133
+ };
134
+ const touchProps = {
135
+ onLayout: onElementLayout,
136
+ ref: viewRef
137
+ };
138
+ return (<Picker {...antPickerProps}>
139
+ <TouchableWithoutFeedback>
140
+ <View {...touchProps}>
141
+ {children}
142
+ </View>
143
+ </TouchableWithoutFeedback>
144
+ </Picker>);
145
+ });
146
+ _MultiSelectorPicker.displayName = 'mpx-picker-multiselector';
147
+ export default _MultiSelectorPicker;
@@ -0,0 +1,99 @@
1
+ import { View, TouchableWithoutFeedback } from 'react-native';
2
+ import { Picker } from '@ant-design/react-native';
3
+ import { regionData } from './regionData';
4
+ import React, { forwardRef, useState, useRef } from 'react';
5
+ import useNodesRef from '../useNodesRef'; // 引入辅助函数
6
+ function formateRegionData(clObj = [], customItem, depth = 2) {
7
+ const l = depth;
8
+ // 'PickerData[]' is not assignable to type 'PickerColumn | PickerColumn[]'.
9
+ // const obj: PickerColumnItem[] = []
10
+ const obj = [];
11
+ if (customItem) {
12
+ const objClone = {
13
+ value: customItem,
14
+ label: customItem,
15
+ children: []
16
+ };
17
+ const panding = { ...objClone };
18
+ let loop = panding;
19
+ while (depth-- > 0) {
20
+ loop.children = [{ ...objClone }];
21
+ loop = loop.children[0];
22
+ }
23
+ obj.push(panding);
24
+ }
25
+ for (let i = 0; i < clObj.length; i++) {
26
+ const region = {
27
+ value: clObj[i].value,
28
+ label: clObj[i].value
29
+ };
30
+ if (clObj[i].children) {
31
+ region.children = formateRegionData(clObj[i].children, customItem, l - 1);
32
+ }
33
+ obj.push(region);
34
+ }
35
+ return obj;
36
+ }
37
+ const _RegionPicker = forwardRef((props, ref) => {
38
+ const { children, value, bindchange, bindcancel, disabled, style } = props;
39
+ const formatRegionData = formateRegionData(regionData, props['custom-item']);
40
+ const [regionvalue, setRegionValue] = useState(value);
41
+ // 存储layout布局信息
42
+ const layoutRef = useRef({});
43
+ const viewRef = useRef(null);
44
+ const nodeRef = useRef(null);
45
+ useNodesRef(props, ref, nodeRef, {
46
+ style
47
+ });
48
+ const onChange = (value) => {
49
+ // 通过 value 查找 code
50
+ let tmp = regionData;
51
+ const postcode = [];
52
+ const code = value.map((item) => {
53
+ for (let i = 0; i < tmp.length; i++) {
54
+ if (tmp[i].value === item) {
55
+ const code = tmp[i].code;
56
+ postcode.push(tmp[i].postcode);
57
+ tmp = tmp[i].children || [];
58
+ return code;
59
+ }
60
+ }
61
+ return item;
62
+ }).filter(code => !!code);
63
+ const detail = { value, code };
64
+ if (postcode[2])
65
+ detail.postcode = postcode[2];
66
+ setRegionValue(value);
67
+ bindchange && bindchange({
68
+ detail
69
+ });
70
+ };
71
+ const onElementLayout = (layout) => {
72
+ viewRef.current?.measure((x, y, width, height, offsetLeft, offsetTop) => {
73
+ layoutRef.current = { x, y, width, height, offsetLeft, offsetTop };
74
+ props.getInnerLayout && props.getInnerLayout(layoutRef);
75
+ });
76
+ };
77
+ const onDismiss = () => {
78
+ bindcancel && bindcancel();
79
+ };
80
+ const regionProps = {
81
+ ref: nodeRef,
82
+ data: formatRegionData,
83
+ value: regionvalue,
84
+ onChange,
85
+ disabled,
86
+ onDismiss
87
+ };
88
+ const touchProps = {
89
+ onLayout: onElementLayout,
90
+ ref: viewRef
91
+ };
92
+ return (<Picker {...regionProps}>
93
+ <TouchableWithoutFeedback>
94
+ <View {...touchProps}>{children}</View>
95
+ </TouchableWithoutFeedback>
96
+ </Picker>);
97
+ });
98
+ _RegionPicker.displayName = 'mpx-picker-region';
99
+ export default _RegionPicker;