@sesamehr/react-design-system 3.10.2 → 3.11.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/dist/Forms/Inputs/Combobox/ComboboxContent.d.ts +2 -0
- package/dist/Forms/Inputs/Combobox/ComboboxContent.js +50 -38
- package/dist/Forms/Inputs/Combobox/useReachEnd.d.ts +22 -0
- package/dist/Forms/Inputs/Combobox/useReachEnd.js +33 -0
- package/dist/react-design-system.css +1 -1
- package/package.json +1 -1
|
@@ -3,5 +3,7 @@ export interface ComboboxContentProps extends Omit<React.ComponentPropsWithoutRe
|
|
|
3
3
|
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
4
4
|
sideOffset?: number;
|
|
5
5
|
align?: 'start' | 'center' | 'end';
|
|
6
|
+
/** Called when the end of the list comes into view. */
|
|
7
|
+
onReachEnd?: () => void;
|
|
6
8
|
}
|
|
7
9
|
export declare const ComboboxContent: import('react').ForwardRefExoticComponent<ComboboxContentProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -1,78 +1,90 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
1
|
+
import { jsx as r, jsxs as l } from "react/jsx-runtime";
|
|
2
2
|
import * as c from "@radix-ui/react-popover";
|
|
3
|
-
import { Command as
|
|
4
|
-
import { forwardRef as
|
|
3
|
+
import { Command as P, CommandInput as S, CommandList as L } from "cmdk";
|
|
4
|
+
import { forwardRef as F, useRef as j, useState as A } from "react";
|
|
5
5
|
/* empty css */
|
|
6
|
-
import { useComboboxContext as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
6
|
+
import { useComboboxContext as D } from "./context.js";
|
|
7
|
+
import { useReachEnd as I } from "./useReachEnd.js";
|
|
8
|
+
import { Surface as O } from "../../../internal/Surface/Surface.js";
|
|
9
|
+
import { ListboxViewport as R } from "../../../internal/Listbox/ListboxViewport.js";
|
|
10
|
+
import { Scrollbar as k } from "../../../Layout/Scrollbar/Scrollbar.js";
|
|
11
|
+
const w = 16, G = F(
|
|
11
12
|
({
|
|
12
|
-
children:
|
|
13
|
+
children: d,
|
|
13
14
|
side: b = "bottom",
|
|
14
|
-
sideOffset:
|
|
15
|
-
align:
|
|
16
|
-
onInteractOutside:
|
|
17
|
-
onEscapeKeyDown:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
sideOffset: p = 4,
|
|
16
|
+
align: x = "start",
|
|
17
|
+
onInteractOutside: e,
|
|
18
|
+
onEscapeKeyDown: m,
|
|
19
|
+
onReachEnd: a,
|
|
20
|
+
...f
|
|
21
|
+
}, u) => {
|
|
22
|
+
const { search: s, cancelOpenEdit: h, skipFilter: C } = D(), i = j(null), [v, N] = A(null);
|
|
23
|
+
return I(i, v, a), /* @__PURE__ */ r(c.Portal, { children: /* @__PURE__ */ r(
|
|
22
24
|
c.Content,
|
|
23
25
|
{
|
|
24
|
-
ref:
|
|
26
|
+
ref: u,
|
|
25
27
|
asChild: !0,
|
|
26
28
|
"data-slot": "combobox-content",
|
|
27
29
|
side: b,
|
|
28
|
-
sideOffset:
|
|
29
|
-
collisionPadding:
|
|
30
|
-
align:
|
|
30
|
+
sideOffset: p,
|
|
31
|
+
collisionPadding: w,
|
|
32
|
+
align: x,
|
|
31
33
|
onOpenAutoFocus: (o) => o.preventDefault(),
|
|
32
34
|
onInteractOutside: (o) => {
|
|
33
|
-
var
|
|
35
|
+
var n;
|
|
34
36
|
const t = o.target;
|
|
35
|
-
(
|
|
37
|
+
(n = t == null ? void 0 : t.closest) != null && n.call(t, '[data-slot="combobox"]') && o.preventDefault(), e == null || e(o);
|
|
36
38
|
},
|
|
37
39
|
onEscapeKeyDown: (o) => {
|
|
38
|
-
|
|
40
|
+
h() && o.preventDefault(), m == null || m(o);
|
|
39
41
|
},
|
|
40
|
-
...
|
|
41
|
-
children: /* @__PURE__ */
|
|
42
|
-
/* @__PURE__ */
|
|
43
|
-
|
|
42
|
+
...f,
|
|
43
|
+
children: /* @__PURE__ */ l(O, { children: [
|
|
44
|
+
/* @__PURE__ */ l(
|
|
45
|
+
P,
|
|
44
46
|
{
|
|
45
47
|
shouldFilter: !C,
|
|
46
|
-
value:
|
|
48
|
+
value: s,
|
|
47
49
|
className: "ox-combobox-command",
|
|
48
50
|
children: [
|
|
49
51
|
/* @__PURE__ */ r(
|
|
50
|
-
|
|
52
|
+
S,
|
|
51
53
|
{
|
|
52
|
-
value:
|
|
54
|
+
value: s,
|
|
53
55
|
"aria-hidden": !0,
|
|
54
56
|
tabIndex: -1,
|
|
55
57
|
className: "ox-combobox-hidden-input"
|
|
56
58
|
}
|
|
57
59
|
),
|
|
58
|
-
/* @__PURE__ */ r(
|
|
59
|
-
|
|
60
|
+
/* @__PURE__ */ r(L, { asChild: !0, children: /* @__PURE__ */ l(
|
|
61
|
+
R,
|
|
60
62
|
{
|
|
61
|
-
ref:
|
|
63
|
+
ref: i,
|
|
62
64
|
className: "ox-combobox-viewport",
|
|
63
|
-
children:
|
|
65
|
+
children: [
|
|
66
|
+
d,
|
|
67
|
+
a && /* @__PURE__ */ r(
|
|
68
|
+
"div",
|
|
69
|
+
{
|
|
70
|
+
ref: N,
|
|
71
|
+
className: "ox-combobox-reach-end",
|
|
72
|
+
"aria-hidden": !0
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
]
|
|
64
76
|
}
|
|
65
77
|
) })
|
|
66
78
|
]
|
|
67
79
|
}
|
|
68
80
|
),
|
|
69
|
-
/* @__PURE__ */ r(
|
|
81
|
+
/* @__PURE__ */ r(k, { port: i, dataTestid: "combobox-scrollbar" })
|
|
70
82
|
] })
|
|
71
83
|
}
|
|
72
84
|
) });
|
|
73
85
|
}
|
|
74
86
|
);
|
|
75
|
-
|
|
87
|
+
G.displayName = "OxComboboxContent";
|
|
76
88
|
export {
|
|
77
|
-
|
|
89
|
+
G as ComboboxContent
|
|
78
90
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Reports that the end of a scrolling list has come into view, once per
|
|
4
|
+
* arrival.
|
|
5
|
+
*
|
|
6
|
+
* An `IntersectionObserver` and not a scroll listener because of the re-arm: a
|
|
7
|
+
* listener has to be disarmed after firing or it fires on every frame the user
|
|
8
|
+
* sits at the bottom, and then something has to decide when to arm it again.
|
|
9
|
+
* The observer re-fires on the transition for free.
|
|
10
|
+
*
|
|
11
|
+
* The sentinel arrives as an element and the port as a ref, which is the one
|
|
12
|
+
* place this diverges from the Vue composable. It has to: the list mounts when
|
|
13
|
+
* it opens, long after this hook first runs, and a ref filling in is not a
|
|
14
|
+
* render — so a hook waiting on `sentinel.current` waits for ever. A callback
|
|
15
|
+
* ref behind state is what turns the element arriving into something the effect
|
|
16
|
+
* can hang off. By the time it has, `port.current` is set too: both land in the
|
|
17
|
+
* same commit.
|
|
18
|
+
*
|
|
19
|
+
* @param port The scrolling element, which is also the observer's root.
|
|
20
|
+
* @param sentinel An empty element at the end of the list, inside `port`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useReachEnd(port: RefObject<HTMLElement | null>, sentinel: HTMLElement | null, reached: (() => void) | undefined): void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useRef as i, useEffect as p } from "react";
|
|
2
|
+
const I = 88;
|
|
3
|
+
function O(s, u, r) {
|
|
4
|
+
const o = i(r);
|
|
5
|
+
p(() => {
|
|
6
|
+
o.current = r;
|
|
7
|
+
}, [r]);
|
|
8
|
+
const f = r !== void 0;
|
|
9
|
+
p(() => {
|
|
10
|
+
const n = s.current, c = u;
|
|
11
|
+
if (!f || !n || !c) return;
|
|
12
|
+
let d = n.scrollHeight, e = null;
|
|
13
|
+
const x = () => {
|
|
14
|
+
e == null || e.disconnect(), e == null || e.observe(c);
|
|
15
|
+
};
|
|
16
|
+
typeof IntersectionObserver < "u" && (e = new IntersectionObserver(
|
|
17
|
+
(b) => {
|
|
18
|
+
var l;
|
|
19
|
+
b.some((g) => g.isIntersecting) && ((l = o.current) == null || l.call(o));
|
|
20
|
+
},
|
|
21
|
+
{ root: n, rootMargin: `0px 0px ${I}px 0px` }
|
|
22
|
+
), e.observe(c));
|
|
23
|
+
const t = typeof MutationObserver > "u" ? null : new MutationObserver(() => {
|
|
24
|
+
n.scrollHeight <= d || (d = n.scrollHeight, x());
|
|
25
|
+
});
|
|
26
|
+
return t == null || t.observe(n, { childList: !0, subtree: !0 }), () => {
|
|
27
|
+
e == null || e.disconnect(), t == null || t.disconnect();
|
|
28
|
+
};
|
|
29
|
+
}, [s, u, f]);
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
O as useReachEnd
|
|
33
|
+
};
|