Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fix/issue-4264
Browse files Browse the repository at this point in the history
  • Loading branch information
chenkeyao.chenkeya committed Jan 11, 2024
2 parents b2fa390 + 5d9dbee commit 9d3a530
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 14 deletions.
20 changes: 20 additions & 0 deletions components/date-picker2/__tests__/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,26 @@ describe('Picker', () => {
wrapper.unmount();
wrapper = null;
}
});
// fix: https://github.com/alibaba-fusion/next/issues/3877
it('should not select default endDate',()=>{
const currentDate = dayjs();
const currentDateStr = currentDate.format('YYYY-MM-DD');
const disabledDate = function (date, mode) {
return currentDate.date() !== date.date();
};
wrapper = mount(<RangePicker visible showTime disabledDate={disabledDate} />);
clickDate(currentDateStr);
clickTime('12');
clickTime('12', 'minute');
clickTime('12', 'second');
assert.deepEqual(getStrValue(), [`${currentDateStr} 12:12:12`, '']);
clickOk();
clickTime('16');
clickTime('16', 'minute');
clickTime('35', 'second');
clickOk();
assert.deepEqual(getStrValue(), [`${currentDateStr} 12:12:12`, `${currentDateStr} 16:16:35`]);
});
// https://github.com/alibaba-fusion/next/issues/2641
it('value controlled issue', () => {
Expand Down
4 changes: 2 additions & 2 deletions components/date-picker2/panels/range-panel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ class RangePanel extends React.Component {
if (!curDateVal) {
curDateVal =
inputType === BEGIN && end
? end.subtract(1, 'day')
? end
: inputType === END && begin
? begin.add(1, 'day')
? begin
: datejs();
}
curDateVal = setTime(curDateVal, v);
Expand Down
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
2 changes: 1 addition & 1 deletion components/rating/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
top: calc(100% + #{$s-1});
left: 0;
border: 1px solid $color-fill1-4;
background: $color-white;
background: $rating-grade-background;
padding: 4px 8px 3px;
font-size: 12px;
white-space: nowrap;
Expand Down
4 changes: 4 additions & 0 deletions components/rating/scss/variable.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ $rating-grade-high-overlay-hover-color: $color-brand1-6 !default;
/// rating icon
/// @namespace statement/normal
$rating-grade-icon-content: $icon-content-favorites-filling !default;

/// rating tip background
/// @namespace statement/normal
$rating-grade-background: $color-white !default;
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
21 changes: 20 additions & 1 deletion tools/serve/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { existsSync, readFileSync, readdirSync } from 'fs-extra';
import createDocParser from '@alifd/doc-parser';
import MagicString from 'magic-string';
import { kebabCase } from 'lodash';
import { ARGV, SRC_DIR_PATH, TARGETS, findFile, logger, parseImportDeclarations } from '../utils';
import { glob } from 'glob';
import { ARGV, SRC_DIR_PATH, TARGETS, findFile, logger, parseImportDeclarations, warn } from '../utils';
import { marked } from '../build/docs/utils';
import { parseDemoMd } from '../build/docs/generate-docs';

Expand Down Expand Up @@ -80,8 +81,15 @@ const demoPlugin = (dirName: string): VitePlugin => {
cssEntry: existsSync(cssEntryPath) ? cssEntryPath : undefined,
jsEntry: existsSync(demoEntryPath) ? demoEntryPath : undefined,
};
}).filter(t => {
if (!t.jsEntry) {
warn(`Not found demo index.tsx: ${t.id}`)
}
return !!t.jsEntry
});
}
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 +120,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 9d3a530

Please sign in to comment.