Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yangkaifeng
uni-app
提交
077ed287
U
uni-app
项目概览
yangkaifeng
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
077ed287
编写于
2月 18, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
差异文件
chore: merge
上级
e5470416
84017bc5
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
409 addition
and
96 deletion
+409
-96
packages/uni-components/dist/components.js
packages/uni-components/dist/components.js
+285
-37
packages/uni-components/src/components/ad-draw.ts
packages/uni-components/src/components/ad-draw.ts
+2
-1
packages/uni-components/src/components/checkbox-group.ts
packages/uni-components/src/components/checkbox-group.ts
+21
-0
packages/uni-components/src/nvue/ad-draw/index.tsx
packages/uni-components/src/nvue/ad-draw/index.tsx
+3
-3
packages/uni-components/src/nvue/ad/index.tsx
packages/uni-components/src/nvue/ad/index.tsx
+10
-5
packages/uni-components/src/nvue/checkbox-group/index.tsx
packages/uni-components/src/nvue/checkbox-group/index.tsx
+12
-33
packages/uni-components/src/nvue/checkbox/index.tsx
packages/uni-components/src/nvue/checkbox/index.tsx
+72
-17
packages/uni-components/src/nvue/components.ts
packages/uni-components/src/nvue/components.ts
+4
-0
未找到文件。
packages/uni-components/dist/components.js
浏览文件 @
077ed287
...
...
@@ -2586,7 +2586,7 @@ function getDefaultEndValue(props2) {
}
return
""
;
}
const
props$
3
=
{
const
props$
2
=
{
name
:
{
type
:
String
,
default
:
""
...
...
@@ -2631,7 +2631,7 @@ const props$3 = {
};
var
Picker
=
/* @__PURE__ */
defineComponent
({
name
:
"
Picker
"
,
props
:
props$
3
,
props
:
props$
2
,
emits
:
[
"
change
"
,
"
cancel
"
,
"
columnchange
"
],
setup
(
props2
,
{
slots
,
...
...
@@ -3196,6 +3196,13 @@ const checkboxProps = {
default
:
""
}
};
const
uniCheckGroupKey
=
PolySymbol
(
process
.
env
.
NODE_ENV
!==
"
production
"
?
"
uniCheckGroup
"
:
"
ucg
"
);
const
checkboxGroupProps
=
{
name
:
{
type
:
String
,
default
:
""
}
};
const
checkboxStyles
=
[{
"
uni-checkbox
"
:
{
""
:
{
...
...
@@ -3253,7 +3260,11 @@ var Checkbox = defineComponent({
const
rootRef
=
ref
(
null
);
const
checkboxChecked
=
ref
(
props2
.
checked
);
const
checkboxValue
=
ref
(
props2
.
value
);
const
onClick
=
(
e2
,
isLabelClick
)
=>
{
const
checkboxColor
=
computed
(()
=>
props2
.
disabled
?
"
#adadad
"
:
props2
.
color
);
const
reset
=
()
=>
{
checkboxChecked
.
value
=
false
;
};
const
_onClick
=
(
$event
,
isLabelClick
)
=>
{
if
(
props2
.
disabled
)
{
return
;
}
...
...
@@ -3261,21 +3272,24 @@ var Checkbox = defineComponent({
rootRef
.
value
.
click
();
}
checkboxChecked
.
value
=
!
checkboxChecked
.
value
;
uniCheckGroup
&&
uniCheckGroup
.
checkboxChange
(
$event
);
};
const
checkboxColor
=
computed
(()
=>
props2
.
disabled
?
"
#adadad
"
:
props2
.
color
);
watch
([()
=>
props2
.
checked
,
()
=>
props2
.
value
],
([
newChecked
,
newModelValue
])
=>
{
checkboxChecked
.
value
=
newChecked
;
checkboxValue
.
value
=
newModelValue
;
});
const
uniLabel
=
inject
(
uniLabelKey
,
false
);
const
{
uniCheckGroup
,
uniLabel
}
=
useCheckboxInject
(
checkboxChecked
,
checkboxValue
,
reset
);
if
(
uniLabel
)
{
uniLabel
.
addHandler
(
onClick
);
uniLabel
.
addHandler
(
_
onClick
);
onBeforeUnmount
(()
=>
{
uniLabel
.
removeHandler
(
onClick
);
uniLabel
.
removeHandler
(
_
onClick
);
});
}
useListeners
(
props2
,
{
"
label-click
"
:
onClick
"
label-click
"
:
_onClick
});
watch
([()
=>
props2
.
checked
,
()
=>
props2
.
value
],
([
newChecked
,
newModelValue
])
=>
{
checkboxChecked
.
value
=
newChecked
;
checkboxValue
.
value
=
newModelValue
;
});
const
wrapSlots
=
()
=>
{
if
(
!
slots
.
default
)
...
...
@@ -3294,7 +3308,7 @@ var Checkbox = defineComponent({
},
{
dataUncType
:
"
uni-checkbox
"
},
{
"
onClick
"
:
onClick
,
"
onClick
"
:
_
onClick
,
"
class
"
:
"
uni-checkbox
"
}),
[
createVNode
(
"
div
"
,
{
"
class
"
:
[
"
uni-checkbox-input
"
,
{
...
...
@@ -3309,40 +3323,43 @@ var Checkbox = defineComponent({
};
}
});
const
uniCheckGroupKey
=
PolySymbol
(
process
.
env
.
NODE_ENV
!==
"
production
"
?
"
uniCheckGroup
"
:
"
ucg
"
);
function
useCustomEvent
(
ref2
,
emit
)
{
return
(
name
,
evt
,
detail
)
=>
{
if
(
ref2
.
value
)
{
emit
(
name
,
normalizeCustomEvent
(
name
,
evt
,
ref2
.
value
,
detail
||
{}));
}
function
useCheckboxInject
(
checkboxChecked
,
checkboxValue
,
reset
)
{
const
field
=
computed
(()
=>
({
checkboxChecked
:
Boolean
(
checkboxChecked
.
value
),
value
:
checkboxValue
.
value
}));
const
formField
=
{
reset
};
}
function
normalizeCustomEvent
(
name
,
domEvt
,
el
,
detail
)
{
const
target
=
normalizeTarget
(
el
);
const
uniCheckGroup
=
inject
(
uniCheckGroupKey
,
false
);
if
(
!!
uniCheckGroup
)
{
uniCheckGroup
.
addField
(
field
);
}
const
uniForm
=
inject
(
uniFormKey
,
false
);
if
(
!!
uniForm
)
{
uniForm
.
addField
(
formField
);
}
const
uniLabel
=
inject
(
uniLabelKey
,
false
);
onBeforeUnmount
(()
=>
{
uniCheckGroup
&&
uniCheckGroup
.
removeField
(
field
);
uniForm
&&
uniForm
.
removeField
(
formField
);
});
return
{
type
:
detail
.
type
||
name
,
timeStamp
:
domEvt
.
timeStamp
||
0
,
target
,
currentTarget
:
target
,
detail
uniCheckGroup
,
uniForm
,
uniLabel
};
}
const
props$2
=
{
name
:
{
type
:
String
,
default
:
""
}
};
var
CheckboxGroup
=
defineComponent
({
name
:
"
CheckboxGroup
"
,
props
:
props$2
,
props
:
checkboxGroupProps
,
emits
:
[
"
change
"
],
setup
(
props2
,
{
slots
,
emit
})
{
const
rootRef
=
ref
(
null
);
const
trigger
=
useCustomEvent
(
rootRef
,
emit
);
const
trigger
=
useCustomEvent
$1
(
rootRef
,
emit
);
useProvideCheckGroup
(
props2
,
trigger
);
return
()
=>
{
return
createVNode
(
"
div
"
,
{
...
...
@@ -3368,7 +3385,7 @@ function useProvideCheckGroup(props2, trigger) {
fields2
.
splice
(
fields2
.
indexOf
(
field
),
1
);
},
checkboxChange
(
$event
)
{
trigger
(
"
change
"
,
$event
,
{
trigger
(
"
change
"
,
{
value
:
getFieldsValue
()
});
}
...
...
@@ -3547,6 +3564,23 @@ function useRadioState(props2) {
return
state
;
}
const
uniRadioGroupKey
=
PolySymbol
(
process
.
env
.
NODE_ENV
!==
"
production
"
?
"
uniRadioGroup
"
:
"
ucg
"
);
function
useCustomEvent
(
ref2
,
emit
)
{
return
(
name
,
evt
,
detail
)
=>
{
if
(
ref2
.
value
)
{
emit
(
name
,
normalizeCustomEvent
(
name
,
evt
,
ref2
.
value
,
detail
||
{}));
}
};
}
function
normalizeCustomEvent
(
name
,
domEvt
,
el
,
detail
)
{
const
target
=
normalizeTarget
(
el
);
return
{
type
:
detail
.
type
||
name
,
timeStamp
:
domEvt
.
timeStamp
||
0
,
target
,
currentTarget
:
target
,
detail
};
}
const
props$1
=
{
name
:
{
type
:
String
,
...
...
@@ -4407,6 +4441,218 @@ function normalizeNodes(nodes, instance, options) {
}
return
nvueNodes
;
}
const
_adDataCache$1
=
{};
function
getAdData$1
(
data
,
onsuccess
,
onerror
)
{
const
{
adpid
,
width
}
=
data
;
const
key
=
adpid
+
"
-
"
+
width
;
const
adDataList
=
_adDataCache$1
[
key
];
if
(
adDataList
&&
adDataList
.
length
>
0
)
{
onsuccess
(
adDataList
.
splice
(
0
,
1
)[
0
]);
return
;
}
plus
.
ad
.
getAds
(
data
,
(
res
)
=>
{
const
list
=
res
.
ads
;
onsuccess
(
list
.
splice
(
0
,
1
)[
0
]);
_adDataCache$1
[
key
]
=
adDataList
?
adDataList
.
concat
(
list
)
:
list
;
},
(
err
)
=>
{
onerror
({
errCode
:
err
.
code
,
errMsg
:
err
.
message
});
});
}
const
adProps
=
{
adpid
:
{
type
:
[
Number
,
String
],
default
:
""
},
data
:
{
type
:
String
,
default
:
""
},
width
:
{
type
:
String
,
default
:
""
},
channel
:
{
type
:
String
,
default
:
""
}
};
const
AdEventType$1
=
{
load
:
"
load
"
,
close
:
"
close
"
,
error
:
"
error
"
,
downloadchange
:
"
downloadchange
"
};
var
Ad
=
defineComponent
({
name
:
"
Ad
"
,
props
:
adProps
,
emits
:
[
AdEventType$1
.
load
,
AdEventType$1
.
close
,
AdEventType$1
.
error
,
AdEventType$1
.
downloadchange
],
setup
(
props2
,
{
emit
})
{
const
adRef
=
ref
(
null
);
const
trigger
=
useCustomEvent$1
(
adRef
,
emit
);
const
state
=
useAdState
();
watch
(()
=>
props2
.
adpid
,
(
value
)
=>
{
_loadAdData$1
(
state
,
props2
,
trigger
);
});
watch
(()
=>
props2
.
data
,
(
value
)
=>
{
state
.
data
=
value
;
});
onMounted
(()
=>
{
setTimeout
(()
=>
{
getComponentSize
(
adRef
.
value
).
then
(({
width
})
=>
{
state
.
width
=
width
===
0
?
-
1
:
width
;
_loadAdData$1
(
state
,
props2
,
trigger
);
});
},
50
);
});
const
listeners
=
{
onDownloadchange
(
e2
)
{
trigger
(
AdEventType$1
.
downloadchange
,
e2
);
},
onDislike
(
e2
)
{
trigger
(
AdEventType$1
.
close
,
e2
);
}
};
return
()
=>
{
return
createVNode
(
"
u-ad
"
,
mergeProps
({
"
ref
"
:
adRef
},
{
data
:
state
.
data
,
rendering
:
true
},
listeners
),
null
);
};
}
});
function
useAdState
(
props2
)
{
const
data
=
ref
(
""
);
const
state
=
reactive
({
width
:
0
,
data
});
return
state
;
}
function
_loadAdData$1
(
state
,
props2
,
trigger
)
{
getAdData$1
({
adpid
:
props2
.
adpid
,
width
:
state
.
width
},
(
res
)
=>
{
state
.
data
=
res
;
trigger
(
AdEventType$1
.
load
,
{});
},
(
err
)
=>
{
trigger
(
AdEventType$1
.
error
,
err
);
});
}
const
_adDataCache
=
{};
function
getAdData
(
adpid
,
width
,
height
,
onsuccess
,
onerror
)
{
const
key
=
adpid
+
"
-
"
+
width
;
const
adDataList
=
_adDataCache
[
key
];
if
(
adDataList
&&
adDataList
.
length
>
0
)
{
onsuccess
(
adDataList
.
splice
(
0
,
1
)[
0
]);
return
;
}
plus
.
ad
.
getDrawAds
({
adpid
:
String
(
adpid
),
count
:
3
,
width
},
(
res
)
=>
{
const
list
=
res
.
ads
;
onsuccess
(
list
.
splice
(
0
,
1
)[
0
]);
_adDataCache
[
key
]
=
adDataList
?
adDataList
.
concat
(
list
)
:
list
;
},
(
err
)
=>
{
onerror
({
errCode
:
err
.
code
,
errMsg
:
err
.
message
});
});
}
const
adDrawProps
=
{
adpid
:
{
type
:
[
Number
,
String
],
default
:
""
},
data
:
{
type
:
String
,
default
:
""
},
width
:
{
type
:
String
,
default
:
""
}
};
const
AdEventType
=
{
load
:
"
load
"
,
close
:
"
close
"
,
error
:
"
error
"
};
var
AdDraw
=
defineComponent
({
name
:
"
AdDraw
"
,
props
:
adDrawProps
,
emits
:
[
AdEventType
.
load
,
AdEventType
.
close
,
AdEventType
.
error
],
setup
(
props2
,
{
emit
})
{
const
adRef
=
ref
(
null
);
const
trigger
=
useCustomEvent$1
(
adRef
,
emit
);
const
state
=
useAdDrawState
();
watch
(()
=>
props2
.
adpid
,
(
value
)
=>
{
_loadAdData
(
state
,
props2
,
trigger
);
});
watch
(()
=>
props2
.
data
,
(
value
)
=>
{
state
.
data
=
value
;
});
const
listeners
=
{
onDislike
(
e2
)
{
trigger
(
AdEventType
.
close
,
e2
);
}
};
onMounted
(()
=>
{
setTimeout
(()
=>
{
getComponentSize
(
adRef
.
value
).
then
(({
width
,
height
})
=>
{
state
.
width
=
width
===
0
?
-
1
:
width
;
state
.
height
=
height
===
0
?
-
1
:
height
;
_loadAdData
(
state
,
props2
,
trigger
);
});
},
50
);
});
return
()
=>
{
const
{
data
}
=
state
;
return
createVNode
(
"
u-ad-draw
"
,
mergeProps
({
"
ref
"
:
adRef
},
{
data
,
rendering
:
true
},
listeners
),
null
);
};
}
});
function
useAdDrawState
(
props2
)
{
const
data
=
ref
(
""
);
const
state
=
reactive
({
width
:
0
,
height
:
0
,
data
});
return
state
;
}
function
_loadAdData
(
state
,
props2
,
trigger
)
{
getAdData
(
props2
.
adpid
,
state
.
width
,
state
.
height
,
(
res
)
=>
{
state
.
data
=
res
;
trigger
(
AdEventType
.
load
,
{});
},
(
err
)
=>
{
trigger
(
AdEventType
.
error
,
err
);
});
}
var
components
=
{
Navigator
,
Label
,
...
...
@@ -4427,6 +4673,8 @@ var components = {
Icon
,
Swiper
,
SwiperItem
,
RichText
RichText
,
Ad
,
AdDraw
};
export
{
components
as
default
};
packages/uni-components/src/components/ad-draw.ts
浏览文件 @
077ed287
...
...
@@ -15,7 +15,8 @@ export function getAdData(
}
// TODO 缺少语法提示 getDrawAds
plus
.
ad
.
getAds
(
// @ts-ignore
plus
.
ad
.
getDrawAds
(
{
adpid
:
String
(
adpid
),
count
:
3
,
...
...
packages/uni-components/src/components/checkbox-group.ts
浏览文件 @
077ed287
import
{
ComputedRef
,
ExtractPropTypes
}
from
'
vue
'
import
{
PolySymbol
}
from
'
@dcloudio/uni-core
'
export
const
uniCheckGroupKey
=
PolySymbol
(
__DEV__
?
'
uniCheckGroup
'
:
'
ucg
'
)
export
type
UniCheckGroupFieldCtx
=
ComputedRef
<
{
checkboxChecked
:
boolean
value
:
string
}
>
export
interface
UniCheckGroupCtx
{
addField
:
(
field
:
UniCheckGroupFieldCtx
)
=>
void
removeField
:
(
field
:
UniCheckGroupFieldCtx
)
=>
void
checkboxChange
:
(
$event
:
Event
)
=>
void
}
export
const
checkboxGroupProps
=
{
name
:
{
type
:
String
,
default
:
''
,
},
}
export
type
CheckBoxGroupProps
=
ExtractPropTypes
<
typeof
checkboxGroupProps
>
packages/uni-components/src/nvue/ad-draw/index.tsx
浏览文件 @
077ed287
...
...
@@ -49,7 +49,7 @@ export default defineComponent({
)
const
listeners
=
{
d
islike
(
e
:
Event
)
{
onD
islike
(
e
:
Event
)
{
trigger
(
AdEventType
.
close
,
e
)
},
}
...
...
@@ -68,7 +68,7 @@ export default defineComponent({
const
{
data
}
=
state
return
(
<
u
-
ad
-
draw
ref
=
"ad"
ref
=
{
adRef
}
{
...{
data
,
rendering
:
true
}
}
{
...
listeners
}
></
u
-
ad
-
draw
>
...
...
@@ -97,7 +97,7 @@ function _loadAdData(
state
.
width
,
state
.
height
,
(
res
:
any
)
=>
{
state
.
data
=
res
.
data
state
.
data
=
res
trigger
(
AdEventType
.
load
,
{})
},
(
err
:
any
)
=>
{
...
...
packages/uni-components/src/nvue/ad/index.tsx
浏览文件 @
077ed287
...
...
@@ -64,17 +64,22 @@ export default defineComponent({
})
const
listeners
=
{
d
ownloadchange
(
e
:
Event
)
{
onD
ownloadchange
(
e
:
Event
)
{
trigger
(
AdEventType
.
downloadchange
,
e
)
},
d
islike
(
e
:
Event
)
{
onD
islike
(
e
:
Event
)
{
trigger
(
AdEventType
.
close
,
e
)
},
}
return
()
=>
{
const
{
data
}
=
state
return
<
u
-
ad
ref
=
"ad"
{
...{
data
,
rendering
:
true
}
}
{
...
listeners
}
/>
return
(
<
u
-
ad
ref
=
{
adRef
}
{
...{
data
:
state
.
data
,
rendering
:
true
}
}
{
...
listeners
}
/>
)
}
},
})
...
...
@@ -99,7 +104,7 @@ function _loadAdData(
width
:
state
.
width
,
},
(
res
:
any
)
=>
{
state
.
data
=
res
.
data
state
.
data
=
res
trigger
(
AdEventType
.
load
,
{})
},
(
err
:
any
)
=>
{
...
...
packages/uni-components/src/nvue/checkbox-group/index.tsx
浏览文件 @
077ed287
import
{
defineComponent
,
inject
,
provide
,
ComputedRef
,
ref
,
ExtractPropTypes
,
}
from
'
vue
'
import
{
uniCheckGroupKey
}
from
'
../../components/checkbox-group
'
import
{
UniFormCtx
,
uniFormKey
}
from
'
../../components/form
'
import
{
defineComponent
,
inject
,
provide
,
ref
}
from
'
vue
'
import
{
CustomEventTrigger
,
useCustomEvent
,
EmitEvent
,
}
from
'
../../helpers/useEvent
'
type
UniCheckGroupFieldCtx
=
ComputedRef
<
{
checkboxChecked
:
boolean
value
:
string
}
>
const
props
=
{
name
:
{
type
:
String
,
default
:
''
,
},
}
type
CheckBoxGroupProps
=
ExtractPropTypes
<
typeof
props
>
export
interface
UniCheckGroupCtx
{
addField
:
(
field
:
UniCheckGroupFieldCtx
)
=>
void
removeField
:
(
field
:
UniCheckGroupFieldCtx
)
=>
void
checkboxChange
:
(
$event
:
Event
)
=>
void
}
}
from
'
../../helpers/useNVueEvent
'
import
{
uniCheckGroupKey
,
UniCheckGroupCtx
,
UniCheckGroupFieldCtx
,
CheckBoxGroupProps
,
checkboxGroupProps
,
}
from
'
../../components/checkbox-group
'
import
{
UniFormCtx
,
uniFormKey
}
from
'
../../components/form
'
export
default
defineComponent
({
name
:
'
CheckboxGroup
'
,
props
,
props
:
checkboxGroupProps
,
emits
:
[
'
change
'
],
setup
(
props
,
{
slots
,
emit
})
{
const
rootRef
=
ref
<
HTMLElement
|
null
>
(
null
)
...
...
@@ -76,7 +55,7 @@ function useProvideCheckGroup(
fields
.
splice
(
fields
.
indexOf
(
field
),
1
)
},
checkboxChange
(
$event
)
{
trigger
(
'
change
'
,
$event
,
{
trigger
(
'
change
'
,
{
value
:
getFieldsValue
(),
})
},
...
...
packages/uni-components/src/nvue/checkbox/index.tsx
浏览文件 @
077ed287
...
...
@@ -2,14 +2,20 @@ import {
defineComponent
,
inject
,
onBeforeUnmount
,
Ref
,
ref
,
computed
,
watch
,
}
from
'
vue
'
import
{
uniLabelKey
,
UniLabelCtx
}
from
'
../label
'
import
{
useListeners
}
from
'
../../helpers/useListeners
'
import
{
NVueComponentStyles
,
createNVueTextVNode
}
from
'
../utils
'
import
{
checkboxProps
}
from
'
../../components/checkbox
'
import
{
uniCheckGroupKey
,
UniCheckGroupCtx
,
}
from
'
../../components/checkbox-group
'
import
{
UniFormCtx
,
uniFormKey
}
from
'
../../components/form
'
import
{
uniLabelKey
,
UniLabelCtx
}
from
'
../label
'
const
checkboxStyles
:
NVueComponentStyles
=
[
{
...
...
@@ -69,7 +75,16 @@ export default defineComponent({
const
rootRef
=
ref
<
HTMLElement
|
null
>
(
null
)
const
checkboxChecked
=
ref
(
props
.
checked
)
const
checkboxValue
=
ref
(
props
.
value
)
const
onClick
=
(
e
:
Event
,
isLabelClick
?:
boolean
)
=>
{
const
checkboxColor
=
computed
(()
=>
props
.
disabled
?
'
#adadad
'
:
props
.
color
)
const
reset
=
()
=>
{
checkboxChecked
.
value
=
false
}
const
_onClick
=
(
$event
:
Event
,
isLabelClick
?:
boolean
)
=>
{
if
(
props
.
disabled
)
{
return
}
...
...
@@ -77,12 +92,23 @@ export default defineComponent({
rootRef
.
value
!
.
click
()
}
checkboxChecked
.
value
=
!
checkboxChecked
.
value
uniCheckGroup
&&
uniCheckGroup
.
checkboxChange
(
$event
)
}
const
checkboxColor
=
computed
(()
=>
props
.
disabled
?
'
#adadad
'
:
props
.
color
const
{
uniCheckGroup
,
uniLabel
}
=
useCheckboxInject
(
checkboxChecked
,
checkboxValue
,
reset
)
if
(
uniLabel
)
{
uniLabel
.
addHandler
(
_onClick
)
onBeforeUnmount
(()
=>
{
uniLabel
.
removeHandler
(
_onClick
)
})
}
useListeners
(
props
,
{
'
label-click
'
:
_onClick
})
watch
(
[()
=>
props
.
checked
,
()
=>
props
.
value
],
([
newChecked
,
newModelValue
])
=>
{
...
...
@@ -91,18 +117,6 @@ export default defineComponent({
}
)
const
uniLabel
=
inject
<
UniLabelCtx
>
(
uniLabelKey
,
false
as
unknown
as
UniLabelCtx
)
if
(
uniLabel
)
{
uniLabel
.
addHandler
(
onClick
)
onBeforeUnmount
(()
=>
{
uniLabel
.
removeHandler
(
onClick
)
})
}
useListeners
(
props
,
{
'
label-click
'
:
onClick
})
const
wrapSlots
=
()
=>
{
if
(
!
slots
.
default
)
return
[]
const
vnodes
=
slots
.
default
()
...
...
@@ -121,7 +135,7 @@ export default defineComponent({
<
div
ref
=
{
rootRef
}
{
...{
dataUncType
:
'
uni-checkbox
'
}
}
onClick
=
{
onClick
}
onClick
=
{
_
onClick
}
class
=
"uni-checkbox"
>
<
div
...
...
@@ -144,3 +158,44 @@ export default defineComponent({
}
},
})
function
useCheckboxInject
(
checkboxChecked
:
Ref
<
string
|
boolean
>
,
checkboxValue
:
Ref
<
string
>
,
reset
:
()
=>
void
)
{
const
field
=
computed
(()
=>
({
checkboxChecked
:
Boolean
(
checkboxChecked
.
value
),
value
:
checkboxValue
.
value
,
}))
const
formField
=
{
reset
}
const
uniCheckGroup
=
inject
<
UniCheckGroupCtx
>
(
uniCheckGroupKey
,
false
as
unknown
as
UniCheckGroupCtx
)
if
(
!!
uniCheckGroup
)
{
uniCheckGroup
.
addField
(
field
)
}
const
uniForm
=
inject
<
UniFormCtx
>
(
uniFormKey
,
false
as
unknown
as
UniFormCtx
)
if
(
!!
uniForm
)
{
uniForm
.
addField
(
formField
)
}
const
uniLabel
=
inject
<
UniLabelCtx
>
(
uniLabelKey
,
false
as
unknown
as
UniLabelCtx
)
onBeforeUnmount
(()
=>
{
uniCheckGroup
&&
uniCheckGroup
.
removeField
(
field
)
uniForm
&&
uniForm
.
removeField
(
formField
)
})
return
{
uniCheckGroup
,
uniForm
,
uniLabel
,
}
}
packages/uni-components/src/nvue/components.ts
浏览文件 @
077ed287
...
...
@@ -18,6 +18,8 @@ import Icon from './icon'
import
Swiper
from
'
./swiper
'
import
SwiperItem
from
'
./swiper-item
'
import
RichText
from
'
./rich-text
'
import
Ad
from
'
./ad
'
import
AdDraw
from
'
./ad-draw
'
export
default
{
Navigator
,
Label
,
...
...
@@ -39,4 +41,6 @@ export default {
Swiper
,
SwiperItem
,
RichText
,
Ad
,
AdDraw
,
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录