@tarojs/components 3.6.0-beta.1 → 3.6.0-beta.2

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,8 +1,43 @@
1
- import { h, Host } from '@stencil/core';
1
+ import { Host, h } from '@stencil/core';
2
+ function isEqualTag(a, b) {
3
+ return typeof a.tagName === 'undefined' ? a.nodeType === b.nodeType : a.tagName === b.tagName;
4
+ }
5
+ function parseChildNodes(items, targets) {
6
+ const list = Array.from(targets.values());
7
+ for (let i = 0, j = 0; i < list.length; i++, j++) {
8
+ const target = list[i];
9
+ let item = items.item(j);
10
+ while (item && !isEqualTag(item, target)) {
11
+ item.remove();
12
+ j++;
13
+ item = items.item(j);
14
+ }
15
+ if (item && !item.isEqualNode(target)) {
16
+ parseChildNodes(item.childNodes, target.childNodes);
17
+ }
18
+ while (i === list.length - 1 && j < items.length) {
19
+ j++;
20
+ item = items.item(j);
21
+ item === null || item === void 0 ? void 0 : item.remove();
22
+ }
23
+ }
24
+ }
2
25
  export class SwiperItem {
3
26
  constructor() {
4
27
  this.itemId = undefined;
5
28
  }
29
+ componentDidRender() {
30
+ var _a, _b, _c;
31
+ const el = this.el;
32
+ if (el.classList.contains('swiper-slide-duplicate')) {
33
+ const list = Array
34
+ .from(((_b = (_a = el.parentElement) === null || _a === void 0 ? void 0 : _a.childNodes) === null || _b === void 0 ? void 0 : _b.values()) || [])
35
+ .filter((e) => e.tagName === 'TARO-SWIPER-ITEM-CORE');
36
+ if (list.length > 0) {
37
+ parseChildNodes(el.childNodes, (_c = list[list.indexOf(el) === 0 ? list.length - 2 : 1]) === null || _c === void 0 ? void 0 : _c.childNodes);
38
+ }
39
+ }
40
+ }
6
41
  render() {
7
42
  return (h(Host, { class: 'swiper-slide', "item-id": this.itemId }));
8
43
  }
@@ -28,5 +63,6 @@ export class SwiperItem {
28
63
  }
29
64
  };
30
65
  }
66
+ static get elementRef() { return "el"; }
31
67
  }
32
68
  //# sourceMappingURL=swiper-item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"swiper-item.js","sourceRoot":"","sources":["../../../src/components/swiper/swiper-item.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAsB,IAAI,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAK5E,MAAM,OAAO,UAAU;;;;EAGrB,MAAM;IACJ,OAAO,CACL,EAAC,IAAI,IAAC,KAAK,EAAC,cAAc,aAAU,IAAI,CAAC,MAAM,GAAG,CACnD,CAAA;EACH,CAAC;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, ComponentInterface, Prop, Host } from '@stencil/core'\n\n@Component({\n tag: 'taro-swiper-item-core'\n})\nexport class SwiperItem implements ComponentInterface {\n @Prop() itemId: string\n\n render () {\n return (\n <Host class='swiper-slide' item-id={this.itemId}/>\n )\n }\n}\n"]}
