Skip to content

Commit

Permalink
fix(checkbox): modify mobile problem
Browse files Browse the repository at this point in the history
  • Loading branch information
James-9696 committed Dec 17, 2024
1 parent 926fb6e commit be9913e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 29 deletions.
4 changes: 2 additions & 2 deletions examples/sites/demos/mobile/app/checkbox/checkbox-group.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<div class="checkbox-wrap">
<tiny-checkbox-group v-model="checked">
<tiny-checkbox label="复选框1"></tiny-checkbox>
<tiny-checkbox label="复选框2"></tiny-checkbox>
<tiny-checkbox label="复选框1">复选框1</tiny-checkbox>
<tiny-checkbox label="复选框2">复选框2</tiny-checkbox>
</tiny-checkbox-group>
<p>当前选中的值为:{{ checked }}</p>
</div>
Expand Down
5 changes: 4 additions & 1 deletion packages/mobile/components/checkbox-group/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,19 @@

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

export default defineComponent({
name: $prefix + 'CheckboxGroup',
componentName: 'CheckboxGroup',
components: {
Checkbox
},
props: CheckboxGroupProps,
emits: ['change', 'update:modelValue'],
setup(props, context) {
return setup({ props, context, renderless, api })
}
Expand Down
43 changes: 22 additions & 21 deletions packages/mobile/components/checkbox/src/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@ import { $prefix } from '../../../vue-common'
import type { PropType } from '../../../vue-common'
import type { ExtractPropTypes, ComputedRef } from 'vue'
import type { ISharedRenderlessFunctionParams, ISharedRenderlessParamUtils } from '../../../types/shared.type'

import type {
addToStore,
removeFromStore,
computedStore,
computedFormItemSize,
computedIsChecked,
computedIsLimitDisabled,
computedIsDisabled,
computedIsDisplayOnly,
computedIsGroupDisplayOnly,
computedGetModelGet,
computedIsGroup,
computedCheckboxSize,
computedGetModelSet,
mounted,
handleChange,
computedDisplayLabel,
computedIsShowText,
computedShowText
} from './renderless'

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

export type IconPosition = 'center' | 'top'
Expand Down Expand Up @@ -75,27 +97,6 @@ export const checkboxProps = {
}
}

import type {
addToStore,
removeFromStore,
computedStore,
computedFormItemSize,
computedIsChecked,
computedIsLimitDisabled,
computedIsDisabled,
computedIsDisplayOnly,
computedIsGroupDisplayOnly,
computedGetModelGet,
computedIsGroup,
computedCheckboxSize,
computedGetModelSet,
mounted,
handleChange,
computedDisplayLabel,
computedIsShowText,
computedShowText
} from './renderless'

export type ICheckboxSizeEnum = 'medium' | 'small' | 'mini'
export type ICheckboxModalValue = string | number | boolean

Expand Down
4 changes: 3 additions & 1 deletion packages/mobile/components/checkbox/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@

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

export default defineComponent({
name: $prefix + 'Checkbox',
componentName: 'Checkbox',
props: checkboxProps,
emits: ['update:modelValue', 'change', 'complete', 'click'],
setup(props, context) {
Expand Down
5 changes: 2 additions & 3 deletions packages/mobile/components/checkbox/src/renderless/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@ export const computedIsChecked =
}

export const computedIsGroup =
({ state, parent, constants }: Pick<ICheckboxRenderlessParams, 'state' | 'parent' | 'constants'>) =>
({ state, vm, constants }: Pick<ICheckboxRenderlessParams, 'state' | 'vm' | 'constants'>) =>
(): boolean => {
let parentObj = parent.$parent

let parentObj = vm.$parent
while (parentObj) {
if (parentObj.$options.componentName !== constants.CHECKBOX_GROUP) {
parentObj = parentObj.$parent
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile/components/checkbox/src/renderless/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const initApi = ({
computedIsDisplayOnly: computedIsDisplayOnly({ state, props }),
computedIsGroupDisplayOnly: computedIsGroupDisplayOnly({ state }),
computedGetModelGet: computedGetModelGet({ state, props }),
computedIsGroup: computedIsGroup({ state, parent, constants }),
computedIsGroup: computedIsGroup({ state, vm, constants }),
computedCheckboxSize: computedCheckboxSize({ state, props, formItemSize }),
computedGetModelSet: computedGetModelSet({ state, dispatch, emit, constants }),
mounted: mounted({ emit, props, api, parent }),
Expand Down

0 comments on commit be9913e

Please sign in to comment.