Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(utils): delete the renderless/common directory and adjust all reference paths. #2849

Merged
merged 28 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
00dd4c5
fix(utils): 调整sha256, 移除 getWindow, isWeb
shenjunjian Jan 26, 2025
39901e7
fix(utils): 移除isSerer到globalConfig, 删除isBrowser函数
shenjunjian Jan 26, 2025
6e7aacd
fix(utils): 移除 prop-util 包
shenjunjian Jan 26, 2025
dba8c92
fix(utils): 更新date, calendar,date-utils, type四个引用
shenjunjian Jan 27, 2025
538736f
fix(utils): 更新string包路径
shenjunjian Feb 5, 2025
ed9307f
fix(utils): 更新 object路径
shenjunjian Feb 5, 2025
10f847f
fix(utils): 添加'@opentiny/utils' 依赖
shenjunjian Feb 5, 2025
97c1f84
fix(utils): 添加'@opentiny/utils' 依赖
shenjunjian Feb 5, 2025
cb2d4b7
fix(utils): 更新 dataset 路径
shenjunjian Feb 5, 2025
3119781
fix(utils): 更新 array 路径
shenjunjian Feb 5, 2025
ea19a56
fix(utils): 更新 array 路径
shenjunjian Feb 5, 2025
63ec0f0
fix(utils): 更新 dataset 路径
shenjunjian Feb 5, 2025
19c771b
fix(utils): 删除所有的renderless/common中的文件
shenjunjian Feb 5, 2025
338eef3
fix(utils): 替换路径
shenjunjian Feb 5, 2025
1ca41ba
fix(utils): 替换路径
shenjunjian Feb 6, 2025
5586ff3
fix(utils): 替换路径
shenjunjian Feb 6, 2025
7302c1c
fix(utils): 替换路径
shenjunjian Feb 6, 2025
ba298b5
fix(utils): 替换路径
shenjunjian Feb 6, 2025
d249b84
fix(utils): 替换路径
shenjunjian Feb 6, 2025
54e95a7
fix(utils): 替换路径
shenjunjian Feb 6, 2025
035da89
Merge branch 'dev' of github.com:opentiny/tiny-vue into refactor-util…
shenjunjian Feb 6, 2025
0b0c263
fix(utils): fix
shenjunjian Feb 7, 2025
c6d2cc6
fix(utils): remove time-line-new
shenjunjian Feb 7, 2025
aaacca6
fix(utils): adjust import orders
shenjunjian Feb 7, 2025
7064e5b
Merge branch 'dev' of github.com:opentiny/tiny-vue into refactor-util…
shenjunjian Feb 7, 2025
1baade3
fix(utils): 替换路径
shenjunjian Feb 7, 2025
6f68ab9
Merge branch 'dev' of github.com:opentiny/tiny-vue into refactor-util…
shenjunjian Feb 7, 2025
44b3da9
fix(utils): add popup-manager file
shenjunjian Feb 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions examples/nuxt/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@
"@opentiny/vue-vite-import": "workspace:~",
"@tiptap/vue-3": "^2.1.0",
"@vitejs/plugin-vue-jsx": "^3.0.0",
"js-sha256": "^0.9.0",
"onigasm": "^2.2.5",
"postcss": "^8.4.16",
"typescript": "^5.0.0",
"vite-plugin-checker": "^0.5.2",
"vite-plugin-dynamic-import": "^1.2.4",
"vite-svg-loader": "^3.6.0"
}
}
}
3 changes: 1 addition & 2 deletions examples/vue2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"@vue/composition-api": "1.7.2",
"@vue/runtime-dom": "^3.2.31",
"@vue/test-utils": "^1.3.3",
"js-sha256": "^0.9.0",
"jsdom": "^21.0.0",
"onigasm": "^2.2.5",
"postcss": "^8.4.16",
Expand All @@ -60,4 +59,4 @@
"vue-template-compiler": "2.6.14",
"vue-tsc": "^1.0.16"
}
}
}
3 changes: 1 addition & 2 deletions examples/vue3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"@vitest/ui": "^0.31.0",
"@vue/runtime-core": "3.2.31",
"@vue/test-utils": "^2.2.7",
"js-sha256": "^0.9.0",
"jsdom": "^21.0.0",
"onigasm": "^2.2.5",
"postcss": "^8.4.16",
Expand All @@ -59,4 +58,4 @@
"vue": "^3.3.9",
"vue-i18n": "^9.1.7"
}
}
}
9 changes: 5 additions & 4 deletions packages/renderless/src/base-select/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { find } from '../common/array'
import { find } from '@opentiny/utils'
import { getObj, isEqual } from '../common/object'
import { isKorean } from '../common/string'
import scrollIntoView from '../common/deps/scroll-into-view'
import PopupManager from '../common/deps/popup-manager'
import debounce from '../common/deps/debounce'
import { getDataset } from '../common/dataset'
import { getDataset } from '@opentiny/utils'
import Memorize from '../common/deps/memorize'
import { isEmptyObject } from '../common/type'
import { addResizeListener, removeResizeListener } from '../common/deps/resize-event'
Expand All @@ -15,7 +15,8 @@ import { isNull } from '../common/type'
import { fastdom } from '../common/deps/fastdom'
import { deepClone } from '../picker-column'
import { escapeRegexpString } from '../option'
import { isBrowser } from '../common/browser'

