@conecli/cone-render 0.10.1-shop-beta.30 → 0.10.1-shop-beta.32

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 Taro from '@tarojs/taro';
2
1
  'app-activity',
3
2
  'app-rank',
4
3
  'app-seckill',
5
4
  'm-coupon',
6
5
  'scene-buy',
7
6
  'light-details',
8
7
  'member-paid-center',
9
8
  'member-paid-card',
10
9
  'member-paid-bind',
11
10
  'app-introduce',
12
11
  if (window?.shopGlobalSwitch?.openAccessibilityLanguage) {
13
12
  Taro.nextTick(() => {
14
13
  const htmlRoot = document?.documentElement;
15
14
  htmlRoot && htmlRoot.setAttribute('lang', isLanguageForEn ? 'en' : 'zh-CN');
16
15
  });
17
16
  }
18
17
  const mainConfig = {
19
18
  childList: true,
20
19
  subtree: true,
21
20
  attributes: true,
22
21
  attributeFilter: ['auto-accessible'],
23
22
  };
24
23
  const mainObserver = new MutationObserver(function (mutations) {
25
24
  mutations.forEach(function (mutation) {
26
25
  if (mutation.type === 'childList') {
27
26
  mutation.addedNodes.forEach(function (node) {
28
27
  if (node.nodeType === Node.ELEMENT_NODE) {
29
28
  if (node.hasAttribute && node.getAttribute('auto-accessible') === 'true') {
30
29
  updateAccessibilityLabel(node);
31
30
  }
32
31
  const accessibleElements = node.querySelectorAll
33
32
  ? node.querySelectorAll('[auto-accessible="true"]')
34
33
  : [];
35
34
  accessibleElements.forEach(function (el) {
36
35
  updateAccessibilityLabel(el);
37
36
  });
38
37
  }
39
38
  });
40
39
  }
41
40
  if (mutation.type === 'attributes' && mutation.attributeName === 'auto-accessible') {
42
41
  if (mutation.target.getAttribute('auto-accessible') === 'true') {
43
42
  updateAccessibilityLabel(mutation.target);
44
43
  }
45
44
  }
46
45
  });
47
46
  });
48
47
  mainObserver.observe(document.body, mainConfig);
49
48
  setupGlobalContentObserver();
50
49
  const contentConfig = {
51
50
  characterData: true,
52
51
  childList: true,
53
52
  subtree: true,
54
53
  };
55
54
  const lastUpdateTime = new WeakMap();
56
55
  const THROTTLE_DELAY = 2000;
57
56
 
58
57
  function shouldUpdate(element) {
59
58
  const now = Date.now();
60
59
  const lastTime = lastUpdateTime.get(element);
61
60
  if (!lastTime || now - lastTime >= THROTTLE_DELAY) {
62
61
  lastUpdateTime.set(element, now);
63
62
  return true;
64
63
  }
65
64
  return false;
66
65
  }
67
66
  const globalContentObserver = new MutationObserver(function (mutations) {
68
67
  const affectedElements = new Set();
69
68
  mutations.forEach(function (mutation) {
70
69
  let targetElement = null;
71
70
  if (mutation.type === 'characterData') {
72
71
  targetElement = findClosestAccessibleElement(mutation.target);
73
72
  } else if (mutation.type === 'childList') {
74
73
  targetElement = findClosestAccessibleElement(mutation.target);
75
74
  }
76
75
  if (targetElement && targetElement.getAttribute('auto-accessible') === 'true') {
77
76
  affectedElements.add(targetElement);
78
77
  }
79
78
  });
80
79
  affectedElements.forEach(function (element) {
81
80
  if (shouldUpdate(element)) {
82
81
  updateAccessibilityLabel(element);
83
82
  } else {
84
83
  }
85
84
  });
86
85
  });
87
86
  globalContentObserver.observe(document.body, contentConfig);
88
87
  let current = node;
89
88
  if (current.nodeType === Node.TEXT_NODE) {
90
89
  current = current.parentElement;
91
90
  }
