From da76d612576a2f2b7c32c46014741d54e724db36 Mon Sep 17 00:00:00 2001 From: GeorgeLeoo Date: Sat, 4 Dec 2021 10:47:28 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20date-picker=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=BA=90=E7=A0=81=E5=BA=94=E8=AF=A5=E7=BB=9F=E4=B8=80=E6=94=BE?= =?UTF-8?q?=E5=9C=A8src=E7=9B=AE=E5=BD=95=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit body: 修复 eslint 报错, 包括以下内容 删除为用到的函数或变量 --- packages/devui-vue/devui/date-picker/index.ts | 6 ++-- .../devui/date-picker/{ => src}/README.md | 0 .../{ => src}/components/calendar/index.scss | 0 .../{ => src}/components/calendar/index.tsx | 0 .../{ => src}/components/helper.ts | 0 .../{ => src}/components/panel/index.scss | 2 +- .../{ => src}/components/panel/index.tsx | 0 .../{ => src}/components/popup/index.scss | 0 .../{ => src}/components/popup/index.tsx | 2 -- .../components/timepicker/index.scss | 4 +-- .../{ => src}/components/timepicker/index.tsx | 2 +- .../components/today-default/index.tsx | 0 .../{ => src}/components/toolbar/index.scss | 2 +- .../{ => src}/components/toolbar/index.tsx | 3 +- .../{ => src}/components/toolbar/svg-icon.tsx | 0 .../date-picker/{ => src}/components/types.ts | 0 .../date-picker/{ => src}/components/utils.ts | 0 .../components/vertical-slider/index.scss | 0 .../components/vertical-slider/index.tsx | 0 .../date-picker/{ => src}/date-picker.scss | 2 +- .../date-picker/{ => src}/date-picker.tsx | 10 +++--- .../devui/date-picker/{ => src}/helper.ts | 36 +++++++++---------- .../{ => src}/stick-slider/index.scss | 0 .../{ => src}/stick-slider/index.tsx | 2 +- .../devui/date-picker/{ => src}/utils.ts | 12 +++---- ...etonItem.spec.ts => skeleton-item.spec.ts} | 0 26 files changed, 40 insertions(+), 43 deletions(-) rename packages/devui-vue/devui/date-picker/{ => src}/README.md (100%) rename packages/devui-vue/devui/date-picker/{ => src}/components/calendar/index.scss (100%) rename packages/devui-vue/devui/date-picker/{ => src}/components/calendar/index.tsx (100%) rename packages/devui-vue/devui/date-picker/{ => src}/components/helper.ts (100%) rename packages/devui-vue/devui/date-picker/{ => src}/components/panel/index.scss (98%) rename packages/devui-vue/devui/date-picker/{ => src}/components/panel/index.tsx (100%) rename packages/devui-vue/devui/date-picker/{ => src}/components/popup/index.scss (100%) rename packages/devui-vue/devui/date-picker/{ => src}/components/popup/index.tsx (98%) rename packages/devui-vue/devui/date-picker/{ => src}/components/timepicker/index.scss (95%) rename packages/devui-vue/devui/date-picker/{ => src}/components/timepicker/index.tsx (96%) rename packages/devui-vue/devui/date-picker/{ => src}/components/today-default/index.tsx (100%) rename packages/devui-vue/devui/date-picker/{ => src}/components/toolbar/index.scss (95%) rename packages/devui-vue/devui/date-picker/{ => src}/components/toolbar/index.tsx (96%) rename packages/devui-vue/devui/date-picker/{ => src}/components/toolbar/svg-icon.tsx (100%) rename packages/devui-vue/devui/date-picker/{ => src}/components/types.ts (100%) rename packages/devui-vue/devui/date-picker/{ => src}/components/utils.ts (100%) rename packages/devui-vue/devui/date-picker/{ => src}/components/vertical-slider/index.scss (100%) rename packages/devui-vue/devui/date-picker/{ => src}/components/vertical-slider/index.tsx (100%) rename packages/devui-vue/devui/date-picker/{ => src}/date-picker.scss (97%) rename packages/devui-vue/devui/date-picker/{ => src}/date-picker.tsx (97%) rename packages/devui-vue/devui/date-picker/{ => src}/helper.ts (89%) rename packages/devui-vue/devui/date-picker/{ => src}/stick-slider/index.scss (100%) rename packages/devui-vue/devui/date-picker/{ => src}/stick-slider/index.tsx (98%) rename packages/devui-vue/devui/date-picker/{ => src}/utils.ts (96%) rename packages/devui-vue/devui/skeleton/__tests__/{skeletonItem.spec.ts => skeleton-item.spec.ts} (100%) diff --git a/packages/devui-vue/devui/date-picker/index.ts b/packages/devui-vue/devui/date-picker/index.ts index 26274dc7..f38643d1 100644 --- a/packages/devui-vue/devui/date-picker/index.ts +++ b/packages/devui-vue/devui/date-picker/index.ts @@ -1,6 +1,6 @@ import { App } from 'vue' -import DatePicker from './date-picker' -import StickSlider from './stick-slider' +import DatePicker from './src/date-picker' +import StickSlider from './src/stick-slider' DatePicker.install = function(app: App) { app.component(DatePicker.name, DatePicker) @@ -14,6 +14,6 @@ export default { category: '数据录入', status: '50%', install(app: App): void { - app.use(DatePicker) + app.use(DatePicker as any) } } diff --git a/packages/devui-vue/devui/date-picker/README.md b/packages/devui-vue/devui/date-picker/src/README.md similarity index 100% rename from packages/devui-vue/devui/date-picker/README.md rename to packages/devui-vue/devui/date-picker/src/README.md diff --git a/packages/devui-vue/devui/date-picker/components/calendar/index.scss b/packages/devui-vue/devui/date-picker/src/components/calendar/index.scss similarity index 100% rename from packages/devui-vue/devui/date-picker/components/calendar/index.scss rename to packages/devui-vue/devui/date-picker/src/components/calendar/index.scss diff --git a/packages/devui-vue/devui/date-picker/components/calendar/index.tsx b/packages/devui-vue/devui/date-picker/src/components/calendar/index.tsx similarity index 100% rename from packages/devui-vue/devui/date-picker/components/calendar/index.tsx rename to packages/devui-vue/devui/date-picker/src/components/calendar/index.tsx diff --git a/packages/devui-vue/devui/date-picker/components/helper.ts b/packages/devui-vue/devui/date-picker/src/components/helper.ts similarity index 100% rename from packages/devui-vue/devui/date-picker/components/helper.ts rename to packages/devui-vue/devui/date-picker/src/components/helper.ts diff --git a/packages/devui-vue/devui/date-picker/components/panel/index.scss b/packages/devui-vue/devui/date-picker/src/components/panel/index.scss similarity index 98% rename from packages/devui-vue/devui/date-picker/components/panel/index.scss rename to packages/devui-vue/devui/date-picker/src/components/panel/index.scss index 9fb2adae..816045f7 100644 --- a/packages/devui-vue/devui/date-picker/components/panel/index.scss +++ b/packages/devui-vue/devui/date-picker/src/components/panel/index.scss @@ -1,4 +1,4 @@ -@import '../../../style/devui.scss'; +@import '../../../../style/devui'; $panel-width: 230px; $panel-height: 210px; diff --git a/packages/devui-vue/devui/date-picker/components/panel/index.tsx b/packages/devui-vue/devui/date-picker/src/components/panel/index.tsx similarity index 100% rename from packages/devui-vue/devui/date-picker/components/panel/index.tsx rename to packages/devui-vue/devui/date-picker/src/components/panel/index.tsx diff --git a/packages/devui-vue/devui/date-picker/components/popup/index.scss b/packages/devui-vue/devui/date-picker/src/components/popup/index.scss similarity index 100% rename from packages/devui-vue/devui/date-picker/components/popup/index.scss rename to packages/devui-vue/devui/date-picker/src/components/popup/index.scss diff --git a/packages/devui-vue/devui/date-picker/components/popup/index.tsx b/packages/devui-vue/devui/date-picker/src/components/popup/index.tsx similarity index 98% rename from packages/devui-vue/devui/date-picker/components/popup/index.tsx rename to packages/devui-vue/devui/date-picker/src/components/popup/index.tsx index f241927b..16286343 100644 --- a/packages/devui-vue/devui/date-picker/components/popup/index.tsx +++ b/packages/devui-vue/devui/date-picker/src/components/popup/index.tsx @@ -2,8 +2,6 @@ import { defineComponent, reactive, renderSlot, ref, useSlots, onMounted, onUnmo import { EventManager, isIn, traceNode, invokeFunction } from '../../utils' import { handlePositionFactory, - formatValue, - formatPlaceholder, getAttachInputDom, } from '../../helper' diff --git a/packages/devui-vue/devui/date-picker/components/timepicker/index.scss b/packages/devui-vue/devui/date-picker/src/components/timepicker/index.scss similarity index 95% rename from packages/devui-vue/devui/date-picker/components/timepicker/index.scss rename to packages/devui-vue/devui/date-picker/src/components/timepicker/index.scss index 139b9aaa..041d8288 100644 --- a/packages/devui-vue/devui/date-picker/components/timepicker/index.scss +++ b/packages/devui-vue/devui/date-picker/src/components/timepicker/index.scss @@ -1,5 +1,5 @@ -@import '../../../style/devui.scss'; -@import '../panel/index.scss'; +@import '../../../../style/devui'; +@import '../panel/index'; $calendar-timepicker-width: 100px; $head-height: 32px; diff --git a/packages/devui-vue/devui/date-picker/components/timepicker/index.tsx b/packages/devui-vue/devui/date-picker/src/components/timepicker/index.tsx similarity index 96% rename from packages/devui-vue/devui/date-picker/components/timepicker/index.tsx rename to packages/devui-vue/devui/date-picker/src/components/timepicker/index.tsx index df874f87..ab6740cd 100644 --- a/packages/devui-vue/devui/date-picker/components/timepicker/index.tsx +++ b/packages/devui-vue/devui/date-picker/src/components/timepicker/index.tsx @@ -1,4 +1,4 @@ -import { defineComponent, onMounted, ref, reactive } from 'vue' +import { defineComponent, reactive } from 'vue' import VerticalSliderFunction from '../vertical-slider' import './index.scss' diff --git a/packages/devui-vue/devui/date-picker/components/today-default/index.tsx b/packages/devui-vue/devui/date-picker/src/components/today-default/index.tsx similarity index 100% rename from packages/devui-vue/devui/date-picker/components/today-default/index.tsx rename to packages/devui-vue/devui/date-picker/src/components/today-default/index.tsx diff --git a/packages/devui-vue/devui/date-picker/components/toolbar/index.scss b/packages/devui-vue/devui/date-picker/src/components/toolbar/index.scss similarity index 95% rename from packages/devui-vue/devui/date-picker/components/toolbar/index.scss rename to packages/devui-vue/devui/date-picker/src/components/toolbar/index.scss index d73f4afc..fc3d5f50 100644 --- a/packages/devui-vue/devui/date-picker/components/toolbar/index.scss +++ b/packages/devui-vue/devui/date-picker/src/components/toolbar/index.scss @@ -1,4 +1,4 @@ -@import '../../../style/devui.scss'; +@import '../../../../style/devui'; $toolbar-height: 32px; $cell-size: 28px; diff --git a/packages/devui-vue/devui/date-picker/components/toolbar/index.tsx b/packages/devui-vue/devui/date-picker/src/components/toolbar/index.tsx similarity index 96% rename from packages/devui-vue/devui/date-picker/components/toolbar/index.tsx rename to packages/devui-vue/devui/date-picker/src/components/toolbar/index.tsx index 802ba167..61b6d809 100644 --- a/packages/devui-vue/devui/date-picker/components/toolbar/index.tsx +++ b/packages/devui-vue/devui/date-picker/src/components/toolbar/index.tsx @@ -1,4 +1,4 @@ -import { compareDate, invokeCallback, subDateMonth } from '../utils' +import { compareDate, invokeCallback } from '../utils' import { Year, Month } from './svg-icon' import { TCalendarToolbarItemProps, TDateToolbarProps } from '../types' import './index.scss' @@ -10,7 +10,6 @@ const Item = (props: TCalendarToolbarItemProps) => { rotate = 0, date, pos, - cb, } = props const color = disabled ? '#cfd0d3' : '#585d6b' const className = `${disabled ? 'disabled' : ''}` diff --git a/packages/devui-vue/devui/date-picker/components/toolbar/svg-icon.tsx b/packages/devui-vue/devui/date-picker/src/components/toolbar/svg-icon.tsx similarity index 100% rename from packages/devui-vue/devui/date-picker/components/toolbar/svg-icon.tsx rename to packages/devui-vue/devui/date-picker/src/components/toolbar/svg-icon.tsx diff --git a/packages/devui-vue/devui/date-picker/components/types.ts b/packages/devui-vue/devui/date-picker/src/components/types.ts similarity index 100% rename from packages/devui-vue/devui/date-picker/components/types.ts rename to packages/devui-vue/devui/date-picker/src/components/types.ts diff --git a/packages/devui-vue/devui/date-picker/components/utils.ts b/packages/devui-vue/devui/date-picker/src/components/utils.ts similarity index 100% rename from packages/devui-vue/devui/date-picker/components/utils.ts rename to packages/devui-vue/devui/date-picker/src/components/utils.ts diff --git a/packages/devui-vue/devui/date-picker/components/vertical-slider/index.scss b/packages/devui-vue/devui/date-picker/src/components/vertical-slider/index.scss similarity index 100% rename from packages/devui-vue/devui/date-picker/components/vertical-slider/index.scss rename to packages/devui-vue/devui/date-picker/src/components/vertical-slider/index.scss diff --git a/packages/devui-vue/devui/date-picker/components/vertical-slider/index.tsx b/packages/devui-vue/devui/date-picker/src/components/vertical-slider/index.tsx similarity index 100% rename from packages/devui-vue/devui/date-picker/components/vertical-slider/index.tsx rename to packages/devui-vue/devui/date-picker/src/components/vertical-slider/index.tsx diff --git a/packages/devui-vue/devui/date-picker/date-picker.scss b/packages/devui-vue/devui/date-picker/src/date-picker.scss similarity index 97% rename from packages/devui-vue/devui/date-picker/date-picker.scss rename to packages/devui-vue/devui/date-picker/src/date-picker.scss index 60bc5249..b1885cf2 100644 --- a/packages/devui-vue/devui/date-picker/date-picker.scss +++ b/packages/devui-vue/devui/date-picker/src/date-picker.scss @@ -1,4 +1,4 @@ -@import '../style/devui.scss'; +@import '../../style/devui'; $cell-font-size: 13px; $border-width: 1px; diff --git a/packages/devui-vue/devui/date-picker/date-picker.tsx b/packages/devui-vue/devui/date-picker/src/date-picker.tsx similarity index 97% rename from packages/devui-vue/devui/date-picker/date-picker.tsx rename to packages/devui-vue/devui/date-picker/src/date-picker.tsx index 1b67f193..e3b6eef3 100644 --- a/packages/devui-vue/devui/date-picker/date-picker.tsx +++ b/packages/devui-vue/devui/date-picker/src/date-picker.tsx @@ -1,8 +1,8 @@ import { onUnmounted, UnwrapRef , defineComponent, reactive, onMounted, ref } from 'vue' import { invokeFunction, isIn } from './utils' import { compareDateSort , parseDate } from './components/utils' -import { Input } from '../input' -import { Icon } from '../icon' +import { Input } from '../../input' +import { Icon } from '../../icon' import { TState, @@ -47,7 +47,7 @@ export default defineComponent({ dateMin: { type: String }, dateMax: { type: String }, }, - setup(props, ctx) { + setup(props) { const panel = ref(null) const input = ref(null) @@ -60,7 +60,7 @@ export default defineComponent({ show: false, value: '', placeholder: formatPlaceholder(props), - current, + current, next, }) @@ -115,7 +115,7 @@ export default defineComponent({ state.end = state.hover = undefined state.start = date }} - onChange={(type, config) => { + onChange={() => { state.value = formatValue(state, props) state.placeholder = formatPlaceholder(props) invokeFunction(props.selectedDateChange, state.value) diff --git a/packages/devui-vue/devui/date-picker/helper.ts b/packages/devui-vue/devui/date-picker/src/helper.ts similarity index 89% rename from packages/devui-vue/devui/date-picker/helper.ts rename to packages/devui-vue/devui/date-picker/src/helper.ts index 47baf8fa..4fa82a2b 100644 --- a/packages/devui-vue/devui/date-picker/helper.ts +++ b/packages/devui-vue/devui/date-picker/src/helper.ts @@ -16,10 +16,10 @@ export type TState = { /** * Calendar 面板年月切换逻辑 - * @param state - * @param index - * @param pos - * @param date + * @param state + * @param index + * @param pos + * @param date */ export const handleCalendarSwitchState = (state: TState, index: number, pos: number, date: Date) => { switch (index) { @@ -48,9 +48,9 @@ export const handleCalendarSwitchState = (state: TState, index: number, pos: num /** * 格式化输入日期字符串 - * @param state - * @param props - * @returns + * @param state + * @param props + * @returns */ export const formatValue = (state: TState, props: any) => { const { format = 'y/MM/dd', range, rangeSpliter = '-' } = props || {} @@ -80,8 +80,8 @@ export const formatValue = (state: TState, props: any) => { /** * 格式化placeholder显示 - * @param props - * @returns + * @param props + * @returns */ export const formatPlaceholder = (props: any) => { if (!props) return '' @@ -92,8 +92,8 @@ export const formatPlaceholder = (props: any) => { /** * 输出日期选择结果 - * @param id - * @param output + * @param id + * @param output */ export const handleValue = (id: string | undefined, output: string) => { if (id && typeof id === 'string') { @@ -106,7 +106,7 @@ export const handleValue = (id: string | undefined, output: string) => { /** * 获取绑定节点 - * @returns + * @returns */ export const getAttachInputDom = (props: any) => { const { attach, attachInputDom = attach } = props || {} @@ -122,10 +122,10 @@ export const getAttachInputDom = (props: any) => { /** * 绑定弹出层场景,计算弹出层位置。 - * @param state - * @param props - * @param container - * @returns + * @param state + * @param props + * @param container + * @returns */ export const handlePositionFactory = (state: { x?: string @@ -144,8 +144,8 @@ export const handlePositionFactory = (state: { state.st = true return } - const { left, top, width, height } = el.getBoundingClientRect() - const { width: _width, height: _height } = container.value.getBoundingClientRect() + const { left, top, height } = el.getBoundingClientRect() + const { height: _height } = container.value.getBoundingClientRect() const bottom = window.innerHeight - top - height state.x = `${left}px` if (bottom > top) { diff --git a/packages/devui-vue/devui/date-picker/stick-slider/index.scss b/packages/devui-vue/devui/date-picker/src/stick-slider/index.scss similarity index 100% rename from packages/devui-vue/devui/date-picker/stick-slider/index.scss rename to packages/devui-vue/devui/date-picker/src/stick-slider/index.scss diff --git a/packages/devui-vue/devui/date-picker/stick-slider/index.tsx b/packages/devui-vue/devui/date-picker/src/stick-slider/index.tsx similarity index 98% rename from packages/devui-vue/devui/date-picker/stick-slider/index.tsx rename to packages/devui-vue/devui/date-picker/src/stick-slider/index.tsx index d51ef64d..5958215b 100644 --- a/packages/devui-vue/devui/date-picker/stick-slider/index.tsx +++ b/packages/devui-vue/devui/date-picker/src/stick-slider/index.tsx @@ -5,7 +5,7 @@ import './index.scss' const StickSlider = defineComponent({ name: 'DStickSlider', props: {}, - setup(props) { + setup() { const state = reactive({ showButtons: false, diff --git a/packages/devui-vue/devui/date-picker/utils.ts b/packages/devui-vue/devui/date-picker/src/utils.ts similarity index 96% rename from packages/devui-vue/devui/date-picker/utils.ts rename to packages/devui-vue/devui/date-picker/src/utils.ts index 9400fc5f..e2e59c7b 100644 --- a/packages/devui-vue/devui/date-picker/utils.ts +++ b/packages/devui-vue/devui/date-picker/src/utils.ts @@ -17,8 +17,8 @@ const fixStart = (n: number, m: string, max = 2, ch = '0') => { /** * - y: year yy 取后2位,其他情况取4位 * - M: month 最多取2位补0 - * @param fmt - * @param d + * @param fmt + * @param d */ export const formatDate = (fmt: string, d: Date) => { const usage = getDateTime(d) @@ -48,9 +48,9 @@ export const formatRange = (fmt: string, a: Date, b: Date, conn = '-') => { /** * 判断节点a是否在节点b中 - * @param a - * @param b - * @returns + * @param a + * @param b + * @returns */ export const isIn = (a: Node | null, b: any) => { if (!b) { @@ -85,7 +85,7 @@ export class EventManager { } export const traceNode = (el: Node) => { - const els: Node[] = [], name = 'scroll' + const els: Node[] = [] while (el.parentNode) { els.push(el.parentNode) el = el.parentNode diff --git a/packages/devui-vue/devui/skeleton/__tests__/skeletonItem.spec.ts b/packages/devui-vue/devui/skeleton/__tests__/skeleton-item.spec.ts similarity index 100% rename from packages/devui-vue/devui/skeleton/__tests__/skeletonItem.spec.ts rename to packages/devui-vue/devui/skeleton/__tests__/skeleton-item.spec.ts -- Gitee