asma-ui-core 3.113.1 → 3.114.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/components/inputs/dynamic-select/components/DynamicInteractiveChipGroup.js +56 -59
- package/dist/components/inputs/full-screen-picker/FullScreenPicker.js +43 -42
- package/dist/components/inputs/full-screen-picker/inputModality.js +11 -0
- package/dist/src/components/inputs/dynamic-select/types.d.ts +8 -1
- package/dist/src/components/inputs/full-screen-picker/inputModality.d.ts +13 -0
- package/package.json +1 -1
|
@@ -1,110 +1,107 @@
|
|
|
1
1
|
import { cn as v } from "../../../../helpers/cn.js";
|
|
2
|
-
import { StyledTooltip as
|
|
2
|
+
import { StyledTooltip as X } from "../../../data-display/tooltip/StyledTooltip.js";
|
|
3
3
|
import { CloseIcon as j } from "../../../icons/close-icon/CloseIcon.js";
|
|
4
|
-
import { ErrorOutlineIcon as
|
|
5
|
-
import { StyledChip as
|
|
4
|
+
import { ErrorOutlineIcon as Y } from "../../../icons/error-outline-icon/ErrorOutlineIcon.js";
|
|
5
|
+
import { StyledChip as Z } from "../../../data-display/chip/StyledChip.js";
|
|
6
6
|
import { StyledInteractiveChip as O } from "../../../data-display/interactive-chip/StyledInteractiveChip.js";
|
|
7
|
-
import { StyledButton as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { DynamicSelectTitle as le } from "./DynamicSelectTitle.js";
|
|
7
|
+
import { StyledButton as _ } from "../../button/StyledButton.js";
|
|
8
|
+
import { useHelperSlot as ee } from "../../../../helpers/useHelperSlot.js";
|
|
9
|
+
import { fieldWidthStyle as te } from "../../field-styles.js";
|
|
10
|
+
import { useWrap as le } from "../helpers/useWrap.js";
|
|
11
|
+
import { DynamicSelectTitle as re } from "./DynamicSelectTitle.js";
|
|
13
12
|
import { Skeleton as N } from "../../../mui-compat/Skeleton.js";
|
|
14
|
-
import { forwardRef as
|
|
13
|
+
import { forwardRef as ae, useEffect as ie, useId as ne } from "react";
|
|
15
14
|
import { jsx as t, jsxs as S } from "react/jsx-runtime";
|
|
16
|
-
var ve =
|
|
17
|
-
const { options: d, dataTest:
|
|
18
|
-
_("DynamicInteractiveChipGroup", f, C);
|
|
19
|
-
const M = Z(f), { containerRef: m, wrapDisabled: w } = te({ dependencyList: [d, d.length] });
|
|
15
|
+
var ve = ae((V, D) => {
|
|
16
|
+
const { options: d, dataTest: z, value: r, readOnly: i, multiple: n, title: A, titleSize: L, width: T = "full", disabled: x, onChange: p, required: R, error: b, helperText: C, disableHelperText: $, valueKey: B = "value", labelKey: E = "label", renderLabel: o, getOptionTooltip: I, loading: H, size: w, locale: q = "en", clearSelectionLabel: G } = V, K = ne(), { show: W, role: F } = ee("DynamicInteractiveChipGroup", b, C, !$), { containerRef: f, wrapDisabled: y } = le({ dependencyList: [d, d.length] });
|
|
20
17
|
ie(() => {
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
const
|
|
18
|
+
f.current && (f.current.inert = !0);
|
|
19
|
+
}, [f]);
|
|
20
|
+
const m = (e) => typeof e == "object" ? e?.[E]?.toString() ?? "" : e?.toString() ?? "", g = (e) => typeof e == "object" ? e?.[B] : e, c = (e) => {
|
|
24
21
|
const l = g(e);
|
|
25
|
-
return l == null ? "" : typeof l == "string" || typeof l == "number" || typeof l == "boolean" ? String(l) : e == null ? "" :
|
|
26
|
-
}, s = (e, l) => g(e) === g(l),
|
|
22
|
+
return l == null ? "" : typeof l == "string" || typeof l == "number" || typeof l == "boolean" ? String(l) : e == null ? "" : m(e);
|
|
23
|
+
}, s = (e, l) => g(e) === g(l), J = n ? Array.isArray(r) && r.length > 0 : r != null, M = (e) => {
|
|
27
24
|
if (!n) {
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
p(
|
|
25
|
+
const a = s(e, r) ? null : e;
|
|
26
|
+
if (a === null) return;
|
|
27
|
+
p(a);
|
|
31
28
|
return;
|
|
32
29
|
}
|
|
33
30
|
const l = r ?? [];
|
|
34
|
-
p(l.find((
|
|
35
|
-
},
|
|
31
|
+
p(l.find((a) => s(a, e)) ? l.filter((a) => !s(a, e)) : [...l, e]);
|
|
32
|
+
}, u = i ? d.filter((e) => !!(n ? r?.find((l) => s(l, e)) : s(r, e))) : d, P = u.findIndex((e) => !(typeof e == "object" && e?.disabled) && !i);
|
|
36
33
|
return /* @__PURE__ */ S("div", {
|
|
37
|
-
"data-testid": `${
|
|
34
|
+
"data-testid": `${z}-dynamic-radio-group`,
|
|
38
35
|
className: "relative flex flex-col gap-y-1",
|
|
39
36
|
"data-field-width": T,
|
|
40
|
-
style:
|
|
37
|
+
style: te(T),
|
|
41
38
|
children: [
|
|
42
|
-
/* @__PURE__ */ t(
|
|
43
|
-
title:
|
|
44
|
-
titleSize:
|
|
39
|
+
/* @__PURE__ */ t(re, {
|
|
40
|
+
title: A,
|
|
41
|
+
titleSize: L
|
|
45
42
|
}),
|
|
46
43
|
/* @__PURE__ */ t("div", {
|
|
47
44
|
"aria-hidden": !0,
|
|
48
|
-
ref:
|
|
45
|
+
ref: f,
|
|
49
46
|
className: "pointer-events-none absolute left-0 top-0 flex flex-wrap gap-2 opacity-0",
|
|
50
47
|
style: { width: "100%" },
|
|
51
|
-
children:
|
|
48
|
+
children: u.map((e) => /* @__PURE__ */ t(O, {
|
|
52
49
|
className: "w-fit",
|
|
53
|
-
readOnly:
|
|
50
|
+
readOnly: i,
|
|
54
51
|
type: n ? "checkbox" : "radio",
|
|
55
52
|
dataTest: `ic-${c(e)}-hidden`,
|
|
56
|
-
label: o ? o(e) :
|
|
53
|
+
label: o ? o(e) : m(e)
|
|
57
54
|
}, c(e)))
|
|
58
55
|
}),
|
|
59
56
|
/* @__PURE__ */ t("div", {
|
|
60
|
-
className: v("flex flex-wrap gap-2",
|
|
61
|
-
children:
|
|
57
|
+
className: v("flex flex-wrap gap-2", y && "flex-col gap-1"),
|
|
58
|
+
children: H ? /* @__PURE__ */ S("div", {
|
|
62
59
|
className: "flex flex-wrap gap-2",
|
|
63
60
|
children: [
|
|
64
61
|
/* @__PURE__ */ t(N, { className: "h-[32px] w-[60px]" }),
|
|
65
62
|
/* @__PURE__ */ t(N, { className: "h-[32px] w-[60px]" }),
|
|
66
63
|
/* @__PURE__ */ t(N, { className: "h-[32px] w-[60px]" })
|
|
67
64
|
]
|
|
68
|
-
}) :
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
const
|
|
72
|
-
return /* @__PURE__ */ t(
|
|
73
|
-
title:
|
|
65
|
+
}) : u?.length ? u.map((e, l) => {
|
|
66
|
+
const a = !!(n ? r?.find((U) => s(U, e)) : s(r, e)), Q = I ? I(e) : null;
|
|
67
|
+
if (i && !a) return null;
|
|
68
|
+
const h = typeof e == "object" ? !!e?.disabled : !1, k = !h && !i && l === P ? D : void 0;
|
|
69
|
+
return /* @__PURE__ */ t(X, {
|
|
70
|
+
title: Q,
|
|
74
71
|
arrow: !0,
|
|
75
72
|
children: /* @__PURE__ */ t("span", {
|
|
76
|
-
className: v(
|
|
77
|
-
children:
|
|
73
|
+
className: v(h && "cursor-not-allowed"),
|
|
74
|
+
children: i && !y ? /* @__PURE__ */ t(Z, {
|
|
78
75
|
ref: k,
|
|
79
|
-
disabled: !!
|
|
76
|
+
disabled: !!x || h,
|
|
80
77
|
classes: { root: "min-h-[32px] h-full" },
|
|
81
78
|
className: "w-fit",
|
|
82
79
|
dataTest: `ic-${c(e)}`,
|
|
83
|
-
label: o ? o(e) :
|
|
80
|
+
label: o ? o(e) : m(e)
|
|
84
81
|
}) : /* @__PURE__ */ t(O, {
|
|
85
82
|
ref: k,
|
|
86
|
-
disabled: !!
|
|
87
|
-
classes:
|
|
83
|
+
disabled: !!x || h,
|
|
84
|
+
classes: y ? {
|
|
88
85
|
root: "border-none outline-none bg-transparent w-full flex justify-start h-full min-h-[40px] shadow-none",
|
|
89
86
|
label: "block whitespace-normal break-words overflow-visible"
|
|
90
87
|
} : { root: "min-h-[32px] h-full" },
|
|
91
88
|
className: "w-fit",
|
|
92
|
-
readOnly:
|
|
89
|
+
readOnly: i,
|
|
93
90
|
type: n ? "checkbox" : "radio",
|
|
94
91
|
dataTest: `ic-${c(e)}`,
|
|
95
|
-
checked:
|
|
96
|
-
size:
|
|
97
|
-
onClick: () =>
|
|
98
|
-
label: o ? o(e) :
|
|
92
|
+
checked: a,
|
|
93
|
+
size: w,
|
|
94
|
+
onClick: () => M(e),
|
|
95
|
+
label: o ? o(e) : m(e)
|
|
99
96
|
})
|
|
100
97
|
})
|
|
101
98
|
}, c(e));
|
|
102
99
|
}) : /* @__PURE__ */ t("span", { children: "-" })
|
|
103
100
|
}),
|
|
104
|
-
!
|
|
101
|
+
!R && J && !i && !x && /* @__PURE__ */ t(_, {
|
|
105
102
|
dataTest: "clear-selection-btn",
|
|
106
103
|
variant: "text",
|
|
107
|
-
startIcon:
|
|
104
|
+
startIcon: w === "medium" ? /* @__PURE__ */ t(j, {
|
|
108
105
|
height: 24,
|
|
109
106
|
width: 24,
|
|
110
107
|
className: "size-6"
|
|
@@ -114,15 +111,15 @@ var ve = re((V, A) => {
|
|
|
114
111
|
className: "size-5"
|
|
115
112
|
}),
|
|
116
113
|
className: "w-fit",
|
|
117
|
-
size:
|
|
114
|
+
size: w,
|
|
118
115
|
onClick: () => p(n ? [] : null),
|
|
119
116
|
children: G ?? (q === "en" ? "Clear selection" : "Fjern valget")
|
|
120
117
|
}),
|
|
121
|
-
/* @__PURE__ */ S("div", {
|
|
118
|
+
W && /* @__PURE__ */ S("div", {
|
|
122
119
|
id: K,
|
|
123
|
-
role:
|
|
124
|
-
className: v("flex min-h-[24px] items-center gap-1 pt-1 text-sm/5 text-delta-600",
|
|
125
|
-
children: [
|
|
120
|
+
role: F,
|
|
121
|
+
className: v("flex min-h-[24px] items-center gap-1 pt-1 text-sm/5 text-delta-600", b && "text-error-500"),
|
|
122
|
+
children: [b && /* @__PURE__ */ t(Y, {
|
|
126
123
|
width: 20,
|
|
127
124
|
height: 20,
|
|
128
125
|
className: "min-w-5"
|
|
@@ -1,67 +1,68 @@
|
|
|
1
|
-
import { CloseIcon as
|
|
2
|
-
import { StyledButton as
|
|
1
|
+
import { CloseIcon as w } from "../../icons/close-icon/CloseIcon.js";
|
|
2
|
+
import { StyledButton as y } from "../button/StyledButton.js";
|
|
3
3
|
import { useShortViewportMediaQuery as g } from "../../../hooks/useMediaQuery.hook.js";
|
|
4
|
-
import { StyledDialog as
|
|
4
|
+
import { StyledDialog as k } from "../../feedback/dialog/StyledDialog.js";
|
|
5
5
|
import { PickerLiveRegion as N } from "./PickerLiveRegion.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
import { isKeyboardModality as S, trackInputModality as I } from "./inputModality.js";
|
|
7
|
+
import { useVisualViewportHeight as R } from "./useVisualViewportHeight.js";
|
|
8
|
+
import { useEffect as x, useRef as p } from "react";
|
|
9
|
+
import { jsx as e, jsxs as m } from "react/jsx-runtime";
|
|
10
|
+
var B = ({ open: o, onClose: t, dataTest: i, title: r, fallbackName: a, ...n }) => {
|
|
11
|
+
const l = r != null && r !== !1 && r !== "";
|
|
12
|
+
return x(I, []), /* @__PURE__ */ e(k, {
|
|
13
|
+
open: o,
|
|
14
|
+
onClose: (f, s) => t(s),
|
|
15
|
+
dataTest: i,
|
|
15
16
|
fullScreen: !0,
|
|
16
17
|
showCloseIcon: !1,
|
|
17
|
-
ariaLabel:
|
|
18
|
-
children: /* @__PURE__ */ e(
|
|
18
|
+
ariaLabel: l ? void 0 : a,
|
|
19
|
+
children: /* @__PURE__ */ e($, {
|
|
19
20
|
...n,
|
|
20
|
-
dataTest:
|
|
21
|
-
title:
|
|
22
|
-
onClose:
|
|
21
|
+
dataTest: i,
|
|
22
|
+
title: l ? r : void 0,
|
|
23
|
+
onClose: t
|
|
23
24
|
})
|
|
24
25
|
});
|
|
25
|
-
},
|
|
26
|
-
const s = g(),
|
|
27
|
-
return
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
if (!
|
|
31
|
-
const
|
|
32
|
-
(
|
|
26
|
+
}, $ = ({ dataTest: o, title: t, closeLabel: i, search: r, headerRow: a, children: n, announcement: l, onClose: f }) => {
|
|
27
|
+
const s = g(), v = R(), c = p(null), u = p(null);
|
|
28
|
+
return x(() => {
|
|
29
|
+
const b = requestAnimationFrame(() => {
|
|
30
|
+
const h = c.current?.closest("dialog");
|
|
31
|
+
if (!h || document.activeElement !== h || !S()) return;
|
|
32
|
+
const d = u.current?.querySelector('[role="listbox"]');
|
|
33
|
+
(d && d.tabIndex >= 0 ? d : c.current)?.focus({ preventScroll: !0 });
|
|
33
34
|
});
|
|
34
|
-
return () => cancelAnimationFrame(
|
|
35
|
-
}, []), /* @__PURE__ */
|
|
35
|
+
return () => cancelAnimationFrame(b);
|
|
36
|
+
}, []), /* @__PURE__ */ m("div", {
|
|
36
37
|
className: "flex min-h-0 flex-col",
|
|
37
|
-
style: { height:
|
|
38
|
+
style: { height: v },
|
|
38
39
|
children: [
|
|
39
|
-
/* @__PURE__ */
|
|
40
|
-
"data-testid": `${
|
|
40
|
+
/* @__PURE__ */ m("div", {
|
|
41
|
+
"data-testid": `${o}-header`,
|
|
41
42
|
className: "flex shrink-0 flex-col border-0 border-b border-solid border-delta-200 bg-white",
|
|
42
43
|
children: [
|
|
43
|
-
/* @__PURE__ */
|
|
44
|
+
/* @__PURE__ */ m("div", {
|
|
44
45
|
className: "flex items-start gap-2",
|
|
45
46
|
children: [
|
|
46
|
-
|
|
47
|
+
t !== void 0 && /* @__PURE__ */ e("h2", {
|
|
47
48
|
className: "m-0 min-w-0 flex-1 break-words pl-4 pt-2 text-[20px] font-semibold leading-7 text-delta-800",
|
|
48
|
-
children:
|
|
49
|
+
children: t
|
|
49
50
|
}),
|
|
50
51
|
s && /* @__PURE__ */ e("div", {
|
|
51
52
|
className: "min-w-0 max-w-[240px] flex-1 pt-2",
|
|
52
53
|
children: r
|
|
53
54
|
}),
|
|
54
|
-
/* @__PURE__ */ e(
|
|
55
|
-
dataTest: `${
|
|
55
|
+
/* @__PURE__ */ e(y, {
|
|
56
|
+
dataTest: `${o}-close`,
|
|
56
57
|
refLink: c,
|
|
57
|
-
"aria-label":
|
|
58
|
+
"aria-label": i,
|
|
58
59
|
variant: "textGray",
|
|
59
|
-
startIcon: /* @__PURE__ */ e(
|
|
60
|
+
startIcon: /* @__PURE__ */ e(w, {
|
|
60
61
|
width: 24,
|
|
61
62
|
height: 24
|
|
62
63
|
}),
|
|
63
64
|
className: "ml-auto h-10 w-10 min-w-10 shrink-0 px-0",
|
|
64
|
-
onClick: () =>
|
|
65
|
+
onClick: () => f("closeButton")
|
|
65
66
|
})
|
|
66
67
|
]
|
|
67
68
|
}),
|
|
@@ -77,17 +78,17 @@ var q = ({ open: i, onClose: l, dataTest: o, title: r, fallbackName: a, ...n })
|
|
|
77
78
|
}),
|
|
78
79
|
/* @__PURE__ */ e("div", {
|
|
79
80
|
ref: u,
|
|
80
|
-
"data-testid": `${
|
|
81
|
+
"data-testid": `${o}-body`,
|
|
81
82
|
className: "flex min-h-0 flex-1 flex-col overflow-y-auto px-4",
|
|
82
83
|
children: n
|
|
83
84
|
}),
|
|
84
85
|
/* @__PURE__ */ e(N, {
|
|
85
|
-
announcement:
|
|
86
|
-
dataTest: `${
|
|
86
|
+
announcement: l,
|
|
87
|
+
dataTest: `${o}-live`
|
|
87
88
|
})
|
|
88
89
|
]
|
|
89
90
|
});
|
|
90
91
|
};
|
|
91
92
|
export {
|
|
92
|
-
|
|
93
|
+
B as FullScreenPicker
|
|
93
94
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var t = !1, r = !1, a = () => {
|
|
2
|
+
r || typeof document > "u" || (r = !0, document.addEventListener("keydown", (e) => {
|
|
3
|
+
e.isTrusted && !e.metaKey && !e.ctrlKey && !e.altKey && (t = !0);
|
|
4
|
+
}, !0), document.addEventListener("pointerdown", (e) => {
|
|
5
|
+
e.isTrusted && (t = !1);
|
|
6
|
+
}, !0));
|
|
7
|
+
}, d = () => t;
|
|
8
|
+
export {
|
|
9
|
+
d as isKeyboardModality,
|
|
10
|
+
a as trackInputModality
|
|
11
|
+
};
|
|
@@ -67,7 +67,14 @@ interface DynamicSelectCommonProps<TOption extends DynamicSelectOption> {
|
|
|
67
67
|
*/
|
|
68
68
|
required?: boolean;
|
|
69
69
|
helperText?: React.ReactNode;
|
|
70
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Stops the helper row being *reserved* below the control. A real `helperText` or an `error` still
|
|
72
|
+
* renders it, growing the layout at that moment — so nothing is silently swallowed.
|
|
73
|
+
*
|
|
74
|
+
* On the autocomplete variant it removes the block outright, which is what it has always done
|
|
75
|
+
* there. On the chip-group variant (1–5 options) it opts out of a 28px row that would otherwise
|
|
76
|
+
* sit empty under the chips.
|
|
77
|
+
*/
|
|
71
78
|
disableHelperText?: boolean;
|
|
72
79
|
/**
|
|
73
80
|
* Key of `TOption` used as the option's identity for comparison and as the chip/tag key.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Starts tracking, once per page, whether the user's last action was a key press or a pointer press
|
|
3
|
+
* (mouse, pen, touch). Capture phase, so it sees the press that opens a picker before anything
|
|
4
|
+
* handles it. Only trusted events count: a script's synthetic events say nothing about the user.
|
|
5
|
+
*
|
|
6
|
+
* Why not `:focus-visible`: when a picker opens, `StyledDialog` moves focus from the field to its own
|
|
7
|
+
* shell, and a browser lets a scripted focus move inherit the field's focus-visible state. A text
|
|
8
|
+
* field is always focus-visible, so a tap on a field that already had focus (after an earlier choice)
|
|
9
|
+
* read as keyboard and put the active-row marker in the list (ASMA-8468).
|
|
10
|
+
*/
|
|
11
|
+
export declare const trackInputModality: () => void;
|
|
12
|
+
/** The user's last action was a key press (see {@link trackInputModality}). */
|
|
13
|
+
export declare const isKeyboardModality: () => boolean;
|