92
91
  while (current && current !== document.body) {
93
92
  if (current.getAttribute && current.getAttribute('auto-accessible') === 'true') {
94
93
  return current;
95
94
  }
96
95
  current = current.parentElement;
97
96
  }
98
97
  return null;
99
98
  if (!element) return;
100
99
  if (element.hasAttribute('aria-label')) {
101
100
  completeA11yAttributes(element);
102
101
  if (!element.getAttribute('data-auto-aria-label')) {
103
102
  return;
104
103
  }
105
104
  }
106
105
  const text = element.innerText;
107
106
  if (text) {
108
107
  const processedText = text.replace(/\r|\n/g, ' ').replace(/¥\s(\d+)(\s(\.\d+))?/, '¥$1$3');
109
108
  element.setAttribute('aria-label', processedText);
110
109
  element.setAttribute('data-auto-aria-label', 'true');
111
110
  completeA11yAttributes(element);
112
111
  }
113
112
  if (!element.hasAttribute('role')) {
114
113
  element.setAttribute('role', 'text');
115
114
  }
116
115
  if (!element.hasAttribute('tabindex')) {
117
116
  element.setAttribute('tabindex', 0);
118
117
  }
119
118
  console.log('🚀 ~~ 页面启用无障碍自动支持方案 ~~ buildType:', buildType);
120
119
  setupMainObserver();
121
120
  console.log('🚀 ~~ 页面不启用无障碍自动支持方案 !! buildType:', buildType);
121
+ import Taro from '@tarojs/taro';
122
122
  'app-activity',
123
123
  'app-rank',
124
124
  'app-seckill',
125
125
  'm-coupon',
126
126
  'scene-buy',
127
127
  'light-details',
128
128
  'member-paid-center',
129
129
  'member-paid-card',
130
130
  'member-paid-bind',
131
131
  'app-introduce',
132
132
  'app-search-result',
133
133
  if (window?.shopGlobalSwitch?.openAccessibilityLanguage) {
134
134
  Taro.nextTick(() => {
135
135
  const htmlRoot = document?.documentElement;
136
136
  htmlRoot && htmlRoot.setAttribute('lang', isLanguageForEn ? 'en' : 'zh-CN');
137
137
  });
138
138
  }
139
139
  const mainConfig = {
140
140
  childList: true,
141
141
  subtree: true,
142
142
  attributes: true,
143
143
  attributeFilter: ['auto-accessible'],
144
144
  };
145
145
  const mainObserver = new MutationObserver(function (mutations) {
146
146
  mutations.forEach(function (mutation) {
147
147
  if (mutation.type === 'childList') {
148
148
  mutation.addedNodes.forEach(function (node) {
149
149
  if (node.nodeType === Node.ELEMENT_NODE) {
150
150
  if (node.hasAttribute && node.getAttribute('auto-accessible') === 'true') {
151
151
  updateAccessibilityLabel(node);
152
152
  }
153
153
  const accessibleElements = node.querySelectorAll
154
154
  ? node.querySelectorAll('[auto-accessible="true"]')
155
155
  : [];
156
156
  accessibleElements.forEach(function (el) {
157
157
  updateAccessibilityLabel(el);
158
158
  });
159
159
  }
160
160
  });
161
161
  }
162
162
  if (mutation.type === 'attributes' && mutation.attributeName === 'auto-accessible') {
163
163
  if (mutation.target.getAttribute('auto-accessible') === 'true') {
164
164
  updateAccessibilityLabel(mutation.target);
165
165
  }
166
166
  }
167
167
  });
168
168
  });
169
169
  mainObserver.observe(document.body, mainConfig);
170
170
  setupGlobalContentObserver();
171
171
  const contentConfig = {
172
172
  characterData: true,
173
173
  childList: true,
174
174
  subtree: true,
175
175
  };
176
176
  const lastUpdateTime = new WeakMap();
177
177
  const THROTTLE_DELAY = 2000;
178
178
 
