├── .gitignore
├── .vscode
└── extensions.json
├── LICENSE
├── README.md
├── index.html
├── package-lock.json
├── package.json
├── preview
├── el-tree-select.png
├── elAutocomplete.png
├── elCascader.png
├── elDatePicker.png
├── elRate.png
├── elSelect.png
├── elSwitch.png
├── elTimePicker.png
├── elUpload.png
├── formItem.png
└── ui.png
├── public
└── vite.svg
├── src
├── App.vue
├── assets
│ └── vue.svg
├── components
│ ├── Autocomplete.ts
│ ├── Cascader.ts
│ ├── Checkbox.ts
│ ├── CheckboxGroup.ts
│ ├── ColorPicker.ts
│ ├── DatePicker.ts
│ ├── DateRangePicker.ts
│ ├── Form.vue
│ ├── FormItem.vue
│ ├── FormUpload.ts
│ ├── Input.ts
│ ├── InputNumber.ts
│ ├── Password.ts
│ ├── RadioGroup.ts
│ ├── Rate.ts
│ ├── Select.ts
│ ├── Slider.ts
│ ├── Switch.ts
│ ├── Textarea.ts
│ ├── TimePicker.ts
│ ├── TimeSelect.ts
│ ├── Transfer.ts
│ ├── Tree.ts
│ ├── TreeSelect.ts
│ ├── Upload.ts
│ ├── createFormItemInput.ts
│ └── index.ts
├── main.ts
├── pages
│ ├── autocomplete.vue
│ ├── cascader.vue
│ ├── date.vue
│ ├── form.vue
│ ├── index.vue
│ ├── input.vue
│ ├── password.vue
│ ├── radio.vue
│ ├── rate.vue
│ ├── select.vue
│ ├── slots.vue
│ ├── switch.vue
│ ├── time.vue
│ ├── transfer.vue
│ ├── tree.vue
│ └── upload.vue
└── vite-env.d.ts
├── tsconfig.json
├── tsconfig.node.json
└── vite.config.ts
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": ["Vue.volar"]
3 | }
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Raymond
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # FormKit element
2 |
3 | Element plus for FormKit.
4 |
5 | Most of the components are based on Element plus, attributes directly pass to the element plus component.
6 |
7 | ## Preview
8 |
9 |
10 |
11 | ## Setup
12 |
13 |
14 | 1. This library require Element plus and FormKit to be installed.
15 |
16 |
17 | If you are using nuxt, you can use FormKit nuxt module to install FormKit.
18 |
19 |
20 | 2. Create formkit.config.ts if using nuxt
21 |
22 |
23 | ```typescript
24 | import { DefaultConfigOptions } from '@formkit/vue'
25 | import { createElementPlugin } from 'formkit-element'
26 |
27 | const config: DefaultConfigOptions = {
28 | plugins: [createElementPlugin()]
29 | }
30 | ```
31 |
32 | 1. or direct setup in main.ts
33 | ```typescript
34 | const app = createApp(App);
35 |
36 | import { plugin, defaultConfig } from '@formkit/vue'
37 | import { createElementPlugin } from "formkit-element";
38 | app.use(plugin, defaultConfig({
39 | plugins: [createElementPlugin()]
40 | }))
41 | ```
42 |
43 | ## Usage
44 |
45 | ### Basic
46 |
47 | ```html
48 |
49 |
50 |
51 |
52 |
54 |
55 |
56 |
57 |
58 |
59 |
69 |
70 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 | ```
90 |
91 |
92 | When using attributes `form-item` the component will be wrapped in a el-form-item component.
93 |
94 | #### el-form-item preivew
95 |
96 |
97 |
98 |
99 | ```typescript
100 |
101 |
102 |
103 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 | ```
142 |
143 |
144 | ### Supported type
145 |
146 | el-cascader
147 |
148 |
149 |
150 |
151 | el-rate
152 |
153 |
154 | ```html
155 |
156 |
157 |
158 |
159 |
160 |
162 |
163 |
164 |
165 | ```
166 |
167 |
168 |
169 |
170 | el-select
171 |
172 |
173 | Custom template of select options
174 | ```html
175 |
207 |
208 |
209 |
210 | {{ item.label }}
211 | {{ item.value }}
216 |
217 |
218 |
219 |
220 | ```
221 |
222 |
223 |
224 |
225 | el-date-picker and el-date-range-picker
226 |
227 |
228 | ```html
229 |
230 |
231 |
232 |
233 | ```
234 |
235 |
236 |
237 |
238 | el-switch
239 |
240 |
241 | ```html
242 |
243 |
244 |
245 |
246 |
247 | ```
248 |
249 |
250 |
251 |
252 | el-time-picker
253 |
254 |
255 | ```html
256 |
257 |
258 |
259 |
260 | ```
261 |
262 |
263 |
264 |
265 | el-autocomplete
266 |
267 |
268 | ```html
269 |
299 |
300 |
301 |
302 | {{ data }}
303 |
304 |
306 |
307 |
308 |
309 |
310 |
311 | ```
312 |
313 |
314 |
315 |
316 | el-upload
317 |
318 |
319 | ```html
320 |
324 |
325 |
326 | {{ data }}
327 |
328 |
329 | select file
330 |
331 |
332 |
333 | select file
334 |
335 |
336 |
337 | ```
338 |
339 |
340 |
341 |
342 |
343 | el-tree-select
344 |
345 |
346 | ```html
347 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 | ```
384 |
385 |
386 |
387 |
388 | - el-checkbox
389 | - el-color-picker
390 | - el-input
391 | - el-input-number
392 | - el-password
393 | - el-radio-group
394 | - el-slider
395 | - el-textarea
396 | - el-time-select
397 | - el-form
398 | - el-transfer
399 | - el-checkbox-group
400 | - el-tree
401 |
402 |
403 | ### el-form submit
404 |
405 | Due to the limitation of vue3, the submit event of el-form is not supported. You can use the submit attribute of FormKit to submit the form.
406 |
407 | ```typescript
408 | const data=ref({})
409 | let onSubmit=()=>{
410 | console.log('submited')
411 | }
412 |
413 | ```
414 |
415 | ```html
416 |
417 | ...
418 |
419 | ```
420 |
421 |
422 |
423 |
424 |
425 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite + Vue + TS
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "formkit-element",
3 | "private": false,
4 | "version": "0.0.44",
5 | "type": "module",
6 | "homepage": "https://github.com/mathsgod/formkit-element",
7 | "url": "https://github.com/mathsgod/formkit-element/issues",
8 | "scripts": {
9 | "dev": "vite",
10 | "build": "vue-tsc --noEmit && vite build",
11 | "preview": "vite preview",
12 | "release": "npm version patch && npm run build && npm publish"
13 | },
14 | "dependencies": {
15 | "vue": "^3.3.4"
16 | },
17 | "devDependencies": {
18 | "@element-plus/icons-vue": "^2.1.0",
19 | "@formkit/themes": "^0.17.2",
20 | "@formkit/vue": "^0.17.2",
21 | "@vitejs/plugin-vue": "^3.1.0",
22 | "element-plus": "^2.3.5",
23 | "typescript": "^4.9.5",
24 | "vite": "^3.2.6",
25 | "vite-plugin-dts": "^1.7.0",
26 | "vue-router": "^4.2.1",
27 | "vue-tsc": "^0.40.4"
28 | },
29 | "files": [
30 | "dist"
31 | ],
32 | "module": "./dist/formkit-element.js",
33 | "license": "MIT"
34 | }
35 |
--------------------------------------------------------------------------------
/preview/el-tree-select.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mathsgod/formkit-element/cc88e5f68f95eaa2443447c9c674cdaa2f83d0b8/preview/el-tree-select.png
--------------------------------------------------------------------------------
/preview/elAutocomplete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mathsgod/formkit-element/cc88e5f68f95eaa2443447c9c674cdaa2f83d0b8/preview/elAutocomplete.png
--------------------------------------------------------------------------------
/preview/elCascader.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mathsgod/formkit-element/cc88e5f68f95eaa2443447c9c674cdaa2f83d0b8/preview/elCascader.png
--------------------------------------------------------------------------------
/preview/elDatePicker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mathsgod/formkit-element/cc88e5f68f95eaa2443447c9c674cdaa2f83d0b8/preview/elDatePicker.png
--------------------------------------------------------------------------------
/preview/elRate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mathsgod/formkit-element/cc88e5f68f95eaa2443447c9c674cdaa2f83d0b8/preview/elRate.png
--------------------------------------------------------------------------------
/preview/elSelect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mathsgod/formkit-element/cc88e5f68f95eaa2443447c9c674cdaa2f83d0b8/preview/elSelect.png
--------------------------------------------------------------------------------
/preview/elSwitch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mathsgod/formkit-element/cc88e5f68f95eaa2443447c9c674cdaa2f83d0b8/preview/elSwitch.png
--------------------------------------------------------------------------------
/preview/elTimePicker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mathsgod/formkit-element/cc88e5f68f95eaa2443447c9c674cdaa2f83d0b8/preview/elTimePicker.png
--------------------------------------------------------------------------------
/preview/elUpload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mathsgod/formkit-element/cc88e5f68f95eaa2443447c9c674cdaa2f83d0b8/preview/elUpload.png
--------------------------------------------------------------------------------
/preview/formItem.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mathsgod/formkit-element/cc88e5f68f95eaa2443447c9c674cdaa2f83d0b8/preview/formItem.png
--------------------------------------------------------------------------------
/preview/ui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mathsgod/formkit-element/cc88e5f68f95eaa2443447c9c674cdaa2f83d0b8/preview/ui.png
--------------------------------------------------------------------------------
/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/assets/vue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/components/Autocomplete.ts:
--------------------------------------------------------------------------------
1 | import { ElAutocomplete } from 'element-plus';
2 | import { defineComponent, h, ref } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | props.context.classes.inner = "";
8 |
9 | let v = ref(props.context.node.value);
10 | props.context.node.on("input", (val: any) => {
11 | v.value = val.payload;
12 | })
13 |
14 | return () => {
15 | return h(ElAutocomplete, {
16 | modelValue: v.value,
17 | "onUpdate:modelValue": (val: any) => {
18 | props.context.node.input(val);
19 | v.value = val;
20 | },
21 | onBlur() {
22 | props.context.handlers.blur()
23 | },
24 | ...props.context.attrs
25 | });
26 | }
27 | }
28 | });
--------------------------------------------------------------------------------
/src/components/Cascader.ts:
--------------------------------------------------------------------------------
1 | import { ElCascader } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | const value = computed({
12 | get() {
13 | return props.context.value;
14 | },
15 | set(val) {
16 | props.context.node.input(val);
17 | }
18 | });
19 |
20 | return () => {
21 | return h(ElCascader, {
22 | modelValue: value.value,
23 | "onUpdate:modelValue": (val: any) => {
24 | value.value = val;
25 | },
26 | onBlur() {
27 | props.context.handlers.blur()
28 | },
29 | ...props.context.attrs
30 | });
31 | }
32 | }
33 | });
--------------------------------------------------------------------------------
/src/components/Checkbox.ts:
--------------------------------------------------------------------------------
1 | import { ElCheckbox } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | const value = computed({
12 | get() {
13 | return props.context.value;
14 | },
15 | set(val) {
16 | props.context.node.input(val);
17 | }
18 | });
19 |
20 |
21 | return () => {
22 | return h(ElCheckbox, {
23 | modelValue: value.value,
24 | "onUpdate:modelValue": (val: any) => {
25 | value.value = val;
26 | },
27 | onBlur() {
28 | props.context.handlers.blur()
29 | },
30 | ...props.context.attrs
31 | });
32 | }
33 | }
34 | });
--------------------------------------------------------------------------------
/src/components/CheckboxGroup.ts:
--------------------------------------------------------------------------------
1 | import { ElCheckboxGroup, ElCheckbox } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 | import { normalizeOptions } from "@formkit/inputs";
4 |
5 | export default defineComponent({
6 | props: ["context"],
7 | setup(props) {
8 | if (props.context.classes.inner == "formkit-inner") {
9 | props.context.classes.inner = "";
10 | }
11 |
12 | const value = computed({
13 | get() {
14 | return props.context.value;
15 | },
16 | set(val) {
17 | props.context.node.input(val);
18 | }
19 | });
20 |
21 | let options = normalizeOptions(props.context.node.props.options ?? []);
22 |
23 | let OptionComponents = options.map((option: any) => {
24 | return h(ElCheckbox, {
25 | label: option.label,
26 | value: option.__original ?? option.value
27 | })
28 | })
29 |
30 | return () => {
31 | return h(ElCheckboxGroup, {
32 | modelValue: value.value,
33 | "onUpdate:modelValue": (val: any) => {
34 | value.value = val;
35 | },
36 | onBlur() {
37 | props.context.handlers.blur()
38 | },
39 | ...props.context.attrs
40 | }, () => OptionComponents
41 | );
42 | }
43 | }
44 | });
--------------------------------------------------------------------------------
/src/components/ColorPicker.ts:
--------------------------------------------------------------------------------
1 | import { ElColorPicker } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | const value = computed({
12 | get() {
13 | return props.context.value;
14 | },
15 | set(val) {
16 | props.context.node.input(val);
17 | }
18 | });
19 |
20 | return () => {
21 | return h(ElColorPicker, {
22 | modelValue: value.value,
23 | "onUpdate:modelValue": (val: any) => {
24 | value.value = val;
25 | },
26 | onBlur() {
27 | props.context.handlers.blur()
28 | },
29 | ...props.context.attrs
30 | });
31 | }
32 | }
33 | });
--------------------------------------------------------------------------------
/src/components/DatePicker.ts:
--------------------------------------------------------------------------------
1 | import { ElDatePicker } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | const value = computed({
12 | get() {
13 | return props.context.value;
14 | },
15 | set(val) {
16 | props.context.node.input(val);
17 | }
18 | });
19 |
20 | return () => {
21 | return h(ElDatePicker, {
22 | valueFormat: "YYYY-MM-DD",
23 | modelValue: value.value,
24 | "onUpdate:modelValue": (val: any) => {
25 | value.value = val;
26 | },
27 | onBlur() {
28 | props.context.handlers.blur()
29 | },
30 | ...props.context.attrs
31 | });
32 | }
33 | }
34 | });
--------------------------------------------------------------------------------
/src/components/DateRangePicker.ts:
--------------------------------------------------------------------------------
1 | import { ElDatePicker } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | const value = computed({
12 | get() {
13 | return props.context.value;
14 | },
15 | set(val) {
16 | props.context.node.input(val);
17 | }
18 | });
19 | return () => {
20 | return h(ElDatePicker, {
21 | valueFormat: "YYYY-MM-DD",
22 | type: "daterange",
23 | modelValue: value.value,
24 | "onUpdate:modelValue": (val: any) => {
25 | value.value = val;
26 | },
27 | onBlur() {
28 | props.context.handlers.blur()
29 | },
30 | ...props.context.attrs
31 | });
32 | }
33 | }
34 | });
--------------------------------------------------------------------------------
/src/components/Form.vue:
--------------------------------------------------------------------------------
1 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | Submit
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/src/components/FormItem.vue:
--------------------------------------------------------------------------------
1 |
22 |
23 |
25 |
26 | {{ props.context.help }}
27 |
28 |
--------------------------------------------------------------------------------
/src/components/FormUpload.ts:
--------------------------------------------------------------------------------
1 |
2 | import { defineComponent, h, ref } from 'vue'
3 | import FormItem from './FormItem.vue';
4 | import Upload from './Upload'
5 |
6 | export default defineComponent({
7 | props: ["context"],
8 | setup(props, { slots }) {
9 |
10 | let children: any = [];;
11 | if (slots) {
12 | children = slots.default?.() ?? [];
13 | }
14 |
15 | return () => {
16 | return h(FormItem, {
17 | context: props.context
18 | },
19 | () => h(Upload, {
20 | style: {
21 | width: "100%"
22 | },
23 | context: props.context,
24 | ...props.context.attrs
25 | }, children)
26 |
27 | )
28 | }
29 | }
30 | });
--------------------------------------------------------------------------------
/src/components/Input.ts:
--------------------------------------------------------------------------------
1 | import { ElInput } from 'element-plus';
2 | import { defineComponent, h, computed, watch } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | const value = computed({
12 | get() {
13 | return props.context.value;
14 | },
15 | set(val) {
16 | props.context.node.input(val);
17 | }
18 | });
19 |
20 | return () => {
21 | return h(ElInput, {
22 | modelValue: value.value,
23 | "onUpdate:modelValue": (val: any) => {
24 | value.value = val;
25 | },
26 | onBlur() {
27 | props.context.handlers.blur()
28 | },
29 | ...props.context.attrs
30 | });
31 | }
32 | }
33 | });
--------------------------------------------------------------------------------
/src/components/InputNumber.ts:
--------------------------------------------------------------------------------
1 | import { ElInputNumber } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | const value = computed({
12 | get() {
13 | return props.context.value;
14 | },
15 | set(val) {
16 | props.context.node.input(val);
17 | }
18 | });
19 |
20 | return () => {
21 | return h(ElInputNumber, {
22 | modelValue: value.value,
23 | "onUpdate:modelValue": (val: any) => {
24 | value.value = val;
25 | },
26 | onBlur() {
27 | props.context.handlers.blur()
28 | },
29 | ...props.context.attrs
30 | });
31 | }
32 | }
33 | });
--------------------------------------------------------------------------------
/src/components/Password.ts:
--------------------------------------------------------------------------------
1 | import { ElInput } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | const value = computed({
12 | get() {
13 | return props.context.value;
14 | },
15 | set(val) {
16 | props.context.node.input(val);
17 | }
18 | });
19 |
20 | return () => {
21 | return h(ElInput, {
22 | type: "password",
23 | modelValue: value.value,
24 | "onUpdate:modelValue": (val: any) => {
25 | value.value = val;
26 | },
27 | onBlur() {
28 | props.context.handlers.blur()
29 | },
30 | ...props.context.attrs
31 | });
32 | }
33 | }
34 | });
--------------------------------------------------------------------------------
/src/components/RadioGroup.ts:
--------------------------------------------------------------------------------
1 | import { ElRadioGroup, ElRadio } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 | import { normalizeOptions } from "@formkit/inputs";
4 |
5 | export default defineComponent({
6 | props: ["context"],
7 | setup(props) {
8 | if (props.context.classes.inner == "formkit-inner") {
9 | props.context.classes.inner = "";
10 | }
11 |
12 | const value = computed({
13 | get() {
14 | return props.context.value;
15 | },
16 | set(val) {
17 | props.context.node.input(val);
18 | }
19 | });
20 |
21 | let options = normalizeOptions(props.context.node.props.options ?? []);
22 |
23 | let OptionComponents = options.map((option: any) => {
24 | return h(ElRadio, {
25 | label: option.__original ?? option.value,
26 | }, () => {
27 | return option.label
28 | })
29 | })
30 |
31 | return () => {
32 | return h(ElRadioGroup, {
33 | modelValue: value.value,
34 | "onUpdate:modelValue": (val: any) => {
35 | value.value = val;
36 | },
37 | onBlur() {
38 | props.context.handlers.blur()
39 | },
40 | ...props.context.attrs
41 | }, () => OptionComponents
42 | );
43 | }
44 | }
45 | });
--------------------------------------------------------------------------------
/src/components/Rate.ts:
--------------------------------------------------------------------------------
1 | import { ElRate } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | const value = computed({
12 | get() {
13 | return props.context.value;
14 | },
15 | set(val) {
16 | props.context.node.input(val);
17 | }
18 | });
19 | return () => {
20 | return h(ElRate, {
21 | modelValue: value.value,
22 | "onUpdate:modelValue": (val: any) => {
23 | value.value = val;
24 | },
25 | ...props.context.attrs
26 | });
27 | }
28 | }
29 | });
--------------------------------------------------------------------------------
/src/components/Select.ts:
--------------------------------------------------------------------------------
1 | import { ElSelect, ElOption } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 | import { normalizeOptions } from "@formkit/inputs";
4 |
5 |
6 | export default defineComponent({
7 | props: ["context"],
8 | setup(props) {
9 | if (props.context.classes.inner == "formkit-inner") {
10 | props.context.classes.inner = "";
11 | }
12 |
13 | const value = computed({
14 | get() {
15 | return props.context.value;
16 | },
17 | set(val) {
18 | props.context.node.input(val);
19 | }
20 | });
21 |
22 | let options = normalizeOptions(props.context.node.props.options ?? []);
23 |
24 | let OptionComponents = options.map((option: any) => {
25 |
26 | if (props.context.slots?.option) {
27 |
28 | return h(ElOption, {
29 | value: option.__original ?? option.value,
30 | }, props.context.slots.option({
31 | item: option
32 | }));
33 |
34 | } else {
35 |
36 | return h(ElOption, {
37 | label: option.label,
38 | value: option.__original ?? option.value
39 | })
40 | }
41 | })
42 |
43 | return () => {
44 | return h(ElSelect, {
45 | modelValue: value.value,
46 | "onUpdate:modelValue": (val: any) => {
47 | value.value = val;
48 | },
49 | onBlur() {
50 | props.context.handlers.blur()
51 | },
52 | ...props.context.attrs
53 | }, () => OptionComponents
54 | );
55 | }
56 | }
57 | });
--------------------------------------------------------------------------------
/src/components/Slider.ts:
--------------------------------------------------------------------------------
1 | import { ElSlider } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | const value = computed({
12 | get() {
13 | return props.context.value;
14 | },
15 | set(val) {
16 | props.context.node.input(val);
17 | }
18 | });
19 | return () => {
20 | return h(ElSlider, {
21 | modelValue: value.value,
22 | "onUpdate:modelValue": (val: any) => {
23 | value.value = val;
24 | },
25 | onBlur() {
26 | props.context.handlers.blur()
27 | },
28 | ...props.context.attrs
29 | });
30 | }
31 | }
32 | });
--------------------------------------------------------------------------------
/src/components/Switch.ts:
--------------------------------------------------------------------------------
1 | import { ElSwitch } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | const value = computed({
12 | get() {
13 | return props.context.value;
14 | },
15 | set(val) {
16 | props.context.node.input(val);
17 | }
18 | });
19 |
20 | return () => {
21 | return h(ElSwitch, {
22 | modelValue: value.value,
23 | "onUpdate:modelValue": (val: any) => {
24 | value.value = val;
25 | },
26 | onBlur() {
27 | props.context.handlers.blur()
28 | },
29 | ...props.context.attrs
30 | });
31 | }
32 | }
33 | });
--------------------------------------------------------------------------------
/src/components/Textarea.ts:
--------------------------------------------------------------------------------
1 | import { ElInput } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | const value = computed({
12 | get() {
13 | return props.context.value;
14 | },
15 | set(val) {
16 | props.context.node.input(val);
17 | }
18 | });
19 |
20 | return () => {
21 | return h(ElInput, {
22 | type: "textarea",
23 | modelValue: value.value,
24 | "onUpdate:modelValue": (val: any) => {
25 | value.value = val;
26 | },
27 | onBlur() {
28 | props.context.handlers.blur()
29 | },
30 | ...props.context.attrs
31 | });
32 | }
33 | }
34 | });
--------------------------------------------------------------------------------
/src/components/TimePicker.ts:
--------------------------------------------------------------------------------
1 | import { ElTimePicker } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | const value = computed({
12 | get() {
13 | return props.context.value;
14 | },
15 | set(val) {
16 | props.context.node.input(val);
17 | }
18 | });
19 | return () => {
20 | return h(ElTimePicker, {
21 | valueFormat: "HH:mm:ss",
22 | modelValue: value.value,
23 | "onUpdate:modelValue": (val: any) => {
24 | value.value = val;
25 | },
26 | onBlur() {
27 | props.context.handlers.blur()
28 | },
29 | ...props.context.attrs
30 | });
31 | }
32 | }
33 | });
--------------------------------------------------------------------------------
/src/components/TimeSelect.ts:
--------------------------------------------------------------------------------
1 | import { ElTimeSelect } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | const value = computed({
12 | get() {
13 | return props.context.value;
14 | },
15 | set(val) {
16 | props.context.node.input(val);
17 | }
18 | });
19 |
20 | return () => {
21 | return h(ElTimeSelect, {
22 | valueFormat: "HH:mm:ss",
23 | modelValue: value.value,
24 | "onUpdate:modelValue": (val: any) => {
25 | value.value = val;
26 | },
27 | onBlur() {
28 | props.context.handlers.blur()
29 | },
30 | ...props.context.attrs
31 | });
32 | }
33 | }
34 | });
--------------------------------------------------------------------------------
/src/components/Transfer.ts:
--------------------------------------------------------------------------------
1 | import { ElTransfer } from 'element-plus';
2 | import { defineComponent, h, computed } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props, { slots }) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | if (props.context.classes.wrapper === "formkit-wrapper") {
12 | props.context.classes.wrapper = "";
13 | }
14 |
15 | const value = computed({
16 | get() {
17 | return props.context.value;
18 | },
19 | set(val) {
20 | props.context.node.input(val);
21 | }
22 | });
23 |
24 |
25 | return () => {
26 | return h(ElTransfer, {
27 | modelValue: value.value,
28 | "onUpdate:modelValue": (val: any) => {
29 | value.value = val;
30 | },
31 | data: props.context.data,
32 | ...props.context.attrs
33 | }, props.context.slots);
34 | }
35 | }
36 | });
--------------------------------------------------------------------------------
/src/components/Tree.ts:
--------------------------------------------------------------------------------
1 | import { ElTree } from 'element-plus';
2 | import { defineComponent, h, computed, ref, watch } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | let tree = ref(null)
12 | watch(() => props.context.value, (val) => {
13 | //set checked keys
14 | (tree as any).value.setCheckedKeys(val);
15 | });
16 |
17 | return () => {
18 | return h(ElTree, {
19 | ref: tree,
20 | defaultCheckedKeys: props.context.value,
21 | onCheckChange() {
22 | let checkedKeys = (tree as any).value.getCheckedKeys();
23 | //filter undefined
24 | checkedKeys = checkedKeys.filter((x: any) => x);
25 | props.context.node.input(checkedKeys);
26 | },
27 | ...props.context.attrs,
28 | showCheckbox: true
29 | });
30 | }
31 | }
32 | });
--------------------------------------------------------------------------------
/src/components/TreeSelect.ts:
--------------------------------------------------------------------------------
1 | import { ElTreeSelect } from 'element-plus';
2 | import { defineComponent, h, computed, ref, watch } from 'vue'
3 |
4 | export default defineComponent({
5 | props: ["context"],
6 | setup(props) {
7 | if (props.context.classes.inner == "formkit-inner") {
8 | props.context.classes.inner = "";
9 | }
10 |
11 | const value = computed({
12 | get() {
13 | return props.context.value;
14 | },
15 | set(val) {
16 | props.context.node.input(val);
17 | }
18 | });
19 |
20 |
21 | return () => {
22 | return h(ElTreeSelect, {
23 | modelValue: value.value,
24 | "onUpdate:modelValue": (val: any) => {
25 | value.value = val;
26 | },
27 | ...props.context.attrs,
28 |
29 | });
30 | }
31 | }
32 | });
--------------------------------------------------------------------------------
/src/components/Upload.ts:
--------------------------------------------------------------------------------
1 | import { defineComponent, h } from 'vue'
2 | import { ElUpload } from 'element-plus';
3 | export default defineComponent({
4 | props: ["context"],
5 | setup(props, { slots }) {
6 | props.context.classes.inner = "";
7 |
8 | let children: any[] = [];
9 | if (slots.default) {
10 | children = slots.default();
11 |
12 | } else {
13 | children = props.context.slots?.default?.() ?? [];
14 | }
15 |
16 | return () => {
17 | return h(ElUpload, {
18 | autoUpload: false,
19 | "modelValue:fileList": props.context.node.value,
20 | "onUpdate:fileList": (val: any) => {
21 | props.context.node.input(val);
22 | },
23 | ...props.context.attrs
24 | }, () => children
25 | )
26 | }
27 |
28 |
29 | },
30 |
31 | })
--------------------------------------------------------------------------------
/src/components/createFormItemInput.ts:
--------------------------------------------------------------------------------
1 |
2 | import { Component, defineComponent, h, ref } from 'vue'
3 | import FormItem from './FormItem.vue';
4 | import { FormKitTypeDefinition } from '@formkit/core';
5 | export default (component: Component, definitionOptions?: Partial): FormKitTypeDefinition => {
6 | return {
7 | type: "input",
8 | props: ["labelWidth", "labelPosition", ...definitionOptions?.props ?? []],
9 | features: definitionOptions?.features ?? [],
10 | component: defineComponent({
11 | props: ["context"],
12 | setup(props, { slots }) {
13 |
14 | return () => {
15 | return h(FormItem, {
16 | context: props.context
17 | }, () => h(component, {
18 | context: {
19 | ...props.context,
20 | ...{ slots: slots }
21 | },
22 | ...props.context.attrs
23 | }))
24 | }
25 | }
26 | })
27 | }
28 | };
--------------------------------------------------------------------------------
/src/components/index.ts:
--------------------------------------------------------------------------------
1 | import { FormKitPlugin } from '@formkit/core';
2 | import { createInput } from '@formkit/vue'
3 |
4 | import Input from './Input'
5 | import Textarea from './Textarea'
6 | import Rate from './Rate'
7 | import Select from "./Select"
8 | import Switch from "./Switch"
9 | import DatePicker from "./DatePicker"
10 | import TimePicker from "./TimePicker"
11 | import ColorPicker from "./ColorPicker"
12 | import Password from "./Password"
13 | import InputNumber from "./InputNumber"
14 | import Checkbox from "./Checkbox"
15 | import Slider from "./Slider"
16 | import TimeSelect from "./TimeSelect"
17 | import RadioGroup from "./RadioGroup"
18 | import Upload from "./Upload"
19 | import Autocomplete from "./Autocomplete"
20 | import Cascader from './Cascader'
21 | import DateRangePicker from './DateRangePicker'
22 | import Transfer from './Transfer'
23 | import CheckboxGroup from './CheckboxGroup';
24 | import Tree from './Tree';
25 | import TreeSelect from './TreeSelect';
26 |
27 | import createFormItemInput from './createFormItemInput';
28 |
29 | import FormItem from "./FormItem.vue"
30 | import Form from './Form.vue'
31 | import FormUpload from './FormUpload'
32 |
33 | import { forms, disablesChildren } from '@formkit/inputs';
34 |
35 | export { FormItem, Form, FormUpload }
36 |
37 | export const createElementPlugin = (): FormKitPlugin => {
38 |
39 | return (node) => {
40 | let type = node.props.type + '';
41 | type = type.replace(/[A-Z]/g, (m: string) => "-" + m.toLowerCase());
42 |
43 | let create: any = createInput;
44 | if (node.props.attrs["form-item"] !== undefined) {
45 | create = createFormItemInput;
46 | }
47 |
48 | switch (type) {
49 | case "el-checkbox-group":
50 | return node.define(create(CheckboxGroup, {
51 | props: ["options"]
52 | }));
53 | case "el-transfer":
54 | return node.define(create(Transfer, {
55 | props: ["data"]
56 | }));
57 | case "el-date-range-picker":
58 | return node.define(create(DateRangePicker));
59 | case "el-cascader":
60 | return node.define(create(Cascader));
61 | case "el-input":
62 | return node.define(create(Input));
63 | case "el-switch":
64 | return node.define(create(Switch));
65 | case "el-textarea":
66 | return node.define(create(Textarea));
67 | case "el-password":
68 | return node.define(create(Password));
69 | case "el-date-picker":
70 | return node.define(create(DatePicker));
71 | case "el-time-picker":
72 | return node.define(create(TimePicker));
73 | case "el-color-picker":
74 | return node.define(create(ColorPicker));
75 | case "el-input-number":
76 | return node.define(create(InputNumber))
77 | case "el-checkbox":
78 | return node.define(create(Checkbox));
79 | case "el-slider":
80 | return node.define(create(Slider));
81 | case "el-time-select":
82 | return node.define(create(TimeSelect));
83 | case "el-upload":
84 | return node.define(create(Upload));
85 | case "el-autocomplete":
86 | return node.define(create(Autocomplete));
87 | case "el-rate":
88 | return node.define(create(Rate));
89 | case "el-select":
90 | return node.define(create(Select, {
91 | props: ["options"],
92 | }));
93 | case "el-radio-group":
94 | return node.define(create(RadioGroup, {
95 | props: ["options"]
96 | }));
97 | case "el-tree":
98 | return node.define(create(Tree));
99 | case "el-tree-select":
100 | return node.define(create(TreeSelect));
101 | case "el-form":
102 | let n = node.define({
103 | type: "group",
104 | component: Form,
105 | props: ["submitLabel", "submit", "labelWidth", "labelPosition", "actions"],
106 | features: [forms, disablesChildren],
107 |
108 | });
109 | return n;
110 | }
111 |
112 |
113 | }
114 |
115 |
116 | };
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import { createApp } from 'vue'
2 | import ElementPlus from 'element-plus'
3 | import 'element-plus/dist/index.css'
4 |
5 |
6 | import App from './App.vue'
7 |
8 | import { plugin, defaultConfig } from '@formkit/vue'
9 | import '@formkit/themes/genesis'
10 |
11 | import * as ElementPlusIconsVue from '@element-plus/icons-vue'
12 |
13 | const app = createApp(App);
14 |
15 |
16 | for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
17 | app.component(key, component)
18 | }
19 |
20 | import { createElementPlugin } from "./components";
21 |
22 |
23 | app.use(ElementPlus)
24 | app.use(plugin, defaultConfig({
25 | plugins: [createElementPlugin()]
26 | }))
27 |
28 | import { createRouter, createWebHistory } from 'vue-router'
29 |
30 | let router = createRouter({
31 | history: createWebHistory(),
32 | routes: [
33 | { path: "/", component: () => import("./pages/index.vue") },
34 | { path: '/input', component: () => import('./pages/input.vue') },
35 | { path: '/select', component: () => import('./pages/select.vue') },
36 | { path: '/upload', component: () => import('./pages/upload.vue') },
37 | { path: '/date', component: () => import('./pages/date.vue') },
38 | { path: '/rate', component: () => import('./pages/rate.vue') },
39 | { path: '/cascader', component: () => import('./pages/cascader.vue') },
40 | { path: '/switch', component: () => import('./pages/switch.vue') },
41 | { path: '/time', component: () => import('./pages/time.vue') },
42 | { path: '/autocomplete', component: () => import('./pages/autocomplete.vue') },
43 | { path: '/form', component: () => import('./pages/form.vue') },
44 | { path: '/transfer', component: () => import('./pages/transfer.vue') },
45 | { path: '/password', component: () => import('./pages/password.vue') },
46 | { path: '/slots', component: () => import('./pages/slots.vue') },
47 | { path: '/tree', component: () => import('./pages/tree.vue') },
48 | { path: '/radio', component: () => import('./pages/radio.vue') },
49 | ],
50 | })
51 |
52 | app.use(router);
53 |
54 |
55 | app.mount('#app')
56 |
--------------------------------------------------------------------------------
/src/pages/autocomplete.vue:
--------------------------------------------------------------------------------
1 |
31 |
32 |
33 |
34 | {{ data }}
35 |
36 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/src/pages/cascader.vue:
--------------------------------------------------------------------------------
1 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
--------------------------------------------------------------------------------
/src/pages/date.vue:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 | {{ data }}
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/pages/form.vue:
--------------------------------------------------------------------------------
1 |
25 |
26 | {{ data1 }}
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | {{ data }}
35 |
36 |
37 |
38 |
39 |
40 |
41 |
45 |
46 |
--------------------------------------------------------------------------------
/src/pages/index.vue:
--------------------------------------------------------------------------------
1 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | Click to upload
60 |
61 |
62 | jpg/png files with a size less than 500KB.
63 |
64 |
65 |
66 |
67 |
68 |
69 |
Change
70 |
71 |
{{ data }}
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
81 |
82 |
84 |
85 |
86 |
87 |
97 |
98 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
135 |
136 |
137 |
138 |
139 |
140 |
150 |
151 |
153 |
154 |
155 |
156 |
157 | Click to upload
158 | only jpg/png files are allowed
159 |
160 |
161 |
162 |
163 |
164 |
165 |
{{ data }}
166 |
167 |
168 |
Component with form Item
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
180 |
182 |
183 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
214 |
215 |
216 |
217 |
219 |
220 |
221 |
222 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
{{ data2 }}
239 |
240 |
241 |
242 |
243 |
244 |
245 |
--------------------------------------------------------------------------------
/src/pages/input.vue:
--------------------------------------------------------------------------------
1 |
26 |
27 |
28 | {{ data }}
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | Change
40 |
41 |
42 |
46 |
47 |
48 |
49 |
50 |
53 |
58 |
--------------------------------------------------------------------------------
/src/pages/password.vue:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
22 |
23 |
24 |
25 |
26 | {{ data }}
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/pages/radio.vue:
--------------------------------------------------------------------------------
1 |
29 |
30 |
31 | {{ data }}
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/pages/rate.vue:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
19 |
20 |
21 |
22 |
23 | {{ data }}
24 |
25 |
--------------------------------------------------------------------------------
/src/pages/select.vue:
--------------------------------------------------------------------------------
1 |
48 |
49 |
50 |
51 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | {{ data }}
76 |
--------------------------------------------------------------------------------
/src/pages/slots.vue:
--------------------------------------------------------------------------------
1 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | custom name
72 |
73 |
74 | abc
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
86 |
87 |
88 | {{ context.option.value }} {{ context.option.label }}
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/src/pages/switch.vue:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | {{ data }}
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/pages/time.vue:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 | {{ data }}
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/pages/transfer.vue:
--------------------------------------------------------------------------------
1 |
20 |
21 |
22 | {{ data }}
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/src/pages/tree.vue:
--------------------------------------------------------------------------------
1 |
49 |
50 | {{ form }}
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/src/pages/upload.vue:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 | {{ data }}
8 |
9 |
10 | select file
11 |
12 |
13 |
14 | select file
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/vite-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare module '*.vue' {
4 | import type { DefineComponent } from 'vue'
5 | const component: DefineComponent<{}, {}, any>
6 | export default component
7 | }
8 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "useDefineForClassFields": true,
5 | "module": "ESNext",
6 | "moduleResolution": "Node",
7 | "strict": true,
8 | "jsx": "preserve",
9 | "sourceMap": true,
10 | "resolveJsonModule": true,
11 | "isolatedModules": true,
12 | "esModuleInterop": true,
13 | "lib": ["ESNext", "DOM"],
14 | "skipLibCheck": true,
15 | "allowJs": true
16 | },
17 | "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "src/components/index.js"],
18 | "references": [{ "path": "./tsconfig.node.json" }]
19 | }
20 |
--------------------------------------------------------------------------------
/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "module": "ESNext",
5 | "moduleResolution": "Node",
6 | "allowSyntheticDefaultImports": true
7 | },
8 | "include": ["vite.config.ts"]
9 | }
10 |
--------------------------------------------------------------------------------
/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import { resolve } from 'path'
3 | import vue from '@vitejs/plugin-vue'
4 |
5 | // https://vitejs.dev/config/
6 | export default defineConfig({
7 | plugins: [vue()],
8 | build: {
9 | lib: {
10 | entry: resolve(__dirname, 'src/components/index.ts'),
11 | name: 'FormkitElement',
12 | fileName: 'formkit-element',
13 | formats: ['es']
14 | },
15 | rollupOptions: {
16 | // make sure to externalize deps that shouldn't be bundled
17 | // into your library
18 | external: ['vue',"@formkit/vue","element-plus"],
19 | output: {
20 | // Provide global variables to use in the UMD build
21 | // for externalized deps
22 | globals: {
23 | vue: 'Vue'
24 | }
25 | }
26 | }
27 | }
28 | })
29 |
--------------------------------------------------------------------------------