Skip to content

Commit

Permalink
Merge branch 'alibaba-fusion:master' into feat/TextArea-hasClear
Browse files Browse the repository at this point in the history
  • Loading branch information
YunMeng99 authored Jan 10, 2024
2 parents 18bf920 + 110937b commit f0662b1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 2 additions & 0 deletions components/field/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export function scrollToFirstError({ errorsGroup, options, instance }) {
window.scrollTo(offsetLeft, firstTop + options.scrollToFirstError);
} else if (firstNode.scrollIntoViewIfNeeded) {
firstNode.scrollIntoViewIfNeeded(true);
} else {
firstNode.scrollIntoView({ block: 'center' });
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/form/form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export default class Form extends React.Component {
dir={rtl ? 'rtl' : undefined}
onSubmit={onSubmit}
>
{responsive ? <RGrid gap={gap}>{newChildren}</RGrid> : newChildren}
{responsive ? <RGrid gap={gap} device={device}>{newChildren}</RGrid> : newChildren}
</Tag>
);
}
Expand Down
10 changes: 1 addition & 9 deletions tools/serve/demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react';
import doc from '__doc';
// @ts-expect-error __demos
import demos from '__demos';
import '__scss';
import './demo.css';
import '../../index.scss';

function DemoItem({ id, doc, render }: { id: string; doc: string; render(): void }) {
React.useEffect(() => {
Expand Down Expand Up @@ -39,14 +39,6 @@ export default function Demo() {
>
{nextLang}
</button>
<button
className="demo-actions-item"
onClick={() => {
location.href = '/theme';
}}
>
theme
</button>
</div>
<section className="demo-doc" dangerouslySetInnerHTML={{ __html: doc }}></section>
<br />
Expand Down
14 changes: 14 additions & 0 deletions tools/serve/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { existsSync, readFileSync, readdirSync } from 'fs-extra';
import createDocParser from '@alifd/doc-parser';
import MagicString from 'magic-string';
import { kebabCase } from 'lodash';
import { glob } from 'glob';
import { ARGV, SRC_DIR_PATH, TARGETS, findFile, logger, parseImportDeclarations } from '../utils';
import { marked } from '../build/docs/utils';
import { parseDemoMd } from '../build/docs/generate-docs';
Expand Down Expand Up @@ -82,6 +83,8 @@ const demoPlugin = (dirName: string): VitePlugin => {
};
});
}
const SCSS_REG = /^__scss/;
const SCSS_VIRTUAL_REG = /^\0__scss\.scss/;
const DOC_REG = /^__doc/;
const DEMOS_REG = /^__demos/;
const DOC_VIRTUAL_REG = /^\0__doc/;
Expand Down Expand Up @@ -112,11 +115,22 @@ const demoPlugin = (dirName: string): VitePlugin => {
return html.replace(/\$name/g, dirName);
},
resolveId(source) {
if (SCSS_REG.test(source)) {
return `\0${source}.scss`;
}
if (DOC_REG.test(source) || DEMOS_REG.test(source)) {
return `\0${source}`;
}
},
load(id) {
if (SCSS_VIRTUAL_REG.test(id)) {
const fixedFiles: string[] = [resolve(SRC_DIR_PATH, 'core/reset.scss')];
const mainFiles = glob.sync('*/main.scss', { cwd: SRC_DIR_PATH, absolute: true });
return fixedFiles
.concat(mainFiles)
.map(f => `@import "${f}";`)
.join('\n');
}
if (DOC_VIRTUAL_REG.test(id)) {
const { doc, files } = loadComponentDoc(dirName);
files.forEach(f => this.addWatchFile(f));
Expand Down

0 comments on commit f0662b1

Please sign in to comment.