!14 步骤条组件封装

Merge pull request !14 from 莫名点/develop
This commit is contained in:
就眠儀式 2022-01-04 10:23:20 +00:00 committed by Gitee
commit 8d7c625ff8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
11 changed files with 1235 additions and 421 deletions

View File

@ -0,0 +1,384 @@
::: anchor
:::
::: title 基础使用
:::
::: demo
<template>
<div>
<lay-step :active="active">
<lay-step-item></lay-step-item>
<lay-step-item></lay-step-item>
<lay-step-item></lay-step-item>
<lay-step-item></lay-step-item>
</lay-step>
<lay-button size="xs" @click="nexts">下一步</lay-button>
<lay-button size="xs" @click="previous">上一步</lay-button>
</div>
</template>
<script>
import { ref } from 'vue';
export default {
setup() {
const loading = ref(true);
const active = ref(-1);
const nexts = () => {
if (active.value++ >=3) active.value = 0
};
const previous = () => {
if (active.value-- ===0) active.value = 0
};
return {
loading,
active
}
}
}
</script>
:::
::: title 带标题带描述
:::
::: demo
<template>
<div>
<lay-step :active="active">
<lay-step-item title="First" content="First step"></lay-step-item>
<lay-step-item title="Second" content="Second step"></lay-step-item>
<lay-step-item title="Third" content="Third step"></lay-step-item>
<lay-step-item title="Fourth" content="Fourth step"></lay-step-item>
</lay-step>
</div>
</template>
<script>
import { ref } from 'vue';
export default {
setup() {
const loading = ref(true);
const active = ref(-1);
const nexts = () => {
if (active.value++ >=3) active.value = 0
};
const previous = () => {
if (active.value-- ===0) active.value = 0
};
return {
loading,
active
}
}
}
</script>
:::
::: title 设置当前选中状态
:::
::: demo
<template>
<div>
<lay-step :active="active" current-status="primary">
<lay-step-item title="First" content="First step"></lay-step-item>
<lay-step-item title="Second" content="Second step"></lay-step-item>
<lay-step-item title="Third" content="Third step"></lay-step-item>
</lay-step>
<lay-button size="xs" @click="next">下一步</lay-button>
<lay-button size="xs" @click="previous">上一步</lay-button>
</div>
</template>
<script>
import { ref } from 'vue';
export default {
setup() {
const loading = ref(true);
const active = ref(-1);
const next = () => {
if (active.value++ >=2) active.value = 0
};
const previous = () => {
if (active.value-- ===0) active.value = 0
};
return {
loading,
active
}
}
}
</script>
:::
::: title 设置第几步状态
:::
这里设置`status` 会覆盖掉`current-status`
::: demo
<template>
<div>
<lay-step :active="active" current-status="warning">
<lay-step-item title="First" content="First step"></lay-step-item>
<lay-step-item status="fail" title="Second" content="Second step"></lay-step-item>
<lay-step-item title="Third" content="Third step"></lay-step-item>
<lay-step-item title="Fourth" content="Fourth step"></lay-step-item>
</lay-step>
<lay-button size="xs" @click="nexts">下一步</lay-button>
<lay-button size="xs" @click="previous">上一步</lay-button>
</div>
</template>
<script>
import { ref } from 'vue';
export default {
setup() {
const loading = ref(true);
const active = ref(-1);
const nexts = () => {
if (active.value++ >=3) active.value = 0
};
const previous = () => {
if (active.value-- ===0) active.value = 0
};
return {
loading,
active
}
}
}
</script>
:::
::: title 自定义宽度
:::
::: demo
<template>
<div>
<lay-step :active="active" space="200px">
<lay-step-item title="First" content="First step"></lay-step-item>
<lay-step-item title="Second" content="Second step"></lay-step-item>
<lay-step-item title="Third" content="Third step"></lay-step-item>
</lay-step>
<lay-button size="xs" @click="next">下一步</lay-button>
<lay-button size="xs" @click="previous">上一步</lay-button>
</div>
</template>
<script>
import { ref } from 'vue';
export default {
setup() {
const loading = ref(true);
const active = ref(-1);
const next = () => {
if (active.value++ >=2) active.value = 0
};
const previous = () => {
if (active.value-- ===0) active.value = 0
};
return {
loading,
active
}
}
}
</script>
:::
::: title 自定义图标
:::
::: demo
<template>
<div>
<lay-step :active="active">
<lay-step-item title="First" content="First step" icon="layui-icon-release"></lay-step-item>
<lay-step-item title="Second" content="Second step" icon="layui-icon-tree"></lay-step-item>
<lay-step-item title="Third" content="Third step" icon="layui-icon-share"></lay-step-item>
</lay-step>
<lay-button size="xs" @click="next">下一步</lay-button>
<lay-button size="xs" @click="previous">上一步</lay-button>
</div>
</template>
<script>
import { ref } from 'vue';
export default {
setup() {
const loading = ref(true);
const active = ref(-1);
const next = () => {
if (active.value++ >=2) active.value = 0
};
const previous = () => {
if (active.value-- ===0) active.value = 0
};
return {
loading,
active
}
}
}
</script>
:::
::: title 居中
:::
::: demo
<template>
<div>
<lay-step :active="active" center>
<lay-step-item title="First" content="First step">
<template #pace>
<lay-icon type="layui-icon-ok"></lay-icon>
</template>
</lay-step-item>
<lay-step-item title="Second" content="Second step"></lay-step-item>
<lay-step-item title="Third" content="Third step"></lay-step-item>
</lay-step>
<lay-button size="xs" @click="next">下一步</lay-button>
<lay-button size="xs" @click="previous">上一步</lay-button>
</div>
</template>
<script>
import { ref } from 'vue';
export default {
setup() {
const loading = ref(true);
const active = ref(-1);
const next = () => {
if (active.value++ >=2) active.value = 0
};
const previous = () => {
if (active.value-- ===0) active.value = 0
};
return {
loading,
active
}
}
}
</script>
:::
::: title 垂直
:::
::: demo
<template>
<div style="height: 300px">
<lay-step :active="active" direction="vertical">
<lay-step-item title="First" content="First step">
<template #pace>
<lay-icon type="layui-icon-ok"></lay-icon>
</template>
</lay-step-item>
<lay-step-item title="Second" content="Second step"></lay-step-item>
<lay-step-item title="Third" content="Third step"></lay-step-item>
</lay-step>
</div>
</template>
<script>
import { ref } from 'vue';
export default {
setup() {
const loading = ref(true);
const active = ref(-1);
const next = () => {
if (active.value++ >=2) active.value = 0
};
const previous = () => {
if (active.value-- ===0) active.value = 0
};
return {
loading,
active
}
}
}
</script>
:::
::: title step步骤条属性
:::
::: table
| 属性 | 描述 | 类型 |可选值 | 默认值|
| ----- | ---- | ------ | ---| ---|
| active | 第几步 | number |-| 0 |
| center | 居中布局 | boolean | `true` `false` | `false` |
| direction | 垂直/平行布局 | string |`horizontal` `vertical` | `horizontal` |
| space | 宽度 | string | - | `auto` |
| currentStatus | 当前状态显示 | string | `primary` `success` `fail` `warning` | `primary` |
:::
::: title stepItem步骤条属性
:::
::: table
| 属性 | 描述 | 类型 |可选值 | 默认值|
| ----- | ---- | ------ | ---| ---|
| title| 标题 | string | - | - |
| content | 内容描述 | string | - | -|
| icon | 图标 | string | - | -|
| status | 状态 | string | `primary` `success` `fail` `warning` | `primary`|
:::
::: title stepItem步骤条slot
:::
::: table
| 属性 | 描述 |
| ----- | ---- |
| pace | 圆圈内容自定义 |
| default | 内容区域自定义 |
:::
::: comment
:::

