@conecli/cone-render 0.10.1-shop3.72 → 0.10.1-shop3.73

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.
@@ -1 +1 @@
1
- import React, { useState, useMemo, useRef, useCallback } from 'react';
2
1
  const {
3
2
  style,
4
3
  dataDefines,
5
4
  containerBorderRadius,
6
5
  floorData,
7
6
  isRealTimeRender,
8
7
  forceRenderTime,
9
8
  containerIndex = 0,
10
9
  } = props;
11
10
  const domRef = useRef<HTMLDivElement>(null);
12
11
  const [wrapperHeight, setWrapperHeight] = useState<number | string>('auto');
13
12
  const hasBeenInViewRef = useRef(false);
14
13
 
15
14
  const handleInViewCallback = useCallback(() => {
16
15
  if (!hasBeenInViewRef.current) {
17
16
  hasBeenInViewRef.current = true;
18
17
  setWrapperHeight('auto');
19
18
  }
20
19
  }, [containerIndex]);
21
20
 
22
21
  const handleOutViewCallback = useCallback(() => {
23
22
  if (hasBeenInViewRef.current && domRef.current) {
24
23
  hasBeenInViewRef.current = false;
25
24
  const height = domRef.current.getBoundingClientRect().height;
26
25
  if (height > 0) {
27
26
  setWrapperHeight(height);
28
27
  }
29
28
  }
30
29
  }, [containerIndex]);
31
30
  const getRenderRealTimeKeyObj = useMemo(() => {
32
31
  return {
33
32
  key: isRealTimeRender ? Date.now() : forceRenderTime,
34
33
  };
35
34
  }, [isRealTimeRender, forceRenderTime]);
36
35
  const innerStyle = useMemo(() => {
37
36
  const baseStyle = style || {};
38
37
  let borderRadius = {};
39
38
  if (typeof containerBorderRadius === 'number') {
40
39
  borderRadius = { borderRadius: containerBorderRadius + 'px' };
41
40
  } else if (containerBorderRadius && typeof containerBorderRadius === 'object') {
42
41
  borderRadius = containerBorderRadius;
43
42
  }
44
43
  if (typeof wrapperHeight === 'number') {
45
44
  return {
46
45
  ...baseStyle,
47
46
  ...borderRadius,
48
47
  height: `${wrapperHeight}px`,
49
48
  overflow: 'hidden',
50
49
  contentVisibility: 'auto',
51
50
  containIntrinsicSize: `${wrapperHeight}px`,
52
51
  };
53
52
  }
54
53
  return { ...baseStyle, ...borderRadius };
55
54
  }, [containerBorderRadius, wrapperHeight]);
56
55
  return (
57
56
  <InOrOutViewObserver
58
57
  inViewCallback={handleInViewCallback}
59
58
  outViewCallback={handleOutViewCallback}
60
59
  threshold={0}
61
60
  >
62
61
  <View ref={domRef} style={innerStyle} className={floorStyle['wrap']}>
63
62
  {floorData?.showCommonFloorHead === false ? null : (
64
63
  <CommonFloorHead
65
64
  dataDefines={dataDefines}
66
65
  floorData={floorData}
67
66
  {...getRenderRealTimeKeyObj}
68
67
  />
69
68
  )}
70
69
  {props.children &&
71
70
  React.cloneElement(props.children, {
72
71
  dataDefines: dataDefines,
73
72
  ...getRenderRealTimeKeyObj,
74
73
  })}
75
74
  </View>
76
75
  </InOrOutViewObserver>
77
76
  );
78
77
  isRealTimeRender: false,
79
78
  forceRenderTime: 1,
79
+ import React, { useState, useMemo, useRef, useCallback } from 'react';
80
80
  const {
81
81
  style,
82
82
  dataDefines,
83
83
  containerBorderRadius,
84
84
  floorData,
85
85
  isRealTimeRender,
86
86
  forceRenderTime,
87
87
  containerIndex = 0,
88
88
  } = props;
89
89
  const domRef = useRef<HTMLDivElement>(null);
90
90
  const [wrapperHeight, setWrapperHeight] = useState<number | string>('auto');
91
91
  const hasBeenInViewRef = useRef(false);
92
92
 
