Skip to content

Commit

Permalink
chore: auto merge branches (#43920)
Browse files Browse the repository at this point in the history
chore: master merge feature
  • Loading branch information
github-actions[bot] authored Jul 31, 2023
2 parents 4eb6074 + 8a16594 commit fc45356
Show file tree
Hide file tree
Showing 168 changed files with 46,097 additions and 44,300 deletions.
12 changes: 12 additions & 0 deletions components/_util/ActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export interface ActionButtonProps {
emitEvent?: boolean;
quitOnNullishReturnValue?: boolean;
children?: React.ReactNode;

/**
* Do not throw if is await mode
*/
isSilent?: () => boolean;
}

function isThenable<T extends any>(thing?: PromiseLike<T>): boolean {
Expand All @@ -29,6 +34,7 @@ const ActionButton: React.FC<ActionButtonProps> = (props) => {
close,
autoFocus,
emitEvent,
isSilent,
quitOnNullishReturnValue,
actionFn,
} = props;
Expand Down Expand Up @@ -70,6 +76,12 @@ const ActionButton: React.FC<ActionButtonProps> = (props) => {
// See: https://github.com/ant-design/ant-design/issues/6183
setLoading(false, true);
clickedRef.current = false;

// Do not throw if is `await` mode
if (isSilent?.()) {
return;
}

return Promise.reject(e);
},
);
Expand Down
7 changes: 5 additions & 2 deletions components/_util/wave/WaveEffect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { render, unmount } from 'rc-util/lib/React/render';
import raf from 'rc-util/lib/raf';
import * as React from 'react';
import { getTargetWaveColor } from './util';
import type { ShowWaveEffect } from './useWave';

function validateNum(value: number) {
return Number.isNaN(value) ? 0 : value;
Expand Down Expand Up @@ -125,7 +126,7 @@ const WaveEffect: React.FC<WaveEffectProps> = (props) => {
);
};

export default function showWaveEffect(node: HTMLElement, className: string) {
const showWaveEffect: ShowWaveEffect = (node, { className }) => {
// Create holder
const holder = document.createElement('div');
holder.style.position = 'absolute';
Expand All @@ -134,4 +135,6 @@ export default function showWaveEffect(node: HTMLElement, className: string) {
node?.insertBefore(holder, node?.firstChild);

render(<WaveEffect target={node} className={className} />, holder);
}
};

export default showWaveEffect;
7 changes: 4 additions & 3 deletions components/_util/wave/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import useWave from './useWave';
export interface WaveProps {
disabled?: boolean;
children?: React.ReactNode;
component?: string;
}

const Wave: React.FC<WaveProps> = (props) => {
const { children, disabled } = props;
const { children, disabled, component } = props;
const { getPrefixCls } = useContext<ConfigConsumerProps>(ConfigContext);
const containerRef = useRef<HTMLElement>(null);

Expand All @@ -23,7 +24,7 @@ const Wave: React.FC<WaveProps> = (props) => {
const [, hashId] = useStyle(prefixCls);

// =============================== Wave ===============================
const showWave = useWave(containerRef, classNames(prefixCls, hashId));
const showWave = useWave(containerRef, classNames(prefixCls, hashId), component);

// ============================== Effect ==============================
React.useEffect(() => {
Expand All @@ -48,7 +49,7 @@ const Wave: React.FC<WaveProps> = (props) => {
return;
}

showWave();
showWave(e);
};

// Bind events
Expand Down
34 changes: 30 additions & 4 deletions components/_util/wave/useWave.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
import * as React from 'react';
import useEvent from 'rc-util/lib/hooks/useEvent';
import showWaveEffect from './WaveEffect';
import { ConfigContext } from '../../config-provider';
import useToken from '../../theme/useToken';
import type { GlobalToken } from '../../theme';

export type ShowWaveEffect = (
element: HTMLElement,
info: {
className: string;
token: GlobalToken;
component?: string;
event: MouseEvent;
},
) => void;

export default function useWave(
nodeRef: React.RefObject<HTMLElement>,
className: string,
): VoidFunction {
function showWave() {
component?: string,
) {
const { wave } = React.useContext(ConfigContext);
const [, token] = useToken();

const showWave = useEvent((event: MouseEvent) => {
const node = nodeRef.current!;

showWaveEffect(node, className);
}
if (wave?.disabled || !node) {
return;
}

const { showEffect } = wave || {};

// Customize wave effect
(showEffect || showWaveEffect)(node, { className, token, component, event });
});

return showWave;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,98 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders components/auto-complete/demo/allowClear.tsx extend context correctly 1`] = `
Array [
<div
class="ant-select ant-select-auto-complete ant-select-single ant-select-show-search"
style="width: 200px;"
>
<div
class="ant-select-selector"
>
<span
class="ant-select-selection-search"
>
<input
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
aria-haspopup="listbox"
aria-owns="rc_select_TEST_OR_SSR_list"
autocomplete="off"
class="ant-select-selection-search-input"
id="rc_select_TEST_OR_SSR"
role="combobox"
type="search"
value=""
/>
</span>
<span
class="ant-select-selection-placeholder"
>
UnClearable
</span>
</div>
<div
class="ant-select-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up ant-select-dropdown-empty ant-select-dropdown-placement-bottomLeft"
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; box-sizing: border-box;"
>
<div>
<div
class="ant-select-item-empty"
id="rc_select_TEST_OR_SSR_list"
role="listbox"
/>
</div>
</div>
</div>,
<br />,
<br />,
<div
class="ant-select ant-select-auto-complete ant-select-single ant-select-allow-clear ant-select-show-search"
style="width: 200px;"
>
<div
class="ant-select-selector"
>
<span
class="ant-select-selection-search"
>
<input
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
aria-haspopup="listbox"
aria-owns="rc_select_TEST_OR_SSR_list"
autocomplete="off"
class="ant-select-selection-search-input"
id="rc_select_TEST_OR_SSR"
role="combobox"
type="search"
value=""
/>
</span>
<span
class="ant-select-selection-placeholder"
>
Customized clear icon
</span>
</div>
<div
class="ant-select-dropdown ant-slide-up-appear ant-slide-up-appear-prepare ant-slide-up ant-select-dropdown-empty ant-select-dropdown-placement-bottomLeft"
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; box-sizing: border-box;"
>
<div>
<div
class="ant-select-item-empty"
id="rc_select_TEST_OR_SSR_list"
role="listbox"
/>
</div>
</div>
</div>,
]
`;

exports[`renders components/auto-complete/demo/basic.tsx extend context correctly 1`] = `
Array [
<div
Expand All @@ -13,7 +106,6 @@ Array [
class="ant-select-selection-search"
>
<input
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down Expand Up @@ -59,7 +151,6 @@ Array [
class="ant-select-selection-search"
>
<input
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down Expand Up @@ -107,7 +198,6 @@ exports[`renders components/auto-complete/demo/borderless.tsx extend context cor
class="ant-select-selection-search"
>
<input
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down Expand Up @@ -160,7 +250,6 @@ exports[`renders components/auto-complete/demo/certain-category.tsx extend conte
class="ant-input-wrapper ant-input-group"
>
<input
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down Expand Up @@ -518,7 +607,6 @@ exports[`renders components/auto-complete/demo/custom.tsx extend context correct
class="ant-select-selection-search"
>
<textarea
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down Expand Up @@ -592,7 +680,6 @@ exports[`renders components/auto-complete/demo/form-debug.tsx extend context cor
class="ant-select-selection-search"
>
<input
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down Expand Up @@ -925,7 +1012,6 @@ exports[`renders components/auto-complete/demo/form-debug.tsx extend context cor
class="ant-select-selection-search"
>
<input
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down Expand Up @@ -1000,7 +1086,6 @@ exports[`renders components/auto-complete/demo/form-debug.tsx extend context cor
class="ant-input-affix-wrapper ant-select-selection-search-input"
>
<input
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down Expand Up @@ -1216,7 +1301,6 @@ exports[`renders components/auto-complete/demo/form-debug.tsx extend context cor
class="ant-input-affix-wrapper ant-select-selection-search-input"
>
<input
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down Expand Up @@ -1436,7 +1520,6 @@ exports[`renders components/auto-complete/demo/form-debug.tsx extend context cor
class="ant-input-wrapper ant-input-group"
>
<input
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down Expand Up @@ -1666,7 +1749,6 @@ exports[`renders components/auto-complete/demo/form-debug.tsx extend context cor
class="ant-input-wrapper ant-input-group"
>
<input
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down Expand Up @@ -1783,7 +1865,6 @@ exports[`renders components/auto-complete/demo/non-case-sensitive.tsx extend con
class="ant-select-selection-search"
>
<input
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down Expand Up @@ -1906,7 +1987,6 @@ exports[`renders components/auto-complete/demo/options.tsx extend context correc
class="ant-select-selection-search"
>
<input
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down Expand Up @@ -1988,7 +2068,6 @@ exports[`renders components/auto-complete/demo/render-panel.tsx extend context c
class="ant-select-selection-search"
>
<input
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down Expand Up @@ -2135,7 +2214,6 @@ exports[`renders components/auto-complete/demo/status.tsx extend context correct
class="ant-select-selection-search"
>
<input
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down Expand Up @@ -2181,7 +2259,6 @@ exports[`renders components/auto-complete/demo/status.tsx extend context correct
class="ant-select-selection-search"
>
<input
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down Expand Up @@ -2234,7 +2311,6 @@ exports[`renders components/auto-complete/demo/uncertain-category.tsx extend con
class="ant-input-wrapper ant-input-group"
>
<input
aria-activedescendant="rc_select_TEST_OR_SSR_list_-1"
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
Expand Down
Loading

0 comments on commit fc45356

Please sign in to comment.