@qyu/reactcmp-dropdown 1.0.1 → 1.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
CHANGED
|
@@ -50,6 +50,7 @@ function App() {
|
|
|
50
50
|
</ddn.CmpButton>
|
|
51
51
|
|
|
52
52
|
<ddn.CmpListAbs
|
|
53
|
+
tabIndex={0}
|
|
53
54
|
className={""}
|
|
54
55
|
stylemodule={stylemodule}
|
|
55
56
|
|
|
@@ -79,6 +80,7 @@ function App() {
|
|
|
79
80
|
|
|
80
81
|
{/* Same as CmpListAbs, but uses fixed positioning */}
|
|
81
82
|
<ddn.CmpListFix
|
|
83
|
+
tabIndex={0}
|
|
82
84
|
className={""}
|
|
83
85
|
stylemodule={stylemodule}
|
|
84
86
|
|
|
@@ -102,6 +104,10 @@ function App() {
|
|
|
102
104
|
justify
|
|
103
105
|
// set justify directly
|
|
104
106
|
jystify={"end" || "start"}
|
|
107
|
+
|
|
108
|
+
// when string - finds portal by id
|
|
109
|
+
// when HTMLElement - uses element for portal
|
|
110
|
+
portal={"dropdowns" || document.getElementById("dropdowns")}
|
|
105
111
|
>
|
|
106
112
|
Your Content Here
|
|
107
113
|
</ddn.CmpListFix>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as r from 'react';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import * as rdom from 'react-dom';
|
|
3
4
|
|
|
4
5
|
const CmpCtxState_Open = r.createContext(null);
|
|
5
6
|
|
|
@@ -169,6 +170,15 @@ const nprop_direction_new = function (raw) {
|
|
|
169
170
|
}
|
|
170
171
|
return raw;
|
|
171
172
|
};
|
|
173
|
+
const nprop_portal_new = function (portal) {
|
|
174
|
+
if (typeof portal === "string") {
|
|
175
|
+
return document.getElementById(portal) ?? null;
|
|
176
|
+
}
|
|
177
|
+
if (portal) {
|
|
178
|
+
return portal;
|
|
179
|
+
}
|
|
180
|
+
return null;
|
|
181
|
+
};
|
|
172
182
|
|
|
173
183
|
const stylemap$1 = {
|
|
174
184
|
listfix: "listfix",
|
|
@@ -315,6 +325,7 @@ const CmpListFix = r.memo(r.forwardRef((props, ref) => {
|
|
|
315
325
|
const nprop_gap = props.gap ?? 0;
|
|
316
326
|
const nprop_lazy = props.lazy ?? false;
|
|
317
327
|
const nprop_align = nprop_align_new(props.align);
|
|
328
|
+
const nprop_portal = nprop_portal_new(props.portal);
|
|
318
329
|
const nprop_justify = nprop_justify_new(props.justify);
|
|
319
330
|
const nprop_direction = nprop_direction_new(props.direction);
|
|
320
331
|
const nprop_style = r.useMemo(() => (props.stylemodule ? stylemap_new_remap(stylemap$1, props.stylemodule) : stylemap$1), [props.stylemodule]);
|
|
@@ -404,7 +415,7 @@ const CmpListFix = r.memo(r.forwardRef((props, ref) => {
|
|
|
404
415
|
}
|
|
405
416
|
return null;
|
|
406
417
|
}, [nprop_lazy, visible, ctxstate.open, props.children]);
|
|
407
|
-
|
|
418
|
+
const element = jsx("div", { ref: mref, tabIndex: props.tabIndex, className: cl("__qyuddn", props.className, nprop_style.listfix, ctxstate.open && nprop_style.listfix_open, ((nprop_align === "end" && !revalign) || (nprop_align === "start" && revalign)) && nprop_style.listfix_align_end, ((nprop_align === "start" && !revalign) || (nprop_align === "end" && revalign)) && nprop_style.listfix_align_start, nprop_align === "center" && nprop_style.listfix_align_center, ((nprop_justify === "end") !== revjustify) && nprop_style.listfix_justify_end, ((nprop_justify === "start") !== revjustify) && nprop_style.listfix_justify_start, nprop_direction === "hor" && nprop_style.listfix_horizontal, nprop_direction === "ver" && nprop_style.listfix_vertical), style: {
|
|
408
419
|
["--gap"]: `${nprop_gap}px`,
|
|
409
420
|
top: top !== null ? `${top}px` : null,
|
|
410
421
|
left: left !== null ? `${left}px` : null,
|
|
@@ -429,6 +440,10 @@ const CmpListFix = r.memo(r.forwardRef((props, ref) => {
|
|
|
429
440
|
right_set(null);
|
|
430
441
|
}
|
|
431
442
|
}, children: children });
|
|
443
|
+
if (nprop_portal) {
|
|
444
|
+
return rdom.createPortal(element, nprop_portal);
|
|
445
|
+
}
|
|
446
|
+
return element;
|
|
432
447
|
}));
|
|
433
448
|
|
|
434
449
|
const stylemap = {
|
|
@@ -610,7 +625,7 @@ const CmpListAbs = r.memo(r.forwardRef((props, ref) => {
|
|
|
610
625
|
}
|
|
611
626
|
return null;
|
|
612
627
|
}, [nprop_lazy, visible, ctxstate.open, props.children]);
|
|
613
|
-
return jsx("div", { ref: mref, className: cl("__qyuddn", props.className, nprop_style.listabs, ctxstate.open && nprop_style.listabs_open, ((nprop_align === "end" && !revalign) || (nprop_align === "start" && revalign)) && nprop_style.listabs_align_end, ((nprop_align === "start" && !revalign) || (nprop_align === "end" && revalign)) && nprop_style.listabs_align_start, nprop_align === "center" && nprop_style.listabs_align_center, ((nprop_justify === "end") !== revjustify) && nprop_style.listabs_justify_end, ((nprop_justify === "start") !== revjustify) && nprop_style.listabs_justify_start, nprop_direction === "hor" && nprop_style.listabs_horizontal, nprop_direction === "ver" && nprop_style.listabs_vertical), style: {
|
|
628
|
+
return jsx("div", { ref: mref, tabIndex: props.tabIndex, className: cl("__qyuddn", props.className, nprop_style.listabs, ctxstate.open && nprop_style.listabs_open, ((nprop_align === "end" && !revalign) || (nprop_align === "start" && revalign)) && nprop_style.listabs_align_end, ((nprop_align === "start" && !revalign) || (nprop_align === "end" && revalign)) && nprop_style.listabs_align_start, nprop_align === "center" && nprop_style.listabs_align_center, ((nprop_justify === "end") !== revjustify) && nprop_style.listabs_justify_end, ((nprop_justify === "start") !== revjustify) && nprop_style.listabs_justify_start, nprop_direction === "hor" && nprop_style.listabs_horizontal, nprop_direction === "ver" && nprop_style.listabs_vertical), style: {
|
|
614
629
|
["--gap"]: `${nprop_gap}px`,
|
|
615
630
|
maxWidth: maxwidth === null ? undefined : `${maxwidth}px`,
|
|
616
631
|
maxHeight: maxheight === null ? undefined : `${maxheight}px`,
|
|
@@ -18,6 +18,7 @@ export type CmpListAbs_Props = Readonly<{
|
|
|
18
18
|
gap?: number;
|
|
19
19
|
lazy?: boolean;
|
|
20
20
|
align?: AlignRaw;
|
|
21
|
+
tabIndex?: number;
|
|
21
22
|
justify?: JustifyRaw;
|
|
22
23
|
direction?: DirectionRaw;
|
|
23
24
|
className?: string;
|
|
@@ -28,6 +29,7 @@ export declare const CmpListAbs: r.NamedExoticComponent<Readonly<{
|
|
|
28
29
|
gap?: number;
|
|
29
30
|
lazy?: boolean;
|
|
30
31
|
align?: AlignRaw;
|
|
32
|
+
tabIndex?: number;
|
|
31
33
|
justify?: JustifyRaw;
|
|
32
34
|
direction?: DirectionRaw;
|
|
33
35
|
className?: string;
|
|
@@ -18,8 +18,10 @@ export type CmpListFix_Props = Readonly<{
|
|
|
18
18
|
gap?: number;
|
|
19
19
|
lazy?: boolean;
|
|
20
20
|
align?: AlignRaw;
|
|
21
|
+
tabIndex?: number;
|
|
21
22
|
justify?: JustifyRaw;
|
|
22
23
|
direction?: DirectionRaw;
|
|
24
|
+
portal?: string | HTMLElement;
|
|
23
25
|
className?: string;
|
|
24
26
|
stylemodule?: CmpListFix_StyleModule;
|
|
25
27
|
children?: r.ReactNode | (() => r.ReactNode);
|
|
@@ -28,8 +30,10 @@ export declare const CmpListFix: r.NamedExoticComponent<Readonly<{
|
|
|
28
30
|
gap?: number;
|
|
29
31
|
lazy?: boolean;
|
|
30
32
|
align?: AlignRaw;
|
|
33
|
+
tabIndex?: number;
|
|
31
34
|
justify?: JustifyRaw;
|
|
32
35
|
direction?: DirectionRaw;
|
|
36
|
+
portal?: string | HTMLElement;
|
|
33
37
|
className?: string;
|
|
34
38
|
stylemodule?: CmpListFix_StyleModule;
|
|
35
39
|
children?: r.ReactNode | (() => r.ReactNode);
|
|
@@ -2,3 +2,4 @@ import type { Align, AlignRaw, Direction, DirectionRaw, Justify, JustifyRaw } fr
|
|
|
2
2
|
export declare const nprop_align_new: (raw: AlignRaw) => Align;
|
|
3
3
|
export declare const nprop_justify_new: (raw: JustifyRaw) => Justify;
|
|
4
4
|
export declare const nprop_direction_new: (raw: DirectionRaw) => Direction;
|
|
5
|
+
export declare const nprop_portal_new: (portal: string | HTMLElement | undefined | null) => HTMLElement | null;
|