1
+ {"version":3,"file":"swiper-item.js","sourceRoot":"","sources":["../../../src/components/swiper/swiper-item.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsB,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAErF,SAAS,UAAU,CAAE,CAAU,EAAE,CAAU;EACzC,OAAO,OAAO,CAAC,CAAC,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,CAAA;AAC/F,CAAC;AAED,SAAS,eAAe,CAAE,KAA4B,EAAE,OAA8B;EACpF,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;EACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE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AAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,0CAAE,UAAU,CAC/D,CAAA;OACF;KACF;EACH,CAAC;EAED,MAAM;IACJ,OAAO,CACL,EAAC,IAAI,IAAC,KAAK,EAAC,cAAc,aAAU,IAAI,CAAC,MAAM,GAAG,CACnD,CAAA;EACH,CAAC;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, ComponentInterface, Element, Host, h, Prop } from '@stencil/core'\n\nfunction isEqualTag (a: Element, b: Element) {\n return typeof a.tagName === 'undefined' ? a.nodeType === b.nodeType : a.tagName === b.tagName\n}\n\nfunction parseChildNodes (items: NodeListOf<ChildNode>, targets: NodeListOf<ChildNode>) {\n const list = Array.from(targets.values())\n for (let i = 0, j = 0; i < list.length; i++, j++) {\n const target = list[i] as Element\n let item = items.item(j) as Element\n while (item && !isEqualTag(item, target)) {\n item.remove()\n j++\n item = items.item(j) as Element\n }\n if (item && !item.isEqualNode(target)) {\n parseChildNodes(item.childNodes, target.childNodes)\n }\n while (i === list.length - 1 && j < items.length) {\n j++\n item = items.item(j) as Element\n item?.remove()\n }\n }\n}\n\n@Component({\n tag: 'taro-swiper-item-core'\n})\nexport class SwiperItem implements ComponentInterface {\n @Element() el: HTMLElement\n\n @Prop() itemId: string\n\n componentDidRender () {\n const el = this.el\n\n if (el.classList.contains('swiper-slide-duplicate')) {\n const list = Array\n .from(el.parentElement?.childNodes?.values() || [])\n .filter((e: Element) => e.tagName === 'TARO-SWIPER-ITEM-CORE')\n if (list.length > 0) {\n parseChildNodes(\n el.childNodes,\n list[list.indexOf(el) === 0 ? list.length - 2 : 1]?.childNodes\n )\n }\n }\n }\n\n render () {\n return (\n <Host class='swiper-slide' item-id={this.itemId}/>\n )\n }\n}\n"]}
@@ -10122,14 +10122,50 @@ const Swiper = class {
10122
10122
  };
10123
10123
  Swiper.style = indexCss;
10124
10124
 
10125
+ function isEqualTag(a, b) {
10126
+ return typeof a.tagName === 'undefined' ? a.nodeType === b.nodeType : a.tagName === b.tagName;
10127
+ }
10128
+ function parseChildNodes(items, targets) {
10129
+ const list = Array.from(targets.values());
10130
+ for (let i = 0, j = 0; i < list.length; i++, j++) {
10131
+ const target = list[i];
10132
+ let item = items.item(j);
10133
+ while (item && !isEqualTag(item, target)) {
10134
+ item.remove();
10135
+ j++;
10136
+ item = items.item(j);
10137
+ }
10138
+ if (item && !item.isEqualNode(target)) {
10139
+ parseChildNodes(item.childNodes, target.childNodes);
10140
+ }
10141
+ while (i === list.length - 1 && j < items.length) {
10142
+ j++;
10143
+ item = items.item(j);
10144
+ item === null || item === void 0 ? void 0 : item.remove();
10145
+ }
10146
+ }
10147
+ }
10125
10148
  const SwiperItem = class {
10126
10149
  constructor(hostRef) {
10127
10150
  registerInstance(this, hostRef);
10128
10151
  this.itemId = undefined;
10129
10152
  }
10153
+ componentDidRender() {
10154
+ var _a, _b, _c;
10155
+ const el = this.el;
10156
+ if (el.classList.contains('swiper-slide-duplicate')) {
10157
+ const list = Array
10158
+ .from(((_b = (_a = el.parentElement) === null || _a === void 0 ? void 0 : _a.childNodes) === null || _b === void 0 ? void 0 : _b.values()) || [])
10159
+ .filter((e) => e.tagName === 'TARO-SWIPER-ITEM-CORE');
10160
+ if (list.length > 0) {
10161
+ parseChildNodes(el.childNodes, (_c = list[list.indexOf(el) === 0 ? list.length - 2 : 1]) === null || _c === void 0 ? void 0 : _c.childNodes);
10162
+ }
10163
+ }
10164
+ }
10130
10165
  render() {
10131
10166
  return (h(Host, { class: 'swiper-slide', "item-id": this.itemId }));
10132
10167
  }
10168
+ get el() { return getElement(this); }
10133
10169
  };
10134
10170
 
10135
10171
  export { Swiper as taro_swiper_core, SwiperItem as taro_swiper_item_core };