vue#Plugin TypeScript Examples

The following examples show how to use vue#Plugin. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts    From vite-vue3-ts with MIT License 6 votes vote down vote up
withInstall = <T>(component: T, alias?: string) => {
  const comp = component as any;
  comp.install = (app: App) => {
    app.component(comp.name || comp.displayName, component);
    if (alias) {
      app.config.globalProperties[alias] = component;
    }
  };
  return component as T & Plugin;
}
Example #2
Source File: plugin.ts    From vue-keycloak with Apache License 2.0 6 votes vote down vote up
vueKeycloak: Plugin = {
  async install(app, options: VueKeycloakPluginConfig) {
    if (isNil(options)) {
      throw new Error('The Keycloak.KeycloakConfig are requried')
    }

    let keycloakPluginConfig: KeycloakPluginConfig
    if (isString(options)) {
      keycloakPluginConfig = await loadJsonConfig(options as string)
    } else if (isPromise(options) || isFunction(options)) {
      keycloakPluginConfig = await (options as KeycloakConfigAsyncFactory)()
    } else {
      keycloakPluginConfig = options as KeycloakPluginConfig
    }

    const keycloakConfig = keycloakPluginConfig.config
    const keycloakInitOptions: Keycloak.KeycloakInitOptions = !isNil(keycloakPluginConfig.initOptions)
      ? { ...defaultInitConfig, ...keycloakPluginConfig.initOptions }
      : defaultInitConfig

    const _keycloak = createKeycloak(keycloakConfig)
    app.config.globalProperties.$keycloak = _keycloak

    await initKeycloak(keycloakInitOptions)
  },
}
Example #3
Source File: plugin.ts    From formkit with MIT License 6 votes vote down vote up
plugin: Plugin = {
  install(
    app,
    _options: FormKitOptions | ((...args: any[]) => FormKitOptions)
  ): void {
    /**
     * Extend the default configuration options.
     */
    const options: FormKitOptions = Object.assign(
      {
        alias: 'FormKit',
        schemaAlias: 'FormKitSchema',
      },
      typeof _options === 'function' ? _options() : _options
    )
    /**
     * The root configuration options.
     */
    const rootConfig = createConfig(options.config || {})
    /**
     * We dont want to explicitly provide any "config" options, only a root
     * config optionso here we override the existing config options.
     */
    options.config = { rootConfig }
    /**
     * Register the global $formkit plugin property.
     */
    app.config.globalProperties.$formkit = createPlugin(app, options)
    /**
     * Provide the config to the application for injection.
     */
    app.provide(optionsSymbol, options)
    /**
     * Provide the root config to the application.
     */
    app.provide(configSymbol, rootConfig as FormKitConfig)
  },
}
Example #4
Source File: index.ts    From elenext with MIT License 5 votes vote down vote up
elenext: Plugin = {
  install(app) {
    const useComponent = (component: Component) => {
      if (component.name) {
        app.component(component.name, component)
      } else {
        throw 'component need name'
      }
    }

    useComponent(ERow)
    useComponent(ECol)
    useComponent(EMenu)
    useComponent(ESubMenu)
    useComponent(EMenuItem)
    useComponent(EMenuItemGroup)

    useComponent(ELayout)
    useComponent(EAside)
    useComponent(EMain)
    useComponent(EHeader)
    useComponent(EFooter)

    useComponent(EButton)
    useComponent(EButtonGroup)
    useComponent(ELink)
    // useComponeEnt(Icon)
    useComponent(EPopper)
    useComponent(ETooltip)
    useComponent(EPopover)

    useComponent(EBreadcrumb)
    useComponent(EBreadcrumbItem)

    useComponent(EAlert)
    useComponent(EPagination)

    useComponent(EInput)
    useComponent(EInputGroup)
    useComponent(ESelect)
    useComponent(ESelectBox)
    useComponent(ESelectOption)
    useComponent(ERadio)
    useComponent(ERadioGroup)
    useComponent(ECheckbox)
    useComponent(ECheckboxGroup)
    useComponent(EColorPicker)
  },
}
Example #5
Source File: elements-vue.ts    From elements with MIT License 5 votes vote down vote up
InoElementsVue: Plugin = {
  async install(_: App) {
    await defineCustomElements(window, getHelperFunctions());
    addIcons(ICON_PATHS);
  }
}