import { isServer } from '@opentiny/utils'

export const handleComposition =
({ api, nextTick, state }) =>
Expand Down Expand Up @@ -1864,7 +1865,7 @@ export const watchInitValue =
export const watchShowClose =
({ nextTick, state, parent }) =>
() => {
if (!isBrowser) return
if (isServer) return
nextTick(() => {
const parentEl = parent.$el
const inputEl = parentEl.querySelector('input[data-tag="tiny-input-inner"]')
Expand Down
2 changes: 1 addition & 1 deletion packages/renderless/src/calendar-bar/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { lastMonth, nextMonth } from '../common/calendar/calendar'
import { lastMonth, nextMonth } from '@opentiny/utils'
import { getDirection } from '../common/deps/touch'

const normalConfig = (config, state) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/renderless/src/calendar-view/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cloneDeep } from '../chart-core/deps/utils'
import { getDirection } from '../common/deps/touch'
import { getDays, lastMonth, nextMonth, getCalendar, transformArray } from '../common/calendar/calendar'
import { getDays, lastMonth, nextMonth, getCalendar, transformArray } from '@opentiny/utils'

const getTime = (date) => new Date(date).getTime()

Expand Down
2 changes: 1 addition & 1 deletion packages/renderless/src/calendar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import { copyArray } from '../common/object'
import { lastMonth, nextMonth, getCalendar, transformArray, parseDate } from '../common/calendar/calendar'
import { lastMonth, nextMonth, getCalendar, transformArray, parseDate } from '@opentiny/utils'

export const computedCalendar =
({ state }) =>
Expand Down
4 changes: 2 additions & 2 deletions packages/renderless/src/cascader-select/column-index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isBrowser } from '../common/browser'
import { isServer } from '@opentiny/utils'

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the server check condition in onTouchStart.

The current condition if (isServer) return will prevent touch handling in server environments, but allow it in server environments. This appears to be the opposite of the intended behavior, as touch events should only be handled in browser environments.

Apply this fix:

-  if (isServer) return
+  if (!isServer) {
     touch.start(event)
     if (state.moving) {
       const dom = vm.$refs.roller
       // ... rest of the function
     }
+  }

Also applies to: 45-45

const DEFAULT_DURATION = 200

Expand Down Expand Up @@ -42,7 +42,7 @@ export const setRollerStyle =
export const onTouchStart =
({ state, props, touch, vm }) =>
(event) => {
if (!isBrowser) return
if (isServer) return
touch.start(event)
if (state.moving) {
const dom = vm.$refs.roller
Expand Down
4 changes: 2 additions & 2 deletions packages/renderless/src/cascader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
*/

import browser, { isBrowser } from '../common/browser'
import { isServer, browser } from '@opentiny/utils'
import { isNull } from '../common/type'
import debounce from '../common/deps/debounce'
import { isEqual } from '../common/object'
Expand Down Expand Up @@ -356,7 +356,7 @@ export const focusFirstNode =
export const computePresentText =
({ props, state }: { props: ICascaderProps; state: ICascaderState }) =>
() => {
if (isBrowser) {
if (!isServer) {
if (!isEmpty(state.checkedValue)) {
const node = state.panel.getNodeByValue(state.checkedValue)

Expand Down
2 changes: 0 additions & 2 deletions packages/renderless/src/common/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ const isEdge = (browser) => {
export const isBrowser =
typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document

export const globalEnvironment = isBrowser ? window : global

export default (() => {
const browser = {
name: undefined,
Expand Down
3 changes: 2 additions & 1 deletion packages/renderless/src/common/deps/clickoutside.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

import { on } from './dom'

const isServer = typeof window === 'undefined'
import { isServer } from '@opentiny/utils'

const nodeList = []
const nameSpace = '@@clickoutsideContext'
let startClick
Expand Down
4 changes: 2 additions & 2 deletions packages/renderless/src/common/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import { isPlainObject, isNumber, isNumeric, isNull } from './type'
import { getObj, toJsonStr } from './object'
import { toFixed, Decimal } from './decimal'
import { globalEnvironment, isBrowser } from './browser'
import { isBrowser } from './browser'

/**
* 文本替换格式类型
Expand Down Expand Up @@ -243,7 +243,7 @@ export const fillChar = (string, length, append, chr = '0') => {

export const random = () => {
let MAX_UINT32_PLUS_ONE = 4294967296
return globalEnvironment.crypto.getRandomValues(new globalEnvironment.Uint32Array(1))[0] / MAX_UINT32_PLUS_ONE
return globalThis.crypto.getRandomValues(new Uint32Array(1))[0] / MAX_UINT32_PLUS_ONE
}

/**
Expand Down
20 changes: 10 additions & 10 deletions packages/renderless/src/date-panel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
import { getWeekData } from '../picker'
import debounce from '../common/deps/debounce'
import {
isDate,
parseDate,
isDate1,
parseDate1,
modifyDate,
modifyTime,
clearTime,
prevYear,
nextYear,
prevMonth,
nextMonth,
nextMonth1,
timeWithinRange,
clearMilliseconds,
modifyWithTimeString,
changeYearMonthAndClampDate,
formatDate,
extractTimeFormat
} from '../common/deps/date-util'
} from '@opentiny/utils'
import { DATEPICKER } from '../common'
import { on, off } from '../common/deps/dom'
import { getDateWithNewTimezone, getLocalTimezone } from '../common/date'
Expand Down Expand Up @@ -60,7 +60,7 @@ export const watchValue =
return
}

if (isDate(value)) {
if (isDate1(value)) {
state.date = state.selectionMode === 'week' ? getWeekData(value) : new Date(value)
} else {
state.date = api.getDefaultValue()
Expand All @@ -70,7 +70,7 @@ export const watchValue =
export const watchDefaultValue =
({ state }) =>
(value) => {
if (!isDate(state.value)) {
if (!isDate1(state.value)) {
state.date = value ? new Date(value) : new Date()
}
}
Expand Down Expand Up @@ -192,7 +192,7 @@ export const cusPrevMonth =
export const cusNextMonth =
({ state }) =>
() =>
(state.date = nextMonth(state.date))
(state.date = nextMonth1(state.date))

export const cusPrevYear =
({ state }) =>
Expand Down Expand Up @@ -238,7 +238,7 @@ export const doPick = (emit) => (date) => {
export const handleTimePick =
({ api, state, t }) =>
(value, visible, first) => {
if (isDate(value)) {
if (isDate1(value)) {
const newDate = state.value
? modifyTime(state.value, value.getHours(), value.getMinutes(), value.getSeconds())
: modifyWithTimeString(api.getDefaultValue(), state.defaultTime, t)
Expand Down Expand Up @@ -487,7 +487,7 @@ export const handleKeyControl =
export const handleVisibleTimeChange =
({ api, vm, state, t }) =>
(value) => {
const time = parseDate(value, state.timeFormat, t)
const time = parseDate1(value, state.timeFormat, t)

if (time && api.checkDateWithinRange(time)) {
state.date = modifyDate(time, state.year, state.month, state.monthDate)
Expand All @@ -505,7 +505,7 @@ export const handleVisibleTimeChange =
export const handleVisibleDateChange =
({ api, state, t }) =>
(value) => {
const date = parseDate(value, state.dateFormat, t)
const date = parseDate1(value, state.dateFormat, t)

if (date) {
if (typeof state.disabledDate === 'function' && state.disabledDate(date)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/renderless/src/date-panel/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import {
getDisabledConfirm,
getNowTime
} from './index'
import { toDate, getWeekNumber, modifyDate, extractDateFormat } from '../common/deps/date-util'
import { toDate1, getWeekNumber, modifyDate, extractDateFormat } from '@opentiny/utils'
import { DATEPICKER, DATE } from '../common'

export const api = [
Expand Down Expand Up @@ -146,7 +146,7 @@ const initWatch = ({ watch, state, api, nextTick, props }) => {
watch(
() => props.modelValue,
(value) => {
let newVal = toDate(value)
let newVal = toDate1(value)
if (newVal) {
const newDate = modifyDate(newVal, newVal.getFullYear(), newVal.getMonth(), newVal.getUTCDate())
state.date = newDate
Expand Down
Loading
Loading