@sheinx/hooks 3.8.4-beta.6 → 3.8.4-beta.8
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.
- package/cjs/common/use-position-style/index.d.ts +1 -0
- package/cjs/common/use-position-style/index.d.ts.map +1 -1
- package/cjs/common/use-position-style/index.js +44 -5
- package/cjs/components/use-popup/use-popup.d.ts.map +1 -1
- package/cjs/components/use-popup/use-popup.js +8 -0
- package/esm/common/use-position-style/index.d.ts +1 -0
- package/esm/common/use-position-style/index.d.ts.map +1 -1
- package/esm/common/use-position-style/index.js +44 -5
- package/esm/components/use-popup/use-popup.d.ts.map +1 -1
- package/esm/components/use-popup/use-popup.js +8 -0
- package/package.json +1 -1
@@ -15,6 +15,7 @@ export interface PositionStyleConfig {
|
|
15
15
|
fixedWidth?: boolean | 'min';
|
16
16
|
updateKey?: number | string;
|
17
17
|
adjust?: boolean;
|
18
|
+
onAdjust?: (position: HorizontalPosition | VerticalPosition) => void;
|
18
19
|
offset?: [number, number];
|
19
20
|
}
|
20
21
|
export declare const usePositionStyle: (config: PositionStyleConfig) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAUpE,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,UAAU,GACV,cAAc,GACd,WAAW,GACX,MAAM,GACN,OAAO,CAAC;AACZ,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,cAAc,GACd,UAAU,GACV,WAAW,GACX,KAAK,GACL,QAAQ,CAAC;AAYb,KAAK,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,OAAO,CAAC;AACpE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IAEd,WAAW,E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W,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,GAAG,gBAAgB,KAAK,IAAI,CAAC;IACrE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3B;AAsBD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;CAsV3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
@@ -108,10 +108,43 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
108
108
|
setPopupElWidth(popupElRef.current.getBoundingClientRect().width);
|
109
109
|
}
|
110
110
|
}, [show, popupElRef.current]);
|
111
|
-
var
|
111
|
+
var adjustHorizontalPosition = function adjustHorizontalPosition(position) {
|
112
|
+
var _config$onAdjust;
|
113
|
+
var winWidth = _utils.docSize.width;
|
112
114
|
var winHeight = _utils.docSize.height;
|
113
|
-
if (!verticalPosition.includes(position)) return position;
|
114
115
|
var newPosition = position;
|
116
|
+
var _position$split = position.split('-'),
|
117
|
+
_position$split2 = _slicedToArray(_position$split, 2),
|
118
|
+
h = _position$split2[0],
|
119
|
+
v = _position$split2[1];
|
120
|
+
if (h === 'right') {
|
121
|
+
var horizontalPoint = context.parentRect.left + context.parentRect.width;
|
122
|
+
if (horizontalPoint / winWidth > 0.5 && horizontalPoint + context.popUpWidth > winWidth) {
|
123
|
+
newPosition = position.replace('right', 'left');
|
124
|
+
}
|
125
|
+
} else if (h === 'left') {
|
126
|
+
var _horizontalPoint = context.parentRect.left;
|
127
|
+
if (_horizontalPoint / winWidth < 0.5 && _horizontalPoint < context.popUpWidth) {
|
128
|
+
newPosition = position.replace('left', 'right');
|
129
|
+
}
|
130
|
+
}
|
131
|
+
if (v === 'top') {
|
132
|
+
var verticalPoint = context.parentRect.top;
|
133
|
+
if (verticalPoint / winHeight > 0.5 && verticalPoint + context.popUpHeight > winHeight) {
|
134
|
+
newPosition = newPosition.replace('top', 'bottom');
|
135
|
+
}
|
136
|
+
} else if (v === 'bottom') {
|
137
|
+
var _verticalPoint = context.parentRect.bottom;
|
138
|
+
if (_verticalPoint / winHeight < 0.5 && _verticalPoint < context.popUpHeight) {
|
139
|
+
newPosition = newPosition.replace('bottom', 'top');
|
140
|
+
}
|
141
|
+
}
|
142
|
+
config === null || config === void 0 || (_config$onAdjust = config.onAdjust) === null || _config$onAdjust === void 0 || _config$onAdjust.call(config, newPosition);
|
143
|
+
return newPosition;
|
144
|
+
};
|
145
|
+
var adjustVerticalPosition = function adjustVerticalPosition(position) {
|
146
|
+
var newPosition = position;
|
147
|
+
var winHeight = _utils.docSize.height;
|
115
148
|
var verticalPoint = context.parentRect.top + context.parentRect.height / 2;
|
116
149
|
if (position.startsWith('top')) {
|
117
150
|
if (verticalPoint / winHeight < 0.5 && context.parentRect.top - context.popUpHeight - popupGap < 0) {
|
@@ -136,15 +169,21 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
136
169
|
}
|
137
170
|
} else {
|
138
171
|
// absolute 场景下,右侧溢出判断需要考虑弹出层元素的尺寸
|
139
|
-
var _position$
|
140
|
-
_position$
|
141
|
-
_horizontalPosition = _position$
|
172
|
+
var _position$split3 = position.split('-'),
|
173
|
+
_position$split4 = _slicedToArray(_position$split3, 2),
|
174
|
+
_horizontalPosition = _position$split4[1];
|
142
175
|
if (_horizontalPosition === 'left' && context.parentRect.left + (popupElWidth || context.popUpWidth) > _utils.docSize.width) {
|
143
176
|
newPosition = newPosition.replace('left', 'right');
|
144
177
|
}
|
145
178
|
}
|
146
179
|
return newPosition;
|
147
180
|
};
|
181
|
+
var adjustPosition = function adjustPosition(position) {
|
182
|
+
if (!verticalPosition.includes(position)) {
|
183
|
+
return adjustHorizontalPosition(position);
|
184
|
+
}
|
185
|
+
return adjustVerticalPosition(position);
|
186
|
+
};
|
148
187
|
var getPopUpInfo = function getPopUpInfo(parentRect) {
|
149
188
|
var _popupElRef$current$p;
|
150
189
|
if (!popupElRef.current) return {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-popup.d.ts","sourceRoot":"","sources":["use-popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAA4E,MAAM,OAAO,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhE,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;;0BAqHK;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;
|
1
|
+
{"version":3,"file":"use-popup.d.ts","sourceRoot":"","sources":["use-popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAA4E,MAAM,OAAO,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhE,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;;0BAqHK;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;0BAa9B;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;;;;;qBAnC7B;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAvEzC,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;8BAOvC,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;2BAyJxD,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;6BAMxC,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;;CA8BlE,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
@@ -129,6 +129,10 @@ var usePopup = function usePopup(props) {
|
|
129
129
|
var handleMouseEnter = (0, _usePersistFn.default)(function (e) {
|
130
130
|
var _targetEvents$onMouse, _targetRef$current, _popupRef$current2;
|
131
131
|
targetEvents === null || targetEvents === void 0 || (_targetEvents$onMouse = targetEvents.onMouseEnter) === null || _targetEvents$onMouse === void 0 || _targetEvents$onMouse.call(targetEvents, e);
|
132
|
+
// todo: 考虑是否严格一些执行,比如需要判断是否是子元素
|
133
|
+
// if (targetRef.current?.contains(e.target as Node)) {
|
134
|
+
// targetEvents?.onMouseEnter?.(e);
|
135
|
+
// }
|
132
136
|
if (trigger !== 'hover') return;
|
133
137
|
var isParentContainsCurrent = (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : _targetRef$current.contains(e.target);
|
134
138
|
if (isParentContainsCurrent || popupRef !== null && popupRef !== void 0 && (_popupRef$current2 = popupRef.current) !== null && _popupRef$current2 !== void 0 && _popupRef$current2.contains(e.target)) {
|
@@ -138,6 +142,10 @@ var usePopup = function usePopup(props) {
|
|
138
142
|
var handleMouseLeave = (0, _usePersistFn.default)(function (e) {
|
139
143
|
var _targetEvents$onMouse2, _popupRef$current3;
|
140
144
|
targetEvents === null || targetEvents === void 0 || (_targetEvents$onMouse2 = targetEvents.onMouseLeave) === null || _targetEvents$onMouse2 === void 0 || _targetEvents$onMouse2.call(targetEvents, e);
|
145
|
+
// todo: 考虑是否严格一些执行,比如需要判断是否是子元素
|
146
|
+
// if (targetRef.current?.contains(e.target as Node)) {
|
147
|
+
// targetEvents?.onMouseLeave?.(e);
|
148
|
+
// }
|
141
149
|
if (trigger !== 'hover') return;
|
142
150
|
// @ts-ignore
|
143
151
|
if (e.relatedTarget instanceof HTMLElement && (_popupRef$current3 = popupRef.current) !== null && _popupRef$current3 !== void 0 && _popupRef$current3.contains(e.relatedTarget)) {
|
@@ -15,6 +15,7 @@ export interface PositionStyleConfig {
|
|
15
15
|
fixedWidth?: boolean | 'min';
|
16
16
|
updateKey?: number | string;
|
17
17
|
adjust?: boolean;
|
18
|
+
onAdjust?: (position: HorizontalPosition | VerticalPosition) => void;
|
18
19
|
offset?: [number, number];
|
19
20
|
}
|
20
21
|
export declare const usePositionStyle: (config: PositionStyleConfig) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAUpE,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,UAAU,GACV,cAAc,GACd,WAAW,GACX,MAAM,GACN,OAAO,CAAC;AACZ,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,cAAc,GACd,UAAU,GACV,WAAW,GACX,KAAK,GACL,QAAQ,CAAC;AAYb,KAAK,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,OAAO,CAAC;AACpE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IAEd,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAE1C,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAEzC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3B;AAsBD,eAAO,MAAM,gBAAgB,W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@@ export var usePositionStyle = function usePositionStyle(config) {
|
|
99
99
|
setPopupElWidth(popupElRef.current.getBoundingClientRect().width);
|
100
100
|
}
|
101
101
|
}, [show, popupElRef.current]);
|
102
|
-
var
|
102
|
+
var adjustHorizontalPosition = function adjustHorizontalPosition(position) {
|
103
|
+
var _config$onAdjust;
|
104
|
+
var winWidth = docSize.width;
|
103
105
|
var winHeight = docSize.height;
|
104
|
-
if (!verticalPosition.includes(position)) return position;
|
105
106
|
var newPosition = position;
|
107
|
+
var _position$split = position.split('-'),
|
108
|
+
_position$split2 = _slicedToArray(_position$split, 2),
|
109
|
+
h = _position$split2[0],
|
110
|
+
v = _position$split2[1];
|
111
|
+
if (h === 'right') {
|
112
|
+
var horizontalPoint = context.parentRect.left + context.parentRect.width;
|
113
|
+
if (horizontalPoint / winWidth > 0.5 && horizontalPoint + context.popUpWidth > winWidth) {
|
114
|
+
newPosition = position.replace('right', 'left');
|
115
|
+
}
|
116
|
+
} else if (h === 'left') {
|
117
|
+
var _horizontalPoint = context.parentRect.left;
|
118
|
+
if (_horizontalPoint / winWidth < 0.5 && _horizontalPoint < context.popUpWidth) {
|
119
|
+
newPosition = position.replace('left', 'right');
|
120
|
+
}
|
121
|
+
}
|
122
|
+
if (v === 'top') {
|
123
|
+
var verticalPoint = context.parentRect.top;
|
124
|
+
if (verticalPoint / winHeight > 0.5 && verticalPoint + context.popUpHeight > winHeight) {
|
125
|
+
newPosition = newPosition.replace('top', 'bottom');
|
126
|
+
}
|
127
|
+
} else if (v === 'bottom') {
|
128
|
+
var _verticalPoint = context.parentRect.bottom;
|
129
|
+
if (_verticalPoint / winHeight < 0.5 && _verticalPoint < context.popUpHeight) {
|
130
|
+
newPosition = newPosition.replace('bottom', 'top');
|
131
|
+
}
|
132
|
+
}
|
133
|
+
config === null || config === void 0 || (_config$onAdjust = config.onAdjust) === null || _config$onAdjust === void 0 || _config$onAdjust.call(config, newPosition);
|
134
|
+
return newPosition;
|
135
|
+
};
|
136
|
+
var adjustVerticalPosition = function adjustVerticalPosition(position) {
|
137
|
+
var newPosition = position;
|
138
|
+
var winHeight = docSize.height;
|
106
139
|
var verticalPoint = context.parentRect.top + context.parentRect.height / 2;
|
107
140
|
if (position.startsWith('top')) {
|
108
141
|
if (verticalPoint / winHeight < 0.5 && context.parentRect.top - context.popUpHeight - popupGap < 0) {
|
@@ -127,15 +160,21 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
127
160
|
}
|
128
161
|
} else {
|
129
162
|
// absolute 场景下,右侧溢出判断需要考虑弹出层元素的尺寸
|
130
|
-
var _position$
|
131
|
-
_position$
|
132
|
-
_horizontalPosition = _position$
|
163
|
+
var _position$split3 = position.split('-'),
|
164
|
+
_position$split4 = _slicedToArray(_position$split3, 2),
|
165
|
+
_horizontalPosition = _position$split4[1];
|
133
166
|
if (_horizontalPosition === 'left' && context.parentRect.left + (popupElWidth || context.popUpWidth) > docSize.width) {
|
134
167
|
newPosition = newPosition.replace('left', 'right');
|
135
168
|
}
|
136
169
|
}
|
137
170
|
return newPosition;
|
138
171
|
};
|
172
|
+
var adjustPosition = function adjustPosition(position) {
|
173
|
+
if (!verticalPosition.includes(position)) {
|
174
|
+
return adjustHorizontalPosition(position);
|
175
|
+
}
|
176
|
+
return adjustVerticalPosition(position);
|
177
|
+
};
|
139
178
|
var getPopUpInfo = function getPopUpInfo(parentRect) {
|
140
179
|
var _popupElRef$current$p;
|
141
180
|
if (!popupElRef.current) return {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-popup.d.ts","sourceRoot":"","sources":["use-popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAA4E,MAAM,OAAO,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhE,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;;0BAqHK;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;
|
1
|
+
{"version":3,"file":"use-popup.d.ts","sourceRoot":"","sources":["use-popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAA4E,MAAM,OAAO,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhE,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;;0BAqHK;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;0BAa9B;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;;;;;qBAnC7B;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAvEzC,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;8BAOvC,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;2BAyJxD,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;6BAMxC,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;;CA8BlE,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
@@ -122,6 +122,10 @@ var usePopup = function usePopup(props) {
|
|
122
122
|
var handleMouseEnter = usePersistFn(function (e) {
|
123
123
|
var _targetEvents$onMouse, _targetRef$current, _popupRef$current2;
|
124
124
|
targetEvents === null || targetEvents === void 0 || (_targetEvents$onMouse = targetEvents.onMouseEnter) === null || _targetEvents$onMouse === void 0 || _targetEvents$onMouse.call(targetEvents, e);
|
125
|
+
// todo: 考虑是否严格一些执行,比如需要判断是否是子元素
|
126
|
+
// if (targetRef.current?.contains(e.target as Node)) {
|
127
|
+
// targetEvents?.onMouseEnter?.(e);
|
128
|
+
// }
|
125
129
|
if (trigger !== 'hover') return;
|
126
130
|
var isParentContainsCurrent = (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : _targetRef$current.contains(e.target);
|
127
131
|
if (isParentContainsCurrent || popupRef !== null && popupRef !== void 0 && (_popupRef$current2 = popupRef.current) !== null && _popupRef$current2 !== void 0 && _popupRef$current2.contains(e.target)) {
|
@@ -131,6 +135,10 @@ var usePopup = function usePopup(props) {
|
|
131
135
|
var handleMouseLeave = usePersistFn(function (e) {
|
132
136
|
var _targetEvents$onMouse2, _popupRef$current3;
|
133
137
|
targetEvents === null || targetEvents === void 0 || (_targetEvents$onMouse2 = targetEvents.onMouseLeave) === null || _targetEvents$onMouse2 === void 0 || _targetEvents$onMouse2.call(targetEvents, e);
|
138
|
+
// todo: 考虑是否严格一些执行,比如需要判断是否是子元素
|
139
|
+
// if (targetRef.current?.contains(e.target as Node)) {
|
140
|
+
// targetEvents?.onMouseLeave?.(e);
|
141
|
+
// }
|
134
142
|
if (trigger !== 'hover') return;
|
135
143
|
// @ts-ignore
|
136
144
|
if (e.relatedTarget instanceof HTMLElement && (_popupRef$current3 = popupRef.current) !== null && _popupRef$current3 !== void 0 && _popupRef$current3.contains(e.relatedTarget)) {
|