@tarojs/components 3.7.0-canary.0 → 3.8.0-canary.0

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.
Files changed (71) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/taro-button-core.cjs.entry.js +1 -1
  3. package/dist/cjs/taro-components.cjs.js +1 -1
  4. package/dist/cjs/taro-image-core.cjs.entry.js +4 -3
  5. package/dist/cjs/taro-pull-to-refresh.cjs.entry.js +2 -2
  6. package/dist/cjs/taro-scroll-view-core.cjs.entry.js +4 -3
  7. package/dist/cjs/taro-swiper-core_2.cjs.entry.js +36 -35
  8. package/dist/collection/components/button/style/index.css +12 -0
  9. package/dist/collection/components/image/image.js +6 -4
  10. package/dist/collection/components/pull-to-refresh/pull-to-refresh.js +1 -1
  11. package/dist/collection/components/pull-to-refresh/style/index.css +0 -1
  12. package/dist/collection/components/scroll-view/scroll-view.js +22 -4
  13. package/dist/collection/components/swiper/swiper-item.js +34 -35
  14. package/dist/collection/components/swiper/swiper.js +2 -0
  15. package/dist/components/taro-button-core.js +1 -1
  16. package/dist/components/taro-image-core.js +6 -4
  17. package/dist/components/taro-pull-to-refresh.js +2 -2
  18. package/dist/components/taro-scroll-view-core.js +5 -3
  19. package/dist/components/taro-swiper-core.js +2 -0
  20. package/dist/components/taro-swiper-item-core.js +34 -35
  21. package/dist/esm/loader.js +1 -1
  22. package/dist/esm/taro-button-core.entry.js +1 -1
  23. package/dist/esm/taro-components.js +1 -1
  24. package/dist/esm/taro-image-core.entry.js +4 -3
  25. package/dist/esm/taro-pull-to-refresh.entry.js +2 -2
  26. package/dist/esm/taro-scroll-view-core.entry.js +4 -3
  27. package/dist/esm/taro-swiper-core_2.entry.js +36 -35
  28. package/dist/esm-es5/loader.js +1 -1
  29. package/dist/esm-es5/taro-button-core.entry.js +1 -1
  30. package/dist/esm-es5/taro-components.js +1 -1
  31. package/dist/esm-es5/taro-image-core.entry.js +1 -1
  32. package/dist/esm-es5/taro-pull-to-refresh.entry.js +1 -1
  33. package/dist/esm-es5/taro-scroll-view-core.entry.js +1 -1
  34. package/dist/esm-es5/taro-swiper-core_2.entry.js +1 -1
  35. package/dist/taro-components/{p-f07cd1de.entry.js → p-0114a2e4.entry.js} +1 -1
  36. package/dist/taro-components/{p-2accb92c.system.entry.js → p-2de2a3fd.system.entry.js} +1 -1
  37. package/dist/taro-components/p-478deb81.entry.js +1 -0
  38. package/dist/taro-components/{p-7152d85b.entry.js → p-7b68dee8.entry.js} +1 -1
  39. package/dist/taro-components/{p-a96b4b19.system.entry.js → p-7e998213.system.entry.js} +1 -1
  40. package/dist/taro-components/p-982bb5bf.entry.js +1 -0
  41. package/dist/taro-components/{p-cdb76676.system.entry.js → p-a4882902.system.entry.js} +1 -1
  42. package/dist/taro-components/p-ba3b2aa5.system.entry.js +1 -0
  43. package/dist/taro-components/p-ce33f1f3.entry.js +1 -0
  44. package/dist/taro-components/p-dab28e1f.system.entry.js +1 -0
  45. package/dist/taro-components/p-ed331c06.system.js +1 -1
  46. package/dist/taro-components/taro-components.esm.js +1 -1
  47. package/dist/types/components/image/image.d.ts +1 -0
  48. package/dist/types/components/scroll-view/scroll-view.d.ts +1 -0
  49. package/dist/types/components.d.ts +2 -0
  50. package/lib/react/react-component-lib/createOverlayComponent.js.map +1 -1
  51. package/lib/vue2/component-lib/index.js +0 -5
  52. package/lib/vue2/component-lib/index.js.map +1 -1
  53. package/lib/vue2/components-loader.js +1 -1
  54. package/lib/vue2/components-loader.js.map +1 -1
  55. package/lib/vue2/components.d.ts +1 -0
  56. package/lib/vue2/components.js +1 -0
  57. package/lib/vue2/components.js.map +1 -1
  58. package/lib/vue2/vue-component-lib/utils.js.map +1 -1
  59. package/lib/vue3/components.js +1 -0
  60. package/lib/vue3/components.js.map +1 -1
  61. package/lib/vue3/vue-component-lib/utils.js.map +1 -1
  62. package/package.json +6 -6
  63. package/types/Button.d.ts +62 -1
  64. package/types/ScrollView.d.ts +2 -2
  65. package/types/common.d.ts +4 -0
  66. package/types/index.vue3.d.ts +18 -9
  67. package/dist/taro-components/p-091a7153.entry.js +0 -1
  68. package/dist/taro-components/p-0cf235de.system.entry.js +0 -1
  69. package/dist/taro-components/p-4874f671.entry.js +0 -1
  70. package/dist/taro-components/p-719e1eaf.entry.js +0 -1
  71. package/dist/taro-components/p-7ff654e6.system.entry.js +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../taro-components-library-vue3/src/vue-component-lib/utils.ts"],"sourcesContent":["/**\n * Modify from https://github.com/ionic-team/stencil-ds-output-targets/blob/main/packages/vue-output-target/vue-component-lib/utils.ts\n * MIT License https://github.com/ionic-team/stencil-ds-output-targets/blob/main/LICENSE\n */\nimport { defineComponent, getCurrentInstance, h, inject, Ref, ref, VNode } from 'vue'\n\nexport interface InputProps<T> {\n modelValue?: T\n}\n\nconst UPDATE_VALUE_EVENT = 'update:modelValue'\nconst MODEL_VALUE = 'modelValue'\nconst ROUTER_LINK_VALUE = 'routerLink'\nconst NAV_MANAGER = 'navManager'\nconst ROUTER_PROP_PREFIX = 'router'\nconst ARIA_PROP_PREFIX = 'aria'\n/**\n * Starting in Vue 3.1.0, all properties are\n * added as keys to the props object, even if\n * they are not being used. In order to correctly\n * account for both value props and v-model props,\n * we need to check if the key exists for Vue <3.1.0\n * and then check if it is not undefined for Vue >= 3.1.0.\n * See https://github.com/vuejs/vue-next/issues/3889\n */\nconst EMPTY_PROP = Symbol('EMPTY_PROP')\nconst DEFAULT_EMPTY_PROP = { default: EMPTY_PROP }\n\ninterface NavManager<T = any> {\n navigate: (options: T) => void\n}\n\nconst getComponentClasses = (classes: unknown) => {\n return (classes as string)?.split(' ') || []\n}\n\nconst getElementClasses = (\n ref: Ref<HTMLElement | undefined>,\n componentClasses: Set<string>,\n defaultClasses: string[] = []\n) => {\n return [...Array.from(ref.value?.classList || []), ...defaultClasses].filter(\n (c: string, i, self) => !componentClasses.has(c) && self.indexOf(c) === i\n )\n}\n\n/**\n * Create a callback to define a Vue component wrapper around a Web Component.\n *\n * @prop name - The component tag name (i.e. `ion-button`)\n * @prop componentProps - An array of properties on the\n * component. These usually match up with the @Prop definitions\n * in each component's TSX file.\n * @prop customElement - An option custom element instance to pass\n * to customElements.define. Only set if `includeImportCustomElements: true` in your config.\n * @prop modelProp - The prop that v-model binds to (i.e. value)\n * @prop modelUpdateEvent - The event that is fired from your Web Component when the value changes (i.e. ionChange)\n * @prop externalModelUpdateEvent - The external event to fire from your Vue component when modelUpdateEvent fires. This is used for ensuring that v-model references have been\n * correctly updated when a user's event callback fires.\n */\nexport const defineContainer = <Props, VModelType = string | number | boolean>(\n name: string,\n defineCustomElement: any,\n componentProps: string[] = [],\n modelProp?: string,\n modelUpdateEvent?: string,\n externalModelUpdateEvent?: string\n) => {\n /**\n * Create a Vue component wrapper around a Web Component.\n * Note: The `props` here are not all properties on a component.\n * They refer to whatever properties are set on an instance of a component.\n */\n\n if (!DEPRECATED_ADAPTER_COMPONENT && defineCustomElement !== undefined) {\n defineCustomElement()\n }\n\n const Container = defineComponent<Props & InputProps<VModelType>>((props: any, { attrs, slots, emit }) => {\n let modelPropValue = props[modelProp]\n const containerRef = ref<HTMLElement>()\n const classes = new Set(getComponentClasses(attrs.class))\n const onVnodeBeforeMount = (vnode: VNode) => {\n // Add a listener to tell Vue to update the v-model\n if (vnode.el) {\n const eventsNames = Array.isArray(modelUpdateEvent) ? modelUpdateEvent : [modelUpdateEvent]\n eventsNames.forEach((eventName: string) => {\n vnode.el!.addEventListener(eventName.toLowerCase(), (e: Event) => {\n modelPropValue = (e?.target as any)[modelProp]\n emit(UPDATE_VALUE_EVENT, modelPropValue)\n\n /**\n * We need to emit the change event here\n * rather than on the web component to ensure\n * that any v-model bindings have been updated.\n * Otherwise, the developer will listen on the\n * native web component, but the v-model will\n * not have been updated yet.\n */\n if (externalModelUpdateEvent) {\n emit(externalModelUpdateEvent, e)\n }\n })\n })\n }\n }\n\n const currentInstance = getCurrentInstance()\n const hasRouter = currentInstance?.appContext?.provides[NAV_MANAGER]\n const navManager: NavManager | undefined = hasRouter ? inject(NAV_MANAGER) : undefined\n const handleRouterLink = (ev: Event) => {\n const { routerLink } = props\n if (routerLink === EMPTY_PROP) return\n\n if (navManager !== undefined) {\n const navigationPayload: any = { event: ev }\n for (const key in props) {\n const value = props[key]\n if (props.hasOwnProperty(key) && key.startsWith(ROUTER_PROP_PREFIX) && value !== EMPTY_PROP) {\n navigationPayload[key] = value\n }\n }\n\n navManager.navigate(navigationPayload)\n } else {\n console.warn('Tried to navigate, but no router was found. Make sure you have mounted Vue Router.')\n }\n }\n\n return () => {\n modelPropValue = props[modelProp]\n\n getComponentClasses(attrs.class).forEach((value) => {\n classes.add(value)\n })\n\n const oldClick = props.onClick\n const handleClick = (ev: Event) => {\n if (oldClick !== undefined) {\n oldClick(ev)\n }\n if (!ev.defaultPrevented) {\n handleRouterLink(ev)\n }\n }\n\n let propsToAdd: any = {\n ref: containerRef,\n class: getElementClasses(containerRef, classes),\n onClick: (ev: Event) => {\n handleClick(ev)\n emit('tap', ev) // Note(taro): 为 click 事件绑定 tap 事件\n },\n onVnodeBeforeMount: modelUpdateEvent ? onVnodeBeforeMount : undefined,\n }\n\n /**\n * We can use Object.entries here\n * to avoid the hasOwnProperty check,\n * but that would require 2 iterations\n * where as this only requires 1.\n */\n for (const key in props) {\n const value = props[key]\n if ((props.hasOwnProperty(key) && value !== EMPTY_PROP) || key.startsWith(ARIA_PROP_PREFIX)) {\n propsToAdd[key] = value\n }\n }\n\n if (modelProp) {\n /**\n * If form value property was set using v-model\n * then we should use that value.\n * Otherwise, check to see if form value property\n * was set as a static value (i.e. no v-model).\n */\n if (props[MODEL_VALUE] !== EMPTY_PROP) {\n propsToAdd = {\n ...propsToAdd,\n [modelProp]: props[MODEL_VALUE],\n }\n } else if (modelPropValue !== EMPTY_PROP) {\n propsToAdd = {\n ...propsToAdd,\n [modelProp]: modelPropValue,\n }\n }\n }\n\n return h(name, propsToAdd, slots.default && slots.default())\n }\n })\n\n Container.displayName = name\n\n Container.props = {\n [ROUTER_LINK_VALUE]: DEFAULT_EMPTY_PROP,\n }\n\n componentProps.forEach((componentProp) => {\n Container.props[componentProp] = DEFAULT_EMPTY_PROP\n })\n\n if (modelProp) {\n Container.props[MODEL_VALUE] = DEFAULT_EMPTY_PROP\n Container.emits = [UPDATE_VALUE_EVENT, externalModelUpdateEvent]\n }\n\n return Container\n}\n"],"names":[],"mappings":";;AAAA;;;AAGG;AAOH,MAAM,kBAAkB,GAAG,mBAAmB,CAAA;AAC9C,MAAM,WAAW,GAAG,YAAY,CAAA;AAChC,MAAM,iBAAiB,GAAG,YAAY,CAAA;AACtC,MAAM,WAAW,GAAG,YAAY,CAAA;AAChC,MAAM,kBAAkB,GAAG,QAAQ,CAAA;AACnC,MAAM,gBAAgB,GAAG,MAAM,CAAA;AAC/B;;;;;;;;AAQG;AACH,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;AACvC,MAAM,kBAAkB,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,CAAA;AAMlD,MAAM,mBAAmB,GAAG,CAAC,OAAgB,KAAI;AAC/C,IAAA,OAAO,CAAC,OAAkB,KAAlB,IAAA,IAAA,OAAO,KAAP,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,OAAO,CAAa,KAAK,CAAC,GAAG,CAAC,KAAI,EAAE,CAAA;AAC9C,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG,CACxB,GAAiC,EACjC,gBAA6B,EAC7B,cAAA,GAA2B,EAAE,KAC3B;;IACF,OAAO,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA,CAAA,EAAA,GAAA,GAAG,CAAC,KAAK,0CAAE,SAAS,KAAI,EAAE,CAAC,EAAE,GAAG,cAAc,CAAC,CAAC,MAAM,CAC1E,CAAC,CAAS,EAAE,CAAC,EAAE,IAAI,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,C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A;AAClB;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../taro-components-library-vue3/src/vue-component-lib/utils.ts"],"sourcesContent":["/**\n * Modify from https://github.com/ionic-team/stencil-ds-output-targets/blob/main/packages/vue-output-target/vue-component-lib/utils.ts\n * MIT License https://github.com/ionic-team/stencil-ds-output-targets/blob/main/LICENSE\n */\nimport { defineComponent, getCurrentInstance, h, inject, Ref,ref, VNode } from 'vue'\n\nexport interface InputProps<T> {\n modelValue?: T\n}\n\nconst UPDATE_VALUE_EVENT = 'update:modelValue'\nconst MODEL_VALUE = 'modelValue'\nconst ROUTER_LINK_VALUE = 'routerLink'\nconst NAV_MANAGER = 'navManager'\nconst ROUTER_PROP_PREFIX = 'router'\nconst ARIA_PROP_PREFIX = 'aria'\n/**\n * Starting in Vue 3.1.0, all properties are\n * added as keys to the props object, even if\n * they are not being used. In order to correctly\n * account for both value props and v-model props,\n * we need to check if the key exists for Vue <3.1.0\n * and then check if it is not undefined for Vue >= 3.1.0.\n * See https://github.com/vuejs/vue-next/issues/3889\n */\nconst EMPTY_PROP = Symbol('EMPTY_PROP')\nconst DEFAULT_EMPTY_PROP = { default: EMPTY_PROP }\n\ninterface NavManager<T = any> {\n navigate: (options: T) => void\n}\n\nconst getComponentClasses = (classes: unknown) => {\n return (classes as string)?.split(' ') || []\n}\n\nconst getElementClasses = (\n ref: Ref<HTMLElement | undefined>,\n componentClasses: Set<string>,\n defaultClasses: string[] = []\n) => {\n return [...Array.from(ref.value?.classList || []), ...defaultClasses].filter(\n (c: string, i, self) => !componentClasses.has(c) && self.indexOf(c) === i\n )\n}\n\n/**\n * Create a callback to define a Vue component wrapper around a Web Component.\n *\n * @prop name - The component tag name (i.e. `ion-button`)\n * @prop componentProps - An array of properties on the\n * component. These usually match up with the @Prop definitions\n * in each component's TSX file.\n * @prop customElement - An option custom element instance to pass\n * to customElements.define. Only set if `includeImportCustomElements: true` in your config.\n * @prop modelProp - The prop that v-model binds to (i.e. value)\n * @prop modelUpdateEvent - The event that is fired from your Web Component when the value changes (i.e. ionChange)\n * @prop externalModelUpdateEvent - The external event to fire from your Vue component when modelUpdateEvent fires. This is used for ensuring that v-model references have been\n * correctly updated when a user's event callback fires.\n */\nexport const defineContainer = <Props, VModelType = string | number | boolean>(\n name: string,\n defineCustomElement: any,\n componentProps: string[] = [],\n modelProp?: string,\n modelUpdateEvent?: string,\n externalModelUpdateEvent?: string\n) => {\n /**\n * Create a Vue component wrapper around a Web Component.\n * Note: The `props` here are not all properties on a component.\n * They refer to whatever properties are set on an instance of a component.\n */\n\n if (!DEPRECATED_ADAPTER_COMPONENT && defineCustomElement !== undefined) {\n defineCustomElement()\n }\n\n const Container = defineComponent<Props & InputProps<VModelType>>((props: any, { attrs, slots, emit }) => {\n let modelPropValue = props[modelProp]\n const containerRef = ref<HTMLElement>()\n const classes = new Set(getComponentClasses(attrs.class))\n const onVnodeBeforeMount = (vnode: VNode) => {\n // Add a listener to tell Vue to update the v-model\n if (vnode.el) {\n const eventsNames = Array.isArray(modelUpdateEvent) ? modelUpdateEvent : [modelUpdateEvent]\n eventsNames.forEach((eventName: string) => {\n vnode.el!.addEventListener(eventName.toLowerCase(), (e: Event) => {\n modelPropValue = (e?.target as any)[modelProp]\n emit(UPDATE_VALUE_EVENT, modelPropValue)\n\n /**\n * We need to emit the change event here\n * rather than on the web component to ensure\n * that any v-model bindings have been updated.\n * Otherwise, the developer will listen on the\n * native web component, but the v-model will\n * not have been updated yet.\n */\n if (externalModelUpdateEvent) {\n emit(externalModelUpdateEvent, e)\n }\n })\n })\n }\n }\n\n const currentInstance = getCurrentInstance()\n const hasRouter = currentInstance?.appContext?.provides[NAV_MANAGER]\n const navManager: NavManager | undefined = hasRouter ? inject(NAV_MANAGER) : undefined\n const handleRouterLink = (ev: Event) => {\n const { routerLink } = props\n if (routerLink === EMPTY_PROP) return\n\n if (navManager !== undefined) {\n const navigationPayload: any = { event: ev }\n for (const key in props) {\n const value = props[key]\n if (props.hasOwnProperty(key) && key.startsWith(ROUTER_PROP_PREFIX) && value !== EMPTY_PROP) {\n navigationPayload[key] = value\n }\n }\n\n navManager.navigate(navigationPayload)\n } else {\n console.warn('Tried to navigate, but no router was found. Make sure you have mounted Vue Router.')\n }\n }\n\n return () => {\n modelPropValue = props[modelProp]\n\n getComponentClasses(attrs.class).forEach((value) => {\n classes.add(value)\n })\n\n const oldClick = props.onClick\n const handleClick = (ev: Event) => {\n if (oldClick !== undefined) {\n oldClick(ev)\n }\n if (!ev.defaultPrevented) {\n handleRouterLink(ev)\n }\n }\n\n let propsToAdd: any = {\n ref: containerRef,\n class: getElementClasses(containerRef, classes),\n onClick: (ev: Event) => {\n handleClick(ev)\n emit('tap', ev) // Note(taro): 为 click 事件绑定 tap 事件\n },\n onVnodeBeforeMount: modelUpdateEvent ? onVnodeBeforeMount : undefined,\n }\n\n /**\n * We can use Object.entries here\n * to avoid the hasOwnProperty check,\n * but that would require 2 iterations\n * where as this only requires 1.\n */\n for (const key in props) {\n const value = props[key]\n if ((props.hasOwnProperty(key) && value !== EMPTY_PROP) || key.startsWith(ARIA_PROP_PREFIX)) {\n propsToAdd[key] = value\n }\n }\n\n if (modelProp) {\n /**\n * If form value property was set using v-model\n * then we should use that value.\n * Otherwise, check to see if form value property\n * was set as a static value (i.e. no v-model).\n */\n if (props[MODEL_VALUE] !== EMPTY_PROP) {\n propsToAdd = {\n ...propsToAdd,\n [modelProp]: props[MODEL_VALUE],\n }\n } else if (modelPropValue !== EMPTY_PROP) {\n propsToAdd = {\n ...propsToAdd,\n [modelProp]: modelPropValue,\n }\n }\n }\n\n return h(name, propsToAdd, slots.default && slots.default())\n }\n })\n\n Container.displayName = name\n\n Container.props = {\n [ROUTER_LINK_VALUE]: DEFAULT_EMPTY_PROP,\n }\n\n componentProps.forEach((componentProp) => {\n Container.props[componentProp] = DEFAULT_EMPTY_PROP\n })\n\n if (modelProp) {\n Container.props[MODEL_VALUE] = DEFAULT_EMPTY_PROP\n Container.emits = [UPDATE_VALUE_EVEN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CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,UAAU,CACb,EAAA,EAAA,CAAC,SAAS,GAAG,KAAK,CAAC,WAAW,CAAC,EAAA,CAChC,CAAA;AACF,iBAAA;qBAAM,IAAI,cAAc,KAAK,UAAU,EAAE;oBACxC,UAAU,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACL,UAAU,CACb,EAAA,EAAA,CAAC,SAAS,GAAG,cAAc,EAAA,CAC5B,CAAA;AACF,iBAAA;AACF,aAAA;AAED,YAAA,OAAO,CAAC,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;AAC9D,SAAC,CAAA;AACH,KAAC,CAAC,CAAA;AAEF,IAAA,SAAS,CAAC,WAAW,GAAG,IAAI,CAAA;IAE5B,SAAS,CAAC,KAAK,GAAG;QAChB,CAAC,iBAAiB,GAAG,kBAAkB;KACxC,CAAA;AAED,IAAA,cAAc,CAAC,OAAO,CAAC,CAAC,aAAa,KAAI;AACvC,QAAA,SAAS,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,kBAAkB,CAAA;AACrD,KAAC,CAAC,CAAA;AAEF,IAAA,IAAI,SAAS,EAAE;AACb,QAAA,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,kBAAkB,CAAA;QACjD,SAAS,CAAC,KAAK,GAAG,CAAC,kBAAkB,EAAE,wBAAwB,CAAC,CAAA;AACjE,KAAA;AAED,IAAA,OAAO,SAAS,CAAA;AAClB;;;;"}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@tarojs/components",
3
- "version": "3.7.0-canary.0",
3
+ "version": "3.8.0-canary.0",
4
4
  "description": "Taro 组件库",
5
5
  "browser": "dist/index.js",
6
6
  "main:h5": "dist/index.js",
7
7
  "main": "dist/index.js",
8
- "module": "dist/index.js",
8
+ "module": "dist/index.cjs.js",
9
9
  "types": "types/index.d.ts",
10
10
  "sideEffects": [
11
11
  "*.scss",
@@ -37,9 +37,9 @@
37
37
  "resolve-pathname": "^3.0.0",
38
38
  "swiper": "6.8.0",
39
39
  "weui": "^1.1.2",
40
- "@tarojs/components-advanced": "3.7.0-canary.0",
41
- "@tarojs/router": "3.7.0-canary.0",
42
- "@tarojs/taro": "3.7.0-canary.0"
40
+ "@tarojs/components-advanced": "3.8.0-canary.0",
41
+ "@tarojs/router": "3.8.0-canary.0",
42
+ "@tarojs/taro": "3.8.0-canary.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@babel/generator": "^7.20.0",
@@ -83,7 +83,7 @@
83
83
  "dev:library-react": "cross-env NODE_ENV=development pnpm --filter @tarojs/components-library-react run dev",
84
84
  "dev:library-vue2": "cross-env NODE_ENV=development pnpm --filter @tarojs/components-library-vue2 run dev",
85
85
  "dev:library-vue3": "cross-env NODE_ENV=development pnpm --filter @tarojs/components-library-vue3 run dev",
86
- "generate:lib": "mkdirp lib",
86
+ "generate:lib": "mkdir -p lib",
87
87
  "generate:stencil-config": "esbuild ./scripts/stencil/stencil.config.ts --bundle --platform=node --outfile=stencil.config.js",
88
88
  "sync:types": "pnpm run tsx --files scripts/json-schema-to-types.ts",
89
89
  "test": "cross-env NODE_ENV=test stencil test --spec --e2e",
package/types/Button.d.ts CHANGED
@@ -165,6 +165,10 @@ interface ButtonProps extends StandardProps {
165
165
  * @supported qq
166
166
  */
167
167
  shareMessageImg?: string
168
+ /** 跳转抖音号个人页,只支持小程序绑定的品牌号、员工号、合作号
169
+ * @supported tt
170
+ */
171
+ dataAwemeId?: string
168
172
  /** 用户点击该按钮时,会返回获取到的用户信息,回调的detail数据与 Taro.getUserInfo 返回的一致
169
173
  *
170
174
  * 生效时机: `open-type="getUserInfo"`
@@ -189,6 +193,11 @@ interface ButtonProps extends StandardProps {
189
193
  * @supported weapp, alipay, swan, tt, jd
190
194
  */
191
195
  onGetPhoneNumber?: CommonEventFunction<ButtonProps.onGetPhoneNumberEventDetail>
196
+ /**
197
+ * 手机号实时验证回调,`open-type="getRealtimePhoneNumber"` 时有效
198
+ * @supported weapp
199
+ */
200
+ onGetRealTimePhoneNumber?: CommonEventFunction<ButtonProps.onGetRealTimePhoneNumberEventDetail>
192
201
  /** 当使用开放能力时,发生错误的回调
193
202
  *
194
203
  * 生效时机:`open-type="launchApp"`
@@ -213,6 +222,11 @@ interface ButtonProps extends StandardProps {
213
222
  * @supported weapp
214
223
  */
215
224
  onChooseAvatar?: CommonEventFunction
225
+ /**
226
+ * 用户同意隐私协议事件回调,`open-type="agreePrivacyAuthorization"`时有效
227
+ * @supported weapp
228
+ */
229
+ onAgreePrivacyAuthorization?: CommonEventFunction
216
230
  /** 点击。
217
231
  * 说明: 每点击一次会触发一次事件,建议自行使用代码防止重复点击,可以使用 js 防抖和节流实现。
218
232
  * @supported alipay
@@ -251,6 +265,12 @@ interface ButtonProps extends StandardProps {
251
265
  * @supported qq
252
266
  */
253
267
  onAddGroupApp?: CommonEventFunction
268
+ /** 监听跳转抖音号个人页的回调
269
+ *
270
+ * 生效时机:`open-type="openAwemeUserProfile"`
271
+ * @supported tt
272
+ */
273
+ onOpenAwemeUserProfile?: CommonEventFunction
254
274
  }
255
275
  declare namespace ButtonProps {
256
276
  /** size 的合法值 */
@@ -277,7 +297,7 @@ declare namespace ButtonProps {
277
297
  reset
278
298
  }
279
299
  /** open-type 的合法值 */
280
- type OpenType = keyof openTypeKeys['weapp'] | keyof openTypeKeys['alipay'] | keyof openTypeKeys['qq']
300
+ type OpenType = keyof openTypeKeys['weapp'] | keyof openTypeKeys['alipay'] | keyof openTypeKeys['qq'] | keyof openTypeKeys['tt']
281
301
  /** open-type 的合法值 */
282
302
  interface openTypeKeys {
283
303
  weapp: {
@@ -293,6 +313,11 @@ declare namespace ButtonProps {
293
313
  * @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html
294
314
  */
295
315
  getPhoneNumber
316
+ /**
317
+ * 手机号实时验证,向用户申请,并在用户同意后,快速填写和实时验证手机号。(*小程序插件中不能使用*)
318
+ * @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getRealtimePhoneNumber.html
319
+ */
320
+ getRealtimePhoneNumber
296
321
  /** 获取用户信息,可以从回调中获取到用户信息 */
297
322
  getUserInfo
298
323
  /** 打开APP,可以通过 app-parameter 属性设定向APP传的参数
@@ -305,6 +330,10 @@ declare namespace ButtonProps {
305
330
  feedback
306
331
  /** 获取用户头像,可以从回调中获得具体信息 */
307
332
  chooseAvatar
333
+ /**
334
+ * 用户同意隐私协议按钮。可通过 bindagreeprivacyauthorization 监听用户同意隐私协议事件
335
+ */
336
+ agreePrivacyAuthorization
308
337
  }
309
338
  /** 支付宝小程序专属的 open-type 合法值
310
339
  * @see https://opendocs.alipay.com/mini/component/button
@@ -350,6 +379,35 @@ declare namespace ButtonProps {
350
379
  /** 在自定义开放数据域组件中,向指定好友发起分享据 */
351
380
  shareMessageToFriend
352
381
  }
382
+ /** TT 小程序专属的 open-type 合法值
383
+ * @see https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/component/list/button/#open-type-%E7%9A%84%E5%90%88%E6%B3%95%E5%80%BC
384
+ */
385
+ tt: {
386
+ /** 触发用户转发, 可以配合 data-channel 属性来设置分享的 channel,具体请参考 ShareParam */
387
+ share
388
+ /** 获取用户手机号,可以从 bindgetphonenumber 回调中获取到用户信息,详情请参见获取手机号 */
389
+ getPhoneNumber
390
+ /** 跳转到抖音IM客服,详情请参见抖音IM客服能力 */
391
+ im
392
+ /** 跳转到抖音平台客服,详情请参见平台客服能力 */
393
+ platformIm
394
+ /** 跳转视频播放页,详情请参见跳转视频播放页 */
395
+ navigateToVideoView
396
+ /** 跳转抖音号个人页,详情请参见跳转抖音号个人页 */
397
+ openAwemeUserProfile
398
+ /** 跳转抖音直播间,详情请参见跳转抖音直播间 */
399
+ openWebcastRoom
400
+ /** 写入系统日历,详情请参见写入系统日历 */
401
+ addCalendarEvent
402
+ /** 添加到桌面,详情请参见添加到桌面 */
403
+ addShortcut
404
+ /** 加群,详情请参见加群 */
405
+ joinGroup
406
+ /** 私信,详情请参见私信 */
407
+ privateMessage
408
+ /** 主动授权私信,详情请参见主动授权私信 */
409
+ authorizePrivateMessage
410
+ }
353
411
  }
354
412
  /** lang 的合法值 */
355
413
  interface Lang {
@@ -426,6 +484,9 @@ declare namespace ButtonProps {
426
484
  */
427
485
  sign: string
428
486
  }
487
+ interface onGetRealTimePhoneNumberEventDetail {
488
+ code: string
489
+ }
429
490
  interface onOpenSettingEventDetail {
430
491
  /* 打开授权设置页的调用状态 */
431
492
  errMsg: string
@@ -1,5 +1,5 @@
1
1
  import { ComponentType } from 'react'
2
- import { StandardProps, CommonEventFunction, BaseEventOrigFunction } from './common'
2
+ import { BaseEventOrigFunction, CommonEventFunction, StandardProps } from './common'
3
3
  interface ScrollViewProps extends StandardProps {
4
4
  /** 允许横向滚动
5
5
  * @default false
@@ -157,7 +157,7 @@ interface ScrollViewProps extends StandardProps {
157
157
  * center - 目标节点显示在视口中间
158
158
  * end - 目标节点显示在视口结束处
159
159
  * nearest - 目标节点在就近的视口边缘显示,若节点已在视口内则不触发滚动
160
- * @supported weapp
160
+ * @supported weapp, h5
161
161
  * @default 'start'
162
162
  */
163
163
  scrollIntoViewAlignment?: 'start' | 'center' | 'end' | 'nearest'
package/types/common.d.ts CHANGED
@@ -26,6 +26,10 @@ export interface StandardProps<T = any, TouchEvent extends BaseTouchEvent<any> =
26
26
  dangerouslySetInnerHTML?: {
27
27
  __html: string
28
28
  }
29
+ /**
30
+ * 是否开启小程序编译模式
31
+ */
32
+ compileMode?: boolean
29
33
  }
30
34
 
31
35
  export interface FormItemProps {
@@ -18,9 +18,9 @@ import { AdCustomProps } from './AdCustom'
18
18
  import { AudioProps } from './Audio'
19
19
  import { ButtonProps } from './Button'
20
20
  import { CameraProps } from './Camera'
21
+ import { CanvasProps } from './Canvas'
21
22
  import { ChannelLiveProps } from './ChannelLive'
22
23
  import { ChannelVideoProps } from './ChannelVideo'
23
- import { CanvasProps } from './Canvas'
24
24
  import { CheckboxProps } from './Checkbox'
25
25
  import { CheckboxGroupProps } from './CheckboxGroup'
26
26
  import { StandardProps } from './common'
@@ -30,17 +30,20 @@ import { CustomWrapperProps } from './CustomWrapper'
30
30
  import { EditorProps } from './Editor'
31
31
  import { FormProps } from './Form'
32
32
  import { FunctionalPageNavigatorProps } from './FunctionalPageNavigator'
33
+ import { GridViewProps } from './GridView'
33
34
  import { IconProps } from './Icon'
34
35
  import { ImageProps } from './Image'
35
36
  import { InputProps } from './Input'
36
37
  import { KeyboardAccessoryProps } from './KeyboardAccessory'
37
38
  import { LabelProps } from './Label'
39
+ import { ListViewProps } from './ListView'
38
40
  import { LivePlayerProps } from './LivePlayer'
39
41
  import { LivePusherProps } from './LivePusher'
40
42
  import { MapProps } from './Map'
41
43
  import { MatchMediaProps } from './MatchMedia'
42
44
  import { MovableAreaProps } from './MovableArea'
43
45
  import { MovableViewProps } from './MovableView'
46
+ import { NativeSlotProps } from './NativeSlot'
44
47
  import { NavigationBarProps } from './NavigationBar'
45
48
  import { NavigatorProps } from './Navigator'
46
49
  import { OfficialAccountProps } from './OfficialAccount'
@@ -52,14 +55,18 @@ import {
52
55
  PickerRegionProps, PickerSelectorProps, PickerTimeProps
53
56
  } from './Picker'
54
57
  import { PickerViewProps } from './PickerView'
58
+ import { PickerViewColumnProps } from './PickerViewColumn'
55
59
  import { ProgressProps } from './Progress'
56
60
  import { RadioProps } from './Radio'
57
61
  import { RadioGroupProps } from './RadioGroup'
58
62
  import { RichTextProps } from './RichText'
63
+ import { RootPortalProps } from './RootPortal'
59
64
  import { ScrollViewProps } from './ScrollView'
60
65
  import { ShareElementProps } from './ShareElement'
61
66
  import { SliderProps } from './Slider'
62
67
  import { SlotProps } from './Slot'
68
+ import { StickyHeaderProps } from './StickyHeader'
69
+ import { StickySectionProps } from './StickySection'
63
70
  import { SwiperProps } from './Swiper'
64
71
  import { SwiperItemProps } from './SwiperItem'
65
72
  import { SwitchProps } from './Switch'
@@ -69,16 +76,18 @@ import { VideoProps } from './Video'
69
76
  import { ViewProps } from './View'
70
77
  import { VoipRoomProps } from './VoipRoom'
71
78
  import { WebViewProps } from './WebView'
72
- import { RootPortalProps } from './RootPortal'
73
- import { PickerViewColumnProps } from './PickerViewColumn'
74
- import { NativeSlotProps } from './NativeSlot'
75
- import { GridViewProps } from './GridView'
76
- import { ListViewProps } from './ListView'
77
- import { StickyHeaderProps } from './StickyHeader'
78
- import { StickySectionProps } from './StickySection'
79
+
80
+ /** 因为react的事件是CamelCase而vue得是Camelcase, 所以需要转换 */
81
+ type OnCamelCaseToOnCamelcase<T extends string> = T extends `on${infer Rest}`
82
+ ? `on${Capitalize<Lowercase<Rest>>}`
83
+ : T;
84
+
85
+ type TransformCamelCase<T extends Record<string, any>> = {
86
+ [key in keyof T as OnCamelCaseToOnCamelcase<key>]: T[key]
87
+ }
79
88
 
80
89
  /** 联合类型不能用omit(比如picker) */
81
- type DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never
90
+ type DistributiveOmit<T, K extends keyof T> = T extends unknown ? TransformCamelCase<Omit<T, K>> : never
82
91
 
83
92
  interface SlimProps {
84
93
  class?: any
@@ -1 +0,0 @@
1
- import{r as t,c as o,h as s,H as i,g as l}from"./p-9137dcab.js";import{c as r}from"./p-de951a46.js";import{d as e}from"./p-d3c7f87d.js";function c(t,o,s=500,i){if(t===o||"number"!=typeof t)return;const l=o-t,r=Date.now(),e=o>=t;!function c(){var h;h=Date.now()-r,t=l*h/s+t,e&&t>=o||!e&&o>=t?i(o):(i(t),requestAnimationFrame(c))}()}const h=class{constructor(s){t(this,s),this.onScroll=o(this,"scroll",3),this.onScrollToUpper=o(this,"scrolltoupper",3),this.onScrollToLower=o(this,"scrolltolower",3),this._scrollLeft=0,this._scrollTop=0,this.upperAndLower=e((()=>{const{offsetWidth:t,offsetHeight:o,scrollLeft:s,scrollTop:i,scrollHeight:l,scrollWidth:r}=this.el,e=Number(this.lowerThreshold),c=Number(this.upperThreshold);!isNaN(e)&&(this.scrollY&&o+i+e>=l||this.scrollX&&t+s+e>=r)&&this.onScrollToLower.emit({direction:this.scrollX?"right":this.scrollY?"bottom":""}),!isNaN(c)&&(this.scrollY&&i<=c||this.scrollX&&s<=c)&&this.onScrollToUpper.emit({direction:this.scrollX?"left":this.scrollY?"top":""})}),200),this.scrollX=!1,this.scrollY=!1,this.upperThreshold=50,this.lowerThreshold=50,this.mpScrollTop=void 0,this.mpScrollLeft=void 0,this.mpScrollIntoView=void 0,this.animated=!1}watchScrollLeft(t){const o=Number(t),{animated:s}=this;this.mpScrollToMethod({left:o,animated:s})}watchScrollTop(t){const o=Number(t),{animated:s}=this;this.mpScrollToMethod({top:o,animated:s})}watchScrollIntoView(t){this.mpScrollIntoViewMethod(t)}handleScroll(t){if(t instanceof CustomEvent)return;t.stopPropagation();const{scrollLeft:o,scrollTop:s,scrollHeight:i,scrollWidth:l}=this.el;this._scrollLeft=o,this._scrollTop=s,this.upperAndLower(),this.onScroll.emit({scrollLeft:o,scrollTop:s,scrollHeight:i,scrollWidth:l})}async mpScrollToMethod(t){let{top:o,left:s,duration:i,animated:l=!1}=t;this.scrollY&&"number"==typeof o&&!isNaN(o)&&o!==this._scrollTop&&(l?c(this._scrollTop,o,i,(t=>this.el.scrollTop=t)):this.el.scrollTop=o,this._scrollTop=o),this.scrollX&&"number"==typeof s&&!isNaN(s)&&s!==this._scrollLeft&&(l?c(this._scrollLeft,s,i,(t=>this.el.scrollLeft=t)):this.el.scrollLeft=s,this._scrollLeft=s)}async mpScrollIntoViewMethod(t){var o;"string"==typeof t&&t&&(null===(o=document.querySelector(`#${t}`))||void 0===o||o.scrollIntoView({behavior:"smooth",block:"center",inline:"start"}))}componentDidLoad(){const t=Number(this.mpScrollTop),o=Number(this.mpScrollLeft),{animated:s}=this;this.mpScrollToMethod({top:t,left:o,animated:s})}render(){const{scrollX:t,scrollY:o}=this,l=r({"taro-scroll-view__scroll-x":t,"taro-scroll-view__scroll-y":o});return s(i,{class:l},s("slot",null))}get el(){return l(this)}static get watchers(){return{mpScrollLeft:["watchScrollLeft"],mpScrollTop:["watchScrollTop"],mpScrollIntoView:["watchScrollIntoView"]}}};h.style="taro-scroll-view-core{display:block;width:100%;-webkit-overflow-scrolling:auto}taro-scroll-view-core::-webkit-scrollbar{display:none}.taro-scroll-view__scroll-x{overflow-x:scroll;overflow-y:hidden}.taro-scroll-view__scroll-y{overflow-x:hidden;overflow-y:scroll}";export{h as taro_scroll_view_core}
@@ -1 +0,0 @@
1
- System.register(["./p-7e6b54cb.system.js","./p-2ec68968.system.js"],(function(o){"use strict";var t,r,e,a,i,n;return{setters:[function(o){t=o.r;r=o.c;e=o.h;a=o.H;i=o.g},function(o){n=o.c}],execute:function(){var c='taro-button-core{display:block;overflow:hidden;position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;margin-left:auto;margin-right:auto;padding-left:14px;padding-right:14px;border-width:0;border-radius:5px;width:100%;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:0;background-color:#f8f8f8;line-height:2.55555556;text-decoration:none;text-align:center;font-size:18px;color:#000;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)}taro-button-core:focus{outline:0}taro-button-core:not([disabled]):active{background-color:#dedede;color:rgba(0, 0, 0, 0.6)}taro-button-core::after{position:absolute;left:0;top:0;-webkit-box-sizing:border-box;box-sizing:border-box;border:1px solid rgba(0, 0, 0, 0.2);border-radius:10px;width:200%;height:200%;content:" ";-webkit-transform:scale(0.5);transform:scale(0.5);-webkit-transform-origin:0 0;transform-origin:0 0}taro-button-core+taro-button-core{margin-top:15px}taro-button-core[type=default]{background-color:#f8f8f8;color:#000}taro-button-core[type=default]:not([disabled]):visited{color:#000}taro-button-core[type=default]:not([disabled]):active{background-color:#dedede;color:rgba(0, 0, 0, 0.6)}taro-button-core[size=mini]{display:inline-block;padding:0 1.32em;width:auto;line-height:2.3;font-size:13px}taro-button-core[plain],taro-button-core[plain][type=default],taro-button-core[plain][type=primary]{border-width:1px;background-color:transparent}taro-button-core[disabled]{color:rgba(255, 255, 255, 0.6)}taro-button-core[disabled][type=default]{background-color:#f7f7f7;color:rgba(0, 0, 0, 0.3)}taro-button-core[disabled][type=primary]{background-color:#9ed99d}taro-button-core[disabled][type=warn]{background-color:#ec8b89}taro-button-core[loading] .weui-loading{margin:-0.2em 0.34em 0 0}taro-button-core[loading][type=primary],taro-button-core[loading][type=warn]{color:rgba(255, 255, 255, 0.6)}taro-button-core[loading][type=primary]{background-color:#179b16}taro-button-core[loading][type=warn]{background-color:#ce3c39}taro-button-core[plain][type=primary]{border:1px solid #1aad19;color:#1aad19}taro-button-core[plain][type=primary]:not([disabled]):active{border-color:rgba(26, 173, 25, 0.6);background-color:transparent;color:rgba(26, 173, 25, 0.6)}taro-button-core[plain][type=primary]::after{border-width:0}taro-button-core[plain],taro-button-core[plain][type=default]{border:1px solid #353535;color:#353535}taro-button-core[plain]:not([disabled]):active,taro-button-core[plain][type=default]:not([disabled]):active{border-color:rgba(53, 53, 53, 0.6);background-color:transparent;color:rgba(53, 53, 53, 0.6)}taro-button-core[plain]::after,taro-button-core[plain][type=default]::after{border-width:0}taro-button-core[type=primary]{background-color:#1aad19;color:#fff}taro-button-core[type=primary]:not([disabled]):visited{color:#fff}taro-button-core[type=primary]:not([disabled]):active{background-color:#179b16;color:rgba(255, 255, 255, 0.6)}taro-button-core[type=warn]{background-color:#e64340;color:#fff}taro-button-core[type=warn]:not([disabled]):visited{color:#fff}taro-button-core[type=warn]:not([disabled]):active{background-color:#ce3c39;color:rgba(255, 255, 255, 0.6)}taro-button-core[plain][disabled]{border:1px solid rgba(0, 0, 0, 0.2);background-color:#f7f7f7;color:rgba(0, 0, 0, 0.3)}taro-button-core[plain][disabled][type=primary]{border:1px solid rgba(0, 0, 0, 0.2);background-color:#f7f7f7;color:rgba(0, 0, 0, 0.3)}';var d=o("taro_button_core",function(){function o(o){t(this,o);this.onSubmit=r(this,"tarobuttonsubmit",7);this.onReset=r(this,"tarobuttonreset",7);this.disabled=undefined;this.hoverClass="button-hover";this.type="";this.hoverStartTime=20;this.hoverStayTime=70;this.size=undefined;this.plain=undefined;this.loading=false;this.formType=null;this.hover=false;this.touch=false}o.prototype.onClick=function(o){if(this.disabled){o.stopPropagation()}};o.prototype.onTouchStart=function(){var o=this;if(this.disabled){return}this.touch=true;if(this.hoverClass&&!this.disabled){setTimeout((function(){if(o.touch){o.hover=true}}),this.hoverStartTime)}};o.prototype.onTouchEnd=function(){var o=this;if(this.disabled){return}this.touch=false;if(this.hoverClass&&!this.disabled){setTimeout((function(){if(!o.touch){o.hover=false}}),this.hoverStayTime)}if(this.formType==="submit"){this.onSubmit.emit()}else if(this.formType==="reset"){this.onReset.emit()}};o.prototype.render=function(){var o;var t=this,r=t.disabled,i=t.hoverClass,c=t.type,d=t.size,b=t.plain,l=t.loading,s=t.hover;var u=n((o={},o["".concat(i)]=s&&!r,o));return e(a,{class:u,type:c,plain:b,loading:l,size:d,disabled:r},l&&e("i",{class:"weui-loading"}),e("slot",null))};Object.defineProperty(o.prototype,"el",{get:function(){return i(this)},enumerable:false,configurable:true});return o}());d.style=c}}}));
@@ -1 +0,0 @@
1
- import{r as t,c as i,h as o,H as e}from"./p-9137dcab.js";import{c as s}from"./p-de951a46.js";import("./p-72f327e1.js");const a=class{constructor(o){t(this,o),this.onLoad=i(this,"load",7),this.onError=i(this,"error",7),this.src=void 0,this.mode="scaleToFill",this.lazyLoad=!1,this.nativeProps={},this.aspectFillMode="width"}componentDidLoad(){if(!this.lazyLoad)return;const t=new IntersectionObserver((i=>{i[i.length-1].isIntersecting&&(t.unobserve(this.imgRef),this.imgRef.src=this.src)}),{rootMargin:"300px 0px"});t.observe(this.imgRef)}imageOnLoad(){const{width:t,height:i,naturalWidth:o,naturalHeight:e}=this.imgRef;this.onLoad.emit({width:t,height:i}),this.aspectFillMode=o>e?"width":"height"}imageOnError(t){this.onError.emit(t)}render(){const{src:t,mode:i="scaleToFill",lazyLoad:a=!1,aspectFillMode:h="width",imageOnLoad:r,imageOnError:m,nativeProps:d}=this,g=s({"taro-img__widthfix":"widthFix"===i}),l=s(`taro-img__mode-${i.toLowerCase().replace(/\s/g,"")}`,{[`taro-img__mode-aspectfill--${h}`]:"aspectFill"===i});return o(e,{class:g},o("img",Object.assign(a?{ref:t=>this.imgRef=t,class:l,onLoad:r.bind(this),onError:m.bind(this)}:{ref:t=>this.imgRef=t,class:l,src:t,onLoad:r.bind(this),onError:m.bind(this)},d)))}};a.style='img[src=""]{opacity:0}taro-image-core{display:inline-block;overflow:hidden;position:relative;width:auto;height:auto;font-size:0}.taro-img.taro-img__widthfix{height:100%}.taro-img__mode-scaletofill{width:100%;height:100%}.taro-img__mode-aspectfit{max-width:100%;max-height:100%}.taro-img__mode-aspectfill{position:absolute;left:50%;top:50%;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%)}.taro-img__mode-aspectfill--width{min-width:100%;height:100%}.taro-img__mode-aspectfill--height{width:100%;min-height:100%}.taro-img__mode-widthfix{width:100%}.taro-img__mode-heightfix{height:100%}.taro-img__mode-top{width:100%}.taro-img__mode-bottom{position:absolute;bottom:0;width:100%}.taro-img__mode-left{height:100%}.taro-img__mode-right{position:absolute;right:0;height:100%}.taro-img__mode-topright{position:absolute;right:0}.taro-img__mode-bottomleft{position:absolute;bottom:0}.taro-img__mode-bottomright{position:absolute;right:0;bottom:0}';export{a as taro_image_core}
@@ -1 +0,0 @@
1
- import{r as t,c as i,h as s,H as e,g as r}from"./p-9137dcab.js";import h from"@tarojs/taro";import{c as a}from"./p-de951a46.js";const o="undefined"!=typeof navigator&&/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent),n={activate:"release",deactivate:"pull",release:"loading",finish:"finish"};let l=!1;try{const t=Object.defineProperty({},"passive",{get(){l=!0}});window.addEventListener("cancel",(()=>({})),t)}catch(t){}const c=!!l&&{passive:!1},d=class{constructor(s){t(this,s),this.onRefresh=i(this,"refresh",7),this._ScreenY=0,this._startScreenY=0,this._lastScreenY=0,this._isMounted=!1,this.triggerPullDownRefresh=t=>{!this.dragOnEdge&&this._isMounted&&(t?(this._lastScreenY=this.distanceToRefresh+1,this.currSt="release",this.setContentStyle(this._lastScreenY)):(this.currSt="finish",this.reset()))},this.init=()=>{const t=this.scrollContainer,i=this.el.querySelector("rmc-pull-to-refresh-content");this.el.appendChild=null==i?void 0:i.appendChild.bind(i),this.el.insertBefore=null==i?void 0:i.insertBefore.bind(i),this.el.replaceChild=null==i?void 0:i.replaceChild.bind(i),this.el.removeChild=null==i?void 0:i.removeChild.bind(i),this._to={touchstart:this.onTouchStart.bind(this,t),touchmove:this.onTouchMove.bind(this,t),touchend:this.onTouchEnd.bind(this,t),touchcancel:this.onTouchEnd.bind(this,t)},Object.keys(this._to).forEach((i=>{t.addEventListener(i,this._to[i],c)}))},this.destroy=()=>{const t=this.scrollContainer;Object.keys(this._to).forEach((i=>{t.removeEventListener(i,this._to[i])}))},this.onTouchStart=(t,i)=>{this._ScreenY=this._startScreenY=i.touches[0].screenY,this._lastScreenY=this._lastScreenY||0},this.isEdge=t=>{const i=this.scrollContainer;return i&&i===document.body?(document.scrollingElement?document.scrollingElement:document.body).scrollTop<=0:t.scrollTop<=0},this.damp=t=>Math.abs(this._lastScreenY)>this.damping?0:t*(.6*(1-Math.abs(this._ScreenY-this._startScreenY)/window.screen.height)),this.onTouchMove=(t,i)=>{const s=i.touches[0].screenY;if(!(this._startScreenY>s)&&this.isEdge(t)){this.dragOnEdge||(this._ScreenY=this._startScreenY=i.touches[0].screenY,this.dragOnEdge=!0),i.cancelable&&i.preventDefault();const t=Math.round(s-this._ScreenY);this._ScreenY=s,this._lastScreenY+=this.damp(t),this.setContentStyle(this._lastScreenY),Math.abs(this._lastScreenY)<this.distanceToRefresh?"deactivate"!==this.currSt&&(this.currSt="deactivate"):"deactivate"===this.currSt&&(this.currSt="activate"),o&&i.changedTouches[0].clientY<0&&this.onTouchEnd()}},this.onTouchEnd=()=>{this.dragOnEdge&&(this.dragOnEdge=!1),"activate"===this.currSt?(this.currSt="release",this.onRefresh.emit(this),this._lastScreenY=this.distanceToRefresh+1,this.setContentStyle(this._lastScreenY)):"release"===this.currSt?(this._lastScreenY=this.distanceToRefresh+1,this.setContentStyle(this._lastScreenY)):this.reset()},this.reset=()=>{this._lastScreenY=0,this.setContentStyle(0)},this.setContentStyle=t=>{var i,s;this.contentRef&&((i=this.contentRef.style).transform=s=t?`translate3d(0px,${t}px,0)`:"",i.webkitTransform=s,i.MozTransform=s)},this.prefixCls="rmc-pull-to-refresh",this.distanceToRefresh=50,this.damping=100,this.indicator=n,this.currSt="deactivate",this.dragOnEdge=!1}get scrollContainer(){return this.el.parentElement||this.el.closest(".taro_page_stationed")||document.querySelector(".taro_page_stationed")||document.querySelector(".taro_page")||document.querySelector(".taro_router")||document.querySelector(".taro-tabbar__panel")||document.body}statusChange(){var t,i,s,e;const r=this.scrollContainer;switch(this.currSt){case"release":null===(i=null===(t=null==r?void 0:r.__page)||void 0===t?void 0:t.onPullDownRefresh)||void 0===i||i.call(t);break;case"deactivate":null===(e=null===(s=null==r?void 0:r.__page)||void 0===s?void 0:s.onPullIntercept)||void 0===e||e.call(s)}}disconnectedCallback(){this.destroy()}componentDidLoad(){this.init(),this._isMounted=!0,h.eventCenter.on("__taroStartPullDownRefresh",(({successHandler:t,errorHandler:i})=>{try{this.triggerPullDownRefresh(!0),t({errMsg:"startPullDownRefresh: ok"})}catch(t){i({errMsg:"startPullDownRefresh: fail"})}})),h.eventCenter.on("__taroStopPullDownRefresh",(({successHandler:t,errorHandler:i})=>{try{this.triggerPullDownRefresh(!1),t({errMsg:"stopPullDownRefresh: ok"})}catch(t){i({errMsg:"stopPullDownRefresh: fail"})}}))}render(){const t=t=>{const{currSt:i,dragOnEdge:e,prefixCls:r}=this,h=a(t,!e&&`${r}-transition`);return s("div",{class:`${r}-content-wrapper`},s("div",{class:h,ref:t=>{this.contentRef=t}},("activate"===i||"release"===i)&&s("div",{class:`${r}-indicator`},s("div",null),s("div",null),s("div",null)),s("slot",null)))};return this.scrollContainer?t(`${this.prefixCls}-content ${this.prefixCls}-down`):s(e,{class:a(this.prefixCls,`${this.prefixCls}-down`)},t(`${this.prefixCls}-content`))}get el(){return r(this)}static get watchers(){return{currSt:["statusChange"]}}};d.style=".rmc-pull-to-refresh-content{-webkit-transform-origin:left top 0;transform-origin:left top 0}.rmc-pull-to-refresh-content-wrapper{overflow:hidden;min-height:100vh}.rmc-pull-to-refresh-transition{-webkit-transition:-webkit-transform 0.3s;transition:-webkit-transform 0.3s;transition:transform 0.3s;transition:transform 0.3s, -webkit-transform 0.3s}@-webkit-keyframes rmc-pull-to-refresh-indicator{50%{opacity:0.2}100%{opacity:1}}@keyframes rmc-pull-to-refresh-indicator{50%{opacity:0.2}100%{opacity:1}}.rmc-pull-to-refresh-indicator{height:30px;line-height:10px;text-align:center}.rmc-pull-to-refresh-indicator>div{display:inline-block;margin:3px;border-radius:100%;width:6px;height:6px;background-color:grey;-webkit-animation:rmc-pull-to-refresh-indicator 0.5s 0s infinite linear;animation:rmc-pull-to-refresh-indicator 0.5s 0s infinite linear;-webkit-animation-fill-mode:both;animation-fill-mode:both}.rmc-pull-to-refresh-indicator>div:nth-child(0){-webkit-animation-delay:-0.1s !important;animation-delay:-0.1s !important}.rmc-pull-to-refresh-indicator>div:nth-child(1){-webkit-animation-delay:-0.2s !important;animation-delay:-0.2s !important}.rmc-pull-to-refresh-indicator>div:nth-child(2){-webkit-animation-delay:-0.3s !important;animation-delay:-0.3s !important}.rmc-pull-to-refresh-down .rmc-pull-to-refresh-indicator{margin-top:-25px}";export{d as taro_pull_to_refresh}
@@ -1 +0,0 @@
1
- System.register(["./p-7e6b54cb.system.js","@tarojs/taro","./p-2ec68968.system.js"],(function(e){"use strict";var t,r,n,i,o,a,s;return{setters:[function(e){t=e.r;r=e.c;n=e.h;i=e.H;o=e.g},function(e){a=e.default},function(e){s=e.c}],execute:function(){var c=".rmc-pull-to-refresh-content{-webkit-transform-origin:left top 0;transform-origin:left top 0}.rmc-pull-to-refresh-content-wrapper{overflow:hidden;min-height:100vh}.rmc-pull-to-refresh-transition{-webkit-transition:-webkit-transform 0.3s;transition:-webkit-transform 0.3s;transition:transform 0.3s;transition:transform 0.3s, -webkit-transform 0.3s}@-webkit-keyframes rmc-pull-to-refresh-indicator{50%{opacity:0.2}100%{opacity:1}}@keyframes rmc-pull-to-refresh-indicator{50%{opacity:0.2}100%{opacity:1}}.rmc-pull-to-refresh-indicator{height:30px;line-height:10px;text-align:center}.rmc-pull-to-refresh-indicator>div{display:inline-block;margin:3px;border-radius:100%;width:6px;height:6px;background-color:grey;-webkit-animation:rmc-pull-to-refresh-indicator 0.5s 0s infinite linear;animation:rmc-pull-to-refresh-indicator 0.5s 0s infinite linear;-webkit-animation-fill-mode:both;animation-fill-mode:both}.rmc-pull-to-refresh-indicator>div:nth-child(0){-webkit-animation-delay:-0.1s !important;animation-delay:-0.1s !important}.rmc-pull-to-refresh-indicator>div:nth-child(1){-webkit-animation-delay:-0.2s !important;animation-delay:-0.2s !important}.rmc-pull-to-refresh-indicator>div:nth-child(2){-webkit-animation-delay:-0.3s !important;animation-delay:-0.3s !important}.rmc-pull-to-refresh-down .rmc-pull-to-refresh-indicator{margin-top:-25px}";function l(e,t){e.transform=t;e.webkitTransform=t;e.MozTransform=t}var u=typeof navigator!=="undefined"&&/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent);var d={activate:"release",deactivate:"pull",release:"loading",finish:"finish"};var f=false;try{var h=Object.defineProperty({},"passive",{get:function(){f=true}});window.addEventListener("cancel",(function(){return{}}),h)}catch(e){}var p=f?{passive:false}:false;var v=e("taro_pull_to_refresh",function(){function e(e){var n=this;t(this,e);this.onRefresh=r(this,"refresh",7);this._ScreenY=0;this._startScreenY=0;this._lastScreenY=0;this._isMounted=false;this.triggerPullDownRefresh=function(e){if(!n.dragOnEdge&&n._isMounted){if(e){n._lastScreenY=n.distanceToRefresh+1;n.currSt="release";n.setContentStyle(n._lastScreenY)}else{n.currSt="finish";n.reset()}}};this.init=function(){var e=n.scrollContainer;var t=n.el.querySelector("rmc-pull-to-refresh-content");n.el.appendChild=t===null||t===void 0?void 0:t.appendChild.bind(t);n.el.insertBefore=t===null||t===void 0?void 0:t.insertBefore.bind(t);n.el.replaceChild=t===null||t===void 0?void 0:t.replaceChild.bind(t);n.el.removeChild=t===null||t===void 0?void 0:t.removeChild.bind(t);n._to={touchstart:n.onTouchStart.bind(n,e),touchmove:n.onTouchMove.bind(n,e),touchend:n.onTouchEnd.bind(n,e),touchcancel:n.onTouchEnd.bind(n,e)};Object.keys(n._to).forEach((function(t){e.addEventListener(t,n._to[t],p)}))};this.destroy=function(){var e=n.scrollContainer;Object.keys(n._to).forEach((function(t){e.removeEventListener(t,n._to[t])}))};this.onTouchStart=function(e,t){n._ScreenY=n._startScreenY=t.touches[0].screenY;n._lastScreenY=n._lastScreenY||0};this.isEdge=function(e){var t=n.scrollContainer;if(t&&t===document.body){var r=document.scrollingElement?document.scrollingElement:document.body;return r.scrollTop<=0}return e.scrollTop<=0};this.damp=function(e){if(Math.abs(n._lastScreenY)>n.damping){return 0}var t=Math.abs(n._ScreenY-n._startScreenY)/window.screen.height;e*=(1-t)*.6;return e};this.onTouchMove=function(e,t){var r=t.touches[0].screenY;if(n._startScreenY>r){return}if(n.isEdge(e)){if(!n.dragOnEdge){n._ScreenY=n._startScreenY=t.touches[0].screenY;n.dragOnEdge=true}if(t.cancelable){t.preventDefault()}var i=Math.round(r-n._ScreenY);n._ScreenY=r;n._lastScreenY+=n.damp(i);n.setContentStyle(n._lastScreenY);if(Math.abs(n._lastScreenY)<n.distanceToRefresh){if(n.currSt!=="deactivate"){n.currSt="deactivate"}}else{if(n.currSt==="deactivate"){n.currSt="activate"}}if(u&&t.changedTouches[0].clientY<0){n.onTouchEnd()}}};this.onTouchEnd=function(){if(n.dragOnEdge){n.dragOnEdge=false}if(n.currSt==="activate"){n.currSt="release";n.onRefresh.emit(n);n._lastScreenY=n.distanceToRefresh+1;n.setContentStyle(n._lastScreenY)}else if(n.currSt==="release"){n._lastScreenY=n.distanceToRefresh+1;n.setContentStyle(n._lastScreenY)}else{n.reset()}};this.reset=function(){n._lastScreenY=0;n.setContentStyle(0)};this.setContentStyle=function(e){if(n.contentRef){if(e){l(n.contentRef.style,"translate3d(0px,".concat(e,"px,0)"))}else{l(n.contentRef.style,"")}}};this.prefixCls="rmc-pull-to-refresh";this.distanceToRefresh=50;this.damping=100;this.indicator=d;this.currSt="deactivate";this.dragOnEdge=false}Object.defineProperty(e.prototype,"scrollContainer",{get:function(){return this.el.parentElement||this.el.closest(".taro_page_stationed")||document.querySelector(".taro_page_stationed")||document.querySelector(".taro_page")||document.querySelector(".taro_router")||document.querySelector(".taro-tabbar__panel")||document.body},enumerable:false,configurable:true});e.prototype.statusChange=function(){var e,t,r,n;var i=this.scrollContainer;switch(this.currSt){case"release":(t=(e=i===null||i===void 0?void 0:i.__page)===null||e===void 0?void 0:e.onPullDownRefresh)===null||t===void 0?void 0:t.call(e);break;case"deactivate":(n=(r=i===null||i===void 0?void 0:i.__page)===null||r===void 0?void 0:r.onPullIntercept)===null||n===void 0?void 0:n.call(r)}};e.prototype.disconnectedCallback=function(){this.destroy()};e.prototype.componentDidLoad=function(){var e=this;this.init();this._isMounted=true;a.eventCenter.on("__taroStartPullDownRefresh",(function(t){var r=t.successHandler,n=t.errorHandler;try{e.triggerPullDownRefresh(true);r({errMsg:"startPullDownRefresh: ok"})}catch(e){n({errMsg:"startPullDownRefresh: fail"})}}));a.eventCenter.on("__taroStopPullDownRefresh",(function(t){var r=t.successHandler,n=t.errorHandler;try{e.triggerPullDownRefresh(false);r({errMsg:"stopPullDownRefresh: ok"})}catch(e){n({errMsg:"stopPullDownRefresh: fail"})}}))};e.prototype.render=function(){var e=this;var t=function(t){var r=e,i=r.currSt,o=r.dragOnEdge,a=r.prefixCls;var c=s(t,!o&&"".concat(a,"-transition"));var l=i==="activate"||i==="release";return n("div",{class:"".concat(a,"-content-wrapper")},n("div",{class:c,ref:function(t){e.contentRef=t}},l&&n("div",{class:"".concat(a,"-indicator")},n("div",null),n("div",null),n("div",null)),n("slot",null)))};if(this.scrollContainer){return t("".concat(this.prefixCls,"-content ").concat(this.prefixCls,"-down"))}return n(i,{class:s(this.prefixCls,"".concat(this.prefixCls,"-down"))},t("".concat(this.prefixCls,"-content")))};Object.defineProperty(e.prototype,"el",{get:function(){return o(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{currSt:["statusChange"]}},enumerable:false,configurable:true});return e}());v.style=c}}}));