@mythpe/quasar-ui-qui 0.0.6 → 0.0.8
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/.gitattributes +2 -0
- package/build/config.js +13 -0
- package/build/index.js +19 -0
- package/build/script.app-ext.js +60 -0
- package/build/script.clean.js +6 -0
- package/build/script.css.js +75 -0
- package/build/script.javascript.js +213 -0
- package/build/script.open-umd.js +6 -0
- package/build/utils.js +54 -0
- package/index.d.ts +6 -0
- package/package.json +3 -3
- package/src/components/MBtn.vue +1 -1
- package/src/index.common.js +2 -3
- package/src/index.esm.js +3 -2
- package/src/index.umd.js +3 -1
- package/src/types/VuePlugin.d.ts +9 -0
- package/src/types/index.d.ts +2 -2
- package/src/utils.js +22 -0
- package/src/utils.ts +12 -14
- package/src/vue-plugin.js +9 -2
- package/tsconfig.json +10 -0
- package/umd-test.html +59 -0
- package/types.d.ts +0 -1
package/.gitattributes
ADDED
package/build/config.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const { name, author, version } = require('../package.json')
|
|
2
|
+
const year = (new Date()).getFullYear()
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
name,
|
|
6
|
+
version,
|
|
7
|
+
banner:
|
|
8
|
+
'/*!\n' +
|
|
9
|
+
' * ' + name + ' v' + version + '\n' +
|
|
10
|
+
' * (c) ' + year + ' ' + author + '\n' +
|
|
11
|
+
' * Released under the MIT License.\n' +
|
|
12
|
+
' */\n'
|
|
13
|
+
}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
process.env.NODE_ENV = 'production'
|
|
2
|
+
|
|
3
|
+
const parallel = require('os').cpus().length > 1
|
|
4
|
+
const runJob = parallel ? require('child_process').fork : require
|
|
5
|
+
const { join } = require('path')
|
|
6
|
+
const { createFolder } = require('./utils')
|
|
7
|
+
const { green, blue } = require('chalk')
|
|
8
|
+
|
|
9
|
+
console.log()
|
|
10
|
+
|
|
11
|
+
require('./script.app-ext.js').syncAppExt()
|
|
12
|
+
require('./script.clean.js')
|
|
13
|
+
|
|
14
|
+
console.log(` 📦 Building ${green('v' + require('../package.json').version)}...${parallel ? blue(' [multi-threaded]') : ''}\n`)
|
|
15
|
+
|
|
16
|
+
// createFolder('dist')
|
|
17
|
+
|
|
18
|
+
// runJob(join(__dirname, './script.javascript.js'))
|
|
19
|
+
// runJob(join(__dirname, './script.css.js'))
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const
|
|
2
|
+
fs = require('fs'),
|
|
3
|
+
path = require('path'),
|
|
4
|
+
root = path.resolve(__dirname, '../..'),
|
|
5
|
+
resolvePath = file => path.resolve(root, file),
|
|
6
|
+
{ blue } = require('chalk')
|
|
7
|
+
|
|
8
|
+
const writeJson = function (file, json) {
|
|
9
|
+
return fs.writeFileSync(file, JSON.stringify(json, null, 2) + '\n', 'utf-8')
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports.syncAppExt = function (both = true) {
|
|
13
|
+
// make sure this project has an app-extension project
|
|
14
|
+
const appExtDir = resolvePath('app-extension')
|
|
15
|
+
if (!fs.existsSync(appExtDir)) {
|
|
16
|
+
return
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// make sure this project has an ui project
|
|
20
|
+
const uiDir = resolvePath('ui')
|
|
21
|
+
if (!fs.existsSync(uiDir)) {
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// get version and name from ui package.json
|
|
26
|
+
const { name, version } = require(resolvePath(resolvePath('ui/package.json')))
|
|
27
|
+
|
|
28
|
+
// read app-ext package.json
|
|
29
|
+
const appExtFile = resolvePath('app-extension/package.json')
|
|
30
|
+
let appExtJson = require(appExtFile),
|
|
31
|
+
finished = false
|
|
32
|
+
|
|
33
|
+
// sync version numbers
|
|
34
|
+
if (both === true) {
|
|
35
|
+
appExtJson.version = version
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// check dependencies
|
|
39
|
+
if (appExtJson.dependencies !== void 0) {
|
|
40
|
+
if (appExtJson.dependencies[name] !== void 0) {
|
|
41
|
+
appExtJson.dependencies[name] = '^' + version
|
|
42
|
+
finished = true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// check devDependencies, if not finished
|
|
46
|
+
if (finished === false && appExtJson.devDependencies !== void 0) {
|
|
47
|
+
if (appExtJson.devDependencies[name] !== void 0) {
|
|
48
|
+
appExtJson.devDependencies[name] = '^' + version
|
|
49
|
+
finished = true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (finished === true) {
|
|
54
|
+
writeJson(appExtFile, appExtJson)
|
|
55
|
+
console.log(` ⭐️ App Extension version ${blue(appExtJson.name)} synced with UI version.\n`)
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
console.error(' App Extension version and dependency NOT synced.\n')
|
|
60
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const sass = require('sass')
|
|
3
|
+
const postcss = require('postcss')
|
|
4
|
+
const cssnano = require('cssnano')
|
|
5
|
+
const rtl = require('rtlcss')
|
|
6
|
+
const autoprefixer = require('autoprefixer')
|
|
7
|
+
|
|
8
|
+
const buildConf = require('./config')
|
|
9
|
+
const buildUtils = require('./utils')
|
|
10
|
+
|
|
11
|
+
const postCssCompiler = postcss([autoprefixer])
|
|
12
|
+
const postCssRtlCompiler = postcss([rtl({})])
|
|
13
|
+
|
|
14
|
+
const nano = postcss([
|
|
15
|
+
cssnano({
|
|
16
|
+
preset: ['default', {
|
|
17
|
+
mergeLonghand: false,
|
|
18
|
+
convertValues: false,
|
|
19
|
+
cssDeclarationSorter: false,
|
|
20
|
+
reduceTransforms: false
|
|
21
|
+
}]
|
|
22
|
+
})
|
|
23
|
+
])
|
|
24
|
+
|
|
25
|
+
Promise
|
|
26
|
+
.all([
|
|
27
|
+
generate('src/index.sass', 'dist/index')
|
|
28
|
+
])
|
|
29
|
+
.catch(e => {
|
|
30
|
+
console.error(e)
|
|
31
|
+
process.exit(1)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Helpers
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
function resolve (_path) {
|
|
39
|
+
return path.resolve(__dirname, '..', _path)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function generate (src, dest) {
|
|
43
|
+
src = resolve(src)
|
|
44
|
+
dest = resolve(dest)
|
|
45
|
+
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
sass.render({ file: src, includePaths: ['node_modules'] }, (err, result) => {
|
|
48
|
+
if (err) {
|
|
49
|
+
reject(err)
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
resolve(result.css)
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
.then(code => buildConf.banner + code)
|
|
57
|
+
.then(code => postCssCompiler.process(code, { from: void 0 }))
|
|
58
|
+
.then(code => {
|
|
59
|
+
code.warnings().forEach(warn => {
|
|
60
|
+
console.warn(warn.toString())
|
|
61
|
+
})
|
|
62
|
+
return code.css
|
|
63
|
+
})
|
|
64
|
+
.then(code => Promise.all([
|
|
65
|
+
generateUMD(dest, code),
|
|
66
|
+
postCssRtlCompiler.process(code, { from: void 0 })
|
|
67
|
+
.then(code => generateUMD(dest, code.css, '.rtl'))
|
|
68
|
+
]))
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function generateUMD (dest, code, ext = '') {
|
|
72
|
+
return buildUtils.writeFile(`${dest}${ext}.css`, code, true)
|
|
73
|
+
.then(code => nano.process(code, { from: void 0 }))
|
|
74
|
+
.then(code => buildUtils.writeFile(`${dest}${ext}.min.css`, code.css, true))
|
|
75
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
const fse = require('fs-extra')
|
|
4
|
+
const rollup = require('rollup')
|
|
5
|
+
const uglify = require('uglify-js')
|
|
6
|
+
const buble = require('@rollup/plugin-buble')
|
|
7
|
+
const json = require('@rollup/plugin-json')
|
|
8
|
+
const { nodeResolve } = require('@rollup/plugin-node-resolve')
|
|
9
|
+
const replace = require('@rollup/plugin-replace')
|
|
10
|
+
|
|
11
|
+
const { version } = require('../package.json')
|
|
12
|
+
|
|
13
|
+
const buildConf = require('./config')
|
|
14
|
+
const buildUtils = require('./utils')
|
|
15
|
+
|
|
16
|
+
const rollupPlugins = [
|
|
17
|
+
replace({
|
|
18
|
+
preventAssignment: false,
|
|
19
|
+
values: {
|
|
20
|
+
__UI_VERSION__: `'${version}'`
|
|
21
|
+
}
|
|
22
|
+
}),
|
|
23
|
+
nodeResolve({
|
|
24
|
+
extensions: ['.js'],
|
|
25
|
+
preferBuiltins: false
|
|
26
|
+
}),
|
|
27
|
+
json(),
|
|
28
|
+
buble({
|
|
29
|
+
objectAssign: 'Object.assign'
|
|
30
|
+
})
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
const builds = [
|
|
34
|
+
{
|
|
35
|
+
rollup: {
|
|
36
|
+
input: {
|
|
37
|
+
input: pathResolve('../src/index.esm.js')
|
|
38
|
+
},
|
|
39
|
+
output: {
|
|
40
|
+
file: pathResolve('../dist/index.esm.js'),
|
|
41
|
+
format: 'es'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
build: {
|
|
45
|
+
// unminified: true,
|
|
46
|
+
minified: true
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
rollup: {
|
|
51
|
+
input: {
|
|
52
|
+
input: pathResolve('../src/index.common.js')
|
|
53
|
+
},
|
|
54
|
+
output: {
|
|
55
|
+
file: pathResolve('../dist/index.common.js'),
|
|
56
|
+
format: 'cjs'
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
build: {
|
|
60
|
+
// unminified: true,
|
|
61
|
+
minified: true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
rollup: {
|
|
66
|
+
input: {
|
|
67
|
+
input: pathResolve('../src/index.umd.js')
|
|
68
|
+
},
|
|
69
|
+
output: {
|
|
70
|
+
name: 'mythUi',
|
|
71
|
+
file: pathResolve('../dist/index.umd.js'),
|
|
72
|
+
format: 'umd'
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
build: {
|
|
76
|
+
unminified: true,
|
|
77
|
+
minified: true,
|
|
78
|
+
minExt: true
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
// Add your asset folders here, if needed
|
|
84
|
+
// addAssets(builds, 'icon-set', 'iconSet')
|
|
85
|
+
// addAssets(builds, 'lang', 'lang')
|
|
86
|
+
|
|
87
|
+
build(builds)
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Helpers
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
function pathResolve (_path) {
|
|
94
|
+
return path.resolve(__dirname, _path)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// eslint-disable-next-line no-unused-vars
|
|
98
|
+
function addAssets (builds, type, injectName) {
|
|
99
|
+
const
|
|
100
|
+
files = fs.readdirSync(pathResolve('../../ui/src/components/' + type)),
|
|
101
|
+
plugins = [buble(/* bubleConfig */)],
|
|
102
|
+
outputDir = pathResolve(`../dist/${type}`)
|
|
103
|
+
|
|
104
|
+
fse.mkdirp(outputDir)
|
|
105
|
+
|
|
106
|
+
files
|
|
107
|
+
.filter(file => file.endsWith('.js'))
|
|
108
|
+
.forEach(file => {
|
|
109
|
+
const name = file.substr(0, file.length - 3).replace(/-([a-z])/g, g => g[1].toUpperCase())
|
|
110
|
+
builds.push({
|
|
111
|
+
rollup: {
|
|
112
|
+
input: {
|
|
113
|
+
input: pathResolve(`../src/components/${type}/${file}`),
|
|
114
|
+
plugins
|
|
115
|
+
},
|
|
116
|
+
output: {
|
|
117
|
+
file: addExtension(pathResolve(`../dist/${type}/${file}`), 'umd'),
|
|
118
|
+
format: 'umd',
|
|
119
|
+
name: `mythUi.${injectName}.${name}`
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
build: {
|
|
123
|
+
minified: true
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function build (builds) {
|
|
130
|
+
return Promise
|
|
131
|
+
.all(builds.map(genConfig).map(buildEntry))
|
|
132
|
+
.catch(buildUtils.logError)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function genConfig (opts) {
|
|
136
|
+
Object.assign(opts.rollup.input, {
|
|
137
|
+
plugins: rollupPlugins,
|
|
138
|
+
external: ['vue', 'quasar']
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
Object.assign(opts.rollup.output, {
|
|
142
|
+
banner: buildConf.banner,
|
|
143
|
+
globals: { vue: 'Vue', quasar: 'Quasar' }
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
return opts
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function addExtension (filename, ext = 'min') {
|
|
150
|
+
const insertionPoint = filename.lastIndexOf('.')
|
|
151
|
+
return `${filename.slice(0, insertionPoint)}.${ext}${filename.slice(insertionPoint)}`
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function buildEntry (config) {
|
|
155
|
+
return rollup
|
|
156
|
+
.rollup(config.rollup.input)
|
|
157
|
+
.then(bundle => bundle.generate(config.rollup.output))
|
|
158
|
+
.then(({ output }) => {
|
|
159
|
+
const code = config.rollup.output.format === 'umd'
|
|
160
|
+
? injectVueRequirement(output[0].code)
|
|
161
|
+
: output[0].code
|
|
162
|
+
|
|
163
|
+
return config.build.unminified
|
|
164
|
+
? buildUtils.writeFile(config.rollup.output.file, code)
|
|
165
|
+
: code
|
|
166
|
+
})
|
|
167
|
+
.then(code => {
|
|
168
|
+
if (!config.build.minified) {
|
|
169
|
+
return code
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const minified = uglify.minify(code, {
|
|
173
|
+
compress: {
|
|
174
|
+
pure_funcs: ['makeMap']
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
if (minified.error) {
|
|
179
|
+
return Promise.reject(minified.error)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return buildUtils.writeFile(
|
|
183
|
+
config.build.minExt === true
|
|
184
|
+
? addExtension(config.rollup.output.file)
|
|
185
|
+
: config.rollup.output.file,
|
|
186
|
+
buildConf.banner + minified.code,
|
|
187
|
+
true
|
|
188
|
+
)
|
|
189
|
+
})
|
|
190
|
+
.catch(err => {
|
|
191
|
+
console.error(err)
|
|
192
|
+
process.exit(1)
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function injectVueRequirement (code) {
|
|
197
|
+
// eslint-disable-next-line
|
|
198
|
+
const index = code.indexOf(`Vue = Vue && Vue.hasOwnProperty('default') ? Vue['default'] : Vue`)
|
|
199
|
+
|
|
200
|
+
if (index === -1) {
|
|
201
|
+
return code
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const checkMe = ` if (Vue === void 0) {
|
|
205
|
+
console.error('[ Quasar ] Vue is required to run. Please add a script tag for it before loading Quasar.')
|
|
206
|
+
return
|
|
207
|
+
}
|
|
208
|
+
`
|
|
209
|
+
|
|
210
|
+
return code.substring(0, index - 1) +
|
|
211
|
+
checkMe +
|
|
212
|
+
code.substring(index)
|
|
213
|
+
}
|
package/build/utils.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const
|
|
2
|
+
fs = require('fs'),
|
|
3
|
+
path = require('path'),
|
|
4
|
+
zlib = require('zlib'),
|
|
5
|
+
{ green, blue, red, cyan } = require('chalk')
|
|
6
|
+
|
|
7
|
+
function getSize (code) {
|
|
8
|
+
return (code.length / 1024).toFixed(2) + 'kb'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports.createFolder = function (folder) {
|
|
12
|
+
const dir = path.join(__dirname, '..', folder)
|
|
13
|
+
if (!fs.existsSync(dir)) {
|
|
14
|
+
fs.mkdirSync(dir)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports.writeFile = function (dest, code, zip) {
|
|
19
|
+
const banner = dest.indexOf('.json') > -1
|
|
20
|
+
? red('[json]')
|
|
21
|
+
: dest.indexOf('.js') > -1
|
|
22
|
+
? green('[js] ')
|
|
23
|
+
: dest.indexOf('.ts') > -1
|
|
24
|
+
? cyan('[ts] ')
|
|
25
|
+
: blue('[css] ')
|
|
26
|
+
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
function report (extra) {
|
|
29
|
+
console.log(`${banner} ${path.relative(process.cwd(), dest).padEnd(41)} ${getSize(code).padStart(8)}${extra || ''}`)
|
|
30
|
+
resolve(code)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
fs.writeFile(dest, code, err => {
|
|
34
|
+
if (err) return reject(err)
|
|
35
|
+
if (zip) {
|
|
36
|
+
zlib.gzip(code, (err, zipped) => {
|
|
37
|
+
if (err) return reject(err)
|
|
38
|
+
report(` (gzipped: ${getSize(zipped).padStart(8)})`)
|
|
39
|
+
})
|
|
40
|
+
} else {
|
|
41
|
+
report()
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports.readFile = function (file) {
|
|
48
|
+
return fs.readFileSync(file, 'utf-8')
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports.logError = function (err) {
|
|
52
|
+
console.error('\n' + red('[Error]'), err)
|
|
53
|
+
console.log()
|
|
54
|
+
}
|
package/index.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mythpe/quasar-ui-qui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "MyTh Quasar UI Kit App Extension",
|
|
5
5
|
"author": "MyTh Ahmed Faiz <mythpe@gmail.com>",
|
|
6
6
|
"email": "mythpe@gmail.com",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"module": "src/index.esm.js",
|
|
10
10
|
"main": "src/index.common.js",
|
|
11
|
-
"
|
|
11
|
+
"type": "module",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"dev": "cd ../dev && yarn dev && cd ..",
|
|
14
14
|
"dev:umd": "yarn build && node build/script.open-umd.js",
|
|
@@ -55,6 +55,6 @@
|
|
|
55
55
|
"last 4 iOS versions"
|
|
56
56
|
],
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"vue-i18n": "^
|
|
58
|
+
"vue-i18n": "^10.0.4"
|
|
59
59
|
}
|
|
60
60
|
}
|
package/src/components/MBtn.vue
CHANGED
|
@@ -10,7 +10,7 @@ defineOptions({
|
|
|
10
10
|
name: 'MBtn',
|
|
11
11
|
inheritAttrs: !1
|
|
12
12
|
})
|
|
13
|
-
const options = computed(() => MythOptions.
|
|
13
|
+
const options = computed(() => MythOptions.defaults.value.btn ?? {})
|
|
14
14
|
const { t, te } = useI18n({ useScope: 'global' })
|
|
15
15
|
const getLabel = computed(() => {
|
|
16
16
|
if (props.label !== undefined) {
|
package/src/index.common.js
CHANGED
package/src/index.esm.js
CHANGED
package/src/index.umd.js
CHANGED
package/src/types/VuePlugin.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { QBtnProps } from 'quasar'
|
|
2
|
+
import type { Ref } from 'vue'
|
|
2
3
|
|
|
3
4
|
export interface UiOptions {
|
|
4
5
|
btn?: {
|
|
@@ -11,3 +12,11 @@ export interface UiOptions {
|
|
|
11
12
|
}
|
|
12
13
|
};
|
|
13
14
|
}
|
|
15
|
+
export interface MythOptionsContext {
|
|
16
|
+
defaults: Ref<UiOptions>;
|
|
17
|
+
getDefaults: () => UiOptions;
|
|
18
|
+
setDefaults: (values: Partial<UiOptions>) => void;
|
|
19
|
+
withDefaults: (values: Partial<UiOptions>) => void;
|
|
20
|
+
withBtnDefaults: (values: Partial<QBtnProps>) => void;
|
|
21
|
+
btnDefaults: () => UiOptions;
|
|
22
|
+
}
|
package/src/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './MBtn
|
|
2
|
-
export * from './VuePlugin
|
|
1
|
+
export * from './MBtn'
|
|
2
|
+
export * from './VuePlugin'
|
package/src/utils.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
const cmDefaults = ref({});
|
|
3
|
+
const MythOptions = {
|
|
4
|
+
defaults: cmDefaults,
|
|
5
|
+
setDefaults(values) {
|
|
6
|
+
cmDefaults.value = { ...values };
|
|
7
|
+
},
|
|
8
|
+
withDefaults(values) {
|
|
9
|
+
cmDefaults.value = { ...cmDefaults.value, ...values };
|
|
10
|
+
},
|
|
11
|
+
withBtnDefaults(values) {
|
|
12
|
+
cmDefaults.value = {
|
|
13
|
+
...cmDefaults.value,
|
|
14
|
+
btn: {
|
|
15
|
+
...cmDefaults.value.btn,
|
|
16
|
+
props: { ...values }
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export default MythOptions;
|
|
22
|
+
export { MythOptions };
|
package/src/utils.ts
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import { ref } from 'vue'
|
|
2
2
|
import type { UiOptions } from './types'
|
|
3
|
-
import { QBtnProps } from 'quasar'
|
|
3
|
+
import type { QBtnProps } from 'quasar'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return this.defaults.value
|
|
9
|
-
},
|
|
5
|
+
const cmDefaults = ref<UiOptions>({})
|
|
6
|
+
const MythOptions = {
|
|
7
|
+
defaults: cmDefaults,
|
|
10
8
|
setDefaults (values: Partial<UiOptions>) {
|
|
11
|
-
|
|
9
|
+
cmDefaults.value = { ...values }
|
|
12
10
|
},
|
|
13
11
|
withDefaults (values: Partial<UiOptions>) {
|
|
14
|
-
|
|
12
|
+
cmDefaults.value = { ...cmDefaults.value, ...values }
|
|
15
13
|
},
|
|
16
14
|
withBtnDefaults (values: Partial<QBtnProps>) {
|
|
17
|
-
|
|
18
|
-
...
|
|
15
|
+
cmDefaults.value = {
|
|
16
|
+
...cmDefaults.value,
|
|
19
17
|
btn: {
|
|
20
|
-
...
|
|
18
|
+
...cmDefaults.value.btn,
|
|
21
19
|
props: { ...values }
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
|
-
},
|
|
25
|
-
btnDefaults () {
|
|
26
|
-
return this.defaults.value.btn
|
|
27
22
|
}
|
|
28
23
|
}
|
|
24
|
+
|
|
25
|
+
export default MythOptions
|
|
26
|
+
export { MythOptions }
|
package/src/vue-plugin.js
CHANGED
|
@@ -6,8 +6,8 @@ const name = js.name
|
|
|
6
6
|
const version = js.version
|
|
7
7
|
|
|
8
8
|
function install (app, options = {}) {
|
|
9
|
-
MythOptions.
|
|
10
|
-
app.component(MBtn
|
|
9
|
+
MythOptions.withDefaults(options)
|
|
10
|
+
app.component('MBtn', MBtn)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export {
|
|
@@ -16,3 +16,10 @@ export {
|
|
|
16
16
|
install,
|
|
17
17
|
MythOptions
|
|
18
18
|
}
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
name,
|
|
22
|
+
version,
|
|
23
|
+
install,
|
|
24
|
+
MythOptions
|
|
25
|
+
}
|
package/tsconfig.json
ADDED
package/umd-test.html
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en-US">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta content="IE=edge" http-equiv="X-UA-Compatible">
|
|
6
|
+
<meta content="telephone=no" name="format-detection">
|
|
7
|
+
<meta content="no" name="msapplication-tap-highlight">
|
|
8
|
+
<meta content="user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1,width=device-width" name="viewport">
|
|
9
|
+
|
|
10
|
+
<title>UMD test</title>
|
|
11
|
+
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons" rel="stylesheet" type="text/css">
|
|
12
|
+
<link href="https://cdn.jsdelivr.net/npm/quasar@2/dist/quasar.prod.css" rel="stylesheet" type="text/css">
|
|
13
|
+
<link href="dist/index.css" rel="stylesheet" type="text/css">
|
|
14
|
+
</head>
|
|
15
|
+
<body>
|
|
16
|
+
<div id="q-app">
|
|
17
|
+
<q-layout view="lHh Lpr fff">
|
|
18
|
+
<q-header class="glossy bg-primary">
|
|
19
|
+
<q-toolbar>
|
|
20
|
+
<q-toolbar-title>
|
|
21
|
+
quasar-ui-qui v{{ version }}
|
|
22
|
+
</q-toolbar-title>
|
|
23
|
+
|
|
24
|
+
<div>Quasar v{{ $q.version }}</div>
|
|
25
|
+
</q-toolbar>
|
|
26
|
+
</q-header>
|
|
27
|
+
|
|
28
|
+
<q-page-container>
|
|
29
|
+
<q-page padding>
|
|
30
|
+
<ul class="q-mb-lg">
|
|
31
|
+
<li>In /ui, run: "yarn build"</li>
|
|
32
|
+
<li class="text-red">You need to build & refresh page on each change manually.</li>
|
|
33
|
+
<li>Use self-closing tags only!</li>
|
|
34
|
+
<li>Example: <my-component></my-component></li>
|
|
35
|
+
</ul>
|
|
36
|
+
</q-page>
|
|
37
|
+
</q-page-container>
|
|
38
|
+
</q-layout>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"></script>
|
|
42
|
+
<script src="https://cdn.jsdelivr.net/npm/quasar@2/dist/quasar.umd.prod.js"></script>
|
|
43
|
+
<script src="dist/index.umd.js"></script>
|
|
44
|
+
|
|
45
|
+
<script>
|
|
46
|
+
const app = Vue.createApp({
|
|
47
|
+
setup() {
|
|
48
|
+
return {
|
|
49
|
+
version: mythUi.version
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
app.use(Quasar)
|
|
55
|
+
app.use(mythUi)
|
|
56
|
+
app.mount('#q-app')
|
|
57
|
+
</script>
|
|
58
|
+
</body>
|
|
59
|
+
</html>
|
package/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './src/types'
|