Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yangkaifeng
uni-app
提交
0d502d80
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,发现更多精彩内容 >>
提交
0d502d80
编写于
5月 20, 2021
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: button loading 、 disabled
上级
23dc9bdc
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
178 addition
and
218 deletion
+178
-218
packages/uni-components/src/components/button/index.tsx
packages/uni-components/src/components/button/index.tsx
+13
-25
packages/uni-components/src/helpers/useEvent.ts
packages/uni-components/src/helpers/useEvent.ts
+1
-1
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+73
-87
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+91
-105
未找到文件。
packages/uni-components/src/components/button/index.tsx
浏览文件 @
0d502d80
...
...
@@ -3,13 +3,12 @@ import { useI18n, initI18nButtonMsgsOnce } from '@dcloudio/uni-core'
import
{
defineBuiltInComponent
}
from
'
../../helpers/component
'
import
{
useHover
}
from
'
../../helpers/useHover
'
import
{
useBooleanAttr
}
from
'
../../helpers/useBooleanAttr
'
import
{
withWebEvent
}
from
'
../../helpers/useEvent
'
import
{
UniFormCtx
,
uniFormKey
}
from
'
../form
'
import
{
uniLabelKey
,
UniLabelCtx
}
from
'
../label
'
import
{
useListeners
}
from
'
../../helpers/useListeners
'
import
{
useAttrs
}
from
'
../../helpers/useAttrs
'
export
default
/*#__PURE__*/
defineBuiltInComponent
({
inheritAttrs
:
false
,
name
:
'
Button
'
,
props
:
{
id
:
{
...
...
@@ -44,8 +43,12 @@ export default /*#__PURE__*/ defineBuiltInComponent({
type
:
String
,
default
:
''
,
},
loading
:
{
type
:
[
Boolean
,
String
],
default
:
false
,
},
},
setup
(
props
,
{
slots
,
emit
})
{
setup
(
props
,
{
slots
})
{
const
rootRef
=
ref
<
HTMLElement
|
null
>
(
null
)
if
(
__PLATFORM__
===
'
app
'
)
{
initI18nButtonMsgsOnce
()
...
...
@@ -56,9 +59,9 @@ export default /*#__PURE__*/ defineBuiltInComponent({
)
const
{
hovering
,
binding
}
=
useHover
(
props
)
const
{
t
}
=
useI18n
()
const
onClick
=
(
e
:
Event
,
isLabelClick
:
boolean
)
=>
{
const
onClick
=
withWebEvent
(
(
e
:
Event
,
isLabelClick
:
boolean
)
=>
{
if
(
props
.
disabled
)
{
return
return
e
.
stopImmediatePropagation
()
}
if
(
isLabelClick
)
{
rootRef
.
value
!
.
click
()
...
...
@@ -81,13 +84,13 @@ export default /*#__PURE__*/ defineBuiltInComponent({
t
(
'
uni.button.feedback.send
'
)
)
}
}
}
)
const
uniLabel
=
inject
<
UniLabelCtx
>
(
uniLabelKey
,
false
as
unknown
as
UniLabelCtx
)
if
(
!!
uniLabel
)
{
if
(
uniLabel
)
{
uniLabel
.
addHandler
(
onClick
)
onBeforeUnmount
(()
=>
{
uniLabel
.
removeHandler
(
onClick
)
...
...
@@ -95,23 +98,10 @@ export default /*#__PURE__*/ defineBuiltInComponent({
}
useListeners
(
props
,
{
'
label-click
'
:
onClick
})
const
{
$listeners
,
$attrs
,
$excludeAttrs
}
=
useAttrs
({
excludeListeners
:
true
,
})
const
_listeners
=
Object
.
create
(
null
)
let
events
=
[
'
onClick
'
,
'
onTap
'
]
if
(
$listeners
.
value
)
{
Object
.
keys
(
$listeners
.
value
).
forEach
((
e
)
=>
{
if
(
props
.
disabled
&&
events
.
includes
(
e
))
{
return
}
_listeners
[
e
]
=
(
$listeners
.
value
as
any
)[
e
]
})
}
return
()
=>
{
const
hoverClass
=
props
.
hoverClass
const
booleanAttrs
=
useBooleanAttr
(
props
,
'
disabled
'
)
const
loadingAttrs
=
useBooleanAttr
(
props
,
'
loading
'
)
const
hasHoverClass
=
hoverClass
&&
hoverClass
!==
'
none
'
return
(
...
...
@@ -121,9 +111,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({
class
=
{
hasHoverClass
&&
hovering
.
value
?
hoverClass
:
''
}
{
...(
hasHoverClass
&&
binding
)
}
{
...
booleanAttrs
}
{
...
_listeners
}
{
...
$attrs
.
value
}
{
...
$excludeAttrs
.
value
}
{
...
loadingAttrs
}
>
{
slots
.
default
&&
slots
.
default
()
}
</
uni
-
button
>
...
...
@@ -151,7 +139,7 @@ function openFeedback(titleText: string, sendText: string) {
fontWeight
:
'
bold
'
,
onclick
:
function
()
{
feedback
.
evalJS
(
'
mui&&
mui.trigger(document.getElementById("submit"),"tap")
'
'
typeof mui !== "undefined" &&
mui.trigger(document.getElementById("submit"),"tap")
'
)
},
},
...
...
packages/uni-components/src/helpers/useEvent.ts
浏览文件 @
0d502d80
...
...
@@ -7,7 +7,7 @@ export type CustomEventTrigger = ReturnType<typeof useCustomEvent>
export
type
NativeEventTrigger
=
ReturnType
<
typeof
useNativeEvent
>
export
type
EmitEvent
<
E
extends
(...
args
:
any
)
=>
any
>
=
[
Parameters
<
E
>
[
0
]]
export
function
withWebEvent
(
fn
:
(
e
:
any
)
=>
any
)
{
export
function
withWebEvent
(
fn
:
(
...
args
:
any
[]
)
=>
any
)
{
return
((
fn
as
any
).
__wwe
=
true
),
fn
}
...
...
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
0d502d80
...
...
@@ -1131,6 +1131,31 @@ function useBooleanAttr(props2, keys) {
return
res
;
},
Object
.
create
(
null
));
}
function
withWebEvent
(
fn
)
{
return
fn
.
__wwe
=
true
,
fn
;
}
function
useCustomEvent
(
ref
,
emit2
)
{
return
(
name
,
evt
,
detail
)
=>
{
if
(
ref
.
value
)
{
emit2
(
name
,
normalizeCustomEvent
(
name
,
evt
,
ref
.
value
,
detail
||
{}));
}
};
}
function
useNativeEvent
(
emit2
)
{
return
(
name
,
evt
)
=>
{
emit2
(
name
,
createNativeEvent
(
evt
));
};
}
function
normalizeCustomEvent
(
name
,
domEvt
,
el
,
detail
)
{
const
target
=
uniShared
.
normalizeTarget
(
el
);
return
{
type
:
detail
.
type
||
name
,
timeStamp
:
domEvt
.
timeStamp
||
0
,
target
,
currentTarget
:
target
,
detail
};
}
const
uniFormKey
=
PolySymbol
(
process
.
env
.
NODE_ENV
!==
"
production
"
?
"
uniForm
"
:
"
uf
"
);
var
index$r
=
/* @__PURE__ */
defineBuiltInComponent
({
name
:
"
Form
"
,
...
...
@@ -1171,31 +1196,6 @@ function provideForm(emit2) {
});
return
fields2
;
}
function
withWebEvent
(
fn
)
{
return
fn
.
__wwe
=
true
,
fn
;
}
function
useCustomEvent
(
ref
,
emit2
)
{
return
(
name
,
evt
,
detail
)
=>
{
if
(
ref
.
value
)
{
emit2
(
name
,
normalizeCustomEvent
(
name
,
evt
,
ref
.
value
,
detail
||
{}));
}
};
}
function
useNativeEvent
(
emit2
)
{
return
(
name
,
evt
)
=>
{
emit2
(
name
,
createNativeEvent
(
evt
));
};
}
function
normalizeCustomEvent
(
name
,
domEvt
,
el
,
detail
)
{
const
target
=
uniShared
.
normalizeTarget
(
el
);
return
{
type
:
detail
.
type
||
name
,
timeStamp
:
domEvt
.
timeStamp
||
0
,
target
,
currentTarget
:
target
,
detail
};
}
const
uniLabelKey
=
PolySymbol
(
process
.
env
.
NODE_ENV
!==
"
production
"
?
"
uniLabel
"
:
"
ul
"
);
const
props$p
=
{
for
:
{
...
...
@@ -1247,45 +1247,7 @@ function useProvideLabel() {
});
return
handlers
;
}
function
entries
(
obj
)
{
return
Object
.
keys
(
obj
).
map
((
key
)
=>
[
key
,
obj
[
key
]]);
}
const
DEFAULT_EXCLUDE_KEYS
=
[
"
class
"
,
"
style
"
];
const
LISTENER_PREFIX
=
/^on
[
A-Z
]
+/
;
const
useAttrs
=
(
params
=
{})
=>
{
const
{
excludeListeners
=
false
,
excludeKeys
=
[]}
=
params
;
const
instance
=
vue
.
getCurrentInstance
();
const
attrs
=
vue
.
shallowRef
({});
const
listeners
=
vue
.
shallowRef
({});
const
excludeAttrs
=
vue
.
shallowRef
({});
const
allExcludeKeys
=
excludeKeys
.
concat
(
DEFAULT_EXCLUDE_KEYS
);
instance
.
attrs
=
vue
.
reactive
(
instance
.
attrs
);
vue
.
watchEffect
(()
=>
{
const
res
=
entries
(
instance
.
attrs
).
reduce
((
acc
,
[
key
,
val
])
=>
{
if
(
allExcludeKeys
.
includes
(
key
))
{
acc
.
exclude
[
key
]
=
val
;
}
else
if
(
LISTENER_PREFIX
.
test
(
key
))
{
if
(
!
excludeListeners
)
{
acc
.
attrs
[
key
]
=
val
;
}
acc
.
listeners
[
key
]
=
val
;
}
else
{
acc
.
attrs
[
key
]
=
val
;
}
return
acc
;
},
{
exclude
:
{},
attrs
:
{},
listeners
:
{}
});
attrs
.
value
=
res
.
attrs
;
listeners
.
value
=
res
.
listeners
;
excludeAttrs
.
value
=
res
.
exclude
;
});
return
{
$attrs
:
attrs
,
$listeners
:
listeners
,
$excludeAttrs
:
excludeAttrs
};
};
var
index$p
=
/* @__PURE__ */
defineBuiltInComponent
({
inheritAttrs
:
false
,
name
:
"
Button
"
,
props
:
{
id
:
{
...
...
@@ -1319,11 +1281,14 @@ var index$p = /* @__PURE__ */ defineBuiltInComponent({
openType
:
{
type
:
String
,
default
:
""
},
loading
:
{
type
:
[
Boolean
,
String
],
default
:
false
}
},
setup
(
props2
,
{
slots
,
emit
:
emit2
slots
})
{
const
rootRef
=
vue
.
ref
(
null
);
const
uniForm
=
vue
.
inject
(
uniFormKey
,
false
);
...
...
@@ -1332,9 +1297,9 @@ var index$p = /* @__PURE__ */ defineBuiltInComponent({
binding
}
=
useHover
(
props2
);
useI18n
();
const
onClick
=
(
e2
,
isLabelClick
)
=>
{
const
onClick
=
withWebEvent
(
(
e2
,
isLabelClick
)
=>
{
if
(
props2
.
disabled
)
{
return
;
return
e2
.
stopImmediatePropagation
()
;
}
if
(
isLabelClick
)
{
rootRef
.
value
.
click
();
...
...
@@ -1351,37 +1316,21 @@ var index$p = /* @__PURE__ */ defineBuiltInComponent({
}
return
;
}
};
}
)
;
const
uniLabel
=
vue
.
inject
(
uniLabelKey
,
false
);
if
(
!!
uniLabel
)
{
if
(
uniLabel
)
{
uniLabel
.
addHandler
(
onClick
);
}
const
{
$listeners
,
$attrs
,
$excludeAttrs
}
=
useAttrs
({
excludeListeners
:
true
});
const
_listeners
=
Object
.
create
(
null
);
let
events
=
[
"
onClick
"
,
"
onTap
"
];
if
(
$listeners
.
value
)
{
Object
.
keys
(
$listeners
.
value
).
forEach
((
e2
)
=>
{
if
(
props2
.
disabled
&&
events
.
includes
(
e2
))
{
return
;
}
_listeners
[
e2
]
=
$listeners
.
value
[
e2
];
});
}
return
()
=>
{
const
hoverClass
=
props2
.
hoverClass
;
const
booleanAttrs
=
useBooleanAttr
(
props2
,
"
disabled
"
);
const
loadingAttrs
=
useBooleanAttr
(
props2
,
"
loading
"
);
const
hasHoverClass
=
hoverClass
&&
hoverClass
!==
"
none
"
;
return
vue
.
createVNode
(
"
uni-button
"
,
vue
.
mergeProps
({
"
ref
"
:
rootRef
,
"
onClick
"
:
onClick
,
"
class
"
:
hasHoverClass
&&
hovering
.
value
?
hoverClass
:
""
},
hasHoverClass
&&
binding
,
booleanAttrs
,
_listeners
,
$attrs
.
value
,
$excludeAttrs
.
value
),
[
slots
.
default
&&
slots
.
default
()],
16
,
[
"
onClick
"
]);
},
hasHoverClass
&&
binding
,
booleanAttrs
,
loadingAttrs
),
[
slots
.
default
&&
slots
.
default
()],
16
,
[
"
onClick
"
]);
};
}
});
...
...
@@ -3054,6 +3003,43 @@ var Input = /* @__PURE__ */ defineBuiltInComponent({
};
}
});
function
entries
(
obj
)
{
return
Object
.
keys
(
obj
).
map
((
key
)
=>
[
key
,
obj
[
key
]]);
}
const
DEFAULT_EXCLUDE_KEYS
=
[
"
class
"
,
"
style
"
];
const
LISTENER_PREFIX
=
/^on
[
A-Z
]
+/
;
const
useAttrs
=
(
params
=
{})
=>
{
const
{
excludeListeners
=
false
,
excludeKeys
=
[]}
=
params
;
const
instance
=
vue
.
getCurrentInstance
();
const
attrs
=
vue
.
shallowRef
({});
const
listeners
=
vue
.
shallowRef
({});
const
excludeAttrs
=
vue
.
shallowRef
({});
const
allExcludeKeys
=
excludeKeys
.
concat
(
DEFAULT_EXCLUDE_KEYS
);
instance
.
attrs
=
vue
.
reactive
(
instance
.
attrs
);
vue
.
watchEffect
(()
=>
{
const
res
=
entries
(
instance
.
attrs
).
reduce
((
acc
,
[
key
,
val
])
=>
{
if
(
allExcludeKeys
.
includes
(
key
))
{
acc
.
exclude
[
key
]
=
val
;
}
else
if
(
LISTENER_PREFIX
.
test
(
key
))
{
if
(
!
excludeListeners
)
{
acc
.
attrs
[
key
]
=
val
;
}
acc
.
listeners
[
key
]
=
val
;
}
else
{
acc
.
attrs
[
key
]
=
val
;
}
return
acc
;
},
{
exclude
:
{},
attrs
:
{},
listeners
:
{}
});
attrs
.
value
=
res
.
attrs
;
listeners
.
value
=
res
.
listeners
;
excludeAttrs
.
value
=
res
.
exclude
;
});
return
{
$attrs
:
attrs
,
$listeners
:
listeners
,
$excludeAttrs
:
excludeAttrs
};
};
function
initScrollBounce
()
{
}
function
disableScrollBounce
({
disable
})
{
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
0d502d80
import {isFunction, extend, hyphenate, isPlainObject, isString, isArray, hasOwn, isObject, capitalize, toRawType, makeMap as makeMap$1, isPromise, invokeArrayFns as invokeArrayFns$1} from "@vue/shared";
import {injectHook, withModifiers, createVNode, getCurrentInstance, inject, provide, reactive, openBlock, createBlock, mergeProps, toDisplayString, defineComponent, ref, computed, watch, onUnmounted,
shallowRef, watchEffect, onBeforeUnmount, onActivated, onMounted, nextTick, resolveComponent, toHandlers, renderSlot, onBeforeMount, withDirectives, vShow
, isVNode, Fragment, markRaw, createCommentVNode, createTextVNode, onBeforeActivate, onBeforeDeactivate, renderList, onDeactivated, Teleport, createApp, Transition, withCtx, KeepAlive, resolveDynamicComponent} from "vue";
import {injectHook, withModifiers, createVNode, getCurrentInstance, inject, provide, reactive, openBlock, createBlock, mergeProps, toDisplayString, defineComponent, ref, computed, watch, onUnmounted,
onBeforeUnmount, onActivated, onMounted, nextTick, resolveComponent, toHandlers, renderSlot, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect
, isVNode, Fragment, markRaw, createCommentVNode, createTextVNode, onBeforeActivate, onBeforeDeactivate, renderList, onDeactivated, Teleport, createApp, Transition, withCtx, KeepAlive, resolveDynamicComponent} from "vue";
import {once, passive, normalizeTarget, isBuiltInComponent, initCostomDataset, invokeArrayFns, NAVBAR_HEIGHT, parseQuery, PRIMARY_COLOR, debounce, getCostomDataset, callOptions, removeLeadingSlash, getLen, ON_REACH_BOTTOM_DISTANCE, decodedQuery, updateElementStyle, addFont, scrollTo, formatDateTime} from "@dcloudio/uni-shared";
import {initVueI18n, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT} from "@dcloudio/uni-i18n";
import {useRoute, createRouter, createWebHistory, createWebHashHistory, useRouter, isNavigationFailure, RouterView} from "vue-router";
...
...
@@ -594,7 +594,7 @@ var safeAreaInsets = {
onChange,
offChange
};
var out = safeAreaInsets;
var
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out = safeAreaInsets;
const onEventPrevent = /* @__PURE__ */ withModifiers(() => {
}, ["prevent"]);
const onEventStop = /* @__PURE__ */ withModifiers(() => {
...
...
@@ -606,10 +606,10 @@ function getWindowOffset() {
const left = parseInt(style.getPropertyValue("--window-left"));
const right = parseInt(style.getPropertyValue("--window-right"));
return {
top: top ? top + out.top : 0,
bottom: bottom ? bottom + out.bottom : 0,
left: left ? left + out.left : 0,
right: right ? right + out.right : 0
top: top ? top +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top : 0,
bottom: bottom ? bottom +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.bottom : 0,
left: left ? left +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.left : 0,
right: right ? right +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.right : 0
};
}
function updateCssVar(cssVars) {
...
...
@@ -1300,7 +1300,7 @@ function normalizePageMeta(pageMeta) {
let offset = rpx2px(refreshOptions.offset);
const {type} = navigationBar;
if (type !== "transparent" && type !== "none") {
offset += NAVBAR_HEIGHT + out.top;
offset += NAVBAR_HEIGHT +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top;
}
refreshOptions.offset = offset;
refreshOptions.height = rpx2px(refreshOptions.height);
...
...
@@ -2182,6 +2182,31 @@ function useBooleanAttr(props2, keys) {
return res;
}, Object.create(null));
}
function withWebEvent(fn) {
return fn.__wwe = true, fn;
}
function useCustomEvent(ref2, emit2) {
return (name, evt, detail) => {
if (ref2.value) {
emit2(name, normalizeCustomEvent(name, evt, ref2.value, detail || {}));
}
};
}
function useNativeEvent(emit2) {
return (name, evt) => {
emit2(name, createNativeEvent(evt));
};
}
function normalizeCustomEvent(name, domEvt, el, detail) {
const target = normalizeTarget(el);
return {
type: detail.type || name,
timeStamp: domEvt.timeStamp || 0,
target,
currentTarget: target,
detail
};
}
const uniFormKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniForm" : "uf");
var index$o = /* @__PURE__ */ defineBuiltInComponent({
name: "Form",
...
...
@@ -2222,31 +2247,6 @@ function provideForm(emit2) {
});
return fields2;
}
function withWebEvent(fn) {
return fn.__wwe = true, fn;
}
function useCustomEvent(ref2, emit2) {
return (name, evt, detail) => {
if (ref2.value) {
emit2(name, normalizeCustomEvent(name, evt, ref2.value, detail || {}));
}
};
}
function useNativeEvent(emit2) {
return (name, evt) => {
emit2(name, createNativeEvent(evt));
};
}
function normalizeCustomEvent(name, domEvt, el, detail) {
const target = normalizeTarget(el);
return {
type: detail.type || name,
timeStamp: domEvt.timeStamp || 0,
target,
currentTarget: target,
detail
};
}
const uniLabelKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniLabel" : "ul");
const props$w = {
for: {
...
...
@@ -2352,45 +2352,7 @@ function _removeListeners(id2, listeners, watch2) {
}
});
}
function entries(obj) {
return Object.keys(obj).map((key) => [key, obj[key]]);
}
const DEFAULT_EXCLUDE_KEYS = ["class", "style"];
const LISTENER_PREFIX = /^on[A-Z]+/;
const useAttrs = (params = {}) => {
const {excludeListeners = false, excludeKeys = []} = params;
const instance2 = getCurrentInstance();
const attrs2 = shallowRef({});
const listeners = shallowRef({});
const excludeAttrs = shallowRef({});
const allExcludeKeys = excludeKeys.concat(DEFAULT_EXCLUDE_KEYS);
instance2.attrs = reactive(instance2.attrs);
watchEffect(() => {
const res = entries(instance2.attrs).reduce((acc, [key, val]) => {
if (allExcludeKeys.includes(key)) {
acc.exclude[key] = val;
} else if (LISTENER_PREFIX.test(key)) {
if (!excludeListeners) {
acc.attrs[key] = val;
}
acc.listeners[key] = val;
} else {
acc.attrs[key] = val;
}
return acc;
}, {
exclude: {},
attrs: {},
listeners: {}
});
attrs2.value = res.attrs;
listeners.value = res.listeners;
excludeAttrs.value = res.exclude;
});
return {$attrs: attrs2, $listeners: listeners, $excludeAttrs: excludeAttrs};
};
var index$m = /* @__PURE__ */ defineBuiltInComponent({
inheritAttrs: false,
name: "Button",
props: {
id: {
...
...
@@ -2424,11 +2386,14 @@ var index$m = /* @__PURE__ */ defineBuiltInComponent({
openType: {
type: String,
default: ""
},
loading: {
type: [Boolean, String],
default: false
}
},
setup(props2, {
slots,
emit: emit2
slots
}) {
const rootRef = ref(null);
const uniForm = inject(uniFormKey, false);
...
...
@@ -2437,9 +2402,9 @@ var index$m = /* @__PURE__ */ defineBuiltInComponent({
binding
} = useHover(props2);
useI18n();
const onClick = (e2, isLabelClick) => {
const onClick =
withWebEvent(
(e2, isLabelClick) => {
if (props2.disabled) {
return;
return
e2.stopImmediatePropagation()
;
}
if (isLabelClick) {
rootRef.value.click();
...
...
@@ -2456,9 +2421,9 @@ var index$m = /* @__PURE__ */ defineBuiltInComponent({
}
return;
}
};
}
)
;
const uniLabel = inject(uniLabelKey, false);
if (
!!
uniLabel) {
if (uniLabel) {
uniLabel.addHandler(onClick);
onBeforeUnmount(() => {
uniLabel.removeHandler(onClick);
...
...
@@ -2467,32 +2432,16 @@ var index$m = /* @__PURE__ */ defineBuiltInComponent({
useListeners(props2, {
"label-click": onClick
});
const {
$listeners,
$attrs,
$excludeAttrs
} = useAttrs({
excludeListeners: true
});
const _listeners = Object.create(null);
let events = ["onClick", "onTap"];
if ($listeners.value) {
Object.keys($listeners.value).forEach((e2) => {
if (props2.disabled && events.includes(e2)) {
return;
}
_listeners[e2] = $listeners.value[e2];
});
}
return () => {
const hoverClass = props2.hoverClass;
const booleanAttrs = useBooleanAttr(props2, "disabled");
const loadingAttrs = useBooleanAttr(props2, "loading");
const hasHoverClass = hoverClass && hoverClass !== "none";
return createVNode("uni-button", mergeProps({
"ref": rootRef,
"onClick": onClick,
"class": hasHoverClass && hovering.value ? hoverClass : ""
}, hasHoverClass && binding, booleanAttrs,
_listeners, $attrs.value, $excludeAttrs.value
), [slots.default && slots.default()], 16, ["onClick"]);
}, hasHoverClass && binding, booleanAttrs,
loadingAttrs
), [slots.default && slots.default()], 16, ["onClick"]);
};
}
});
...
...
@@ -4937,6 +4886,43 @@ var Input = /* @__PURE__ */ defineBuiltInComponent({
};
}
});
function entries(obj) {
return Object.keys(obj).map((key) => [key, obj[key]]);
}
const DEFAULT_EXCLUDE_KEYS = ["class", "style"];
const LISTENER_PREFIX = /^on[A-Z]+/;
const useAttrs = (params = {}) => {
const {excludeListeners = false, excludeKeys = []} = params;
const instance2 = getCurrentInstance();
const attrs2 = shallowRef({});
const listeners = shallowRef({});
const excludeAttrs = shallowRef({});
const allExcludeKeys = excludeKeys.concat(DEFAULT_EXCLUDE_KEYS);
instance2.attrs = reactive(instance2.attrs);
watchEffect(() => {
const res = entries(instance2.attrs).reduce((acc, [key, val]) => {
if (allExcludeKeys.includes(key)) {
acc.exclude[key] = val;
} else if (LISTENER_PREFIX.test(key)) {
if (!excludeListeners) {
acc.attrs[key] = val;
}
acc.listeners[key] = val;
} else {
acc.attrs[key] = val;
}
return acc;
}, {
exclude: {},
attrs: {},
listeners: {}
});
attrs2.value = res.attrs;
listeners.value = res.listeners;
excludeAttrs.value = res.exclude;
});
return {$attrs: attrs2, $listeners: listeners, $excludeAttrs: excludeAttrs};
};
function initScrollBounce() {
}
function disableScrollBounce({disable}) {
...
...
@@ -14928,7 +14914,7 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
const windowWidth = getWindowWidth(screenWidth);
let windowHeight = window.innerHeight;
const language = navigator.language;
const statusBarHeight = out.top;
const statusBarHeight =
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top;
let osname;
let osversion;
let model;
...
...
@@ -15041,12 +15027,12 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
const system = `${osname} ${osversion}`;
const platform = osname.toLocaleLowerCase();
const safeArea = {
left: out.left,
right: windowWidth - out.right,
top: out.top,
bottom: windowHeight - out.bottom,
width: windowWidth -
out.left -
out.right,
height: windowHeight -
out.top -
out.bottom
left:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.left,
right: windowWidth -
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.right,
top:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top,
bottom: windowHeight -
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.bottom,
width: windowWidth -
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.right,
height: windowHeight -
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.bottom
};
const {top: windowTop, bottom: windowBottom} = getWindowOffset();
windowHeight -= windowTop;
...
...
@@ -15066,10 +15052,10 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
model,
safeArea,
safeAreaInsets: {
top: out.top,
right: out.right,
bottom: out.bottom,
left: out.left
top:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top,
right:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.right,
bottom:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.bottom,
left:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.left
}
};
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录