asma-ui-core 3.101.0 → 3.101.2
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/inputs/dynamic-select/components/DynamicSelectReadOnlyValue.js +6 -7
- package/dist/components/utils/popover/PopoverAnatomy.js +49 -42
- package/dist/components/utils/popover/useScrollGutter.js +33 -0
- package/dist/src/components/inputs/dynamic-select/components/DynamicSelectReadOnlyValue.d.ts +5 -4
- package/dist/src/components/utils/popover/useScrollGutter.d.ts +19 -0
- package/package.json +1 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return /* @__PURE__ */ x("div", {
|
|
1
|
+
import { jsx as d, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
var m = ({ dataTest: a, options: c, value: t, title: n, valueKey: i = "value", labelKey: o = "label", renderLabel: r }) => {
|
|
3
|
+
const s = (e) => typeof e == "object" ? e?.[i] : e, f = (e) => typeof e == "object" ? e?.[o]?.toString() ?? "" : e?.toString() ?? "", l = t == null ? null : c.find((e) => s(e) === s(t)) ?? t;
|
|
4
|
+
return /* @__PURE__ */ u("div", {
|
|
6
5
|
"data-testid": `${a}-read-only`,
|
|
7
6
|
className: "flex flex-col gap-y-1",
|
|
8
7
|
children: [n && /* @__PURE__ */ d("span", {
|
|
@@ -10,11 +9,11 @@ var g = ({ dataTest: a, options: c, value: t, title: n, size: i = "medium", valu
|
|
|
10
9
|
children: n
|
|
11
10
|
}), /* @__PURE__ */ d("div", {
|
|
12
11
|
"data-testid": `${a}-read-only-value`,
|
|
13
|
-
className:
|
|
12
|
+
className: "text-base/6 text-delta-700",
|
|
14
13
|
children: l === null ? "-" : r ? r(l) : f(l)
|
|
15
14
|
})]
|
|
16
15
|
});
|
|
17
16
|
};
|
|
18
17
|
export {
|
|
19
|
-
|
|
18
|
+
m as DynamicSelectReadOnlyValue
|
|
20
19
|
};
|
|
@@ -1,46 +1,53 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { CloseIcon as
|
|
3
|
-
import { StyledButton as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
import { cn as n } from "../../../helpers/cn.js";
|
|
2
|
+
import { CloseIcon as c } from "../../icons/close-icon/CloseIcon.js";
|
|
3
|
+
import { StyledButton as h } from "../../inputs/button/StyledButton.js";
|
|
4
|
+
import { useScrollGutter as u } from "./useScrollGutter.js";
|
|
5
|
+
import { useRef as v } from "react";
|
|
6
|
+
import { Fragment as g, jsx as e, jsxs as r } from "react/jsx-runtime";
|
|
7
|
+
var _ = 40, j = "box-border flex flex-col overflow-hidden rounded-lg bg-white text-delta-700 outline-none shadow-[inset_0_0_0_1px_var(--colors-delta-300),0px_4px_40px_0px_#22213366]", k = ({ dataTest: d, title: t, titleId: m, children: f, viewResultsAction: l, resetAction: a, footerActions: o, closeLabel: p, onClose: x }) => {
|
|
8
|
+
const i = v(null), s = u(i);
|
|
9
|
+
return /* @__PURE__ */ r(g, { children: [
|
|
10
|
+
/* @__PURE__ */ r("div", {
|
|
11
|
+
className: "relative flex min-h-0 flex-1 flex-col",
|
|
12
|
+
children: [
|
|
13
|
+
t && /* @__PURE__ */ e("div", {
|
|
14
|
+
id: m,
|
|
15
|
+
className: "shrink-0 truncate pb-1 pl-4 pr-10 pt-2 text-lg font-semibold leading-7 text-delta-800",
|
|
16
|
+
children: t
|
|
17
|
+
}),
|
|
18
|
+
/* @__PURE__ */ e("div", {
|
|
19
|
+
ref: i,
|
|
20
|
+
className: n("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto py-2 pl-4 [scrollbar-gutter:stable]", !t && s.overflows && "mt-10"),
|
|
21
|
+
style: { paddingRight: Math.max(0, _ - s.width) },
|
|
22
|
+
children: f
|
|
23
|
+
}),
|
|
24
|
+
/* @__PURE__ */ e("div", {
|
|
25
|
+
className: "absolute right-0 top-0",
|
|
26
|
+
children: /* @__PURE__ */ e(h, {
|
|
27
|
+
dataTest: `${d}-close`,
|
|
28
|
+
variant: "textGray",
|
|
29
|
+
type: "button",
|
|
30
|
+
"aria-label": p,
|
|
31
|
+
onClick: x,
|
|
32
|
+
startIcon: /* @__PURE__ */ e(c, {
|
|
33
|
+
width: 24,
|
|
34
|
+
height: 24
|
|
35
|
+
})
|
|
29
36
|
})
|
|
30
37
|
})
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
})
|
|
42
|
-
|
|
38
|
+
]
|
|
39
|
+
}),
|
|
40
|
+
(l ?? a) && /* @__PURE__ */ r("div", {
|
|
41
|
+
className: n("flex shrink-0 items-start p-1", l ? "justify-between" : "justify-end"),
|
|
42
|
+
children: [l, a]
|
|
43
|
+
}),
|
|
44
|
+
o && /* @__PURE__ */ e("div", {
|
|
45
|
+
className: "flex shrink-0 flex-col items-end p-3",
|
|
46
|
+
children: o
|
|
47
|
+
})
|
|
48
|
+
] });
|
|
49
|
+
};
|
|
43
50
|
export {
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
j as POPOVER_SURFACE_CLASSNAME,
|
|
52
|
+
k as PopoverAnatomy
|
|
46
53
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useLayoutEffect as v, useState as l } from "react";
|
|
2
|
+
var w = {
|
|
3
|
+
width: 0,
|
|
4
|
+
overflows: !1
|
|
5
|
+
}, h = (s) => {
|
|
6
|
+
const [f, u] = l(w);
|
|
7
|
+
return v(() => {
|
|
8
|
+
const e = s.current;
|
|
9
|
+
if (!e) return;
|
|
10
|
+
const t = () => {
|
|
11
|
+
const r = e.offsetWidth - e.clientWidth, d = e.scrollHeight > e.clientHeight;
|
|
12
|
+
u((n) => n.width === r && n.overflows === d ? n : {
|
|
13
|
+
width: r,
|
|
14
|
+
overflows: d
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
if (t(), typeof ResizeObserver > "u" || typeof MutationObserver > "u") return;
|
|
18
|
+
const o = new ResizeObserver(t), i = () => {
|
|
19
|
+
o.observe(e);
|
|
20
|
+
for (const r of Array.from(e.children)) o.observe(r);
|
|
21
|
+
};
|
|
22
|
+
i();
|
|
23
|
+
const c = new MutationObserver(() => {
|
|
24
|
+
i(), t();
|
|
25
|
+
});
|
|
26
|
+
return c.observe(e, { childList: !0 }), window.addEventListener("resize", t), () => {
|
|
27
|
+
o.disconnect(), c.disconnect(), window.removeEventListener("resize", t);
|
|
28
|
+
};
|
|
29
|
+
}, [s]), f;
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
h as useScrollGutter
|
|
33
|
+
};
|
package/dist/src/components/inputs/dynamic-select/components/DynamicSelectReadOnlyValue.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DynamicSelectOption, StyledDynamicSelectProps } from '../types';
|
|
2
|
-
type DynamicSelectReadOnlyValueProps<TOption extends DynamicSelectOption> = Pick<StyledDynamicSelectProps<TOption>, 'dataTest' | 'options' | 'title' | '
|
|
2
|
+
type DynamicSelectReadOnlyValueProps<TOption extends DynamicSelectOption> = Pick<StyledDynamicSelectProps<TOption>, 'dataTest' | 'options' | 'title' | 'valueKey' | 'labelKey' | 'renderLabel'> & {
|
|
3
3
|
value: TOption | null;
|
|
4
4
|
};
|
|
5
5
|
/**
|
|
@@ -7,8 +7,9 @@ type DynamicSelectReadOnlyValueProps<TOption extends DynamicSelectOption> = Pick
|
|
|
7
7
|
* input field, no helper/error row (there is nothing to validate). Applies whatever the option
|
|
8
8
|
* count, so the ≤5 chip variant and the 6+ autocomplete variant read the same.
|
|
9
9
|
*
|
|
10
|
-
* Text = Body Base 16/24 `text-icon/body` (delta-700)
|
|
11
|
-
* same placeholder the chip variant shows.
|
|
10
|
+
* Text = Body Base 16/24 `text-icon/body` (delta-700) at every `size`: `size` scales chips and
|
|
11
|
+
* buttons, and read-only draws neither. No value → `-`, the same placeholder the chip variant shows.
|
|
12
|
+
* Multiple selects never reach this component.
|
|
12
13
|
*/
|
|
13
|
-
export declare const DynamicSelectReadOnlyValue: <TOption extends DynamicSelectOption>({ dataTest, options, value, title,
|
|
14
|
+
export declare const DynamicSelectReadOnlyValue: <TOption extends DynamicSelectOption>({ dataTest, options, value, title, valueKey, labelKey, renderLabel, }: DynamicSelectReadOnlyValueProps<TOption>) => JSX.Element;
|
|
14
15
|
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
export interface ScrollGutter {
|
|
3
|
+
/** Layout width the scrollbar takes: 15-17px for a classic bar, 0 for an overlay one. */
|
|
4
|
+
width: number;
|
|
5
|
+
/** The content is taller than the scroll container. */
|
|
6
|
+
overflows: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Measures a scroll container's scrollbar gutter and whether it overflows, and keeps both current.
|
|
10
|
+
*
|
|
11
|
+
* Meant for a container with `scrollbar-gutter: stable`: its gutter is then reserved whether or not it
|
|
12
|
+
* scrolls, so `width` is a property of the platform (and zoom), not of the content — padding derived
|
|
13
|
+
* from it cannot oscillate as scrolling starts and stops. Re-measured on its own resize, on any direct
|
|
14
|
+
* child's resize (content growing inside a container already at max-height does not resize it), when
|
|
15
|
+
* children are added or removed, and on window resize, which also catches browser zoom.
|
|
16
|
+
*
|
|
17
|
+
* Measured in a layout effect, so the corrected layout is in place before the first paint.
|
|
18
|
+
*/
|
|
19
|
+
export declare const useScrollGutter: (ref: RefObject<HTMLElement | null>) => ScrollGutter;
|