0.15.2 • Published 5 months ago

kikimore v0.15.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

⚠ DEPRECATED

!WARNING

kikimore 已升级至原作者 cloydlaufaim

不仅有更多的新组件和能力增强,为了后续的漏洞修复和迭代优化,请尽快迁移

特性

  • Vue 2.6/2.7/3 一体通用
  • Element UI / Element Plus 一体通用
  • 支持 Vite,Vue CLI,webpack...
  • 支持全局属性、全局事件、全局插槽、全局作用域插槽 (vue-global-config 提供技术支持)

安装

npm i kikimore

Vite

// vite.config.ts

export default defineConfig({
  optimizeDeps: {
    include: ['kikimore'],
  },
})

Vue CLI

// vue.config.js

module.exports = {
  transpileDependencies: ['kikimore'],
}

Element Plus (Vue 3)

局部注册

<script setup>
import { KiFormDialog, KiPopButton, KiPopSwitch, KiSelect } from 'kikimore'
</script>

全局注册

import { createApp, h } from 'vue'
import 'element-plus/dist/index.css'
import ElementPlus from 'element-plus'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { KiFormDialog, KiPopButton, KiPopSwitch, KiSelect } from 'kikimore'
import App from './App.vue'

const app = createApp(App)
  .use(ElementPlus)
  .use(KiFormDialog, {
    // 全局配置
  })
  .use(KiPopButton, {
    // 全局配置
  })
  .use(KiPopSwitch, {
    // 全局配置
  })
  .use(KiSelect, {
    // 全局配置
  })

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.mount('#app')

CDN

⚠ 暂不支持。

Element UI (Vue 2.7/2.6)

局部注册

<script>
import { KiFormDialog, KiPopButton, KiPopSwitch, KiSelect } from 'kikimore'

export default {
  components: { KiFormDialog, KiPopButton, KiPopSwitch, KiSelect },
}
</script>

全局注册

import Vue from 'vue'
import 'element-ui/lib/theme-chalk/index.css'
import ElementUI from 'element-ui'
import { KiFormDialog, KiPopButton, KiPopSwitch, KiSelect } from 'kikimore'
import App from './App.vue'

Vue.use(ElementUI)
Vue.use(FormDialog, {
  // 全局配置
})
Vue.use(KiPopButton, {
  // 全局配置
})
Vue.use(KiPopSwitch, {
  // 全局配置
})
Vue.use(KiSelect, {
  // 全局配置
})

new Vue({
  render: h => h(App),
}).$mount('#app')

CDN

⚠ 暂不支持。

FormDialog

el-dialog + el-form 组合拳。

特性

  • 打开对话框自动回显数据,关闭对话框自动重置数据
  • 提交、拒绝、重置、全屏一应俱全
  • 校验失败时平滑滚动至错误项并震动提示
  • 限制高度,无页面级滚动条
  • 只读模式
  • 支持全局属性、全局事件、全局插槽 (vue-global-config 提供技术支持)

Props

名称说明类型默认值
title对话框标题string
v-model:show (Vue 3) /show.sync (Vue 2)是否显示booleanfalse
modelValue (Vue 3) /value (Vue 2) /v-model表单数据对象 (el-formmodel)any
elFormPropsel-form 的属性object
retrieve读取数据Function
loading读取状态booleanfalse
readonly是否只读booleanfalse
showFullscreenToggle是否显示全屏开关booleantrue
showConfirmButton是否显示确认按钮boolean!readonly
confirmButtonText确认按钮的文案string'OK'
confirm确认Function
showCancelButton是否显示取消按钮boolean!readonly
cancelButtonText取消按钮的文案string'Cancel'
showDenyButton是否显示拒绝按钮booleanfalse
denyButtonText拒绝按钮的文案string'No'
deny拒绝Function
showResetButton是否显示重置按钮booleanfalse
resetButtonText重置按钮的文案string'Reset'
reverseButtons是否反转按钮顺序booleanfalse
...el-dialog 的属性

modelValue (Vue 3) / value (Vue 2) / v-model

如果是 plain object 类型,将用于 el-formmodel

onMounted 时记录初始值 (与 el-form-item 保持一致),关闭对话框时会重置至初始值。

