@qyu/reactcmp-dropdown 2.1.1 → 2.2.0
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/README.md +6 -0
- package/build/bundle/entry/index.js +51 -11
- package/build/declaration/component/list-abs/element/view.d.ts +2 -0
- package/build/declaration/component/list-fix/element/view.d.ts +2 -0
- package/build/declaration/component/list-portal/element/view.d.ts +2 -0
- package/build/declaration/hook/listpos/api/absolute.d.ts +2 -0
- package/build/declaration/hook/listpos/api/fixed.d.ts +2 -0
- package/build/declaration/index.d.ts +1 -0
- package/build/declaration/util/measurement/new.d.ts +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -170,6 +170,12 @@ function App() {
|
|
|
170
170
|
clmap={clmap}
|
|
171
171
|
clmap_content={clmap}
|
|
172
172
|
render_view={props => <div {...props} />}
|
|
173
|
+
// how to measure content
|
|
174
|
+
// offset (default) will use .offsetHeight and .offsetWidth
|
|
175
|
+
// precise will use .getBoundingClientRect()
|
|
176
|
+
// offset properties are integers, so they cut the floating point
|
|
177
|
+
// .getBoundingClientRect() uses floats, but also measures after transforms
|
|
178
|
+
measurement_kind={"offset" || "precise"}
|
|
173
179
|
|
|
174
180
|
// specify the portal
|
|
175
181
|
portal={"domid"}
|
|
@@ -412,6 +412,24 @@ const useFocusCaptureInfer = function (params) {
|
|
|
412
412
|
});
|
|
413
413
|
};
|
|
414
414
|
|
|
415
|
+
const measurement_new = function (element, config) {
|
|
416
|
+
switch (config.kind) {
|
|
417
|
+
case "offset": {
|
|
418
|
+
return {
|
|
419
|
+
width: element.offsetWidth,
|
|
420
|
+
height: element.offsetHeight,
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
case "precise": {
|
|
424
|
+
const rect = element.getBoundingClientRect();
|
|
425
|
+
return {
|
|
426
|
+
width: rect.width,
|
|
427
|
+
height: rect.height,
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
|
|
415
433
|
const prop_stretch_new = function (raw) {
|
|
416
434
|
if (!raw) {
|
|
417
435
|
return "none";
|
|
@@ -623,8 +641,9 @@ const useListPosApiFixed = function (params) {
|
|
|
623
641
|
content.classList.add(params.clmap_content._tracking);
|
|
624
642
|
}
|
|
625
643
|
const container_rect = container.getBoundingClientRect();
|
|
644
|
+
const content_rect = measurement_new(content, { kind: params.measurement_kind });
|
|
626
645
|
const axis_main = {
|
|
627
|
-
list_size:
|
|
646
|
+
list_size: content_rect.height,
|
|
628
647
|
screen_size: document.documentElement.clientHeight,
|
|
629
648
|
container_pos: container_rect.y,
|
|
630
649
|
container_size: container_rect.height,
|
|
@@ -637,7 +656,7 @@ const useListPosApiFixed = function (params) {
|
|
|
637
656
|
},
|
|
638
657
|
};
|
|
639
658
|
const axis_cross = {
|
|
640
|
-
list_size:
|
|
659
|
+
list_size: content_rect.width,
|
|
641
660
|
screen_size: document.documentElement.clientWidth,
|
|
642
661
|
container_pos: container_rect.x,
|
|
643
662
|
container_size: container_rect.width,
|
|
@@ -670,7 +689,7 @@ const useListPosApiFixed = function (params) {
|
|
|
670
689
|
}
|
|
671
690
|
}
|
|
672
691
|
},
|
|
673
|
-
}), [ctxstate_refs.rootref, params.ref_list, params.ref_content, nprop_stretch])
|
|
692
|
+
}), [ctxstate_refs.rootref, params.ref_list, params.ref_content, nprop_stretch, params.measurement_kind])
|
|
674
693
|
};
|
|
675
694
|
};
|
|
676
695
|
|
|
@@ -907,12 +926,13 @@ const render_view_default$4 = function (props) {
|
|
|
907
926
|
};
|
|
908
927
|
const CmpListFix = r.memo(r.forwardRef((props, f_ref) => {
|
|
909
928
|
const nprop_gap = props.gap ?? 0;
|
|
910
|
-
const nprop_lazy = props.lazy ??
|
|
929
|
+
const nprop_lazy = props.lazy ?? true;
|
|
911
930
|
const nprop_align = prop_align_new(props.align);
|
|
912
931
|
const nprop_justify = prop_justify_new(props.justify);
|
|
913
932
|
const nprop_direction = prop_direction_new(props.direction);
|
|
914
933
|
const nprop_transition_nopos = props.transition_nopos ?? false;
|
|
915
934
|
const nprop_transition_nosize = props.transition_nosize ?? false;
|
|
935
|
+
const nprop_measurement_kind = props.measurement_kind ?? "offset";
|
|
916
936
|
const nprop_render_view = props.render_view ?? render_view_default$4;
|
|
917
937
|
const nprop_clmap = r.useMemo(() => prop_clmap_new(props.clmap, prop_clmap_def_listfix), [props.clmap]);
|
|
918
938
|
const nprop_clmap_content = r.useMemo(() => prop_clmap_new(props.clmap_content, prop_clmap_def_content), [props.clmap_content]);
|
|
@@ -922,7 +942,13 @@ const CmpListFix = r.memo(r.forwardRef((props, f_ref) => {
|
|
|
922
942
|
const ref_content = useRefO(l_ref_content);
|
|
923
943
|
const open = useOpenInfer({});
|
|
924
944
|
const [visible, visible_set] = r.useState(false);
|
|
925
|
-
const listapi = useListPosApiFixed({
|
|
945
|
+
const listapi = useListPosApiFixed({
|
|
946
|
+
ref_list,
|
|
947
|
+
ref_content,
|
|
948
|
+
clmap_content: nprop_clmap_content,
|
|
949
|
+
stretch: props.stretch,
|
|
950
|
+
measurement_kind: nprop_measurement_kind,
|
|
951
|
+
});
|
|
926
952
|
const ctxstate_content = useCtxStateInitContent({
|
|
927
953
|
ref_content: l_ref_content,
|
|
928
954
|
});
|
|
@@ -1100,16 +1126,17 @@ const useListPosApiAbsolute = function (params) {
|
|
|
1100
1126
|
content.classList.add(params.clmap_content._tracking);
|
|
1101
1127
|
}
|
|
1102
1128
|
const container_rect = container.getBoundingClientRect();
|
|
1129
|
+
const content_rect = measurement_new(content, { kind: params.measurement_kind });
|
|
1103
1130
|
const axis_main = {
|
|
1104
1131
|
size_set: height_set,
|
|
1105
|
-
list_size:
|
|
1132
|
+
list_size: content_rect.height,
|
|
1106
1133
|
screen_size: document.documentElement.clientHeight,
|
|
1107
1134
|
container_pos: container_rect.y,
|
|
1108
1135
|
container_size: container_rect.height,
|
|
1109
1136
|
};
|
|
1110
1137
|
const axis_cross = {
|
|
1111
1138
|
size_set: width_set,
|
|
1112
|
-
list_size:
|
|
1139
|
+
list_size: content_rect.width,
|
|
1113
1140
|
screen_size: document.documentElement.clientWidth,
|
|
1114
1141
|
container_pos: container_rect.x,
|
|
1115
1142
|
container_size: container_rect.width,
|
|
@@ -1134,7 +1161,7 @@ const useListPosApiAbsolute = function (params) {
|
|
|
1134
1161
|
}
|
|
1135
1162
|
}
|
|
1136
1163
|
},
|
|
1137
|
-
}), [ctxstate_refs.rootref, params.ref_list, params.ref_content, params.clmap_content])
|
|
1164
|
+
}), [ctxstate_refs.rootref, params.ref_list, params.ref_content, params.clmap_content, params.measurement_kind])
|
|
1138
1165
|
};
|
|
1139
1166
|
};
|
|
1140
1167
|
|
|
@@ -1161,6 +1188,7 @@ const CmpListAbs = r.memo(r.forwardRef((props, f_ref) => {
|
|
|
1161
1188
|
const nprop_align = prop_align_new(props.align);
|
|
1162
1189
|
const nprop_justify = prop_justify_new(props.justify);
|
|
1163
1190
|
const nprop_direction = prop_direction_new(props.direction);
|
|
1191
|
+
const nprop_measurement_kind = props.measurement_kind ?? "offset";
|
|
1164
1192
|
const nprop_render_view = props.render_view ?? render_view_default$3;
|
|
1165
1193
|
const nprop_clmap = r.useMemo(() => prop_clmap_new(props.clmap, prop_clmap_def_listabs), [props.clmap]);
|
|
1166
1194
|
const nprop_clmap_content = r.useMemo(() => prop_clmap_new(props.clmap_content, prop_clmap_def_content), [props.clmap_content]);
|
|
@@ -1171,7 +1199,12 @@ const CmpListAbs = r.memo(r.forwardRef((props, f_ref) => {
|
|
|
1171
1199
|
const ref_content = useRefO(l_ref_content);
|
|
1172
1200
|
const open = useOpenInfer({});
|
|
1173
1201
|
const [visible, visible_set] = r.useState(false);
|
|
1174
|
-
const listapi = useListPosApiAbsolute({
|
|
1202
|
+
const listapi = useListPosApiAbsolute({
|
|
1203
|
+
ref_list,
|
|
1204
|
+
ref_content,
|
|
1205
|
+
clmap_content: nprop_clmap_content,
|
|
1206
|
+
measurement_kind: nprop_measurement_kind,
|
|
1207
|
+
});
|
|
1175
1208
|
const ctxstate_content = useCtxStateInitContent({
|
|
1176
1209
|
ref_content: l_ref_content,
|
|
1177
1210
|
});
|
|
@@ -1262,6 +1295,7 @@ const CmpListPortal = r.memo(r.forwardRef((props, f_ref) => {
|
|
|
1262
1295
|
const nprop_direction = prop_direction_new(props.direction);
|
|
1263
1296
|
const nprop_transition_nopos = props.transition_nopos ?? false;
|
|
1264
1297
|
const nprop_transition_nosize = props.transition_nosize ?? false;
|
|
1298
|
+
const nprop_measurement_kind = props.measurement_kind ?? "offset";
|
|
1265
1299
|
const nprop_render_view = props.render_view ?? render_view_default$2;
|
|
1266
1300
|
const nprop_clmap = r.useMemo(() => prop_clmap_new(props.clmap, prop_clmap_def_listfix), [props.clmap]);
|
|
1267
1301
|
const nprop_clmap_content = r.useMemo(() => prop_clmap_new(props.clmap_content, prop_clmap_def_content), [props.clmap_content]);
|
|
@@ -1271,7 +1305,13 @@ const CmpListPortal = r.memo(r.forwardRef((props, f_ref) => {
|
|
|
1271
1305
|
const ref_content = useRefO(l_ref_content);
|
|
1272
1306
|
const open = useOpenInfer({});
|
|
1273
1307
|
const [visible, visible_set] = r.useState(false);
|
|
1274
|
-
const listapi = useListPosApiFixed({
|
|
1308
|
+
const listapi = useListPosApiFixed({
|
|
1309
|
+
ref_list,
|
|
1310
|
+
ref_content,
|
|
1311
|
+
clmap_content: nprop_clmap_content,
|
|
1312
|
+
stretch: props.stretch,
|
|
1313
|
+
measurement_kind: nprop_measurement_kind,
|
|
1314
|
+
});
|
|
1275
1315
|
const ctxstate_content = useCtxStateInitContent({
|
|
1276
1316
|
ref_content: l_ref_content,
|
|
1277
1317
|
});
|
|
@@ -1536,4 +1576,4 @@ const useCloseEvtShardInfer = function (params) {
|
|
|
1536
1576
|
});
|
|
1537
1577
|
};
|
|
1538
1578
|
|
|
1539
|
-
export { CmpButton, CmpButtonVirtual, CmpContainer, CmpContainerVirtual, CmpContent, CmpCtxState_Config, CmpCtxState_Content, CmpCtxState_Open, CmpCtxState_Refs, CmpListAbs, CmpListFix, CmpListPortal, cssprops_new_position, cssprops_new_size, prop_align_new, prop_align_new_reversed, prop_clmap_def_container, prop_clmap_def_content, prop_clmap_def_listabs, prop_clmap_def_listfix, prop_clmap_new, prop_direction_new, prop_justify_new, prop_justify_new_reversed, prop_portal_new, useCloseEvtRoot, useCloseEvtRootInfer, useCloseEvtShard, useCloseEvtShardInfer, useCtxStateConfig, useCtxStateContent, useCtxStateInitConfig, useCtxStateInitContent, useCtxStateInitOpen, useCtxStateInitRefs, useCtxStateOpen, useCtxStateRefs, useDDNList, useDDNListInfer, useDDNRoot, useDDNRootInfer, useDDNShard, useDDNShardInfer, useFocusCapture, useFocusCaptureInfer, useListPosApiAbsolute, useListPosApiFixed, useListPosRearrange, useOpen, useOpenInfer };
|
|
1579
|
+
export { CmpButton, CmpButtonVirtual, CmpContainer, CmpContainerVirtual, CmpContent, CmpCtxState_Config, CmpCtxState_Content, CmpCtxState_Open, CmpCtxState_Refs, CmpListAbs, CmpListFix, CmpListPortal, cssprops_new_position, cssprops_new_size, measurement_new, prop_align_new, prop_align_new_reversed, prop_clmap_def_container, prop_clmap_def_content, prop_clmap_def_listabs, prop_clmap_def_listfix, prop_clmap_new, prop_direction_new, prop_justify_new, prop_justify_new_reversed, prop_portal_new, useCloseEvtRoot, useCloseEvtRootInfer, useCloseEvtShard, useCloseEvtShardInfer, useCtxStateConfig, useCtxStateContent, useCtxStateInitConfig, useCtxStateInitContent, useCtxStateInitOpen, useCtxStateInitRefs, useCtxStateOpen, useCtxStateRefs, useDDNList, useDDNListInfer, useDDNRoot, useDDNRootInfer, useDDNShard, useDDNShardInfer, useFocusCapture, useFocusCaptureInfer, useListPosApiAbsolute, useListPosApiFixed, useListPosRearrange, useOpen, useOpenInfer };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ListPosRearrange_Config } from "../../../hook/listpos/rearrange/type/config.js";
|
|
2
|
+
import type { Measurement_New_Kind } from "../../../util/measurement/new.js";
|
|
2
3
|
import type { PropAlign_Raw } from "../../../util/prop/align/type/prop.js";
|
|
3
4
|
import { prop_clmap_def_content } from "../../../util/prop/clmap/def/content.js";
|
|
4
5
|
import { prop_clmap_def_listabs } from "../../../util/prop/clmap/def/listabs.js";
|
|
@@ -9,6 +10,7 @@ import * as r from "react";
|
|
|
9
10
|
export type CmpListAbs_Props = {
|
|
10
11
|
readonly gap?: number;
|
|
11
12
|
readonly lazy?: boolean;
|
|
13
|
+
readonly measurement_kind?: Measurement_New_Kind;
|
|
12
14
|
readonly align?: PropAlign_Raw;
|
|
13
15
|
readonly justify?: PropJustify_Raw;
|
|
14
16
|
readonly direction?: PropDirection_Raw;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ListPosRearrange_Config } from "../../../hook/listpos/rearrange/type/config.js";
|
|
2
|
+
import type { Measurement_New_Kind } from "../../../util/measurement/new.js";
|
|
2
3
|
import type { PropAlign_Raw } from "../../../util/prop/align/type/prop.js";
|
|
3
4
|
import { prop_clmap_def_content } from "../../../util/prop/clmap/def/content.js";
|
|
4
5
|
import { prop_clmap_def_listfix } from "../../../util/prop/clmap/def/listfix.js";
|
|
@@ -10,6 +11,7 @@ import * as r from "react";
|
|
|
10
11
|
export type CmpListFix_Props = {
|
|
11
12
|
readonly gap?: number;
|
|
12
13
|
readonly lazy?: boolean;
|
|
14
|
+
readonly measurement_kind?: Measurement_New_Kind;
|
|
13
15
|
readonly align?: PropAlign_Raw;
|
|
14
16
|
readonly justify?: PropJustify_Raw;
|
|
15
17
|
readonly stretch?: PropStretch_Raw;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ListPosRearrange_Config } from "../../../hook/listpos/rearrange/type/config.js";
|
|
2
|
+
import type { Measurement_New_Kind } from "../../../util/measurement/new.js";
|
|
2
3
|
import type { PropAlign_Raw } from "../../../util/prop/align/type/prop.js";
|
|
3
4
|
import { prop_clmap_def_content } from "../../../util/prop/clmap/def/content.js";
|
|
4
5
|
import { prop_clmap_def_listfix } from "../../../util/prop/clmap/def/listfix.js";
|
|
@@ -10,6 +11,7 @@ import type { PropStretch_Raw } from "../../../util/prop/stretch/type/prop.js";
|
|
|
10
11
|
import * as r from "react";
|
|
11
12
|
export type CmpListPortal_Props = {
|
|
12
13
|
readonly portal: NonNullable<PropPortal_Raw>;
|
|
14
|
+
readonly measurement_kind?: Measurement_New_Kind;
|
|
13
15
|
readonly gap?: number;
|
|
14
16
|
readonly lazy?: boolean;
|
|
15
17
|
readonly stretch?: PropStretch_Raw;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ListPosApi_Api } from "./type/api.js";
|
|
2
2
|
import type { ListPosApi_Reverse } from "./type/reverse.js";
|
|
3
3
|
import type { ListPosApi_Size } from "./type/size.js";
|
|
4
|
+
import { type Measurement_New_Kind } from "../../../util/measurement/new.js";
|
|
4
5
|
import type { PropClMap_DefContent } from "../../../util/prop/clmap/def/content.js";
|
|
5
6
|
export type UseListPosAbsolute_Return = {
|
|
6
7
|
readonly api: ListPosApi_Api;
|
|
@@ -11,5 +12,6 @@ export type UseListPosAbsolute_Params = {
|
|
|
11
12
|
readonly ref_list: () => HTMLElement | null;
|
|
12
13
|
readonly ref_content: () => HTMLElement | null;
|
|
13
14
|
readonly clmap_content: PropClMap_DefContent;
|
|
15
|
+
readonly measurement_kind: Measurement_New_Kind;
|
|
14
16
|
};
|
|
15
17
|
export declare const useListPosApiAbsolute: (params: UseListPosAbsolute_Params) => UseListPosAbsolute_Return;
|
|
@@ -3,6 +3,7 @@ import type { ListPosApi_Position } from "./type/position.js";
|
|
|
3
3
|
import type { ListPosApi_Reverse } from "./type/reverse.js";
|
|
4
4
|
import type { ListPosApi_Size } from "./type/size.js";
|
|
5
5
|
import type { FnORefHTML } from "../../../type/fnref.js";
|
|
6
|
+
import { type Measurement_New_Kind } from "../../../util/measurement/new.js";
|
|
6
7
|
import type { PropClMap_DefContent } from "../../../util/prop/clmap/def/content.js";
|
|
7
8
|
import type { PropStretch_Raw } from "../../../util/prop/stretch/type/prop.js";
|
|
8
9
|
export type UseListPosFixed_Return = {
|
|
@@ -15,6 +16,7 @@ export type UseListPosFixed_Params = {
|
|
|
15
16
|
readonly ref_list: FnORefHTML;
|
|
16
17
|
readonly ref_content: FnORefHTML;
|
|
17
18
|
readonly clmap_content: PropClMap_DefContent;
|
|
19
|
+
readonly measurement_kind: Measurement_New_Kind;
|
|
18
20
|
readonly stretch?: PropStretch_Raw;
|
|
19
21
|
};
|
|
20
22
|
export declare const useListPosApiFixed: (params: UseListPosFixed_Params) => UseListPosFixed_Return;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type Measurement_New_Kind = ("offset" | "precise");
|
|
2
|
+
export type Measurement_New_Config = {
|
|
3
|
+
readonly kind: Measurement_New_Kind;
|
|
4
|
+
};
|
|
5
|
+
export type Measurement_New_Result = {
|
|
6
|
+
readonly width: number;
|
|
7
|
+
readonly height: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const measurement_new: (element: HTMLElement, config: Measurement_New_Config) => Measurement_New_Result;
|