@tarojs/components-advanced 3.6.0-beta.1 → 3.6.0-canary.11

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.
@@ -98,6 +98,6 @@
98
98
  * @see https://taro-docs.jd.com/docs/virtual-list
99
99
  */
100
100
 
101
- var VirtualList = process.env.FRAMEWORK.includes('vue') ? require('./vue').default : require('./react').default;
101
+ var VirtualList = process.env.FRAMEWORK === 'vue' || process.env.FRAMEWORK === 'vue3' ? require('./vue').default : require('./react').default;
102
102
  export { VirtualList };
103
103
  export default VirtualList;
@@ -4,7 +4,6 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
5
5
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
6
6
  import { isFunction } from '@tarojs/shared';
7
- import { IS_PROD } from '../../utils/constants';
8
7
  import { isHorizontalFunc } from './utils';
9
8
  var ListSet = /*#__PURE__*/function () {
10
9
  function ListSet(props, refresh) {
@@ -62,7 +61,7 @@ var ListSet = /*#__PURE__*/function () {
62
61
  width = _this$props.width;
63
62
  var isHorizontal = isHorizontalFunc(this.props);
64
63
  var size = isHorizontal ? width : height;
65
- if (!IS_PROD && typeof size !== 'number') {
64
+ if (process.env.NODE_ENV !== 'production' && typeof size !== 'number') {
66
65
  console.warn("In mode ".concat(isHorizontal ? 'horizontal, width' : 'vertical, height', " parameter should be a number, but got ").concat(_typeof(size), "."));
67
66
  }
68
67
  return size;
@@ -3,6 +3,7 @@ import ListSet from './list-set';
3
3
  import { defaultItemKey } from './utils';
4
4
  import type { VirtualListProps } from './';
5
5
  export interface IProps extends Partial<VirtualListProps> {
6
+ children?: VirtualListProps['item'];
6
7
  direction?: 'ltr' | 'rtl' | 'horizontal' | 'vertical';
7
8
  itemKey?: typeof defaultItemKey;
8
9
  itemTagName?: string;
@@ -45,6 +45,10 @@ var VirtualList = React.forwardRef(function VirtualList(props, ref) {
45
45
  _ref2$overscanCount = _ref2.overscanCount,
46
46
  overscanCount = _ref2$overscanCount === void 0 ? 1 : _ref2$overscanCount,
47
47
  rest = _objectWithoutProperties(_ref2, _excluded2);
48
+ if ('children' in rest) {
49
+ console.warn('Taro(VirtualList): children props have been deprecated. ' + 'Please use the item props instead.');
50
+ rest.item = rest.children;
51
+ }
48
52
  if (rest.item instanceof Array) {
49
53
  console.warn('Taro(VirtualList): item should not be an array');
50
54
  rest.item = rest.item[0];
@@ -11,7 +11,6 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
11
11
  var _excluded = ["className", "direction", "height", "innerRef", "item", "itemCount", "itemData", "itemKey", "layout", "style", "useIsScrolling", "width", "renderTop", "renderBottom"];
12
12
  import memoizeOne from 'memoize-one';
13
13
  import React from 'react';
14
- import { IS_PREACT } from '../../../utils/constants';
15
14
  import { convertNumber2PX } from '../../../utils/convert';
16
15
  import { omit } from '../../../utils/lodash';
17
16
  import { cancelTimeout, requestTimeout } from '../../../utils/timer';
@@ -30,7 +29,7 @@ var List = /*#__PURE__*/function (_React$PureComponent) {
30
29
  _defineProperty(_assertThisInitialized(_this), "itemList", void 0);
31
30
  _defineProperty(_assertThisInitialized(_this), "preset", void 0);
32
31
  _defineProperty(_assertThisInitialized(_this), "refresh", function () {
33
- if (IS_PREACT) {
32
+ if (process.env.FRAMEWORK === 'preact') {
34
33
  _this.forceUpdate();
35
34
  } else {
36
35
  _this.setState(function (_ref) {
@@ -1,8 +1,7 @@
1
1
  import _typeof from "@babel/runtime/helpers/esm/typeof";
2
- import { IS_PROD } from '../../../utils/constants';
3
2
  var devWarningsDirection = null;
4
3
  var devWarningsTagName = null;
5
- if (!IS_PROD) {
4
+ if (process.env.NODE_ENV !== 'production') {
6
5
  if (typeof window !== 'undefined' && typeof window.WeakSet !== 'undefined') {
7
6
  devWarningsDirection = /* #__PURE__ */
8
7
  new WeakSet();
@@ -21,12 +20,12 @@ export var validateListProps = function validateListProps(_ref, _ref2) {
21
20
  width = _ref.width,
22
21
  itemSize = _ref.itemSize;
23
22
  var instance = _ref2.instance;
24
- if (!IS_PROD) {
23
+ if (process.env.NODE_ENV !== 'production') {
25
24
  if (!['number', 'function'].includes(_typeof(itemSize))) {
26
25
  throw Error('An invalid "itemSize" prop has been specified. ' + 'Value should be a number or function. ' + "\"".concat(itemSize === null ? 'null' : _typeof(itemSize), "\" was specified."));
27
26
  }
28
27
  }
29
- if (!IS_PROD) {
28
+ if (process.env.NODE_ENV !== 'production') {
30
29
  if (innerTagName != null || outerTagName != null || itemTagName != null) {
31
30
  if (devWarningsTagName && !devWarningsTagName.has(instance)) {
32
31
  devWarningsTagName.add(instance);
@@ -1,4 +1,4 @@
1
- import Taro, { createSelectorQuery as _createSelectorQuery } from '@tarojs/taro';
1
+ import Taro from '@tarojs/taro';
2
2
 
3
3
  // In DEV mode, this Set helps us only log a warning once per component instance.
4
4
  // This avoids spamming the console every time a render happens.
@@ -16,7 +16,7 @@ export function isRtlFunc(_ref2) {
16
16
  }
17
17
  export function getRectSize(id, success, fail) {
18
18
  var retryMs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 500;
19
- var query = _createSelectorQuery();
19
+ var query = Taro.createSelectorQuery();
20
20
  try {
21
21
  query.select(id).boundingClientRect(function (res) {
22
22
  if (res) {
@@ -1,7 +1,6 @@
1
1
  import _typeof from "@babel/runtime/helpers/esm/typeof";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import memoizeOne from 'memoize-one';
4
- import { IS_VUE3, IS_WEB } from '../../../utils/constants';
5
4
  import { convertNumber2PX } from '../../../utils/convert';
6
5
  import { omit } from '../../../utils/lodash';
7
6
  import { cancelTimeout, requestTimeout } from '../../../utils/timer';
@@ -46,7 +45,7 @@ export default {
46
45
  },
47
46
  innerElementType: {
48
47
  type: String,
49
- default: IS_WEB ? 'taro-view-core' : 'view'
48
+ default: process.env.TARO_ENV === 'h5' ? 'taro-view-core' : 'view'
50
49
  },
51
50
  direction: {
52
51
  type: String,
@@ -73,15 +72,15 @@ export default {
73
72
  itemKey: String,
74
73
  itemTagName: {
75
74
  type: String,
76
- default: IS_WEB ? 'taro-view-core' : 'view'
75
+ default: process.env.TARO_ENV === 'h5' ? 'taro-view-core' : 'view'
77
76
  },
78
77
  innerTagName: {
79
78
  type: String,
80
- default: IS_WEB ? 'taro-view-core' : 'view'
79
+ default: process.env.TARO_ENV === 'h5' ? 'taro-view-core' : 'view'
81
80
  },
82
81
  outerTagName: {
83
82
  type: String,
84
- default: IS_WEB ? 'taro-scroll-view-core' : 'scroll-view'
83
+ default: process.env.TARO_ENV === 'h5' ? 'taro-scroll-view-core' : 'scroll-view'
85
84
  },
86
85
  itemElementType: String,
87
86
  outerElementType: String,
@@ -456,7 +455,7 @@ export default {
456
455
  if (this.preset.isRelative) {
457
456
  var _this$$slots$top, _this$$slots, _this$$slots$bottom, _this$$slots2;
458
457
  var pre = convertNumber2PX(this.itemList.getOffsetSize(startIndex));
459
- return _render(this.preset.outerTagName, outerElementProps, [IS_VUE3 ? (_this$$slots$top = (_this$$slots = this.$slots).top) === null || _this$$slots$top === void 0 ? void 0 : _this$$slots$top.call(_this$$slots) : this.$slots.top, _render(this.preset.itemTagName, {
458
+ return _render(this.preset.outerTagName, outerElementProps, [process.env.FRAMEWORK === 'vue3' ? (_this$$slots$top = (_this$$slots = this.$slots).top) === null || _this$$slots$top === void 0 ? void 0 : _this$$slots$top.call(_this$$slots) : this.$slots.top, _render(this.preset.itemTagName, {
460
459
  key: "".concat(id, "-pre"),
461
460
  id: "".concat(id, "-pre"),
462
461
  style: {
@@ -471,10 +470,10 @@ export default {
471
470
  pointerEvents: isScrolling ? 'none' : 'auto',
472
471
  position: 'relative'
473
472
  }
474
- }, items), IS_VUE3 ? (_this$$slots$bottom = (_this$$slots2 = this.$slots).bottom) === null || _this$$slots$bottom === void 0 ? void 0 : _this$$slots$bottom.call(_this$$slots2) : this.$slots.bottom]);
473
+ }, items), process.env.FRAMEWORK === 'vue3' ? (_this$$slots$bottom = (_this$$slots2 = this.$slots).bottom) === null || _this$$slots$bottom === void 0 ? void 0 : _this$$slots$bottom.call(_this$$slots2) : this.$slots.bottom]);
475
474
  } else {
476
475
  var _this$$slots$top2, _this$$slots3, _this$$slots$bottom2, _this$$slots4;
477
- return _render(this.preset.outerTagName, outerElementProps, [IS_VUE3 ? (_this$$slots$top2 = (_this$$slots3 = this.$slots).top) === null || _this$$slots$top2 === void 0 ? void 0 : _this$$slots$top2.call(_this$$slots3) : this.$slots.top, _render(this.preset.innerTagName, {
476
+ return _render(this.preset.outerTagName, outerElementProps, [process.env.FRAMEWORK === 'vue3' ? (_this$$slots$top2 = (_this$$slots3 = this.$slots).top) === null || _this$$slots$top2 === void 0 ? void 0 : _this$$slots$top2.call(_this$$slots3) : this.$slots.top, _render(this.preset.innerTagName, {
478
477
  ref: innerRef,
479
478
  key: "".concat(id, "-inner"),
480
479
  id: "".concat(id, "-inner"),
@@ -484,7 +483,7 @@ export default {
484
483
  position: 'relative',
485
484
  width: !isHorizontal ? '100%' : estimatedTotalSize
486
485
  }
487
- }, items), IS_VUE3 ? (_this$$slots$bottom2 = (_this$$slots4 = this.$slots).bottom) === null || _this$$slots$bottom2 === void 0 ? void 0 : _this$$slots$bottom2.call(_this$$slots4) : this.$slots.bottom]);
486
+ }, items), process.env.FRAMEWORK === 'vue3' ? (_this$$slots$bottom2 = (_this$$slots4 = this.$slots).bottom) === null || _this$$slots$bottom2 === void 0 ? void 0 : _this$$slots$bottom2.call(_this$$slots4) : this.$slots.bottom]);
488
487
  }
489
488
  }
490
489
  };
@@ -2,7 +2,6 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
3
  var _excluded = ["attrs", "on", "props", "slots"];
4
4
  import { h } from 'vue';
5
- import { IS_VUE3 } from '../../../utils/constants';
6
5
  export default function (componentName, options, children) {
7
6
  var _options$attrs = options.attrs,
8
7
  attrs = _options$attrs === void 0 ? {} : _options$attrs,
@@ -13,7 +12,7 @@ export default function (componentName, options, children) {
13
12
  _options$slots = options.slots,
14
13
  slots = _options$slots === void 0 ? {} : _options$slots,
15
14
  el = _objectWithoutProperties(options, _excluded);
16
- if (IS_VUE3) {
15
+ if (process.env.FRAMEWORK === 'vue3') {
17
16
  // Events
18
17
  Object.keys(on).forEach(function (key) {
19
18
  var name = "on".concat(key.charAt(0).toUpperCase()).concat(key.slice(1));
@@ -1,4 +1,3 @@
1
- export * from './constants';
2
1
  export * from './convert';
3
2
  export * from './lodash';
4
3
  export * from './math';
@@ -1,4 +1,3 @@
1
- export * from './constants';
2
1
  export * from './convert';
3
2
  export * from './lodash';
4
3
  export * from './math';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/components-advanced",
3
- "version": "3.6.0-beta.1",
3
+ "version": "3.6.0-canary.11",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,14 +8,18 @@
8
8
  "dist",
9
9
  "typings"
10
10
  ],
11
+ "sideEffects": [
12
+ "*.scss",
13
+ "*.css"
14
+ ],
11
15
  "keywords": [],
12
16
  "author": "ZakaryCode",
13
17
  "license": "MIT",
14
18
  "dependencies": {
15
19
  "memoize-one": "^6.0.0",
16
20
  "postcss": "^8.4.18",
17
- "@tarojs/components": "3.6.0-beta.1",
18
- "@tarojs/shared": "3.6.0-beta.1"
21
+ "@tarojs/components": "3.6.0-canary.11",
22
+ "@tarojs/shared": "3.6.0-canary.11"
19
23
  },
20
24
  "devDependencies": {
21
25
  "@babel/cli": "^7.14.5",
@@ -26,7 +30,7 @@
26
30
  "react-dom": "^18.2.0",
27
31
  "typescript": "^4.7.4",
28
32
  "vue": "^3.0.0",
29
- "babel-preset-taro": "3.6.0-beta.1"
33
+ "babel-preset-taro": "3.6.0-canary.11"
30
34
  },
31
35
  "peerDependencies": {
32
36
  "react": ">=17"
@@ -1,4 +0,0 @@
1
- export declare const IS_PROD: boolean;
2
- export declare const IS_WEB: boolean;
3
- export declare const IS_PREACT: boolean;
4
- export declare const IS_VUE3: boolean;
@@ -1,4 +0,0 @@
1
- export var IS_PROD = process.env.NODE_ENV === 'production';
2
- export var IS_WEB = process.env.TARO_ENV === 'h5';
3
- export var IS_PREACT = process.env.FRAMEWORK === 'preact';
4
- export var IS_VUE3 = process.env.FRAMEWORK === 'vue3';