init
This commit is contained in:
@@ -0,0 +1,178 @@
|
||||
import { w as withInstall } from "../badge/index2.js";
|
||||
import { defineComponent, ref, computed, watch, resolveComponent, openBlock, createElementBlock, normalizeClass, createVNode, withCtx, createElementVNode, unref, isRef, createBlock } from "vue";
|
||||
var index = /* @__PURE__ */ (() => ".layui-tree-select{width:220px}.layui-tree-select-content{padding:10px}.layui-tree-select .layui-icon-triangle-d{transition:all .3s;-webkit-transition:all .3s;color:var(--global-neutral-color-8)}.layui-tree-select .layui-icon-triangle-d.triangle{transform:rotate(180deg)}\n")();
|
||||
function getNode(root, id) {
|
||||
let resultNode = null;
|
||||
findNode(root, id);
|
||||
function findNode(root2, id2) {
|
||||
if (!!root2) {
|
||||
let type = Object.prototype.toString.call(root2);
|
||||
if (type === "[object Object]") {
|
||||
if (root2.id && root2.id === id2) {
|
||||
resultNode = root2;
|
||||
} else {
|
||||
let node = root2.children || null;
|
||||
findNode(node, id2);
|
||||
}
|
||||
} else if (type === "[object Array]") {
|
||||
let needNode = root2.find((i) => !!i === true && i.id === id2);
|
||||
if (!!needNode) {
|
||||
resultNode = needNode;
|
||||
} else {
|
||||
if (root2.length) {
|
||||
root2.forEach((item) => {
|
||||
if (item && item.children) {
|
||||
let node = item.children;
|
||||
if (node && node.length) {
|
||||
findNode(node, id2);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultNode;
|
||||
}
|
||||
const _hoisted_1 = { class: "layui-tree-select-content" };
|
||||
const __default__ = {
|
||||
name: "LayTreeSelect"
|
||||
};
|
||||
const _sfc_main = defineComponent({
|
||||
...__default__,
|
||||
props: {
|
||||
data: null,
|
||||
modelValue: null,
|
||||
disabled: { type: Boolean, default: false },
|
||||
placeholder: { default: "\u8BF7\u9009\u62E9" },
|
||||
multiple: { type: Boolean, default: false },
|
||||
allowClear: { type: Boolean, default: false },
|
||||
collapseTagsTooltip: { type: Boolean, default: true },
|
||||
minCollapsedNum: { default: 3 },
|
||||
size: { default: "md" },
|
||||
checkStrictly: { type: Boolean, default: true }
|
||||
},
|
||||
emits: ["update:modelValue", "change", "search"],
|
||||
setup(__props, { emit: emits }) {
|
||||
const props = __props;
|
||||
const singleValue = ref();
|
||||
const multipleValue = ref(["1"]);
|
||||
const openState = ref(false);
|
||||
const dropdownRef = ref();
|
||||
const selectedValue = computed({
|
||||
get() {
|
||||
return props.modelValue;
|
||||
},
|
||||
set(value) {
|
||||
emits("update:modelValue", value);
|
||||
emits("change", value);
|
||||
}
|
||||
});
|
||||
const checkedKeys = computed({
|
||||
get() {
|
||||
return props.multiple ? props.modelValue : [];
|
||||
},
|
||||
set(value) {
|
||||
if (props.multiple) {
|
||||
emits("update:modelValue", value);
|
||||
emits("change", value);
|
||||
}
|
||||
}
|
||||
});
|
||||
watch(selectedValue, () => {
|
||||
if (props.multiple) {
|
||||
multipleValue.value = selectedValue.value.map((value) => {
|
||||
const node = getNode(props.data, value);
|
||||
node.label = node.title;
|
||||
node.closable = !node.disabled;
|
||||
return node;
|
||||
});
|
||||
} else {
|
||||
const node = getNode(props.data, selectedValue.value);
|
||||
if (node) {
|
||||
singleValue.value = node.title;
|
||||
}
|
||||
}
|
||||
}, { immediate: true, deep: true });
|
||||
const handleClick = (node) => {
|
||||
dropdownRef.value.hide();
|
||||
selectedValue.value = node.id;
|
||||
};
|
||||
return (_ctx, _cache) => {
|
||||
const _component_lay_icon = resolveComponent("lay-icon");
|
||||
const _component_lay_tag_input = resolveComponent("lay-tag-input");
|
||||
const _component_lay_input = resolveComponent("lay-input");
|
||||
const _component_lay_tree = resolveComponent("lay-tree");
|
||||
const _component_lay_dropdown = resolveComponent("lay-dropdown");
|
||||
return openBlock(), createElementBlock("div", {
|
||||
class: normalizeClass(["layui-tree-select", { "layui-disabled": __props.disabled }])
|
||||
}, [
|
||||
createVNode(_component_lay_dropdown, {
|
||||
ref_key: "dropdownRef",
|
||||
ref: dropdownRef,
|
||||
disabled: __props.disabled,
|
||||
"update-at-scroll": true,
|
||||
onShow: _cache[4] || (_cache[4] = ($event) => openState.value = true),
|
||||
onHide: _cache[5] || (_cache[5] = ($event) => openState.value = false)
|
||||
}, {
|
||||
content: withCtx(() => [
|
||||
createElementVNode("div", _hoisted_1, [
|
||||
createVNode(_component_lay_tree, {
|
||||
data: __props.data,
|
||||
onlyIconControl: true,
|
||||
"show-checkbox": __props.multiple,
|
||||
"check-strictly": __props.checkStrictly,
|
||||
selectedKey: unref(selectedValue),
|
||||
"onUpdate:selectedKey": _cache[2] || (_cache[2] = ($event) => isRef(selectedValue) ? selectedValue.value = $event : null),
|
||||
checkedKeys: unref(checkedKeys),
|
||||
"onUpdate:checkedKeys": _cache[3] || (_cache[3] = ($event) => isRef(checkedKeys) ? checkedKeys.value = $event : null),
|
||||
onNodeClick: handleClick
|
||||
}, null, 8, ["data", "show-checkbox", "check-strictly", "selectedKey", "checkedKeys"])
|
||||
])
|
||||
]),
|
||||
default: withCtx(() => [
|
||||
__props.multiple ? (openBlock(), createBlock(_component_lay_tag_input, {
|
||||
key: 0,
|
||||
size: __props.size,
|
||||
"allow-clear": __props.allowClear,
|
||||
placeholder: __props.placeholder,
|
||||
collapseTagsTooltip: __props.collapseTagsTooltip,
|
||||
minCollapsedNum: __props.minCollapsedNum,
|
||||
disabledInput: true,
|
||||
modelValue: multipleValue.value,
|
||||
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => multipleValue.value = $event)
|
||||
}, {
|
||||
suffix: withCtx(() => [
|
||||
createVNode(_component_lay_icon, {
|
||||
type: "layui-icon-triangle-d",
|
||||
class: normalizeClass({ triangle: openState.value })
|
||||
}, null, 8, ["class"])
|
||||
]),
|
||||
_: 1
|
||||
}, 8, ["size", "allow-clear", "placeholder", "collapseTagsTooltip", "minCollapsedNum", "modelValue"])) : (openBlock(), createBlock(_component_lay_input, {
|
||||
key: 1,
|
||||
modelValue: singleValue.value,
|
||||
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => singleValue.value = $event),
|
||||
placeholder: __props.placeholder,
|
||||
disabled: __props.disabled,
|
||||
readonly: true,
|
||||
size: __props.size
|
||||
}, {
|
||||
suffix: withCtx(() => [
|
||||
createVNode(_component_lay_icon, {
|
||||
type: "layui-icon-triangle-d",
|
||||
class: normalizeClass({ triangle: openState.value })
|
||||
}, null, 8, ["class"])
|
||||
]),
|
||||
_: 1
|
||||
}, 8, ["modelValue", "placeholder", "disabled", "size"]))
|
||||
]),
|
||||
_: 1
|
||||
}, 8, ["disabled"])
|
||||
], 2);
|
||||
};
|
||||
}
|
||||
});
|
||||
const component = withInstall(_sfc_main);
|
||||
export { component as default };
|
||||
Binary file not shown.
@@ -0,0 +1,38 @@
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: "LayIcon",
|
||||
};
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
|
||||
export interface LayIconProps {
|
||||
size?: string;
|
||||
type?: string;
|
||||
color?: string;
|
||||
prefix?: string;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<LayIconProps>(), {
|
||||
prefix: "layui-icon",
|
||||
});
|
||||
|
||||
const styles = computed(() => {
|
||||
return {
|
||||
color: props.color,
|
||||
fontSize: props.size,
|
||||
};
|
||||
});
|
||||
|
||||
const classes = computed(() => {
|
||||
return {
|
||||
type: props.type,
|
||||
prefix: props.prefix,
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<i :class="[prefix, type]" :style="styles" />
|
||||
</template>
|
||||
@@ -0,0 +1,16 @@
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: "SeniorIcon",
|
||||
};
|
||||
</script>
|
||||
<script setup lang="ts">
|
||||
import LayIcon from "../component/icon/index";
|
||||
|
||||
const props = defineProps<{
|
||||
color?: string;
|
||||
size?: string;
|
||||
}>();
|
||||
</script>
|
||||
<template>
|
||||
<lay-icon :color="props.color" :size="props.size" type="layui-icon-senior" />
|
||||
</template>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,105 @@
|
||||
<template>
|
||||
<div class="contributor">
|
||||
<lay-tooltip
|
||||
:content="contributor.login"
|
||||
v-for="contributor in contributors"
|
||||
:key="contributor.id"
|
||||
:is-dark="false"
|
||||
>
|
||||
<a :href="contributor.htmlUrl" target="_blank">
|
||||
<lay-avatar :src="contributor.avatarUrl" radius></lay-avatar>
|
||||
</a>
|
||||
</lay-tooltip>
|
||||
</div>
|
||||
<lay-tooltip content="在线编辑" :is-dark="false">
|
||||
<a
|
||||
class="online-edit"
|
||||
:href="
|
||||
'https://github.com/layui/layui-vue/edit/next/package/document-component/src/document/zh-CN/components/' +
|
||||
filePath +
|
||||
'.md'
|
||||
"
|
||||
target="_blank"
|
||||
>
|
||||
<lay-icon type="layui-icon-edit"></lay-icon>
|
||||
</a>
|
||||
</lay-tooltip>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import axios from "axios";
|
||||
import { Ref, ref } from "vue";
|
||||
|
||||
export interface LayContributor {
|
||||
filePath: string;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<LayContributor>(), {
|
||||
filePath: "",
|
||||
});
|
||||
|
||||
const suffix = ".md";
|
||||
const githubAPI =
|
||||
"https://api.github.com/repos/layui/layui-vue/commits?path=/package/document-component/src/document/zh-CN/components/";
|
||||
const contributors: Ref<any> = ref([]);
|
||||
|
||||
var compare = function (x: any, y: any) {
|
||||
if (x.commits < y.commits) {
|
||||
return 1;
|
||||
} else if (x.commits > y.commits) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
const fetchContributors = () => {
|
||||
axios.get(githubAPI + props.filePath + suffix).then((result) => {
|
||||
const topic: any[] = [];
|
||||
result.data.forEach((item: any) => {
|
||||
if (item.committer) {
|
||||
const itemdata = {
|
||||
id: item.committer["id"],
|
||||
login: item.committer["login"],
|
||||
avatarUrl: item.committer["avatar_url"],
|
||||
htmlUrl: item.committer["html_url"],
|
||||
commits: 1,
|
||||
};
|
||||
if (topic.some((e) => e.id == itemdata.id)) {
|
||||
topic.forEach((item) => {
|
||||
if (item.id === itemdata.id) {
|
||||
item.commits = item.commits + 1;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
topic.push(itemdata);
|
||||
}
|
||||
}
|
||||
});
|
||||
contributors.value = topic.sort(compare);
|
||||
});
|
||||
};
|
||||
|
||||
fetchContributors();
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.contributor {
|
||||
text-align: left;
|
||||
margin: 30px 15px 30px 20px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.contributor a {
|
||||
height: 40px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.contributor span {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.online-edit {
|
||||
display: inline-block;
|
||||
}
|
||||
</style>
|
||||
Binary file not shown.
Reference in New Issue
Block a user