View File

@ -1,52 +1,52 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck // @ts-nocheck
import { createApp } from './main' import { createApp } from "./main";
import { renderToString } from '@vue/server-renderer' import { renderToString } from "@vue/server-renderer";
export async function render(url, manifest): Promise<string[]> { export async function render(url, manifest): Promise<string[]> {
const { app, router } = createApp() const { app, router } = createApp();
// set the router to the desired URL before rendering // set the router to the desired URL before rendering
router.push(url) router.push(url);
await router.isReady() await router.isReady();
// passing SSR context object which will be available via useSSRContext() // passing SSR context object which will be available via useSSRContext()
// @vitejs/plugin-vue injects code into a component's setup() that registers // @vitejs/plugin-vue injects code into a component's step() that registers
// itself on ctx.modules. After the render, ctx.modules would contain all the // itself on ctx.modules. After the render, ctx.modules would contain all the
// components that have been instantiated during this render call. // components that have been instantiated during this render call.
const ctx = {} const ctx = {};
const html = await renderToString(app, ctx) const html = await renderToString(app, ctx);
// the SSR manifest generated by Vite contains module -> chunk/asset mapping // the SSR manifest generated by Vite contains module -> chunk/asset mapping
// which we can then use to determine what files need to be preloaded for this // which we can then use to determine what files need to be preloaded for this
// request. // request.
const preloadLinks = renderPreloadLinks(ctx.modules, manifest) const preloadLinks = renderPreloadLinks(ctx.modules, manifest);
return [html, preloadLinks] return [html, preloadLinks];
} }
function renderPreloadLinks(modules, manifest) { function renderPreloadLinks(modules, manifest) {
let links = '' let links = "";
const seen = new Set() const seen = new Set();
modules.forEach((id) => { modules.forEach((id) => {
const files = manifest[id] const files = manifest[id];
if (files) { if (files) {
files.forEach((file) => { files.forEach((file) => {
if (!seen.has(file)) { if (!seen.has(file)) {
seen.add(file) seen.add(file);
links += renderPreloadLink(file) links += renderPreloadLink(file);
} }
}) });
} }
}) });
return links return links;
} }
function renderPreloadLink(file) { function renderPreloadLink(file) {
if (file.endsWith('.js')) { if (file.endsWith(".js")) {
return `<link rel="modulepreload" crossorigin href="${file}">` return `<link rel="modulepreload" crossorigin href="${file}">`;
} else if (file.endsWith('.css')) { } else if (file.endsWith(".css")) {
return `<link rel="stylesheet" href="${file}">` return `<link rel="stylesheet" href="${file}">`;
} else { } else {
return '' return "";
} }
} }

View File

