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.
@@ -1,8 +1,7 @@
1
- import { cn as u } from "../../../../helpers/cn.js";
2
- import { jsx as d, jsxs as x } from "react/jsx-runtime";
3
- var g = ({ dataTest: a, options: c, value: t, title: n, size: i = "medium", valueKey: o = "value", labelKey: m = "label", renderLabel: r }) => {
4
- const s = (e) => typeof e == "object" ? e?.[o] : e, f = (e) => typeof e == "object" ? e?.[m]?.toString() ?? "" : e?.toString() ?? "", l = t == null ? null : c.find((e) => s(e) === s(t)) ?? t;
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: u("text-delta-700", i === "small" ? "text-sm/5" : "text-base/6"),
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
- g as DynamicSelectReadOnlyValue
18
+ m as DynamicSelectReadOnlyValue
20
19
  };
@@ -1,46 +1,53 @@
1
- import { cn as p } from "../../../helpers/cn.js";
2
- import { CloseIcon as m } from "../../icons/close-icon/CloseIcon.js";
3
- import { StyledButton as c } from "../../inputs/button/StyledButton.js";
4
- import { Fragment as f, jsx as e, jsxs as t } from "react/jsx-runtime";
5
- var g = "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]", y = ({ dataTest: i, title: a, titleId: d, children: n, viewResultsAction: l, resetAction: r, footerActions: o, closeLabel: s, onClose: x }) => /* @__PURE__ */ t(f, { children: [
6
- /* @__PURE__ */ t("div", {
7
- className: "relative flex min-h-0 flex-1 flex-col",
8
- children: [
9
- a && /* @__PURE__ */ e("div", {
10
- id: d,
11
- className: "shrink-0 truncate pb-1 pl-4 pr-10 pt-2 text-lg font-semibold leading-7 text-delta-800",
12
- children: a
13
- }),
14
- /* @__PURE__ */ e("div", {
15
- className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto py-2 pl-4 pr-10",
16
- children: n
17
- }),
18
- /* @__PURE__ */ e("div", {
19
- className: "absolute right-0 top-0",
20
- children: /* @__PURE__ */ e(c, {
21
- dataTest: `${i}-close`,
22
- variant: "textGray",
23
- type: "button",
24
- "aria-label": s,
25
- onClick: x,
26
- startIcon: /* @__PURE__ */ e(m, {
27
- width: 24,
28
- height: 24
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
- (l ?? r) && /* @__PURE__ */ t("div", {
35
- className: p("flex shrink-0 items-start p-1", l ? "justify-between" : "justify-end"),
36
- children: [l, r]
37
- }),
38
- o && /* @__PURE__ */ e("div", {
39
- className: "flex shrink-0 flex-col items-end p-3",
40
- children: o
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
- g as POPOVER_SURFACE_CLASSNAME,
45
- y as PopoverAnatomy
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
+ };
@@ -1,5 +1,5 @@
1
1
  import { DynamicSelectOption, StyledDynamicSelectProps } from '../types';
2
- type DynamicSelectReadOnlyValueProps<TOption extends DynamicSelectOption> = Pick<StyledDynamicSelectProps<TOption>, 'dataTest' | 'options' | 'title' | 'size' | 'valueKey' | 'labelKey' | 'renderLabel'> & {
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); 14/20 at `size='small'`. No value → `-`, the
11
- * same placeholder the chip variant shows. Multiple selects never reach this component.
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, size, valueKey, labelKey, renderLabel, }: DynamicSelectReadOnlyValueProps<TOption>) => JSX.Element;
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;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.101.0",
6
+ "version": "3.101.2",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",