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

refactor(mobile): remove @opentiny/mobile-utils package, and add alia… #2767

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module.exports = {
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-invalid-this': 'off',
'vue/no-deprecated-dollar-scopedslots-api': 'off',
'@typescript-eslint/lines-between-class-members': 'off'
'@typescript-eslint/lines-between-class-members': 'off',
'@typescript-eslint/no-this-alias': 'off'
}
}
1 change: 1 addition & 0 deletions examples/sites/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export default defineConfig((config) => {
resolve: {
extensions: ['.js', '.ts', '.tsx', '.vue'],
alias: {
'@mobile-root': pathFromWorkspaceRoot('packages/mobile'),
'@': path.resolve('src'),
'@demos': path.resolve(`${demosPath}`),
'@menu': menuPath,
Expand Down
1 change: 1 addition & 0 deletions examples/vue3/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default defineConfig((config) => {
resolve: {
extensions: ['.js', '.ts', '.tsx', '.vue'],
alias: {
'@mobile-root': pathFromWorkspaceRoot('packages/mobile'),
'vue': path.resolve('node_modules/vue/dist/vue.esm-bundler.js'),
'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
'@': pathFromWorkspaceRoot('examples/docs/newsrc'),
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/action-sheet/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

<script lang="ts">
import { renderless, api } from './renderless/vue'
import { $prefix, setup, defineComponent } from '../../../vue-common'
import { $prefix, setup, defineComponent } from '@mobile-root/vue-common'
import '@opentiny/vue-theme-mobile/action-sheet/index.less'
import BScroll from '@better-scroll/core'
import { actionSheetProps } from './action-sheet'
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/alert/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<script lang="ts">
import { renderless, api } from './renderless/vue'
import { setup, defineComponent } from '../../../vue-common'
import { setup, defineComponent } from '@mobile-root/vue-common'
import { iconClose, iconSuccess, iconError, iconHelp, iconWarningTriangle } from '@opentiny/vue-icon'
import type { IAlertApi } from './alert'
import { alertProps } from './alert'
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/avatar/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
-->
<script lang="tsx">
import { $prefix, setup, h, defineComponent } from '../../../vue-common'
import { $prefix, setup, h, defineComponent } from '@mobile-root/vue-common'
import { renderless, api } from './renderless/vue'
import '@opentiny/vue-theme-mobile/avatar/index.less'

Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/badge/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<script lang="ts">
import { renderless, api } from './renderless/vue'
import { setup, defineComponent } from '../../../vue-common'
import { setup, defineComponent } from '@mobile-root/vue-common'
import { badgeProps } from './badge'
import '@opentiny/vue-theme-mobile/badge/index.less'

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

import { computedContent, computedValueRef, computedTransform } from './index'
import { xss } from '@opentiny/mobile-utils/xss'
import { xss } from '@mobile-root/utils/xss'
import type { IBadgeState, IBadgeProps, IBadgeApi, IBadgeRenderlessParams } from '../badge'

export const api = ['state']
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/button/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

<script lang="ts">
import { renderless, api } from './renderless/vue'
import { setup, defineComponent } from '../../../vue-common'
import { setup, defineComponent } from '@mobile-root/vue-common'
import { buttonProps } from './button'
import '@opentiny/vue-theme-mobile/button/index.less'

Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/button/src/renderless/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
*/
import type { IButtonRenderlessParams, IButtonState } from '../button'
import { xss } from '@opentiny/mobile-utils'
import { xss } from '@mobile-root/utils'

export const handleClick =
({ emit, props, state }: Pick<IButtonRenderlessParams, 'emit' | 'props' | 'state'>) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/checkbox-group/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<script lang="tsx">
import { renderless, api } from './renderless/vue'
import { $prefix, setup, defineComponent } from '../../../vue-common'
import { $prefix, setup, defineComponent } from '@mobile-root/vue-common'
import Checkbox from '../../checkbox'
import { CheckboxGroupProps } from './checkbox-group'
import '@opentiny/vue-theme-mobile/checkbox-group/index.less'
Expand Down
4 changes: 2 additions & 2 deletions packages/mobile/components/checkbox/src/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
import { $prefix } from '../../../vue-common'
import type { PropType } from '../../../vue-common'
import { $prefix } from '@mobile-root/vue-common'
import type { PropType } from '@mobile-root/vue-common'
import type { ExtractPropTypes, ComputedRef } from 'vue'
import type { ISharedRenderlessFunctionParams, ISharedRenderlessParamUtils } from '../../../types/shared.type'

Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/checkbox/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

<script lang="ts">
import { renderless, api } from './renderless/vue'
import { $prefix, setup, defineComponent } from '../../../vue-common'
import { $prefix, setup, defineComponent } from '@mobile-root/vue-common'
import { checkboxProps } from './checkbox'
import '@opentiny/vue-theme-mobile/checkbox/index.less'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import type { ICheckboxRenderlessParams, ICheckboxState, ICheckboxChangeEvent, ICheckboxProps } from '../checkbox'
import { isNull } from '@opentiny/mobile-utils/type'
import { isNull } from '@mobile-root/utils/type'

export const addToStore =
({ state, props }: Pick<ICheckboxRenderlessParams, 'state' | 'props'>) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/container/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<script lang="ts">
import { renderless, api } from './renderless/vue'
import { setup, defineComponent } from '../../../vue-common'
import { setup, defineComponent } from '@mobile-root/vue-common'
import { containerProps } from './container'
import '@opentiny/vue-theme-mobile/container/index.less'

Expand Down
4 changes: 2 additions & 2 deletions packages/mobile/components/container/src/renderless/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
*/

import { isNumber } from '@opentiny/mobile-utils/type'
import { isNumber } from '@mobile-root/utils/type'

export const computedShowHeader =
({ constants, props }) =>
Expand Down Expand Up @@ -128,7 +128,7 @@ export const computedLeftStyle =
export const computedShowRight =
({ constants, props }) =>
() => {
return props.pattern === constants.DEFAULT ? false : true
return props.pattern !== constants.DEFAULT

Choose a reason for hiding this comment

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

The condition props.pattern === constants.DEFAULT ? false : true is simplified to props.pattern !== constants.DEFAULT. This change is correct and maintains the original logic.

}

export const computedRightStyle =
Expand Down
3 changes: 2 additions & 1 deletion packages/mobile/components/date-picker/src/date-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
import type { PropType } from '../../../vue-common'
import type { PropType } from '@mobile-root/vue-common'
import { iconClose } from '@opentiny/vue-icon'
import type { ComputedRef, ExtractPropTypes } from 'vue'
import type { ISharedRenderlessFunctionParams, ISharedRenderlessParamUtils } from '../../../types/shared.type'

export type { ISharedRenderlessParamHooks } from '../../../types/shared.type'

const currentYear = new Date().getFullYear()
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/date-picker/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</template>

<script lang="ts">
import { props, setup, defineComponent } from '../../../vue-common'
import { props, setup, defineComponent } from '@mobile-root/vue-common'
import { renderless, api } from './renderless/vue'
import MiniPicker from '../../mini-picker'
import Input from '../../input'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
onChange,
updateColumnValue
} from './index'
import { DATE } from '@opentiny/mobile-utils'
import { DATE } from '@mobile-root/utils'
import type {
IDatePickerApi,
IDatePickerProps,
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/dialog-box/src/dialog-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
*/

import { $prefix } from '../../../vue-common'
import { $prefix } from '@mobile-root/vue-common'
import type { ExtractPropTypes } from 'vue'
import type {
handleCancel,
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/dialog-box/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<script lang="ts">
import { renderless, api } from './renderless/vue'
import { setup, defineComponent } from '../../../vue-common'
import { setup, defineComponent } from '@mobile-root/vue-common'
import { dialogBoxProps } from './dialog-box'
import '@opentiny/vue-theme-mobile/dialog-box/index.less'

Expand Down
6 changes: 3 additions & 3 deletions packages/mobile/components/dialog-box/src/renderless/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*
*/

import { on, off, addClass, removeClass } from '@opentiny/mobile-utils/deps/dom'
import { emitEvent } from '@opentiny/mobile-utils/event'
import { getDomNode } from '@opentiny/mobile-utils/deps/dom'
import { on, off, addClass, removeClass } from '@mobile-root/utils/deps/dom'
import { emitEvent } from '@mobile-root/utils/event'
import { getDomNode } from '@mobile-root/utils/deps/dom'
import type { IDialogBoxRenderlessParams, IDialogBoxStyle } from '../dialog-box'

export const computedAnimationName =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
hideScrollbar,
computedBodyStyle
} from './index'
import usePopup from '@opentiny/mobile-utils/deps/vue-popup'
import usePopup from '@mobile-root/utils/deps/vue-popup'
import type {
IDialogBoxApi,
IDialogBoxProps,
Expand Down
4 changes: 2 additions & 2 deletions packages/mobile/components/dropdown-item/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@

<script lang="ts">
import { renderless, api } from './renderless/vue'
import { setup, defineComponent, directive } from '../../../vue-common'
import { setup, defineComponent, directive } from '@mobile-root/vue-common'
import { iconYes } from '@opentiny/vue-icon'
import Popup from '../../popup'
import Button from '../../button'
import Clickoutside from '@opentiny/mobile-utils/deps/clickoutside'
import Clickoutside from '@mobile-root/utils/deps/clickoutside'
import '@opentiny/vue-theme-mobile/dropdown-item/index.less'
import { dropdownItemProps } from './dropdown-item'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {
IDropdownItemTag,
IDropdownItemOptionStyle
} from '../dropdown-item'
import { on, off } from '@opentiny/mobile-utils/deps/dom'
import { on, off } from '@mobile-root/utils/deps/dom'

export const getTitle = (props: IDropdownItemRenderlessParams['props']) => (): string => {
if (props.title) {
Expand Down
8 changes: 4 additions & 4 deletions packages/mobile/components/dropdown-menu/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
item.type === 'filter'
? 'IconUnfilter'
: item.type === 'selection' && item.state.showPopup
? 'IconUp'
: 'IconDown'
? 'IconUp'
: 'IconDown'
"
:class="[item.type === 'filter' ? 'filter-icon' : '']"
/>
Expand All @@ -68,10 +68,10 @@

<script lang="ts">
import { renderless, api } from './renderless/vue'
import { setup, defineComponent, directive } from '../../../vue-common'
import { setup, defineComponent, directive } from '@mobile-root/vue-common'
import { iconUp, iconDown, iconUnfilter, iconSort, iconDeltaDown, iconDeltaUp } from '@opentiny/vue-icon'
import { dropdownMenuProps } from './dropdown-menu'
import Clickoutside from '@opentiny/mobile-utils/deps/clickoutside'
import Clickoutside from '@mobile-root/utils/deps/clickoutside'
import '@opentiny/vue-theme-mobile/dropdown-menu/index.less'

export default defineComponent({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import type { IDropdownMenuRenderlessParams, IDropdownMenuPopperParams, IDropdownItemVm } from '../dropdown-menu'
import userPopper from '@opentiny/mobile-utils/deps/vue-popper'
import userPopper from '@mobile-root/utils/deps/vue-popper'

export const toggleItem =
(state: IDropdownMenuRenderlessParams['state']) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/exception/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<script>
import { renderless, api } from './renderless/vue'
import { setup, $prefix, defineComponent } from '../../../vue-common'
import { setup, $prefix, defineComponent } from '@mobile-root/vue-common'
import Button from '../../button'
import { exceptionProps } from './exception'
import '@opentiny/vue-theme-mobile/exception/index.less'
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/file-upload/src/file-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ import type {
} from './renderless'
import type { downloadFile as ordinaryDownload } from '../../upload-list/src/upload-list'
import type { IUploadFormData } from '../../upload/src/upload'
import { $props } from '../../../vue-common'
import { $props } from '@mobile-root/vue-common'

export type { ISharedRenderlessParamHooks } from '../../../types/shared.type'

Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/file-upload/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-->
<script lang="tsx">
import { renderless, api } from './renderless/vue'
import { setup, h, defineComponent } from '../../../vue-common'
import { setup, h, defineComponent } from '@mobile-root/vue-common'
import UploadList from '../../upload-list'
import Upload from '../../upload'
import { iconUpload } from '@opentiny/vue-icon'
Expand Down
10 changes: 5 additions & 5 deletions packages/mobile/components/file-upload/src/renderless/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import type {
IFileUploadLargeDocumentDownload
} from '../file-upload'

import { extend } from '@opentiny/mobile-utils/object'
import { xss, log } from '@opentiny/mobile-utils/xss'
import uploadAjax from '@opentiny/mobile-utils/deps/upload-ajax'
import { isObject } from '@opentiny/mobile-utils/type'
import { isEmptyObject } from '@opentiny/mobile-utils/type'
import { extend } from '@mobile-root/utils/object'
import { xss, log } from '@mobile-root/utils/xss'
import uploadAjax from '@mobile-root/utils/deps/upload-ajax'
import { isObject } from '@mobile-root/utils/type'
import { isEmptyObject } from '@mobile-root/utils/type'

let initTokenPromise = null

Expand Down
4 changes: 2 additions & 2 deletions packages/mobile/components/file-upload/src/renderless/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
IFileUploadStreamsaver
} from '../file-upload'
import { downloadFile as ordinaryDownload } from '../../../upload-list/src/renderless'
import { formatFileSize } from '@opentiny/mobile-utils/string'
import { formatFileSize } from '@mobile-root/utils/string'

import {
initService,
Expand Down Expand Up @@ -96,7 +96,7 @@ import {
closeRecordPanel,
getTipMessage
} from './index'
import { isEmptyObject } from '@opentiny/mobile-utils/type'
import { isEmptyObject } from '@mobile-root/utils/type'

export const api = [
'state',
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/form-item/src/label-wrap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { setup, h, $props, defineComponent } from '../../../vue-common'
import { setup, h, $props, defineComponent } from '@mobile-root/vue-common'

export default defineComponent({
props: {
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/form-item/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
-->
<script lang="tsx">
import { $prefix, setup, parseVnode, h, defineComponent, isVue2 } from '../../../vue-common'
import { $prefix, setup, parseVnode, h, defineComponent, isVue2 } from '@mobile-root/vue-common'
import { renderless, api } from './renderless/vue'
import LabelWrap from './label-wrap'
import Tooltip from '../../tooltip'
Expand Down
12 changes: 6 additions & 6 deletions packages/mobile/components/form-item/src/renderless/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
*
*/

import { POSITION, VALIDATE_STATE } from '@opentiny/mobile-utils'
import { omitText } from '@opentiny/mobile-utils/string'
import { merge } from '@opentiny/mobile-utils/object'
import Validator from '@opentiny/mobile-utils/validate'
import { isNull } from '@opentiny/mobile-utils/type'
import debounce from '@opentiny/mobile-utils/deps/debounce'
import { POSITION, VALIDATE_STATE } from '@mobile-root/utils'
import { omitText } from '@mobile-root/utils/string'
import { merge } from '@mobile-root/utils/object'
import Validator from '@mobile-root/utils/validate'
import { isNull } from '@mobile-root/utils/type'
import debounce from '@mobile-root/utils/deps/debounce'
import type {
IFormItemRenderlessParams,
IFormItemDisplayedValueParam,
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/form/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<script lang="tsx">
import { renderless, api } from './renderless/vue'
import { $prefix, setup, defineComponent } from '../../../vue-common'
import { $prefix, setup, defineComponent } from '@mobile-root/vue-common'
import type { IFormApi } from '@opentiny/vue-renderless/types/form.type'
import { formProps } from './form'
import '@opentiny/vue-theme-mobile/form/index.less'
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/form/src/renderless/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
*/

import { merge } from '@opentiny/mobile-utils/object'
import { merge } from '@mobile-root/utils/object'

import type { IFormRenderlessParams } from '../form'

Expand Down
Loading
Loading