Browse Source

refactor: replement deprecated fields (#7519)

pull/7534/head
extclp 7 months ago committed by GitHub
parent
commit
d6cc262c3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      antd-tools/generator-types/src/index.ts
  2. 8
      antd-tools/generator-types/src/parser.ts
  3. 3
      antd-tools/getTSCommonConfig.js
  4. 2
      components/_util/getScroll.ts
  5. 4
      components/_util/scrollTo.ts
  6. 8
      components/_util/triggerEvent.ts
  7. 2
      components/checkbox/Group.tsx
  8. 2
      components/menu/src/Menu.tsx
  9. 2
      components/menu/src/hooks/useItems.tsx
  10. 2
      components/rate/util.ts
  11. 4
      components/tree/demo/search.vue
  12. 2
      components/vc-image/src/PreviewGroup.tsx
  13. 2
      components/vc-picker/panels/TimePanel/TimeUnitColumn.tsx
  14. 2
      components/vc-slider/src/common/createSlider.tsx
  15. 2
      components/vc-slider/src/utils.ts
  16. 2
      components/vc-tree-select/hooks/useDataEntities.ts
  17. 2
      components/vc-tree/utils/treeUtil.ts
  18. 5
      components/vc-util/Dom/css.ts
  19. 2
      components/vc-util/isMobile.ts
  20. 5
      package.json
  21. 4
      site/src/components/vue-colorful/components/common/Interactive.tsx
  22. 2
      site/src/components/vue-colorful/hooks/useStyleSheet.ts
  23. 2
      site/src/layouts/header/Menu.vue

6
antd-tools/generator-types/src/index.ts

@ -21,13 +21,13 @@ async function readMarkdown(options: Options): Promise<Map<String, VueTag>> {
return formatter(mdParser(fileContent), componentName, kebabComponentName, options.tagPrefix); return formatter(mdParser(fileContent), componentName, kebabComponentName, options.tagPrefix);
}) })
.filter(item => item) as VueTag[][]; .filter(item => item) as VueTag[][];
const tags: Map<String, VueTag> = new Map(); const tags = new Map<String, VueTag>();
flatMap(data, item => item).forEach(mergedTag => mergeTag(tags, mergedTag)); flatMap(data, item => item).forEach(mergedTag => mergeTag(tags, mergedTag));
return tags; return tags;
} }
function readTypings(options: Options): Map<String, VueTag> { function readTypings(options: Options): Map<String, VueTag> {
const tags: Map<String, VueTag> = new Map(); const tags = new Map<String, VueTag>();
const fileContent = readFileSync(options.typingsPath, 'utf-8'); const fileContent = readFileSync(options.typingsPath, 'utf-8');
fileContent fileContent
.split('\n') .split('\n')
@ -61,7 +61,7 @@ function mergeTag(tags: Map<String, VueTag>, mergedTag: VueTag) {
function mergeTags(mergedTagsArr: Map<String, VueTag>[]): VueTag[] { function mergeTags(mergedTagsArr: Map<String, VueTag>[]): VueTag[] {
if (mergedTagsArr.length === 1) return [...mergedTagsArr[0].values()]; if (mergedTagsArr.length === 1) return [...mergedTagsArr[0].values()];
const tags: Map<String, VueTag> = new Map(); const tags = new Map<String, VueTag>();
if (mergedTagsArr.length === 0) return []; if (mergedTagsArr.length === 0) return [];
mergedTagsArr.forEach(mergedTags => { mergedTagsArr.forEach(mergedTags => {
mergedTags.forEach(mergedTag => mergeTag(tags, mergedTag)); mergedTags.forEach(mergedTag => mergeTag(tags, mergedTag));

8
antd-tools/generator-types/src/parser.ts

@ -21,7 +21,7 @@ export type Articals = Artical[];
function readLine(input: string) { function readLine(input: string) {
const end = input.indexOf('\n'); const end = input.indexOf('\n');
return input.substr(0, end !== -1 ? end : input.length); return input.substring(0, end !== -1 ? end : input.length);
} }
function splitTableLine(line: string) { function splitTableLine(line: string) {
@ -47,7 +47,7 @@ function tableParse(input: string) {
}; };
while (start < end) { while (start < end) {
const target = input.substr(start); const target = input.substring(start);
const line = readLine(target); const line = readLine(target);
if (!/^\|/.test(target)) { if (!/^\|/.test(target)) {
@ -79,7 +79,7 @@ export function mdParser(input: string): Articals {
const end = input.length; const end = input.length;
while (start < end) { while (start < end) {
const target = input.substr(start); const target = input.substring(start);
let match; let match;
if ((match = TITLE_REG.exec(target))) { if ((match = TITLE_REG.exec(target))) {
@ -91,7 +91,7 @@ export function mdParser(input: string): Articals {
start += match.index + match[0].length; start += match.index + match[0].length;
} else if ((match = TABLE_REG.exec(target))) { } else if ((match = TABLE_REG.exec(target))) {
const { table, usedLength } = tableParse(target.substr(match.index)); const { table, usedLength } = tableParse(target.substring(match.index));
artical.push({ artical.push({
type: 'table', type: 'table',
table, table,

3
antd-tools/getTSCommonConfig.js

@ -1,7 +1,6 @@
'use strict'; 'use strict';
const fs = require('fs'); const fs = require('fs');
const assign = require('object-assign');
const { getProjectPath } = require('./utils/projectHelper'); const { getProjectPath } = require('./utils/projectHelper');
module.exports = function () { module.exports = function () {
@ -9,7 +8,7 @@ module.exports = function () {
if (fs.existsSync(getProjectPath('tsconfig.json'))) { if (fs.existsSync(getProjectPath('tsconfig.json'))) {
my = require(getProjectPath('tsconfig.json')); my = require(getProjectPath('tsconfig.json'));
} }
return assign( return Object.assign(
{ {
noUnusedParameters: true, noUnusedParameters: true,
noUnusedLocals: true, noUnusedLocals: true,

2
components/_util/getScroll.ts

@ -12,7 +12,7 @@ export default function getScroll(
const method = top ? 'scrollTop' : 'scrollLeft'; const method = top ? 'scrollTop' : 'scrollLeft';
let result = 0; let result = 0;
if (isWindow(target)) { if (isWindow(target)) {
result = target[top ? 'pageYOffset' : 'pageXOffset']; result = target[top ? 'scrollY' : 'scrollX'];
} else if (target instanceof Document) { } else if (target instanceof Document) {
result = target.documentElement[method]; result = target.documentElement[method];
} else if (target instanceof HTMLElement) { } else if (target instanceof HTMLElement) {

4
components/_util/scrollTo.ts

@ -22,8 +22,8 @@ export default function scrollTo(y: number, options: ScrollToOptions = {}) {
const time = timestamp - startTime; const time = timestamp - startTime;
const nextScrollTop = easeInOutCubic(time > duration ? duration : time, scrollTop, y, duration); const nextScrollTop = easeInOutCubic(time > duration ? duration : time, scrollTop, y, duration);
if (isWindow(container)) { if (isWindow(container)) {
(container as Window).scrollTo(window.pageXOffset, nextScrollTop); (container as Window).scrollTo(window.scrollX, nextScrollTop);
} else if (container instanceof Document || container.constructor.name === 'HTMLDocument') { } else if (container instanceof Document) {
(container as Document).documentElement.scrollTop = nextScrollTop; (container as Document).documentElement.scrollTop = nextScrollTop;
} else { } else {
(container as HTMLElement).scrollTop = nextScrollTop; (container as HTMLElement).scrollTop = nextScrollTop;

8
components/_util/triggerEvent.ts

@ -1,8 +0,0 @@
export default function triggerEvent(el: Element, type: string) {
if ('createEvent' in document) {
// modern browsers, IE9+
const e = document.createEvent('HTMLEvents');
e.initEvent(type, false, true);
el.dispatchEvent(e);
}
}

2
components/checkbox/Group.tsx

@ -41,7 +41,7 @@ export default defineComponent({
}); });
}); });
const triggerUpdate = ref(Symbol()); const triggerUpdate = ref(Symbol());
const registeredValuesMap = ref<Map<Symbol, string>>(new Map()); const registeredValuesMap = ref(new Map<Symbol, string>());
const cancelValue = (id: Symbol) => { const cancelValue = (id: Symbol) => {
registeredValuesMap.value.delete(id); registeredValuesMap.value.delete(id);
triggerUpdate.value = Symbol(); triggerUpdate.value = Symbol();

2
components/menu/src/Menu.tsx

@ -112,7 +112,7 @@ export default defineComponent({
return !override; return !override;
}), }),
); );
const store = shallowRef<Map<string, StoreMenuInfo>>(new Map()); const store = shallowRef(new Map<string, StoreMenuInfo>());
const siderCollapsed = inject(SiderCollapsedKey, ref(undefined)); const siderCollapsed = inject(SiderCollapsedKey, ref(undefined));
const inlineCollapsed = computed(() => { const inlineCollapsed = computed(() => {
if (siderCollapsed.value !== undefined) { if (siderCollapsed.value !== undefined) {

2
components/menu/src/hooks/useItems.tsx

@ -116,7 +116,7 @@ function convertItemsToNodes(
export default function useItems(props: MenuProps) { export default function useItems(props: MenuProps) {
const itemsNodes = shallowRef([]); const itemsNodes = shallowRef([]);
const hasItmes = shallowRef(false); const hasItmes = shallowRef(false);
const store = shallowRef<Map<string, StoreMenuInfo>>(new Map()); const store = shallowRef(new Map<string, StoreMenuInfo>());
watch( watch(
() => props.items, () => props.items,
() => { () => {

2
components/rate/util.ts

@ -1,5 +1,5 @@
function getScroll(w: Window) { function getScroll(w: Window) {
let ret = w.pageXOffset; let ret = w.scrollX;
const method = 'scrollLeft'; const method = 'scrollLeft';
if (typeof ret !== 'number') { if (typeof ret !== 'number') {
const d = w.document; const d = w.document;

4
components/tree/demo/search.vue

@ -27,9 +27,9 @@ Searchable Tree.
> >
<template #title="{ title }"> <template #title="{ title }">
<span v-if="title.indexOf(searchValue) > -1"> <span v-if="title.indexOf(searchValue) > -1">
{{ title.substr(0, title.indexOf(searchValue)) }} {{ title.substring(0, title.indexOf(searchValue)) }}
<span style="color: #f50">{{ searchValue }}</span> <span style="color: #f50">{{ searchValue }}</span>
{{ title.substr(title.indexOf(searchValue) + searchValue.length) }} {{ title.substring(title.indexOf(searchValue) + searchValue.length) }}
</span> </span>
<span v-else>{{ title }}</span> <span v-else>{{ title }}</span>
</template> </template>

2
components/vc-image/src/PreviewGroup.tsx

@ -95,7 +95,7 @@ const Group = defineComponent({
? mergeDefaultValue(props.preview, defaultValues) ? mergeDefaultValue(props.preview, defaultValues)
: defaultValues; : defaultValues;
}); });
const previewUrls = reactive<Map<number, PreviewUrl>>(new Map()); const previewUrls = reactive(new Map<number, PreviewUrl>());
const current = ref<number>(); const current = ref<number>();
const previewVisible = computed(() => preview.value.visible); const previewVisible = computed(() => preview.value.visible);

2
components/vc-picker/panels/TimePanel/TimeUnitColumn.tsx

@ -25,7 +25,7 @@ export default defineComponent<TimeUnitColumnProps>({
const { open } = useInjectPanel(); const { open } = useInjectPanel();
const ulRef = shallowRef<HTMLElement>(null); const ulRef = shallowRef<HTMLElement>(null);
const liRefs = ref<Map<number, HTMLElement | null>>(new Map()); const liRefs = ref(new Map<number, HTMLElement | null>());
const scrollRef = ref<Function>(); const scrollRef = ref<Function>();
watch( watch(

2
components/vc-slider/src/common/createSlider.tsx

@ -210,7 +210,7 @@ export default function createSlider(Component) {
if (vertical) { if (vertical) {
return reverse ? rect.bottom : rect.top; return reverse ? rect.bottom : rect.top;
} }
return window.pageXOffset + (reverse ? rect.right : rect.left); return window.scrollX + (reverse ? rect.right : rect.left);
}, },
getSliderLength() { getSliderLength() {
const slider = this.sliderRef; const slider = this.sliderRef;

2
components/vc-slider/src/utils.ts

@ -58,7 +58,7 @@ export function getHandleCenterPosition(vertical: boolean, handle: HTMLElement)
const coords = handle.getBoundingClientRect(); const coords = handle.getBoundingClientRect();
return vertical return vertical
? coords.top + coords.height * 0.5 ? coords.top + coords.height * 0.5
: window.pageXOffset + coords.left + coords.width * 0.5; : window.scrollX + coords.left + coords.width * 0.5;
} }
export function ensureValueInRange(val: number, { max, min }: { max?: number; min?: number }) { export function ensureValueInRange(val: number, { max, min }: { max?: number; min?: number }) {

2
components/vc-tree-select/hooks/useDataEntities.ts

@ -8,7 +8,7 @@ import { shallowRef, watchEffect } from 'vue';
import { warning } from '../../vc-util/warning'; import { warning } from '../../vc-util/warning';
export default (treeData: ShallowRef<any>, fieldNames: Ref<FieldNames>) => { export default (treeData: ShallowRef<any>, fieldNames: Ref<FieldNames>) => {
const valueEntities = shallowRef<Map<RawValueType, DataEntity>>(new Map()); const valueEntities = shallowRef(new Map<RawValueType, DataEntity>());
const keyEntities = shallowRef<Record<string, DataEntity>>({}); const keyEntities = shallowRef<Record<string, DataEntity>>({});
watchEffect(() => { watchEffect(() => {
const fieldNamesValue = fieldNames.value; const fieldNamesValue = fieldNames.value;

2
components/vc-tree/utils/treeUtil.ts

@ -40,7 +40,7 @@ export function fillFieldNames(fieldNames?: FieldNames): Required<FieldNames> {
* Warning if TreeNode do not provides key * Warning if TreeNode do not provides key
*/ */
export function warningWithoutKey(treeData: DataNode[], fieldNames: FieldNames) { export function warningWithoutKey(treeData: DataNode[], fieldNames: FieldNames) {
const keys: Map<string, boolean> = new Map(); const keys = new Map<string, boolean>();
function dig(list: DataNode[], path = '') { function dig(list: DataNode[], path = '') {
(list || []).forEach(treeNode => { (list || []).forEach(treeNode => {

5
components/vc-util/Dom/css.ts

@ -101,15 +101,14 @@ export function getOffset(node: any) {
const box = node.getBoundingClientRect(); const box = node.getBoundingClientRect();
const docElem = document.documentElement; const docElem = document.documentElement;
// < ie8 不支持 win.pageXOffset, 则使用 docElem.scrollLeft
return { return {
left: left:
box.left + box.left +
(window.pageXOffset || docElem.scrollLeft) - (window.scrollX || docElem.scrollLeft) -
(docElem.clientLeft || document.body.clientLeft || 0), (docElem.clientLeft || document.body.clientLeft || 0),
top: top:
box.top + box.top +
(window.pageYOffset || docElem.scrollTop) - (window.scrollY || docElem.scrollTop) -
(docElem.clientTop || document.body.clientTop || 0), (docElem.clientTop || document.body.clientTop || 0),
}; };
} }

2
components/vc-util/isMobile.ts

@ -9,7 +9,7 @@ export default () => {
agent, agent,
) || ) ||
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test( /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(
agent?.substr(0, 4), agent?.substring(0, 4),
) )
); );
}; };

5
package.json

@ -216,7 +216,6 @@
"mockdate": "^2.0.2", "mockdate": "^2.0.2",
"moment": "^2.29.1", "moment": "^2.29.1",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"object-assign": "^4.1.1",
"postcss": "^8.2.12", "postcss": "^8.2.12",
"postcss-loader": "^6.0.0", "postcss-loader": "^6.0.0",
"prettier": "^2.2.0", "prettier": "^2.2.0",
@ -308,10 +307,6 @@
"dist/*", "dist/*",
"*.css" "*.css"
], ],
"vetur": {
"tags": "vetur/tags.json",
"attributes": "vetur/attributes.json"
},
"config": { "config": {
"commitizen": { "commitizen": {
"path": "node_modules/cz-git", "path": "node_modules/cz-git",

4
site/src/components/vue-colorful/components/common/Interactive.tsx

@ -36,8 +36,8 @@ const getRelativePosition = (
const pointer = isTouch(event) ? getTouchPoint(event.touches, touchId) : (event as MouseEvent); const pointer = isTouch(event) ? getTouchPoint(event.touches, touchId) : (event as MouseEvent);
return { return {
left: clamp((pointer.pageX - (rect.left + getParentWindow(node).pageXOffset)) / rect.width), left: clamp((pointer.pageX - (rect.left + getParentWindow(node).scrollX)) / rect.width),
top: clamp((pointer.pageY - (rect.top + getParentWindow(node).pageYOffset)) / rect.height), top: clamp((pointer.pageY - (rect.top + getParentWindow(node).scrollY)) / rect.height),
}; };
}; };

2
site/src/components/vue-colorful/hooks/useStyleSheet.ts

@ -6,7 +6,7 @@ import { getNonce } from '../utils/nonce';
// Bundler is configured to load this as a processed minified CSS-string // Bundler is configured to load this as a processed minified CSS-string
import styles from '../css/styles.css'; import styles from '../css/styles.css';
const styleElementMap: Map<Document, HTMLStyleElement> = new Map(); const styleElementMap = new Map<Document, HTMLStyleElement>();
/** /**
* Injects CSS code into the document's <head> * Injects CSS code into the document's <head>

2
site/src/layouts/header/Menu.vue

@ -56,7 +56,7 @@ export default defineComponent({
location: { pathname }, location: { pathname },
} = window; } = window;
const currentProtocol = `${window.location.protocol}//`; const currentProtocol = `${window.location.protocol}//`;
const currentHref = window.location.href.substr(currentProtocol.length); const currentHref = window.location.href.substring(currentProtocol.length);
if (isLocalStorageNameSupported()) { if (isLocalStorageNameSupported()) {
localStorage.setItem('locale', isZhCN(pathname) ? 'en-US' : 'zh-CN'); localStorage.setItem('locale', isZhCN(pathname) ? 'en-US' : 'zh-CN');

Loading…
Cancel
Save