8 |
9 | ## 如何使用
10 |
11 | 使用组件库时,只需安装 `@opentiny/vue` , `@opentiny/vue-renderless` 会同步完成安装
12 |
13 | ## 本地开发
14 | ```shell
15 | git clone git@github.com:opentiny/tiny-vue-renderless.git
16 | cd tiny-vue-renderless
17 | npm i
18 | ```
19 | - 克隆的 tiny-vue-renderless 工程放在与 tiny-vue 工程同个目录文件夹
20 | - 安装 tiny-vue-renderless 的依赖
21 | - 然后启动 tiny-vue 工程
22 | - 本地启动 tiny-vue 工程后,即可调试 tiny-vue-renderless 工程
23 |
24 | ## 开源协议
25 |
26 | [MIT](LICENSE)
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | [
4 | '@babel/preset-env',
5 | {
6 | useBuiltIns: 'entry',
7 | corejs: { version: '3' }
8 | }
9 | ]
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ ! $version ];
3 | then npm version 0.1.0-`date "+%Y%m%d%H%M%S"`;
4 | else npm version $version;
5 | fi
6 |
7 | npm install
8 | npm run build
9 | npm run release
10 |
11 | if [ $? -ne 0 ]
12 | then
13 | echo "[ERROR] build falid!"
14 | exit 1
15 | fi
16 | echo '[INFO] build completed'
17 |
18 |
--------------------------------------------------------------------------------
/build/babel.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "comments": false,
3 | "presets": [
4 | [
5 | "@babel/env",
6 | {
7 | "modules": false
8 | }
9 | ]
10 | ],
11 | "plugins": [
12 | "@babel/plugin-transform-runtime"
13 | ]
14 | }
--------------------------------------------------------------------------------
/build/build-version.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs-extra')
2 | const path = require('path')
3 | const utils = require('./utils')
4 |
5 | /**
6 | * 在文件 src/common/index.js 注入版本规则
7 | */
8 |
9 | const RUNTIME_VERSION = 'process.env.RUNTIME_VERSION'
10 | const BASE_RUNTIME_PATH = path.join(__dirname, '..', 'dist', 'common')
11 | const RENDERLESS_VERSION = fs.readJsonSync(path.join(__dirname, '../package.json')).version;
12 | ['index.js', 'runtime.js'].forEach((fileName) => {
13 | const fullPath = path.join(BASE_RUNTIME_PATH, fileName)
14 |
15 | if (fs.existsSync(fullPath)) {
16 | let scriptContent = fs.readFileSync(fullPath).toString('UTF-8')
17 |
18 | scriptContent = scriptContent.replace(RUNTIME_VERSION, `'${RENDERLESS_VERSION}'`)
19 |
20 | fs.writeFileSync(fullPath, scriptContent)
21 | }
22 | })
23 |
24 | utils.logGreen('npm run build:version done.')
25 |
--------------------------------------------------------------------------------
/build/release.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs')
2 | const path = require('path')
3 | const { execSync } = require('child_process')
4 |
5 | const source = 'dist'
6 |
7 | fs.copyFileSync('package.json', source + '/package.json')
8 |
9 | execSync('npm pack', { cwd: source })
10 |
11 | fs.readdirSync(source).forEach((item) => {
12 | if (item.endsWith('.tgz')) {
13 | const tgzPath = path.join(source, item)
14 |
15 | fs.copyFileSync(tgzPath, path.join(item))
16 | fs.unlinkSync(tgzPath)
17 | }
18 | })
19 |
--------------------------------------------------------------------------------
/commitlint.config.js:
--------------------------------------------------------------------------------
1 | module.exports = { extends: ['@commitlint/config-conventional'] }
2 |
--------------------------------------------------------------------------------
/scripts/release.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs')
2 | const path = require('path')
3 | const { execSync } = require('child_process')
4 |
5 | const source = 'dist'
6 |
7 | fs.copyFileSync('package.json', source + '/package.json')
8 |
9 | fs.copyFileSync('README.md', source + '/README.md')
10 |
11 | execSync('npm pack', { cwd: source })
12 |
13 | fs.readdirSync(source).forEach((item) => {
14 | if (item.endsWith('.tgz')) {
15 | const tgzPath = path.join(source, item)
16 |
17 | fs.copyFileSync(tgzPath, path.join(item))
18 | fs.unlinkSync(tgzPath)
19 | }
20 | })
21 |
--------------------------------------------------------------------------------
/src/action-menu/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const handleMoreClick = (emit) => () => {
14 | emit('more-click')
15 | }
16 |
17 | export const handleItemClick = (emit) => (data) => {
18 | emit('item-click', data)
19 | }
20 |
21 | export const visibleChange = (emit)=>(status)=>{
22 | emit('visible-change',status)
23 | }
24 |
--------------------------------------------------------------------------------
/src/action-menu/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { handleMoreClick, handleItemClick ,visibleChange} from './index'
14 |
15 | export const api = ['state', 'handleMoreClick', 'handleItemClick','visibleChange']
16 |
17 | export const renderless = (props, { computed, reactive }, { emit,nextTick }) => {
18 | const api = {
19 | handleMoreClick: handleMoreClick(emit),
20 | handleItemClick: handleItemClick(emit),
21 | visibleChange: visibleChange(emit)
22 | }
23 | const state = reactive({
24 | visibleOptions: computed(() => props.options.slice(0, props.maxShowNum)),
25 | moreOptions: computed(() => props.options.slice(props.maxShowNum)),
26 | spacing: computed(() => (String(props.spacing).includes('px') ? props.spacing : props.spacing + 'px'))
27 | })
28 |
29 | Object.assign(api, {
30 | state
31 | })
32 |
33 | return api
34 | }
35 |
--------------------------------------------------------------------------------
/src/alert/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const close = ({ emit, state }) => () => {
14 | state.show = false
15 | emit('close')
16 | }
17 |
18 | export const computedGetIcon = ({ constants, props }) => () => props.icon || constants.ICON_MAP[props.type]
19 |
20 | export const computedGetTitle = ({ constants, t, props }) => () => props.title || t(constants.TITLE_MAP[props.type])
21 |
--------------------------------------------------------------------------------
/src/alert/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { close, computedGetIcon, computedGetTitle } from './index'
14 |
15 | export const api = ['close', 'state']
16 |
17 | export const renderless = (props, { computed, reactive }, { t, emit, constants }) => {
18 | const api = {
19 | computedGetIcon: computedGetIcon({ constants, props }),
20 | computedGetTitle: computedGetTitle({ constants, props, t })
21 | }
22 |
23 | const state = reactive({
24 | show: true,
25 | getIcon: computed(() => api.computedGetIcon()),
26 | getTitle: computed(() => api.computedGetTitle())
27 | })
28 |
29 | Object.assign(api, {
30 | state,
31 | close: close({ state, emit })
32 | })
33 |
34 | return api
35 | }
36 |
--------------------------------------------------------------------------------
/src/anchor/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICElinksMapNSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { mounted, updated, unmounted, getContainer, linkClick, onItersectionObserver } from './index'
14 |
15 | export const api = ['state', 'getContainer', 'linkClick', 'onItersectionObserver']
16 |
17 | export const renderless = (props, { onMounted, onUnmounted, onUpdated, reactive }, { vm, emit }) => {
18 | const api = {}
19 | const state = reactive({
20 | currentLink: '',
21 | observerLinks: {},
22 | intersectionObserver: null,
23 | scrollContainer: null,
24 | currentHash: ''
25 | })
26 |
27 | Object.assign(api, {
28 | state,
29 | mounted: mounted({ vm, state, api }),
30 | updated: updated({ state, api }),
31 | unmounted: unmounted({ state }),
32 | getContainer: getContainer({ props }),
33 | linkClick: linkClick({ state, vm, emit, props }),
34 | onItersectionObserver: onItersectionObserver({ vm, state, props, emit })
35 | })
36 |
37 | onMounted(api.mounted)
38 | onUpdated(api.updated)
39 | onUnmounted(api.unmounted)
40 |
41 | return api
42 | }
43 |
--------------------------------------------------------------------------------
/src/autonavi-map/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { getAmap } from '@opentiny/vue-renderless/chart-core/deps/utils'
14 |
15 | export const amap = (columns, rows, settings, extra) => {
16 | const { key, v, amap, useOuterMap, url } = settings
17 | const { _once } = extra
18 | const registerSign = 'amap_register'
19 |
20 | if (_once[registerSign]) {
21 | return {}
22 | }
23 |
24 | _once[registerSign] = true
25 |
26 | if (useOuterMap) {
27 | return { amap }
28 | }
29 |
30 | return getAmap({ key, version: v, url }).then(() => ({ amap }))
31 | }
32 |
--------------------------------------------------------------------------------
/src/avatar/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const handleError = ({ props, state }) => () => {
14 | const { error } = props
15 | const errorFlag = error ? error() : undefined
16 |
17 | if (errorFlag !== false) {
18 | if (state.isSrcImageExist) {
19 | state.isSrcImageExist = false;
20 | } else {
21 | state.isDefaultImageExist = false;
22 | }
23 | }
24 | }
25 |
26 | export const computedAvatarClass = (contants) => (props) => {
27 | const { size, icon, shape } = props
28 | let classList = [contants.COMPONENT_PREFIX]
29 |
30 | if (size && typeof size === 'string') {
31 | classList.push(`${contants.COMPONENT_PREFIX}--${size}`)
32 | }
33 |
34 | if (icon) {
35 | classList.push(`${contants.COMPONENT_PREFIX}--${contants.icon}`)
36 | }
37 |
38 | if (shape) {
39 | classList.push(`${contants.COMPONENT_PREFIX}--${shape}`)
40 | }
41 |
42 | return classList.join(' ')
43 | }
44 |
--------------------------------------------------------------------------------
/src/avatar/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { computedAvatarClass, handleError } from './index'
14 |
15 | export const api = ['state', 'handleError']
16 |
17 | export const renderless = (props, { computed, reactive }, { constants }) => {
18 | const api = {
19 | computedAvatarClass: computedAvatarClass(constants)
20 | }
21 |
22 | const state = reactive({
23 | isSrcImageExist: true,
24 | isDefaultImageExist: true,
25 | avatarClass: computed(() => api.computedAvatarClass(props))
26 | })
27 |
28 | Object.assign(api, {
29 | state,
30 | handleError: handleError({ props, state })
31 | })
32 |
33 | return api
34 | }
35 |
--------------------------------------------------------------------------------
/src/badge/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const computedContent = ({ props, state }) => () =>
14 | typeof state.valueRef === 'number' && typeof props.max === 'number' ? (props.max < state.valueRef ? `${props.max}+` : state.valueRef) : state.valueRef
15 |
16 | export const computedValueRef = ({ props }) => () => {
17 | if (typeof props.value === 'number') {
18 | return props.value
19 | }
20 |
21 | return typeof props.modelValue === 'number' ? props.modelValue : undefined
22 | }
23 |
--------------------------------------------------------------------------------
/src/badge/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { computedContent, computedValueRef } from './index'
14 | import { xss } from '@opentiny/vue-renderless/common/xss'
15 |
16 | export const api = ['state']
17 |
18 | export const renderless = (props, { computed, reactive }) => {
19 | const api = {
20 | computedValueRef: computedValueRef({ props })
21 | }
22 |
23 | const state = reactive({
24 | isOverstep: false,
25 | valueRef: computed(() => api.computedValueRef()),
26 | content: computed(() => api.computedContent()),
27 | href: computed(() => xss.filterUrl(props.href))
28 | })
29 |
30 | api.state = state
31 | api.computedContent = computedContent({ props, state })
32 |
33 | return api
34 | }
35 |
--------------------------------------------------------------------------------
/src/baidu-map/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { getBmap } from '@opentiny/vue-renderless/chart-core/deps/utils'
14 |
15 | export const bmap = (columns, rows, settings, extra) => {
16 | const { key, v, bmap, useOuterMap, url } = settings
17 | const { _once } = extra
18 | const registerSign = 'bmap_register'
19 |
20 | if (_once[registerSign]) {
21 | return {}
22 | }
23 |
24 | _once[registerSign] = true
25 |
26 | if (useOuterMap) {
27 | return { bmap }
28 | }
29 |
30 | return getBmap({ key, version: v, url }).then(() => ({ bmap }))
31 | }
32 |
--------------------------------------------------------------------------------
/src/breadcrumb-item/index.js:
--------------------------------------------------------------------------------
1 | export const linkClick = ({ props, refs, router, emit, breadcrumbEmitter, constants }) => (event) => {
2 | const { replace, to, option } = props
3 | const currentBreadcrumbItem = { link: refs.link, replace, to, event, option }
4 |
5 | breadcrumbEmitter.emit(constants.EVENT_NAME.breadcrumbItemSelect, currentBreadcrumbItem)
6 | emit('select', currentBreadcrumbItem)
7 |
8 | if (!to || !router) {
9 | return
10 | }
11 |
12 | replace ? router.replace(to) : router.push(to)
13 | }
14 |
--------------------------------------------------------------------------------
/src/breadcrumb-item/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { on, off } from '@opentiny/vue-renderless/common/deps/dom'
14 | import { linkClick } from './index'
15 |
16 | export const api = ['linkClick']
17 |
18 | export const renderless = (props, { onMounted, onBeforeUnmount, inject }, { refs, router, emit }) => {
19 | const breadcrumbEmitter = inject('breadcrumbEmitter')
20 | const breadcrumb = inject('breadcrumb')
21 | const constants = breadcrumb._constants
22 |
23 | const api = {
24 | linkClick: linkClick({ props, refs, router, emit, breadcrumbEmitter, constants })
25 | }
26 |
27 | onMounted(() => {
28 | on(refs.link, 'click', api.linkClick)
29 | })
30 |
31 | onBeforeUnmount(() => {
32 | off(refs.link, 'click', api.linkClick)
33 | })
34 |
35 | return {
36 | api
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/breadcrumb/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const breadcrumbItemSelect = ({ emit, state, constants }) => {
14 | state.breadcrumbEmitter.on(constants.EVENT_NAME.breadcrumbItemSelect, (value) => {
15 | state.currentBreadcrumbItem = value
16 | emit('select', value)
17 | })
18 | }
19 |
--------------------------------------------------------------------------------
/src/breadcrumb/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { breadcrumbItemSelect } from './index'
14 |
15 | export const api = ['breadcrumbItemSelect']
16 |
17 | export const renderless = (props, { reactive, provide }, { emit, constants, emitter }) => {
18 | const state = reactive({
19 | breadcrumbEmitter: emitter(),
20 | currentBreadcrumbItem: {}
21 | })
22 |
23 | const api = {
24 | breadcrumbItemSelect: () => breadcrumbItemSelect({ api, emit, state, constants })
25 | }
26 |
27 | provide('breadcrumbEmitter', state.breadcrumbEmitter)
28 |
29 | api.breadcrumbItemSelect()
30 |
31 | return api
32 | }
33 |
--------------------------------------------------------------------------------
/src/bulletin-board/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { xss } from '@opentiny/vue-renderless/common/xss.js'
14 |
15 | export const getRoute = (route) => `/${route || ''}`.replace(/^\/+/, '/')
16 |
17 | export const computedDataList = ({ props, state }) => () => {
18 | const list = props.data[Number(state.actName) - 1] || []
19 |
20 | list.forEach((subItem) => {
21 | subItem.url = xss.filterUrl(subItem.url)
22 | })
23 |
24 | return list
25 | }
26 |
27 | export const computedMoreLink = ({ props }) => () => {
28 | if (props.moreLink) {
29 | props.moreLink.url = xss.filterUrl(props.moreLink.url)
30 | }
31 | return props.moreLink
32 | }
33 |
--------------------------------------------------------------------------------
/src/bulletin-board/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { getRoute, computedDataList, computedMoreLink } from './index'
14 |
15 | export const api = ['state', 'getRoute']
16 |
17 | export const renderless = (props, { reactive, computed, watch }) => {
18 | const api = {}
19 | const state = reactive({
20 | actName: props.activeName,
21 | dataList: computed(() => api.computedDataList()),
22 | moreLink: computed(() => api.computedMoreLink())
23 | })
24 |
25 | watch(
26 | () => props.activeName,
27 | (value) => {
28 | state.actName = value
29 | },
30 | { immediate: true }
31 | )
32 |
33 | Object.assign(api, {
34 | state,
35 | getRoute,
36 | computedDataList: computedDataList({ props, state }),
37 | computedMoreLink: computedMoreLink({ props })
38 | })
39 |
40 | return api
41 | }
42 |
--------------------------------------------------------------------------------
/src/button-group/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const handleClick = ({ emit, props, state }) => (node) => {
14 | if (!state.disabled) {
15 | state.value = node[props.valueField]
16 | emit('update:modelValue', state.value)
17 | }
18 | }
19 |
20 | export const moreNodeClick = ({ emit, props, state }) => (node) => {
21 | if (!state.disabled) {
22 | const index = state.moreData.indexOf(node)
23 |
24 | state.moreData.splice(index, 1, state.buttonData[state.buttonData.length - 1])
25 | state.buttonData.splice(state.buttonData.length - 1, 1, node)
26 | state.value = node[props.valueField]
27 | emit('update:modelValue', state.value)
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/button/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const handleClick = ({ emit, props, state }) => (event) => {
14 | if (props.nativeType === 'button' && props.resetTime > 0) {
15 | state.disabled = true
16 |
17 | state.timer = setTimeout(() => {
18 | state.disabled = false
19 | }, props.resetTime)
20 | }
21 |
22 | emit('click', event)
23 | }
24 |
25 | export const clearTimer = (state) => () => clearTimeout(state.timer)
26 |
--------------------------------------------------------------------------------
/src/button/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { handleClick, clearTimer } from './index'
14 |
15 | export const api = ['state', 'handleClick']
16 |
17 | export const renderless = (props, { computed, onBeforeUnmount, reactive, watch, inject }, { emit, parent }) => {
18 | parent.tinyForm = parent.tinyForm || inject('form', null)
19 |
20 | const state = reactive({
21 | timer: null,
22 | disabled: props.disabled,
23 | plain: computed(() => props.plain || (parent.buttonGroup || {}).plain),
24 | formDisabled: computed(() => (parent.tinyForm || {}).disabled),
25 | buttonDisabled: computed(() => props.disabled || state.disabled || (parent.buttonGroup || {}).disabled || state.formDisabled)
26 | })
27 |
28 | watch(
29 | () => props.disabled,
30 | (value) => {
31 | state.disabled = value
32 | },
33 | { immediate: true }
34 | )
35 |
36 | const api = {
37 | state,
38 | clearTimer: clearTimer(state),
39 | handleClick: handleClick({ emit, props, state })
40 | }
41 |
42 | onBeforeUnmount(api.clearTimer)
43 |
44 | return api
45 | }
46 |
--------------------------------------------------------------------------------
/src/card-template/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import PopupManager from '@opentiny/vue-renderless/common/deps/popup-manager'
14 |
15 | export const toolClick = (showMoreTools) => (cb) => {
16 | typeof cb === 'function' && cb()
17 | showMoreTools.value = false
18 | }
19 |
20 | export const computedMoreTools = ({ props }) => () => (Array.isArray(props.tools) && props.tools.length > 3 ? props.tools.slice(2) : [])
21 |
22 | export const computedTools = ({ props, state, constants, refs, t }) => () => {
23 | let result = []
24 | const tools = props.tools
25 |
26 | if (Array.isArray(tools) && tools.length) {
27 | if (tools.length <= 3) {
28 | result = tools
29 | } else {
30 | result = [].concat(tools[0], tools[1], {
31 | icon: constants.MOREICON,
32 | title: t('ui.base.more'),
33 | click() {
34 | state.showMoreTools = !state.showMoreTools
35 | refs.selector.style.zIndex = PopupManager.nextZIndex()
36 | }
37 | })
38 | }
39 | }
40 |
41 | return result
42 | }
43 |
--------------------------------------------------------------------------------
/src/card-template/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { toolClick, computedTools, computedMoreTools } from './index'
14 |
15 | export const api = ['state', 'toolClick']
16 |
17 | export const renderless = (props, { computed, reactive }, { t, refs, constants }) => {
18 | const api = {
19 | computedMoreTools: computedMoreTools({ props })
20 | }
21 |
22 | const state = reactive({
23 | isEnter: false,
24 | showMoreTools: false,
25 | moreTools: computed(() => api.computedMoreTools(props)),
26 | currentTools: computed(() => api.computedTools())
27 | })
28 |
29 | api.state = state
30 | api.computedTools = computedTools({ constants, props, refs, state, t })
31 | api.toolClick = toolClick(state)
32 |
33 | return api
34 | }
35 |
--------------------------------------------------------------------------------
/src/cascader-menu/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { handleExpand, handleMouseMove, clearHoverZone } from './index'
14 | import { CASCADER } from '@opentiny/vue-renderless/common'
15 | import { random } from '@opentiny/vue-renderless/common/string'
16 |
17 | export const api = ['state', 'handleMouseMove', 'handleExpand']
18 |
19 | export const renderless = (props, { computed, reactive }, { vm, parent }) => {
20 | const refs = vm.$refs
21 | const api = {}
22 | const state = reactive({
23 | activeNode: null,
24 | hoverTimer: null,
25 | id: Math.floor(random() * 10000),
26 | isEmpty: computed(() => !props.nodes.length),
27 | menuId: computed(() => `${CASCADER.MenuConnector}${state.id}-${props.index}`)
28 | })
29 |
30 | Object.assign(api, {
31 | state,
32 | clearHoverZone: clearHoverZone(refs),
33 | handleExpand: handleExpand(state),
34 | handleMouseMove: handleMouseMove({ api, parent, refs, state, svg: CASCADER.SvgStr })
35 | })
36 |
37 | return api
38 | }
39 |
--------------------------------------------------------------------------------
/src/chart-core/modules/animation.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export default ({ options, animation }) => {
14 | if (!animation) {
15 | return
16 | }
17 |
18 | Object.keys(animation).forEach((key) => {
19 | options[key] = animation[key]
20 | })
21 | }
22 |
--------------------------------------------------------------------------------
/src/chart-core/modules/mark.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export default (seriesItem, marks) => {
14 | Object.keys(marks).forEach((key) => {
15 | if (marks[key]) {
16 | seriesItem[key] = marks[key]
17 | }
18 | })
19 | }
20 |
--------------------------------------------------------------------------------
/src/chart-graph/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { itemPoint, itemLabel, itemContent } from '@opentiny/vue-renderless/chart-core/deps/constants'
14 |
15 | const getTooltip = () => ({
16 | trigger: 'item',
17 | formatter(item) {
18 | const tpl = []
19 | const { name, value, color, dataType } = item
20 |
21 | color && tpl.push(itemPoint(color))
22 | tpl.push(itemLabel(`${name}`, !value))
23 | if (dataType === 'node') {
24 | value && tpl.push(`${itemContent(value)} `)
25 | }
26 |
27 | return tpl.join('')
28 | }
29 | })
30 |
31 | const getGraphSeries = () => [{ type: 'graph', label: { textBorderWidth: 1, color: '#fff', textBorderColor: 'inherit' } }]
32 |
33 | export const graph = (columns, rows, settings, extra) => {
34 | const { tooltipVisible } = extra
35 | const tooltip = tooltipVisible && getTooltip({})
36 | const series = getGraphSeries()
37 |
38 | return { tooltip, series }
39 | }
40 |
--------------------------------------------------------------------------------
/src/chart-sunburst/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { itemPoint, itemLabel, itemContent } from '@opentiny/vue-renderless/chart-core/deps/constants'
14 |
15 | const getTooltip = () => ({
16 | trigger: 'item',
17 | formatter(item) {
18 | const tpl = []
19 | const { name, value, color } = item
20 |
21 | if (name) {
22 | color && tpl.push(itemPoint(color))
23 | tpl.push(`${itemLabel('label')}${itemContent(name)}`)
24 | tpl.push(' ')
25 | }
26 |
27 | color && tpl.push(itemPoint(color))
28 | tpl.push(`${itemLabel('sum')}${itemContent(value)}`)
29 |
30 | return tpl.join('')
31 | }
32 | })
33 |
34 | export const sunburst = (columns, rows, settings, extra) => {
35 | const defaultItemStyle = { borderWidth: 2 }
36 |
37 | const series = { type: 'sunburst', itemStyle: defaultItemStyle }
38 |
39 | const { tooltipVisible } = extra
40 |
41 | const tooltip = tooltipVisible && getTooltip({})
42 |
43 | let options = { series, tooltip }
44 |
45 | return options
46 | }
47 |
--------------------------------------------------------------------------------
/src/checkbox-group/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const computedFormItemSize = (props) => () => (props.formItem || {}).formItemSize
14 |
15 | export const computedCheckboxGroupSize = ({ props, formItemSize }) => () => props.size || formItemSize.value
16 |
--------------------------------------------------------------------------------
/src/checkbox-group/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { computedFormItemSize, computedCheckboxGroupSize } from './index'
14 |
15 | export const api = ['state']
16 |
17 | export const renderless = (props, { computed, reactive, watch }, { dispatch, constants }) => {
18 | const api = {
19 | computedFormItemSize: computedFormItemSize(props)
20 | }
21 |
22 | const formItemSize = computed(() => api.computedFormItemSize())
23 |
24 | const state = reactive({
25 | checkboxGroupSize: computed(() => api.computedCheckboxGroupSize())
26 | })
27 |
28 | Object.assign(api, {
29 | state,
30 | computedCheckboxGroupSize: computedCheckboxGroupSize({
31 | props,
32 | formItemSize
33 | })
34 | })
35 |
36 | watch(
37 | () => props.modelValue,
38 | (value) => dispatch(constants.FORM_ITEM, constants.FORM_CHANGE, [value])
39 | )
40 |
41 | return api
42 | }
43 |
--------------------------------------------------------------------------------
/src/col/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { setSubitemAttrValue, setGlobalAttrValue, getClassName, getStyle, row } from './index'
14 |
15 | export const api = ['state']
16 |
17 | export const renderless = (props, { computed, reactive }, { parent }) => {
18 | const api = {}
19 | const state = reactive({
20 | row: computed(() => api.row()),
21 | style: computed(() => api.getStyle()),
22 | className: computed(() => api.getClassName())
23 | })
24 |
25 | Object.assign(api, {
26 | state,
27 | row: row(parent),
28 | setGlobalAttrValue,
29 | setSubitemAttrValue,
30 | getStyle: getStyle({ props, state }),
31 | getClassName: getClassName({ api, props })
32 | })
33 |
34 | return api
35 | }
36 |
--------------------------------------------------------------------------------
/src/collapse-item/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const handleFocus = ({ state, interval }) => () => {
14 | setTimeout(() => {
15 | if (!state.isClick) {
16 | state.focusing = true
17 | } else {
18 | state.isClick = false
19 | }
20 | }, interval)
21 | }
22 |
23 | export const handleHeaderClick = ({ componentName, dispatch, eventName, props, parent, state }) => () => {
24 | if (props.disabled) {
25 | return
26 | }
27 |
28 | dispatch(componentName, eventName, parent)
29 |
30 | state.focusing = false
31 | state.isClick = true
32 | }
33 |
34 | export const handleEnterClick = ({ componentName, dispatch, eventName, parent }) => () => dispatch(componentName, eventName, parent)
35 |
--------------------------------------------------------------------------------
/src/collapse/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { setActiveNames, handleItemClick } from './index'
14 |
15 | export const api = ['state']
16 |
17 | export const renderless = (props, { reactive, watch }, { parent, emit, constants }) => {
18 | const eventName = constants.EVENT_NAME.CollapseItemClick
19 |
20 | const state = reactive({
21 | activeNames: []
22 | })
23 |
24 | const api = {
25 | state,
26 | setActiveNames: setActiveNames({ emit, props, state })
27 | }
28 |
29 | api.handleItemClick = handleItemClick({ api, props, state })
30 |
31 | watch(
32 | () => props.modelValue,
33 | (value) => {
34 | state.activeNames = value || value === 0 ? [].concat(value) : []
35 | },
36 | { immediate: true }
37 | )
38 |
39 | parent.$on(eventName, api.handleItemClick)
40 |
41 | return api
42 | }
43 |
--------------------------------------------------------------------------------
/src/common/deps/after-leave.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | const AfterLave = 'after-leave'
14 | const Speed = 300
15 |
16 | export default (instance, callback, speed = Speed, once = false) => {
17 | if (!instance || !callback) {
18 | throw new Error('instance & callback is required')
19 | }
20 |
21 | let called = false
22 |
23 | const eventCallback = function () {
24 | if (called) {
25 | return
26 | }
27 |
28 | called = true
29 |
30 | if (typeof callback === 'function') {
31 | callback.apply(null, arguments)
32 | }
33 | }
34 |
35 | if (once) {
36 | instance.$once(AfterLave, eventCallback)
37 | } else {
38 | instance.$on(AfterLave, eventCallback)
39 | }
40 |
41 | setTimeout(eventCallback, speed + 100)
42 | }
43 |
--------------------------------------------------------------------------------
/src/common/deps/debounce.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import throttle from '@opentiny/vue-renderless/common/deps/throttle'
14 |
15 | export default function (delay, atBegin, callback) {
16 | return callback === undefined ? throttle(delay, atBegin, false) : throttle(delay, callback, atBegin !== false)
17 | }
18 |
--------------------------------------------------------------------------------
/src/common/deps/letter-only.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { on, off } from '@opentiny/vue-renderless/common/deps/dom'
14 |
15 | /**
16 | * v-letter-only
17 | * @desc 只接受输入非数字字符
18 | * @example
19 | * ```vue
20 | *
21 | * ```
22 | */
23 | const checkValue = (event) => {
24 | if (event.charCode >= 48 && event.charCode <= 57) {
25 | event.preventDefault()
26 | }
27 |
28 | return true
29 | }
30 |
31 | export default {
32 | bind(element) {
33 | on(element, 'keypress', checkValue)
34 | },
35 | unbind(element) {
36 | off(element, 'keypress', checkValue)
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/common/deps/modal-queue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | const queue = []
14 | export default queue
15 |
--------------------------------------------------------------------------------
/src/common/deps/number-only.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { on, off } from '@opentiny/vue-renderless/common/deps/dom'
14 |
15 | /**
16 | * v-number-only
17 | * @desc 只接受输入数字
18 | * @example
19 | * ```vue
20 | *
21 | * ```
22 | */
23 | const checkValue = (event) => {
24 | event.target.value = event.target.value.replace(/[^0-9]/g, '')
25 |
26 | if (event.charCode >= 48 && event.charCode <= 57) {
27 | return true
28 | }
29 |
30 | event.preventDefault()
31 | }
32 |
33 | export default {
34 | bind(element) {
35 | on(element, 'keypress', checkValue)
36 | },
37 | unbind(element) {
38 | off(element, 'keypress', checkValue)
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/common/deps/repeat-click.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { on, once } from '@opentiny/vue-renderless/common/deps/dom'
14 |
15 | export default (el, binding) => {
16 | let interval = null
17 | let startTime
18 |
19 | const handler = () => {
20 | typeof binding.value === 'function' && binding.value.apply()
21 | }
22 |
23 | const clear = () => {
24 | if (Date.now() - startTime < 100) {
25 | handler()
26 | }
27 |
28 | clearInterval(interval)
29 | interval = null
30 | }
31 |
32 | on(el, 'mousedown', (e) => {
33 | if (e.button !== 0) {
34 | return
35 | }
36 |
37 | startTime = Date.now()
38 | once(document, 'mouseup', clear)
39 | clearInterval(interval)
40 | interval = setInterval(handler, 100)
41 | })
42 | }
43 |
--------------------------------------------------------------------------------
/src/common/deps/requestAnimationFrame.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | !(function () {
14 | let lastTime = 0
15 | const vendors = ['ms', 'moz', 'webkit', 'o']
16 |
17 | for (let x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
18 | window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']
19 |
20 | window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame']
21 | }
22 |
23 | if (!window.requestAnimationFrame) {
24 | window.requestAnimationFrame = function (callback) {
25 | const now = new Date().getTime()
26 | const timeToCall = Math.max(0, 16 - (now - lastTime))
27 | const timeCallback = now + timeToCall
28 |
29 | const id = window.setTimeout(() => {
30 | callback(timeCallback)
31 | }, timeToCall)
32 |
33 | lastTime = now + timeToCall
34 |
35 | return id
36 | }
37 | }
38 |
39 | if (!window.cancelAnimationFrame) {
40 | window.cancelAnimationFrame = function (id) {
41 | clearTimeout(id)
42 | }
43 | }
44 | })()
45 |
--------------------------------------------------------------------------------
/src/common/deps/scroll-into-view.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | const isServer = typeof window === 'undefined'
14 |
15 | export default (container, selected) => {
16 | if (isServer) {
17 | return
18 | }
19 |
20 | if (!selected) {
21 | container.scrollTop = 0
22 | return
23 | }
24 |
25 | const offsetParents = []
26 | let { offsetParent, offsetTop, offsetHeight } = selected
27 |
28 | while (offsetParent && container !== offsetParent && container.contains(offsetParent)) {
29 | offsetParents.push(offsetParent)
30 | offsetParent = offsetParent.offsetParent
31 | }
32 |
33 | const top = offsetTop + offsetParents.reduce((prev, curr) => prev + curr.offsetTop, 0)
34 | const bottom = top + offsetHeight
35 | const viewRectTop = container.scrollTop
36 | const viewRectBottom = viewRectTop + container.clientHeight
37 |
38 | if (top < viewRectTop) {
39 | container.scrollTop = top
40 | } else if (bottom > viewRectBottom) {
41 | container.scrollTop = bottom - container.clientHeight
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/common/deps/touch.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | const MIN_DISTANCE = 10
14 |
15 | function getDirection(w, h) {
16 | if (h > w && h > MIN_DISTANCE) {
17 | return 'vertical'
18 | } else if (w > h && w > MIN_DISTANCE) {
19 | return 'horizontal'
20 | }
21 | return ''
22 | }
23 |
24 | export const resetTouchStatus = (state) => {
25 | state.direction = ''
26 | state.deltaX = 0
27 | state.deltaY = 0
28 | state.offsetX = 0
29 | state.offsetY = 0
30 | }
31 |
32 | export const touchStart = (state) => (event) => {
33 | resetTouchStatus(state)
34 |
35 | state.startX = event.touches[0].clientX
36 | state.startY = event.touches[0].clientY
37 | }
38 |
39 | export const touchMove = (state) => (event) => {
40 | const touch = event.touches[0]
41 |
42 | state.deltaX = touch.clientX - state.startX
43 | state.deltaY = touch.clientY - state.startY
44 | state.offsetX = Math.abs(state.deltaX)
45 | state.offsetY = Math.abs(state.deltaY)
46 |
47 | state.direction = state.direction || getDirection(state.offsetX, state.offsetY)
48 | }
49 |
--------------------------------------------------------------------------------
/src/common/deps/tree-model/util.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const NODE_KEY = '$treeNodeId'
14 |
15 | export const getNodeKey = function (key, data) {
16 | if (!key) {
17 | return data[NODE_KEY]
18 | }
19 | return data[key]
20 | }
21 |
22 | export const markNodeData = function (node, data) {
23 | if (!data || data[NODE_KEY]) {
24 | return
25 | }
26 |
27 | Object.defineProperty(data, NODE_KEY, {
28 | value: node.id,
29 | enumerable: false,
30 | configurable: false,
31 | writable: false
32 | })
33 | }
34 |
--------------------------------------------------------------------------------
/src/common/deps/vue-emitter.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export default (vm) => {
14 | const broadcast = (vm, componentName, eventName, params) => {
15 | vm.$children.forEach((child) => {
16 | const name = child.$options.componentName
17 |
18 | if (name === componentName) {
19 | child.$emit(eventName, params)
20 | } else {
21 | broadcast(child, componentName, eventName, params)
22 | }
23 | })
24 | }
25 |
26 | return {
27 | dispatch(componentName, eventName, params) {
28 | let parent = vm.$parent || vm.$root
29 | let name = parent.$options.componentName
30 |
31 | while (parent && !parent.$attrs.novalid && (!name || name !== componentName)) {
32 | parent = parent.$parent
33 |
34 | if (parent) {
35 | name = parent.$options.componentName
36 | }
37 | }
38 |
39 | if (parent) {
40 | parent.$emit.apply(parent, [eventName].concat(params))
41 | }
42 | },
43 | broadcast(componentName, eventName, params) {
44 | broadcast(vm, componentName, eventName, params)
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/common/event.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | /**
14 | * 触发事件,并返回是否在事件中执行了 preventDefault 方法,支持事件传递附加参数。
15 | *
16 | * // 触发事件,返回 false 则退出
17 | * if (!emitEvent(emit, 'before', 1)) {
18 | * return
19 | * }
20 | *
21 | * // @before='before' 定义事件执行的函数
22 | * function before(event, value) {
23 | * // value: 1
24 | * event.preventDefault() // 通知事件宿主停止执行
25 | * }
26 | *
27 | * @param {Function} emit 触发事件的函数
28 | * @param {String} name 事件的名称
29 | * @returns {Boolean}
30 | */
31 | export const emitEvent = (emit, name, ...args) => {
32 | let cancel = false
33 |
34 | if (typeof emit === 'function' && typeof name === 'string') {
35 | const event = document.createEvent('HTMLEvents')
36 |
37 | event.initEvent(name, false, true)
38 | event.preventDefault = () => {
39 | cancel = true
40 | }
41 |
42 | args.unshift(event)
43 | args.unshift(name)
44 | emit.apply(null, args)
45 | }
46 |
47 | return !cancel
48 | }
49 |
--------------------------------------------------------------------------------
/src/common/validate/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import Schema from './schema'
14 | import validators from './validations/index'
15 | import getDefaultMessage from './messages'
16 |
17 | Schema.validators = validators
18 | Schema.getDefaultMessage = getDefaultMessage
19 |
20 | export default Schema
21 |
--------------------------------------------------------------------------------
/src/common/validate/rules/enum.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import * as util from '../util'
14 |
15 | const ENUM = 'enum'
16 |
17 | export default function (rule, checkValue, source, errors, options) {
18 | rule[ENUM] = Array.isArray(rule[ENUM]) ? rule[ENUM] : []
19 |
20 | if (rule[ENUM].indexOf(checkValue) === -1) {
21 | errors.push(util.format(options.messages[ENUM], rule.fullField, rule[ENUM].join(', ')))
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/common/validate/rules/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import type from './type'
14 | import range from './range'
15 | import enumRule from './enum'
16 | import pattern from './pattern'
17 | import required from './required'
18 | import whitespace from './whitespace'
19 |
20 | export default {
21 | type,
22 | range,
23 | pattern,
24 | required,
25 | whitespace,
26 | enum: enumRule
27 | }
28 |
--------------------------------------------------------------------------------
/src/common/validate/rules/pattern.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import * as util from '../util'
14 |
15 | export default function (rule, checkValue, source, errors, options) {
16 | if (rule.pattern) {
17 | if (rule.pattern instanceof RegExp) {
18 | rule.pattern.lastIndex = 0
19 |
20 | if (!rule.pattern.test(checkValue)) {
21 | errors.push(util.format(options.messages.pattern.mismatch, rule.fullField, checkValue, rule.pattern))
22 | }
23 | } else if (typeof rule.pattern === 'string') {
24 | const _pattern = new RegExp(rule.pattern)
25 |
26 | if (!_pattern.test(checkValue)) {
27 | errors.push(util.format(options.messages.pattern.mismatch, rule.fullField, checkValue, rule.pattern))
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/common/validate/rules/required.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import * as util from '../util'
14 | import { hasOwn } from '@opentiny/vue-renderless/common/type'
15 |
16 | export default function ({ rule, checkValue, source, errors, options, type }) {
17 | if (rule.required && (!hasOwn.call(source, rule.field) || util.isEmptyValue(checkValue, type || rule.type))) {
18 | errors.push(util.format(options.messages.required, rule.fullField))
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/common/validate/rules/whitespace.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import * as util from '../util'
14 |
15 | export default function (rule, checkValue, source, errors, options) {
16 | if (/^\s+$/.test(checkValue) || checkValue === '') {
17 | errors.push(util.format(options.messages.whitespace, rule.fullField))
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/common/validate/validations/array.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import rules from '../rules/index'
14 | import { isEmptyValue } from '../util'
15 | import { hasOwn } from '@opentiny/vue-renderless/common/type'
16 |
17 | export default function (rule, checkValue, callback, source, options) {
18 | const errors = []
19 | const validate = rule.required || (!rule.required && hasOwn.call(source, rule.field))
20 |
21 | if (validate) {
22 | if (isEmptyValue(checkValue, 'array') && !rule.required) {
23 | return callback()
24 | }
25 |
26 | rules.required({ rule, checkValue, source, errors, options, type: 'array' })
27 |
28 | if (!isEmptyValue(checkValue, 'array')) {
29 | rules.type(rule, checkValue, source, errors, options)
30 | rules.range(rule, checkValue, source, errors, options)
31 | }
32 | }
33 |
34 | callback(errors)
35 | }
36 |
--------------------------------------------------------------------------------
/src/common/validate/validations/enum.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import rules from '../rules/index'
14 | import { isEmptyValue } from '../util'
15 | import { hasOwn } from '@opentiny/vue-renderless/common/type'
16 |
17 | const ENUM = 'enum'
18 |
19 | export default function (rule, checkValue, callback, source, options) {
20 | const errors = []
21 | const validate = rule.required || (!rule.required && hasOwn.call(source, rule.field))
22 |
23 | if (validate) {
24 | if (isEmptyValue(checkValue) && !rule.required) {
25 | return callback()
26 | }
27 |
28 | rules.required({ rule, checkValue, source, errors, options })
29 |
30 | if (checkValue !== undefined) {
31 | rules[ENUM](rule, checkValue, source, errors, options)
32 | }
33 | }
34 |
35 | callback(errors)
36 | }
37 |
--------------------------------------------------------------------------------
/src/common/validate/validations/float.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import rules from '../rules/index'
14 | import { isEmptyValue } from '../util'
15 | import { hasOwn } from '@opentiny/vue-renderless/common/type'
16 |
17 | export default function (rule, checkValue, cb, source, options) {
18 | const errors = []
19 | const validate = rule.required || (!rule.required && hasOwn.call(source, rule.field))
20 |
21 | if (validate) {
22 | if (isEmptyValue(checkValue) && !rule.required) {
23 | return cb()
24 | }
25 |
26 | rules.required({ rule, checkValue, source, errors, options })
27 |
28 | if (checkValue !== undefined) {
29 | rules.type(rule, checkValue, source, errors, options)
30 | rules.range(rule, checkValue, source, errors, options)
31 | }
32 | }
33 |
34 | cb(errors)
35 | }
36 |
--------------------------------------------------------------------------------
/src/common/validate/validations/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import date from './date'
14 | import type from './type'
15 | import float from './float'
16 | import array from './array'
17 | import string from './string'
18 | import method from './method'
19 | import number from './number'
20 | import integer from './integer'
21 | import pattern from './pattern'
22 | import required from './required'
23 | import enumValidator from './enum'
24 |
25 | export default {
26 | date,
27 | float,
28 | array,
29 | string,
30 | method,
31 | number,
32 | integer,
33 | pattern,
34 | required,
35 | hex: type,
36 | url: type,
37 | time: type,
38 | email: type,
39 | digits: type,
40 | dateYM: type,
41 | speczh: type,
42 | dateYMD: type,
43 | version: type,
44 | fileSize: type,
45 | regexp: method,
46 | object: method,
47 | dateTime: type,
48 | specialch: type,
49 | boolean: method,
50 | acceptImg: type,
51 | specialch2: type,
52 | acceptFile: type,
53 | longDateTime: type,
54 | enum: enumValidator
55 | }
56 |
--------------------------------------------------------------------------------
/src/common/validate/validations/integer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import rules from '../rules/index'
14 | import { isEmptyValue } from '../util'
15 | import { hasOwn } from '@opentiny/vue-renderless/common/type'
16 |
17 | export default function (rule, checkValue, callback, source, options) {
18 | const errors = []
19 | const validate = rule.required || (!rule.required && hasOwn.call(source, rule.field))
20 |
21 | if (validate) {
22 | if (isEmptyValue(checkValue) && !rule.required) {
23 | return callback()
24 | }
25 |
26 | rules.required({ rule, checkValue, source, errors, options })
27 |
28 | if (undefined !== checkValue) {
29 | rules.type(rule, checkValue, source, errors, options)
30 | rules.range(rule, checkValue, source, errors, options)
31 | }
32 | }
33 |
34 | callback(errors)
35 | }
36 |
--------------------------------------------------------------------------------
/src/common/validate/validations/method.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import rules from '../rules/index'
14 | import { isEmptyValue } from '../util'
15 | import { hasOwn } from '@opentiny/vue-renderless/common/type'
16 |
17 | export default function (rule, checkValue, callback, source, options) {
18 | const validate = rule.required || (!rule.required && hasOwn.call(source, rule.field))
19 | const errors = []
20 |
21 | if (validate) {
22 | if (!rule.required && isEmptyValue(checkValue)) {
23 | return callback()
24 | }
25 |
26 | rules.required({ rule, checkValue, source, errors, options })
27 |
28 | if (undefined !== checkValue) {
29 | rules.type(rule, checkValue, source, errors, options)
30 | }
31 | }
32 |
33 | callback(errors)
34 | }
35 |
--------------------------------------------------------------------------------
/src/common/validate/validations/number.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import rules from '../rules/index'
14 | import { isEmptyValue } from '../util'
15 | import { hasOwn } from '@opentiny/vue-renderless/common/type'
16 |
17 | export default function (rule, checkValue, callback, source, options) {
18 | const errors = []
19 | const validate = rule.required || (!rule.required && hasOwn.call(source, rule.field))
20 |
21 | if (validate) {
22 | if (checkValue === '') {
23 | checkValue = undefined
24 | }
25 |
26 | if (!rule.required && isEmptyValue(checkValue)) {
27 | return callback()
28 | }
29 |
30 | rules.required({ rule, checkValue, source, errors, options })
31 |
32 | if (checkValue !== undefined) {
33 | rules.type(rule, checkValue, source, errors, options)
34 | rules.range(rule, checkValue, source, errors, options)
35 | }
36 | }
37 |
38 | callback(errors)
39 | }
40 |
--------------------------------------------------------------------------------
/src/common/validate/validations/pattern.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import rules from '../rules/index'
14 | import { isEmptyValue } from '../util'
15 | import { hasOwn } from '@opentiny/vue-renderless/common/type'
16 |
17 | export default function (rule, checkValue, callback, source, options) {
18 | const errors = []
19 | const validate = rule.required || (!rule.required && hasOwn.call(source, rule.field))
20 |
21 | if (validate) {
22 | if (isEmptyValue(checkValue, 'string') && !rule.required) {
23 | return callback()
24 | }
25 |
26 | rules.required({ rule, checkValue, source, errors, options })
27 |
28 | if (!isEmptyValue(checkValue, 'string')) {
29 | rules.pattern(rule, checkValue, source, errors, options)
30 | }
31 | }
32 |
33 | callback(errors)
34 | }
35 |
--------------------------------------------------------------------------------
/src/common/validate/validations/required.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import rules from '../rules/index'
14 |
15 | export default function (rule, checkValue, callback, source, options) {
16 | const errors = []
17 | const type = Array.isArray(checkValue) ? 'array' : typeof checkValue
18 |
19 | rules.required({ rule, checkValue, source, errors, options, type })
20 | callback(errors)
21 | }
22 |
--------------------------------------------------------------------------------
/src/common/validate/validations/type.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import rules from '../rules/index'
14 | import { isEmptyValue } from '../util'
15 | import { hasOwn } from '@opentiny/vue-renderless/common/type'
16 |
17 | export default function (rule, checkValue, callback, source, options) {
18 | const ruleType = rule.type
19 | const errors = []
20 | const validate = rule.required || (!rule.required && hasOwn.call(source, rule.field))
21 |
22 | if (validate) {
23 | if (isEmptyValue(checkValue, ruleType) && !rule.required) {
24 | return callback()
25 | }
26 |
27 | rules.required({
28 | rule,
29 | checkValue,
30 | source,
31 | errors,
32 | options,
33 | type: ruleType
34 | })
35 |
36 | if (!isEmptyValue(checkValue, ruleType)) {
37 | rules.type(rule, checkValue, source, errors, options)
38 | }
39 | }
40 |
41 | callback(errors)
42 | }
43 |
--------------------------------------------------------------------------------
/src/company/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { init, change, initService } from './index'
14 |
15 | export const api = ['state', 'change', 'clear', 'visibleChange']
16 |
17 | export const renderless = (props, { watch, reactive }, { emit, service }) => {
18 | const $service = initService({ props, service })
19 |
20 | const state = reactive({
21 | options: [],
22 | source: null,
23 | selectedValue: props.modelValue
24 | })
25 |
26 | const api = {
27 | state,
28 | change: change(emit),
29 | init: init({ state, props, service: $service })
30 | }
31 |
32 | watch(
33 | () => props.modelValue,
34 | (propsValue) => {
35 | state.selectedValue = propsValue
36 | },
37 | { immediate: true }
38 | )
39 |
40 | api.init()
41 |
42 | return api
43 | }
44 |
--------------------------------------------------------------------------------
/src/country/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { init, change, initService } from './index'
14 |
15 | export const api = ['state', 'change', 'emit']
16 |
17 | export const renderless = (props, { watch, reactive }, { service, emit }) => {
18 | const $service = initService({ props, service })
19 |
20 | const state = reactive({
21 | source: null,
22 | options: [],
23 | selectedValue: props.modelValue
24 | })
25 |
26 | const api = {
27 | state,
28 | emit,
29 | change: change(emit),
30 | init: init({ state, service: $service })
31 | }
32 |
33 | watch(
34 | () => props.modelValue,
35 | (newValue) => {
36 | state.selectedValue = newValue
37 | },
38 | { immediate: true }
39 | )
40 |
41 | api.init()
42 |
43 | return api
44 | }
45 |
--------------------------------------------------------------------------------
/src/currency/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { init, fixServiceData, change, initService } from './index'
14 |
15 | export const api = ['state', 'change']
16 |
17 | export const renderless = (props, { watch, reactive }, { service, emit }) => {
18 | const api = {}
19 | const $service = initService({ props, service })
20 |
21 | const state = reactive({
22 | options: [],
23 | selectedValue: props.modelValue
24 | })
25 |
26 | Object.assign(api, {
27 | state,
28 | change: change(emit),
29 | fixServiceData: fixServiceData({ props, service: $service }),
30 | init: init({ state, service: $service, api })
31 | })
32 |
33 | watch(
34 | () => props.modelValue,
35 | (param) => {
36 | state.selectedValue = param
37 | },
38 | { immediate: true }
39 | )
40 |
41 | api.init()
42 |
43 | return api
44 | }
45 |
--------------------------------------------------------------------------------
/src/drop-roles/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { init, change, initService } from './index'
14 |
15 | export const api = ['state', 'change']
16 |
17 | export const renderless = (props, { onMounted, reactive, watch }, { parent, emit, service }) => {
18 | const $service = initService({ props, service })
19 |
20 | const state = reactive({
21 | options: [],
22 | source: null,
23 | selectedValue: props.modelValue,
24 | attrs: parent.$attr
25 | })
26 |
27 | watch(
28 | () => props.modelValue,
29 | (value) => {
30 | state.selectedValue = value
31 | },
32 | { immediate: true }
33 | )
34 |
35 | const api = {
36 | state,
37 | change: change(emit),
38 | init: init({ state, service: $service, emit })
39 | }
40 |
41 | onMounted(api.init)
42 |
43 | return api
44 | }
45 |
--------------------------------------------------------------------------------
/src/drop-times/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { format } from '@opentiny/vue-renderless/common/date'
14 |
15 | export const init = ({ state, props }) => () => {
16 | let list = [],
17 | value
18 |
19 | for (let minutes = props.start; minutes <= props.end; minutes += props.step) {
20 | value = format(new Date(0, 0, 0, 0, minutes, 0), 'hh:mm')
21 |
22 | list.push({
23 | label: value,
24 | value
25 | })
26 | }
27 |
28 | state.options = list
29 | }
30 |
31 | export const change = (emit) => (value) => {
32 | emit('update:modelValue', value)
33 | emit('change', value)
34 | }
35 |
--------------------------------------------------------------------------------
/src/drop-times/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { init, change } from './index'
14 |
15 | export const api = ['state', 'change']
16 |
17 | export const renderless = (props, { onMounted, reactive, watch }, { emit }) => {
18 | const state = reactive({
19 | options: [],
20 | selectedValue: props.modelValue
21 | })
22 |
23 | watch(
24 | () => props.modelValue,
25 | (newValue) => (state.selectedValue = newValue)
26 | )
27 |
28 | const api = {
29 | state,
30 | change: change(emit),
31 | init: init({ state, props, emit })
32 | }
33 |
34 | onMounted(api.init)
35 |
36 | return api
37 | }
38 |
--------------------------------------------------------------------------------
/src/dropdown-menu/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { toggleItem, updateOffset, clickOutside, getScroller, useVuePopper } from './index'
14 |
15 | export const api = ['state', 'toggleItem', 'updateOffset', 'clickOutside', 'doDestroy']
16 |
17 | export const renderless = (props, hooks, instance) => {
18 | const api = {}
19 | const { reactive, provide } = hooks
20 | const { refs, nextTick, mode, vm } = instance
21 | const state = reactive({
22 | offset: 0,
23 | scroller: null,
24 | children: [],
25 | size: '',
26 | showPopper: false
27 | })
28 |
29 | if (mode === 'mobile') {
30 | provide('dropdownMenu', vm)
31 | nextTick(() => {
32 | state.scroller = getScroller(refs.menu)
33 | })
34 | } else {
35 | useVuePopper({ api, hooks, props, instance, state })
36 | }
37 |
38 | Object.assign(api, {
39 | state,
40 | toggleItem: toggleItem(state),
41 | clickOutside: clickOutside({ props, refs, state }),
42 | updateOffset: updateOffset({ props, state, refs })
43 | })
44 |
45 | return api
46 | }
47 |
--------------------------------------------------------------------------------
/src/exception/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const create = (emit) => () => emit('btn-click')
14 |
15 | export const getMessage =
16 | ({ props, t }) =>
17 | () => {
18 | const types = ['build', 'weaknet', 'pcview', 'busy', 'noperm']
19 | return props.message || t(`ui.exception.${~types.indexOf(props.type) ? props.type : 'nodata'}`)
20 | }
21 |
--------------------------------------------------------------------------------
/src/exception/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { create, getMessage } from './index'
14 |
15 | export const api = ['state', 'create']
16 |
17 | export const renderless = (props, { computed, reactive }, { t, emit }) => {
18 | const api = {
19 | create: create(emit),
20 | getMessage: getMessage({ props, t })
21 | }
22 |
23 | const state = reactive({
24 | message: computed(() => api.getMessage({ props, t }))
25 | })
26 |
27 | api.state = state
28 |
29 | return api
30 | }
31 |
--------------------------------------------------------------------------------
/src/floatbar/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { xss } from '@opentiny/vue-renderless/common/xss.js'
14 |
15 | export const computeData = ({ props }) => {
16 | if (Array.isArray(props.data) && props.data.length) {
17 | props.data.forEach((item) => {
18 | item.url = xss.filterUrl(item.url)
19 | })
20 | }
21 |
22 | return props.data
23 | }
24 |
--------------------------------------------------------------------------------
/src/floatbar/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { computeData } from './index'
14 |
15 | export const api = ['state']
16 |
17 | export const renderless = (props, { computed, reactive }) => {
18 | const state = reactive({
19 | data: computed(() => computeData({ props }))
20 | })
21 |
22 | const api = { state }
23 |
24 | return api
25 | }
26 |
--------------------------------------------------------------------------------
/src/grid/core/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import StoreMap from './storeMap'
14 | import Interceptor from './interceptor'
15 |
16 | export { StoreMap, Interceptor }
17 |
--------------------------------------------------------------------------------
/src/grid/static/array/arrayIndexOf.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | const arrayIndexOf = (obj, val) => {
27 | if (obj.indexOf) {
28 | return obj.indexOf(val)
29 | }
30 |
31 | for (let index = 0, len = obj.length; index < len; index++) {
32 | if (val === obj[index]) {
33 | return index
34 | }
35 | }
36 | }
37 |
38 | export default arrayIndexOf
39 |
--------------------------------------------------------------------------------
/src/grid/static/array/every.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import helperCreateIterateHandleFn from './helperCreateIterateHandle'
27 |
28 | export default helperCreateIterateHandleFn('every', 1, 1, false, true)
29 |
--------------------------------------------------------------------------------
/src/grid/static/array/find.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import helperCreateIterateHandle from './helperCreateIterateHandle'
27 |
28 | const find = helperCreateIterateHandle('find', 1, 3, true)
29 |
30 | export default find
31 |
--------------------------------------------------------------------------------
/src/grid/static/array/includes.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import indexOf from '../base/indexOf'
14 |
15 | const includes = (obj, val) => ~indexOf(obj, val)
16 |
17 | export default includes
18 |
--------------------------------------------------------------------------------
/src/grid/static/array/lastArrayEach.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | const lastArrayEach = (obj, iterate, context) => {
27 | for (let len = obj.length - 1; len >= 0; len--) {
28 | iterate.call(context, obj[len], len, obj)
29 | }
30 | }
31 |
32 | export default lastArrayEach
33 |
--------------------------------------------------------------------------------
/src/grid/static/array/slice.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | const slice = (array, startIndex, endIndex) => {
27 | let result = []
28 |
29 | if (array) {
30 | for (startIndex = startIndex || 0, endIndex = endIndex || array.length; startIndex < endIndex; startIndex++) {
31 | result.push(array[startIndex])
32 | }
33 | }
34 |
35 | return result
36 | }
37 |
38 | export default slice
39 |
--------------------------------------------------------------------------------
/src/grid/static/array/toArray.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import map from './map'
27 |
28 | const toArray = (arr) => map(arr, (item) => item)
29 |
30 | export default toArray
31 |
--------------------------------------------------------------------------------
/src/grid/static/base/clone.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import isPlainObject from './isPlainObject'
14 | import objectMap from '../object/objectMap'
15 | import map from '../array/map'
16 |
17 | let deepClone
18 | const startClone = (func, obj, deep) => func(obj, deep ? (val) => deepClone(val, deep) : (val) => val)
19 |
20 | deepClone = (val, deep) => (isPlainObject(val) ? startClone(objectMap, val, deep) : Array.isArray(val) ? startClone(map, val, deep) : val)
21 |
22 | const clone = (obj, deep) => (obj ? deepClone(obj, deep) : obj)
23 |
24 | export default clone
25 |
--------------------------------------------------------------------------------
/src/grid/static/base/each.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import arrayEach from '../array/arrayEach'
27 | import objectEach from '../object/objectEach'
28 |
29 | const each = (obj, iterate, context) => {
30 | if (obj) {
31 | return Array.isArray(obj) ? arrayEach(obj, iterate, context) : objectEach(obj, iterate, context)
32 | }
33 |
34 | return obj
35 | }
36 |
37 | export default each
38 |
--------------------------------------------------------------------------------
/src/grid/static/base/eqNull.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import isNullType from './isNull'
27 | import isUndefinedType from './isUndefined'
28 |
29 | const eqNull = (object) => isNullType(object) || isUndefinedType(object)
30 |
31 | export default eqNull
32 |
--------------------------------------------------------------------------------
/src/grid/static/base/hasOwnProp.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | const hasOwnProp = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key)
14 |
15 | export default hasOwnProp
16 |
--------------------------------------------------------------------------------
/src/grid/static/base/helperCreateInInObjectString.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | let objectToString = Object.prototype.toString
27 |
28 | function helperCreateInInObjectString(type) {
29 | return function (obj) {
30 | return '[object ' + type + ']' === objectToString.call(obj)
31 | }
32 | }
33 |
34 | export default helperCreateInInObjectString
35 |
--------------------------------------------------------------------------------
/src/grid/static/base/helperCreateInTypeof.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | export default function helperCreateInTypeof(type) {
27 | return function (obj) {
28 | return typeof obj === type
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/grid/static/base/helperDefaultCompare.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | function helperDefaultCompare(v1, v2) {
27 | return v1 === v2
28 | }
29 |
30 | export default helperDefaultCompare
31 |
--------------------------------------------------------------------------------
/src/grid/static/base/helperDeleteProperty.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | const helperDeleteProperty = (obj, property) => {
27 | try {
28 | delete obj[property]
29 | } catch (e) {
30 | obj[property] = undefined
31 | }
32 | }
33 |
34 | export default helperDeleteProperty
35 |
--------------------------------------------------------------------------------
/src/grid/static/base/helperGetHGSKeys.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | const helperGetHGSKeys = (property) =>
27 | // 以最快的方式判断数组,可忽略准确性
28 | property ? (property.splice && property.join ? property : String(property).split('.')) : []
29 |
30 | export default helperGetHGSKeys
31 |
--------------------------------------------------------------------------------
/src/grid/static/base/indexOf.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import helperCreateIndexOfFn from './helperCreateIndexOf'
27 | import arrayIndexOfFn from '../array/arrayIndexOf'
28 |
29 | export default helperCreateIndexOfFn('indexOf', arrayIndexOfFn)
30 |
--------------------------------------------------------------------------------
/src/grid/static/base/isArray.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import helperCreateInInObjectString from './helperCreateInInObjectString'
27 |
28 | /**
29 | * 判断是否数组
30 | *
31 | * @param {Object} obj 对象
32 | * @return {Boolean}
33 | */
34 | let isArray = Array.isArray || helperCreateInInObjectString('Array')
35 |
36 | export default isArray
37 |
--------------------------------------------------------------------------------
/src/grid/static/base/isBoolean.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | const isBoolean = (obj) => typeof obj === 'boolean'
27 |
28 | export default isBoolean
29 |
--------------------------------------------------------------------------------
/src/grid/static/base/isDate.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 | import helperCreateInInObjectString from './helperCreateInInObjectString'
26 |
27 | /**
28 | * 判断是否Date对象
29 | *
30 | * @param {Object} obj 对象
31 | * @return {Boolean}
32 | */
33 | let isDate = helperCreateInInObjectString('Date')
34 |
35 | export default isDate
36 |
--------------------------------------------------------------------------------
/src/grid/static/base/isEmpty.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import isObject from './isObject'
14 | const isEmpty = (obj) => {
15 | if (isObject(obj)) {
16 | return Object.keys(obj).length === 0
17 | }
18 | return true
19 | }
20 |
21 | export default isEmpty
22 |
--------------------------------------------------------------------------------
/src/grid/static/base/isEqual.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import helperEqlCompare from './helperEqualCompare'
27 |
28 | const isEqual = (obj1, obj2) =>
29 | helperEqlCompare({
30 | val1: obj1,
31 | val2: obj2,
32 | compare: (v1, v2) => v1 === v2
33 | })
34 |
35 | export default isEqual
36 |
--------------------------------------------------------------------------------
/src/grid/static/base/isFunction.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | const isFunction = (obj) => typeof obj === 'function'
14 |
15 | export default isFunction
16 |
--------------------------------------------------------------------------------
/src/grid/static/base/isNaN.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import isNumber from './isNumber'
27 |
28 | const isNumberNaN = (obj) => isNumber(obj) && isNaN(obj)
29 |
30 | export default isNumberNaN
31 |
--------------------------------------------------------------------------------
/src/grid/static/base/isNull.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | const isNull = (object) => object === null
27 |
28 | export default isNull
29 |
--------------------------------------------------------------------------------
/src/grid/static/base/isNumber.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | const isNumber = (obj) => typeof obj === 'number'
14 |
15 | export default isNumber
16 |
--------------------------------------------------------------------------------
/src/grid/static/base/isObject.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | const isObject = (obj) => typeof obj === 'object' && obj !== null
14 |
15 | export default isObject
16 |
--------------------------------------------------------------------------------
/src/grid/static/base/isPlainObject.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { isPlainObject } from '@opentiny/vue-renderless/common/type'
14 |
15 | export default isPlainObject
16 |
--------------------------------------------------------------------------------
/src/grid/static/base/isRegExp.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import helperCreateInInObjectString from './helperCreateInInObjectString'
27 |
28 | /**
29 | * 判断是否RegExp对象
30 | *
31 | * @param {Object} obj 对象
32 | * @return {Boolean}
33 | */
34 | let isRegExp = helperCreateInInObjectString('RegExp')
35 |
36 | export default isRegExp
37 |
--------------------------------------------------------------------------------
/src/grid/static/base/isSet.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 | const supportSet = typeof Set !== 'undefined'
26 |
27 | const isSet = (obj) => supportSet && obj instanceof Set
28 |
29 | export default isSet
30 |
--------------------------------------------------------------------------------
/src/grid/static/base/isString.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | const isString = (obj) => typeof obj === 'string'
14 |
15 | export default isString
16 |
--------------------------------------------------------------------------------
/src/grid/static/base/isUndefined.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | const isUndefined = (obj) => typeof obj === 'undefined'
14 |
15 | export default isUndefined
16 |
--------------------------------------------------------------------------------
/src/grid/static/base/keys.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import helperCreateGetObjects from './helperCreateGetObjects'
27 |
28 | const keys = helperCreateGetObjects('keys', 1)
29 |
30 | export default keys
31 |
--------------------------------------------------------------------------------
/src/grid/static/base/toJSONString.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | const toJSONString = (obj) => JSON.stringify(obj) || ''
14 |
15 | export default toJSONString
16 |
--------------------------------------------------------------------------------
/src/grid/static/base/uniqueId.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | let __uniqueId = 0
14 |
15 | const uniqueId = (prefix) => (prefix ? String(prefix) : 0) + ++__uniqueId
16 |
17 | export default uniqueId
18 |
--------------------------------------------------------------------------------
/src/grid/static/function/property.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 | import isNull from '../base/isNull'
26 |
27 | const property = (key, defs) => (object) => (isNull(object) ? defs : object[key])
28 |
29 | export default property
30 |
--------------------------------------------------------------------------------
/src/grid/static/number/helperCreateToNumber.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | const helperCreateToNumber = (handle) => (str) => {
27 | if (str) {
28 | let num = handle(str)
29 |
30 | if (!isNaN(num)) {
31 | return num
32 | }
33 | }
34 |
35 | return 0
36 | }
37 |
38 | export default helperCreateToNumber
39 |
--------------------------------------------------------------------------------
/src/grid/static/number/toNumber.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import helperCreateToNumber from './helperCreateToNumber'
27 |
28 | const toNumber = helperCreateToNumber(parseFloat)
29 |
30 | export default toNumber
31 |
--------------------------------------------------------------------------------
/src/grid/static/object/extend.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import assign from './assign'
14 |
15 | const extend = assign
16 |
17 | export default extend
18 |
--------------------------------------------------------------------------------
/src/grid/static/object/lastObjectEach.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import lastArrayEach from '../array/lastArrayEach'
27 | import keys from '../base/keys'
28 |
29 | const lastObjectEach = (obj, iterate, context) => {
30 | lastArrayEach(keys(obj), (key) => {
31 | iterate.call(context, obj[key], key, obj)
32 | })
33 | }
34 |
35 | export default lastObjectEach
36 |
--------------------------------------------------------------------------------
/src/grid/static/object/objectEach.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import hasOwnProp from '../base/hasOwnProp'
27 |
28 | const objectEach = (obj, iterate, context) => {
29 | if (obj) {
30 | Object.keys(obj).forEach((key) => {
31 | if (hasOwnProp(obj, key)) {
32 | iterate.call(context, obj[key], key, obj)
33 | }
34 | })
35 | }
36 | }
37 |
38 | export default objectEach
39 |
--------------------------------------------------------------------------------
/src/grid/static/object/values.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import objectEach from './objectEach'
14 |
15 | const values = (obj, iterator, ctx) => {
16 | const objectValues = []
17 |
18 | objectEach(
19 | obj,
20 | (val) => {
21 | objectValues.push(val)
22 | },
23 | ctx
24 | )
25 |
26 | return objectValues
27 | }
28 |
29 | export default values
30 |
--------------------------------------------------------------------------------
/src/grid/static/static/staticDocument.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import staticStrUndefined from './staticStrUndefined'
27 |
28 | let staticDocument = typeof document === staticStrUndefined ? 0 : document
29 |
30 | export default staticDocument
31 |
--------------------------------------------------------------------------------
/src/grid/static/static/staticHGKeyRE.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | const staticHGKeyRE = /(.+)?\[(\d+)\]$/
27 |
28 | export default staticHGKeyRE
29 |
--------------------------------------------------------------------------------
/src/grid/static/static/staticParseInt.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | let staticParseInt = parseInt
27 |
28 | export default staticParseInt
29 |
--------------------------------------------------------------------------------
/src/grid/static/static/staticStrUndefined.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | let staticStrUndefined = 'undefined'
27 |
28 | export default staticStrUndefined
29 |
--------------------------------------------------------------------------------
/src/grid/static/static/staticWindow.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import staticStrUndefined from './staticStrUndefined'
27 |
28 | let staticWindow = typeof window === staticStrUndefined ? 0 : window
29 |
30 | export default staticWindow
31 |
--------------------------------------------------------------------------------
/src/grid/static/string/template.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2019 Xu Liangzhan
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 |
26 | import toValString from './toString'
27 | import get from '../base/get'
28 |
29 | const template = (str, obj) => {
30 | let rest = toValString(str)
31 |
32 | if (rest && obj) {
33 | return rest.replace(/\{{2}([.\w[\]\s]+)\}{2}/g, (match, keys) => get(obj, keys))
34 | }
35 |
36 | return rest
37 | }
38 |
39 | export default template
40 |
--------------------------------------------------------------------------------
/src/grid/utils/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import GlobalEvent from './event'
14 |
15 | export * from './column'
16 | export * from './common'
17 | export * from './dom'
18 | export { GlobalEvent }
19 |
--------------------------------------------------------------------------------
/src/index-bar-anchor/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import {} from './index'
14 |
15 | export const api = ['state']
16 |
17 | export const renderless = (props, { computed, reactive, onMounted, onUpdated, watch }, { emit, parent, refs }) => {
18 | const state = reactive({})
19 |
20 | const api = {
21 | state
22 | }
23 |
24 | Object.assign(api, {
25 | state
26 | })
27 |
28 | return api
29 | }
30 |
--------------------------------------------------------------------------------
/src/layout/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | // layout renderless
14 |
15 | export const api = []
16 |
17 | export const renderless = () => ({})
18 |
--------------------------------------------------------------------------------
/src/link/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const handleClick = ({ emit, props, state }) => (event) => {
14 | if (!state.disabled && !props.href) {
15 | emit('click', event)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/link/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { handleClick } from './index'
14 |
15 | export const api = ['state', 'handleClick']
16 |
17 | export const renderless = (props, { inject, reactive, computed }, { emit, parent }) => {
18 | parent.tinyForm = parent.tinyForm || inject('form', null)
19 |
20 | const state = reactive({
21 | formDisabled: computed(() => (parent.tinyForm || {}).disabled),
22 | disabled: computed(() => props.disabled || state.formDisabled)
23 | })
24 |
25 | return {
26 | state,
27 | handleClick: handleClick({ emit, props, state })
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/list/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const clickList = ({ emit, props }) => () => {
14 | const list = {
15 | id: props.id,
16 | content: props.content,
17 | subtext: props.subText,
18 | contentdes: props.contentDes
19 | }
20 |
21 | emit('click', list)
22 | }
23 |
--------------------------------------------------------------------------------
/src/list/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { clickList } from './index'
14 |
15 | export const api = ['state', 'clickList']
16 |
17 | export const renderless = (props, { reactive }, { emit }) => {
18 | const state = reactive({
19 | test: '1'
20 | })
21 |
22 | const api = {
23 | state,
24 | clickList: clickList({ emit, props })
25 | }
26 |
27 | return api
28 | }
29 |
--------------------------------------------------------------------------------
/src/loading/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import afterLeave from '@opentiny/vue-renderless/common/deps/after-leave'
14 | import { removeClass } from '@opentiny/vue-renderless/common/deps/dom'
15 |
16 | export const handleAfterLeave = (emit) => () => {
17 | emit('after-leave')
18 | }
19 |
20 | export const setText = (state) => (text) => {
21 | state.text = text
22 | }
23 |
24 | export const close = ({ state, constants, vm }) => () => {
25 | afterLeave(
26 | vm,
27 | () => {
28 | const target = state.fullscreen || state.body ? document.body : state.target
29 |
30 | removeClass(target, constants.PARENT_RELATIVE_CLS)
31 | removeClass(target, constants.PARENT_HIDDEN_CLS)
32 |
33 | if (vm.$el && vm.$el.parentNode) {
34 | vm.$el.parentNode.removeChild(vm.$el)
35 | }
36 |
37 | state.closed = true
38 | },
39 | 300
40 | )
41 |
42 | state.visible = false
43 | }
44 |
--------------------------------------------------------------------------------
/src/loading/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { handleAfterLeave, setText, close } from './index'
14 |
15 | export const api = ['state', 'handleAfterLeave', 'setText', 'close']
16 |
17 | export const renderless = (props, { reactive }, { constants, vm, emit }) => {
18 | const state = reactive({
19 | text: null,
20 | spinner: null,
21 | visible: false,
22 | customClass: '',
23 | background: null,
24 | fullscreen: true,
25 | closed: false
26 | })
27 |
28 | const api = {
29 | state,
30 | setText: setText(state),
31 | handleAfterLeave: handleAfterLeave(emit),
32 | close: close({ state, constants, vm })
33 | }
34 |
35 | return api
36 | }
37 |
--------------------------------------------------------------------------------
/src/locales/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { getLocales, setText, switchLanguage, initService, changeLocale } from './index'
14 |
15 | export const api = ['state', 'switchLanguage', 't', 'changeLocale']
16 |
17 | export const renderless = (props, { reactive, watch }, { t, service }, vnode) => {
18 | const api = {}
19 | const $service = initService({ props, service })
20 |
21 | const state = reactive({
22 | current: '',
23 | locales: [],
24 | visible: false,
25 | text: ''
26 | })
27 |
28 | Object.assign(api, {
29 | t,
30 | state,
31 | setText: setText(state),
32 | changeLocale: changeLocale({ props, service: $service, vnode }),
33 | switchLanguage: switchLanguage({ api, service: $service, state }),
34 | getLocales: getLocales({ api, service: $service, state })
35 | })
36 |
37 | api.getLocales()
38 |
39 | watch(() => state.current, api.changeLocale, { immediate: true })
40 |
41 | return api
42 | }
43 |
--------------------------------------------------------------------------------
/src/logon-user/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const init = ({ service, state }) => () => {
14 | const { getUserInfo } = service
15 |
16 | getUserInfo().then((user) => {
17 | state.userName = user.userCN
18 | })
19 | }
20 |
21 | export const initService = ({ props, service }) => {
22 | const { base = {} } = service || {}
23 |
24 | const getUserInfoNoop = () => Promise.reject(new Error('[TINY Error][LogonUser] Prop getUserInfo is not configured'))
25 |
26 | return {
27 | getUserInfo: props.getUserInfo || base.getUserInfo || getUserInfoNoop
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/logon-user/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { init, initService } from './index'
14 |
15 | export const api = ['state']
16 |
17 | export const renderless = (props, { reactive }, { service }) => {
18 | const $service = initService({ props, service })
19 |
20 | const state = reactive({
21 | userName: ''
22 | })
23 |
24 | const api = {
25 | state,
26 | init: init({ service: $service, state })
27 | }
28 |
29 | api.init()
30 |
31 | return api
32 | }
33 |
--------------------------------------------------------------------------------
/src/logout/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { logout, initService } from './index'
14 |
15 | export const api = ['state', 'logout']
16 |
17 | export const renderless = (props, { reactive }, { service }) => {
18 | const $service = initService({ props, service })
19 |
20 | const state = reactive({
21 | logout: $service.isGuestUser()
22 | })
23 |
24 | const api = {
25 | state,
26 | logout: logout({ service: $service, state, props })
27 | }
28 |
29 | return api
30 | }
31 |
--------------------------------------------------------------------------------
/src/milestone/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { handleClick, flagOprate, getMileIcon, getMileContent, getLineColor, handleFlagClick } from './index'
14 |
15 | export const api = [
16 | 'state',
17 | 'showTip',
18 | 'handleClick',
19 | 'handleFlagClick',
20 | 'flagOprate',
21 | 'getMileIcon',
22 | 'getMileContent',
23 | 'getMileFlagStyle',
24 | 'getLineColor',
25 | 'getStatus'
26 | ]
27 |
28 | export const renderless = (props, { reactive }, { emit, refs, constants }) => {
29 | const state = reactive({
30 | tipContent: ''
31 | })
32 |
33 | const api = {
34 | state,
35 | getLineColor: getLineColor(props),
36 | getMileContent: getMileContent(props),
37 | handleFlagClick: handleFlagClick(emit),
38 | handleClick: handleClick({ emit, state }),
39 | getMileIcon: getMileIcon({ constants, props }),
40 | flagOprate: flagOprate({ constants, refs, state })
41 | }
42 |
43 | return api
44 | }
45 |
--------------------------------------------------------------------------------
/src/option-group/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const queryChange = ({ select, state, vm }) => () => {
14 | state.visible = true
15 |
16 | if (Array.isArray(select.state.options)) {
17 | const groupOptions = select.state.options.filter((option) => option.state.parent && vm && option.state.parent.label === vm.label)
18 |
19 | if (Array.isArray(groupOptions)) {
20 | state.visible = groupOptions.some((option) => option.visible === true)
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/option-group/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { queryChange } from './index'
14 |
15 | export const api = ['state', 'queryChange']
16 |
17 | export const renderless = (props, { onMounted, reactive, watch, inject }, { broadcast, vm }) => {
18 | const select = inject('select')
19 | const constants = select._constants
20 |
21 | const state = reactive({
22 | visible: true
23 | })
24 |
25 | const api = {
26 | state,
27 | queryChange: queryChange({ select, state, vm })
28 | }
29 |
30 | watch(
31 | () => props.disabled,
32 | (value) => {
33 | broadcast(constants.COMPONENT_NAME.Option, constants.EVENT_NAME.handleGroupDisabled, value)
34 | },
35 | { immediate: true }
36 | )
37 |
38 | onMounted(() => {
39 | if (props.disabled) {
40 | broadcast(constants.COMPONENT_NAME.Option, constants.EVENT_NAME.handleGroupDisabled, props.disabled)
41 | }
42 |
43 | select.state.selectEmitter.on(constants.EVENT_NAME.queryChange, api.queryChange)
44 | })
45 |
46 | return api
47 | }
48 |
--------------------------------------------------------------------------------
/src/panel/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { emitEvent } from '@opentiny/vue-renderless/common/event'
14 |
15 | export const toggle = ({ api, state }) => () => {
16 | state.isShow ? api.collapse() : api.expand()
17 | }
18 |
19 | export const expand = ({ emit, state }) => () => {
20 | if (!emitEvent(emit, 'before-expand')) {
21 | return
22 | }
23 |
24 | state.isShow = true
25 |
26 | emit('expand', true)
27 | }
28 |
29 | export const collapse = ({ emit, state }) => () => {
30 | if (!emitEvent(emit, 'before-collapse')) {
31 | return
32 | }
33 |
34 | state.isShow = false
35 |
36 | emit('collapse', false)
37 | }
38 |
--------------------------------------------------------------------------------
/src/panel/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { collapse, expand, toggle } from './index'
14 |
15 | export const api = ['state', 'toggle']
16 |
17 | export const renderless = (props, { reactive }, { emit }) => {
18 | const api = {}
19 | const state = reactive({
20 | isShow: props.expand
21 | })
22 |
23 | Object.assign(api, {
24 | state,
25 | collapse: collapse({ emit, state }),
26 | expand: expand({ emit, state }),
27 | toggle: toggle({ api, state })
28 | })
29 |
30 | return api
31 | }
32 |
--------------------------------------------------------------------------------
/src/radio-group/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { handleKeydown, mounted } from './index'
14 |
15 | export const api = ['state', 'handleKeydown']
16 |
17 | export const renderless = (props, { computed, onMounted, reactive, watch }, { parent, dispatch }) => {
18 | const state = reactive({
19 | radioGroupSize: computed(() => props.size),
20 | tag: 'div'
21 | })
22 |
23 | parent.$on('handleChange', (value) => {
24 | parent.$emit('change', value)
25 | })
26 |
27 | const api = {
28 | state,
29 | dispatch,
30 | onMounted: mounted(parent),
31 | handleKeydown: handleKeydown({ parent })
32 | }
33 |
34 | watch(
35 | () => props.modelValue,
36 | (value) => {
37 | api.dispatch('FormItem', 'form.change', [value])
38 | }
39 | )
40 |
41 | onMounted(api.onMounted)
42 |
43 | return api
44 | }
45 |
--------------------------------------------------------------------------------
/src/roles/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { showList, show, hide, getRoleList, changeRole, initService } from './index'
14 |
15 | export const api = ['state', 'showList', 'show', 'hide', 'changeRole']
16 |
17 | export const renderless = (props, { computed, reactive }, { emit, service, constants }) => {
18 | const $service = initService(service)
19 | let api = {}
20 |
21 | const state = reactive({
22 | currentRole: '',
23 | currentId: '',
24 | showPopover: true,
25 | showIcon: true,
26 | roleList: computed(() => api.getRoleList())
27 | })
28 |
29 | api = {
30 | state,
31 | show: show(state),
32 | hide: hide(state),
33 | showList: showList(state),
34 | getRoleList: getRoleList({ constants, service: $service, state }),
35 | changeRole: changeRole({ constants, emit, props, service: $service, state })
36 | }
37 |
38 | return api
39 | }
40 |
--------------------------------------------------------------------------------
/src/row/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const computedClassName = ({ flex, justify, align }) => {
14 | const className = []
15 |
16 | if (flex) {
17 | className.push('row-flex')
18 | className.push(`row-justify-${justify}`)
19 | className.push(`row-align-${align}`)
20 | }
21 |
22 | return className.join(' ')
23 | }
24 |
25 | export const computedStyle = (gutter) => {
26 | const value = gutter ? -(gutter / 2) : 0
27 |
28 | return value ? { marginLeft: value + 'px', marginRight: value + 'px' } : {}
29 | }
30 |
--------------------------------------------------------------------------------
/src/row/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { computedClassName, computedStyle } from './index'
14 |
15 | export const api = ['state']
16 |
17 | export const renderless = (props, { computed, reactive }) => {
18 | const api = {
19 | computedStyle,
20 | computedClassName
21 | }
22 |
23 | const state = reactive({
24 | style: computed(() => api.computedStyle(props.gutter)),
25 | className: computed(() =>
26 | api.computedClassName({
27 | flex: props.flex,
28 | justify: props.justify,
29 | align: props.align
30 | })
31 | )
32 | })
33 |
34 | api.state = state
35 |
36 | return api
37 | }
38 |
--------------------------------------------------------------------------------
/src/scroll-text/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const computedBindStyle = ({ constants, time }) => ({
14 | [constants.ANIMATION_DURATION]: parseInt(time, 10) + 's'
15 | })
16 |
17 | export const stopAnimation = ({ props, state }) => () => {
18 | if (props.hoverStop) {
19 | state.isStop = true
20 | }
21 | }
22 |
23 | export const startAnimation = ({ props, state }) => () => {
24 | if (props.hoverStop) {
25 | state.isStop = false
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/scroll-text/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { computedBindStyle, stopAnimation, startAnimation } from './index'
14 |
15 | export const api = ['state', 'startAnimation', 'stopAnimation']
16 |
17 | export const renderless = (props, { computed, reactive }, { constants }) => {
18 | const api = {
19 | computedBindStyle
20 | }
21 |
22 | const state = reactive({
23 | isStop: false,
24 | bindStyle: computed(() => api.computedBindStyle({ constants, time: props.time }))
25 | })
26 |
27 | Object.assign(api, {
28 | state,
29 | startAnimation: startAnimation({ props, state }),
30 | stopAnimation: stopAnimation({ props, state })
31 | })
32 |
33 | return api
34 | }
35 |
--------------------------------------------------------------------------------
/src/scrollbar/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { handleScroll, update } from './index'
14 | import { addResizeListener, removeResizeListener } from '@opentiny/vue-renderless/common/deps/resize-event'
15 |
16 | export const api = ['state', 'update', 'handleScroll']
17 |
18 | export const renderless = (props, { onBeforeUnmount, onMounted, reactive }, { refs, nextTick, emit }) => {
19 | const state = reactive({
20 | sizeWidth: '0',
21 | sizeHeight: '0',
22 | moveX: 0,
23 | moveY: 0
24 | })
25 |
26 | const api = {
27 | state,
28 | update: update({ refs, state }),
29 | handleScroll: handleScroll({ refs, state, emit })
30 | }
31 |
32 | onMounted(() => {
33 | if (props.native) {
34 | return
35 | }
36 |
37 | nextTick(api.update)
38 |
39 | !props.noresize && addResizeListener(refs.resize, api.update)
40 | })
41 |
42 | onBeforeUnmount(() => {
43 | if (props.native) {
44 | return
45 | }
46 |
47 | !props.noresize && removeResizeListener(refs.resize, api.update)
48 | })
49 |
50 | return api
51 | }
52 |
--------------------------------------------------------------------------------
/src/select-dropdown/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const mounted = ({ selectEmitter, constants, state, selectVm, updatePopper, destroyPopper, parent }) => () => {
14 | selectEmitter.on(constants.EVENT_NAME.updatePopper, (keepZIndex) => {
15 | let hideDrop = false
16 |
17 | if (!state.referenceElm || state.referenceElm.nodeType !== 1) {
18 | // 触发源如果是用户传递的插槽,则赋值为外侧div
19 | state.referenceElm = selectVm.$refs.reference ? selectVm.$refs.reference.$el : selectVm.$refs.select
20 | selectVm.popperElm = selectVm.state.popperElm = state.popperElm = parent.$el
21 | }
22 |
23 | if (parent.select.state.visible && !hideDrop) {
24 | updatePopper(keepZIndex)
25 | hideDrop = true
26 | }
27 | })
28 |
29 | selectEmitter.on(constants.EVENT_NAME.destroyPopper, destroyPopper)
30 | }
31 |
--------------------------------------------------------------------------------
/src/slide-bar/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { leftClick, rightClick, blockClick, changeState, changeSize, mouseEvent } from './index'
14 |
15 | export const api = ['state', 'mouseEvent', 'rightClick', 'leftClick', 'blockClick']
16 |
17 | export const renderless = (props, { onMounted, reactive }, { refs, parent, emit }) => {
18 | const api = {}
19 | const state = reactive({
20 | leftLength: 0,
21 | blockWidth: 0,
22 | blockMargin: 0,
23 | showLeft: false,
24 | showRight: false,
25 | blockWrapper: 0,
26 | wrapperWidth: 0,
27 | currentIndex: -1,
28 | offsetWidth: 0
29 | })
30 |
31 | Object.assign(api, {
32 | state,
33 | blockClick: blockClick({ emit, state }),
34 | changeState: changeState({ props, state }),
35 | changeSize: changeSize({ props, refs, state }),
36 | leftClick: leftClick({ api, props, refs, state }),
37 | mouseEvent: mouseEvent({ api, props, refs, state }),
38 | rightClick: rightClick({ api, parent, props, refs, state })
39 | })
40 |
41 | onMounted(api.changeSize)
42 |
43 | return api
44 | }
45 |
--------------------------------------------------------------------------------
/src/steps/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const api = []
14 |
15 | export const renderless = function () {
16 | return {}
17 | }
18 |
--------------------------------------------------------------------------------
/src/tab-bar/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 | import { computedBarStyle } from './index'
13 |
14 | export const api = ['state', 'computedBarStyle']
15 |
16 | export const renderless = (props, { inject, reactive }, { parent }) => {
17 | const state = reactive({
18 | rootTabs: inject('rootTabs'),
19 | barStyle: {}
20 | })
21 |
22 | const api = {
23 | state,
24 | computedBarStyle: computedBarStyle(parent)
25 | }
26 |
27 | return api
28 | }
29 |
--------------------------------------------------------------------------------
/src/tab-dropdown/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const handleClick = (state) => (name) => {
14 | state.rootTabs.setCurrentName(name)
15 | state.hide = true
16 | }
17 |
18 | export const setDropdownTabs = (state) => (data) => {
19 | state.dropdownTabs = data
20 | }
21 |
--------------------------------------------------------------------------------
/src/tab-dropdown/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { handleClick, setDropdownTabs } from './index'
14 |
15 | export const api = ['state', 'handleClick', ' setDropdownTabs']
16 |
17 | export const renderless = (props, { inject, reactive }) => {
18 | const state = reactive({
19 | hide: true,
20 | dropdownTabs: props.tabs || [],
21 | rootTabs: inject('rootTabs')
22 | })
23 |
24 | const api = {
25 | state,
26 | handleClick: handleClick(state),
27 | setDropdownTabs: setDropdownTabs(state)
28 | }
29 |
30 | return api
31 | }
32 |
--------------------------------------------------------------------------------
/src/tab-item/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const computedIsClosable = ({ parent, props }) => () => props.withClose || parent.withClose
14 |
15 | export const computedActive = ({ parent, nextTick, props, state }) => () => {
16 | const active = parent.state.currentName === (props.name || state.index)
17 |
18 | if (active) {
19 | state.loaded = true
20 |
21 | nextTick(() => {
22 | state.animateShow = true
23 | })
24 | } else {
25 | state.animateShow = false
26 | }
27 |
28 | return active
29 | }
30 |
31 | export const computedPaneName = ({ props, state }) => () => props.name || state.index
32 |
33 | export const watchTitle = (parent) => () => parent.$emit('tab-nav-update')
34 |
--------------------------------------------------------------------------------
/src/tab-item/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { computedIsClosable, computedActive, computedPaneName, watchTitle } from './index'
14 |
15 | export const api = ['state']
16 |
17 | export const renderless = (props, { computed, inject, reactive, watch }, { parent, nextTick }) => {
18 | const api = {
19 | watchTitle: watchTitle(parent),
20 | computedIsClosable: computedIsClosable({ parent, props })
21 | }
22 |
23 | const state = reactive({
24 | index: null,
25 | loaded: false,
26 | animateShow: true,
27 | rootTabs: inject('rootTabs'),
28 | active: computed(() => api.computedActive()),
29 | paneName: computed(() => api.computedPaneName()),
30 | isClosable: computed(() => api.computedIsClosable())
31 | })
32 |
33 | Object.assign(api, {
34 | state,
35 | computedActive: computedActive({ parent, nextTick, props, state }),
36 | computedPaneName: computedPaneName({ props, state })
37 | })
38 |
39 | watch(() => props.title, api.watchTitle)
40 |
41 | return api
42 | }
43 |
--------------------------------------------------------------------------------
/src/tabbar/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const setActiveItem = ({ props, state }) => () => {
14 | state.children.forEach((item, index) => {
15 | item.state ? (item.state.index = index) : (item.index = index)
16 | item.state && (item.state.active = (item.name || index) === props.modelValue)
17 | })
18 | }
19 |
20 | export const onChange = ({ emit, props }) => (active) => {
21 | if (active !== props.modelValue) {
22 | emit('update:modelValue', active)
23 | emit('change', active)
24 | }
25 | }
26 |
27 | export const getChildrens = ({ childrenHandler }) => () => {
28 | const $children = []
29 |
30 | childrenHandler(({ options, vm }) => {
31 | options.componentName === 'TinyTabbarItem' && $children.push(vm)
32 | })
33 |
34 | return $children
35 | }
36 |
--------------------------------------------------------------------------------
/src/tag/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const handleClose = ({ emit, props }) => (event) => {
14 | event.stopPropagation()
15 |
16 | const close = () => emit('close', event)
17 | props.beforeDelete ? props.beforeDelete(close) : close()
18 | }
19 |
20 | export const handleClick = ({ emit, parent }) => (event) => {
21 | parent.$parent && parent.$parent.tagSelectable && event.stopPropagation()
22 | emit('click', event)
23 | }
24 |
--------------------------------------------------------------------------------
/src/tag/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { handleClose, handleClick } from './index'
14 |
15 | export const api = ['handleClose', 'handleClick']
16 |
17 | export const renderless = (props, hooks, { emit, parent }) => ({
18 | handleClose: handleClose({ emit, props }),
19 | handleClick: handleClick({ emit, parent })
20 | })
21 |
--------------------------------------------------------------------------------
/src/tall-storage/vue-storage-box.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { addMemory, searchMemory, selectedMemory } from './index'
14 |
15 | export default ({ api, props, reactive, toRefs }) => {
16 | const state = reactive({
17 | storageData: [],
18 | isMemoryStorage: false
19 | })
20 |
21 | return {
22 | ...toRefs(state),
23 | addMemory: addMemory(props),
24 | searchMemory: searchMemory({ props, state }),
25 | selectedMemory: selectedMemory({ api, state })
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/tall-storage/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { mousedown, selectItem, keydown } from './index'
14 | import { on, off } from '@opentiny/vue-renderless/common/deps/dom'
15 |
16 | export const api = ['state', 'mousedown', 'selectItem']
17 |
18 | export const renderless = (props, { onUnmounted, reactive, watch }, { emit }) => {
19 | const state = reactive({
20 | hoverValue: ''
21 | })
22 |
23 | const api = {
24 | state,
25 | mousedown,
26 | selectItem: selectItem({ emit, state }),
27 | keydown: keydown({ emit, props, state })
28 | }
29 |
30 | watch(
31 | () => props.isMemoryStorage,
32 | (value) => !value && (state.hoverValue = ''),
33 | { immediate: true }
34 | )
35 |
36 | onUnmounted(() => {
37 | state.hoverValue = ''
38 | off(document, 'keydown', api.keydown)
39 | })
40 |
41 | on(document, 'keydown', api.keydown)
42 |
43 | return api
44 | }
45 |
--------------------------------------------------------------------------------
/src/text-popup/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { computedWidth, watchValue, mounted, onFocus, onBlur, onInput, separteText, jointText } from './index'
14 |
15 | export const api = ['state', 'onFocus', 'onBlur', 'onInput']
16 |
17 | export const renderless = (props, { computed, onMounted, reactive, watch }, { emit, nextTick, refs }) => {
18 | const api = {}
19 | const state = reactive({
20 | type: 'input',
21 | textAreaValue: '',
22 | text: null,
23 | popup: null,
24 | width: computed(() => api.computedWidth())
25 | })
26 |
27 | Object.assign(api, {
28 | state,
29 | jointText,
30 | separteText,
31 | computedWidth: computedWidth({ props }),
32 | mounted: mounted({ props, refs, state }),
33 | onInput: onInput({ api, emit, props }),
34 | watchValue: watchValue({ api, props, state }),
35 | onBlur: onBlur({ api, emit, props, state }),
36 | onFocus: onFocus({ api, emit, props, nextTick, state })
37 | })
38 |
39 | watch(() => props.modelValue, api.watchValue, { immediate: true })
40 |
41 | onMounted(api.mounted)
42 |
43 | return api
44 | }
45 |
--------------------------------------------------------------------------------
/src/time-line/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { handleClick, getStatusCls, getStatus, computedData, getDate, computedCurrent, computedIsReverse } from './index'
14 |
15 | export const api = ['state', 'handleClick', 'getStatusCls', 'getStatus', 'getDate']
16 |
17 | export const renderless = (props, { computed, reactive }, { t, emit, constants }) => {
18 | const api = {}
19 | const state = reactive({
20 | nodes: computed(() => api.computedData()),
21 | current: computed(() => api.computedCurrent()),
22 | isReverse: computed(() => api.computedIsReverse())
23 | })
24 |
25 | Object.assign(api, {
26 | state,
27 | getDate,
28 | computedData: computedData({ props, state }),
29 | computedCurrent: computedCurrent({ props, state }),
30 | computedIsReverse: computedIsReverse(props),
31 | getStatus: getStatus({ state, t }),
32 | handleClick: handleClick({ emit, state, api }),
33 | getStatusCls: getStatusCls({ constants, props, state })
34 | })
35 |
36 | return api
37 | }
38 |
--------------------------------------------------------------------------------
/src/time-panel/scrollIntoView.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export default (container, selected) => {
14 | if (!selected) {
15 | container.scrollTop = 0
16 | return
17 | }
18 |
19 | const offsetParents = []
20 | let pointer = selected.offsetParent
21 |
22 | while (pointer && container !== pointer && container.contains(pointer)) {
23 | offsetParents.push(pointer)
24 | pointer = pointer.offsetParent
25 | }
26 |
27 | const top = selected.offsetTop + offsetParents.reduce((prev, curr) => prev + curr.offsetTop, 0)
28 | const bottom = top + selected.offsetHeight
29 | const viewRectTop = container.scrollTop
30 | const viewRectBottom = viewRectTop + container.clientHeight
31 |
32 | if (top < viewRectTop) {
33 | container.scrollTop = top
34 | } else if (bottom > viewRectBottom) {
35 | container.scrollTop = bottom - container.clientHeight
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/upload-dragger/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { onDragOver, onDrop } from './index'
14 |
15 | export const api = ['state', 'onDragOver', 'onDrop']
16 |
17 | export const renderless = (props, { inject, reactive, ref }, { emit }) => {
18 | const state = reactive({
19 | dragover: false,
20 | uploader: inject('uploader') || ref({ default: '' })
21 | })
22 |
23 | const api = {
24 | state,
25 | onDragOver: onDragOver({ props, state }),
26 | onDrop: onDrop({ emit, props, state })
27 | }
28 |
29 | return api
30 | }
31 |
--------------------------------------------------------------------------------
/src/user-account/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const init = ({ service, state }) => () => {
14 | const { getUserInfo, getUserImageUrl, getLangData } = service
15 |
16 | getLangData().then((langData) => {
17 | getUserInfo().then((user) => {
18 | getUserImageUrl(user.employeeNumber).then((url) => {
19 | const { locale = 'zhCN' } = langData
20 | const { displayNameCn, displayNameEn, userCN } = user
21 | const displayName = locale === 'zhCN' ? displayNameCn || userCN : displayNameEn || userCN
22 |
23 | state.imgUrl = url
24 | state.userName = displayName
25 | })
26 | })
27 | })
28 | }
29 |
--------------------------------------------------------------------------------
/src/user-account/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { initService } from '@opentiny/vue-renderless/user'
14 | import { init } from './index'
15 |
16 | export const api = ['state']
17 |
18 | export const renderless = (props, { reactive }, { service }) => {
19 | const $service = initService({ props, service })
20 |
21 | const state = reactive({
22 | imgUrl: '',
23 | userName: '',
24 | roleNumber: ''
25 | })
26 |
27 | const api = {
28 | state,
29 | init: init({ service: $service, state })
30 | }
31 |
32 | api.init()
33 |
34 | return api
35 | }
36 |
--------------------------------------------------------------------------------
/src/user-contact/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const getUserHref = ({ props }) => () => {
14 | let href = 'javascript:;'
15 |
16 | if (!props.isNewImMode) {
17 | href = 'javascript:;'
18 | }
19 |
20 | return href
21 | }
22 |
--------------------------------------------------------------------------------
/src/user-contact/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { getUserHref } from './index'
14 |
15 | export const api = ['show', 'getUserHref']
16 |
17 | export const renderless = (props, { reactive, ref }) => {
18 | const state = reactive({
19 | initialized: false
20 | })
21 |
22 | const api = {
23 | state,
24 | show: ref(false)
25 | }
26 |
27 | Object.assign(api, {
28 | getUserHref: getUserHref({ api, props })
29 | })
30 |
31 | return api
32 | }
33 |
--------------------------------------------------------------------------------
/src/user-head/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { computedMessage, computedStyle, computedFontSize, computedLabel, getInternalValue, computedSize } from './index'
14 |
15 | export const api = ['state']
16 |
17 | export const renderless = (props, { reactive, computed }) => {
18 | const api = {
19 | computedMessage: computedMessage(props),
20 | getInternalValue: getInternalValue(props)
21 | }
22 | const state = reactive({
23 | internalValue: computed(() => api.getInternalValue()),
24 | label: computed(() => api.computedLabel()),
25 | style: computed(() => api.computedStyle()),
26 | message: computed(() => api.computedMessage()),
27 | fontSize: computed(() => api.computedFontSize()),
28 | size: computed(() => api.computedSize())
29 | })
30 |
31 | Object.assign(api, {
32 | state,
33 | computedLabel: computedLabel({ state, props }),
34 | computedStyle: computedStyle({ state, props }),
35 | computedFontSize: computedFontSize({ props, state }),
36 | computedSize: computedSize({ props, state })
37 | })
38 |
39 | return api
40 | }
41 |
--------------------------------------------------------------------------------
/src/user-link/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | export const initUser = ({ api, props, state }) => (value) => {
14 | if (!value) {
15 | state.user = value
16 | return
17 | }
18 |
19 | api.getUsers(value).then((info) => {
20 | // 按value排序
21 | info.sort((a, b) => (value.indexOf(String(a[props.valueField])) > value.indexOf(String(b[props.valueField])) ? 1 : -1))
22 |
23 | const list = info.map((user) => user[props.valueField])
24 |
25 | state.options = info
26 | state.user = props.multiple ? list : list[0]
27 | props.cache && api.cacheUser(info)
28 | })
29 | }
30 |
31 | export const showCard = ({ api, service, state }) => (user) => {
32 | state.spinner = true
33 | state.expand = false
34 |
35 | service.fetchUser(user.employeeNumber).then((data) => {
36 | state.data = data
37 | state.spinner = false
38 | })
39 |
40 | api.getUserImageUrl(user.employeeNumber).then((url) => {
41 | state.imgUrl = url
42 | })
43 | }
44 |
45 | export const showDetail = (state) => () => {
46 | state.expand = !state.expand
47 | }
48 |
--------------------------------------------------------------------------------
/src/year-table/vue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 - present TinyVue Authors.
3 | * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
4 | *
5 | * Use of this source code is governed by an MIT-style license.
6 | *
7 | * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8 | * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9 | * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10 | *
11 | */
12 |
13 | import { getCellStyle, handleYearTableClick } from './index'
14 |
15 | export const api = ['state', 'handleYearTableClick', 'getCellStyle']
16 |
17 | export const renderless = (props, { computed, reactive }, { emit }) => {
18 | const api = {}
19 | const state = reactive({
20 | startYear: computed(() => Math.floor(props.date.getFullYear() / 10) * 10)
21 | })
22 |
23 | Object.assign(api, {
24 | state,
25 | getCellStyle: getCellStyle({ props }),
26 | handleYearTableClick: handleYearTableClick({ emit })
27 | })
28 |
29 | return api
30 | }
31 |
--------------------------------------------------------------------------------