This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
17 changed files
with
748 additions
and
655 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
module.exports = { | ||
extends: './node_modules/@surmon-china/abc-factory/preset/eslintrc/vue.typescript', | ||
rules: { | ||
'vue/max-attributes-per-line': [0] | ||
'vue/max-attributes-per-line': 0, | ||
'vue/order-in-components': 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,32 @@ | ||
module.exports = { | ||
entry: 'src/index.ts', | ||
resolve: ['.vue', '.ts'], | ||
targets: ['umd', 'esm'], | ||
minimize: false, | ||
external: [ | ||
'swiper', | ||
'vue', | ||
], | ||
globals: { | ||
swiper: 'Swiper', | ||
vue: 'Vue', | ||
module.exports = [ | ||
{ | ||
entry: 'src/exporter.ts', | ||
fileName: 'exporter', | ||
targets: ['umd', 'esm'], | ||
minimize: false, | ||
external: ['vue'], | ||
globals: { | ||
vue: 'Vue' | ||
}, | ||
typescript: { | ||
tsconfigOverride: { | ||
compilerOptions: { | ||
declaration: false | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
entry: 'src/index.ts', | ||
targets: ['umd', 'esm'], | ||
minimize: false, | ||
external: [ | ||
'swiper', | ||
'vue', | ||
], | ||
globals: { | ||
swiper: 'Swiper', | ||
vue: 'Vue', | ||
} | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @file vue-awesome-swiper | ||
* @module exporter | ||
* @author Surmon <https://github.com/surmon-china> | ||
*/ | ||
|
||
import Swiper, { SwiperOptions } from 'swiper' | ||
import _Vue, { PluginFunction } from 'vue' | ||
import { CoreNames } from './constants' | ||
import getDirective from './directive' | ||
import getSwiperComponent from './swiper' | ||
import SwiperSlideComponent from './slide' | ||
|
||
export interface InstallFunction extends PluginFunction<SwiperOptions> { | ||
installed?: boolean | ||
} | ||
|
||
const getInstaller = (SwiperClass: typeof Swiper) => { | ||
const install: InstallFunction = (Vue: typeof _Vue, globalOptions?: SwiperOptions) => { | ||
if (install.installed) return | ||
|
||
const SwiperComponent = getSwiperComponent(SwiperClass) | ||
if (globalOptions) { | ||
(SwiperComponent as any).options.props.defaultOptions.default = () => globalOptions | ||
} | ||
|
||
Vue.component(CoreNames.SwiperComponent, SwiperComponent) | ||
Vue.component(CoreNames.SwiperSlideComponent, SwiperSlideComponent) | ||
Vue.directive(CoreNames.SwiperDirective, getDirective(SwiperClass, globalOptions)) | ||
install.installed = true | ||
} | ||
return install | ||
} | ||
|
||
export default function exporter(SwiperClass: typeof Swiper) { | ||
return { | ||
version: 'PACKAGE_VERSION', | ||
install: getInstaller(SwiperClass), | ||
directive: getDirective(SwiperClass), | ||
[CoreNames.SwiperComponent as const]: getSwiperComponent(SwiperClass), | ||
[CoreNames.SwiperSlideComponent as const]: SwiperSlideComponent | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,17 @@ | ||
/** | ||
* @file vue-awesome-swiper | ||
* @module entry | ||
* @author Surmon <https://github.com/surmon-china> | ||
*/ | ||
|
||
import { SwiperOptions } from 'swiper' | ||
import _Vue, { PluginFunction } from 'vue' | ||
import { SWIPER_DIRECTIVE_NAME } from './constants' | ||
import SwiperDirective, { getDirectiveByOptions } from './directive' | ||
import SwiperComponent from './swiper.vue' | ||
import SwiperSlideComponent from './slide.vue' | ||
import { SWIPER_COMPONENT_NAME, SWIPER_SLIDE_COMPONENT_NAME } from './constants' | ||
|
||
interface InstallFunction extends PluginFunction<SwiperOptions> { | ||
installed?: boolean | ||
} | ||
|
||
export const install: InstallFunction = (Vue: typeof _Vue, globalOptions?: SwiperOptions) => { | ||
if (install.installed) return | ||
install.installed = true | ||
|
||
if (globalOptions) { | ||
(SwiperComponent as any).options.props.defaultOptions.default = () => globalOptions | ||
} | ||
|
||
Vue.component(SWIPER_COMPONENT_NAME, SwiperComponent) | ||
Vue.component(SWIPER_SLIDE_COMPONENT_NAME, SwiperSlideComponent) | ||
Vue.directive(SWIPER_DIRECTIVE_NAME, getDirectiveByOptions(globalOptions)) | ||
} | ||
|
||
export const Swiper = SwiperComponent | ||
export const SwiperSlide = SwiperSlideComponent | ||
export const directive = SwiperDirective | ||
|
||
export default { | ||
install, | ||
directive, | ||
Swiper: SwiperComponent, | ||
SwiperSlide: SwiperSlideComponent | ||
} | ||
/** | ||
* @file vue-awesome-swiper | ||
* @module default-export | ||
* @author Surmon <https://github.com/surmon-china> | ||
*/ | ||
|
||
import SwiperClass from 'swiper' | ||
import exporter from './exporter' | ||
|
||
const VueAwesomeSwiper = exporter(SwiperClass) | ||
|
||
export const version = VueAwesomeSwiper.version | ||
export const install = VueAwesomeSwiper.install | ||
export const directive = VueAwesomeSwiper.directive | ||
export const Swiper = VueAwesomeSwiper.Swiper | ||
export const SwiperSlide = VueAwesomeSwiper.SwiperSlide | ||
export default VueAwesomeSwiper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @file vue-awesome-swiper | ||
* @module SwiperSlideComponent | ||
* @author Surmon <https://github.com/surmon-china> | ||
*/ | ||
|
||
import Vue, { VNode, CreateElement } from 'vue' | ||
import { CoreNames, DEFAULT_CLASSES } from './constants' | ||
|
||
export default Vue.extend({ | ||
name: CoreNames.SwiperSlideComponent, | ||
computed: { | ||
slideClass(): string { | ||
return (this.$parent as any)?.swiperOptions?.slideClass || DEFAULT_CLASSES.slideClass | ||
} | ||
}, | ||
methods: { | ||
update() { | ||
(this.$parent as any)?.swiperInstance?.update() | ||
} | ||
}, | ||
mounted() { | ||
this.update() | ||
}, | ||
updated() { | ||
this.update() | ||
}, | ||
render(createElement: CreateElement): VNode { | ||
return createElement( | ||
'div', | ||
{ | ||
class: this.slideClass | ||
}, | ||
this.$slots.default | ||
) | ||
} | ||
}) |
Oops, something went wrong.