diff --git a/.replit b/.replit new file mode 100644 index 0000000000..7a95b0aba3 --- /dev/null +++ b/.replit @@ -0,0 +1,39 @@ +modules = ["vue-node-20", "nodejs-20", "web"] +[agent] +expertMode = true + +[nix] +channel = "stable-25_05" + +[workflows] +runButton = "Project" + +[[workflows.workflow]] +name = "Project" +mode = "parallel" +author = "agent" + +[[workflows.workflow.tasks]] +task = "workflow.run" +args = "Dev Server" + +[[workflows.workflow]] +name = "Dev Server" +author = "agent" + +[[workflows.workflow.tasks]] +task = "shell.exec" +args = "npm run dev" +waitForPort = 5000 + +[workflows.workflow.metadata] +outputType = "webview" + +[[ports]] +localPort = 5000 +externalPort = 80 + +[deployment] +deploymentTarget = "static" +build = ["npm", "run", "build"] +publicDir = "site/dist" diff --git a/attached_assets/targeted_element_1765522910746.png b/attached_assets/targeted_element_1765522910746.png new file mode 100644 index 0000000000..8d10be39c2 Binary files /dev/null and b/attached_assets/targeted_element_1765522910746.png differ diff --git a/attached_assets/targeted_element_1765523011666.png b/attached_assets/targeted_element_1765523011666.png new file mode 100644 index 0000000000..6241e9c749 Binary files /dev/null and b/attached_assets/targeted_element_1765523011666.png differ diff --git a/components/breadcrumb/Breadcrumb.tsx b/components/breadcrumb/Breadcrumb.tsx index ad9e24b0de..19ee97eb3a 100644 --- a/components/breadcrumb/Breadcrumb.tsx +++ b/components/breadcrumb/Breadcrumb.tsx @@ -1,4 +1,4 @@ -import type { PropType, ExtractPropTypes } from 'vue'; +import type { PropType, ExtractPropTypes, VNode } from 'vue'; import { cloneVNode, defineComponent } from 'vue'; import PropTypes from '../_util/vue-types'; import { flattenChildren, getPropsSlot } from '../_util/props-util'; @@ -16,11 +16,13 @@ export interface Route { children?: Omit[]; } +export type SeparatorGeneratorFunc = (info: { prevItem: Route | VNode | null; index: number }) => string; + export const breadcrumbProps = () => ({ prefixCls: String, routes: { type: Array as PropType }, params: PropTypes.any, - separator: PropTypes.any, + separator: [String, Function] as PropType, itemRender: { type: Function as PropType< (opt: { route: Route; params: unknown; routes: Route[]; paths: string[] }) => VueNode @@ -90,7 +92,7 @@ export default defineComponent({ itemRender = defaultItemRender, }: any) => { const paths = []; - return routes.map((route: Route) => { + return routes.map((route: Route, index: number) => { const path = getPath(route.path, params); if (path) { @@ -114,7 +116,9 @@ export default defineComponent({ > ); } - const itemProps: BreadcrumbItemProps = { separator }; + const prevItem = index > 0 ? routes[index - 1] : null; + const itemSeparator = separator(prevItem, index); + const itemProps: BreadcrumbItemProps = { separator: itemSeparator }; if (overlay) { itemProps.overlay = overlay; } @@ -131,7 +135,18 @@ export default defineComponent({ const { routes, params = {} } = props; const children = flattenChildren(getPropsSlot(slots, props)); - const separator = getPropsSlot(slots, props, 'separator') ?? '/'; + const separatorProp = props.separator; + const isSeparatorGenerator = typeof separatorProp === 'function'; + const separator = isSeparatorGenerator + ? separatorProp + : (getPropsSlot(slots, props, 'separator') ?? '/'); + + const getSeparator = (prevItem: Route | VNode | null, index: number) => { + if (isSeparatorGenerator) { + return (separator as SeparatorGeneratorFunc)({ prevItem, index }); + } + return separator; + }; const itemRender = props.itemRender || slots.itemRender || defaultItemRender; if (routes && routes.length > 0) { @@ -139,7 +154,7 @@ export default defineComponent({ crumbs = genForRoutes({ routes, params, - separator, + separator: getSeparator, itemRender, }); } else if (children.length) { @@ -150,7 +165,9 @@ export default defineComponent({ 'Breadcrumb', "Only accepts Breadcrumb.Item and Breadcrumb.Separator as it's children", ); - return cloneVNode(element, { separator, key: index }); + const prevItem = index > 0 ? children[index - 1] : null; + const itemSeparator = getSeparator(prevItem, index); + return cloneVNode(element, { separator: itemSeparator, key: index }); }); } diff --git a/components/breadcrumb/demo/separator-indepent.vue b/components/breadcrumb/demo/separator-indepent.vue index 2f03d93825..8be0b8e560 100644 --- a/components/breadcrumb/demo/separator-indepent.vue +++ b/components/breadcrumb/demo/separator-indepent.vue @@ -8,15 +8,18 @@ title: ## zh-CN -使用 `Breadcrumb.Separator` 可以自定义分隔符。 +使用 `Breadcrumb.Separator` 可以自定义分隔符,也可以传入一个函数来动态生成分隔符。 ## en-US The separator can be customized by setting the separator property: `Breadcrumb.Separator`. +You can also pass a generator function that receives the previous item and index to dynamically generate separators. + + diff --git a/components/breadcrumb/index.ts b/components/breadcrumb/index.ts index 6ef68e149e..f65e09e335 100644 --- a/components/breadcrumb/index.ts +++ b/components/breadcrumb/index.ts @@ -3,7 +3,7 @@ import Breadcrumb from './Breadcrumb'; import BreadcrumbItem from './BreadcrumbItem'; import BreadcrumbSeparator from './BreadcrumbSeparator'; -export type { BreadcrumbProps } from './Breadcrumb'; +export type { BreadcrumbProps, SeparatorGeneratorFunc } from './Breadcrumb'; export type { BreadcrumbItemProps } from './BreadcrumbItem'; export type { BreadcrumbSeparatorProps } from './BreadcrumbSeparator'; diff --git a/replit.md b/replit.md new file mode 100644 index 0000000000..dc7b8dbc1f --- /dev/null +++ b/replit.md @@ -0,0 +1,41 @@ +# Ant Design Vue + +## Overview +This is the Ant Design Vue component library - an enterprise-class UI design language and Vue-based implementation. This repository contains both the component library source code and the documentation site. + +## Project Structure +- `components/` - Vue 3 component library source code +- `site/` - Vite-powered documentation site +- `scripts/` - Build and utility scripts +- `plugin/` - Custom Vite plugins for documentation processing +- `antd-tools/` - Build tooling for the component library + +## Development Setup +The project uses: +- **Node.js 20** - JavaScript runtime +- **Vite 3** - Development server and build tool +- **Vue 3** - Frontend framework +- **Less** - CSS preprocessing +- **TypeScript** - Type-safe JavaScript + +## Running the Project +The dev server runs on port 5000: +```bash +npm run dev +``` + +This starts the documentation site with hot reload for development. + +## Key Scripts +- `npm run dev` - Start development server +- `npm run build` - Build the documentation site for production +- `npm run compile` - Compile the component library +- `npm run test` - Run tests + +## Configuration +- Vite config: `site/vite.config.ts` +- TypeScript config: `tsconfig.json` +- ESLint config: `.eslintrc.js` + +## Recent Changes +- December 2024: Configured for Replit environment with port 5000 diff --git a/site/vite.config.ts b/site/vite.config.ts index 5e913e7617..663c35088e 100644 --- a/site/vite.config.ts +++ b/site/vite.config.ts @@ -19,7 +19,8 @@ export default { }, }, server: { - host: true, + host: '0.0.0.0', + port: 5000, }, plugins: [ vueJsx({