@stenajs-webui/core 23.2.0 → 23.3.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.
@@ -2,8 +2,14 @@ import * as React from "react";
2
2
  import { BoxProps } from "../layout/box/Box";
3
3
  export interface BlockKeyboardEventsProps extends BoxProps {
4
4
  /**
5
- * Key or keys that will be blocked. If not set, all keys are blocked.
5
+ * Key or keys that will be blocked from bubbling to parents.
6
+ * If not set, all keys are blocked from bubbling.
6
7
  */
7
8
  blockedKeys?: string | Array<string>;
9
+ /**
10
+ * Whether to also block mouse events from bubbling.
11
+ * Default: false
12
+ */
13
+ blockMouse?: boolean;
8
14
  }
9
15
  export declare const BlockKeyboardEvents: React.FC<BlockKeyboardEventsProps>;
package/dist/index.es.js CHANGED
@@ -1,12 +1,12 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._separatorLine_nzfcz_1{display:flex;border:0;margin:0;flex:none}._visuallyHidden_1gevf_1{border:0;clip:rect(0 0 0 0);height:1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}._text_1iisw_1{--swui-text-color: var(--swui-text-primary-color);--swui-text-color-caption: var(--lhds-color-ui-600);--swui-text-color-overline: var(--lhds-color-ui-600);--swui-text-font-family: var(--swui-font-primary);--swui-text-font-weight: var(--swui-font-weight-text);--current-color: var(--swui-text-color);--current-font-size: var(--swui-font-size-medium);--current-line-height: var(--swui-line-height-medium);--current-font-weight: var(--swui-text-font-weight);--current-letter-spacing: var(--swui-text-letter-spacing);font-size:var(--current-font-size);line-height:var(--current-line-height);color:var(--current-color);letter-spacing:var(--current-letter-spacing);font-family:var(--swui-text-font-family);font-weight:var(--current-font-weight)}._text_1iisw_1._bold_1iisw_27{--current-font-weight: var(--swui-font-weight-text-bold)}._text_1iisw_1._caption_1iisw_31{--current-font-size: var(--swui-font-size-small);--current-line-height: var(--swui-line-height-small);--current-color: var(--swui-text-color-caption);--current-letter-spacing: 0;font-style:italic}._text_1iisw_1._overline_1iisw_39{--current-font-size: var(--swui-font-size-smaller);--current-line-height: var(--swui-line-height-smaller);--current-color: var(--swui-text-color-overline);--current-font-weight: var(--swui-font-weight-text-bold);--current-letter-spacing: .1rem;text-transform:uppercase}._text_1iisw_1._large_1iisw_48{--current-font-size: var(--swui-font-size-large);--current-line-height: var(--swui-line-height-large)}._text_1iisw_1._medium_1iisw_53{--current-font-size: var(--swui-font-size-medium);--current-line-height: var(--swui-line-height-medium)}._text_1iisw_1._small_1iisw_58{--current-font-size: var(--swui-font-size-small);--current-line-height: var(--swui-line-height-small)}._text_1iisw_1._smaller_1iisw_63{--current-font-size: var(--swui-font-size-smaller);--current-line-height: var(--swui-line-height-smaller)}._heading_1cnsg_1{font-size:2rem;color:var(--swui-text-primary-color);letter-spacing:0;margin:0;line-height:var(--swui-line-height);font-family:var(--swui-font-primary);font-weight:var(--swui-font-weight-text-bold)}._heading_1cnsg_1._h1_1cnsg_10{font-size:2.8rem}._heading_1cnsg_1._h2_1cnsg_14{font-size:2.4rem}._heading_1cnsg_1._h3_1cnsg_18{font-size:2rem}._heading_1cnsg_1._h4_1cnsg_22{font-size:1.8rem}._heading_1cnsg_1._h5_1cnsg_26{font-size:1.6rem}._heading_1cnsg_1._h6_1cnsg_30{font-size:1.4rem}")),document.head.appendChild(e)}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}})();
2
2
  import { cssColor as N } from "@stenajs-webui/theme";
3
3
  import { jsx as c, Fragment as T, jsxs as U } from "react/jsx-runtime";