@ -1,362 +1,373 @@
import BaseLayout from '../layouts/Layout.vue' import BaseLayout from "../layouts/Layout.vue";
import Component from '../view/component.vue' import Component from "../view/component.vue";
import Hooks from '../view/hooks.vue' import Hooks from "../view/hooks.vue";
import Guide from '../view/guide.vue' import Guide from "../view/guide.vue";
import Index from '../view/index.vue' import Index from "../view/index.vue";
import Ecology from '../view/ecology.vue' import Ecology from "../view/ecology.vue";
const zhCN = [ const zhCN = [
{ {
path: '/', path: "/",
redirect: '/zh-CN/index', redirect: "/zh-CN/index",
component: BaseLayout, component: BaseLayout,
meta: { title: '首页' }, meta: { title: "首页" },
children: [ children: [
{ {
path: '/zh-CN/index', path: "/zh-CN/index",
component: Index, component: Index,
meta: { title: '指南' }, meta: { title: "指南" },
}, },
{ {
path: '/zh-CN/ecology', path: "/zh-CN/ecology",
component: Ecology, component: Ecology,
meta: { title: '生态' }, meta: { title: "生态" },
}, },
{ {
path: '/zh-CN/guide', path: "/zh-CN/guide",
redirect: '/zh-CN/guide/introduce', redirect: "/zh-CN/guide/introduce",
component: Guide, component: Guide,
meta: { title: '指南' }, meta: { title: "指南" },
children: [ children: [
{ {
path: '/zh-CN/guide/introduce', path: "/zh-CN/guide/introduce",
component: () => import('../../docs/zh-CN/guide/introduce.md'), component: () => import("../../docs/zh-CN/guide/introduce.md"),
meta: { title: '介绍' }, meta: { title: "介绍" },
}, },
{ {
path: '/zh-CN/guide/getStarted', path: "/zh-CN/guide/getStarted",
component: () => import('../../docs/zh-CN/guide/getStarted.md'), component: () => import("../../docs/zh-CN/guide/getStarted.md"),
meta: { title: '安装' }, meta: { title: "安装" },
}, },
{ {
path: '/zh-CN/guide/changelog', path: "/zh-CN/guide/changelog",
component: () => import('../../docs/zh-CN/guide/changelog.md'), component: () => import("../../docs/zh-CN/guide/changelog.md"),
meta: { title: '更新' }, meta: { title: "更新" },
}, },
{ {
path: '/zh-CN/guide/problem', path: "/zh-CN/guide/problem",
component: () => import('../../docs/zh-CN/guide/problem.md'), component: () => import("../../docs/zh-CN/guide/problem.md"),
meta: { title: '问题' }, meta: { title: "问题" },
}, },
{ {
path: '/zh-CN/guide/member', path: "/zh-CN/guide/member",
component: () => import('../../docs/zh-CN/guide/member.md'), component: () => import("../../docs/zh-CN/guide/member.md"),
meta: { title: '团队' }, meta: { title: "团队" },
}, },
{ {
path: '/zh-CN/guide/norms', path: "/zh-CN/guide/norms",
component: () => import('../../docs/zh-CN/guide/norms.md'), component: () => import("../../docs/zh-CN/guide/norms.md"),
meta: { title: '规范' }, meta: { title: "规范" },
}, },
{ {
path: '/zh-CN/guide/theme', path: "/zh-CN/guide/theme",
component: () => import('../../docs/zh-CN/guide/theme.md'), component: () => import("../../docs/zh-CN/guide/theme.md"),
meta: { title: '主题' }, meta: { title: "主题" },
}, },
{ {
path: '/zh-CN/guide/sponsor', path: "/zh-CN/guide/sponsor",
component: () => import('../../docs/zh-CN/guide/sponsor.md'), component: () => import("../../docs/zh-CN/guide/sponsor.md"),
meta: { title: '赞助' }, meta: { title: "赞助" },
}, },
], ],
}, },
{ {
path: '/zh-CN/components', path: "/zh-CN/components",
redirect: '/zh-CN/components/color', redirect: "/zh-CN/components/color",
component: Component, component: Component,
meta: { title: '组件' }, meta: { title: "组件" },
children: [ children: [
{ {
path: '/zh-CN/components/skeleton', path: "/zh-CN/components/skeleton",
component: () => import('../../docs/zh-CN/components/skeleton.md'), component: () => import("../../docs/zh-CN/components/skeleton.md"),
meta: { title: '骨架屏' }, meta: { title: "骨架屏" },
}, },
{ {
path: '/zh-CN/components/layout', path: "/zh-CN/components/layout",
component: () => import('../../docs/zh-CN/components/layout.md'), component: () => import("../../docs/zh-CN/components/layout.md"),
meta: { title: '布局' }, meta: { title: "布局" },
}, },
{ {
path: '/zh-CN/components/color', path: "/zh-CN/components/color",
component: () => import('../../docs/zh-CN/components/color.md'), component: () => import("../../docs/zh-CN/components/color.md"),
meta: { title: '颜色' }, meta: { title: "颜色" },
}, },
{ {
path: '/zh-CN/components/container', path: "/zh-CN/components/container",
component: () => import('../../docs/zh-CN/components/container.md'), component: () => import("../../docs/zh-CN/components/container.md"),
meta: { title: '容器' }, meta: { title: "容器" },
}, },
{ {
path: '/zh-CN/components/breadcrumb', path: "/zh-CN/components/breadcrumb",
component: () => component: () =>
import('../../docs/zh-CN/components/breadcrumb.md'), import("../../docs/zh-CN/components/breadcrumb.md"),
meta: { title: '面包屑' }, meta: { title: "面包屑" },
}, },
{ {
path: '/zh-CN/components/button', path: "/zh-CN/components/button",
component: () => import('../../docs/zh-CN/components/button.md'), component: () => import("../../docs/zh-CN/components/button.md"),
meta: { title: '按钮' }, meta: { title: "按钮" },
}, },
{ {
path: '/zh-CN/components/icon', path: "/zh-CN/components/icon",
component: () => import('../../docs/zh-CN/components/icon.md'), component: () => import("../../docs/zh-CN/components/icon.md"),
meta: { title: '图标' }, meta: { title: "图标" },
}, },
{ {
path: '/zh-CN/components/panel', path: "/zh-CN/components/panel",
component: () => import('../../docs/zh-CN/components/panel.md'), component: () => import("../../docs/zh-CN/components/panel.md"),
meta: { title: '面板' }, meta: { title: "面板" },
}, },
{ {
path: '/zh-CN/components/animation', path: "/zh-CN/components/animation",
component: () => import('../../docs/zh-CN/components/animation.md'), component: () => import("../../docs/zh-CN/components/animation.md"),
meta: { title: '动画' }, meta: { title: "动画" },
}, },
{ {
path: '/zh-CN/components/card', path: "/zh-CN/components/card",
component: () => import('../../docs/zh-CN/components/card.md'), component: () => import("../../docs/zh-CN/components/card.md"),
meta: { title: '卡片' }, meta: { title: "卡片" },
}, },
{ {
path: '/zh-CN/components/grid', path: "/zh-CN/components/grid",
component: () => import('../../docs/zh-CN/components/grid.md'), component: () => import("../../docs/zh-CN/components/grid.md"),
meta: { title: '栅格' }, meta: { title: "栅格" },
}, },
{ {
path: '/zh-CN/components/form', path: "/zh-CN/components/form",
component: () => import('../../docs/zh-CN/components/form.md'), component: () => import("../../docs/zh-CN/components/form.md"),
meta: { title: '表单' }, meta: { title: "表单" },
}, },
{ {
path: '/zh-CN/components/badge', path: "/zh-CN/components/badge",
component: () => import('../../docs/zh-CN/components/badge.md'), component: () => import("../../docs/zh-CN/components/badge.md"),
meta: { title: '徽章' }, meta: { title: "徽章" },
}, },
{ {
path: '/zh-CN/components/block', path: "/zh-CN/components/block",
component: () => import('../../docs/zh-CN/components/block.md'), component: () => import("../../docs/zh-CN/components/block.md"),
meta: { title: '辅助' }, meta: { title: "辅助" },
}, },
{ {
path: '/zh-CN/components/line', path: "/zh-CN/components/line",
component: () => import('../../docs/zh-CN/components/line.md'), component: () => import("../../docs/zh-CN/components/line.md"),
meta: { title: '分割' }, meta: { title: "分割" },
}, },
{ {
path: '/zh-CN/components/progress', path: "/zh-CN/components/progress",
component: () => import('../../docs/zh-CN/components/progress.md'), component: () => import("../../docs/zh-CN/components/progress.md"),
meta: { title: '进度' }, meta: { title: "进度" },
}, },
{ {
path: '/zh-CN/components/menu', path: "/zh-CN/components/menu",
component: () => import('../../docs/zh-CN/components/menu.md'), component: () => import("../../docs/zh-CN/components/menu.md"),
meta: { title: '菜单' }, meta: { title: "菜单" },
}, },
{ {
path: '/zh-CN/components/timeline', path: "/zh-CN/components/timeline",
component: () => import('../../docs/zh-CN/components/timeline.md'), component: () => import("../../docs/zh-CN/components/timeline.md"),
meta: { title: '时间线' }, meta: { title: "时间线" },
}, },
{ {
path: '/zh-CN/components/collapse', path: "/zh-CN/components/collapse",
component: () => import('../../docs/zh-CN/components/collapse.md'), component: () => import("../../docs/zh-CN/components/collapse.md"),
meta: { title: '折叠面板' }, meta: { title: "折叠面板" },
}, },
{ {
path: '/zh-CN/components/table', path: "/zh-CN/components/step",
component: () => import('../../docs/zh-CN/components/table.md'), component: () => import("../../docs/zh-CN/components/step.md"),
meta: { title: '表格' }, meta: { title: "分步" },
}, },
{ {
path: '/zh-CN/components/avatar', path: "/zh-CN/components/table",
component: () => import('../../docs/zh-CN/components/avatar.md'), component: () => import("../../docs/zh-CN/components/table.md"),
meta: { title: '头像' }, meta: { title: "表格" },
}, },
{ {
path: '/zh-CN/components/field', path: "/zh-CN/components/avatar",
component: () => import('../../docs/zh-CN/components/field.md'), component: () => import("../../docs/zh-CN/components/avatar.md"),
meta: { title: '字段' }, meta: { title: "头像" },
}, },
{ {
path: '/zh-CN/components/empty', path: "/zh-CN/components/field",
component: () => import('../../docs/zh-CN/components/empty.md'), component: () => import("../../docs/zh-CN/components/field.md"),
meta: { title: '空' }, meta: { title: "字段" },
}, },
{ {
path: '/zh-CN/components/rate', path: "/zh-CN/components/empty",
component: () => import('../../docs/zh-CN/components/rate.md'), component: () => import("../../docs/zh-CN/components/empty.md"),
meta: { title: '评分' }, meta: { title: "空" },
}, },
{ {
path: '/zh-CN/components/dropdown', path: "/zh-CN/components/rate",
component: () => import('../../docs/zh-CN/components/dropdown.md'), component: () => import("../../docs/zh-CN/components/rate.md"),
meta: { title: '下拉' }, meta: { title: "评分" },
}, },
{ {
path: '/zh-CN/components/tab', path: "/zh-CN/components/dropdown",
component: () => import('../../docs/zh-CN/components/tab.md'), component: () => import("../../docs/zh-CN/components/dropdown.md"),
meta: { title: '选项卡' }, meta: { title: "下拉" },
}, },
{ {
path: '/zh-CN/components/iconPicker', path: "/zh-CN/components/tab",
component: () => import("../../docs/zh-CN/components/tab.md"),
meta: { title: "选项卡" },
},
{
path: "/zh-CN/components/iconPicker",
component: () => component: () =>
import('../../docs/zh-CN/components/iconPicker.md'), import("../../docs/zh-CN/components/iconPicker.md"),
meta: { title: '图标选择' }, meta: { title: "图标选择" },
}, },
{ {
path: '/zh-CN/components/tree', path: "/zh-CN/components/tree",
component: () => import('../../docs/zh-CN/components/tree.md'), component: () => import("../../docs/zh-CN/components/tree.md"),
meta: { title: '树形组件' }, meta: { title: "树形组件" },
}, },
{ {
path: '/zh-CN/components/page', path: "/zh-CN/components/page",
component: () => import('../../docs/zh-CN/components/page.md'), component: () => import("../../docs/zh-CN/components/page.md"),
meta: { title: '分页' }, meta: { title: "分页" },
}, },
{ {
path: '/zh-CN/components/transfer', path: "/zh-CN/components/transfer",
component: () => import('../../docs/zh-CN/components/transfer.md'), component: () => import("../../docs/zh-CN/components/transfer.md"),
meta: { title: '穿梭框' }, meta: { title: "穿梭框" },
}, },
{ {
path: '/zh-CN/components/checkbox', path: "/zh-CN/components/checkbox",
component: () => import('../../docs/zh-CN/components/checkbox.md'), component: () => import("../../docs/zh-CN/components/checkbox.md"),
meta: { title: '复选框' }, meta: { title: "复选框" },
}, },
{ {
path: '/zh-CN/components/radio', path: "/zh-CN/components/radio",
component: () => import('../../docs/zh-CN/components/radio.md'), component: () => import("../../docs/zh-CN/components/radio.md"),
meta: { title: '单选框' }, meta: { title: "单选框" },
}, },
{ {
path: '/zh-CN/components/input', path: "/zh-CN/components/input",
component: () => import('../../docs/zh-CN/components/input.md'), component: () => import("../../docs/zh-CN/components/input.md"),
meta: { title: '输入框' }, meta: { title: "输入框" },
}, },
{ {
path: '/zh-CN/components/inputNumber', path: "/zh-CN/components/inputNumber",
component: () => import('../../docs/zh-CN/components/inputNumber.md'),
meta: { title: '数字输入框' },
},
{
path: '/zh-CN/components/textarea',
component: () => import('../../docs/zh-CN/components/textarea.md'),
meta: { title: '文本域' },
},
{
path: '/zh-CN/components/switch',
component: () => import('../../docs/zh-CN/components/switch.md'),
meta: { title: '开关' },
},
{
path: '/zh-CN/components/slider',
component: () => import('../../docs/zh-CN/components/slider.md'),
meta: { title: '滑块' },
},
{
path: '/zh-CN/components/carousel',
component: () => import('../../docs/zh-CN/components/carousel.md'),
meta: { title: '轮播' },
},
{
path: '/zh-CN/components/select',
component: () => import('../../docs/zh-CN/components/select.md'),
meta: { title: '下拉选择' },
},
{
path: '/zh-CN/components/colorPicker',
component: () => component: () =>
import('../../docs/zh-CN/components/colorPicker.md'), import("../../docs/zh-CN/components/inputNumber.md"),
meta: { title: '颜色选择器' }, meta: { title: "数字输入框" },
},{
path: '/zh-CN/components/layer',
component: () => import('../../docs/zh-CN/components/layer.md'),
meta: { title: '简介' },
}, },
{ {
path: '/zh-CN/components/tooltip', path: "/zh-CN/components/textarea",
component: () => import('../../docs/zh-CN/components/tooltip.md'), component: () => import("../../docs/zh-CN/components/textarea.md"),
meta: { title: '文字提示' }, meta: { title: "文本域" },
}, },
{ {
path: '/zh-CN/components/modal', path: "/zh-CN/components/switch",
component: () => import('../../docs/zh-CN/components/modal.md'), component: () => import("../../docs/zh-CN/components/switch.md"),
meta: { title: '弹层' }, meta: { title: "开关" },
},{
path: '/zh-CN/components/load',
component: () => import('../../docs/zh-CN/components/load.md'),
meta: { title: '加载' },
},{
path: '/zh-CN/components/confirm',
component: () => import('../../docs/zh-CN/components/confirm.md'),
meta: { title: '询问' },
},{
path: '/zh-CN/components/msg',
component: () => import('../../docs/zh-CN/components/msg.md'),
meta: { title: '信息' },
},{
path: '/zh-CN/components/backtop',
component: () => import('../../docs/zh-CN/components/backtop.md'),
meta: { title: '返回顶部' },
}, },
{ {
path: '/zh-CN/components/countup', path: "/zh-CN/components/slider",
component: () => import('../../docs/zh-CN/components/countup.md'), component: () => import("../../docs/zh-CN/components/slider.md"),
meta: { title: '数字滚动' }, meta: { title: "滑块" },
},
{
path: "/zh-CN/components/carousel",
component: () => import("../../docs/zh-CN/components/carousel.md"),
meta: { title: "轮播" },
},
{
path: "/zh-CN/components/select",
component: () => import("../../docs/zh-CN/components/select.md"),
meta: { title: "下拉选择" },
},
{
path: "/zh-CN/components/colorPicker",
component: () =>
import("../../docs/zh-CN/components/colorPicker.md"),
meta: { title: "颜色选择器" },
},
{
path: "/zh-CN/components/layer",
component: () => import("../../docs/zh-CN/components/layer.md"),
meta: { title: "简介" },
},
{
path: "/zh-CN/components/tooltip",
component: () => import("../../docs/zh-CN/components/tooltip.md"),
meta: { title: "文字提示" },
},
{
path: "/zh-CN/components/modal",
component: () => import("../../docs/zh-CN/components/modal.md"),
meta: { title: "弹层" },
},
{
path: "/zh-CN/components/load",
component: () => import("../../docs/zh-CN/components/load.md"),
meta: { title: "加载" },
},
{
path: "/zh-CN/components/confirm",
component: () => import("../../docs/zh-CN/components/confirm.md"),
meta: { title: "询问" },
},
{
path: "/zh-CN/components/msg",
component: () => import("../../docs/zh-CN/components/msg.md"),
meta: { title: "信息" },
},
{
path: "/zh-CN/components/backtop",
component: () => import("../../docs/zh-CN/components/backtop.md"),
meta: { title: "返回顶部" },
},
{
path: "/zh-CN/components/countup",
component: () => import("../../docs/zh-CN/components/countup.md"),
meta: { title: "数字滚动" },
}, },
], ],
}, },
{ {
path: '/zh-CN/hooks', path: "/zh-CN/hooks",
redirect: '/zh-CN/hooks/useStarted', redirect: "/zh-CN/hooks/useStarted",
component: Hooks, component: Hooks,
meta: { title: 'hooks' }, meta: { title: "hooks" },
children: [ children: [
{ {
path: '/zh-CN/hooks/useStarted', path: "/zh-CN/hooks/useStarted",
component: () => import("../../docs/zh-CN/hooks/useStarted.md"),
meta: { title: "useStarted" },
},
{
path: "/zh-CN/hooks/useClickOutside",
component: () => component: () =>
import('../../docs/zh-CN/hooks/useStarted.md'), import("../../docs/zh-CN/hooks/useClickOutside.md"),
meta: { title: 'useStarted' }, meta: { title: "useClickOutside" },
}, },
{ {
path: '/zh-CN/hooks/useClickOutside', path: "/zh-CN/hooks/useFullScreen",
component: () => component: () => import("../../docs/zh-CN/hooks/useFullScreen.md"),
import('../../docs/zh-CN/hooks/useClickOutside.md'), meta: { title: "useFullScreen" },
meta: { title: 'useClickOutside' },
}, },
{ {
path: '/zh-CN/hooks/useFullScreen', path: "/zh-CN/hooks/useMove",
component: () => import('../../docs/zh-CN/hooks/useFullScreen.md'), component: () => import("../../docs/zh-CN/hooks/useMove.md"),
meta: { title: 'useFullScreen' }, meta: { title: "useMove" },
}, },
{ {
path: '/zh-CN/hooks/useMove', path: "/zh-CN/hooks/useState",
component: () => import('../../docs/zh-CN/hooks/useMove.md'), component: () => import("../../docs/zh-CN/hooks/useState.md"),
meta: { title: 'useMove' }, meta: { title: "useState" },
}, {
path: '/zh-CN/hooks/useState',
component: () => import('../../docs/zh-CN/hooks/useState.md'),
meta: { title: 'useState' },
}, },
{ {
path: '/zh-CN/hooks/useBoolean', path: "/zh-CN/hooks/useBoolean",
component: () => import('../../docs/zh-CN/hooks/useBoolean.md'), component: () => import("../../docs/zh-CN/hooks/useBoolean.md"),
meta: { title: 'useBoolean' }, meta: { title: "useBoolean" },
}, },
], ],
}, },
], ],
}, },
] ];
export default zhCN export default zhCN;