retrieve

<template>
  <KiFormDialog
    :retrieve="() => {
      // 表格打开之后、获取数据之前
      $POST('xxx').then(() => {
        // 获取数据之后
      })
    }"
  />
</template>

readonly

开启只读模式时默认不显示确认和取消按钮。

<el-form disabled /> 的区别是在样式上,更便于用户阅读。

如果希望部分组件不进入禁用状态:

  • 单独给这个组件设置 :disabled="false"
  • 给这部分组件包一层 <el-form />

confirm

如果返回一个 Promise 实例,则在该 Promise 实例状态终结后对话框才会关闭。

<template>
  <KiFormDialog
    :confirm="() => {
      // 确认之前
      $POST('xxx').then(() => {
        // 确认之后
      })
    }"
  />
</template>

返回 Promise.reject() / Promise.resolve({ show: true }) / { show: true } 时对话框不会关闭。

<template>
  <KiFormDialog
    :confirm="() => {
      const valid = true
      if (valid) {
        return $POST('xxx')
      }
      else {
        $swal.warning('校验失败')
        return {
          show: true,
        }
      }
    }"
  />
</template>

deny

如果返回一个 Promise 实例,则在该 Promise 实例状态终结后对话框才会关闭。

<template>
  <KiFormDialog
    :deny="() => {
      // 确认之前
      $POST('xxx').then(() => {
        // 确认之后
      })
    }"
  />
</template>

返回 Promise.reject() / Promise.resolve({ show: true }) / { show: true } 时对话框不会关闭。

<template>
  <KiFormDialog
    :deny="() => {
      const valid = true
      if (valid) {
        return $POST('xxx')
      }
      else {
        $swal.warning('校验失败')
        return {
          show: true,
        }
      }
    }"
  />
</template>

reverseButtons

关于 “确定” 和 “取消” 按钮的顺序,可以看看这篇知乎回答

Events

名称说明回调参数
fullscreen-change切换全屏状态时触发(fullscreen: boolean)
...el-dialogel-form 的事件

Slots

名称说明
el-form 的内容
...el-dialog 的插槽

Exposes

名称说明类型
highlightError平滑滚动至校验失败的表单项(selectors: string | Element | NodeList = '.el-form .el-form-item.is-error', container = window) => void
...通过 ref 调用 el-form 的方法

改变遮罩层定位

.el-dialog__wrapper, .v-modal {
  position: absolute;
}

// 在原来的基础上减去 navbar + tab 的高度 (以 90px 为例)
.el-dialog {
  .el-dialog__body {
    max-height: calc(100vh - 190px) !important;
  }

  &.is-fullscreen .el-dialog__body {
    max-height: calc(100vh - 135px) !important;
  }
}

PopButton

el-button + el-popconfirm + el-popover + el-tooltip 组合拳。

特性

  • 操作拦截 (el-popconfirm 点击确定后才会触发 click 事件)
  • el-popoverel-tooltipcontent 属性均支持渲染 HTML
  • el-tooltip 不与 el-popconfirmel-popover 冲突
  • el-popconfirmel-popoverel-tooltip 内容为空时,默认不启用
  • 支持全局属性、全局事件、全局插槽 (vue-global-config 提供技术支持)

Props

名称说明类型默认值
elPopconfirmPropsel-popconfirm 的属性object
elPopoverPropsel-popover 的属性,支持事件绑定object
elPopoverProps.rawContentcontent 中的内容是否作为 HTML 字符串处理booleanfalse
elTooltipPropsel-tooltip 的属性object
elTooltipProps.rawContentcontent 中的内容是否作为 HTML 字符串处理booleanfalse
...el-button 的属性

Events

el-popconfirmel-popover 的事件。

Slots

名称说明
tooltip-contentel-tooltipcontent 插槽
popover-contentel-popovercontent 插槽

PopSwitch

el-switch + el-popconfirm + el-popover + el-tooltip 组合拳。

