asma-ui-core 3.134.7 → 3.135.1
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/asma-ui-core.css +1 -1
- package/dist/components/utils/bottom-sheet/StyledBottomSheet.js +172 -127
- package/dist/components/utils/bottom-sheet/sheetCopy.js +12 -0
- package/dist/components/utils/bottom-sheet/useDragToDismiss.hook.js +26 -20
- package/dist/datetime/components/time-picker/components/TimePickerColumn.js +9 -7
- package/dist/src/components/utils/bottom-sheet/StyledBottomSheet.d.ts +19 -8
- package/dist/src/components/utils/bottom-sheet/sheetCopy.d.ts +6 -0
- package/dist/src/components/utils/bottom-sheet/useDragToDismiss.hook.d.ts +7 -5
- package/package.json +1 -1
|
@@ -1,178 +1,223 @@
|
|
|
1
1
|
import { cn as l } from "../../../helpers/cn.js";
|
|
2
|
-
import { registerOpenModalDialog as
|
|
3
|
-
import { CloseIcon as
|
|
4
|
-
import {
|
|
5
|
-
import { StyledButton as
|
|
6
|
-
import { OverlayBackOwnerContext as
|
|
7
|
-
import { isKeyboardModality as
|
|
8
|
-
import { useDebouncedValue as
|
|
9
|
-
import { useFocusTrap as
|
|
10
|
-
import { useShortViewportMediaQuery as
|
|
11
|
-
import { SHEET_TEXT as
|
|
12
|
-
import { formatResultsLabel as
|
|
13
|
-
import { useBodyScrollLock as
|
|
14
|
-
import
|
|
15
|
-
import { useDragToDismiss as
|
|
16
|
-
import { useEffect as
|
|
17
|
-
import { jsx as
|
|
18
|
-
var
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
const { dragHandleProps:
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
2
|
+
import { registerOpenModalDialog as ce } from "../../../hooks/useTopLayer.hook.js";
|
|
3
|
+
import { CloseIcon as de } from "../../icons/close-icon/CloseIcon.js";
|
|
4
|
+
import { BackIcon as ue } from "../../icons/back-icon/BackIcon.js";
|
|
5
|
+
import { StyledButton as N } from "../../inputs/button/StyledButton.js";
|
|
6
|
+
import { OverlayBackOwnerContext as fe, isOverlayBackEnabled as X, requestCloseTopOverlayBack as R, useBackCloses as me } from "../../../hooks/useBackCloses.hook.js";
|
|
7
|
+
import { isKeyboardModality as pe, trackInputModality as he } from "../../inputs/full-screen-picker/inputModality.js";
|
|
8
|
+
import { useDebouncedValue as ve } from "../../../hooks/useDebouncedValue.hook.js";
|
|
9
|
+
import { useFocusTrap as be } from "../../../hooks/useFocusTrap.hook.js";
|
|
10
|
+
import { useShortViewportMediaQuery as xe } from "../../../hooks/useMediaQuery.hook.js";
|
|
11
|
+
import { SHEET_HEADER_TEXT as ye, SHEET_TEXT as we } from "./sheetCopy.js";
|
|
12
|
+
import { formatResultsLabel as ge } from "./formatResultsLabel.js";
|
|
13
|
+
import { useBodyScrollLock as Ee } from "../../../hooks/useBodyScrollLock.hook.js";
|
|
14
|
+
import ke from "./StyledBottomSheet.module.js";
|
|
15
|
+
import { useDragToDismiss as Se } from "./useDragToDismiss.hook.js";
|
|
16
|
+
import { useEffect as x, useId as Ne, useLayoutEffect as Re, useRef as c, useState as C } from "react";
|
|
17
|
+
import { jsx as t, jsxs as f } from "react/jsx-runtime";
|
|
18
|
+
var Ce = 500, ze = ({ dataTest: s, id: Q, open: r, onClose: i, title: m, ariaLabel: Y, titleIcon: _, onBack: B, backLabel: J, children: W, viewResultsAction: L, resetAction: Z, footerActions: ee, resultCount: O, locale: y = "en", closeLabel: te = we[y].close, className: re, registerBackClose: oe = !0, ownerRef: ne, triggerRef: T }) => {
|
|
19
|
+
const D = Ne(), d = c(null), H = c(null), I = c(null), M = ne ?? d, w = c(!1), [g, j] = C(!1), $ = xe(), F = c(null), [u, p] = C(!1), [ae, se] = C(!1), A = !$ && (u || ae), E = ye[y], h = c(i), P = c(r);
|
|
20
|
+
x(() => {
|
|
21
|
+
h.current = i, P.current = r;
|
|
22
|
+
}, [i, r]);
|
|
23
|
+
const { dragHandleProps: ie, dragOffset: q } = Se(H, () => {
|
|
24
|
+
h.current("drag");
|
|
25
|
+
}, A ? () => p(!0) : void 0);
|
|
26
|
+
x(() => {
|
|
27
|
+
const e = F.current;
|
|
28
|
+
if (!r || u || !e) return;
|
|
29
|
+
const a = () => {
|
|
30
|
+
const n = e.scrollHeight > e.clientHeight + 1;
|
|
31
|
+
n && e.contains(document.activeElement) ? p(!0) : se(n);
|
|
32
|
+
};
|
|
33
|
+
a();
|
|
34
|
+
const o = new ResizeObserver(a);
|
|
35
|
+
o.observe(e);
|
|
36
|
+
for (const n of Array.from(e.children)) o.observe(n);
|
|
37
|
+
return () => o.disconnect();
|
|
38
|
+
}, [r, u]), Ee(r), be(r, d), x(() => {
|
|
39
|
+
if (!r) return;
|
|
40
|
+
const e = (o) => {
|
|
41
|
+
o.key === "Escape" && (w.current = !0, window.setTimeout(() => {
|
|
42
|
+
w.current = !1;
|
|
31
43
|
}, 0));
|
|
32
|
-
},
|
|
33
|
-
if (
|
|
34
|
-
const
|
|
35
|
-
|
|
44
|
+
}, a = (o) => {
|
|
45
|
+
if (o.key !== "Escape" || o.defaultPrevented) return;
|
|
46
|
+
const n = document.activeElement;
|
|
47
|
+
n instanceof Element && n.closest("dialog[open]") !== d.current || (o.preventDefault(), o.stopImmediatePropagation(), R(o));
|
|
36
48
|
};
|
|
37
|
-
return window.addEventListener("keydown", e, !0), window.addEventListener("keydown",
|
|
38
|
-
window.removeEventListener("keydown", e, !0), window.removeEventListener("keydown",
|
|
49
|
+
return window.addEventListener("keydown", e, !0), window.addEventListener("keydown", a), () => {
|
|
50
|
+
window.removeEventListener("keydown", e, !0), window.removeEventListener("keydown", a);
|
|
39
51
|
};
|
|
40
|
-
}, [
|
|
41
|
-
active:
|
|
42
|
-
requestClose: () =>
|
|
43
|
-
ownerRef:
|
|
44
|
-
}),
|
|
45
|
-
const e =
|
|
46
|
-
if (!
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
}),
|
|
52
|
+
}, [r]), me({
|
|
53
|
+
active: r && oe,
|
|
54
|
+
requestClose: () => h.current("escape"),
|
|
55
|
+
ownerRef: M
|
|
56
|
+
}), Re(() => {
|
|
57
|
+
const e = d.current;
|
|
58
|
+
if (!r || !e) return;
|
|
59
|
+
he();
|
|
60
|
+
const a = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
61
|
+
I.current = T?.current ?? a, e.open || e.showModal(), e.focus({ preventScroll: !0 });
|
|
62
|
+
const o = requestAnimationFrame(() => {
|
|
63
|
+
j(!0);
|
|
64
|
+
}), n = ce(e);
|
|
53
65
|
return () => {
|
|
54
|
-
cancelAnimationFrame(
|
|
55
|
-
const
|
|
56
|
-
|
|
66
|
+
cancelAnimationFrame(o), n(), j(!1), p(!1), e.open && e.close();
|
|
67
|
+
const G = I.current;
|
|
68
|
+
G?.isConnected && G.focus({
|
|
57
69
|
preventScroll: !0,
|
|
58
|
-
focusVisible:
|
|
70
|
+
focusVisible: pe()
|
|
59
71
|
});
|
|
60
72
|
};
|
|
61
|
-
}, [
|
|
62
|
-
const e =
|
|
63
|
-
if (!e || !
|
|
64
|
-
let
|
|
65
|
-
const
|
|
73
|
+
}, [r, T]), x(() => {
|
|
74
|
+
const e = d.current;
|
|
75
|
+
if (!e || !r) return;
|
|
76
|
+
let a = !1;
|
|
77
|
+
const o = () => {
|
|
66
78
|
requestAnimationFrame(() => {
|
|
67
|
-
|
|
79
|
+
a = !1, P.current && e.isConnected && !e.open && (e.showModal(), e.focus({ preventScroll: !0 }));
|
|
68
80
|
});
|
|
69
|
-
},
|
|
70
|
-
|
|
81
|
+
}, n = () => {
|
|
82
|
+
a || (a = !0, X() && R(), o());
|
|
71
83
|
};
|
|
72
|
-
return e.addEventListener("close",
|
|
73
|
-
}, [
|
|
74
|
-
const
|
|
75
|
-
if (!
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
} },
|
|
79
|
-
dataTest: `${
|
|
84
|
+
return e.addEventListener("close", n), () => e.removeEventListener("close", n);
|
|
85
|
+
}, [r]);
|
|
86
|
+
const V = ge(ve(O, Ce), y);
|
|
87
|
+
if (!r) return null;
|
|
88
|
+
const le = { close: () => {
|
|
89
|
+
i("action");
|
|
90
|
+
} }, v = (e) => typeof e == "function" ? e(le) : e, K = O !== void 0, k = L !== void 0 ? v(L) : K ? /* @__PURE__ */ t(N, {
|
|
91
|
+
dataTest: `${s}-view-results`,
|
|
80
92
|
type: "button",
|
|
81
93
|
variant: "text",
|
|
82
94
|
onClick: () => {
|
|
83
|
-
|
|
95
|
+
i("viewResults");
|
|
84
96
|
},
|
|
85
|
-
children:
|
|
86
|
-
}) : void 0,
|
|
87
|
-
return /* @__PURE__ */
|
|
88
|
-
ref:
|
|
89
|
-
id:
|
|
97
|
+
children: V
|
|
98
|
+
}) : void 0, U = v(Z), b = v(ee), S = !!(k ?? U), z = q > 0;
|
|
99
|
+
return /* @__PURE__ */ t("dialog", {
|
|
100
|
+
ref: d,
|
|
101
|
+
id: Q,
|
|
90
102
|
tabIndex: -1,
|
|
91
103
|
"aria-modal": "true",
|
|
92
|
-
"aria-labelledby": m ?
|
|
93
|
-
"aria-label": m ? void 0 :
|
|
94
|
-
"data-test":
|
|
95
|
-
"data-testid":
|
|
104
|
+
"aria-labelledby": m ? D : void 0,
|
|
105
|
+
"aria-label": m ? void 0 : Y,
|
|
106
|
+
"data-test": s,
|
|
107
|
+
"data-testid": s,
|
|
96
108
|
onCancel: (e) => {
|
|
97
|
-
if (e.cancelable && e.preventDefault(), !
|
|
98
|
-
if (!
|
|
99
|
-
|
|
109
|
+
if (e.cancelable && e.preventDefault(), !w.current) {
|
|
110
|
+
if (!X()) {
|
|
111
|
+
h.current("escape");
|
|
100
112
|
return;
|
|
101
113
|
}
|
|
102
|
-
|
|
114
|
+
R();
|
|
103
115
|
}
|
|
104
116
|
},
|
|
105
|
-
className: l(
|
|
106
|
-
children: /* @__PURE__ */
|
|
107
|
-
value:
|
|
108
|
-
children: [/* @__PURE__ */
|
|
117
|
+
className: l(ke.StyledBottomSheet, "fixed inset-0 m-0 h-full max-h-none w-full max-w-none flex-col items-center justify-end overflow-hidden border-0 bg-transparent p-0 outline-none open:flex"),
|
|
118
|
+
children: /* @__PURE__ */ f(fe.Provider, {
|
|
119
|
+
value: M,
|
|
120
|
+
children: [/* @__PURE__ */ t("div", {
|
|
109
121
|
"aria-hidden": "true",
|
|
110
|
-
"data-testid": `${
|
|
122
|
+
"data-testid": `${s}-scrim`,
|
|
111
123
|
onClick: () => {
|
|
112
|
-
|
|
124
|
+
i("scrim");
|
|
113
125
|
},
|
|
114
|
-
className: l("absolute inset-0 bg-[#626e7eb2] transition-opacity duration-[250ms] ease-out motion-reduce:duration-150",
|
|
115
|
-
}), /* @__PURE__ */
|
|
116
|
-
ref:
|
|
117
|
-
"data-state":
|
|
118
|
-
style:
|
|
119
|
-
className: l("relative box-border flex w-full max-w-[640px] flex-col border border-solid border-delta-300 bg-white text-delta-700 outline-none",
|
|
126
|
+
className: l("absolute inset-0 bg-[#626e7eb2] transition-opacity duration-[250ms] ease-out motion-reduce:duration-150", g ? "opacity-100" : "opacity-0")
|
|
127
|
+
}), /* @__PURE__ */ f("div", {
|
|
128
|
+
ref: H,
|
|
129
|
+
"data-state": g ? "open" : "closed",
|
|
130
|
+
style: z ? { transform: `translateY(${q}px)` } : void 0,
|
|
131
|
+
className: l("relative box-border flex w-full max-w-[640px] flex-col border border-solid border-delta-300 bg-white text-delta-700 outline-none", $ ? "h-full max-h-none rounded-none" : l("rounded-t-[28px]", u ? "max-h-[90dvh]" : "max-h-[50dvh]"), !z && ["ease-out motion-safe:transition-transform motion-safe:duration-[250ms] motion-reduce:transition-opacity motion-reduce:duration-150", g ? "translate-y-0 opacity-100" : "motion-safe:translate-y-full motion-reduce:opacity-0"], re),
|
|
120
132
|
children: [
|
|
121
|
-
/* @__PURE__ */
|
|
133
|
+
/* @__PURE__ */ f("div", {
|
|
122
134
|
className: "border-b-solid shrink-0 border-b border-delta-200 pb-2",
|
|
123
|
-
children: [/* @__PURE__ */
|
|
124
|
-
...
|
|
135
|
+
children: [/* @__PURE__ */ f("div", {
|
|
136
|
+
...ie,
|
|
125
137
|
className: "relative flex h-12 touch-none items-center gap-2 px-2",
|
|
126
138
|
children: [
|
|
127
|
-
/* @__PURE__ */
|
|
128
|
-
|
|
129
|
-
|
|
139
|
+
/* @__PURE__ */ t("div", {
|
|
140
|
+
className: "flex min-w-0 flex-1 items-center",
|
|
141
|
+
children: B && /* @__PURE__ */ t(N, {
|
|
142
|
+
dataTest: `${s}-back`,
|
|
143
|
+
variant: "textGray",
|
|
144
|
+
type: "button",
|
|
145
|
+
"aria-label": J ?? E.back,
|
|
146
|
+
onClick: B,
|
|
147
|
+
startIcon: /* @__PURE__ */ t(ue, {
|
|
148
|
+
width: 24,
|
|
149
|
+
height: 24
|
|
150
|
+
})
|
|
151
|
+
})
|
|
152
|
+
}),
|
|
153
|
+
A ? /* @__PURE__ */ t("button", {
|
|
154
|
+
type: "button",
|
|
155
|
+
"data-drag-handle": !0,
|
|
156
|
+
"data-testid": `${s}-drag-handle`,
|
|
157
|
+
"aria-label": u ? E.collapse : E.expand,
|
|
158
|
+
"aria-expanded": u,
|
|
159
|
+
onClick: () => {
|
|
160
|
+
p((e) => !e);
|
|
161
|
+
},
|
|
162
|
+
className: "absolute left-1/2 top-1/2 flex h-6 w-12 -translate-x-1/2 -translate-y-1/2 cursor-grab items-center justify-center rounded border-0 bg-transparent p-0 outline-none focus-visible:[box-shadow:inset_0_0_0_2px_var(--colors-focus-ring)]",
|
|
163
|
+
children: /* @__PURE__ */ t("span", {
|
|
164
|
+
"aria-hidden": "true",
|
|
165
|
+
className: "h-1 w-8 rounded-full bg-delta-700"
|
|
166
|
+
})
|
|
167
|
+
}) : /* @__PURE__ */ t("span", {
|
|
168
|
+
"aria-hidden": "true",
|
|
169
|
+
"data-testid": `${s}-drag-handle`,
|
|
170
|
+
className: "pointer-events-none absolute left-1/2 top-1/2 h-1 w-8 -translate-x-1/2 -translate-y-1/2 rounded-full bg-delta-700"
|
|
171
|
+
}),
|
|
172
|
+
/* @__PURE__ */ t(N, {
|
|
173
|
+
dataTest: `${s}-close`,
|
|
130
174
|
variant: "textGray",
|
|
131
175
|
type: "button",
|
|
132
|
-
"aria-label":
|
|
176
|
+
"aria-label": te,
|
|
133
177
|
onClick: () => {
|
|
134
|
-
|
|
178
|
+
i("closeButton");
|
|
135
179
|
},
|
|
136
|
-
startIcon: /* @__PURE__ */
|
|
180
|
+
startIcon: /* @__PURE__ */ t(de, {
|
|
137
181
|
width: 24,
|
|
138
182
|
height: 24
|
|
139
183
|
})
|
|
140
|
-
}),
|
|
141
|
-
/* @__PURE__ */ o(ee, {
|
|
142
|
-
"aria-hidden": "true",
|
|
143
|
-
focusable: "false",
|
|
144
|
-
width: 24,
|
|
145
|
-
height: 24,
|
|
146
|
-
className: "pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-delta-800"
|
|
147
184
|
})
|
|
148
185
|
]
|
|
149
|
-
}), m && /* @__PURE__ */
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
186
|
+
}), m && /* @__PURE__ */ f("div", {
|
|
187
|
+
className: "flex items-center gap-1 px-4",
|
|
188
|
+
children: [_ && /* @__PURE__ */ t("span", {
|
|
189
|
+
"aria-hidden": "true",
|
|
190
|
+
className: "flex size-5 shrink-0 items-center justify-center text-delta-700",
|
|
191
|
+
children: _
|
|
192
|
+
}), /* @__PURE__ */ t("div", {
|
|
193
|
+
id: D,
|
|
194
|
+
className: "min-w-0 flex-1 truncate text-lg font-semibold leading-7 text-delta-800",
|
|
195
|
+
children: m
|
|
196
|
+
})]
|
|
153
197
|
})]
|
|
154
198
|
}),
|
|
155
|
-
/* @__PURE__ */
|
|
156
|
-
|
|
157
|
-
|
|
199
|
+
/* @__PURE__ */ t("div", {
|
|
200
|
+
ref: F,
|
|
201
|
+
className: l("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto overscroll-contain pl-4 pr-2 pt-2", S || b ? "pb-2" : "pb-[max(0.5rem,env(safe-area-inset-bottom))]"),
|
|
202
|
+
children: v(W)
|
|
158
203
|
}),
|
|
159
|
-
|
|
160
|
-
className: l("border-t-solid flex shrink-0 items-start border-t border-delta-200 bg-white p-1",
|
|
204
|
+
S && /* @__PURE__ */ f("div", {
|
|
205
|
+
className: l("border-t-solid flex shrink-0 items-start border-t border-delta-200 bg-white p-1", k ? "justify-between" : "justify-end", "max-xs:flex-wrap max-xs:gap-y-2 max-xs:[&>:nth-child(2)]:ml-auto", !b && "pb-[max(0.25rem,env(safe-area-inset-bottom))]"),
|
|
161
206
|
children: [
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
207
|
+
k,
|
|
208
|
+
U,
|
|
209
|
+
K && /* @__PURE__ */ t("span", {
|
|
165
210
|
className: "sr-only",
|
|
166
211
|
role: "status",
|
|
167
212
|
"aria-live": "polite",
|
|
168
213
|
"aria-atomic": "true",
|
|
169
|
-
children:
|
|
214
|
+
children: V
|
|
170
215
|
})
|
|
171
216
|
]
|
|
172
217
|
}),
|
|
173
|
-
|
|
174
|
-
className: l("flex shrink-0 flex-col items-end bg-white p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]",
|
|
175
|
-
children:
|
|
218
|
+
b && /* @__PURE__ */ t("div", {
|
|
219
|
+
className: l("flex shrink-0 flex-col items-end bg-white p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]", S && "max-xs:pt-1"),
|
|
220
|
+
children: b
|
|
176
221
|
})
|
|
177
222
|
]
|
|
178
223
|
})]
|
|
@@ -180,5 +225,5 @@ var he = 500, Fe = ({ dataTest: d, id: V, open: t, onClose: a, title: m, ariaLab
|
|
|
180
225
|
});
|
|
181
226
|
};
|
|
182
227
|
export {
|
|
183
|
-
|
|
228
|
+
ze as StyledBottomSheet
|
|
184
229
|
};
|
|
@@ -9,7 +9,19 @@ var e = {
|
|
|
9
9
|
viewResults: "View results",
|
|
10
10
|
noMatches: "No matches"
|
|
11
11
|
}
|
|
12
|
+
}, s = {
|
|
13
|
+
no: {
|
|
14
|
+
expand: "Utvid",
|
|
15
|
+
collapse: "Minimer",
|
|
16
|
+
back: "Tilbake"
|
|
17
|
+
},
|
|
18
|
+
en: {
|
|
19
|
+
expand: "Expand",
|
|
20
|
+
collapse: "Minimize",
|
|
21
|
+
back: "Back"
|
|
22
|
+
}
|
|
12
23
|
};
|
|
13
24
|
export {
|
|
25
|
+
s as SHEET_HEADER_TEXT,
|
|
14
26
|
e as SHEET_TEXT
|
|
15
27
|
};
|
|
@@ -1,40 +1,46 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
var
|
|
3
|
-
const [
|
|
4
|
-
|
|
1
|
+
import { useRef as d, useState as p } from "react";
|
|
2
|
+
var f = 0.3, g = 48, l = 4, h = (i, u, c) => {
|
|
3
|
+
const [s, o] = p(0), n = d(null), a = (r, t) => {
|
|
4
|
+
const e = n.current;
|
|
5
|
+
e?.pointerId === r.pointerId && (n.current = null, r.currentTarget.hasPointerCapture(r.pointerId) && r.currentTarget.releasePointerCapture(r.pointerId), o(0), e.captured && (t > e.height * f ? u() : t < -g && c?.()));
|
|
5
6
|
};
|
|
6
7
|
return {
|
|
7
|
-
dragOffset:
|
|
8
|
+
dragOffset: s,
|
|
8
9
|
dragHandleProps: {
|
|
9
10
|
onPointerDown: (r) => {
|
|
10
|
-
if (r.pointerType === "mouse" && r.button !== 0 || r.target instanceof Element && r.target.closest("button")) return;
|
|
11
|
+
if (r.pointerType === "mouse" && r.button !== 0 || r.target instanceof Element && r.target.closest("button:not([data-drag-handle])")) return;
|
|
11
12
|
const t = i.current;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
t && (n.current = {
|
|
14
|
+
pointerId: r.pointerId,
|
|
15
|
+
startY: r.clientY,
|
|
16
|
+
height: t.getBoundingClientRect().height,
|
|
17
|
+
captured: !1
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
onPointerMove: (r) => {
|
|
21
|
+
const t = n.current;
|
|
22
|
+
if (t?.pointerId !== r.pointerId) return;
|
|
23
|
+
const e = r.clientY - t.startY;
|
|
24
|
+
if (!t.captured) {
|
|
25
|
+
if (Math.abs(e) < l) return;
|
|
26
|
+
t.captured = !0;
|
|
18
27
|
try {
|
|
19
28
|
r.currentTarget.setPointerCapture(r.pointerId);
|
|
20
29
|
} catch {
|
|
21
30
|
}
|
|
22
31
|
}
|
|
23
|
-
|
|
24
|
-
onPointerMove: (r) => {
|
|
25
|
-
const t = e.current;
|
|
26
|
-
t?.pointerId === r.pointerId && n(Math.max(0, r.clientY - t.startY));
|
|
32
|
+
o(Math.max(0, e));
|
|
27
33
|
},
|
|
28
34
|
onPointerUp: (r) => {
|
|
29
|
-
const t =
|
|
30
|
-
|
|
35
|
+
const t = n.current;
|
|
36
|
+
a(r, t ? r.clientY - t.startY : 0);
|
|
31
37
|
},
|
|
32
38
|
onPointerCancel: (r) => {
|
|
33
|
-
|
|
39
|
+
a(r, 0);
|
|
34
40
|
}
|
|
35
41
|
}
|
|
36
42
|
};
|
|
37
43
|
};
|
|
38
44
|
export {
|
|
39
|
-
|
|
45
|
+
h as useDragToDismiss
|
|
40
46
|
};
|
|
@@ -4,13 +4,13 @@ import { clampToMinTime as j, isHourDisabled as x, isMinuteDisabled as D } from
|
|
|
4
4
|
import { isHourRejected as N, isMinuteRejected as C } from "../helpers/disabledTime.js";
|
|
5
5
|
import P from "clsx";
|
|
6
6
|
import { jsx as n } from "react/jsx-runtime";
|
|
7
|
-
import { getHours as
|
|
7
|
+
import { getHours as k, getMinutes as R, set as T } from "date-fns";
|
|
8
8
|
var G = ({ type: M, value: o, onSelect: h, minTime: c, isTimeDisabled: l, disabledTimeReason: d }) => {
|
|
9
|
-
const r = /* @__PURE__ */ new Date(), t = M === "hours", m =
|
|
9
|
+
const r = /* @__PURE__ */ new Date(), t = M === "hours", m = k(o ?? r), u = o ?? r, b = t ? 24 : 12, g = t ? r.getHours() : r.getMinutes();
|
|
10
10
|
return /* @__PURE__ */ n("div", {
|
|
11
11
|
className: s["styled-time-picker-root_column"],
|
|
12
12
|
children: new Array(b).fill(null).map((z, p) => {
|
|
13
|
-
const e = t ? p : p * 5, a = o && e === (t ?
|
|
13
|
+
const e = t ? p : p * 5, a = o && e === (t ? k(o) : R(o)), f = g == e, H = t ? x(e, c) : D(m, e, c), _ = t ? N(e, u, l) : C(m, e, u, l), i = _ && !!d, w = /* @__PURE__ */ n("button", {
|
|
14
14
|
type: "button",
|
|
15
15
|
disabled: H || _ && !i,
|
|
16
16
|
"aria-disabled": i || void 0,
|
|
@@ -18,15 +18,17 @@ var G = ({ type: M, value: o, onSelect: h, minTime: c, isTimeDisabled: l, disabl
|
|
|
18
18
|
className: P("border-0", s["styled-time-picker-root_cell"], f && s["styled-time-picker-root_cell__cell-now"], a && s["styled-time-picker-root_cell__cell-selected"]),
|
|
19
19
|
onClick: () => {
|
|
20
20
|
if (i) return;
|
|
21
|
-
const
|
|
22
|
-
h(t ? j(
|
|
21
|
+
const y = T(o ?? /* @__PURE__ */ new Date(), t ? { hours: e } : { minutes: e });
|
|
22
|
+
h(t ? j(y, c) : y);
|
|
23
23
|
},
|
|
24
24
|
children: e.toString().padStart(2, "0")
|
|
25
25
|
}, e);
|
|
26
26
|
return i ? /* @__PURE__ */ n(S, {
|
|
27
27
|
title: d,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
persistentDescription: !0,
|
|
29
|
+
arrow: !0,
|
|
30
|
+
children: w
|
|
31
|
+
}, e) : w;
|
|
30
32
|
})
|
|
31
33
|
});
|
|
32
34
|
};
|
|
@@ -2,7 +2,7 @@ import { ReactNode, RefObject } from 'react';
|
|
|
2
2
|
import { UiCoreLocale } from '../../../helpers/uiCoreLocale';
|
|
3
3
|
import { PopoverSlot } from '../popover/PopoverSheet';
|
|
4
4
|
export type BottomSheetCloseReason = 'closeButton' | 'scrim' | 'escape' | 'drag' | 'viewResults' | 'action';
|
|
5
|
-
/** @figmaNode
|
|
5
|
+
/** @figmaNode rIndtQfMCi8wQ46CQ2oqsb#7-10991 (DS_draft · "_bottom sheet", approved) */
|
|
6
6
|
export interface StyledBottomSheetProps {
|
|
7
7
|
/** @figmaProp none — test hook */
|
|
8
8
|
dataTest: string;
|
|
@@ -20,6 +20,15 @@ export interface StyledBottomSheetProps {
|
|
|
20
20
|
title?: ReactNode;
|
|
21
21
|
/** @figmaProp none — a11y: the dialog's name when there is no `title` */
|
|
22
22
|
ariaLabel?: string;
|
|
23
|
+
/** @figmaProp Icon = ReactNode→true | undefined→false — the 20px icon before the title */
|
|
24
|
+
titleIcon?: ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Shows the header's back control, e.g. to return from a sub-step to the previous sheet content.
|
|
27
|
+
* @figmaProp Back = function→true | undefined→false
|
|
28
|
+
*/
|
|
29
|
+
onBack?: () => void;
|
|
30
|
+
/** @figmaProp none — a11y: accessible name of the back control; defaults to "Back" in `locale` */
|
|
31
|
+
backLabel?: string;
|
|
23
32
|
/** @figmaProp Slot — the scrollable body */
|
|
24
33
|
children: PopoverSlot;
|
|
25
34
|
/**
|
|
@@ -57,16 +66,18 @@ export interface StyledBottomSheetProps {
|
|
|
57
66
|
}
|
|
58
67
|
/**
|
|
59
68
|
* ASMA Design System **Bottom Sheet** (ASMA-8184) — the mobile (0–743px) form of the Action popover:
|
|
60
|
-
* a modal sheet with a dimmed scrim, top-rounded container,
|
|
61
|
-
* close), a body that scrolls internally and an optional sticky footer.
|
|
69
|
+
* a modal sheet with a dimmed scrim, top-rounded container, drag handle, header (optional back,
|
|
70
|
+
* close, optional icon + title), a body that scrolls internally and an optional sticky footer.
|
|
62
71
|
*
|
|
63
|
-
* Height fits the content
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
72
|
+
* Height fits the content, with no minimum, up to half the screen. A sheet whose content needs more
|
|
73
|
+
* can be expanded to 90vh — by dragging the handle up, or by activating it (Tab lands on it, Space /
|
|
74
|
+
* Enter toggle between the two heights) — and scrolls internally from there. Below 480px of viewport
|
|
75
|
+
* height (a phone in landscape) it becomes a full-screen dialog instead. Five equivalent dismiss
|
|
76
|
+
* routes — close button, "Vis resultater", scrim, Escape, dragging down past 30% — and none of them
|
|
77
|
+
* commits or discards anything: filters apply as the user goes and actions commit on activation.
|
|
67
78
|
*
|
|
68
79
|
* Interaction model is the popover's: `role="dialog"`, `Tab` only, no `role="menu"`, no arrow keys.
|
|
69
80
|
* Focus moves to the sheet on open (so the title is announced first) and back to the trigger on
|
|
70
81
|
* close. `PopoverSheet` with `variant='action'` renders this automatically below 744px.
|
|
71
82
|
*/
|
|
72
|
-
export declare const StyledBottomSheet: ({ dataTest, id, open, onClose, title, ariaLabel, children, viewResultsAction, resetAction, footerActions, resultCount, locale, closeLabel, className, registerBackClose, ownerRef, triggerRef, }: StyledBottomSheetProps) => JSX.Element | null;
|
|
83
|
+
export declare const StyledBottomSheet: ({ dataTest, id, open, onClose, title, ariaLabel, titleIcon, onBack, backLabel, children, viewResultsAction, resetAction, footerActions, resultCount, locale, closeLabel, className, registerBackClose, ownerRef, triggerRef, }: StyledBottomSheetProps) => JSX.Element | null;
|
|
@@ -9,3 +9,9 @@ export declare const SHEET_TEXT: Record<UiCoreLocale, {
|
|
|
9
9
|
viewResults: string;
|
|
10
10
|
noMatches: string;
|
|
11
11
|
}>;
|
|
12
|
+
/** Names of the sheet's header controls, worded as `MinimizableDialog`'s expand/minimize and the header's back. */
|
|
13
|
+
export declare const SHEET_HEADER_TEXT: Record<UiCoreLocale, {
|
|
14
|
+
expand: string;
|
|
15
|
+
collapse: string;
|
|
16
|
+
back: string;
|
|
17
|
+
}>;
|
|
@@ -12,11 +12,13 @@ interface DragToDismiss {
|
|
|
12
12
|
dragOffset: number;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Drag the sheet down past 30% of its height to dismiss it; release earlier and it snaps back.
|
|
15
|
+
* Drag the sheet down past 30% of its height to dismiss it; release earlier and it snaps back. Drag it
|
|
16
|
+
* up by 48px and `onDragUp` runs, which expands a sheet that has a taller height.
|
|
16
17
|
*
|
|
17
|
-
* Deliberately never the only exit (WCAG 2.5.7): the close button, the scrim
|
|
18
|
-
*
|
|
19
|
-
* so the close control keeps working as a plain click.
|
|
18
|
+
* Deliberately never the only exit or the only way to resize (WCAG 2.5.7): the close button, the scrim
|
|
19
|
+
* and Escape close it, and the drag handle toggles the height as a button. A press that starts on any
|
|
20
|
+
* other button in the drag zone is left alone, so the close control keeps working as a plain click.
|
|
21
|
+
* The pointer is captured only once it has moved, so a tap on the drag handle stays a click.
|
|
20
22
|
*/
|
|
21
|
-
export declare const useDragToDismiss: (sheetRef: RefObject<HTMLElement | null>, onDismiss: () => void) => DragToDismiss;
|
|
23
|
+
export declare const useDragToDismiss: (sheetRef: RefObject<HTMLElement | null>, onDismiss: () => void, onDragUp?: () => void) => DragToDismiss;
|
|
22
24
|
export {};
|