93
93
  const globalSwitch = useMemo(() => {
94
94
  let contentVisibilityShieldAll = true;
95
95
  let contentVisibilityShieldModuleId: number[] = [];
96
96
  if (window.shopGlobalSwitch) {
97
97
  contentVisibilityShieldAll =
98
98
  typeof window.shopGlobalSwitch.contentVisibilityShieldAll === 'boolean'
99
99
  ? window.shopGlobalSwitch.contentVisibilityShieldAll
100
100
  : true;
101
101
  contentVisibilityShieldModuleId = Array.isArray(
102
102
  window.shopGlobalSwitch.contentVisibilityShieldModuleId,
103
103
  )
104
104
  ? window.shopGlobalSwitch.contentVisibilityShieldModuleId
105
105
  : [];
106
106
  }
107
107
  return { contentVisibilityShieldAll, contentVisibilityShieldModuleId };
108
108
  }, []);
109
109
 
110
110
  const handleInViewCallback = useCallback(() => {
111
111
  if (globalSwitch.contentVisibilityShieldAll) return;
112
112
  if (
113
113
  floorData.moduleId &&
114
114
  globalSwitch.contentVisibilityShieldModuleId.indexOf(floorData.moduleId) > -1
115
115
  ) {
116
116
  return;
117
117
  }
118
118
  if (!hasBeenInViewRef.current) {
119
119
  hasBeenInViewRef.current = true;
120
120
  setWrapperHeight('auto');
121
121
  }
122
122
  }, [containerIndex]);
123
123
 
124
124
  const handleOutViewCallback = useCallback(() => {
125
125
  if (globalSwitch.contentVisibilityShieldAll) return;
126
126
  if (
127
127
  floorData.moduleId &&
128
128
  globalSwitch.contentVisibilityShieldModuleId.indexOf(floorData.moduleId) > -1
129
129
  ) {
130
130
  return;
131
131
  }
132
132
  if (hasBeenInViewRef.current && domRef.current) {
133
133
  hasBeenInViewRef.current = false;
134
134
  const height = domRef.current.getBoundingClientRect().height;
135
135
  if (height > 0) {
136
136
  setWrapperHeight(height);
137
137
  }
138
138
  }
139
139
  }, [containerIndex]);
140
140
  const getRenderRealTimeKeyObj = useMemo(() => {
141
141
  return {
142
142
  key: isRealTimeRender ? Date.now() : forceRenderTime,
143
143
  };
144
144
  }, [isRealTimeRender, forceRenderTime]);
145
145
  const innerStyle = useMemo(() => {
146
146
  const baseStyle = style || {};
147
147
  let borderRadius = {};
148
148
  if (typeof containerBorderRadius === 'number') {
149
149
  borderRadius = { borderRadius: containerBorderRadius + 'px' };
150
150
  } else if (containerBorderRadius && typeof containerBorderRadius === 'object') {
151
151
  borderRadius = containerBorderRadius;
152
152
  }
153
153
  if (typeof wrapperHeight === 'number') {
154
154
  return {
155
155
  ...baseStyle,
156
156
  ...borderRadius,
157
157
  height: `${wrapperHeight}px`,
158
158
  overflow: 'hidden',
159
159
  contentVisibility: 'auto',
160
160
  containIntrinsicSize: `${wrapperHeight}px`,
161
161
  };
162
162
  }
163
163
  return { ...baseStyle, ...borderRadius };
164
164
  }, [containerBorderRadius, wrapperHeight]);
165
165
  return (
166
166
  <InOrOutViewObserver
167
167
  inViewCallback={handleInViewCallback}
168
168
  outViewCallback={handleOutViewCallback}
169
169
  threshold={0}
170
170
  >
171
171
  <View ref={domRef} style={innerStyle} className={floorStyle['wrap']}>
172
172
  {floorData?.showCommonFloorHead === false ? null : (
173
173
  <CommonFloorHead
174
174
  dataDefines={dataDefines}
175
175
  floorData={floorData}
176
176
  {...getRenderRealTimeKeyObj}
177
177
  />
178
178
  )}
179
179
  {props.children &&
180
180
  React.cloneElement(props.children, {
181
181
  dataDefines: dataDefines,
182
182
  ...getRenderRealTimeKeyObj,
183
183
  })}
184
184
  </View>
185
185
  </InOrOutViewObserver>
186
186
  );
187
187
  isRealTimeRender: false,
188
188
  forceRenderTime: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conecli/cone-render",
3
- "version": "0.10.1-shop3.72",
3
+ "version": "0.10.1-shop3.73",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist/"