179
179
  function shouldUpdate(element) {
180
180
  const now = Date.now();
181
181
  const lastTime = lastUpdateTime.get(element);
182
182
  if (!lastTime || now - lastTime >= THROTTLE_DELAY) {
183
183
  lastUpdateTime.set(element, now);
184
184
  return true;
185
185
  }
186
186
  return false;
187
187
  }
188
188
  const globalContentObserver = new MutationObserver(function (mutations) {
189
189
  const affectedElements = new Set();
190
190
  mutations.forEach(function (mutation) {
191
191
  let targetElement = null;
192
192
  if (mutation.type === 'characterData') {
193
193
  targetElement = findClosestAccessibleElement(mutation.target);
194
194
  } else if (mutation.type === 'childList') {
195
195
  targetElement = findClosestAccessibleElement(mutation.target);
196
196
  }
197
197
  if (targetElement && targetElement.getAttribute('auto-accessible') === 'true') {
198
198
  affectedElements.add(targetElement);
199
199
  }
200
200
  });
201
201
  affectedElements.forEach(function (element) {
202
202
  if (shouldUpdate(element)) {
203
203
  updateAccessibilityLabel(element);
204
204
  } else {
205
205
  }
206
206
  });
207
207
  });
208
208
  globalContentObserver.observe(document.body, contentConfig);
209
209
  let current = node;
210
210
  if (current.nodeType === Node.TEXT_NODE) {
211
211
  current = current.parentElement;
212
212
  }
213
213
  while (current && current !== document.body) {
214
214
  if (current.getAttribute && current.getAttribute('auto-accessible') === 'true') {
215
215
  return current;
216
216
  }
217
217
  current = current.parentElement;
218
218
  }
219
219
  return null;
220
220
  if (!element) return;
221
221
  if (element.hasAttribute('aria-label')) {
222
222
  completeA11yAttributes(element);
223
223
  if (!element.getAttribute('data-auto-aria-label')) {
224
224
  return;
225
225
  }
226
226
  }
227
227
  const text = element.innerText;
228
228
  if (text) {
229
229
  const processedText = text.replace(/\r|\n/g, ' ').replace(/¥\s(\d+)(\s(\.\d+))?/, '¥$1$3');
230
230
  element.setAttribute('aria-label', processedText);
231
231
  element.setAttribute('data-auto-aria-label', 'true');
232
232
  completeA11yAttributes(element);
233
233
  }
234
234
  if (!element.hasAttribute('role')) {
235
235
  element.setAttribute('role', 'text');
236
236
  }
237
237
  if (!element.hasAttribute('tabindex')) {
238
238
  element.setAttribute('tabindex', 0);
239
239
  }
240
240
  console.log('🚀 ~~ 页面启用无障碍自动支持方案 ~~ buildType:', buildType);
241
241
  setupMainObserver();
242
242
  console.log('🚀 ~~ 页面不启用无障碍自动支持方案 !! buildType:', buildType);
@@ -1 +1 @@
1
- import React, { useEffect, useRef } from 'react';
2
1
  let value = `${initValue}`;
3
2
  if (!cnPriceTextList.includes(value)) {
4
3
  if (value && !/^[0123456789-]*$/.test(value.substring(0, 1))) {
5
4
  symbol = value.substring(0, 1);
6
5
  value = value.substring(1);
7
6
  }
8
7
  if (/^\d+(\.\d+)?[eE][+-]?\d+$/.test(value)) {
9
8
  draBusinessCustomReport({
10
9
  eventName: 'business',
11
10
  errorName: getSgmCustomCode(`${SgmCustomCode.PRICE_RENDER}_basePrice`),
12
11
  errorMessage: '当前价格为科学计数数据,上报关注该价格',
13
12
  extraData: JSON.stringify({
14
13
  price: value,
15
14
  originalPrice: initValue,
16
15
  }),
17
16
  });
18
17
  }
19
18
  if (!decToIntegerState) {
20
19
  value = parseFloat(value).toFixed(decLength);
21
20
  } else {
22
21
  if (value.indexOf('.') !== -1) {
23
22
  value = parseFloat(value).toFixed(decLength);
24
23
  value = `${value}`.replace(/0+$/, '');
25
24
  }
26
25
  }
27
26
  if (value === 'NaN') {
28
27
  draBusinessCustomReport({
29
28
  eventName: 'business',
30
29
  errorName: getSgmCustomCode(`${SgmCustomCode.PRICE_RENDER}_basePrice`),
31
30
  errorMessage: '价格转换异常,兜底展示暂无报价',
32
31
  extraData: JSON.stringify({
33
32
  price: value,
34
33
  originalPrice: initValue,
35
34
  }),
36
35
  });
37
36
  value = '暂无报价';
38
37
  }
39
38
  }