特性

  • 操作拦截 (el-popconfirm 点击确定后才会触发 change 事件)
  • 支持内嵌文字描述,宽度自适应
  • el-popoverel-tooltipcontent 属性均支持渲染 HTML
  • el-tooltip 不与 el-popconfirmel-popover 冲突
  • el-popconfirmel-popoverel-tooltip 内容为空时,默认不启用
  • 支持全局属性、全局事件、全局插槽 (vue-global-config 提供技术支持)

Props

名称说明类型默认值
inlinePrompt是否内嵌文字描述booleanfalse
elPopconfirmPropsel-popconfirm 的属性object
elPopoverPropsel-popover 的属性,支持事件绑定object
elPopoverProps.rawContentcontent 中的内容是否作为 HTML 字符串处理booleanfalse
elTooltipPropsel-tooltip 的属性object
elTooltipProps.rawContentcontent 中的内容是否作为 HTML 字符串处理booleanfalse
...el-switch 的属性

Events

el-switchel-popconfirmel-popover 的事件。

Slots

名称说明
tooltip-contentel-tooltipcontent 插槽
popover-contentel-popovercontent 插槽

Exposes

通过 ref 调用 el-switch 的方法。

Select

el-select + el-option + el-option-group 组合拳。

特性

  • 单向绑定 label
  • 远程搜索时无需关心 optionsloading
  • 无匹配选项时展示 label (而不是 value)
  • 多选时支持一键全选
  • 支持全局属性、全局事件、全局插槽、全局作用域插槽 (vue-global-config 提供技术支持)

Props

名称说明类型默认值
modelValue (Vue 3) /value (Vue 2) /v-model绑定值any
v-model:options (Vue 3) /options.sync (Vue 2)选项any[]
props定位选项的各项属性object
search远程搜索 (remote-method 封装)(query: string) =>Promise<any[]> | any[]
searchImmediately是否立即执行远程搜索booleantrue
v-model:label (Vue 3) /label.sync (Vue 2)绑定值对应的 label (单向数据流)string | string[]
showSelectAllCheckbox多选时是否显示全选框booleantrue
selectAllCheckboxLabel全选框的文案string'Select All'
...el-select 的属性

options

默认情况下绑定值将得到选中项的数组元素本身。

可使用 props.value 改变此行为 (比如选项的数组元素是 plain object 类型,而绑定值只想要其中某个属性)。

props

interface Props {
  // 定位 option 中的 value
  // 如果是 string 类型,将默认用于 el-select 的 value-key
  'value': string | symbol | ((value: any) => any)
  // 定位 option 中的 label
  'label': string | symbol | ((value: any) => string)
  // 定位 option 中的 disabled
  'disabled': string | symbol | ((value: any) => boolean)
  // 定位 option 中分组的 label
  'groupLabel': string | symbol | ((value: any) => string)
  // 定位 option 中分组的 options
  'groupOptions': string | symbol | ((value: any) => any[])
  // 定位 option 中分组的 disabled
  'groupDisabled': string | symbol | ((value: any) => boolean)
}
  • 支持属性名,如 'url'
  • 支持属性路径,如 'data[0].url'
  • 支持 symbol 类型的属性名
  • 支持 Function,如 value => value.url

Events

el-select 的事件。

Slots

名称说明
prefixel-selectprefix 插槽
emptyel-selectempty 插槽
group-prependel-option-group 的前置内容
group-appendel-option-group 的后置内容
el-option 的默认插槽,作用域参数为 {option: any, index: number}
option-prependel-option 的前置内容,默认内容为全选框
option-appendel-option 的后置内容

Exposes

名称说明类型
remoteMethodel-selectremoteMethod 属性,自行控制 search 时机时使用(query: string) => void
...通过 ref 调用 el-select 的方法

命名

关于 valuelabel 的命名:

  • value:这里要表达的含义就是选中目标的 “值”,等同于原生 <input type="checkbox"> 元素的 value 属性,不一定是其唯一标识,所以不应该使用 id 或者 key,且 key 与 Vue 的特殊 attribute 冲突。

  • label:HTML 中 <label><input> 元素相关联,用于对后者进行说明,所以 label 天生是用来表达选中目标的 “展示名称” 的,而 ‘name’ 由于与原生 <input> 元素的 name 属性冲突故不考虑使用 ‘name’。

