Skip to content

Commit

Permalink
fix: update model type
Browse files Browse the repository at this point in the history
  • Loading branch information
daief committed Jun 23, 2023
1 parent f95af70 commit b380143
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ export function render() {
- [x] pre insert all global style
- [ ] popper/modal/drawer animation(maybe some preset animations)
- [x] modal, drawer
- [ ] refine theme usage
- [x] refine theme usage
- [ ] inline-block(radio, checkbox, toggle) vertical-align

## Components

Expand Down
1 change: 0 additions & 1 deletion docs/src/pages/components/drawer.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ export default {
| disableTeleport | disable teleport behavior | boolean | - |
| flattern | make drawer to be always visible | boolean | - |
| placement | drawer open position | left, right | left |
| placement | drawer open position | left, right | left |

### Events

Expand Down
7 changes: 6 additions & 1 deletion src/components/radio/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ export const radioGroupProps = {

export type IRadioGroupProps = ExtractFromProps<typeof radioGroupProps>;

export const RadioGroup = componentV2<IRadioGroupProps, HTMLAttributes>({
export const RadioGroup = componentV2<
IRadioGroupProps,
HTMLAttributes & {
'onUpdate:modelValue'?: (value: IText) => void;
}
>({
name: 'RadioGroup',
props: radioGroupProps,
emits: [V_MODEL_EVENT],
Expand Down
4 changes: 4 additions & 0 deletions src/shared/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export interface IStyleProps {
style?: StyleValue;
}

export interface IModalValueProps<V> {
'onUpdate:modelValue'?: (value: V) => void;
}

export type IMaybeRef<T> = T | Ref<T>;

export type IMaybeRefs<T> = {
Expand Down
15 changes: 15 additions & 0 deletions src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import {
Comment,
Fragment,
isVNode,
Ref,
Slots,
toRef,
VNode,
VNodeNormalizedChildren,
} from 'vue';
import { IMaybeRefs } from './types/common';

export const isBrowser = typeof window !== 'undefined';

Expand Down Expand Up @@ -163,3 +166,15 @@ export function debounce<F extends (...args: any) => any>(

return result;
}

export const maybeRefsToRefs = <T, Keys extends (keyof T)[]>(
obj: IMaybeRefs<T>,
keys: Keys,
): {
[P in Keys[number]]: Ref<T[P]>;
} => {
return keys.reduce((acc, key) => {
acc[key] = toRef(obj, key);
return acc;
}, {} as any);
};

0 comments on commit b380143

Please sign in to comment.