@sheinx/hooks 3.8.0-beta.33 → 3.8.0-beta.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-check.d.ts","sourceRoot":"","sources":["use-check.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;
|
1
|
+
{"version":3,"file":"use-check.d.ts","sourceRoot":"","sources":["use-check.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;qBAgEpB,gBAAgB,CAAC,gBAAgB,CAAC;0BArBT,MAAM,WAAW,CAAC,gBAAgB,CAAC;;;;;;;;;;;yBA5Ba,gBAAgB;;;;CA0E3G,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
@@ -46,11 +46,19 @@ var useCheck = function useCheck(props) {
|
|
46
46
|
var handleInputRef = (0, _useForkRef.default)(inputRef, inputRefPo);
|
47
47
|
var handleClick = function handleClick(otherHandlers, needStopPropagation) {
|
48
48
|
return function (event) {
|
49
|
-
var
|
49
|
+
var _otherHandlers$onClic;
|
50
50
|
if (needStopPropagation) {
|
51
51
|
event.stopPropagation();
|
52
52
|
}
|
53
|
-
|
53
|
+
|
54
|
+
// 检查是否被 label 元素包裹,如果是则不需要手动触发 input.click()
|
55
|
+
// 因为 label 会自动将点击事件传递给内部的 input 元素
|
56
|
+
var target = event.currentTarget;
|
57
|
+
var isInsideLabel = target.closest('label') !== null;
|
58
|
+
if (!isInsideLabel) {
|
59
|
+
var _inputRef$current;
|
60
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.click();
|
61
|
+
}
|
54
62
|
otherHandlers === null || otherHandlers === void 0 || (_otherHandlers$onClic = otherHandlers.onClick) === null || _otherHandlers$onClic === void 0 || _otherHandlers$onClic.call(otherHandlers, event);
|
55
63
|
};
|
56
64
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-check.d.ts","sourceRoot":"","sources":["use-check.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;
|
1
|
+
{"version":3,"file":"use-check.d.ts","sourceRoot":"","sources":["use-check.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;qBAgEpB,gBAAgB,CAAC,gBAAgB,CAAC;0BArBT,MAAM,WAAW,CAAC,gBAAgB,CAAC;;;;;;;;;;;yBA5Ba,gBAAgB;;;;CA0E3G,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
@@ -40,11 +40,19 @@ var useCheck = function useCheck(props) {
|
|
40
40
|
var handleInputRef = useForkRef(inputRef, inputRefPo);
|
41
41
|
var handleClick = function handleClick(otherHandlers, needStopPropagation) {
|
42
42
|
return function (event) {
|
43
|
-
var
|
43
|
+
var _otherHandlers$onClic;
|
44
44
|
if (needStopPropagation) {
|
45
45
|
event.stopPropagation();
|
46
46
|
}
|
47
|
-
|
47
|
+
|
48
|
+
// 检查是否被 label 元素包裹,如果是则不需要手动触发 input.click()
|
49
|
+
// 因为 label 会自动将点击事件传递给内部的 input 元素
|
50
|
+
var target = event.currentTarget;
|
51
|
+
var isInsideLabel = target.closest('label') !== null;
|
52
|
+
if (!isInsideLabel) {
|
53
|
+
var _inputRef$current;
|
54
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.click();
|
55
|
+
}
|
48
56
|
otherHandlers === null || otherHandlers === void 0 || (_otherHandlers$onClic = otherHandlers.onClick) === null || _otherHandlers$onClic === void 0 || _otherHandlers$onClic.call(otherHandlers, event);
|
49
57
|
};
|
50
58
|
};
|