40
39
  const [intVal, decimalVal] = `${value}`.split('.');
41
40
  return {
42
41
  currencySymbol: !cnPriceTextList.includes(intVal) ? symbol : '',
43
42
  intVal,
44
43
  decimalVal,
45
44
  };
46
45
  const {
47
46
  prefixCls,
48
47
  symPos,
49
48
  symbol,
50
49
  decPos,
51
50
  status,
52
51
  className,
53
52
  style,
54
53
  symClassName,
55
54
  intClassName,
56
55
  decClassName,
57
56
  noPriceClassName,
58
57
  value,
59
58
  decLength,
60
59
  decToIntegerState,
61
60
  isPlusPrice,
62
61
  isSamsPrice,
63
62
  isMemberPrice,
64
63
  isSfpPrice,
65
64
  memberPriceIcon,
66
65
  isShowPriceLabel,
67
66
  priceLabelText,
68
67
  priceTextColor,
69
68
  useFontV2 = false,
70
69
  useFontV2Bold = false,
71
70
  } = props;
72
71
  const cRef = useRef<any>(null);
73
72
  useEffect(() => {
74
73
  if (isShowPriceLabel && priceTextColor && cRef.current) {
75
74
  cRef.current?.style?.setProperty('--after-ele-color', priceTextColor);
76
75
  }
77
76
  }, [isShowPriceLabel, priceTextColor]);
78
77
  const cls = classNames(
79
78
  className ? `${className}` : '',
80
79
  prefixCls,
81
80
  {
82
81
  'd-font-v2': useFontV2,
83
82
  'd-font-v2-bold': useFontV2Bold,
84
83
  },
85
84
  'd-imag-rendering-crisp-edges',
86
85
  {
87
86
  del: status === 'del',
88
87
  },
89
88
  {
90
89
  'd-plus-price': isPlusPrice,
91
90
  },
92
91
  {
93
92
  'd-sams-price': isSamsPrice,
94
93
  },
95
94
  {
96
95
  'd-sfp-price': isSfpPrice,
97
96
  },
98
97
  {
99
98
  'd-member-price': isMemberPrice,
100
99
  },
101
100
  {
102
101
  [`d-member-price-${memberPriceIcon}`]: memberPriceIcon,
103
102
  },
104
103
  {
105
104
  'd-price-label': isShowPriceLabel,
106
105
  },
107
106
  {
108
107
  'd-price-text-clor': isShowPriceLabel && priceTextColor,
109
108
  },
110
109
  );
111
110
  const symCls = classNames(symClassName ? `${symClassName}` : '', {
112
111
  'sym-sub': symPos === 'sub',
113
112
  'sym-sup': symPos === 'sup',
114
113
  });
115
114
  const intCls = classNames(intClassName ? `${intClassName}` : '');
116
115
  const decCls = classNames(decClassName ? `${decClassName}` : '', {
117
116
  'dec-sub': decPos === 'sub',
118
117
  'dec-sup': decPos === 'sup',
119
118
  });
120
119
  const noPriceCls = classNames(noPriceClassName ? `${noPriceClassName}` : '');
121
120
  const { currencySymbol, intVal, decimalVal } = dealPrice(
122
121
  value,
123
122
  decLength,
124
123
  symbol,
125
124
  decToIntegerState,
126
125
  );