View File

@ -50,362 +50,371 @@
</lay-layout> </lay-layout>
</template> </template>
<script> <script>
import { ref, watch } from 'vue' import { ref, watch } from "vue";
import { useRouter, useRoute } from 'vue-router' import { useRouter, useRoute } from "vue-router";
export default { export default {
setup() { setup() {
const route = useRoute() const route = useRoute();
const router = useRouter() const router = useRouter();
const currentPath = ref('/zh-CN/guide') const currentPath = ref("/zh-CN/guide");
watch( watch(
() => route.path, () => route.path,
(val) => { (val) => {
currentPath.value = val currentPath.value = val;
}, },
{ {
immediate: true, immediate: true,
deep: true, deep: true,
} }
) );
const menus = [ const menus = [
{ {
id: 1, id: 1,
title: '通用', title: "通用",
children: [ children: [
{ {
id: 20, id: 20,
title: '颜色', title: "颜色",
subTitle: 'color', subTitle: "color",
path: '/zh-CN/components/color', path: "/zh-CN/components/color",
}, },
{ {
id: 6, id: 6,
title: '按钮', title: "按钮",
subTitle: 'button', subTitle: "button",
path: '/zh-CN/components/button', path: "/zh-CN/components/button",
}, },
{ {
id: 7, id: 7,
title: '图标', title: "图标",
subTitle: 'iconfont', subTitle: "iconfont",
path: '/zh-CN/components/icon', path: "/zh-CN/components/icon",
}, },
{ {
id: 10, id: 10,
title: '动画', title: "动画",
subTitle: 'animation', subTitle: "animation",
path: '/zh-CN/components/animation', path: "/zh-CN/components/animation",
}, },
], ],
}, },
{ {
id: 1, id: 1,
title: '布局', title: "布局",
children: [ children: [
{ {
id: 111, id: 111,
title: '骨架屏', title: "骨架屏",
subTitle: 'skeleton', subTitle: "skeleton",
path: '/zh-CN/components/skeleton', path: "/zh-CN/components/skeleton",
}, },
{ {
id: 4, id: 4,
title: '布局', title: "布局",
subTitle: 'layout', subTitle: "layout",
path: '/zh-CN/components/layout', path: "/zh-CN/components/layout",
}, },
{ {
id: 5, id: 5,
title: '容器', title: "容器",
subTitle: 'container', subTitle: "container",
path: '/zh-CN/components/container', path: "/zh-CN/components/container",
}, },
{ {
id: 11, id: 11,
title: '栅格', title: "栅格",
subTitle: 'grid', subTitle: "grid",
path: '/zh-CN/components/grid', path: "/zh-CN/components/grid",
}, },
{ {
id: 8, id: 8,
title: '面板', title: "面板",
subTitle: 'panel', subTitle: "panel",
path: '/zh-CN/components/panel', path: "/zh-CN/components/panel",
}, },
{ {
id: 9, id: 9,
title: '卡片', title: "卡片",
subTitle: 'card', subTitle: "card",
path: '/zh-CN/components/card', path: "/zh-CN/components/card",
}, },
], ],
}, },
{ {
id: 1, id: 1,
title: '导航', title: "导航",
children: [ children: [
{ {
id: 16, id: 16,
title: '菜单', title: "菜单",
subTitle: 'nav', subTitle: "nav",
path: '/zh-CN/components/menu', path: "/zh-CN/components/menu",
}, },
{ {
id: 17, id: 17,
title: '面包屑', title: "面包屑",
subTitle: 'breadcrumb', subTitle: "breadcrumb",
path: '/zh-CN/components/breadcrumb', path: "/zh-CN/components/breadcrumb",
}, },
{ {
id: 28, id: 28,
title: '选项卡', title: "选项卡",
subTitle: 'tab', subTitle: "tab",
path: '/zh-CN/components/tab', path: "/zh-CN/components/tab",
}, },
{ {
id: 27, id: 27,
title: '下拉菜单', title: "下拉菜单",
subTitle: 'dropdown', subTitle: "dropdown",
path: '/zh-CN/components/dropdown', path: "/zh-CN/components/dropdown",
}, },
{ {
id: 42, id: 42,
title: '返回顶部', title: "返回顶部",
subTitle: 'backtop', subTitle: "backtop",
path: '/zh-CN/components/backtop', path: "/zh-CN/components/backtop",
}, },
], ],
}, },
{ {
id: 1, id: 1,
title: '表单', title: "表单",
children: [ children: [
{ {
id: 36, id: 36,
title: '开关', title: "开关",
subTitle: 'switch', subTitle: "switch",
path: '/zh-CN/components/switch', path: "/zh-CN/components/switch",
}, },
{ {
id: 32, id: 32,
title: '复选框', title: "复选框",
subTitle: 'checkbox', subTitle: "checkbox",
path: '/zh-CN/components/checkbox', path: "/zh-CN/components/checkbox",
}, },
{ {
id: 33, id: 33,
title: '单选框', title: "单选框",
subTitle: 'radio', subTitle: "radio",
path: '/zh-CN/components/radio', path: "/zh-CN/components/radio",
}, },
{ {
id: 34, id: 34,
title: '输入框', title: "输入框",
subTitle: 'input', subTitle: "input",
path: '/zh-CN/components/input', path: "/zh-CN/components/input",
}, },
{ {
id: 341, id: 341,
title: '数字输入框', title: "数字输入框",
subTitle: 'inputNumber', subTitle: "inputNumber",
path: '/zh-CN/components/inputNumber', path: "/zh-CN/components/inputNumber",
}, },
{ {
id: 35, id: 35,
title: '文本域', title: "文本域",
subTitle: 'textarea', subTitle: "textarea",
path: '/zh-CN/components/textarea', path: "/zh-CN/components/textarea",
}, },
{ {
id: 39, id: 39,
title: '下拉选择', title: "下拉选择",
subTitle: 'select', subTitle: "select",
path: '/zh-CN/components/select', path: "/zh-CN/components/select",
}, },
{ {
id: 40, id: 40,
title: '颜色选择器', title: "颜色选择器",
subTitle: 'colorPicker', subTitle: "colorPicker",
path: '/zh-CN/components/colorPicker', path: "/zh-CN/components/colorPicker",
}, },
{ {
id: 29, id: 29,
title: '图标选择器', title: "图标选择器",
subTitle: 'iconPicker', subTitle: "iconPicker",
path: '/zh-CN/components/iconPicker', path: "/zh-CN/components/iconPicker",
}, },
{ {
id: 26, id: 26,
title: '评分', title: "评分",
subTitle: 'rate', subTitle: "rate",
path: '/zh-CN/components/rate', path: "/zh-CN/components/rate",
}, },
{ {
id: 37, id: 37,
title: '滑块', title: "滑块",
subTitle: 'slider', subTitle: "slider",
path: '/zh-CN/components/slider', path: "/zh-CN/components/slider",
}, },
{ {
id: 12, id: 12,
title: '表单', title: "表单",
subTitle: 'form', subTitle: "form",
path: '/zh-CN/components/form', path: "/zh-CN/components/form",
}, },
], ],
}, },
{ {
id: 1, id: 1,
title: '展示', title: "展示",
children: [ children: [
{ {
id: 18, id: 18,
title: '进度', title: "进度",
subTitle: 'progress', subTitle: "progress",
path: '/zh-CN/components/progress', path: "/zh-CN/components/progress",
}, },
{ {
id: 19, id: 19,
title: '时间线', title: "时间线",
subTitle: 'timeline', subTitle: "timeline",
path: '/zh-CN/components/timeline', path: "/zh-CN/components/timeline",
}, },
{ {
id: 21, id: 21,
title: '折叠面板', title: "折叠面板",
subTitle: 'collapse', subTitle: "collapse",
path: '/zh-CN/components/collapse', path: "/zh-CN/components/collapse",
}, },
{ {
id: 22, id: 22,
title: '表格', title: "表格",
subTitle: 'table', subTitle: "table",
path: '/zh-CN/components/table', path: "/zh-CN/components/table",
}, },
{ {
id: 23, id: 23,
title: '头像', title: "头像",
subTitle: 'avatar', subTitle: "avatar",
path: '/zh-CN/components/avatar', path: "/zh-CN/components/avatar",
}, },
{ {
id: 25, id: 25,
title: '空', title: "空",
subTitle: 'empty', subTitle: "empty",
path: '/zh-CN/components/empty', path: "/zh-CN/components/empty",
}, },
{ {
id: 29, id: 29,
title: '分页', title: "分页",
subTitle: 'page', subTitle: "page",
path: '/zh-CN/components/page', path: "/zh-CN/components/page",
}, },
{ {
id: 30, id: 30,
title: '树形组件', title: "树形组件",
subTitle: 'tree', subTitle: "tree",
path: '/zh-CN/components/tree', path: "/zh-CN/components/tree",
}, },
{ {
id: 31, id: 31,
title: '穿梭框', title: "穿梭框",
subTitle: 'transfer', subTitle: "transfer",
path: '/zh-CN/components/transfer', path: "/zh-CN/components/transfer",
}, },
{ {
id: 38, id: 38,
title: '轮播', title: "轮播",
subTitle: 'carousel', subTitle: "carousel",
path: '/zh-CN/components/carousel', path: "/zh-CN/components/carousel",
}, },
{ {
id: 43, id: 43,
title: '数字滚动', title: "数字滚动",
subTitle: 'countUp', subTitle: "countUp",
path: '/zh-CN/components/countup', path: "/zh-CN/components/countup",
}, },
], ],
}, },
{ {
id: 1, id: 1,
title: '辅助', title: "辅助",
children: [ children: [
{ {
id: 13, id: 13,
title: '徽章', title: "徽章",
subTitle: 'badge', subTitle: "badge",
path: '/zh-CN/components/badge', path: "/zh-CN/components/badge",
}, },
{ {
id: 14, id: 14,
title: '区块', title: "区块",
subTitle: 'block', subTitle: "block",
path: '/zh-CN/components/block', path: "/zh-CN/components/block",
}, },
{ {
id: 15, id: 15,
title: '分割', title: "分割",
subTitle: 'line', subTitle: "line",
path: '/zh-CN/components/line', path: "/zh-CN/components/line",
}, },
{ {
id: 24, id: 24,
title: '字段', title: "字段",
subTitle: 'field', subTitle: "field",
path: '/zh-CN/components/field', path: "/zh-CN/components/field",
}, },
{ {
id: 25, id: 25,
title: '文字提示', title: "文字提示",
subTitle: 'tooltip', subTitle: "tooltip",
path: '/zh-CN/components/tooltip', path: "/zh-CN/components/tooltip",
},
{
id: 99,
title: "分步",
subTitle: "setup",
path: "/zh-CN/components/step",
}, },
], ],
}, },
{ {
id: 1, id: 1,
title: '反馈', title: "反馈",
children: [ children: [
{ {
id: 90, id: 90,
title: '弹层', title: "弹层",
subTitle: 'modal', subTitle: "modal",
path: '/zh-CN/components/modal', path: "/zh-CN/components/modal",
},{ },
{
id: 91, id: 91,
title: '加载', title: "加载",
subTitle: 'modal', subTitle: "modal",
path: '/zh-CN/components/load', path: "/zh-CN/components/load",
},{ },
{
id: 92, id: 92,
title: '询问', title: "询问",
subTitle: 'confirm', subTitle: "confirm",
path: '/zh-CN/components/confirm', path: "/zh-CN/components/confirm",
},{ },
{
id: 93, id: 93,
title: '消息', title: "消息",
subTitle: 'msg', subTitle: "msg",
path: '/zh-CN/components/msg', path: "/zh-CN/components/msg",
}, },
], ],
}, },
] ];
const selected = ref(1) const selected = ref(1);
const handleClick = function (menu) { const handleClick = function (menu) {
selected.value = menu.id selected.value = menu.id;
router.push(menu.path) router.push(menu.path);
} };
return { return {
menus, menus,
selected, selected,
currentPath, currentPath,
handleClick, handleClick,
} };
}, },
} };
</script> </script>

