@tarojs/taro-h5 3.6.0-beta.3 → 3.6.0-beta.4
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.
- package/dist/api/media/image/previewImage.js +2 -2
- package/dist/api/ui/interaction/modal.js +3 -3
- package/dist/api/ui/interaction/modal.js.map +1 -1
- package/dist/api/ui/interaction/toast.js +3 -3
- package/dist/api/ui/interaction/toast.js.map +1 -1
- package/dist/index.cjs.js +89 -14278
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +111 -14300
- package/dist/index.esm.js.map +1 -1
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +12 -21
- package/dist/utils/index.js.map +1 -1
- package/package.json +7 -7
- package/dist/node_modules/.pnpm/registry.npmjs.org_@stencil_core@2.22.2/node_modules/@stencil/core/internal/app-data/index.js +0 -89
- package/dist/node_modules/.pnpm/registry.npmjs.org_@stencil_core@2.22.2/node_modules/@stencil/core/internal/app-data/index.js.map +0 -1
- package/dist/node_modules/.pnpm/registry.npmjs.org_@stencil_core@2.22.2/node_modules/@stencil/core/internal/client/index.js +0 -3371
- package/dist/node_modules/.pnpm/registry.npmjs.org_@stencil_core@2.22.2/node_modules/@stencil/core/internal/client/index.js.map +0 -1
- package/dist/node_modules/.pnpm/registry.npmjs.org_@stencil_core@2.22.2/node_modules/@stencil/core/internal/client/shadow-css.js +0 -388
- package/dist/node_modules/.pnpm/registry.npmjs.org_@stencil_core@2.22.2/node_modules/@stencil/core/internal/client/shadow-css.js.map +0 -1
- package/dist/packages/taro-components/dist/components/index2.js +0 -77
- package/dist/packages/taro-components/dist/components/index2.js.map +0 -1
- package/dist/packages/taro-components/dist/components/index3.js +0 -35
- package/dist/packages/taro-components/dist/components/index3.js.map +0 -1
- package/dist/packages/taro-components/dist/components/taro-swiper-core.js +0 -10171
- package/dist/packages/taro-components/dist/components/taro-swiper-core.js.map +0 -1
- package/dist/packages/taro-components/dist/components/taro-swiper-item-core.js +0 -69
- package/dist/packages/taro-components/dist/components/taro-swiper-item-core.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from '../../../node_modules/.pnpm/registry.npmjs.org_tslib@1.14.1/node_modules/tslib/tslib.es6.js';
|
|
2
|
-
import { defineCustomElement } from '
|
|
3
|
-
import { defineCustomElement as defineCustomElement$1 } from '
|
|
2
|
+
import { defineCustomElement } from '@tarojs/components/dist/components/taro-swiper-core';
|
|
3
|
+
import { defineCustomElement as defineCustomElement$1 } from '@tarojs/components/dist/components/taro-swiper-item-core';
|
|
4
4
|
import { isFunction } from '@tarojs/shared';
|
|
5
5
|
import { shouldBeObject } from '../../../utils/index.js';
|
|
6
6
|
import { MethodHandler } from '../../../utils/handler.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Current } from '@tarojs/runtime';
|
|
2
|
-
import { inlineStyle,
|
|
2
|
+
import { inlineStyle, getCurrentPath } from '../../../utils/index.js';
|
|
3
3
|
|
|
4
4
|
class Modal {
|
|
5
5
|
constructor() {
|
|
@@ -129,7 +129,7 @@ class Modal {
|
|
|
129
129
|
document.body.appendChild(this.el);
|
|
130
130
|
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
131
131
|
// Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
|
|
132
|
-
this.currentPath = (_b = (_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b :
|
|
132
|
+
this.currentPath = (_b = (_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getCurrentPath();
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
show(options = {}) {
|
|
@@ -179,7 +179,7 @@ class Modal {
|
|
|
179
179
|
this.el.style.display = 'block';
|
|
180
180
|
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
181
181
|
// Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
|
|
182
|
-
this.currentPath = (_b = (_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b :
|
|
182
|
+
this.currentPath = (_b = (_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getCurrentPath();
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
185
|
hide() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sources":["../../../../src/api/ui/interaction/modal.ts"],"sourcesContent":["import { Current } from '@tarojs/runtime'\n\nimport { getLaunchPage, inlineStyle } from '../../../utils'\n\nexport default class Modal {\n options = {\n title: '',\n content: '',\n showCancel: true,\n cancelText: '取消',\n cancelColor: '#000000',\n confirmText: '确定',\n confirmColor: '#3CC51F'\n }\n\n style = {\n maskStyle: {\n position: 'fixed',\n 'z-index': '1000',\n top: '0',\n right: '0',\n left: '0',\n bottom: '0',\n background: 'rgba(0,0,0,0.6)'\n },\n modalStyle: {\n 'z-index': '4999',\n position: 'fixed',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n width: '80%',\n 'max-width': '300px',\n 'border-radius': '3px',\n 'text-align': 'center',\n 'line-height': '1.6',\n overflow: 'hidden',\n background: '#FFFFFF'\n },\n titleStyle: {\n padding: '20px 24px 9px',\n 'font-size': '18px'\n },\n textStyle: {\n padding: '0 24px 12px',\n 'min-height': '40px',\n 'font-size': '15px',\n 'line-height': '1.3',\n color: '#808080'\n },\n footStyle: {\n position: 'relative',\n 'line-height': '48px',\n 'font-size': '18px',\n display: 'flex'\n },\n btnStyle: {\n position: 'relative',\n '-webkit-box-flex': '1',\n '-webkit-flex': '1',\n flex: '1'\n }\n }\n\n currentPath: string | null\n el: HTMLDivElement\n title: HTMLDivElement\n text: HTMLDivElement\n cancel: HTMLDivElement\n confirm: HTMLDivElement\n hideOpacityTimer: ReturnType<typeof setTimeout>\n hideDisplayTimer: ReturnType<typeof setTimeout>\n\n create (options = {}) {\n return new Promise<string>((resolve) => {\n // style\n const { maskStyle, modalStyle, titleStyle, textStyle, footStyle, btnStyle } = this.style\n\n // configuration\n const config = {\n ...this.options,\n ...options\n }\n\n // wrapper\n this.el = document.createElement('div')\n this.el.className = 'taro__modal'\n this.el.style.opacity = '0'\n this.el.style.transition = 'opacity 0.2s linear'\n\n // mask\n const mask = document.createElement('div')\n mask.className = 'taro-modal__mask'\n mask.setAttribute('style', inlineStyle(maskStyle))\n\n // modal\n const modal = document.createElement('div')\n modal.className = 'taro-modal__content'\n modal.setAttribute('style', inlineStyle(modalStyle))\n\n // title\n const titleCSS = config.title ? titleStyle : {\n ...titleStyle,\n display: 'none'\n }\n this.title = document.createElement('div')\n\n this.title.className = 'taro-modal__title'\n this.title.setAttribute('style', inlineStyle(titleCSS))\n this.title.textContent = config.title\n\n // text\n const textCSS = config.title ? textStyle : {\n ...textStyle,\n padding: '40px 20px 26px',\n color: '#353535'\n }\n this.text = document.createElement('div')\n this.text.className = 'taro-modal__text'\n this.text.setAttribute('style', inlineStyle(textCSS))\n this.text.textContent = config.content\n\n // foot\n const foot = document.createElement('div')\n foot.className = 'taro-modal__foot'\n foot.setAttribute('style', inlineStyle(footStyle))\n\n // cancel button\n const cancelCSS = {\n ...btnStyle,\n color: config.cancelColor,\n display: config.showCancel ? 'block' : 'none'\n }\n this.cancel = document.createElement('div')\n this.cancel.className = 'taro-model__btn taro-model__cancel'\n this.cancel.setAttribute('style', inlineStyle(cancelCSS))\n this.cancel.textContent = config.cancelText\n this.cancel.onclick = () => {\n this.hide()\n resolve('cancel')\n }\n\n // confirm button\n this.confirm = document.createElement('div')\n this.confirm.className = 'taro-model__btn taro-model__confirm'\n this.confirm.setAttribute('style', inlineStyle(btnStyle))\n this.confirm.style.color = config.confirmColor\n this.confirm.textContent = config.confirmText\n this.confirm.onclick = () => {\n this.hide()\n resolve('confirm')\n }\n\n // result\n foot.appendChild(this.cancel)\n foot.appendChild(this.confirm)\n modal.appendChild(this.title)\n modal.appendChild(this.text)\n modal.appendChild(foot)\n this.el.appendChild(mask)\n this.el.appendChild(modal)\n\n // show immediately\n document.body.appendChild(this.el)\n setTimeout(() => { this.el.style.opacity = '1' }, 0)\n\n // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path\n this.currentPath = Current.page?.path ?? getLaunchPage()\n })\n }\n\n show (options = {}) {\n return new Promise<string>((resolve) => {\n const config = {\n ...this.options,\n ...options\n }\n\n if (this.hideOpacityTimer) clearTimeout(this.hideOpacityTimer)\n if (this.hideDisplayTimer) clearTimeout(this.hideDisplayTimer)\n\n // title & text\n const { textStyle } = this.style\n\n if (config.title) {\n this.title.textContent = config.title\n // none => block\n this.title.style.display = 'block'\n this.text.setAttribute('style', inlineStyle(textStyle))\n } else {\n this.title.textContent = ''\n // block => none\n this.title.style.display = 'none'\n const textCSS = {\n ...textStyle,\n padding: '40px 20px 26px',\n color: '#353535'\n }\n this.text.setAttribute('style', inlineStyle(textCSS))\n }\n\n this.text.textContent = config.content || ''\n\n // showCancel\n this.cancel.style.display = config.showCancel ? 'block' : 'none'\n\n // cancelText\n this.cancel.textContent = config.cancelText || ''\n\n // cancelColor\n this.cancel.style.color = config.cancelColor || ''\n\n // confirmText\n this.confirm.textContent = config.confirmText || ''\n\n // confirmColor\n this.confirm.style.color = config.confirmColor || ''\n\n // cbs\n this.cancel.onclick = () => {\n this.hide()\n resolve('cancel')\n }\n this.confirm.onclick = () => {\n this.hide()\n resolve('confirm')\n }\n\n // show\n this.el.style.display = 'block'\n setTimeout(() => { this.el.style.opacity = '1' }, 0)\n\n // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path\n this.currentPath = Current.page?.path ?? getLaunchPage()\n })\n }\n\n hide () {\n if (this.hideOpacityTimer) clearTimeout(this.hideOpacityTimer)\n if (this.hideDisplayTimer) clearTimeout(this.hideDisplayTimer)\n\n this.currentPath = null\n\n this.hideOpacityTimer = setTimeout(() => {\n this.el.style.opacity = '0'\n this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none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CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAA;YAC3B,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC,MAAQ,EAAA,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAA,EAAE,EAAE,GAAG,CAAC,CAAA;SAClF,EAAE,CAAC,CAAC,CAAA;KACN;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"modal.js","sources":["../../../../src/api/ui/interaction/modal.ts"],"sourcesContent":["import { Current } from '@tarojs/runtime'\n\nimport { getCurrentPath, inlineStyle } from '../../../utils'\n\nexport default class Modal {\n options = {\n title: '',\n content: '',\n showCancel: true,\n cancelText: '取消',\n cancelColor: '#000000',\n confirmText: '确定',\n confirmColor: '#3CC51F'\n }\n\n style = {\n maskStyle: {\n position: 'fixed',\n 'z-index': '1000',\n top: '0',\n right: '0',\n left: '0',\n bottom: '0',\n background: 'rgba(0,0,0,0.6)'\n },\n modalStyle: {\n 'z-index': '4999',\n position: 'fixed',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n width: '80%',\n 'max-width': '300px',\n 'border-radius': '3px',\n 'text-align': 'center',\n 'line-height': '1.6',\n overflow: 'hidden',\n background: '#FFFFFF'\n },\n titleStyle: {\n padding: '20px 24px 9px',\n 'font-size': '18px'\n },\n textStyle: {\n padding: '0 24px 12px',\n 'min-height': '40px',\n 'font-size': '15px',\n 'line-height': '1.3',\n color: '#808080'\n },\n footStyle: {\n position: 'relative',\n 'line-height': '48px',\n 'font-size': '18px',\n display: 'flex'\n },\n btnStyle: {\n position: 'relative',\n '-webkit-box-flex': '1',\n '-webkit-flex': '1',\n flex: '1'\n }\n }\n\n currentPath: string | null\n el: HTMLDivElement\n title: HTMLDivElement\n text: HTMLDivElement\n cancel: HTMLDivElement\n confirm: HTMLDivElement\n hideOpacityTimer: ReturnType<typeof setTimeout>\n hideDisplayTimer: ReturnType<typeof setTimeout>\n\n create (options = {}) {\n return new Promise<string>((resolve) => {\n // style\n const { maskStyle, modalStyle, titleStyle, textStyle, footStyle, btnStyle } = this.style\n\n // configuration\n const config = {\n ...this.options,\n ...options\n }\n\n // wrapper\n this.el = document.createElement('div')\n this.el.className = 'taro__modal'\n this.el.style.opacity = '0'\n this.el.style.transition = 'opacity 0.2s linear'\n\n // mask\n const mask = document.createElement('div')\n mask.className = 'taro-modal__mask'\n mask.setAttribute('style', inlineStyle(maskStyle))\n\n // modal\n const modal = document.createElement('div')\n modal.className = 'taro-modal__content'\n modal.setAttribute('style', inlineStyle(modalStyle))\n\n // title\n const titleCSS = config.title ? titleStyle : {\n ...titleStyle,\n display: 'none'\n }\n this.title = document.createElement('div')\n\n this.title.className = 'taro-modal__title'\n this.title.setAttribute('style', inlineStyle(titleCSS))\n this.title.textContent = config.title\n\n // text\n const textCSS = config.title ? textStyle : {\n ...textStyle,\n padding: '40px 20px 26px',\n color: '#353535'\n }\n this.text = document.createElement('div')\n this.text.className = 'taro-modal__text'\n this.text.setAttribute('style', inlineStyle(textCSS))\n this.text.textContent = config.content\n\n // foot\n const foot = document.createElement('div')\n foot.className = 'taro-modal__foot'\n foot.setAttribute('style', inlineStyle(footStyle))\n\n // cancel button\n const cancelCSS = {\n ...btnStyle,\n color: config.cancelColor,\n display: config.showCancel ? 'block' : 'none'\n }\n this.cancel = document.createElement('div')\n this.cancel.className = 'taro-model__btn taro-model__cancel'\n this.cancel.setAttribute('style', inlineStyle(cancelCSS))\n this.cancel.textContent = config.cancelText\n this.cancel.onclick = () => {\n this.hide()\n resolve('cancel')\n }\n\n // confirm button\n this.confirm = document.createElement('div')\n this.confirm.className = 'taro-model__btn taro-model__confirm'\n this.confirm.setAttribute('style', inlineStyle(btnStyle))\n this.confirm.style.color = config.confirmColor\n this.confirm.textContent = config.confirmText\n this.confirm.onclick = () => {\n this.hide()\n resolve('confirm')\n }\n\n // result\n foot.appendChild(this.cancel)\n foot.appendChild(this.confirm)\n modal.appendChild(this.title)\n modal.appendChild(this.text)\n modal.appendChild(foot)\n this.el.appendChild(mask)\n this.el.appendChild(modal)\n\n // show immediately\n document.body.appendChild(this.el)\n setTimeout(() => { this.el.style.opacity = '1' }, 0)\n\n // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path\n this.currentPath = Current.page?.path ?? getCurrentPath()\n })\n }\n\n show (options = {}) {\n return new Promise<string>((resolve) => {\n const config = {\n ...this.options,\n ...options\n }\n\n if (this.hideOpacityTimer) clearTimeout(this.hideOpacityTimer)\n if (this.hideDisplayTimer) clearTimeout(this.hideDisplayTimer)\n\n // title & text\n const { textStyle } = this.style\n\n if (config.title) {\n this.title.textContent = config.title\n // none => block\n this.title.style.display = 'block'\n this.text.setAttribute('style', inlineStyle(textStyle))\n } else {\n this.title.textContent = ''\n // block => none\n this.title.style.display = 'none'\n const textCSS = {\n ...textStyle,\n padding: '40px 20px 26px',\n color: '#353535'\n }\n this.text.setAttribute('style', inlineStyle(textCSS))\n }\n\n this.text.textContent = config.content || ''\n\n // showCancel\n this.cancel.style.display = config.showCancel ? 'block' : 'none'\n\n // cancelText\n this.cancel.textContent = config.cancelText || ''\n\n // cancelColor\n this.cancel.style.color = config.cancelColor || ''\n\n // confirmText\n this.confirm.textContent = config.confirmText || ''\n\n // confirmColor\n this.confirm.style.color = config.confirmColor || ''\n\n // cbs\n this.cancel.onclick = () => {\n this.hide()\n resolve('cancel')\n }\n this.confirm.onclick = () => {\n this.hide()\n resolve('confirm')\n }\n\n // show\n this.el.style.display = 'block'\n setTimeout(() => { this.el.style.opacity = '1' }, 0)\n\n // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path\n this.currentPath = Current.page?.path ?? getCurrentPath()\n })\n }\n\n hide () {\n if (this.hideOpacityTimer) clearTimeout(this.hideOpacityTimer)\n if (this.hideDisplayTimer) clearTimeout(this.hideDisplayTimer)\n\n this.currentPath = null\n\n this.hideOpacityTimer = setTimeout(() => {\n this.el.style.opacity = '0'\n this.hideDisplayTimer = setTimeout(() => { this.el.style.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EAAE,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAA;YAC3B,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC,MAAQ,EAAA,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAA,EAAE,EAAE,GAAG,CAAC,CAAA;SAClF,EAAE,CAAC,CAAC,CAAA;KACN;AACF;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Current } from '@tarojs/runtime';
|
|
2
|
-
import { inlineStyle,
|
|
2
|
+
import { inlineStyle, getCurrentPath } from '../../../utils/index.js';
|
|
3
3
|
|
|
4
4
|
class Toast {
|
|
5
5
|
constructor() {
|
|
@@ -122,7 +122,7 @@ class Toast {
|
|
|
122
122
|
// disappear after duration
|
|
123
123
|
config.duration >= 0 && this.hide(config.duration, this.type);
|
|
124
124
|
// Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
|
|
125
|
-
this.currentPath = (_b = (_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b :
|
|
125
|
+
this.currentPath = (_b = (_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getCurrentPath();
|
|
126
126
|
return '';
|
|
127
127
|
}
|
|
128
128
|
show(options = {}, _type = 'toast') {
|
|
@@ -159,7 +159,7 @@ class Toast {
|
|
|
159
159
|
// disappear after duration
|
|
160
160
|
config.duration >= 0 && this.hide(config.duration, this.type);
|
|
161
161
|
// Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
|
|
162
|
-
this.currentPath = (_b = (_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b :
|
|
162
|
+
this.currentPath = (_b = (_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getCurrentPath();
|
|
163
163
|
return '';
|
|
164
164
|
}
|
|
165
165
|
hide(duration = 0, type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.js","sources":["../../../../src/api/ui/interaction/toast.ts"],"sourcesContent":["import { Current } from '@tarojs/runtime'\n\nimport { getLaunchPage, inlineStyle } from '../../../utils'\n\nexport default class Toast {\n options = {\n title: '',\n icon: 'none',\n image: '',\n duration: 1500,\n mask: false\n }\n\n style = {\n maskStyle: {\n position: 'fixed',\n 'z-index': '1000',\n top: '0',\n right: '0',\n left: '0',\n bottom: '0'\n },\n toastStyle: {\n 'z-index': '5000',\n 'box-sizing': 'border-box',\n display: 'flex',\n 'flex-direction': 'column',\n 'justify-content': 'center',\n '-webkit-justify-content': 'center',\n position: 'fixed',\n top: '50%',\n left: '50%',\n 'min-width': '120px',\n 'max-width': '200px',\n 'min-height': '120px',\n padding: '15px',\n transform: 'translate(-50%, -50%)',\n 'border-radius': '5px',\n 'text-align': 'center',\n 'line-height': '1.6',\n color: '#FFFFFF',\n background: 'rgba(17, 17, 17, 0.7)'\n },\n successStyle: {\n margin: '6px auto',\n width: '38px',\n height: '38px',\n background: 'transparent url(data:image/svg+xml;base64,PHN2ZyB0PSIxNjM5NTQ4OTYzMjA0IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjQzNDgiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMjE5Ljk1MiA1MTIuNTc2bDIxMC40MzIgMjEwLjQzMi00NS4yNDggNDUuMjU2LTIxMC40MzItMjEwLjQzMnoiIHAtaWQ9IjQzNDkiIGZpbGw9IiNmZmZmZmYiPjwvcGF0aD48cGF0aCBkPSJNNzk5LjY3MiAyNjIuMjY0bDQ1LjI1NiA0NS4yNTYtNDYwLjQ2NCA0NjAuNDY0LTQ1LjI1Ni00NS4yNTZ6IiBwLWlkPSI0MzUwIiBmaWxsPSIjZmZmZmZmIj48L3BhdGg+PC9zdmc+) no-repeat',\n 'background-size': '100%'\n },\n errrorStyle: {\n margin: '6px auto',\n width: '38px',\n height: '38px',\n background: 'transparent url(data:image/svg+xml;base64,PHN2ZyB0PSIxNjM5NTUxMDU1MTgzIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjE0MDc2IiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+PHBhdGggZD0iTTUxMiA2NEMyNjQuNTggNjQgNjQgMjY0LjU4IDY0IDUxMnMyMDAuNTggNDQ4IDQ0OCA0NDggNDQ4LTIwMC41OCA0NDgtNDQ4Uzc1OS40MiA2NCA1MTIgNjR6IG0wIDc1MmEzNiAzNiAwIDEgMSAzNi0zNiAzNiAzNiAwIDAgMS0zNiAzNnogbTUxLjgzLTU1MS45NUw1NDggNjM2YTM2IDM2IDAgMCAxLTcyIDBsLTE1LjgzLTM3MS45NWMtMC4xLTEuMzMtMC4xNy0yLjY4LTAuMTctNC4wNWE1MiA1MiAwIDAgMSAxMDQgMGMwIDEuMzctMC4wNyAyLjcyLTAuMTcgNC4wNXoiIHAtaWQ9IjE0MDc3IiBmaWxsPSIjZmZmZmZmIj48L3BhdGg+PC9zdmc+) no-repeat',\n 'background-size': '100%'\n },\n loadingStyle: {\n margin: '6px auto',\n width: '38px',\n height: '38px',\n '-webkit-animation': 'taroLoading 1s steps(12, end) infinite',\n animation: 'taroLoading 1s steps(12, end) infinite',\n background: 'transparent url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9Ij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IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=) no-repeat',\n 'background-size': '100%'\n },\n imageStyle: {\n margin: '6px auto',\n width: '40px',\n height: '40px',\n background: 'transparent no-repeat',\n 'background-size': '100%'\n },\n textStyle: {\n margin: '0',\n 'font-size': '16px'\n }\n }\n\n currentPath: string | null\n el: HTMLDivElement\n mask: HTMLDivElement\n icon: HTMLParagraphElement\n toast: HTMLDivElement\n title: HTMLParagraphElement\n type: any\n hideOpacityTimer: ReturnType<typeof setTimeout>\n hideDisplayTimer: ReturnType<typeof setTimeout>\n\n create (options = {}, _type: 'loading' | 'toast' = 'toast') {\n // style\n const { maskStyle, toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle, textStyle } = this.style\n\n // configuration\n const config = {\n ...this.options,\n ...options,\n _type\n }\n\n // wrapper\n this.el = document.createElement('div')\n this.el.className = 'taro__toast'\n this.el.style.opacity = '0'\n this.el.style.transition = 'opacity 0.1s linear'\n\n // mask\n this.mask = document.createElement('div')\n this.mask.setAttribute('style', inlineStyle(maskStyle))\n this.mask.style.display = config.mask ? 'block' : 'none'\n\n // icon\n this.icon = document.createElement('p')\n if (config.image) {\n this.icon.setAttribute('style', inlineStyle({\n ...imageStyle,\n 'background-image': `url(${config.image})`\n }))\n } else {\n const iconStyle = config.icon === 'loading' ? loadingStyle : config.icon === 'error' ? errrorStyle : successStyle\n this.icon.setAttribute('style', inlineStyle({\n ...iconStyle,\n ...(config.icon === 'none' ? { display: 'none' } : {})\n }))\n }\n\n // toast\n this.toast = document.createElement('div')\n this.toast.setAttribute('style', inlineStyle({\n ...toastStyle,\n ...(config.icon === 'none' ? {\n 'min-height': '0',\n padding: '10px 15px'\n } : {})\n }))\n\n // title\n this.title = document.createElement('p')\n this.title.setAttribute('style', inlineStyle(textStyle))\n this.title.textContent = config.title\n\n // result\n this.toast.appendChild(this.icon)\n this.toast.appendChild(this.title)\n this.el.appendChild(this.mask)\n this.el.appendChild(this.toast)\n\n // show immediately\n document.body.appendChild(this.el)\n setTimeout(() => { this.el.style.opacity = '1' }, 0)\n this.type = config._type\n\n // disappear after duration\n config.duration >= 0 && this.hide(config.duration, this.type)\n\n // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path\n this.currentPath = Current.page?.path ?? getLaunchPage()\n\n return ''\n }\n\n show (options = {}, _type: 'loading' | 'toast' = 'toast') {\n const config = {\n ...this.options,\n ...options,\n _type\n }\n\n if (this.hideOpacityTimer) clearTimeout(this.hideOpacityTimer)\n if (this.hideDisplayTimer) clearTimeout(this.hideDisplayTimer)\n\n // title\n this.title.textContent = config.title || ''\n\n // mask\n this.mask.style.display = config.mask ? 'block' : 'none'\n\n // image\n const { toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle } = this.style\n if (config.image) {\n this.icon.setAttribute('style', inlineStyle({\n ...imageStyle,\n 'background-image': `url(${config.image})`\n }))\n } else {\n if (!config.image && config.icon) {\n const iconStyle = config.icon === 'loading' ? loadingStyle : config.icon === 'error' ? errrorStyle : successStyle\n this.icon.setAttribute('style', inlineStyle({\n ...iconStyle,\n ...(config.icon === 'none' ? { display: 'none' } : {})\n }))\n }\n }\n\n // toast\n this.toast.setAttribute('style', inlineStyle({\n ...toastStyle,\n ...(config.icon === 'none' ? {\n 'min-height': '0',\n padding: '10px 15px'\n } : {})\n }))\n\n // show\n this.el.style.display = 'block'\n setTimeout(() => { this.el.style.opacity = '1' }, 0)\n this.type = config._type\n\n // disappear after duration\n config.duration >= 0 && this.hide(config.duration, this.type)\n\n // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path\n this.currentPath = Current.page?.path ?? getLaunchPage()\n\n return ''\n }\n\n hide (duration = 0, type) {\n if (this.type !== type) return\n\n if (this.hideOpacityTimer) clearTimeout(this.hideOpacityTimer)\n if (this.hideDisplayTimer) clearTimeout(this.hideDisplayTimer)\n\n this.currentPath = null\n\n this.hideOpacityTimer = setTimeout(() => {\n this.el.style.opacity = '0'\n this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none' }, 100)\n }, duration)\n }\n}\n"],"names":[],"mappings":";;;AAIc,MAAO,KAAK,CAAA;AAA1B,IAAA,WAAA,GAAA;AACE,QAAA,IAAA,CAAA,OAAO,GAAG;AACR,YAAA,KAAK,EAAE,EAAE;AACT,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,KAAK,EAAE,EAAE;AACT,YAAA,QAAQ,EAAE,IAAI;AACd,YAAA,IAAI,EAAE,KAAK;SACZ,CAAA;AAED,QAAA,IAAA,CAAA,KAAK,GAAG;AACN,YAAA,SAAS,EAAE;AACT,gBAAA,QAAQ,EAAE,OAAO;AACjB,gBAAA,SAAS,EAAE,MAAM;AACjB,gBAAA,GAAG,EAAE,GAAG;AACR,gBAAA,KAAK,EAAE,GAAG;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AAA,OAAO,EAAE,CAAA;KACV;AAED,IAAA,IAAI,CAAE,QAAQ,GAAG,CAAC,EAAE,IAAI,EAAA;AACtB,QAAA,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;YAAE,OAAM;QAE9B,IAAI,IAAI,CAAC,gBAAgB;AAAE,YAAA,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;QAC9D,IAAI,IAAI,CAAC,gBAAgB;AAAE,YAAA,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;AAE9D,QAAA,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;AAEvB,QAAA,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC,MAAK;YACtC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAA;YAC3B,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC,MAAQ,EAAA,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAA,EAAE,EAAE,GAAG,CAAC,CAAA;SAClF,EAAE,QAAQ,CAAC,CAAA;KACb;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"toast.js","sources":["../../../../src/api/ui/interaction/toast.ts"],"sourcesContent":["import { Current } from '@tarojs/runtime'\n\nimport { getCurrentPath, inlineStyle } from '../../../utils'\n\nexport default class Toast {\n options = {\n title: '',\n icon: 'none',\n image: '',\n duration: 1500,\n mask: false\n }\n\n style = {\n maskStyle: {\n position: 'fixed',\n 'z-index': '1000',\n top: '0',\n right: '0',\n left: '0',\n bottom: '0'\n },\n toastStyle: {\n 'z-index': '5000',\n 'box-sizing': 'border-box',\n display: 'flex',\n 'flex-direction': 'column',\n 'justify-content': 'center',\n '-webkit-justify-content': 'center',\n position: 'fixed',\n top: '50%',\n left: '50%',\n 'min-width': '120px',\n 'max-width': '200px',\n 'min-height': '120px',\n padding: '15px',\n transform: 'translate(-50%, -50%)',\n 'border-radius': '5px',\n 'text-align': 'center',\n 'line-height': '1.6',\n color: '#FFFFFF',\n background: 'rgba(17, 17, 17, 0.7)'\n },\n successStyle: {\n margin: '6px auto',\n width: '38px',\n height: '38px',\n background: 'transparent url(data:image/svg+xml;base64,PHN2ZyB0PSIxNjM5NTQ4OTYzMjA0IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjQzNDgiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMjE5Ljk1MiA1MTIuNTc2bDIxMC40MzIgMjEwLjQzMi00NS4yNDggNDUuMjU2LTIxMC40MzItMjEwLjQzMnoiIHAtaWQ9IjQzNDkiIGZpbGw9IiNmZmZmZmYiPjwvcGF0aD48cGF0aCBkPSJNNzk5LjY3MiAyNjIuMjY0bDQ1LjI1NiA0NS4yNTYtNDYwLjQ2NCA0NjAuNDY0LTQ1LjI1Ni00NS4yNTZ6IiBwLWlkPSI0MzUwIiBmaWxsPSIjZmZmZmZmIj48L3BhdGg+PC9zdmc+) no-repeat',\n 'background-size': '100%'\n },\n errrorStyle: {\n margin: '6px auto',\n width: '38px',\n height: '38px',\n background: 'transparent url(data:image/svg+xml;base64,PHN2ZyB0PSIxNjM5NTUxMDU1MTgzIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjE0MDc2IiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+PHBhdGggZD0iTTUxMiA2NEMyNjQuNTggNjQgNjQgMjY0LjU4IDY0IDUxMnMyMDAuNTggNDQ4IDQ0OCA0NDggNDQ4LTIwMC41OCA0NDgtNDQ4Uzc1OS40MiA2NCA1MTIgNjR6IG0wIDc1MmEzNiAzNiAwIDEgMSAzNi0zNiAzNiAzNiAwIDAgMS0zNiAzNnogbTUxLjgzLTU1MS45NUw1NDggNjM2YTM2IDM2IDAgMCAxLTcyIDBsLTE1LjgzLTM3MS45NWMtMC4xLTEuMzMtMC4xNy0yLjY4LTAuMTctNC4wNWE1MiA1MiAwIDAgMSAxMDQgMGMwIDEuMzctMC4wNyAyLjcyLTAuMTcgNC4wNXoiIHAtaWQ9IjE0MDc3IiBmaWxsPSIjZmZmZmZmIj48L3BhdGg+PC9zdmc+) no-repeat',\n 'background-size': '100%'\n },\n loadingStyle: {\n margin: '6px auto',\n width: '38px',\n height: '38px',\n '-webkit-animation': 'taroLoading 1s steps(12, end) infinite',\n animation: 'taroLoading 1s steps(12, end) infinite',\n background: 'transparent url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41Ii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HJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=) no-repeat',\n 'background-size': '100%'\n },\n imageStyle: {\n margin: '6px auto',\n width: '40px',\n height: '40px',\n background: 'transparent no-repeat',\n 'background-size': '100%'\n },\n textStyle: {\n margin: '0',\n 'font-size': '16px'\n }\n }\n\n currentPath: string | null\n el: HTMLDivElement\n mask: HTMLDivElement\n icon: HTMLParagraphElement\n toast: HTMLDivElement\n title: HTMLParagraphElement\n type: any\n hideOpacityTimer: ReturnType<typeof setTimeout>\n hideDisplayTimer: ReturnType<typeof setTimeout>\n\n create (options = {}, _type: 'loading' | 'toast' = 'toast') {\n // style\n const { maskStyle, toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle, textStyle } = this.style\n\n // configuration\n const config = {\n ...this.options,\n ...options,\n _type\n }\n\n // wrapper\n this.el = document.createElement('div')\n this.el.className = 'taro__toast'\n this.el.style.opacity = '0'\n this.el.style.transition = 'opacity 0.1s linear'\n\n // mask\n this.mask = document.createElement('div')\n this.mask.setAttribute('style', inlineStyle(maskStyle))\n this.mask.style.display = config.mask ? 'block' : 'none'\n\n // icon\n this.icon = document.createElement('p')\n if (config.image) {\n this.icon.setAttribute('style', inlineStyle({\n ...imageStyle,\n 'background-image': `url(${config.image})`\n }))\n } else {\n const iconStyle = config.icon === 'loading' ? loadingStyle : config.icon === 'error' ? errrorStyle : successStyle\n this.icon.setAttribute('style', inlineStyle({\n ...iconStyle,\n ...(config.icon === 'none' ? { display: 'none' } : {})\n }))\n }\n\n // toast\n this.toast = document.createElement('div')\n this.toast.setAttribute('style', inlineStyle({\n ...toastStyle,\n ...(config.icon === 'none' ? {\n 'min-height': '0',\n padding: '10px 15px'\n } : {})\n }))\n\n // title\n this.title = document.createElement('p')\n this.title.setAttribute('style', inlineStyle(textStyle))\n this.title.textContent = config.title\n\n // result\n this.toast.appendChild(this.icon)\n this.toast.appendChild(this.title)\n this.el.appendChild(this.mask)\n this.el.appendChild(this.toast)\n\n // show immediately\n document.body.appendChild(this.el)\n setTimeout(() => { this.el.style.opacity = '1' }, 0)\n this.type = config._type\n\n // disappear after duration\n config.duration >= 0 && this.hide(config.duration, this.type)\n\n // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path\n this.currentPath = Current.page?.path ?? getCurrentPath()\n\n return ''\n }\n\n show (options = {}, _type: 'loading' | 'toast' = 'toast') {\n const config = {\n ...this.options,\n ...options,\n _type\n }\n\n if (this.hideOpacityTimer) clearTimeout(this.hideOpacityTimer)\n if (this.hideDisplayTimer) clearTimeout(this.hideDisplayTimer)\n\n // title\n this.title.textContent = config.title || ''\n\n // mask\n this.mask.style.display = config.mask ? 'block' : 'none'\n\n // image\n const { toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle } = this.style\n if (config.image) {\n this.icon.setAttribute('style', inlineStyle({\n ...imageStyle,\n 'background-image': `url(${config.image})`\n }))\n } else {\n if (!config.image && config.icon) {\n const iconStyle = config.icon === 'loading' ? loadingStyle : config.icon === 'error' ? errrorStyle : successStyle\n this.icon.setAttribute('style', inlineStyle({\n ...iconStyle,\n ...(config.icon === 'none' ? { display: 'none' } : {})\n }))\n }\n }\n\n // toast\n this.toast.setAttribute('style', inlineStyle({\n ...toastStyle,\n ...(config.icon === 'none' ? {\n 'min-height': '0',\n padding: '10px 15px'\n } : {})\n }))\n\n // show\n this.el.style.display = 'block'\n setTimeout(() => { this.el.style.opacity = '1' }, 0)\n this.type = config._type\n\n // disappear after duration\n config.duration >= 0 && this.hide(config.duration, this.type)\n\n // Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path\n this.currentPath = Current.page?.path ?? getCurrentPath()\n\n return ''\n }\n\n hide (duration = 0, type) {\n if (this.type !== type) return\n\n if (this.hideOpacityTimer) clearTimeout(this.hideOpacityTimer)\n if (this.hideDisplayTimer) clearTimeout(this.hideDisplayTimer)\n\n this.currentPath = null\n\n this.hideOpacityTimer = setTimeout(() => {\n this.el.style.opacity = '0'\n this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none' }, 100)\n }, duration)\n }\n}\n"],"names":[],"mappings":";;;AAIc,MAAO,KAAK,CAAA;AAA1B,IAAA,WAAA,GAAA;AACE,QAAA,IAAA,CAAA,OAAO,GAAG;AACR,YAAA,KAAK,EAAE,EAAE;AACT,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,KAAK,EAAE,EAAE;AACT,YAAA,QAAQ,EAAE,IAAI;AACd,YAAA,IAAI,EAAE,KAAK;SACZ,CAAA;AAED,QAAA,IAAA,CAAA,KAAK,GAAG;AACN,YAAA,SAAS,EAAE;AACT,gBAAA,QAAQ,EAAE,OAAO;AACjB,gBAAA,SAAS,EAAE,MAAM;AACjB,gBAAA,GAAG,EAAE,GAAG;AACR,gBAAA,KAAK,EAAE,GAAG;AACV,gBAAA,IAAI,EAAE,GAAG;AACT,gBAAA,MAAM,EAAE,GAAG;AACZ,aAAA;AACD,YAAA,UAAU,EAAE;AACV,gBAAA,SAAS,EAAE,MAAM;AACjB,gBAAA,YAAY,EAAE,YAAY;AAC1B,gBAAA,OAAO,EAAE,MAAM;AACf,gBAAA,gBAAgB,EAAE,QAAQ;AAC1B,gBAAA,iBAAiB,EAAE,QAAQ;AAC3B,gBAAA,yBAAyB,EAAE,QAAQ;AACnC,gBAAA,QAAQ,EAAE,OAAO;AACjB,gBAAA,GAAG,EAAE,KAAK;AACV,gBAAA,IAAI,EAAE,KAAK;AACX,gBAAA,WAAW,EAAE,OAAO;AACpB,gBAAA,WAAW,EAAE,OAAO;AACpB,gBAAA,YAAY,EAAE,OAAO;AACrB,gBAAA,OAAO,EAAE,MAAM;AACf,gBAAA,SAAS,EAAE,uB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