@cdlab996/lowcode-materials-vant2
v2.0.0
Published
Vant 2 materials for the LowCode Engine (Vue 2.7).
Readme
@cdlab996/lowcode-materials-vant2
LowCode Engine materials of
Vant 2 (vant 2.13.9) for Vue 2.7, rendered by
@cdlab996/lowcode-vue2.
Components
81 components: every component documented by vant 2.13.9 (the last Vant 2 release)
has a meta, with the props, events and slots of its docs,
a snippet and a docUrl to its page.
- The metas are generated from the docs of that version (
scripts/materials, see CONTRIBUTING.md in the repository);vantis pinned to 2.13.9. tests/meta.test.tschecks them against the components of that version: declared props, handler names, doc links, code generation exports and screenshots.screenshots/holds a thumbnail of every component, rendered from its snippet in the designer canvas; components with nothing to show (modals, sub-components) usescreenshots/fallback.svg.
Usage
The package ships browser builds; the designer loads them through
assets.json. The canvas must run Vue 2.7 with the
@cdlab996/lowcode-vue2 simulator.
From a CDN (unpkg serves the published dist):
import { injectAssets } from '@alilc/lowcode-plugin-inject'
import type { IPublicModelPluginContext } from '@alilc/lowcode-types'
const editorInit = (ctx: IPublicModelPluginContext) => ({
async init() {
const assets = await injectAssets(
'https://unpkg.com/@cdlab996/lowcode-materials-vant2/dist/assets.json',
)
await ctx.material.setAssets(assets)
},
})
editorInit.pluginName = 'editorInit'From the installed package (pnpm add @cdlab996/lowcode-materials-vant2), serve its dist
yourself and pass the imported JSON with your own URLs:
import assets from '@cdlab996/lowcode-materials-vant2/dist/assets.json'In the designer of this repository, the material is built in; any other
material is added by pasting its assets.json URL into the 物料 panel.
Files
dist/index.js,dist/index.css: the components, aswindow.Cdlab996LowcodeMaterialsVant2dist/meta.js: the metas, aswindow.Cdlab996LowcodeMaterialsVant2Metadist/assets.json: the engine assets pointing at the two, with thecodegenmanifestdist/screenshots/: snippet thumbnails
The scripts, the styles and assets.json also come minified (.min).
assets.json of a release:
{
"version": "<version>",
"packages": [
{
"package": "@cdlab996/lowcode-materials-vant2",
"version": "<version>",
"library": "Cdlab996LowcodeMaterialsVant2",
"urls": [
"https://unpkg.com/@cdlab996/lowcode-materials-vant2@<version>/dist/index.css",
"https://unpkg.com/@cdlab996/lowcode-materials-vant2@<version>/dist/index.js"
],
"codegen": {
"exports": { "...": "component -> export of vant" },
"styles": ["..."],
"dependencies": { "vant": "2.13.9" }
}
}
],
"components": [
{
"exportName": "Cdlab996LowcodeMaterialsVant2Meta",
"url": "https://unpkg.com/@cdlab996/lowcode-materials-vant2@<version>/dist/meta.js",
"package": { "npm": "@cdlab996/lowcode-materials-vant2" }
}
],
"sort": { "groupList": [], "categoryList": [] }
}The codegen manifest is what the code generator
(@cdlab996/lowcode-code-generator) uses to import the components from
vant in generated projects.
Development
pnpm -C packages/materials/vant2 build # dist/
pnpm dev --watch vant2 # from the repository root: rebuild on change, next to the designer