style: remove omit.js

v2.3
tangjinzhou 2021-09-23 14:36:23 +08:00
parent 8e111e6a7c
commit 365a32be26
21 changed files with 36 additions and 56 deletions

View File

@ -12,7 +12,6 @@ import {
} from 'vue';
import PropTypes from '../_util/vue-types';
import classNames from '../_util/classNames';
import omit from 'omit.js';
import ResizeObserver from '../vc-resize-observer';
import throttleByAnimationFrame from '../_util/throttleByAnimationFrame';
import { withInstall } from '../_util/type';
@ -24,6 +23,7 @@ import {
getFixedBottom,
} from './utils';
import useConfigInject from '../_util/hooks/useConfigInject';
import omit from '../_util/omit';
function getDefaultTarget() {
return typeof window !== 'undefined' ? window : null;

View File

@ -4,10 +4,10 @@ import Select, { selectProps } from '../select';
import PropTypes from '../_util/vue-types';
import { defaultConfigProvider } from '../config-provider';
import { getComponent, getOptionProps, isValidElement, getSlot } from '../_util/props-util';
import Omit from 'omit.js';
import warning from '../_util/warning';
import Option from './Option';
import OptGroup from './OptGroup';
import omit from '../_util/omit';
function isSelectOptionOrSelectOptGroup(child: any): boolean {
return child?.type?.isSelectOption || child?.type?.isSelectOptGroup;
@ -134,7 +134,7 @@ const AutoComplete = defineComponent({
: [];
}
const selectProps = {
...Omit(getOptionProps(this), ['dataSource', 'optionLabelProp']),
...omit(getOptionProps(this) as any, ['dataSource', 'optionLabelProp']),
...this.$attrs,
mode: Select.SECRET_COMBOBOX_MODE_DO_NOT_USE,
// optionLabelProp,

View File

@ -4,7 +4,6 @@ import PropTypes from '../_util/vue-types';
import VcCascader from '../vc-cascader';
import arrayTreeFilter from 'array-tree-filter';
import classNames from '../_util/classNames';
import omit from 'omit.js';
import KeyCode from '../_util/KeyCode';
import Input from '../input';
import CloseCircleFilled from '@ant-design/icons-vue/CloseCircleFilled';
@ -28,6 +27,7 @@ import type { VueNode } from '../_util/type';
import { tuple, withInstall } from '../_util/type';
import type { RenderEmptyHandler } from '../config-provider/renderEmpty';
import { useInjectFormItemContext } from '../form/FormItemContext';
import omit from '../_util/omit';
export interface CascaderOptionType {
value?: string | number;

View File

@ -1,7 +1,6 @@
import type { CSSProperties } from 'vue';
import { inject, provide, nextTick, defineComponent } from 'vue';
import classnames from '../_util/classNames';
import omit from 'omit.js';
import VcDrawer from '../vc-drawer/src';
import PropTypes from '../_util/vue-types';
import BaseMixin from '../_util/BaseMixin';
@ -9,6 +8,7 @@ import CloseOutlined from '@ant-design/icons-vue/CloseOutlined';
import { getComponent, getOptionProps } from '../_util/props-util';
import { defaultConfigProvider } from '../config-provider';
import { tuple, withInstall } from '../_util/type';
import omit from '../_util/omit';
const PlacementTypes = tuple('top', 'right', 'bottom', 'left');
type placementType = typeof PlacementTypes[number];

View File

@ -2,12 +2,12 @@ import type { VNode } from 'vue';
import { defineComponent, inject, nextTick, withDirectives } from 'vue';
import antInputDirective from '../_util/antInputDirective';
import classNames from '../_util/classNames';
import omit from 'omit.js';
import inputProps from './inputProps';
import { hasProp, getComponent, getOptionProps } from '../_util/props-util';
import { defaultConfigProvider } from '../config-provider';
import ClearableLabeledInput from './ClearableLabeledInput';
import { useInjectFormItemContext } from '../form/FormItemContext';
import omit from '../_util/omit';
export function fixControlledValue(value: string | number) {
if (typeof value === 'undefined' || value === null) {

View File

@ -1,7 +1,6 @@
import type { PropType, VNode } from 'vue';
import { nextTick, defineComponent, withDirectives } from 'vue';
import ResizeObserver from '../vc-resize-observer';
import omit from 'omit.js';
import classNames from '../_util/classNames';
import calculateNodeHeight from './calculateNodeHeight';
import raf from '../_util/raf';
@ -11,6 +10,7 @@ import inputProps from './inputProps';
import PropTypes from '../_util/vue-types';
import { getOptionProps } from '../_util/props-util';
import antInput from '../_util/antInputDirective';
import omit from '../_util/omit';
const RESIZE_STATUS_NONE = 0;
const RESIZE_STATUS_RESIZING = 1;

View File

@ -1,13 +1,13 @@
import type { App, PropType, Plugin, ExtractPropTypes } from 'vue';
import { watch, ref, onMounted, defineComponent, nextTick } from 'vue';
import classNames from '../_util/classNames';
import omit from 'omit.js';
import PropTypes from '../_util/vue-types';
import VcMentions from '../vc-mentions';
import { mentionsProps as baseMentionsProps } from '../vc-mentions/src/mentionsProps';
import useConfigInject from '../_util/hooks/useConfigInject';
import { flattenChildren, getOptionProps } from '../_util/props-util';
import { useInjectFormItemContext } from '../form/FormItemContext';
import omit from '../_util/omit';
const { Option } = VcMentions;

View File

@ -2,9 +2,8 @@ import { createVNode, render as vueRender } from 'vue';
import ConfirmDialog from './ConfirmDialog';
import type { ModalFuncProps } from './Modal';
import { destroyFns } from './Modal';
import Omit from 'omit.js';
import ConfigProvider, { globalConfig } from '../config-provider';
import omit from '../_util/omit';
const defaultRootPrefixCls = '';
@ -16,7 +15,7 @@ const confirm = (config: ModalFuncProps) => {
const div = document.createElement('div');
document.body.appendChild(div);
let currentConfig = {
...Omit(config, ['parentContext', 'appContext']),
...omit(config, ['parentContext', 'appContext']),
close,
visible: true,
} as any;

View File

@ -1,4 +1,3 @@
import omit from 'omit.js';
import type { ExtractPropTypes, PropType } from 'vue';
import { computed, onMounted, ref, toRef, defineComponent } from 'vue';
import Tooltip from '../tooltip';
@ -19,6 +18,7 @@ import useConfigInject from '../_util/hooks/useConfigInject';
import classNames from '../_util/classNames';
import { getTransitionName } from '../_util/transition';
import { cloneVNodes } from '../_util/vnode';
import omit from '../_util/omit';
export const popconfirmProps = () => ({
...abstractTooltipProps(),

View File

@ -5,7 +5,7 @@ import { tuple } from '../_util/type';
import useConfigInject from '../_util/hooks/useConfigInject';
import type { SkeletonElementProps } from './Element';
import Element, { skeletonElementProps } from './Element';
import Omit from 'omit.js';
import omit from '../_util/omit';
export interface SkeletonInputProps extends Omit<SkeletonElementProps, 'size' | 'shape'> {
size?: 'large' | 'small' | 'default';
@ -14,7 +14,7 @@ export interface SkeletonInputProps extends Omit<SkeletonElementProps, 'size' |
const SkeletonInput = defineComponent({
name: 'ASkeletonInput',
props: {
...Omit(skeletonElementProps(), 'shape'),
...omit(skeletonElementProps(), ['shape']),
size: PropTypes.oneOf(tuple('large', 'small', 'default')),
},
setup(props) {

View File

@ -7,9 +7,9 @@ import Wave from '../_util/wave';
import warning from '../_util/warning';
import { tuple, withInstall } from '../_util/type';
import { getPropsSlot } from '../_util/props-util';
import Omit from 'omit.js';
import useConfigInject from '../_util/hooks/useConfigInject';
import { useInjectFormItemContext } from '../form/FormItemContext';
import omit from '../_util/omit';
export const SwitchSizes = tuple('small', 'default');
type CheckedType = boolean | string | number;
@ -72,7 +72,9 @@ const Switch = defineComponent({
'`value` is not validate prop, do you mean `checked`?',
);
});
const checked = ref(props.checked !== undefined ? props.checked : attrs.defaultChecked);
const checked = ref<string | number | boolean>(
props.checked !== undefined ? props.checked : (attrs.defaultChecked as boolean),
);
const checkedStatus = computed(() => checked.value === props.checkedValue);
watch(
@ -146,13 +148,12 @@ const Switch = defineComponent({
return () => (
<Wave insertExtraNode>
<button
{...Omit(props, [
{...omit(props, [
'prefixCls',
'checkedChildren',
'unCheckedChildren',
'checked',
'autofocus',
'defaultChecked',
'checkedValue',
'unCheckedValue',
'id',
@ -165,7 +166,7 @@ const Switch = defineComponent({
onMouseup={handleMouseUp}
type="button"
role="switch"
aria-checked={checked.value}
aria-checked={checked.value as any}
disabled={props.disabled || props.loading}
class={[attrs.class, classNames.value]}
ref={refSwitchNode}

View File

@ -1,4 +1,3 @@
import omit from 'omit.js';
import LocaleReceiver from '../locale-provider/LocaleReceiver';
import warning from '../_util/warning';
import TransButton from '../_util/transButton';
@ -31,6 +30,7 @@ import {
import type { AutoSizeType } from '../input/ResizableTextArea';
import useConfigInject from '../_util/hooks/useConfigInject';
import type { EventHandler } from '../_util/EventInterface';
import omit from '../_util/omit';
export type BaseType = 'secondary' | 'success' | 'warning' | 'danger';

View File

@ -2,8 +2,8 @@ import type { AnchorHTMLAttributes, FunctionalComponent } from 'vue';
import warning from '../_util/warning';
import type { BlockProps } from './Base';
import Base, { baseProps } from './Base';
import Omit from 'omit.js';
import PropTypes from '../_util/vue-types';
import omit from '../_util/omit';
export interface LinkProps extends BlockProps, Omit<AnchorHTMLAttributes, 'type'> {
ellipsis?: boolean;
@ -31,6 +31,6 @@ const Link: FunctionalComponent<LinkProps> = (props, { slots, attrs }) => {
Link.displayName = 'ATypographyLink';
Link.inheritAttrs = false;
Link.props = Omit({ ...baseProps(), ellipsis: PropTypes.looseBool }, ['component']);
Link.props = omit({ ...baseProps(), ellipsis: PropTypes.looseBool }, ['component']) as any;
export default Link;

View File

@ -1,5 +1,5 @@
import Omit from 'omit.js';
import type { FunctionalComponent } from 'vue';
import omit from '../_util/omit';
import type { BlockProps } from './Base';
import Base, { baseProps } from './Base';
@ -15,6 +15,6 @@ const Paragraph: FunctionalComponent<BlockProps> = (props, { slots, attrs }) =>
Paragraph.displayName = 'ATypographyParagraph';
Paragraph.inheritAttrs = false;
Paragraph.props = Omit(baseProps(), ['component']);
Paragraph.props = omit(baseProps(), ['component']) as any;
export default Paragraph;

View File

@ -1,8 +1,8 @@
import type { FunctionalComponent } from 'vue';
import omit from '../_util/omit';
import warning from '../_util/warning';
import type { BlockProps, EllipsisConfig } from './Base';
import Base, { baseProps } from './Base';
import Omit from 'omit.js';
export interface TextProps extends BlockProps {
ellipsis?: boolean | Omit<EllipsisConfig, 'expandable' | 'rows' | 'onExpand'>;
@ -21,7 +21,7 @@ const Text: FunctionalComponent<TextProps> = (props, { slots, attrs }) => {
...props,
ellipsis:
ellipsis && typeof ellipsis === 'object'
? Omit(ellipsis as any, ['expandable', 'rows'])
? omit(ellipsis as any, ['expandable', 'rows'])
: ellipsis,
component: 'span',
...attrs,
@ -31,6 +31,6 @@ const Text: FunctionalComponent<TextProps> = (props, { slots, attrs }) => {
Text.displayName = 'ATypographyText';
Text.inheritAttrs = false;
Text.props = Omit(baseProps(), ['component']);
Text.props = omit(baseProps(), ['component']) as any;
export default Text;

View File

@ -1,5 +1,5 @@
import Omit from 'omit.js';
import type { FunctionalComponent } from 'vue';
import omit from '../_util/omit';
import { tupleNum } from '../_util/type';
import PropTypes from '../_util/vue-types';
import warning from '../_util/warning';
@ -31,6 +31,6 @@ const Title: FunctionalComponent<TitleProps> = (props, { slots, attrs }) => {
Title.displayName = 'ATypographyTitle';
Title.inheritAttrs = false;
Title.props = Omit({ ...baseProps(), level: PropTypes.number }, ['component', 'strong']);
Title.props = omit({ ...baseProps(), level: PropTypes.number }, ['component', 'strong']) as any;
export default Title;

View File

@ -12,7 +12,6 @@ import {
computed,
} from 'vue';
import classNames from '../../_util/classNames';
import omit from 'omit.js';
import KeyCode from '../../_util/KeyCode';
import { initDefaultProps } from '../../_util/props-util';
import {
@ -26,6 +25,8 @@ import { vcMentionsProps, defaultProps } from './mentionsProps';
import type { OptionProps } from './Option';
import MentionsContextKey from './MentionsContext';
import antInputDirective from '../../_util/antInputDirective';
import omit from '../../_util/omit';
import type { EventHandler } from '../../_util/EventInterface';
export type MentionsProps = Partial<ExtractPropTypes<typeof vcMentionsProps>>;
@ -59,7 +60,7 @@ export default defineComponent({
emit('change', val);
};
const onChange = ({ target: { value, composing }, isComposing }) => {
const onChange: EventHandler = ({ target: { value, composing }, isComposing }) => {
if (isComposing || composing) return;
triggerChange(value);
};

View File

@ -1,24 +1,6 @@
import type { MentionsProps } from './Mentions';
import type { OptionProps } from './Option';
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
type OmitFunc = <T extends object, K extends [...(keyof T)[]]>(
obj: T,
...keys: K
) => { [K2 in Exclude<keyof T, K[number]>]: T[K2] };
export const omit: OmitFunc = (obj, ...keys) => {
const clone = {
...obj,
};
keys.forEach(key => {
delete clone[key];
});
return clone;
};
/**
* Cut input selection into 2 part and return text before selection start
*/

View File

@ -10,11 +10,11 @@ import type {
} from '../interface';
import { getPosition, isTreeNode } from '../util';
import { warning } from '../../vc-util/warning';
import Omit from 'omit.js';
import type { VNodeChild } from 'vue';
import { camelize } from 'vue';
import type { TreeNodeProps } from '../props';
import { filterEmpty } from '../../_util/props-util';
import omit from '../../_util/omit';
export function getKey(key: Key, pos: string) {
if (key !== null && key !== undefined) {
@ -141,7 +141,7 @@ export function flattenTreeData(
// Add FlattenDataNode into list
const flattenNode: FlattenNode = {
...Omit(treeNode, [fieldTitle, fieldKey, fieldChildren] as any),
...omit(treeNode, [fieldTitle, fieldKey, fieldChildren] as any),
title: treeNode[fieldTitle],
key: mergedKey,
parent,

View File

@ -134,6 +134,7 @@
"cross-env": "^7.0.0",
"css-loader": "^5.0.0",
"css-minimizer-webpack-plugin": "^3.0.0",
"date-fns": "^2.24.0",
"deep-assign": "^3.0.0",
"diacritics": "^1.3.0",
"docsearch.js": "^2.6.3",
@ -183,6 +184,7 @@
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"mockdate": "^2.0.2",
"moment": "^2.29.1",
"nprogress": "^0.2.0",
"object-assign": "^4.1.1",
"postcss": "^8.2.12",
@ -244,14 +246,11 @@
"@simonwep/pickr": "~1.8.0",
"array-tree-filter": "^2.1.0",
"async-validator": "^3.3.0",
"date-fns": "^2.22.1",
"dayjs": "^1.10.5",
"dom-align": "^1.12.1",
"dom-scroll-into-view": "^2.0.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.15",
"moment": "^2.27.0",
"omit.js": "^2.0.0",
"resize-observer-polyfill": "^1.5.1",
"scroll-into-view-if-needed": "^2.2.25",
"shallow-equal": "^1.0.0",

View File

@ -1,5 +1,3 @@
declare module 'omit.js';
declare module '*.json' {
const value: any;
export const version: string;