View File

@ -66,8 +66,10 @@ import LayCarouselItem from "./module/carouselItem/index";
import LayColorPicker from "./module/colorPicker/index"; import LayColorPicker from "./module/colorPicker/index";
import LayTooltip from "./module/tooltip/index"; import LayTooltip from "./module/tooltip/index";
import LayInputNumber from "./module/inputNumber/index"; import LayInputNumber from "./module/inputNumber/index";
import LaySkeleton from './module/skeleton/index'; import LaySkeleton from "./module/skeleton/index";
import LaySkeletonItem from './module/skeletonItem/index'; import LaySkeletonItem from "./module/skeletonItem/index";
import LayStep from "./module/step/index";
import LayStepItem from "./module/stepItem/index";
const components: Record<string, IDefineComponent> = { const components: Record<string, IDefineComponent> = {
LayRadio, LayRadio,
@ -132,6 +134,8 @@ const components: Record<string, IDefineComponent> = {
LaySkeleton, LaySkeleton,
LaySkeletonItem, LaySkeletonItem,
LayCountUp, LayCountUp,
LayStep,
LayStepItem,
}; };
const install = (app: App, options?: InstallOptions): void => { const install = (app: App, options?: InstallOptions): void => {
@ -144,6 +148,8 @@ const install = (app: App, options?: InstallOptions): void => {
}; };
export { export {
LayStep,
LayStepItem,
LaySkeleton, LaySkeleton,
LaySkeletonItem, LaySkeletonItem,
LayRadio, LayRadio,

View File

@ -108,13 +108,13 @@ const props = withDefaults(defineProps<LaySliderProps>(), {
let rangeValue: Ref<number[]> = ref([0, 0]); let rangeValue: Ref<number[]> = ref([0, 0]);
if (Array.isArray(props.modelValue)) { if (Array.isArray(props.modelValue)) {
// eslint-disable-next-line vue/no-setup-props-destructure // eslint-disable-next-line vue/no-step-props-destructure
rangeValue.value = props.modelValue; rangeValue.value = props.modelValue;
} }
let verticalRangeValue: Ref<number[]> = ref([0, 0]); let verticalRangeValue: Ref<number[]> = ref([0, 0]);
if (Array.isArray(props.modelValue)) { if (Array.isArray(props.modelValue)) {
// eslint-disable-next-line vue/no-setup-props-destructure // eslint-disable-next-line vue/no-step-props-destructure
verticalRangeValue.value = props.modelValue; verticalRangeValue.value = props.modelValue;
} }

191
src/module/step/index.less Normal file
View File

@ -0,0 +1,191 @@
@width-height-pace: 20px;
@step-color: #5FB878;
.lay-step{
display: flex;
flex-wrap: nowrap;
.lay-step-item{
flex-grow: 1;
}
.is-item-center{
text-align: center;
}
.lay-step-item-last {
flex-grow: 0 !important;
}
.lay-step-item-pace{
width: @width-height-pace;
height: @width-height-pace;
border: 2px #8D8D8D solid;
border-radius: 50%;
text-align: center;
line-height: @width-height-pace;
background: #FFFFFF;
}
.is-center{
margin: 0 auto;
}
.lay-step-item-active{
border: 2px @step-color solid;
color: #FFFFFF;
background: @step-color;
}
.lay-step-item-wait{
border: 2px #000000 solid;
color: #000000;
}
.lay-step-item--success {
border: 2px @step-color solid;
color: #FFFFFF;
background: @step-color;
}
.lay-step-item--fail{
border: 2px #FF5722 solid;
color: #FFFFFF;
background: #FF5722;
}
.lay-step-item--warning{
border: 2px #FFB800 solid;
color: #FFFFFF;
background: #FFB800;
}
.lay-step-item--primary{
border: 2px #1E9FFF solid;
color: #FFFFFF;
background: #1E9FFF;
}
.lay-step-item-success {
border: 2px @step-color solid;
color: #FFFFFF;
background: @step-color;
}
.lay-step-item-fail{
border: 2px #FF5722 solid;
color: #FFFFFF;
background: #FF5722;
}
.lay-step-item-warning{
border: 2px #FFB800 solid;
color: #FFFFFF;
background: #FFB800;
}
.lay-step-item-primary{
border: 2px #1E9FFF solid;
color: #FFFFFF;
background: #1E9FFF;
}
.lay-step-item-content{
color: #8D8D8D;
.lay-step-item-content-title{
font-weight: bold;
font-size: 16px;
}
}
.lay-step-item-content-active{
color: @step-color;
}
.lay-step-item-content--success{
color: @step-color;
}
.lay-step-item-content--fail{
color: #FF5722;
}
.lay-step-item-content--warning{
color: #FFB800;
}
.lay-step-item-content--primary{
color: #1E9FFF;
}
.lay-step-item-content-wait{
color: #000000;
}
.lay-step-item-content-success{
color: @step-color;
}
.lay-step-item-content-fail{
color: #FF5722;
}
.lay-step-item-content-warning{
color: #FFB800;
}
.lay-step-item-content-primary{
color: #1E9FFF;
}
.lay-step-item-line{
position: relative;
}
.lay-step-item-line:before {
z-index: -1;
content: "";
position: absolute;
top: 50%;
transform: translateY(-50%);
display: block;
height: 2px;
width: 100%;
background: #C9C5C5;
}
.is-line-center:before {
left: 50%;
}
.lay-step-item-line-active:before {
transition: background 150ms;
background: #5FB878 !important;
}
.lay-step-item-line-fail:before {
transition: background 150ms;
background: #FF5722 !important;
}
.lay-step-item-line-warning:before {
transition: background 150ms;
background: #FFB800 !important;
}
.lay-step-item-line-primary:before {
transition: background 150ms;
background: #1E9FFF !important;
}
}
.lay-step-column {
height: 100%;
flex-flow: column;
.lay-step-item-line{
position: relative;
height: 100%;
width: 24px;
}
.lay-step-item-line:before {
z-index: -1;
content: "";
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
display: block;
width: 2px;
height: 100%;
background: #C9C5C5;
}
.is-vertical{
display: flex;
}
}

9
src/module/step/index.ts Normal file
View File

@ -0,0 +1,9 @@
import type { App } from "vue";
import Component from "./index.vue";
import type { IDefineComponent } from "../type/index";
Component.install = (app: App) => {
app.component(Component.name || "laySetup", Component);
};
export default Component as IDefineComponent;

43
src/module/step/index.vue Normal file
View File

@ -0,0 +1,43 @@
<template>
<div :class="['lay-step', direction !== 'vertical' ? '' : 'lay-step-column']">
<slot></slot>
</div>
</template>
<script setup name="layStep" lang="ts">
import { ref, watch, provide, defineProps, withDefaults } from "vue";
import "./index.less";
export interface LayStepProps {
active?: number;
center?: boolean;
direction?: string;
space?: string;
currentStatus?: string;
}
const props = withDefaults(defineProps<LayStepProps>(), {
active: 0,
center: false,
direction: "horizontal",
space: "auto",
currentStatus: "primary",
});
const steps = ref([]);
watch(steps, () => {
steps.value.forEach(
(instance: { setIndex: (arg0: any) => void }, index: any) => {
instance.setIndex(index);
}
);
});
provide("LayStep", {
props,
steps,
});
</script>
<style scoped></style>

View File

@ -0,0 +1,9 @@
import type { App } from "vue";
import Component from "./index.vue";
import type { IDefineComponent } from "../type/index";
Component.install = (app: App) => {
app.component(Component.name || "laySetupItem", Component);
};
export default Component as IDefineComponent;

View File

@ -0,0 +1,152 @@
<template>
<div
:class="[
'lay-step-item',
isLast && !isCenter ? 'lay-step-item-last' : '',
isCenter ? 'is-item-center' : '',
isVertical ? 'is-vertical' : '',
]"
:style="{ flexBasis: space, flexGrow: space === 'auto' ? 1 : 0 }"
>
<div
:class="[
!isLast
? isLineActive
? `lay-step-item-line lay-step-item-line-${status || 'active'}`
: 'lay-step-item-line'
: '',
isCenter ? 'is-line-center' : '',
]"
>
<div
:class="[
'lay-step-item-pace',
isActive ? `lay-step-item-active` : '',
isCurrent === index ? `lay-step-item--${currentStatus}` : '',
status ? `lay-step-item-${status}` : '',
isWait ? 'lay-step-item-wait' : '',
isCenter ? 'is-center' : '',
]"
>
<slot name="pace">
<template v-if="icon">
<lay-icon :type="icon"></lay-icon>
</template>
<template v-else>
<span v-if="!isActive">{{ index + 1 }}</span>
<lay-icon
v-else
:type="status === 'fail' ? 'layui-icon-close' : 'layui-icon-ok'"
></lay-icon>
</template>
</slot>
</div>
</div>
<slot>
<div
:class="[
'lay-step-item-content',
isActive ? `lay-step-item-content-active` : '',
isCurrent === index ? `lay-step-item-content--${currentStatus}` : '',
status ? `lay-step-item-content-${status}` : '',
isWait ? 'lay-step-item-content-wait' : '',
]"
>
<div class="lay-step-item-content-title">{{ title }}</div>
<p>{{ content }}</p>
</div>
</slot>
</div>
</template>
<script setup name="LayStepItem" lang="ts">
import {
ref,
inject,
onMounted,
computed,
getCurrentInstance,
onBeforeUnmount,
reactive,
defineProps,
withDefaults,
} from "vue";
import type { ComputedRef } from "vue";
export interface LayStepItemProps {
title?: string;
content?: string;
icon?: string;
status?: string;
}
const props = withDefaults(defineProps<LayStepItemProps>(), {
title: "",
content: "",
icon: "",
status: "",
});
const index = ref(-1);
const parents: any = inject("LayStep");
const currentInstance: any = getCurrentInstance();
const setIndex = (val: number) => {
index.value = val;
};
const stepsCount = computed(() => {
return parents.steps.value.length;
});
const currentStatus = computed(() => {
return parents.props.currentStatus;
});
const isCurrent = computed(() => {
return parents.props.active;
});
console.log(isCurrent);
const space = computed(() => {
return parents.props.space;
});
const isVertical = computed(() => {
return parents.props.direction === "vertical";
});
const isCenter = computed(() => {
return parents.props.center;
});
const isLineActive: ComputedRef<boolean> = computed(() => {
return index.value <= parents.props.active - 1;
});
const isWait: ComputedRef<boolean> = computed(() => {
return index.value === parents.props.active + 1;
});
const isActive: ComputedRef<boolean> = computed(() => {
return index.value <= parents.props.active;
});
const isLast: ComputedRef<boolean> = computed(() => {
return (
parents.steps.value[stepsCount.value - 1]?.itemId === currentInstance.uid
);
});
const stepItemState = reactive({
itemId: computed(() => currentInstance?.uid),
setIndex,
});
parents.steps.value = [...parents.steps.value, stepItemState];
onMounted(() => {});
onBeforeUnmount(() => {
parents.steps.value = parents.steps.value.filter(
(instance: { itemId: any }) => instance.itemId !== currentInstance.uid
);
});
</script>