Element 本身没有做到命名的统一,el-selectlabel 表示选项的标签, 但 el-checkboxlabel 却表示的是选中状态的值。

UI 组件库的标杆 Ant Design 也是使用 valuelabel 命名。

更新日志

各版本详细改动请参考 release notes

0.15.1

5 months ago

0.15.2

5 months ago

0.14.0-rc.2

7 months ago

0.14.0-rc.1

7 months ago

0.14.0-rc.0

7 months ago

0.14.0-alpha.5

8 months ago

0.14.0-alpha.4

8 months ago

0.14.0-alpha.3

8 months ago

0.14.0-alpha.2

8 months ago

0.14.0-alpha.9

7 months ago

0.14.0-alpha.8

7 months ago

0.14.0-alpha.7

7 months ago

0.14.0-alpha.6

7 months ago

0.14.0-alpha.1

8 months ago

0.14.0-alpha.0

8 months ago

0.14.0-beta.0

7 months ago

0.14.0-beta.1

7 months ago

0.14.0-beta.2

7 months ago

0.14.0-beta.3

7 months ago

0.14.0

7 months ago

0.14.0-alpha.12

7 months ago

0.14.0-alpha.11

7 months ago

0.14.0-alpha.10

7 months ago

0.14.0-alpha.14

7 months ago

0.14.0-alpha.13

7 months ago

0.15.0

7 months ago

0.13.2

1 year ago

0.13.3

1 year ago

0.8.7

2 years ago

0.8.6

2 years ago

0.13.0

1 year ago

0.13.1

1 year ago

0.9.7

1 year ago

0.9.4

2 years ago

0.9.3

2 years ago

0.9.6

1 year ago

0.9.5

2 years ago

0.10.1

1 year ago

0.10.2

1 year ago

0.10.3

1 year ago

0.10.4

1 year ago

0.10.5

1 year ago

0.10.6

1 year ago

0.10.7

1 year ago

0.10.8

1 year ago

0.10.0

1 year ago

0.11.0

1 year ago

0.11.1

1 year ago

0.9.0

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.12.0

1 year ago

0.12.1

1 year ago

0.8.5

2 years ago

0.8.4

2 years ago

0.7.0

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.8.3

2 years ago

0.8.2

2 years ago

0.6.18

2 years ago

0.6.17

2 years ago

0.6.16

2 years ago

0.6.15

2 years ago

0.5.10

2 years ago

0.5.11

2 years ago

0.5.14

2 years ago

0.5.12

2 years ago

0.5.13

2 years ago

0.6.7

2 years ago

0.6.6

2 years ago

0.6.9

2 years ago

0.6.8

2 years ago

0.6.10

2 years ago

0.6.12

2 years ago

0.6.11

2 years ago

0.6.14

2 years ago

0.6.13

2 years ago

0.6.3

2 years ago

0.6.2

2 years ago

0.6.5

2 years ago

0.6.4

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.4

2 years ago

0.5.6

2 years ago

0.5.5

2 years ago

0.5.8

2 years ago

0.5.7

2 years ago

0.5.9

2 years ago

0.5.3

2 years ago

0.5.0

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.4.28

2 years ago

0.4.29

2 years ago

0.4.26

2 years ago

0.4.27

2 years ago

0.4.25

2 years ago

0.4.20

2 years ago

0.4.21

2 years ago

0.4.24

2 years ago

0.4.22

2 years ago

0.4.23

2 years ago

0.4.19

2 years ago

0.4.17

2 years ago

0.4.18

2 years ago

0.4.15

3 years ago

0.4.16

3 years ago

0.4.13

3 years ago

0.4.14

3 years ago

0.4.12

3 years ago

0.4.10

3 years ago

0.4.11

3 years ago

0.4.9

3 years ago

0.4.8

3 years ago

0.4.7

3 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.6

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.4

3 years ago

0.2.16

3 years ago

0.3.0

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.3

3 years ago

0.2.15

3 years ago

0.2.14

3 years ago

0.2.13

3 years ago

0.2.12

3 years ago

0.2.11

3 years ago

0.2.10

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.4

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.13

3 years ago

0.1.10

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.0

3 years ago

0.1.1

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.3

3 years ago

0.0.4

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago