diff --git a/packages/opendesign/package.json b/packages/opendesign/package.json index e9fffa08139d4cdec5ef50ba50f81c76b9934f15..7002ee4e5b5aab4f6639d957c6ef5b98c00f8965 100644 --- a/packages/opendesign/package.json +++ b/packages/opendesign/package.json @@ -33,8 +33,5 @@ "@opensig/open-scripts": "workspace:^", "typescript": "catalog:typescript", "vue-tsc": "catalog:build" - }, - "dependencies": { - "date-fns": "catalog:date" } } diff --git a/packages/opendesign/src/_utils/date.ts b/packages/opendesign/src/_utils/date.ts deleted file mode 100644 index 82814adc8ddf24aa9d4641790251b3b551f87d80..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/_utils/date.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { startOfMonth, addYears, subYears, addMonths, subMonths, format as formatDate, parse as parseDate } from 'date-fns'; - -export const WEEK_DAYS = 7; -export const MINUTE_TIME = 60 * 1000; -export const HOUR_TIME = 60 * MINUTE_TIME; -export const DAY_TIME = 24 * HOUR_TIME; -export const WEEK_TIME = WEEK_DAYS * DAY_TIME; - -/** - * 根据传入日期获取连续几周的日期 - * @param date 传入日期 - * @param length 周数量 - * @param param { - * weekStartsOn: 0|1|2|3|4|5|6 0代表星期日 - * } - */ -export function getWeeksByDate( - date: Date, - length: number = 1, - { - weekStartsOn = 0, - parse = (d: Date) => d as T, - }: { - weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6; - parse?: (d: Date) => T; - } = {} -): Array { - const time = date.getTime(); - const day = date.getDay(); - - const weeks: Array = []; - const dis = (weekStartsOn % WEEK_DAYS) - day; - const first = time + DAY_TIME * dis; - - for (let i = 0; i < WEEK_DAYS * length; i++) { - if (i === dis) { - weeks.push(parse(date)); - } else { - const d = new Date(first + DAY_TIME * i); - weeks.push(parse(d)); - } - } - - return weeks; -} - -export { startOfMonth, addYears, subYears, addMonths, subMonths, formatDate, parseDate }; - -export function isSameDate(date1: Date, date2: Date): boolean { - return date1.getTime() === date2.getTime(); -} diff --git a/packages/opendesign/src/date-picker/OCalendar.vue b/packages/opendesign/src/date-picker/OCalendar.vue deleted file mode 100644 index 41b67cf3c4598cd26dc2c8674c5a09f07d28b002..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/OCalendar.vue +++ /dev/null @@ -1,17 +0,0 @@ - - diff --git a/packages/opendesign/src/date-picker/ODatePicker.vue b/packages/opendesign/src/date-picker/ODatePicker.vue deleted file mode 100644 index 0401c79ee6d91741b591143acfe3ce39810e897c..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/ODatePicker.vue +++ /dev/null @@ -1,256 +0,0 @@ - - -../_components/i-input diff --git a/packages/opendesign/src/date-picker/ODateRangePicker.vue b/packages/opendesign/src/date-picker/ODateRangePicker.vue deleted file mode 100644 index 0b5976bcfffdb6a1f2879cf1d85a608d227ba5b5..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/ODateRangePicker.vue +++ /dev/null @@ -1,254 +0,0 @@ - - diff --git a/packages/opendesign/src/date-picker/PickerFoot.vue b/packages/opendesign/src/date-picker/PickerFoot.vue deleted file mode 100644 index d18bc37e179d6600d835ae726c065155f05c1dac..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/PickerFoot.vue +++ /dev/null @@ -1,132 +0,0 @@ - - diff --git a/packages/opendesign/src/date-picker/PickerHead.vue b/packages/opendesign/src/date-picker/PickerHead.vue deleted file mode 100644 index a5d415090c746a1baa6d9e1a0c10053f816d1413..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/PickerHead.vue +++ /dev/null @@ -1,119 +0,0 @@ - - diff --git a/packages/opendesign/src/date-picker/PickerPane.vue b/packages/opendesign/src/date-picker/PickerPane.vue deleted file mode 100644 index 622854c4851c2d4aa5c8f12f2574698512e228af..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/PickerPane.vue +++ /dev/null @@ -1,423 +0,0 @@ - - diff --git a/packages/opendesign/src/date-picker/__demo__/DatePickerBasic.vue b/packages/opendesign/src/date-picker/__demo__/DatePickerBasic.vue deleted file mode 100644 index eceafc19eec270eec215bffd130f2a825ac31db8..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/__demo__/DatePickerBasic.vue +++ /dev/null @@ -1,167 +0,0 @@ - - - diff --git a/packages/opendesign/src/date-picker/__demo__/TheIndex.vue b/packages/opendesign/src/date-picker/__demo__/TheIndex.vue deleted file mode 100644 index 3dd0cec1f7bce3f488a38207233fe600e030543c..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/__demo__/TheIndex.vue +++ /dev/null @@ -1,11 +0,0 @@ - - - diff --git a/packages/opendesign/src/date-picker/date.ts b/packages/opendesign/src/date-picker/date.ts deleted file mode 100644 index 41d7c2564efa330cee57afde9dd6c4b150845b4c..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/date.ts +++ /dev/null @@ -1,211 +0,0 @@ -import { isNull } from '../_utils/is'; -import { PickerDate } from './picker-date'; -import { PickerModeT } from './types'; -import { OScroller } from '../scrollbar'; - -export const WEEK_DAYS = 7; -export const MINUTE_TIME = 60 * 1000; -export const HOUR_TIME = 60 * MINUTE_TIME; -export const DAY_TIME = 24 * HOUR_TIME; -export const WEEK_TIME = WEEK_DAYS * DAY_TIME; - -export interface DateRangeT { - start: PickerDate; - end: PickerDate; -} - -export const Labels = { - weeks: ['日', '一', '二', '三', '四', '五', '六'], - year: '年', - month: '月', - months: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], - day: '日', - now: '此刻', - confirm: '确定', - clear: '清除', -}; - -export function getYearLabel(value: number): string { - return `${value}${Labels.year}`; -} - -export function getMonthLabel(value: number): string { - return `${value}${Labels.month}`; -} - -export function getDayLabel(value: number): string { - return `${value}${Labels.day}`; -} - -export const DefaultFormatString: Record = { - year: 'yyyy', - month: 'yyyy-MM', - quarter: 'Q', - date: 'yyyy-MM-dd', - datetime: 'yyyy-MM-dd HH:mm:ss', - time: 'HH:mm:ss', -}; - -/** - * 根据formatString决定type - * @param formatString - */ -export function getPickerType(formatString: string): PickerModeT { - // const y = formatString.includes('y'); - // const m = formatString.includes('M'); - const d = formatString.includes('d'); - if (d) { - return 'date'; - } - return 'date'; -} - -export function normalizeDateValue( - value: string | Date | number | undefined, - parseFn: (v: string) => Date -): { type: 'string' | 'number' | 'Date'; value: Date } { - if (typeof value === 'string') { - try { - return { - type: 'string', - value: parseFn(value), - }; - } catch { - return { - type: 'string', - value: new Date(NaN), - }; - } - } - if (typeof value === 'number') { - return { - type: 'number', - value: new Date(value), - }; - } - if (value instanceof Date) { - return { - type: 'Date', - value: value, - }; - } - - const d = new Date(value || NaN); - return { - type: 'Date', - value: d, - }; -} - -export function getRealDateValue(value: Date | null, type: 'string' | 'number' | 'Date', formatFn: (d: Date) => string): string | number | Date { - if (isNull(value)) { - return ''; - } - if (type === 'string') { - return formatFn(value); - } - if (type === 'number') { - return value.getTime(); - } - if (type === 'Date') { - return value; - } - return ''; -} - -export function isSameYear(date1: { year?: number }, date2: { year?: number }): boolean { - return date1.year === date2.year; -} -export function isSameMonth(date1: { year?: number; month?: number }, date2: { year?: number; month?: number }): boolean { - return date1.year === date2.year && date1.month === date2.month; -} -export function isSameDay(date1: { year?: number; month?: number; day?: number }, date2: { year?: number; month?: number; day?: number }): boolean { - return date1.year === date2.year && date1.month === date2.month && date1.day === date2.day; -} - -/** - * 获取日期在范围内的状态 - * @param date - * @param range - * @returns {in: boolean, start: boolean, end: boolean} - */ -export function getDateRangeStatus(date: PickerDate, range: DateRangeT) { - const { start, end } = range; - - const dt = date.date?.getTime(); - const st = range.start.date?.getTime(); - const et = range.end.date?.getTime(); - - return { - in: dt >= st && dt <= et, - start: isSameDay(date, start), - end: isSameDay(date, end), - }; -} - -export function scrollSelectOrNowCellInToView( - scroller: InstanceType | undefined, - { - smooth, - align, - }: { - smooth?: boolean; - align?: 'center' | 'top' | 'bottom'; - } = { - smooth: true, - align: 'top', - } -): void { - if (!scroller) { - return; - } - - let el = scroller.$el.querySelector('.o-picker-cell-selected'); - if (!el) { - el = scroller.$el.querySelector('.o-picker-cell-now'); - } - const containerRef = scroller.getContainerEl(); - if (!el || !containerRef) { - return; - } - const { offsetTop, clientHeight } = el; - const { clientHeight: outHeight } = containerRef; - - let top = offsetTop; - if (align === 'center') { - top = offsetTop - outHeight / 2 + clientHeight / 2; - } else if (align === 'bottom') { - top = offsetTop - outHeight + clientHeight; - } - scroller.scrollTo({ - top, - behavior: smooth ? 'smooth' : 'auto', - }); -} - -/** - * 获取连续数字 - * @param start - * @param length - * @param handler - */ -export function getNumberList(start: number, length: number, handler: (v: number) => T): T[] { - const rlt = []; - for (let i = start; i < length; i++) { - rlt.push(handler(i)); - } - return rlt; -} - -export function formatTime(date: PickerDate, formatString: string = 'HH:mm:ss'): string { - const h = date.hour ? '0' : date.hour.toString(); - const m = date.minute ? '0' : date.minute.toString(); - const s = date.second ? '0' : date.second.toString(); - return formatString - .replace('HH', h.padStart(2, '0')) - .replace('mm', m.padStart(2, '0')) - .replace('ss', s.padStart(2, '0')) - .replace('H', h) - .replace('m', m) - .replace('s', s); -} diff --git a/packages/opendesign/src/date-picker/index.ts b/packages/opendesign/src/date-picker/index.ts deleted file mode 100644 index 7ed13394f6893fc66d863d524e4406c370b4e670..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import _ODatePicker from './ODatePicker.vue'; -import _ODateRangePicker from './ODateRangePicker.vue'; -import type { App } from 'vue'; - -const ODatePicker = Object.assign(_ODatePicker, { - install(app: App) { - app.component('ODatePicker', _ODatePicker); - }, -}); - -const ODateRangePicker = Object.assign(_ODateRangePicker, { - install(app: App) { - app.component('ODateRangePicker', _ODateRangePicker); - }, -}); - -export { ODatePicker, ODateRangePicker }; -export * from './types'; diff --git a/packages/opendesign/src/date-picker/picker-date.ts b/packages/opendesign/src/date-picker/picker-date.ts deleted file mode 100644 index 9cbd4ee934dc3679fb39af7882111e54d490df14..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/picker-date.ts +++ /dev/null @@ -1,140 +0,0 @@ -import { isUndefined, isFunction, isNumber, isValidDate } from '../_utils/is'; - -interface DateT { - year?: number; - month?: number; - dayOfweek?: number; - day?: number; - hour?: number; - minute?: number; - second?: number; -} - -export class PickerDate { - private _cache: DateT; - private _date: Date; - private _onChange?: (d: PickerDate) => void; - constructor(date?: string | number | Date | null, onChange?: (d: PickerDate) => void) { - if (!date) { - this._date = new Date(NaN); - } else { - this._date = new Date(date); - } - this._cache = {}; - this._onChange = onChange; - } - - set(value: { year?: number; month?: number; day?: number; hour?: number; minute?: number; second?: number }, defaultValue?: Date) { - const { year = this.year, month = this.month, day = this.day, hour = this.hour, minute = this.minute, second = this.second } = value; - const now = new Date(new Date().setHours(0, 0, 0, 0)); - - const def = defaultValue && isValidDate(defaultValue) ? defaultValue : now; - const y = !isNumber(year) ? def.getFullYear() : year; - const m = !isNumber(month) ? def.getMonth() : month; - const d = !isNumber(day) ? def.getDate() : day; - - const h = !isNumber(hour) ? def.getHours() : hour; - const mt = !isNumber(minute) ? def.getMinutes() : minute; - const s = !isNumber(second) ? def.getSeconds() : second; - - const last = this._date.getTime(); - this._date = new Date(y, m, d, h, mt, s); - - if (last !== this._date.getTime()) { - this._cache = {}; - - if (isFunction(this._onChange)) { - this._onChange(this); - } - } - return this; - } - - get valid(): Boolean { - return isValidDate(this._date); - } - - get date(): Date { - return this._date; - } - - set date(date: Date | null) { - const last = this._date.getTime(); - this._date = date ?? new Date(NaN); - - if (last !== this._date.getTime()) { - this._cache = {}; - - if (isFunction(this._onChange)) { - this._onChange(this); - } - } - } - - // year - get year(): number { - if (isUndefined(this._cache.year)) { - this._cache.year = this._date.getFullYear(); - } - return this._cache.year; - } - set year(value: number) { - this.set({ year: value }); - } - - // month - get month(): number { - if (isUndefined(this._cache.month)) { - const m = this._date.getMonth(); - this._cache.month = m; - } - return this._cache.month; - } - set month(value: number) { - this.set({ month: value }); - } - - // day - get day(): number { - if (isUndefined(this._cache.day)) { - this._cache.day = this._date.getDate(); - } - return this._cache.day; - } - set day(value: number) { - this.set({ day: value }); - } - - // hour - get hour(): number { - if (isUndefined(this._cache.hour)) { - this._cache.hour = this._date.getHours(); - } - return this._cache.hour; - } - set hour(value: number) { - this.set({ hour: value }); - } - - // minute - get minute(): number { - if (isUndefined(this._cache.minute)) { - this._cache.minute = this._date.getMinutes(); - } - return this._cache.minute; - } - set minute(value: number) { - this.set({ minute: value }); - } - - // second - get second(): number { - if (isUndefined(this._cache.second)) { - this._cache.second = this._date.getSeconds(); - } - return this._cache.second; - } - set second(value: number) { - this.set({ second: value }); - } -} diff --git a/packages/opendesign/src/date-picker/picker/DayPicker.vue b/packages/opendesign/src/date-picker/picker/DayPicker.vue deleted file mode 100644 index c0b1f4a22eaccad965cb69957bc0b79864ca8239..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/picker/DayPicker.vue +++ /dev/null @@ -1,219 +0,0 @@ - - diff --git a/packages/opendesign/src/date-picker/picker/MonthPicker.vue b/packages/opendesign/src/date-picker/picker/MonthPicker.vue deleted file mode 100644 index cda8b2197cce7b444bf44d735ebc9c77b9d99080..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/picker/MonthPicker.vue +++ /dev/null @@ -1,158 +0,0 @@ - - diff --git a/packages/opendesign/src/date-picker/picker/TimePicker.vue b/packages/opendesign/src/date-picker/picker/TimePicker.vue deleted file mode 100644 index 456189b92b8d12acb72ab0aaa2ab01d9ee9de6ba..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/picker/TimePicker.vue +++ /dev/null @@ -1,242 +0,0 @@ - - diff --git a/packages/opendesign/src/date-picker/picker/YearPicker.vue b/packages/opendesign/src/date-picker/picker/YearPicker.vue deleted file mode 100644 index 61851ab602cfa6044089850f3b33e8154eb9662f..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/picker/YearPicker.vue +++ /dev/null @@ -1,166 +0,0 @@ - - diff --git a/packages/opendesign/src/date-picker/style/index.scss b/packages/opendesign/src/date-picker/style/index.scss deleted file mode 100644 index 1ea415d706e85b719bd6440bd2347921e36e4833..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/style/index.scss +++ /dev/null @@ -1,18 +0,0 @@ -@use '../../_styles/mixin.scss' as *; -@use './var.scss'; - -.o-dp-icon { - display: flex; - align-items: center; - font-size: var(--icon-size); - color: var(--icon-color); -} - -.o-range-separator { - display: flex; - align-items: center; - justify-content: center; -} -.o-range-separator-line { - margin: 0 8px; -} diff --git a/packages/opendesign/src/date-picker/style/index.ts b/packages/opendesign/src/date-picker/style/index.ts deleted file mode 100644 index 88c36c964a78a1a9db457288f62b5169c54cfdf7..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/style/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -import '../../_styles'; -import '../../_components/inner-frame/style'; -import '../../_components/inner-input/style'; -import '../../_components/in-input/style'; -import '../../_components/inner-panel/style'; -import '../../button/style'; -import '../../link/style'; -import '../../icon/style'; -import '../../scrollbar/style'; -import './index.scss'; -import './pane.scss'; diff --git a/packages/opendesign/src/date-picker/style/pane.scss b/packages/opendesign/src/date-picker/style/pane.scss deleted file mode 100644 index 16170605cc7914f9c5abfddd381f945f90fb9ae9..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/style/pane.scss +++ /dev/null @@ -1,320 +0,0 @@ -@use '../../_styles/mixin.scss' as *; -@use './var.scss'; - -.o-picker-hidden { - display: none; -} -.o-picker-pane { - color: var(--picker-panel-color); - font-size: var(--picker-panel-text-size); - line-height: var(--picker-panel-text-height); -} -.o-picker-main-wrap { - display: flex; - justify-content: center; -} -.o-picker-main { - display: flex; - justify-content: center; - max-height: 321px; -} -.o-picker-main-date { - flex-shrink: 0; -} -.o-picker-pane-year { - height: var(--picker-pane-year-height); - width: var(--picker-pane-year-width); -} -.o-picker-pane-month { - width: var(--picker-pane-month-width); - height: var(--picker-pane-month-height); -} -.o-picker-pane-date { - width: var(--picker-pane-date-width); - height: var(--picker-pane-date-height); -} -.o-picker-pane-time { - height: var(--picker-pane-time-height); -} - -.o-picker-row { - display: flex; - flex-wrap: wrap; -} -.o-picker-cell { - text-align: center; - cursor: pointer; - --cell-today-size: 4px; - display: flex; - align-items: center; - justify-content: center; - flex: 1; - padding: 4px; - margin: 2px 0; - flex: calc(100% / var(--column)) 0 0; - - &:hover { - --picker-cell-val-bg-color: var(--picker-cell-bg-color-hover); - } -} -.o-picker-cell-val { - padding: 0 8px; - display: flex; - justify-content: center; - align-items: center; - border-radius: 24px; - background-color: var(--picker-cell-val-bg-color); - flex: 0; - white-space: nowrap; - - transition: all var(--o-easing-standard) var(--o-duration-m2); -} - -.o-range-picker-pane { - .o-picker-cell-val { - flex: 1; - } -} - -.o-picker-cell-range-start, -.o-picker-cell-range-end, -.o-picker-cell-selected { - @include me-hover { - color: var(--picker-cell-color-selected); - --picker-cell-val-bg-color: var(--picker-cell-bg-color-selected); - } - - .o-picker-selecting & { - color: var(--picker-cell-color-selecting); - --picker-cell-val-bg-color: var(--picker-cell-bg-color-selecting); - } -} -.o-picker-cell-in-range { - background-color: var(--picker-cell-in-range-bg-color); - .o-picker-cell-val { - flex: 1; - } -} -.o-picker-cell-range-start { - border-top-left-radius: var(--picker-cell-radius-selected); - border-bottom-left-radius: var(--picker-cell-radius-selected); - background-color: var(--picker-cell-in-range-bg-color); - .o-picker-cell-val { - flex: 1; - } -} - -.o-picker-cell-range-end { - border-top-right-radius: var(--picker-cell-radius-selected); - border-bottom-right-radius: var(--picker-cell-radius-selected); - background-color: var(--picker-cell-in-range-bg-color); - .o-picker-cell-val { - flex: 1; - } -} - -.o-picker-cell-now { - position: relative; - &::after { - content: ''; - border-radius: 50%; - width: var(--picker-cell-today-size); - height: var(--picker-cell-today-size); - background-color: var(--picker-cell-today-dot-color); - position: absolute; - left: 50%; - bottom: calc(-0.5 * var(--picker-cell-today-size)); - margin-left: calc(-0.5 * var(--picker-cell-today-size)); - } -} - -.o-picker-cell-out-view { - @include me-hover { - color: var(--picker-panel-color-out); - --picker-cell-val-bg-color: transparent; - } -} - -.o-picker-cell-disabled { - @include me-hover { - color: var(--picker-panel-color-out); - --picker-cell-val-bg-color: transparent; - cursor: not-allowed; - } - .o-picker-selecting & { - color: var(--picker-panel-color-out); - --picker-cell-val-bg-color: transparent; - cursor: not-allowed; - } -} - -// head -.o-picker-head { - display: flex; - align-items: center; - height: var(--picker-head-height); - padding: 12px 24px; - flex-shrink: 0; - border-bottom: 1px solid var(--o-color-control1-light); -} -.o-picker-head-value { - flex: 1; - display: flex; - justify-content: center; - align-items: center; -} - -.o-picker-head-btns { - display: flex; - align-items: center; - user-select: none; -} - -.o-picker-head-btn { - --icon-size: var(--picker-panel-icon-size); - + .o-picker-head-btn { - margin-left: 4px; - } -} - -.o-picker-head-year, -.o-picker-head-month { - cursor: pointer; - @include hover { - color: var(--picker-link-color-hover); - } -} -.o-picker-head-month { - .o-picker-head-year + & { - margin-left: 8px; - } -} -.o-picker-head-time { - width: var(); -} - -// pane foot -.o-picker-foot { - padding: 12px 16px; - display: flex; - justify-content: center; - align-items: center; - border-top: 1px solid var(--o-color-control1-light); - justify-content: space-between; - - &.has-confirm { - justify-content: space-between; - } -} - -.o-picker-extra { - border-top: 1px solid var(--o-color-control1-light); -} - -.o-picker-shortcut { - display: flex; - flex-wrap: wrap; -} -.o-picker-shortcut-item { - margin-right: 4px; -} -.o-picker-shortcut-btn { - margin-left: 4px; - &:first-child { - margin-left: 0; - } -} - -// year pane -.o-picker-year { - padding: 4px; -} - -// month pane -.o-picker-month { - padding: 4px; -} - -// date pane -.o-picker-date { - padding: 10px 16px; -} - -.o-pd-cell-week { - cursor: default; - color: var(--o-color-info3); -} -.o-pd-cell-val { - flex: 1; -} - -// time pane -.o-picker-time { - display: flex; -} - -// time pane -.o-picker-main-time { - flex: 1; - &:not(:first-child) { - border-left: var(--picker-col-bd); - } -} -.o-picker-time { - display: flex; -} - -.o-pt-col-wrap { - flex: 1; - height: 100%; - + .o-pt-col-wrap { - position: relative; - &::before { - content: ''; - position: absolute; - left: 0; - top: 2px; - bottom: 2px; - border-left: var(--picker-col-bd); - } - } -} -.o-pt-col { - flex: 1; - min-width: var(--picker-pane-time-cell-width); -} - -.o-pt-cell.o-picker-cell-selected:not(.o-picker-cell-disabled) { - @include me-hover { - color: var(--picker-time-cell-color-selected); - --picker-cell-val-bg-color: var(--picker-time-cell-bg-color-selected); - } -} - -.o-pt-col-align-top { - &::after { - content: ''; - display: block; - height: calc(100% - var(--cell-height)); - } -} -.o-pt-col-align-bottom { - &::before { - content: ''; - display: block; - height: calc(100% - var(--cell-height)); - } -} -.o-pt-col-align-center { - --height: calc(50% - var(--cell-height) / 2); - &::before { - content: ''; - display: block; - height: var(--height); - } - &::after { - content: ''; - display: block; - height: var(--height); - } -} diff --git a/packages/opendesign/src/date-picker/style/var.scss b/packages/opendesign/src/date-picker/style/var.scss deleted file mode 100644 index 15277f6dbceb1d4841751636684074fa5c75c64e..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/style/var.scss +++ /dev/null @@ -1,43 +0,0 @@ -.o-date-picker { -} - -.o-date-picker-panel { - --picker-panel-color: var(--o-color-info1); - --picker-panel-color-out: var(--o-color-info4); - - --picker-panel-icon-size: var(--o-icon_size_control-m); - --picker-panel-text-size: var(--o-font_size-text1); - --picker-panel-text-height: var(--o-line_height-text1); - - --picker-cell-radius-selected: 24px; - --picker-cell-bg-color-hover: var(--o-color-control2-light); - - --picker-cell-color-selected: var(--o-color-info1-inverse); - --picker-cell-bg-color-selected: var(--o-color-primary1); - - --picker-cell-color-selecting: var(--o-color-info3); - --picker-cell-bg-color-selecting: var(--o-color-primary4); - - --picker-cell-in-range-bg-color: var(--o-color-control4-light); - - --picker-cell-today-size: 4px; - --picker-cell-today-dot-color: var(--o-color-primary1); - - --picker-col-bd: 1px solid var(--o-color-control4); - - --picker-time-cell-color-selected: var(--o-color-info1); - --picker-time-cell-bg-color-selected: var(--o-color-control3-light); - - --picker-head-height: 48px; - - --picker-pane-year-width: 256px; - --picker-pane-year-height: 256px; - --picker-pane-month-width: 312px; - --picker-pane-month-height: auto; - --picker-pane-date-width: 312px; - --picker-pane-date-height: auto; - --picker-pane-time-cell-width: 64px; - --picker-pane-time-height: 256px; - - --picker-link-color-hover: var(--o-color-primary1); -} diff --git a/packages/opendesign/src/date-picker/types.ts b/packages/opendesign/src/date-picker/types.ts deleted file mode 100644 index f85c8ae40d2c882f0af081eafa97d83f43ebcbcf..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/date-picker/types.ts +++ /dev/null @@ -1,232 +0,0 @@ -import { ExtractPropTypes, PropType } from 'vue'; -import type { SizeT, RoundT, VariantT, Color2T } from '../_utils/types'; -import { PickerDate } from './picker-date'; - -export interface ShortcutT { - label: string; - value: Date | (() => Date); -} -export type ReservedShortcutT = 'now'; -export type ShortcutParamT = ReservedShortcutT | ShortcutT; - -export const PickerModes = ['year', 'month', 'date', 'datetime', 'quarter', 'time'] as const; -export type PickerModeT = (typeof PickerModes)[number]; - -export const AllPickerModes = PickerModes.map((item) => `${item}-range`); -export type ALLPickerModeT = (typeof AllPickerModes)[number]; - -export type DisaplyYearListT = (year: number) => Array<{ year: number; label: string }>; - -export type DisaplyMonthListT = (year: number) => Array<{ year?: number; month: number; label: string }>; - -export type DisaplyDayListT = (year: number, month: number) => Array<{ year?: number; month?: number; day: number; label: string }>; - -export type DisaplyTimeListT = (date: Date) => Array<{ value: number; label: string }>; - -export interface YearCellT { - year: number; -} -export interface MonthCellT extends Partial { - month: number; -} -export interface DayCellT extends Partial { - day: number; -} - -export type disableYearCellT = (cell: YearCellT) => boolean; -export type disableMonthCellT = (cell: MonthCellT) => boolean; -export type disableDayCellT = (cell: DayCellT) => boolean; -export type disableTimeCellT = (value: number, type: 'hour' | 'minute' | 'second') => boolean; - -export interface TimeValueT { - hours?: number; - minutes?: number; - seconds?: number; -} - -const commonPickerProps = { - /** - * 选择器模式 - */ - mode: { - type: String as PropType, - default: 'date', - }, - /** - * 格式化字符串 - */ - formatString: { - type: String, - }, - /** - * 大小 SizeT - */ - size: { - type: String as PropType, - }, - /** - * 圆角值 RoundT - */ - round: { - type: String as PropType, - }, - /** - * 颜色类型 Color2T - */ - color: { - type: String as PropType, - default: 'normal', - }, - /** - * 按钮类型 VariantT - */ - variant: { - type: String as PropType, - default: 'outline', - }, - /** - * 提示文本 - */ - placeholder: { - type: String, - }, - /** - * 是否禁用 - */ - disabled: { - type: Boolean, - }, - /** - * 是否只读 - */ - readonly: { - type: Boolean, - }, - /** - * 是否可以清除 - */ - clearable: { - type: Boolean, - default: true, - }, - /** - * 时间格式化为字符串函数 - */ - format: { - type: Function as PropType<(d: Date) => string>, - }, - /** - * 时间字符串处理为时间函数 - */ - parse: { - type: Function as PropType<(d: string) => Date>, - }, - /** - * 面板上的快捷按钮 - */ - shortcuts: { - type: [String, Object] as PropType>, - }, - /** - * 面板上是否显示确认按钮 - */ - needConfirm: { - type: Boolean, - }, - /** - * 面板上确认按钮文本 - */ - confirmLabel: { - type: String, - }, - /** - * 日期禁用 - */ - disableCell: { - type: Function as PropType, - }, - /** - * 时间禁用 - */ - disableTimeCell: { - type: Function as PropType, - }, - /** - * 时间禁用 - */ - disableTime: { - type: Function as PropType<(current: Date, type?: 'start' | 'end') => boolean>, - }, - /****** month */ - /** - * 是否支持选择年份 - */ - yearSelectable: { - type: Boolean, - default: true, - }, - /** - * 是否支持选择年份 - */ - // monthSelectable: { - // type: [Boolean], - // default: true, - // }, - /** - * 控制面板展示的年份 - */ - displayYearList: { - type: Function as PropType<(year: number) => Array<{ year: number; label: string }>>, - }, - /** - * 控制面板展示的月份 - */ - displayMonthList: { - type: Function as PropType<(year: number) => Array<{ year?: number; month: number; label: string }>>, - }, - /** - * 控制面板展示的月份 - */ - displayDayList: { - type: Function as PropType<(year: number, month: number) => Array<{ year?: number; month: number; day: number; label: string }>>, - }, -}; - -export const datePickerProps = { - /** - * 值 - * v-model - */ - modelValue: { - type: [Date, String, Number] as PropType, - }, - /** - * 默认值 - */ - defaultValue: { - type: [Date, String, Number] as PropType, - }, - ...commonPickerProps, -}; - -export type DatePickerPropsT = ExtractPropTypes; - -export const dateRangePickerProps = { - /** - * 值 - * v-model - */ - modelValue: { - type: Array as PropType>, - }, - /** - * 默认值 - */ - defaultValue: { - type: Array as PropType>, - }, - ...commonPickerProps, -}; -export type DateRangePickerPropsT = ExtractPropTypes; - -export { PickerDate }; diff --git a/packages/portal/src/router.ts b/packages/portal/src/router.ts index fcf60af54cb38720af4c77558ade370b2350440a..098fc730bd91434427070d8af614b66ced68287e 100644 --- a/packages/portal/src/router.ts +++ b/packages/portal/src/router.ts @@ -43,22 +43,6 @@ export const routes = [ title: '全局配置 config-provider', }, }, - // { - // path: '/date-picker', - // name: 'DatePicker', - // component: () => import('@opendesign-src/date-picker/__demo__/TheIndex.vue'), - // meta: { - // title: '日期选择器 DatePicker', - // }, - // }, - { - path: '/date-picker', - name: 'DatePicker', - component: () => import('@opendesign-src/date-picker/__demo__/TheIndex.vue'), - meta: { - title: '日期选择器 DatePicker', - }, - }, { path: '/form', name: 'Form', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5ff2667293acfcbef4010bbf34c65240c6ec2072..8c34a8ba4aa51b5f58e4c3d864bfbf49bd61aa5c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -37,10 +37,6 @@ catalogs: sass-embedded: specifier: ^1.83.4 version: 1.83.4 - date: - date-fns: - specifier: ^2.30.0 - version: 2.30.0 io: commander: specifier: ^13.1.0 @@ -252,9 +248,6 @@ importers: packages/opendesign: dependencies: - date-fns: - specifier: catalog:date - version: 2.30.0 vue: specifier: ^3.3.0 version: 3.5.13(typescript@5.8.2) @@ -377,10 +370,6 @@ packages: engines: {node: '>=6.0.0'} hasBin: true - '@babel/runtime@7.26.7': - resolution: {integrity: sha512-AOPI3D+a8dXnja+iwsUqGRjr1BbZIe771sXdapOtYI531gSqpi92vXivKcq2asu/DFpdl1ceFAKZyRzK2PCVcQ==} - engines: {node: '>=6.9.0'} - '@babel/types@7.28.0': resolution: {integrity: sha512-jYnje+JyZG5YThjHiF28oT4SIZLnYOcSBb6+SDaFIyzDVSkXQmQQYclJ2R+YxcdmK0AX6x1E5OQNtuh3jHDrUg==} engines: {node: '>=6.9.0'} @@ -1304,10 +1293,6 @@ packages: csstype@3.1.3: resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} - date-fns@2.30.0: - resolution: {integrity: sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==} - engines: {node: '>=0.11'} - de-indent@1.0.2: resolution: {integrity: sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==} @@ -2024,9 +2009,6 @@ packages: resolution: {integrity: sha512-YTUo+Flmw4ZXiWfQKGcwwc11KnoRAYgzAE2E7mXKCjSviTKShtxBsN6YUUBB2gtaBzKzeKunxhUwNHQuRryhWA==} engines: {node: '>= 4'} - regenerator-runtime@0.14.1: - resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==} - require-from-string@2.0.2: resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} engines: {node: '>=0.10.0'} @@ -2578,10 +2560,6 @@ snapshots: dependencies: '@babel/types': 7.28.0 - '@babel/runtime@7.26.7': - dependencies: - regenerator-runtime: 0.14.1 - '@babel/types@7.28.0': dependencies: '@babel/helper-string-parser': 7.27.1 @@ -3471,10 +3449,6 @@ snapshots: csstype@3.1.3: {} - date-fns@2.30.0: - dependencies: - '@babel/runtime': 7.26.7 - de-indent@1.0.2: {} debug@4.4.1: @@ -4238,8 +4212,6 @@ snapshots: tiny-invariant: 1.3.3 tslib: 2.8.1 - regenerator-runtime@0.14.1: {} - require-from-string@2.0.2: {} resolve-from@4.0.0: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index d91d9927b97709a8fe3feea3080e08fda2fa8575..be8d7251058e552676c0c9fc862a229d7481bf36 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -60,10 +60,6 @@ catalogs: "fs-extra": "^11.3.0" "commander": "^13.1.0" - # 日期处理 - date: - "date-fns": "^2.30.0" - # 其余工具 utils: "magic-string": "^0.30.17"