127
126
  return (
128
127
  <View
129
128
  ref={cRef}
130
129
  className={cls}
131
130
  style={style}
132
131
  data-after={isShowPriceLabel ? priceLabelText : ''}
133
132
  >
134
133
  {intVal === '-1' ? (
135
134
  <Text className={`${prefixCls}-txt int-txt off-shelf ${noPriceCls}`}>{`暂无报价`}</Text>
136
135
  ) : (
137
136
  <>
138
137
  <Text className={`${prefixCls}-sym ${symCls}`}>{currencySymbol}</Text>
139
138
  <Text className={`${prefixCls}-txt int-txt ${intCls}`}>{intVal}</Text>
140
139
  {!!decimalVal && (
141
140
  <Text className={`${prefixCls}-txt dec-txt ${decCls}`}>.{decimalVal}</Text>
142
141
  )}
143
142
  </>
144
143
  )}
145
144
  </View>
146
145
  );
147
146
  prefixCls: 'd-mini-price',
148
147
  style: {},
149
148
  status: '',
150
149
  symbol: '¥',
151
150
  symPos: 'sub',
152
151
  decLength: 2,
153
152
  decPos: 'sub',
154
153
  decToIntegerState: false,
155
154
  isPlusPrice: false,
156
155
  isShowPriceLabel: false,
157
156
  priceLabelText: '到手价',
158
157
  priceTextColor: '',
159
158
  useFontV2: false,
160
159
  useFontV2Bold: false,
160
+ import React, { useEffect, useRef } from 'react';
161
161
  let value = `${initValue}`;
162
162
  if (!cnPriceTextList.includes(value)) {
163
163
  if (value && !/^[0123456789-]*$/.test(value.substring(0, 1))) {
164
164
  symbol = value.substring(0, 1);
165
165
  value = value.substring(1);
166
166
  }
167
167
  if (/^\d+(\.\d+)?[eE][+-]?\d+$/.test(value)) {
168
168
  draBusinessCustomReport({
169
169
  eventName: 'business',
170
170
  errorName: getSgmCustomCode(`${SgmCustomCode.PRICE_RENDER}_basePrice`),
171
171
  errorMessage: '当前价格为科学计数数据,上报关注该价格',
172
172
  extraData: JSON.stringify({
173
173
  price: value,
174
174
  originalPrice: initValue,
175
175
  }),
176
176
  });
177
177
  }
178
178
  if (!decToIntegerState) {
179
179
  value = parseFloat(value).toFixed(decLength);
180
180
  } else {
181
181
  if (value.indexOf('.') !== -1) {
182
182
  value = parseFloat(value).toFixed(decLength);
183
183
  value = `${value}`.replace(/0+$/, '');
184
184
  }
185
185
  }
186
186
  if (value === 'NaN') {
187
187
  draBusinessCustomReport({
188
188
  eventName: 'business',
189
189
  errorName: getSgmCustomCode(`${SgmCustomCode.PRICE_RENDER}_basePrice`),
190
190
  errorMessage: '价格转换异常,兜底展示暂无报价',
191
191
  extraData: JSON.stringify({
192
192
  price: value,
193
193
  originalPrice: initValue,
194
194
  }),
195
195
  });
196
196
  value = '暂无报价';
197
197
  }
198
198
  }
199
199
  const [intVal, decimalVal] = `${value}`.split('.');
200
200
  return {
201
201
  currencySymbol: !cnPriceTextList.includes(intVal) ? symbol : '',
202
202
  intVal,
203
203
  decimalVal,
204
204
  };
205
205
  const {
206
206
  prefixCls,
207
207
  symPos,
208
208
  symbol,
209
209
  decPos,
210
210
  status,
211
211
  className,
212
212
  style,
213
213
  symClassName,
214
214
  intClassName,
215
215
  decClassName,
216
216
  noPriceClassName,
217
217
  value,
218
218
  decLength,
219
219
  decToIntegerState,
220
220
  isPlusPrice,
221
221
  isSamsPrice,
222
222
  isMemberPrice,
223
223
  isSfpPrice,
224
224
  memberPriceIcon,
225
225
  isShowPriceLabel,
226
226
  priceLabelText,
227
227
  priceTextColor,
228
228
  useFontV2 = false,
229
229
  useFontV2Bold = false,
230
230
  nativeProps,
231
231
  } = props;
