origam 0.3.6 → 0.3.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/dist/components/index.d.ts +0 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/composables/Commons/hotkey.composable.d.ts.map +1 -1
- package/dist/composables/index.d.ts +2 -2
- package/dist/composables/index.d.ts.map +1 -1
- package/dist/consts/Commons/hotkey.const.d.ts.map +1 -1
- package/dist/consts/index.d.ts +1 -1
- package/dist/consts/index.d.ts.map +1 -1
- package/dist/interfaces/index.d.ts +0 -2
- package/dist/interfaces/index.d.ts.map +1 -1
- package/dist/src/App.vue +3 -3
- package/dist/src/components/index.cjs +0 -11
- package/dist/src/components/index.d.ts +0 -1
- package/dist/src/components/index.js +0 -1
- package/dist/src/composables/Commons/border.composable.spec.cjs +1 -1
- package/dist/src/composables/Commons/border.composable.spec.js +1 -1
- package/dist/src/composables/Commons/hotkey.composable.cjs +3 -4
- package/dist/src/composables/Commons/hotkey.composable.js +1 -2
- package/dist/src/composables/index.cjs +12 -12
- package/dist/src/composables/index.d.ts +2 -2
- package/dist/src/composables/index.js +2 -2
- package/dist/src/consts/Commons/hotkey.const.cjs +0 -1
- package/dist/src/consts/Commons/hotkey.const.js +0 -1
- package/dist/src/consts/index.cjs +11 -11
- package/dist/src/consts/index.d.ts +1 -1
- package/dist/src/consts/index.js +1 -1
- package/dist/src/interfaces/index.cjs +0 -22
- package/dist/src/interfaces/index.d.ts +0 -2
- package/dist/src/interfaces/index.js +0 -2
- package/dist/src/types/index.cjs +0 -11
- package/dist/src/types/index.d.ts +0 -1
- package/dist/src/types/index.js +0 -1
- package/dist/src/utils/Commons/hotkey.util.cjs +2 -2
- package/dist/src/utils/Commons/hotkey.util.js +1 -1
- package/dist/src/utils/index.cjs +0 -11
- package/dist/src/utils/index.d.ts +0 -1
- package/dist/src/utils/index.js +0 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/src/components/PageBuilder/OrigamCssBox.vue +0 -267
- package/dist/src/components/PageBuilder/OrigamEditWrapper.vue +0 -57
- package/dist/src/components/PageBuilder/OrigamPageBuilder.vue +0 -34
- package/dist/src/components/PageBuilder/index.cjs +0 -27
- package/dist/src/components/PageBuilder/index.d.ts +0 -3
- package/dist/src/components/PageBuilder/index.js +0 -3
- package/dist/src/composables/PageBuilder/editor.composable.cjs +0 -40
- package/dist/src/composables/PageBuilder/editor.composable.d.ts +0 -18
- package/dist/src/composables/PageBuilder/editor.composable.js +0 -33
- package/dist/src/consts/PageBuilder/edit.const.cjs +0 -17
- package/dist/src/consts/PageBuilder/edit.const.d.ts +0 -4
- package/dist/src/consts/PageBuilder/edit.const.js +0 -11
- package/dist/src/interfaces/PageBuilder/cssBox.interface.cjs +0 -1
- package/dist/src/interfaces/PageBuilder/cssBox.interface.d.ts +0 -3
- package/dist/src/interfaces/PageBuilder/cssBox.interface.js +0 -0
- package/dist/src/interfaces/PageBuilder/editWrapper.interface.cjs +0 -1
- package/dist/src/interfaces/PageBuilder/editWrapper.interface.d.ts +0 -16
- package/dist/src/interfaces/PageBuilder/editWrapper.interface.js +0 -0
- package/dist/src/types/PageBuilder/editor.type.cjs +0 -1
- package/dist/src/types/PageBuilder/editor.type.d.ts +0 -10
- package/dist/src/types/PageBuilder/editor.type.js +0 -0
- package/dist/src/utils/PageBuilder/editor.util.cjs +0 -79
- package/dist/src/utils/PageBuilder/editor.util.d.ts +0 -4
- package/dist/src/utils/PageBuilder/editor.util.js +0 -71
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
:class="editWrapperClasses"
|
|
4
|
-
:style="editWrapperStyles"
|
|
5
|
-
>
|
|
6
|
-
<div class="origam-edit-wrapper__wrapper">
|
|
7
|
-
<slot name="default"/>
|
|
8
|
-
</div>
|
|
9
|
-
</div>
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<script setup>
|
|
13
|
-
import { computed, ref, StyleValue, useSlots, watch } from "vue";
|
|
14
|
-
import { useProps } from "../../composables";
|
|
15
|
-
import { scanForAutoProps } from "../../utils";
|
|
16
|
-
const props = defineProps({
|
|
17
|
-
slotName: { type: String, required: false, default: "default" },
|
|
18
|
-
autoDetectProps: { type: Boolean, required: false, default: true },
|
|
19
|
-
id: { type: String, required: false },
|
|
20
|
-
class: { type: [String, Array, Object], required: false },
|
|
21
|
-
style: { type: [String, Array, Object, Boolean, null], required: false, skipCheck: true }
|
|
22
|
-
});
|
|
23
|
-
const { filterProps } = useProps(props);
|
|
24
|
-
const slots = useSlots();
|
|
25
|
-
const vnodes = ref([]);
|
|
26
|
-
watch(() => props, () => {
|
|
27
|
-
if (typeof slots[props.slotName] !== "undefined") {
|
|
28
|
-
vnodes.value = slots[props.slotName]();
|
|
29
|
-
}
|
|
30
|
-
if (slots[props.slotName] && props.autoDetectProps && vnodes) {
|
|
31
|
-
const _propsTypes = scanForAutoProps(vnodes.value);
|
|
32
|
-
console.log(_propsTypes);
|
|
33
|
-
}
|
|
34
|
-
}, {
|
|
35
|
-
immediate: true
|
|
36
|
-
});
|
|
37
|
-
const editWrapperStyles = computed(() => {
|
|
38
|
-
return [
|
|
39
|
-
props.style
|
|
40
|
-
];
|
|
41
|
-
});
|
|
42
|
-
const editWrapperClasses = computed(() => {
|
|
43
|
-
return [
|
|
44
|
-
"origam-edit-wrapper",
|
|
45
|
-
props.class
|
|
46
|
-
];
|
|
47
|
-
});
|
|
48
|
-
defineExpose({
|
|
49
|
-
filterProps
|
|
50
|
-
});
|
|
51
|
-
</script>
|
|
52
|
-
|
|
53
|
-
<style>
|
|
54
|
-
:root {
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
</style>
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<origam-layout
|
|
3
|
-
ref="pageBuilderRef"
|
|
4
|
-
:class="pageBuilderClasses"
|
|
5
|
-
:style="pageBuilderStyles"
|
|
6
|
-
>
|
|
7
|
-
<template #default>
|
|
8
|
-
<slot name="default"/>
|
|
9
|
-
</template>
|
|
10
|
-
</origam-layout>
|
|
11
|
-
</template>
|
|
12
|
-
|
|
13
|
-
<script setup>
|
|
14
|
-
import { computed, StyleValue } from "vue";
|
|
15
|
-
import { OrigamLayout } from "../../components";
|
|
16
|
-
import { useProps } from "../../composables";
|
|
17
|
-
const props = defineProps({
|
|
18
|
-
overlaps: { type: Array, required: false },
|
|
19
|
-
fullHeight: { type: Boolean, required: false, default: true },
|
|
20
|
-
id: { type: String, required: false },
|
|
21
|
-
class: { type: [String, Array, Object], required: false },
|
|
22
|
-
style: { type: [String, Array, Object, Boolean, null], required: false, skipCheck: true }
|
|
23
|
-
});
|
|
24
|
-
const { filterProps } = useProps(props);
|
|
25
|
-
const pageBuilderStyles = computed(() => {
|
|
26
|
-
return [props.style];
|
|
27
|
-
});
|
|
28
|
-
const pageBuilderClasses = computed(() => {
|
|
29
|
-
return ["origam-page-builder", props.class];
|
|
30
|
-
});
|
|
31
|
-
defineExpose({
|
|
32
|
-
filterProps
|
|
33
|
-
});
|
|
34
|
-
</script>
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "OrigamCssBox", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _OrigamCssBox.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "OrigamEditWrapper", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _OrigamEditWrapper.default;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "OrigamPageBuilder", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _OrigamPageBuilder.default;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
var _OrigamPageBuilder = _interopRequireDefault(require("./OrigamPageBuilder.vue"));
|
|
25
|
-
var _OrigamCssBox = _interopRequireDefault(require("./OrigamCssBox.vue"));
|
|
26
|
-
var _OrigamEditWrapper = _interopRequireDefault(require("./OrigamEditWrapper.vue"));
|
|
27
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createEditor = createEditor;
|
|
7
|
-
exports.useEditor = useEditor;
|
|
8
|
-
var _vue = require("vue");
|
|
9
|
-
var _composables = require("../../composables/index.cjs");
|
|
10
|
-
var _consts = require("../../consts/index.cjs");
|
|
11
|
-
var _utils = require("../../utils/index.cjs");
|
|
12
|
-
function createEditor(props, name = (0, _utils.getCurrentInstanceName)()) {
|
|
13
|
-
const children = (0, _vue.ref)(/* @__PURE__ */new Map());
|
|
14
|
-
const parents = (0, _vue.ref)(/* @__PURE__ */new Map());
|
|
15
|
-
const edit = (0, _composables.useVModel)(props, "edit", props.edit, v => new Set(v), v => [...v.values()]);
|
|
16
|
-
const lock = (0, _composables.useVModel)(props, "lock", props.lock, v => new Set(v), v => [...v.values()]);
|
|
17
|
-
const editor = {
|
|
18
|
-
id: (0, _vue.ref)(name),
|
|
19
|
-
root: {
|
|
20
|
-
edit,
|
|
21
|
-
lock,
|
|
22
|
-
children,
|
|
23
|
-
parents
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
(0, _vue.provide)(_consts.ORIGAM_EDIT_KEY, editor);
|
|
27
|
-
return editor.root;
|
|
28
|
-
}
|
|
29
|
-
function useEditor(props) {
|
|
30
|
-
const parent = (0, _vue.inject)(_consts.ORIGAM_EDIT_KEY, _consts.EMPTY_EDIT);
|
|
31
|
-
const uidSymbol = Symbol((0, _utils.getUid)());
|
|
32
|
-
const computedId = (0, _vue.computed)(() => uidSymbol);
|
|
33
|
-
return {
|
|
34
|
-
...parent,
|
|
35
|
-
id: computedId,
|
|
36
|
-
props,
|
|
37
|
-
isEdited: (0, _vue.computed)(() => parent.root.edit.value.has(computedId.value)),
|
|
38
|
-
isLocked: (0, _vue.computed)(() => parent.root.lock.value.has(computedId.value))
|
|
39
|
-
};
|
|
40
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare function createEditor(props: any, name?: string): {
|
|
2
|
-
children: import("vue").Ref<Map<unknown, Array<unknown>>>;
|
|
3
|
-
parents: import("vue").Ref<Map<unknown, unknown>>;
|
|
4
|
-
edit: import("vue").Ref<Set<unknown>>;
|
|
5
|
-
lock: import("vue").Ref<Set<unknown>>;
|
|
6
|
-
};
|
|
7
|
-
export declare function useEditor(props: any): {
|
|
8
|
-
id: import("vue").ComputedRef<symbol>;
|
|
9
|
-
props: any;
|
|
10
|
-
isEdited: import("vue").ComputedRef<boolean>;
|
|
11
|
-
isLocked: import("vue").ComputedRef<boolean>;
|
|
12
|
-
root: {
|
|
13
|
-
children: import("vue").Ref<Map<unknown, Array<unknown>>>;
|
|
14
|
-
parents: import("vue").Ref<Map<unknown, unknown>>;
|
|
15
|
-
edit: import("vue").Ref<Set<unknown>>;
|
|
16
|
-
lock: import("vue").Ref<Set<unknown>>;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { computed, inject, provide, ref } from "vue";
|
|
2
|
-
import { useVModel } from "../../composables/index.js";
|
|
3
|
-
import { EMPTY_EDIT, ORIGAM_EDIT_KEY } from "../../consts/index.js";
|
|
4
|
-
import { getCurrentInstanceName, getUid } from "../../utils/index.js";
|
|
5
|
-
export function createEditor(props, name = getCurrentInstanceName()) {
|
|
6
|
-
const children = ref(/* @__PURE__ */ new Map());
|
|
7
|
-
const parents = ref(/* @__PURE__ */ new Map());
|
|
8
|
-
const edit = useVModel(props, "edit", props.edit, (v) => new Set(v), (v) => [...v.values()]);
|
|
9
|
-
const lock = useVModel(props, "lock", props.lock, (v) => new Set(v), (v) => [...v.values()]);
|
|
10
|
-
const editor = {
|
|
11
|
-
id: ref(name),
|
|
12
|
-
root: {
|
|
13
|
-
edit,
|
|
14
|
-
lock,
|
|
15
|
-
children,
|
|
16
|
-
parents
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
provide(ORIGAM_EDIT_KEY, editor);
|
|
20
|
-
return editor.root;
|
|
21
|
-
}
|
|
22
|
-
export function useEditor(props) {
|
|
23
|
-
const parent = inject(ORIGAM_EDIT_KEY, EMPTY_EDIT);
|
|
24
|
-
const uidSymbol = Symbol(getUid());
|
|
25
|
-
const computedId = computed(() => uidSymbol);
|
|
26
|
-
return {
|
|
27
|
-
...parent,
|
|
28
|
-
id: computedId,
|
|
29
|
-
props,
|
|
30
|
-
isEdited: computed(() => parent.root.edit.value.has(computedId.value)),
|
|
31
|
-
isLocked: computed(() => parent.root.lock.value.has(computedId.value))
|
|
32
|
-
};
|
|
33
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ORIGAM_EDIT_KEY = exports.EMPTY_EDIT = void 0;
|
|
7
|
-
var _vue = require("vue");
|
|
8
|
-
const ORIGAM_EDIT_KEY = exports.ORIGAM_EDIT_KEY = Symbol.for("origam:editor");
|
|
9
|
-
const EMPTY_EDIT = exports.EMPTY_EDIT = {
|
|
10
|
-
id: (0, _vue.shallowRef)(),
|
|
11
|
-
root: {
|
|
12
|
-
parents: (0, _vue.ref)(/* @__PURE__ */new Map()),
|
|
13
|
-
children: (0, _vue.ref)(/* @__PURE__ */new Map()),
|
|
14
|
-
edit: (0, _vue.ref)(/* @__PURE__ */new Set()),
|
|
15
|
-
lock: (0, _vue.ref)(/* @__PURE__ */new Set())
|
|
16
|
-
}
|
|
17
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ref, shallowRef } from "vue";
|
|
2
|
-
export const ORIGAM_EDIT_KEY = Symbol.for("origam:editor");
|
|
3
|
-
export const EMPTY_EDIT = {
|
|
4
|
-
id: shallowRef(),
|
|
5
|
-
root: {
|
|
6
|
-
parents: ref(/* @__PURE__ */ new Map()),
|
|
7
|
-
children: ref(/* @__PURE__ */ new Map()),
|
|
8
|
-
edit: ref(/* @__PURE__ */ new Set()),
|
|
9
|
-
lock: ref(/* @__PURE__ */ new Set())
|
|
10
|
-
}
|
|
11
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ICommonsComponentProps } from '../../interfaces';
|
|
2
|
-
export interface IEditWrapperProps extends ICommonsComponentProps {
|
|
3
|
-
slotName?: string;
|
|
4
|
-
autoDetectProps?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface IAutoPropComponentDefinition {
|
|
7
|
-
name: string;
|
|
8
|
-
index: number;
|
|
9
|
-
props: Array<IPropDefinition>;
|
|
10
|
-
}
|
|
11
|
-
export interface IPropDefinition {
|
|
12
|
-
name: string;
|
|
13
|
-
types?: string[];
|
|
14
|
-
required?: boolean;
|
|
15
|
-
default?: any;
|
|
16
|
-
}
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
File without changes
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getNameFromFile = getNameFromFile;
|
|
7
|
-
exports.getTagName = getTagName;
|
|
8
|
-
exports.scanForAutoProps = scanForAutoProps;
|
|
9
|
-
var _changeCase = require("change-case");
|
|
10
|
-
function getNameFromFile(file) {
|
|
11
|
-
const parts = /([^/]+)\.vue$/.exec(file);
|
|
12
|
-
if (parts) {
|
|
13
|
-
return (0, _changeCase.pascalCase)(parts[1]);
|
|
14
|
-
}
|
|
15
|
-
return "Anonymous";
|
|
16
|
-
}
|
|
17
|
-
function getTagName(vnode) {
|
|
18
|
-
if (typeof vnode.type === "string") {
|
|
19
|
-
return vnode.type;
|
|
20
|
-
} else if (vnode.type?.__asyncResolved) {
|
|
21
|
-
const asyncComp = vnode.type?.__asyncResolved;
|
|
22
|
-
return asyncComp.name ?? getNameFromFile(asyncComp.__file);
|
|
23
|
-
} else if (vnode.type?.name) {
|
|
24
|
-
return vnode.type.name;
|
|
25
|
-
} else if (vnode.type?.__file) {
|
|
26
|
-
return getNameFromFile(vnode.type.__file);
|
|
27
|
-
}
|
|
28
|
-
return "Anonymous";
|
|
29
|
-
}
|
|
30
|
-
function scanForAutoProps(vnodes) {
|
|
31
|
-
const result = [];
|
|
32
|
-
let index = 0;
|
|
33
|
-
for (const vnode of vnodes) {
|
|
34
|
-
if (typeof vnode.type === "object") {
|
|
35
|
-
const propDefs = [];
|
|
36
|
-
for (const key in vnode.type.props) {
|
|
37
|
-
const prop = vnode.type.props[key];
|
|
38
|
-
let types;
|
|
39
|
-
let defaultValue;
|
|
40
|
-
if (prop) {
|
|
41
|
-
const rawTypes = Array.isArray(prop.type) ? prop.type : typeof prop === "function" ? [prop] : [prop.type];
|
|
42
|
-
types = rawTypes.map(t => {
|
|
43
|
-
switch (t) {
|
|
44
|
-
case String:
|
|
45
|
-
return "string";
|
|
46
|
-
case Number:
|
|
47
|
-
return "number";
|
|
48
|
-
case Boolean:
|
|
49
|
-
return "boolean";
|
|
50
|
-
case Object:
|
|
51
|
-
return "object";
|
|
52
|
-
case Array:
|
|
53
|
-
return "array";
|
|
54
|
-
default:
|
|
55
|
-
return "unknown";
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
defaultValue = typeof prop.default === "function" ? prop.default.toString() : prop.default;
|
|
59
|
-
}
|
|
60
|
-
propDefs.push({
|
|
61
|
-
name: key,
|
|
62
|
-
types,
|
|
63
|
-
required: prop?.required,
|
|
64
|
-
default: defaultValue
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
result.push({
|
|
68
|
-
name: getTagName(vnode),
|
|
69
|
-
index,
|
|
70
|
-
props: propDefs
|
|
71
|
-
});
|
|
72
|
-
index++;
|
|
73
|
-
}
|
|
74
|
-
if (Array.isArray(vnode.children)) {
|
|
75
|
-
result.push(...scanForAutoProps(vnode.children));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return result.filter(def => def.props.length);
|
|
79
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { pascalCase } from "change-case";
|
|
2
|
-
export function getNameFromFile(file) {
|
|
3
|
-
const parts = /([^/]+)\.vue$/.exec(file);
|
|
4
|
-
if (parts) {
|
|
5
|
-
return pascalCase(parts[1]);
|
|
6
|
-
}
|
|
7
|
-
return "Anonymous";
|
|
8
|
-
}
|
|
9
|
-
export function getTagName(vnode) {
|
|
10
|
-
if (typeof vnode.type === "string") {
|
|
11
|
-
return vnode.type;
|
|
12
|
-
} else if (vnode.type?.__asyncResolved) {
|
|
13
|
-
const asyncComp = vnode.type?.__asyncResolved;
|
|
14
|
-
return asyncComp.name ?? getNameFromFile(asyncComp.__file);
|
|
15
|
-
} else if (vnode.type?.name) {
|
|
16
|
-
return vnode.type.name;
|
|
17
|
-
} else if (vnode.type?.__file) {
|
|
18
|
-
return getNameFromFile(vnode.type.__file);
|
|
19
|
-
}
|
|
20
|
-
return "Anonymous";
|
|
21
|
-
}
|
|
22
|
-
export function scanForAutoProps(vnodes) {
|
|
23
|
-
const result = [];
|
|
24
|
-
let index = 0;
|
|
25
|
-
for (const vnode of vnodes) {
|
|
26
|
-
if (typeof vnode.type === "object") {
|
|
27
|
-
const propDefs = [];
|
|
28
|
-
for (const key in vnode.type.props) {
|
|
29
|
-
const prop = vnode.type.props[key];
|
|
30
|
-
let types;
|
|
31
|
-
let defaultValue;
|
|
32
|
-
if (prop) {
|
|
33
|
-
const rawTypes = Array.isArray(prop.type) ? prop.type : typeof prop === "function" ? [prop] : [prop.type];
|
|
34
|
-
types = rawTypes.map((t) => {
|
|
35
|
-
switch (t) {
|
|
36
|
-
case String:
|
|
37
|
-
return "string";
|
|
38
|
-
case Number:
|
|
39
|
-
return "number";
|
|
40
|
-
case Boolean:
|
|
41
|
-
return "boolean";
|
|
42
|
-
case Object:
|
|
43
|
-
return "object";
|
|
44
|
-
case Array:
|
|
45
|
-
return "array";
|
|
46
|
-
default:
|
|
47
|
-
return "unknown";
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
defaultValue = typeof prop.default === "function" ? prop.default.toString() : prop.default;
|
|
51
|
-
}
|
|
52
|
-
propDefs.push({
|
|
53
|
-
name: key,
|
|
54
|
-
types,
|
|
55
|
-
required: prop?.required,
|
|
56
|
-
default: defaultValue
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
result.push({
|
|
60
|
-
name: getTagName(vnode),
|
|
61
|
-
index,
|
|
62
|
-
props: propDefs
|
|
63
|
-
});
|
|
64
|
-
index++;
|
|
65
|
-
}
|
|
66
|
-
if (Array.isArray(vnode.children)) {
|
|
67
|
-
result.push(...scanForAutoProps(vnode.children));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return result.filter((def) => def.props.length);
|
|
71
|
-
}
|