4
- import V, { forwardRef as f, useState as h, useCallback as m, useLayoutEffect as F, useRef as g, createContext as j, useEffect as p, useMemo as S, useContext as q, isValidElement as B, Fragment as W } from "react";
4
+ import V, { forwardRef as f, useState as h, useCallback as m, useLayoutEffect as F, useRef as g, createContext as B, useEffect as p, useMemo as S, useContext as j, isValidElement as q, Fragment as W } from "react";
5
5
  import E from "@emotion/styled";
6
6
  import { system as X, background as G, border as Y, borderRight as K, borderLeft as Z, borderTop as J, borderBottom as Q, borderColor as ee, borderRadius as te, borderStyle as re, borderWidth as ne, boxShadow as ue, flexbox as oe, overflow as se, position as ie, layout as ae, zIndex as ce, left as le, right as de, top as pe, bottom as me } from "styled-system";
7
7
  import { memoize as he, pickBy as P, debounce as fe } from "lodash-es";
8
8
  import O from "classnames";
9
- const ge = "_separatorLine_nzfcz_1", ve = {
9
+ const ge = "_separatorLine_nzfcz_1", ye = {
10
10
  separatorLine: ge
11
11
  }, lt = f(
12
12
  ({
@@ -17,7 +17,7 @@ const ge = "_separatorLine_nzfcz_1", ve = {
17
17
  }, u) => /* @__PURE__ */ c(
18
18
  "hr",
19
19
  {
20
- className: ve.separatorLine,
20
+ className: ye.separatorLine,
21
21
  "aria-hidden": !0,
22
22
  color: e,
23
23
  style: {
@@ -28,7 +28,7 @@ const ge = "_separatorLine_nzfcz_1", ve = {
28
28
  ref: u
29
29
  }
30
30
  )
31
- ), ye = E.button`
31
+ ), ve = E.button`
32
32
  display: inline-block;
33
33
  user-select: none;
34
34
  border: 0;
@@ -64,11 +64,11 @@ const ge = "_separatorLine_nzfcz_1", ve = {
64
64
  children: i,
65
65
  background: l = "transparent",
66
66
  hoverBackground: d,
67
- focusBackground: v,
67
+ focusBackground: y,
68
68
  type: k = "button",
69
69
  ..._
70
- }, H) => /* @__PURE__ */ c(
71
- ye,
70
+ }, D) => /* @__PURE__ */ c(
71
+ ve,
72
72
  {
73
73
  opacityOnHover: s,
74
74
  title: n,
@@ -78,10 +78,10 @@ const ge = "_separatorLine_nzfcz_1", ve = {
78
78
  onDoubleClick: r,
79
79
  disableFocusHighlight: e,
80
80
  pointer: !!(t || r) && !o,
81
- ref: H,
81
+ ref: D,
82
82
  background: l,
83
83
  hoverBackground: d,
84
- focusBackground: v,
84
+ focusBackground: y,
85
85
  type: k,
86
86
  ..._,
87
87
  children: i
@@ -721,12 +721,12 @@ const ge = "_separatorLine_nzfcz_1", ve = {
721
721
  function({ num: t = 1, ...r }, n) {
722
722
  return /* @__PURE__ */ c(b, { spacing: t, ref: n, ...r });
723
723
  }
724
- ), Le = E.div`
724
+ ), Ae = E.div`
725
725
  --current-size: 1;
726
726
  flex: none;
727
727
  width: calc(var(--current-size) * var(--swui-metrics-space));
728
728
  height: calc(var(--current-size) * var(--swui-metrics-space));
729
- `, vt = ({
729
+ `, yt = ({
730
730
  half: e = !1,
731
731
  horizontal: t = !1,
732
732
  num: r = 1,
@@ -734,7 +734,7 @@ const ge = "_separatorLine_nzfcz_1", ve = {
734
734
  }) => {
735
735
  const u = r * (e ? 0.5 : 1);
736
736
  return /* @__PURE__ */ c(
737
- Le,
737
+ Ae,
738
738
  {
739
739
  style: {
740
740
  "--current-size": u,
@@ -743,7 +743,7 @@ const ge = "_separatorLine_nzfcz_1", ve = {
743
743
  }
744
744
  }
745
745
  );
746
- }, yt = ({ children: e, nest: t, render: r }) => t ? /* @__PURE__ */ c(T, { children: r(e) }) : /* @__PURE__ */ c(T, { children: e }), D = j({
746
+ }, vt = ({ children: e, nest: t, render: r }) => t ? /* @__PURE__ */ c(T, { children: r(e) }) : /* @__PURE__ */ c(T, { children: e }), H = B({
747
747
  isFontLarge: !1,
748
748
  fontSizeRatio: 1
749
749
  }), R = 12, bt = ({ children: e }) => {
@@ -763,7 +763,7 @@ const ge = "_separatorLine_nzfcz_1", ve = {
763
763
  () => ({ isFontLarge: r, fontSizeRatio: u }),
764
764
  [u, r]
765
765
  );
766
- return /* @__PURE__ */ U(D.Provider, { value: s, children: [
766
+ return /* @__PURE__ */ U(H.Provider, { value: s, children: [
767
767
  /* @__PURE__ */ c(
768
768
  "div",
769
769
  {
@@ -783,26 +783,26 @@ const ge = "_separatorLine_nzfcz_1", ve = {
783
783
  e
784
784
  ] });
785
785
  }, wt = () => {
786
- const e = q(D);
786
+ const e = j(H);
787
787
  return e || {
788
788
  isFontLarge: !1,
789
789
  fontSizeRatio: 1
790
790
  };
791
- }, Ae = "_visuallyHidden_1gevf_1", Me = {
792
- visuallyHidden: Ae
791
+ }, Le = "_visuallyHidden_1gevf_1", Me = {
792
+ visuallyHidden: Le
793
793
  }, ze = (e) => P(e, Fe), xt = (e) => P(e, Pe), Fe = (e, t) => t.startsWith("data-") || t.startsWith("aria-"), Pe = (e, t) => t.startsWith("aria-"), kt = ({
794
794
  children: e,
795
795
  ...t
796
- }) => /* @__PURE__ */ c("span", { className: Me.visuallyHidden, ...ze(t), children: e }), Oe = "_text_1iisw_1", De = "_standard_1iisw_24", He = "_bold_1iisw_27", Ne = "_caption_1iisw_31", Ue = "_overline_1iisw_39", Ve = "_large_1iisw_48", je = "_medium_1iisw_53", qe = "_small_1iisw_58", Be = "_smaller_1iisw_63", $ = {
796
+ }) => /* @__PURE__ */ c("span", { className: Me.visuallyHidden, ...ze(t), children: e }), Oe = "_text_1iisw_1", He = "_standard_1iisw_24", De = "_bold_1iisw_27", Ne = "_caption_1iisw_31", Ue = "_overline_1iisw_39", Ve = "_large_1iisw_48", Be = "_medium_1iisw_53", je = "_small_1iisw_58", qe = "_smaller_1iisw_63", $ = {
797
797
  text: Oe,
798
- standard: De,
799
- bold: He,
798
+ standard: He,
799
+ bold: De,
800
800
  caption: Ne,
801
801
  overline: Ue,
802
802
  large: Ve,
803
- medium: je,
804
- small: qe,
805
- smaller: Be
803
+ medium: Be,
804
+ small: je,
805
+ smaller: qe
806
806
  }, w = f(
807
807
  ({
808
808
  children: e,
@@ -816,7 +816,7 @@ const ge = "_separatorLine_nzfcz_1", ve = {
816
816
  textAlign: i = "left",
817
817
  overflow: l,
818
818
  textOverflow: d,
819
- style: v,
819
+ style: y,
820
820
  ...k
821
821
  }, _) => /* @__PURE__ */ c(
822
822
  "span",
@@ -831,13 +831,13 @@ const ge = "_separatorLine_nzfcz_1", ve = {
831
831
  textAlign: i,
832
832
  overflow: l,
833
833
  textOverflow: d,
834
- ...v
834
+ ...y
835
835
  },
836
836
  ...k,
837
837
  children: e
838
838
  }
839
839
  )
840
- ), _t = w, $t = (e) => /* @__PURE__ */ c(w, { size: "small", ...e }), St = (e) => /* @__PURE__ */ c(w, { size: "smaller", ...e }), Et = (e) => /* @__PURE__ */ c(w, { size: "medium", ...e }), Ct = (e) => /* @__PURE__ */ c(w, { size: "large", ...e }), We = "_heading_1cnsg_1", Xe = "_h1_1cnsg_10", Ge = "_h2_1cnsg_14", Ye = "_h3_1cnsg_18", Ke = "_h4_1cnsg_22", Ze = "_h5_1cnsg_26", Je = "_h6_1cnsg_30", L = {
840
+ ), _t = w, $t = (e) => /* @__PURE__ */ c(w, { size: "small", ...e }), St = (e) => /* @__PURE__ */ c(w, { size: "smaller", ...e }), Et = (e) => /* @__PURE__ */ c(w, { size: "medium", ...e }), Ct = (e) => /* @__PURE__ */ c(w, { size: "large", ...e }), We = "_heading_1cnsg_1", Xe = "_h1_1cnsg_10", Ge = "_h2_1cnsg_14", Ye = "_h3_1cnsg_18", Ke = "_h4_1cnsg_22", Ze = "_h5_1cnsg_26", Je = "_h6_1cnsg_30", A = {
841
841
  heading: We,
842
842
  h1: Xe,
843
843
  h2: Ge,
@@ -859,7 +859,7 @@ const ge = "_separatorLine_nzfcz_1", ve = {
859
859
  }, l) => /* @__PURE__ */ c(
860
860
  a ?? e,
861
861
  {
862
- className: O(L.heading, L[e], t),
862
+ className: O(A.heading, A[e], t),
863
863
  style: { color: r, whiteSpace: n, wordBreak: u, ...o },
864
864
  ref: l,
865
865
  ...i,
@@ -868,24 +868,28 @@ const ge = "_separatorLine_nzfcz_1", ve = {
868
868
  )
869
869
  ), Tt = (e) => /* @__PURE__ */ c(Qe, { variant: "h2", ...e }), It = ({
870
870
  blockedKeys: e,
871
- ...t
871
+ blockMouse: t = !1,
872
+ ...r
872
873
  }) => {
873
- const r = m(
874
- (u) => {
875
- (e == null || e.includes(u.key)) && (u.stopPropagation(), u.preventDefault());
874
+ const n = m(
875
+ (o) => {
876
+ (e == null || (Array.isArray(e) ? e.includes(o.key) : e === o.key)) && o.stopPropagation();
876
877
  },
877
878
  [e]
878
- ), n = m((u) => {
879
- u.stopPropagation(), u.preventDefault();
880
- }, []);
879
+ ), u = m(
880
+ (o) => {
881
+ t && o.stopPropagation();
882
+ },
883
+ [t]
884
+ );
881
885
  return /* @__PURE__ */ c(
882
886
  b,
883
887
  {
884
- ...t,
885
- onKeyDown: r,
886
- onKeyUp: r,
887
- onMouseDown: n,
888
- onMouseUp: n
888
+ ...r,
889
+ onKeyDown: n,
890
+ onKeyUp: n,
891
+ onMouseDown: u,
892
+ onMouseUp: u
889
893
  }
890
894
  );
891
895
  }, et = (e, t) => e === t, Rt = (e, t, r = et) => {
@@ -897,14 +901,14 @@ const ge = "_separatorLine_nzfcz_1", ve = {
897
901
  ), u = m(
898
902
  (i) => {
899
903
  t(
900
- i.reduce((l, d) => l.some((v) => r(v, d)) ? l : [...l, d], e)
904
+ i.reduce((l, d) => l.some((y) => r(y, d)) ? l : [...l, d], e)
901
905
  );
902
906
  },
903
907
  [e, t, r]
904
908
  ), o = m(
905
909
  (i) => {
906
910
  const l = e.findIndex((d) => r(d, i));
907
- l >= 0 && t(e.filter((d, v) => v !== l));
911
+ l >= 0 && t(e.filter((d, y) => y !== l));
908
912
  },
909
913
  [e, t, r]
910
914
  ), s = m(
@@ -934,7 +938,7 @@ const ge = "_separatorLine_nzfcz_1", ve = {
934
938
  r((s) => !s);
935
939
  }, [r]);
936
940
  return [t, n, u, o];
937
- }, Lt = (e, t) => {
941
+ }, At = (e, t) => {
938
942
  const [r, n] = h(e);
939
943
  return p(() => {
940
944
  const u = setTimeout(() => {
@@ -944,7 +948,7 @@ const ge = "_separatorLine_nzfcz_1", ve = {
944
948
  clearTimeout(u);
945
949
  };
946
950
  }, [e, t]), r;
947
- }, At = (e, t) => {
951
+ }, Lt = (e, t) => {
948
952
  const [r, n] = h(e);
949
953
  return p(() => {
950
954
  e && n(!0);
@@ -957,10 +961,10 @@ const ge = "_separatorLine_nzfcz_1", ve = {
957
961
  }, [e, t]), r;
958
962
  };
959
963
  let tt = 0;
960
- const A = (e) => `webui-${e ? e + "-" : ""}${++tt}`, Mt = (e) => {
961
- const [t, r] = h(() => A(e));
962
- return p(() => r(A(e)), [e]), t;
963
- }, y = (e, t, r) => {
964
+ const L = (e) => `webui-${e ? e + "-" : ""}${++tt}`, Mt = (e) => {
965
+ const [t, r] = h(() => L(e));
966
+ return p(() => r(L(e)), [e]), t;
967
+ }, v = (e, t, r) => {
964
968
  const n = g(null);
965
969
  p(() => {
966
970
  n.current = r;
@@ -981,7 +985,7 @@ const A = (e) => `webui-${e ? e + "-" : ""}${++tt}`, Mt = (e) => {
981
985
  const [t, r, n] = C(!1);
982
986
  p(() => {
983
987
  document.activeElement === e.current ? r() : n();
984
- }, [e, n, r]), y(e, "focus", r), y(e, "blur", n);
988
+ }, [e, n, r]), v(e, "focus", r), v(e, "blur", n);
985
989
  const u = m(() => {
986
990
  e.current && e.current.focus();
987
991
  }, [e]), o = m(() => {
@@ -1001,11 +1005,11 @@ const A = (e) => `webui-${e ? e + "-" : ""}${++tt}`, Mt = (e) => {
1001
1005
  return t.current = e, t;
1002
1006
  }, Ot = (e) => {
1003
1007
  const [t, r, n] = C(!1);
1004
- return y(e, "mouseover", r), y(e, "mouseout", n), t;
1005
- }, Dt = (e) => {
1008
+ return v(e, "mouseover", r), v(e, "mouseout", n), t;
1009
+ }, Ht = (e) => {
1006
1010
  const [t, r, n] = C(!1);
1007
- return y(e, "mouseenter", r), y(e, "mouseleave", n), t;
1008
- }, Ht = (e, t) => {
1011
+ return v(e, "mouseenter", r), v(e, "mouseleave", n), t;
1012
+ }, Dt = (e, t) => {
1009
1013
  const r = g(() => {
1010
1014
  });
1011
1015
  p(() => {
@@ -1056,12 +1060,12 @@ const A = (e) => `webui-${e ? e + "-" : ""}${++tt}`, Mt = (e) => {
1056
1060
  return p(() => (e.current && a.observe(e.current), () => {
1057
1061
  a.disconnect();
1058
1062
  }), [a, e]), r;
1059
- }, jt = (e) => {
1063
+ }, Bt = (e) => {
1060
1064
  const t = g(null);
1061
1065
  return p(() => {
1062
1066
  e && (typeof e == "function" ? e(t.current) : e.current = t.current);
1063
1067
  }), t;
1064
- }, qt = (e, t, r = !0) => {
1068
+ }, jt = (e, t, r = !0) => {
1065
1069
  const [n, u] = h(e), o = g(null), s = m(
1066
1070
  (a, i = t) => {
1067
1071
  u(a), r && clearTimeout(o.current), o.current = setTimeout(() => u(e), i);
@@ -1071,7 +1075,7 @@ const A = (e) => `webui-${e ? e + "-" : ""}${++tt}`, Mt = (e) => {
1071
1075
  return p(() => () => {
1072
1076
  clearTimeout(o.current);
1073
1077
  }, []), [n, s];
1074
- }, Bt = () => S(() => /* @__PURE__ */ new Date(), []), Wt = (e) => (t, r) => e(t).localeCompare(e(r)), Xt = (e) => (t, r) => e(t) - e(r), Gt = (e) => {
1078
+ }, qt = () => S(() => /* @__PURE__ */ new Date(), []), Wt = (e) => (t, r) => e(t).localeCompare(e(r)), Xt = (e) => (t, r) => e(t) - e(r), Gt = (e) => {
1075
1079
  throw new Error(`Switch unhandled case: ${e}`);
1076
1080
  }, Yt = (e, t) => t, Kt = (e) => Object.keys(e).filter((t) => e[t]), Zt = (e) => {
1077
1081
  try {
@@ -1091,12 +1095,12 @@ function Qt(e, t) {
1091
1095
  throw new Error("Invariant error: " + t);
1092
1096
  }
1093
1097
  const er = (e) => {
1094
- if (!B(e) || e.type !== W) return !1;
1098
+ if (!q(e) || e.type !== W) return !1;
1095
1099
  const r = e.props.children;
1096
1100
  return Array.isArray(r) ? r.every(z) : z(r);
1097
1101
  }, z = (e) => e == null || e === !1;
1098
1102
  export {
1099
- D as AccessibleFontSizeContext,
1103
+ H as AccessibleFontSizeContext,
1100
1104
  bt as AccessibleFontSizeProvider,
1101
1105
  It as BlockKeyboardEvents,
1102
1106
  b as Box,
@@ -1106,14 +1110,14 @@ export {
1106
1110
  Qe as Heading,
1107
1111
  ft as Indent,
1108
1112
  Ct as LargeText,
1109
- yt as Nest,
1113
+ vt as Nest,
1110
1114
  mt as ResizeAwareBox,
1111
1115
  ht as Row,
1112
1116
  kt as ScreenReaderOnlyText,
1113
1117
  lt as SeparatorLine,
1114
1118
  $t as SmallText,
1115
1119
  St as SmallerText,
1116
- vt as Space,
1120
+ yt as Space,
1117
1121
  gt as Spacing,
1118
1122
  Et as StandardText,
1119
1123
  w as Text,
@@ -1134,22 +1138,22 @@ export {
1134
1138
  wt as useAccessibleFontSizeContext,
1135
1139
  Rt as useArraySet,
1136
1140
  C as useBoolean,
1137
- Lt as useDebounce,
1138
- At as useDelayedFalse,
1141
+ At as useDebounce,
1142
+ Lt as useDelayedFalse,
1139
1143
  Mt as useDomId,
1140
1144
  Re as useElementDimensions,
1141
1145
  zt as useElementFocus,
1142
1146
  Ft as useEventCallback,
1143
- y as useEventListener,
1144
- jt as useForwardedRef,
1147
+ v as useEventListener,
1148
+ Bt as useForwardedRef,
1145
1149
  Pt as useLatest,
1146
- Dt as useMouseIsEntered,
1150
+ Ht as useMouseIsEntered,
1147
1151
  Ot as useMouseIsOver,
1148
- Ht as useMultiOnClickOutside,
1152
+ Dt as useMultiOnClickOutside,
1149
1153
  Nt as useOnClickOutside,
1150
1154
  Ut as useOnNoMouseMovement,
1151
1155
  Vt as useOnScreen,
1152
- qt as useTimeoutState,
1153
- Bt as useToday
1156
+ jt as useTimeoutState,
1157
+ qt as useToday
1154
1158
  };
1155
1159
  //# sourceMappingURL=index.es.js.map