232
232
  const cRef = useRef<any>(null);
233
233
  useEffect(() => {
234
234
  if (isShowPriceLabel && priceTextColor && cRef.current) {
235
235
  cRef.current?.style?.setProperty('--after-ele-color', priceTextColor);
236
236
  }
237
237
  }, [isShowPriceLabel, priceTextColor]);
238
238
  const cls = classNames(
239
239
  className ? `${className}` : '',
240
240
  prefixCls,
241
241
  {
242
242
  'd-font-v2': useFontV2,
243
243
  'd-font-v2-bold': useFontV2Bold,
244
244
  },
245
245
  'd-imag-rendering-crisp-edges',
246
246
  {
247
247
  del: status === 'del',
248
248
  },
249
249
  {
250
250
  'd-plus-price': isPlusPrice,
251
251
  },
252
252
  {
253
253
  'd-sams-price': isSamsPrice,
254
254
  },
255
255
  {
256
256
  'd-sfp-price': isSfpPrice,
257
257
  },
258
258
  {
259
259
  'd-member-price': isMemberPrice,
260
260
  },
261
261
  {
262
262
  [`d-member-price-${memberPriceIcon}`]: memberPriceIcon,
263
263
  },
264
264
  {
265
265
  'd-price-label': isShowPriceLabel,
266
266
  },
267
267
  {
268
268
  'd-price-text-clor': isShowPriceLabel && priceTextColor,
269
269
  },
270
270
  );
271
271
  const symCls = classNames(symClassName ? `${symClassName}` : '', {
272
272
  'sym-sub': symPos === 'sub',
273
273
  'sym-sup': symPos === 'sup',
274
274
  });
275
275
  const intCls = classNames(intClassName ? `${intClassName}` : '');
276
276
  const decCls = classNames(decClassName ? `${decClassName}` : '', {
277
277
  'dec-sub': decPos === 'sub',
278
278
  'dec-sup': decPos === 'sup',
279
279
  });
280
280
  const noPriceCls = classNames(noPriceClassName ? `${noPriceClassName}` : '');
281
281
  const { currencySymbol, intVal, decimalVal } = dealPrice(
282
282
  value,
283
283
  decLength,
284
284
  symbol,
285
285
  decToIntegerState,
286
286
  );
287
287
  return (
288
288
  <View
289
289
  ref={cRef}
290
290
  className={cls}
291
291
  style={style}
292
292
  data-after={isShowPriceLabel ? priceLabelText : ''}
293
293
  {...nativeProps}
294
294
  >
295
295
  {intVal === '-1' ? (
296
296
  <Text className={`${prefixCls}-txt int-txt off-shelf ${noPriceCls}`}>{`暂无报价`}</Text>
297
297
  ) : (
298
298
  <>
299
299
  <Text className={`${prefixCls}-sym ${symCls}`}>{currencySymbol}</Text>
300
300
  <Text className={`${prefixCls}-txt int-txt ${intCls}`}>{intVal}</Text>
301
301
  {!!decimalVal && (
302
302
  <Text className={`${prefixCls}-txt dec-txt ${decCls}`}>.{decimalVal}</Text>
303
303
  )}
304
304
  </>
305
305
  )}
306
306
  </View>
307
307
  );
308
308
  prefixCls: 'd-mini-price',
309
309
  style: {},
310
310
  status: '',
311
311
  symbol: '¥',
312
312
  symPos: 'sub',
313
313
  decLength: 2,
314
314
  decPos: 'sub',
315
315
  decToIntegerState: false,
316
316
  isPlusPrice: false,
317
317
  isShowPriceLabel: false,
318
318
  priceLabelText: '到手价',
319
319
  priceTextColor: '',
320
320
  useFontV2: false,
321
321
  useFontV2Bold: false,