@idooel/components 0.0.2 → 0.0.3-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -98
- package/dist/@idooel/components.esm.js +8527 -7070
- package/dist/@idooel/components.umd.js +8569 -7114
- package/jsconfig.json +7 -7
- package/package.json +65 -50
- package/packages/alert/index.js +4 -4
- package/packages/alert/src/index.vue +45 -45
- package/packages/batch-export/index.js +4 -4
- package/packages/batch-export/src/index.vue +104 -104
- package/packages/business-components/modal-fsm/index.js +4 -4
- package/packages/business-components/modal-fsm/src/index.vue +163 -163
- package/packages/business-components/modal-import/index.js +4 -4
- package/packages/business-components/modal-import/src/index.vue +222 -139
- package/packages/business-components/modal-timeline/index.js +4 -4
- package/packages/business-components/modal-timeline/src/index.vue +77 -77
- package/packages/business-components/tabs-sub-center/index.js +4 -4
- package/packages/business-components/tabs-sub-center/src/index.vue +116 -116
- package/packages/button/index.js +4 -4
- package/packages/button/src/index.vue +65 -65
- package/packages/checkbox/index.js +4 -4
- package/packages/checkbox/src/index.vue +52 -52
- package/packages/composite-components/button-group/index.js +4 -4
- package/packages/composite-components/button-group/src/index.vue +151 -151
- package/packages/composite-components/form-attachment/src/index.vue +14 -14
- package/packages/composite-components/form-img-crop/index.js +4 -4
- package/packages/composite-components/form-img-crop/src/index.vue +131 -120
- package/packages/composite-components/modal-confirm/index.js +4 -4
- package/packages/composite-components/modal-confirm/src/index.vue +103 -103
- package/packages/composite-components/modal-form/index.js +4 -4
- package/packages/composite-components/modal-form/src/index.vue +230 -230
- package/packages/composite-components/modal-img-crop/index.js +4 -4
- package/packages/composite-components/modal-img-crop/src/index.vue +298 -298
- package/packages/composite-components/modal-table/index.js +4 -4
- package/packages/composite-components/modal-table/src/index.vue +150 -155
- package/packages/composite-components/modal-tree/index.js +4 -4
- package/packages/composite-components/modal-tree/src/index.vue +75 -75
- package/packages/composite-components/search-area/index.js +4 -4
- package/packages/composite-components/search-area/src/index.vue +239 -237
- package/packages/composite-components/search-area/src/label.vue +35 -35
- package/packages/composite-components/select-entity-modal-table/index.js +4 -4
- package/packages/composite-components/select-entity-modal-table/src/index.vue +171 -171
- package/packages/date/index.js +4 -4
- package/packages/date/src/index.vue +112 -112
- package/packages/date-range/index.js +4 -4
- package/packages/date-range/src/index.vue +47 -47
- package/packages/form/index.js +4 -4
- package/packages/form/src/index.vue +393 -318
- package/packages/icon/index.js +4 -4
- package/packages/icon/src/index.vue +31 -31
- package/packages/index.js +162 -153
- package/packages/input/index.js +4 -4
- package/packages/input/src/index.vue +35 -35
- package/packages/input-number/index.js +4 -4
- package/packages/input-number/src/index.vue +23 -23
- package/packages/loading/index.js +4 -4
- package/packages/loading/src/index.vue +36 -36
- package/packages/meta/provider.js +4 -0
- package/packages/modal/index.js +4 -4
- package/packages/modal/src/index.vue +184 -184
- package/packages/models/form-group-model/index.js +4 -4
- package/packages/models/form-group-model/src/index.vue +271 -273
- package/packages/models/form-model/index.js +4 -4
- package/packages/models/form-model/src/index.vue +353 -232
- package/packages/models/step-model/index.js +4 -4
- package/packages/models/step-model/src/index.vue +224 -224
- package/packages/models/tree-table-model/index.js +4 -4
- package/packages/models/tree-table-model/src/index.vue +1376 -689
- package/packages/pagination/index.js +5 -0
- package/packages/pagination/src/index.vue +372 -0
- package/packages/radio/index.js +4 -4
- package/packages/radio/src/index.vue +56 -56
- package/packages/select/index.js +4 -4
- package/packages/select/src/index.vue +113 -105
- package/packages/select-entity/index.js +4 -4
- package/packages/select-entity/src/index.vue +119 -119
- package/packages/table/index.js +4 -4
- package/packages/table/src/action.vue +176 -172
- package/packages/table/src/index.vue +604 -289
- package/packages/tabs/index.js +4 -4
- package/packages/tabs/src/index.vue +55 -55
- package/packages/text/index.js +4 -4
- package/packages/text/src/index.vue +47 -47
- package/packages/text-editor/index.js +4 -4
- package/packages/text-editor/src/index.vue +72 -72
- package/packages/textarea/index.js +4 -4
- package/packages/textarea/src/index.vue +57 -57
- package/packages/theme/form.scss +21 -21
- package/packages/theme/index.scss +43 -42
- package/packages/theme/overrid.scss +7 -7
- package/packages/theme/styleClass.scss +2 -2
- package/packages/theme/variables.scss +55 -55
- package/packages/timeline/index.js +4 -4
- package/packages/timeline/src/index.vue +257 -257
- package/packages/tpl/index.js +4 -4
- package/packages/tpl/src/index.vue +55 -55
- package/packages/tree/index.js +4 -4
- package/packages/tree/src/TreeNode.vue +29 -29
- package/packages/tree/src/index.vue +101 -101
- package/packages/tree-select/index.js +4 -4
- package/packages/tree-select/src/index.vue +142 -142
- package/packages/upload/index.js +4 -4
- package/packages/upload/src/index.vue +998 -444
- package/packages/utils/index.js +67 -63
- package/packages/utils/vue2-expr.js +72 -0
- package/scripts/rollup.config.js +46 -42
- package/scripts/rollup.esm.config.js +11 -11
- package/scripts/rollup.umd.config.js +17 -14
- package/vitest.config.js +17 -0
package/packages/utils/index.js
CHANGED
|
@@ -1,63 +1,67 @@
|
|
|
1
|
-
import { parse } from '@idooel/expression'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
1
|
+
import { parse } from '@idooel/expression'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const NAMESPACE = '__idooel__ele__'
|
|
5
|
+
export const CONTEXT = '__idooel__ele__context__'
|
|
6
|
+
export const EXPOSED = 'exposed'
|
|
7
|
+
|
|
8
|
+
export const AREA_NAMES = {
|
|
9
|
+
BUTTON_GROUP: 'BUTTON_GROUP'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const BUILT_IN_EVENT_NAMES = {
|
|
13
|
+
SUBMIT: 'submit',
|
|
14
|
+
CANCEL: 'cancel',
|
|
15
|
+
INCREASE: 'increase',
|
|
16
|
+
DELETE: 'delete',
|
|
17
|
+
NEXT: 'next',
|
|
18
|
+
PREVIOUS: 'previous',
|
|
19
|
+
// create, edit, view are reserved for table cru in the current version
|
|
20
|
+
CREATE: 'create',
|
|
21
|
+
EDIT: 'edit',
|
|
22
|
+
VIEW: 'view'
|
|
23
|
+
}
|
|
24
|
+
export const BUILT_IN_METHODS_NAMES = {
|
|
25
|
+
CLOSE_MODAL: 'closeModal',
|
|
26
|
+
SUBMIT_FORM: 'submitForm',
|
|
27
|
+
//TODO: not use
|
|
28
|
+
REFRESH_TABLE: 'refreshTable',
|
|
29
|
+
CLEAN_EFFECT: 'cleanEffect'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const BUILT_IN_TRIGGER = {
|
|
33
|
+
// default it's not a trigger
|
|
34
|
+
TEXT: 'text',
|
|
35
|
+
//状态机触发器
|
|
36
|
+
FSM: 'fsm',
|
|
37
|
+
ELE_MODAL_FORM: 'ele-modal-form',
|
|
38
|
+
ELE_MODAL_TABLE: 'ele-modal-table'
|
|
39
|
+
}
|
|
40
|
+
export const PAGE_STATUS = {
|
|
41
|
+
CREATE: 'create',
|
|
42
|
+
//TODO implement edit and view
|
|
43
|
+
EDIT: 'edit',
|
|
44
|
+
VIEW: 'view'
|
|
45
|
+
}
|
|
46
|
+
export const RESERVE_EVENT_NAMES = {
|
|
47
|
+
//global event
|
|
48
|
+
INIT: 'init',
|
|
49
|
+
WATCH: 'watch',
|
|
50
|
+
//form event
|
|
51
|
+
WATCH_FORM_STATUS: 'watch-form-status',
|
|
52
|
+
INIT_FORM: 'init-form',
|
|
53
|
+
//table event
|
|
54
|
+
SEARCH: 'search',
|
|
55
|
+
TREE_CHANGE: 'tree-change'
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const parseFieldMap = (fieldMap = {}, dataSource = {}) => {
|
|
59
|
+
let ret = {}
|
|
60
|
+
Object.keys(fieldMap).forEach((key) => {
|
|
61
|
+
ret[fieldMap[key]] = parse(key, dataSource)
|
|
62
|
+
})
|
|
63
|
+
return ret
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export * from './vue2-expr'
|
|
67
|
+
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Binds an expression to a Vue data property, updating it whenever the model state changes.
|
|
5
|
+
*
|
|
6
|
+
* @param {Vue} vm - The Vue instance (component).
|
|
7
|
+
* @param {BaseModel} model - The runtime-context model.
|
|
8
|
+
* @param {string} expression - The expression string to evaluate.
|
|
9
|
+
* @param {string} dataKey - The key in vm.$data (or vm) to update.
|
|
10
|
+
* @param {object} [options] - Optional settings.
|
|
11
|
+
* @param {object} [options.extraContext] - Additional context for evaluation.
|
|
12
|
+
* @returns {Function} Unsubscribe function.
|
|
13
|
+
*/
|
|
14
|
+
export function bindExpression(vm, model, expression, dataKey, options = {}) {
|
|
15
|
+
if (!model || !expression) return () => {}
|
|
16
|
+
|
|
17
|
+
const evaluate = () => {
|
|
18
|
+
try {
|
|
19
|
+
return model.eval(expression, options.extraContext)
|
|
20
|
+
} catch (e) {
|
|
21
|
+
console.warn(`[bindExpression] Evaluation failed for "${expression}":`, e)
|
|
22
|
+
return undefined
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Initial set
|
|
27
|
+
const initialValue = evaluate()
|
|
28
|
+
if (dataKey in vm) {
|
|
29
|
+
vm[dataKey] = initialValue
|
|
30
|
+
} else {
|
|
31
|
+
// If property doesn't exist, try to set it reactively (though likely too late for template compilation)
|
|
32
|
+
Vue.set(vm, dataKey, initialValue)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Subscribe to store changes
|
|
36
|
+
// Note: Optimally, we would subscribe to specific paths if parsed from expression.
|
|
37
|
+
// For now, we subscribe to the store's root or relevant parts.
|
|
38
|
+
// Using store.subscribe() listens to *any* change, which might be heavy.
|
|
39
|
+
// But without AST analysis of dependency paths, it's the only safe way.
|
|
40
|
+
const unsubscribe = model.store.subscribe(() => {
|
|
41
|
+
const newValue = evaluate()
|
|
42
|
+
if (vm[dataKey] !== newValue) {
|
|
43
|
+
vm[dataKey] = newValue
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
// Auto-cleanup on destroy
|
|
48
|
+
if (vm.$once) {
|
|
49
|
+
vm.$once('hook:beforeDestroy', unsubscribe)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return unsubscribe
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A mixin to easily use runtime-context expressions in Vue components.
|
|
57
|
+
*
|
|
58
|
+
* Usage:
|
|
59
|
+
* export default {
|
|
60
|
+
* mixins: [ExpressionMixin],
|
|
61
|
+
* mounted() {
|
|
62
|
+
* this.bindExpr('isVisible', 'age > 18')
|
|
63
|
+
* }
|
|
64
|
+
* }
|
|
65
|
+
*/
|
|
66
|
+
export const ExpressionMixin = {
|
|
67
|
+
methods: {
|
|
68
|
+
bindExpr(dataKey, expression, model = this.model || this.formModel) {
|
|
69
|
+
return bindExpression(this, model, expression, dataKey)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
package/scripts/rollup.config.js
CHANGED
|
@@ -1,43 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
|
3
|
-
import { terser } from 'rollup-plugin-terser'
|
|
4
|
-
import strip from '@rollup/plugin-strip'
|
|
5
|
-
import vue from 'rollup-plugin-vue'
|
|
6
|
-
import postcss from 'rollup-plugin-postcss'
|
|
7
|
-
import postcssImport from 'postcss-import'
|
|
8
|
-
import { babel } from '@rollup/plugin-babel'
|
|
9
|
-
import alias from '@rollup/plugin-alias'
|
|
10
|
-
import { resolve } from 'path'
|
|
11
|
-
|
|
12
|
-
//TODO: bundle all packages in future
|
|
13
|
-
|
|
14
|
-
/** @type { import('rollup').RollupOptions } */
|
|
15
|
-
export default {
|
|
16
|
-
input: 'packages/index.js',
|
|
17
|
-
external: ['vue', '@idooel/shared', 'vue-upload-component', 'moment'],
|
|
18
|
-
plugins: [
|
|
19
|
-
nodeResolve(),
|
|
20
|
-
vue({
|
|
21
|
-
css: true,
|
|
22
|
-
compileTemplate: true
|
|
23
|
-
}),
|
|
24
|
-
alias({
|
|
25
|
-
entries: [
|
|
26
|
-
{ find: '@/utils', replacement: resolve(__dirname, '../packages/utils') }
|
|
27
|
-
]
|
|
28
|
-
}),
|
|
29
|
-
babel({
|
|
30
|
-
babelHelpers: 'bundled',
|
|
31
|
-
presets: [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
1
|
+
|
|
2
|
+
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
|
3
|
+
import { terser } from 'rollup-plugin-terser'
|
|
4
|
+
import strip from '@rollup/plugin-strip'
|
|
5
|
+
import vue from 'rollup-plugin-vue'
|
|
6
|
+
import postcss from 'rollup-plugin-postcss'
|
|
7
|
+
import postcssImport from 'postcss-import'
|
|
8
|
+
import { babel } from '@rollup/plugin-babel'
|
|
9
|
+
import alias from '@rollup/plugin-alias'
|
|
10
|
+
import { resolve } from 'path'
|
|
11
|
+
|
|
12
|
+
//TODO: bundle all packages in future
|
|
13
|
+
|
|
14
|
+
/** @type { import('rollup').RollupOptions } */
|
|
15
|
+
export default {
|
|
16
|
+
input: 'packages/index.js',
|
|
17
|
+
external: ['vue', '@idooel/runtime-context', '@idooel/shared', '@idooel/expression', 'vue-upload-component', 'moment'],
|
|
18
|
+
plugins: [
|
|
19
|
+
nodeResolve(),
|
|
20
|
+
vue({
|
|
21
|
+
css: true,
|
|
22
|
+
compileTemplate: true
|
|
23
|
+
}),
|
|
24
|
+
alias({
|
|
25
|
+
entries: [
|
|
26
|
+
{ find: '@/utils', replacement: resolve(__dirname, '../packages/utils') }
|
|
27
|
+
]
|
|
28
|
+
}),
|
|
29
|
+
babel({
|
|
30
|
+
babelHelpers: 'bundled',
|
|
31
|
+
presets: [
|
|
32
|
+
['@babel/preset-env', { targets: { ie: 11 }, modules: false }],
|
|
33
|
+
'@vue/babel-preset-jsx'
|
|
34
|
+
],
|
|
35
|
+
extensions: ['.js', '.jsx', '.es', '.es6', '.mjs', '.vue'],
|
|
36
|
+
filter: (id) => {
|
|
37
|
+
const isSupportedExt = /\.(js|jsx|es6?|mjs|vue)(\?|$)/.test(id)
|
|
38
|
+
return isSupportedExt && !/node_modules/.test(id)
|
|
39
|
+
}
|
|
40
|
+
}),
|
|
41
|
+
postcss({
|
|
42
|
+
extensions: ['.css', '.scss'],
|
|
43
|
+
extract: true,
|
|
44
|
+
plugins: [postcssImport()]
|
|
45
|
+
})
|
|
46
|
+
]
|
|
43
47
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import baseConfig from './rollup.config.js'
|
|
2
|
-
import { module } from '../package.json'
|
|
3
|
-
|
|
4
|
-
/** @type { import('rollup').RollupOptions } */
|
|
5
|
-
export default {
|
|
6
|
-
...baseConfig,
|
|
7
|
-
output: {
|
|
8
|
-
name: '__ele__esm__components__',
|
|
9
|
-
file: module,
|
|
10
|
-
format: 'es'
|
|
11
|
-
}
|
|
1
|
+
import baseConfig from './rollup.config.js'
|
|
2
|
+
import { module } from '../package.json'
|
|
3
|
+
|
|
4
|
+
/** @type { import('rollup').RollupOptions } */
|
|
5
|
+
export default {
|
|
6
|
+
...baseConfig,
|
|
7
|
+
output: {
|
|
8
|
+
name: '__ele__esm__components__',
|
|
9
|
+
file: module,
|
|
10
|
+
format: 'es'
|
|
11
|
+
}
|
|
12
12
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import baseConfig from './rollup.config.js'
|
|
2
|
-
import { main } from '../package.json'
|
|
3
|
-
/** @type { import('rollup').RollupOptions } */
|
|
4
|
-
export default {
|
|
5
|
-
...baseConfig,
|
|
6
|
-
output: {
|
|
7
|
-
name: '__ele__umd__components__',
|
|
8
|
-
file: main,
|
|
9
|
-
format: 'umd',
|
|
10
|
-
globals: {
|
|
11
|
-
vue: 'Vue'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import baseConfig from './rollup.config.js'
|
|
2
|
+
import { main } from '../package.json'
|
|
3
|
+
/** @type { import('rollup').RollupOptions } */
|
|
4
|
+
export default {
|
|
5
|
+
...baseConfig,
|
|
6
|
+
output: {
|
|
7
|
+
name: '__ele__umd__components__',
|
|
8
|
+
file: main,
|
|
9
|
+
format: 'umd',
|
|
10
|
+
globals: {
|
|
11
|
+
vue: 'Vue',
|
|
12
|
+
'@idooel/runtime-context': '@idooel/runtime-context',
|
|
13
|
+
'@idooel/shared': '@idooel/shared',
|
|
14
|
+
'@idooel/expression': '@idooel/expression'
|
|
15
|
+
},
|
|
16
|
+
exports: 'named'
|
|
17
|
+
}
|
|
15
18
|
}
|
package/vitest.config.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config'
|
|
2
|
+
import vue from '@vitejs/plugin-vue2'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [vue()],
|
|
7
|
+
resolve: {
|
|
8
|
+
alias: {
|
|
9
|
+
'@': path.resolve(__dirname, 'packages')
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
test: {
|
|
13
|
+
environment: 'jsdom',
|
|
14
|
+
globals: true,
|
|
15
|
+
setupFiles: ['__tests__/setup.js']
|
|
16
|
+
}
|
|
17
|
+
})
|