@webority/ui-react 0.148.0 → 0.149.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.
@@ -59937,37 +59937,37 @@ function VUe() {
59937
59937
  return typeof document < "u" && document.querySelector("wui-drawer[open], .offcanvas.show") !== null;
59938
59938
  }
59939
59939
  function wG(e) {
59940
- let { marker: r, props: i } = U("AppModal", e), { open: a, eyebrow: o, title: s, subtitle: c, headerIcon: l, tone: u = "neutral", dismissible: d = !0, onClose: f, onBack: m, backLabel: g = "Back", headerActions: _, footer: v, size: y = "md", placement: b = "center", hideHeader: x = !1, staticBackdrop: w = !0, confirmDiscard: T, dirty: E = !1, ariaLabel: D, closeLabel: O = "Close", className: k = "", children: A, ...j } = i;
59941
- G("AppModal", j), W("AppModal", "tone", u, NUe), W("AppModal", "placement", b, PUe), W("AppModal", "size", typeof y == "string" ? y : null, [...Object.keys(CG), "fullscreen"]);
59942
- let { style: M, ref: N, "data-wui": P, "data-wui-props": F, ...I } = j, L = P ? {
59943
- "data-wui": P,
59944
- "data-wui-props": F
59945
- } : r, R = L["data-wui"], z = L["data-wui-props"];
59946
- x && !D && typeof s != "string" && RUe();
59947
- let B = S(null), V = S(null), [ee, H] = C(!1);
59940
+ let { marker: r, props: i } = U("AppModal", e), { open: a, eyebrow: o, title: s, subtitle: c, headerIcon: l, tone: u = "neutral", dismissible: d = !0, onClose: f, onBack: m, backLabel: g = "Back", headerActions: _, footer: v, size: y = "md", placement: b = "center", hideHeader: x = !1, staticBackdrop: w = !0, closeOnEscape: T = !0, confirmDiscard: E, dirty: D = !1, ariaLabel: O, closeLabel: k = "Close", className: A = "", children: j, ...M } = i;
59941
+ G("AppModal", M), W("AppModal", "tone", u, NUe), W("AppModal", "placement", b, PUe), W("AppModal", "size", typeof y == "string" ? y : null, [...Object.keys(CG), "fullscreen"]);
59942
+ let { style: N, ref: P, "data-wui": F, "data-wui-props": I, ...L } = M, R = F ? {
59943
+ "data-wui": F,
59944
+ "data-wui-props": I
59945
+ } : r, z = R["data-wui"], B = R["data-wui-props"];
59946
+ x && !O && typeof s != "string" && RUe();
59947
+ let V = S(null), ee = S(null), [H, te] = C(!1);
59948
59948
  h(() => {
59949
- a || H(!1);
59949
+ a || te(!1);
59950
59950
  }, [a]), h(() => {
59951
- ee && V.current?.focus();
59952
- }, [ee]), h(() => {
59951
+ H && ee.current?.focus();
59952
+ }, [H]), h(() => {
59953
59953
  if (a) return MUe();
59954
59954
  }, [a]), h(() => {
59955
- let e = B.current?.closest(".modal");
59956
- e && (T ? e.setAttribute("confirm-discard", T) : e.removeAttribute("confirm-discard"));
59957
- }, [a, T]);
59958
- let te = S(null), ne = p((e) => {
59959
- te.current = e, typeof N == "function" ? N(e) : N && (N.current = e);
59960
- }, [N]);
59955
+ let e = V.current?.closest(".modal");
59956
+ e && (E ? e.setAttribute("confirm-discard", E) : e.removeAttribute("confirm-discard"));
59957
+ }, [a, E]);
59958
+ let ne = S(null), re = p((e) => {
59959
+ ne.current = e, typeof P == "function" ? P(e) : P && (P.current = e);
59960
+ }, [P]);
59961
59961
  h(() => {
59962
- let e = te.current?.dialog;
59963
- e && (e.setAttribute("data-wui", R), z === void 0 ? e.removeAttribute("data-wui-props") : e.setAttribute("data-wui-props", z));
59962
+ let e = ne.current?.dialog;
59963
+ e && (e.setAttribute("data-wui", z), B === void 0 ? e.removeAttribute("data-wui-props") : e.setAttribute("data-wui-props", B));
59964
59964
  }, [
59965
59965
  a,
59966
- R,
59967
- z
59966
+ z,
59967
+ B
59968
59968
  ]), h(() => {
59969
59969
  if (!a) return;
59970
- let e = B.current?.closest(".modal-content");
59970
+ let e = V.current?.closest(".modal-content");
59971
59971
  if (!e) return;
59972
59972
  let t = () => Array.from(e.querySelectorAll(FUe));
59973
59973
  (e.querySelector("[data-autofocus]") || t().find((e) => !e.classList.contains("wui-modal-close") && !e.classList.contains("wui-modal-back")) || t()[0] || e).focus?.({ preventScroll: !0 });
@@ -59980,43 +59980,43 @@ function wG(e) {
59980
59980
  }, 500);
59981
59981
  };
59982
59982
  }, [a]);
59983
- let re = () => {
59984
- T && E ? H(!0) : f?.();
59985
- }, ie = (e) => {
59986
- e.target.closest?.("[data-wui-dismiss]") && re();
59987
- }, ae = () => {
59988
- H(!1), f?.();
59983
+ let ie = () => {
59984
+ E && D ? te(!0) : f?.();
59985
+ }, ae = (e) => {
59986
+ e.target.closest?.("[data-wui-dismiss]") && ie();
59989
59987
  }, oe = () => {
59990
- H(!1), (B.current?.querySelector("input:not([type=\"hidden\"]):not([disabled]),select:not([disabled]),textarea:not([disabled])"))?.focus();
59991
- }, se = y === "fullscreen", ce = typeof y == "number" ? y : CG[y] ?? CG.md, le = [
59988
+ te(!1), f?.();
59989
+ }, se = () => {
59990
+ te(!1), (V.current?.querySelector("input:not([type=\"hidden\"]):not([disabled]),select:not([disabled]),textarea:not([disabled])"))?.focus();
59991
+ }, ce = y === "fullscreen", le = typeof y == "number" ? y : CG[y] ?? CG.md, ue = [
59992
59992
  "wui-modal",
59993
59993
  u === "neutral" ? "" : `tone-${u}`,
59994
- k
59995
- ].filter(Boolean).join(" "), ue = a && VUe(), de = [
59994
+ A
59995
+ ].filter(Boolean).join(" "), de = a && VUe(), fe = [
59996
59996
  "wui-modal-shell",
59997
- se && IUe,
59998
- ue && "wui-modal-stacked"
59997
+ ce && IUe,
59998
+ de && "wui-modal-stacked"
59999
59999
  ].filter(Boolean).join(" ");
60000
60000
  return /* @__PURE__ */ n(Ofe, {
60001
- ...I,
60002
- ref: ne,
60001
+ ...L,
60002
+ ref: re,
60003
60003
  show: a,
60004
- onHide: re,
60004
+ onHide: ie,
60005
60005
  backdrop: !w || "static",
60006
- keyboard: !w,
60006
+ keyboard: T,
60007
60007
  autoFocus: !1,
60008
60008
  enforceFocus: !0,
60009
60009
  restoreFocus: !0,
60010
60010
  centered: b !== "top",
60011
- className: de,
60012
- style: se ? M : {
60013
- "--wui-modal-max-width": `${ce}px`,
60014
- ...M
60011
+ className: fe,
60012
+ style: ce ? N : {
60013
+ "--wui-modal-max-width": `${le}px`,
60014
+ ...N
60015
60015
  },
60016
60016
  dialogClassName: "wui-rb-dialog",
60017
- contentClassName: le,
60018
- backdropClassName: ue ? "wui-modal-dim wui-modal-backdrop-stacked" : "wui-modal-dim",
60019
- "aria-label": D || (typeof s == "string" ? s : void 0),
60017
+ contentClassName: ue,
60018
+ backdropClassName: de ? "wui-modal-dim wui-modal-backdrop-stacked" : "wui-modal-dim",
60019
+ "aria-label": O || (typeof s == "string" ? s : void 0),
60020
60020
  children: [
60021
60021
  !x && /* @__PURE__ */ n("div", {
60022
60022
  className: "wui-modal-header",
@@ -60064,8 +60064,8 @@ function wG(e) {
60064
60064
  d && /* @__PURE__ */ t("button", {
60065
60065
  type: "button",
60066
60066
  className: "wui-modal-close",
60067
- onClick: re,
60068
- "aria-label": O,
60067
+ onClick: ie,
60068
+ "aria-label": k,
60069
60069
  children: /* @__PURE__ */ t("svg", {
60070
60070
  width: "18",
60071
60071
  height: "18",
@@ -60083,18 +60083,18 @@ function wG(e) {
60083
60083
  }),
60084
60084
  /* @__PURE__ */ t("div", {
60085
60085
  className: "wui-modal-body",
60086
- ref: B,
60087
- onClick: ie,
60088
- children: A
60086
+ ref: V,
60087
+ onClick: ae,
60088
+ children: j
60089
60089
  }),
60090
- (v || ee) && /* @__PURE__ */ n("div", {
60091
- className: ee ? "wui-modal-footer wui-drawer-discarding" : "wui-modal-footer",
60092
- onClick: ie,
60093
- children: [ee && /* @__PURE__ */ t(jUe, {
60094
- text: T,
60095
- confirmRef: V,
60096
- onDiscard: ae,
60097
- onKeep: oe
60090
+ (v || H) && /* @__PURE__ */ n("div", {
60091
+ className: H ? "wui-modal-footer wui-drawer-discarding" : "wui-modal-footer",
60092
+ onClick: ae,
60093
+ children: [H && /* @__PURE__ */ t(jUe, {
60094
+ text: E,
60095
+ confirmRef: ee,
60096
+ onDiscard: oe,
60097
+ onKeep: se
60098
60098
  }), v]
60099
60099
  })
60100
60100
  ]
@@ -63668,6 +63668,7 @@ function KKe(r) {
63668
63668
  title: s,
63669
63669
  onClose: z,
63670
63670
  staticBackdrop: S,
63671
+ closeOnEscape: !S,
63671
63672
  placement: w,
63672
63673
  size: T,
63673
63674
  className: [
@@ -134668,7 +134669,7 @@ var ySt = d(function({ compact: r, tenant: i, "aria-label": a, className: o, ...
134668
134669
  kind: "WeborityWeb",
134669
134670
  library: {
134670
134671
  name: "@webority/ui-react",
134671
- version: "0.148.0"
134672
+ version: "0.149.0"
134672
134673
  },
134673
134674
  rendererProtocolVersion: 13,
134674
134675
  platform: "Web",
@@ -147713,6 +147714,13 @@ var ySt = d(function({ compact: r, tenant: i, "aria-label": a, className: o, ...
147713
147714
  description: "The close button's accessible name, for other languages.",
147714
147715
  default: "Close"
147715
147716
  },
147717
+ {
147718
+ name: "closeOnEscape",
147719
+ type: "boolean",
147720
+ required: !1,
147721
+ description: "Escape closes the modal through onClose, asking first when confirmDiscard applies. Set false for a dialog that must not close from the keyboard.",
147722
+ default: !0
147723
+ },
147716
147724
  {
147717
147725
  name: "confirmDiscard",
147718
147726
  type: "string",
@@ -147730,7 +147738,7 @@ var ySt = d(function({ compact: r, tenant: i, "aria-label": a, className: o, ...
147730
147738
  name: "dismissible",
147731
147739
  type: "boolean",
147732
147740
  required: !1,
147733
- description: "Shows the close button in the header. Pair it with staticBackdrop for a forced-choice dialog.",
147741
+ description: "Shows the close button in the header. For a forced-choice dialog, pair false with staticBackdrop and closeOnEscape false.",
147734
147742
  default: !0
147735
147743
  },
147736
147744
  {
@@ -147796,7 +147804,7 @@ var ySt = d(function({ compact: r, tenant: i, "aria-label": a, className: o, ...
147796
147804
  name: "staticBackdrop",
147797
147805
  type: "boolean",
147798
147806
  required: !1,
147799
- description: "The pop-up closes only through its own Close or Cancel by default. false lets Escape and an outside click close it.",
147807
+ description: "Covers outside clicks only: by default an outside click leaves the pop-up open. false lets an outside click close it.",
147800
147808
  default: !0
147801
147809
  },
147802
147810
  {
@@ -147904,7 +147912,7 @@ var ySt = d(function({ compact: r, tenant: i, "aria-label": a, className: o, ...
147904
147912
  a11y: [
147905
147913
  "Focus stays inside the dialog: Tab and Shift+Tab wrap between its first and last control.",
147906
147914
  "The page behind an open dialog is made inert, and the dialog is named by a plain-text title or by ariaLabel; a headerless dialog with neither warns in development.",
147907
- "Escape and an outside click leave it open by default; set staticBackdrop to false to let them close it."
147915
+ "An outside click leaves it open by default (staticBackdrop); Escape closes it unless closeOnEscape is false."
147908
147916
  ]
147909
147917
  }
147910
147918
  },
@@ -2,7 +2,7 @@
2
2
  "kind": "WeborityWeb",
3
3
  "library": {
4
4
  "name": "@webority/ui-react",
5
- "version": "0.148.0"
5
+ "version": "0.149.0"
6
6
  },
7
7
  "rendererProtocolVersion": 13,
8
8
  "platform": "Web",
@@ -14180,6 +14180,13 @@
14180
14180
  "description": "The close button's accessible name, for other languages.",
14181
14181
  "default": "Close"
14182
14182
  },
14183
+ {
14184
+ "name": "closeOnEscape",
14185
+ "type": "boolean",
14186
+ "required": false,
14187
+ "description": "Escape closes the modal through onClose, asking first when confirmDiscard applies. Set false for a dialog that must not close from the keyboard.",
14188
+ "default": true
14189
+ },
14183
14190
  {
14184
14191
  "name": "confirmDiscard",
14185
14192
  "type": "string",
@@ -14197,7 +14204,7 @@
14197
14204
  "name": "dismissible",
14198
14205
  "type": "boolean",
14199
14206
  "required": false,
14200
- "description": "Shows the close button in the header. Pair it with staticBackdrop for a forced-choice dialog.",
14207
+ "description": "Shows the close button in the header. For a forced-choice dialog, pair false with staticBackdrop and closeOnEscape false.",
14201
14208
  "default": true
14202
14209
  },
14203
14210
  {
@@ -14266,7 +14273,7 @@
14266
14273
  "name": "staticBackdrop",
14267
14274
  "type": "boolean",
14268
14275
  "required": false,
14269
- "description": "The pop-up closes only through its own Close or Cancel by default. false lets Escape and an outside click close it.",
14276
+ "description": "Covers outside clicks only: by default an outside click leaves the pop-up open. false lets an outside click close it.",
14270
14277
  "default": true
14271
14278
  },
14272
14279
  {
@@ -14402,7 +14409,7 @@
14402
14409
  "a11y": [
14403
14410
  "Focus stays inside the dialog: Tab and Shift+Tab wrap between its first and last control.",
14404
14411
  "The page behind an open dialog is made inert, and the dialog is named by a plain-text title or by ariaLabel; a headerless dialog with neither warns in development.",
14405
- "Escape and an outside click leave it open by default; set staticBackdrop to false to let them close it."
14412
+ "An outside click leaves it open by default (staticBackdrop); Escape closes it unless closeOnEscape is false."
14406
14413
  ]
14407
14414
  }
14408
14415
  },
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "webority-web",
3
- "version": "0.148.0",
3
+ "version": "0.149.0",
4
4
  "platform": "Web",
5
5
  "kitModuleVersion": 2,
6
6
  "rendererProtocolVersion": 13,
7
7
  "library": {
8
8
  "name": "@webority/ui-react",
9
- "version": "0.148.0"
9
+ "version": "0.149.0"
10
10
  },
11
11
  "files": {
12
12
  "manifest.json": {
13
- "sha256": "ca51e1bbfda10ac1abf669292d210efc5e3cd133b29f223900842cc6377e39eb",
14
- "bytes": 987853
13
+ "sha256": "995913281b5628e54e63a1225605b9fd6b1e0a0c526d9293741985da88ff396c",
14
+ "bytes": 988201
15
15
  },
16
16
  "kit.js": {
17
- "sha256": "337bd0913da462d198e5f03bbe813c99455cb612a0a8f15820f2b3b14db04b16",
18
- "bytes": 11188258
17
+ "sha256": "a88bfe1c522365bf99b8d9bbed113188e4d45b676f89eabdae50bf26f88ddd12",
18
+ "bytes": 11188610
19
19
  },
20
20
  "kit.css": {
21
21
  "sha256": "13b14f71fb6ea024945f95cba617b4f1d49f44a65ba7c7ed05d2354805539ef6",
@@ -1 +1 @@
1
- import e from"../lib/fillLabel.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./AppButton.js";import r from"./AppIcon.js";import i from"./AppInput.js";import a from"./AppModal.js";import o from"./assertValidValue.js";import{MODAL_ICONS as s}from"./ModalIcons.js";import c from"./warnUnknownProps.js";import{useEffect as l,useState as u}from"react";import{Fragment as d,jsx as f,jsxs as p}from"react/jsx-runtime";var m=[`sm`,`md`,`lg`,`xl`],h=[`default`,`plain`],g=[`success`,`danger`,`warning`,`info`,`primary`];function _(_){let{marker:v,props:y}=t(`AppConfirmDialog`,_),{open:b,title:x,variant:S=`default`,description:C,confirmLabel:w=`Confirm`,cancelLabel:T=`Cancel`,typePhraseLabel:E=`Type {phrase} to confirm`,tone:D,image:O,icon:k,iconSize:A,confirmPhrase:j,onConfirm:M,onClose:N,loading:P=!1,staticBackdrop:F=!0,placement:I=`center`,size:L=`md`,className:R=``,children:z,...B}=y;c(`AppConfirmDialog`,B),o(`AppConfirmDialog`,`tone`,D,g),o(`AppConfirmDialog`,`size`,typeof L==`string`?L:null,m),o(`AppConfirmDialog`,`variant`,S,h);let[V,H]=u(``);if(l(()=>{b||H(``)},[b]),!b)return null;let U=!!j&&V.trim()!==j,[W,...G]=E.split(`{phrase}`),K=G.join(j),q=S===`plain`,J=q?`sm`:`md`,Y=q||O||k?null:s[D===`danger`?`delete`:D??`info`],X=A>0?{"--wui-confirm-icon-size":`${A}px`}:void 0,Z=()=>{P||N?.()};return/* @__PURE__ */ f(a,{...v,...B,open:b,hideHeader:!0,title:x,onClose:Z,staticBackdrop:F,placement:I,size:L,className:[`wui-confirm`,q&&`wui-confirm-plain`,R].filter(Boolean).join(` `),footer:/* @__PURE__ */ p(`div`,{className:`wui-confirm-actions`,children:[/* @__PURE__ */ f(n,{tone:`neutral`,...q?{}:{variant:`soft`},size:J,disabled:P,onClick:Z,children:T}),/* @__PURE__ */ f(n,{tone:D===`danger`?`danger`:void 0,size:J,disabled:U,loading:P,onClick:M,children:w})]}),children:/* @__PURE__ */ p(`div`,{className:`wui-confirm-content`,children:[!q&&O?/* @__PURE__ */ f(`span`,{className:`wui-confirm-icon`,style:X,children:/* @__PURE__ */ f(`img`,{src:O,alt:``,"aria-hidden":`true`})}):!q&&k?/* @__PURE__ */ f(`span`,{className:`wui-confirm-icon`,style:X,children:typeof k==`string`?/* @__PURE__ */ f(r,{name:k,size:80}):k}):Y&&/* @__PURE__ */ f(`span`,{className:`wui-confirm-icon`,style:X,children:/* @__PURE__ */ f(Y,{size:120})}),/* @__PURE__ */ f(`h3`,{className:`wui-confirm-title`,tabIndex:-1,"data-autofocus":``,children:x}),C&&/* @__PURE__ */ f(`p`,{className:`wui-confirm-msg`,children:C}),z!=null&&z!==!1&&/* @__PURE__ */ f(`div`,{className:`wui-confirm-body`,children:z}),j&&/* @__PURE__ */ f(i,{fieldClassName:`mt-3 mb-0 w-100 text-start`,label:/* @__PURE__ */ p(d,{children:[W,/* @__PURE__ */ f(`strong`,{children:j}),K]}),value:V,onChange:e=>H(e.target.value),"aria-label":e(E,{phrase:j}),disabled:P})]})})}export{_ as default};
1
+ import e from"../lib/fillLabel.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./AppButton.js";import r from"./AppIcon.js";import i from"./AppInput.js";import a from"./AppModal.js";import o from"./assertValidValue.js";import{MODAL_ICONS as s}from"./ModalIcons.js";import c from"./warnUnknownProps.js";import{useEffect as l,useState as u}from"react";import{Fragment as d,jsx as f,jsxs as p}from"react/jsx-runtime";var m=[`sm`,`md`,`lg`,`xl`],h=[`default`,`plain`],g=[`success`,`danger`,`warning`,`info`,`primary`];function _(_){let{marker:v,props:y}=t(`AppConfirmDialog`,_),{open:b,title:x,variant:S=`default`,description:C,confirmLabel:w=`Confirm`,cancelLabel:T=`Cancel`,typePhraseLabel:E=`Type {phrase} to confirm`,tone:D,image:O,icon:k,iconSize:A,confirmPhrase:j,onConfirm:M,onClose:N,loading:P=!1,staticBackdrop:F=!0,placement:I=`center`,size:L=`md`,className:R=``,children:z,...B}=y;c(`AppConfirmDialog`,B),o(`AppConfirmDialog`,`tone`,D,g),o(`AppConfirmDialog`,`size`,typeof L==`string`?L:null,m),o(`AppConfirmDialog`,`variant`,S,h);let[V,H]=u(``);if(l(()=>{b||H(``)},[b]),!b)return null;let U=!!j&&V.trim()!==j,[W,...G]=E.split(`{phrase}`),K=G.join(j),q=S===`plain`,J=q?`sm`:`md`,Y=q||O||k?null:s[D===`danger`?`delete`:D??`info`],X=A>0?{"--wui-confirm-icon-size":`${A}px`}:void 0,Z=()=>{P||N?.()};return/* @__PURE__ */ f(a,{...v,...B,open:b,hideHeader:!0,title:x,onClose:Z,staticBackdrop:F,closeOnEscape:!F,placement:I,size:L,className:[`wui-confirm`,q&&`wui-confirm-plain`,R].filter(Boolean).join(` `),footer:/* @__PURE__ */ p(`div`,{className:`wui-confirm-actions`,children:[/* @__PURE__ */ f(n,{tone:`neutral`,...q?{}:{variant:`soft`},size:J,disabled:P,onClick:Z,children:T}),/* @__PURE__ */ f(n,{tone:D===`danger`?`danger`:void 0,size:J,disabled:U,loading:P,onClick:M,children:w})]}),children:/* @__PURE__ */ p(`div`,{className:`wui-confirm-content`,children:[!q&&O?/* @__PURE__ */ f(`span`,{className:`wui-confirm-icon`,style:X,children:/* @__PURE__ */ f(`img`,{src:O,alt:``,"aria-hidden":`true`})}):!q&&k?/* @__PURE__ */ f(`span`,{className:`wui-confirm-icon`,style:X,children:typeof k==`string`?/* @__PURE__ */ f(r,{name:k,size:80}):k}):Y&&/* @__PURE__ */ f(`span`,{className:`wui-confirm-icon`,style:X,children:/* @__PURE__ */ f(Y,{size:120})}),/* @__PURE__ */ f(`h3`,{className:`wui-confirm-title`,tabIndex:-1,"data-autofocus":``,children:x}),C&&/* @__PURE__ */ f(`p`,{className:`wui-confirm-msg`,children:C}),z!=null&&z!==!1&&/* @__PURE__ */ f(`div`,{className:`wui-confirm-body`,children:z}),j&&/* @__PURE__ */ f(i,{fieldClassName:`mt-3 mb-0 w-100 text-start`,label:/* @__PURE__ */ p(d,{children:[W,/* @__PURE__ */ f(`strong`,{children:j}),K]}),value:V,onChange:e=>H(e.target.value),"aria-label":e(E,{phrase:j}),disabled:P})]})})}export{_ as default};
@@ -1 +1 @@
1
- import e from"../lib/DiscardPrompt.js";import{devWarn as t}from"../lib/devWarn.js";import{lockPageScroll as n}from"../lib/pageScrollLock.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppIcon.js";import a from"./assertValidValue.js";import o from"./warnUnknownProps.js";import{useCallback as s,useEffect as c,useRef as l,useState as u}from"react";import{Modal as ee}from"react-bootstrap";import{jsx as d,jsxs as f}from"react/jsx-runtime";var te=[`neutral`,`danger`,`success`,`warning`],ne=[`center`,`top`],p=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,m={sm:380,md:440,lg:640,xl:880},re=`wui-modal-fullscreen`,h=!1;function ie(){let e=!0;try{e=process.env.NODE_ENV!==`production`}catch{e=!0}e&&!h&&(h=!0,t("[@webority/ui-react] <AppModal hideHeader> has no accessible name: pass `ariaLabel` (or a string `title`)."))}function g(e,t){if(e.key!==`Tab`)return;let n=Array.from(t.querySelectorAll(p));if(!n.length){e.preventDefault(),t.focus();return}let r=n[0],i=n[n.length-1],a=document.activeElement;e.shiftKey&&(a===r||a===t)?(e.preventDefault(),i.focus()):!e.shiftKey&&a===i&&(e.preventDefault(),r.focus())}function ae(){let e=[];for(let t of document.body.children)t.hasAttribute(`inert`)||t.matches(`.modal, .modal-backdrop`)||(t.setAttribute(`inert`,``),e.push(t));return e}function oe(){return typeof document<`u`&&document.querySelector(`wui-drawer[open], .offcanvas.show`)!==null}function _(t){let{marker:h,props:_}=r(`AppModal`,t),{open:v,eyebrow:y,title:b,subtitle:x,headerIcon:S,tone:C=`neutral`,dismissible:w=!0,onClose:T,onBack:E,backLabel:D=`Back`,headerActions:O,footer:k,size:A=`md`,placement:j=`center`,hideHeader:M=!1,staticBackdrop:N=!0,confirmDiscard:P,dirty:se=!1,ariaLabel:F,closeLabel:ce=`Close`,className:le=``,children:ue,...I}=_;o(`AppModal`,I),a(`AppModal`,`tone`,C,te),a(`AppModal`,`placement`,j,ne),a(`AppModal`,`size`,typeof A==`string`?A:null,[...Object.keys(m),`fullscreen`]);let{style:L,ref:R,"data-wui":z,"data-wui-props":B,...V}=I,H=z?{"data-wui":z,"data-wui-props":B}:h,U=H[`data-wui`],W=H[`data-wui-props`];M&&!F&&typeof b!=`string`&&ie();let G=l(null),K=l(null),[q,J]=u(!1);c(()=>{v||J(!1)},[v]),c(()=>{q&&K.current?.focus()},[q]),c(()=>{if(v)return n()},[v]),c(()=>{let e=G.current?.closest(`.modal`);e&&(P?e.setAttribute(`confirm-discard`,P):e.removeAttribute(`confirm-discard`))},[v,P]);let Y=l(null),de=s(e=>{Y.current=e,typeof R==`function`?R(e):R&&(R.current=e)},[R]);c(()=>{let e=Y.current?.dialog;e&&(e.setAttribute(`data-wui`,U),W===void 0?e.removeAttribute(`data-wui-props`):e.setAttribute(`data-wui-props`,W))},[v,U,W]),c(()=>{if(!v)return;let e=G.current?.closest(`.modal-content`);if(!e)return;let t=()=>Array.from(e.querySelectorAll(p));(e.querySelector(`[data-autofocus]`)||t().find(e=>!e.classList.contains(`wui-modal-close`)&&!e.classList.contains(`wui-modal-back`))||t()[0]||e).focus?.({preventScroll:!0});let n=e.closest(`.modal`),r=ae(),i=e=>g(e,n);return n?.addEventListener(`keydown`,i),()=>{n?.removeEventListener(`keydown`,i);for(let e of r)e.removeAttribute(`inert`);n&&setTimeout(()=>{n.isConnected&&!n.classList.contains(`show`)&&n.dispatchEvent(new Event(`transitionend`,{bubbles:!0}))},500)}},[v]);let X=()=>{P&&se?J(!0):T?.()},Z=e=>{e.target.closest?.(`[data-wui-dismiss]`)&&X()},fe=()=>{J(!1),T?.()},pe=()=>{J(!1),(G.current?.querySelector(`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled])`))?.focus()},Q=A===`fullscreen`,me=typeof A==`number`?A:m[A]??m.md,he=[`wui-modal`,C===`neutral`?``:`tone-${C}`,le].filter(Boolean).join(` `),$=v&&oe(),ge=[`wui-modal-shell`,Q&&re,$&&`wui-modal-stacked`].filter(Boolean).join(` `);return/* @__PURE__ */ f(ee,{...V,ref:de,show:v,onHide:X,backdrop:!N||`static`,keyboard:!N,autoFocus:!1,enforceFocus:!0,restoreFocus:!0,centered:j!==`top`,className:ge,style:Q?L:{"--wui-modal-max-width":`${me}px`,...L},dialogClassName:`wui-rb-dialog`,contentClassName:he,backdropClassName:$?`wui-modal-dim wui-modal-backdrop-stacked`:`wui-modal-dim`,"aria-label":F||(typeof b==`string`?b:void 0),children:[!M&&/* @__PURE__ */ f(`div`,{className:`wui-modal-header`,children:[E&&/* @__PURE__ */ d(`button`,{type:`button`,className:`wui-modal-back`,onClick:E,"aria-label":D,children:/* @__PURE__ */ d(i,{name:`arrow-left`,size:18})}),/* @__PURE__ */ f(`div`,{className:`wui-modal-heading`,children:[S&&/* @__PURE__ */ d(`span`,{className:`wui-modal-headicon`,children:/* @__PURE__ */ d(i,{name:S,size:18})}),/* @__PURE__ */ f(`div`,{className:`wui-modal-headtext`,children:[y&&/* @__PURE__ */ d(`div`,{className:`wui-modal-eyebrow`,children:y}),/* @__PURE__ */ d(`div`,{className:`wui-modal-title`,children:b}),x&&/* @__PURE__ */ d(`div`,{className:`wui-modal-subtitle`,children:x})]})]}),O&&/* @__PURE__ */ d(`div`,{className:`wui-modal-header-actions`,children:O}),w&&/* @__PURE__ */ d(`button`,{type:`button`,className:`wui-modal-close`,onClick:X,"aria-label":ce,children:/* @__PURE__ */ d(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:/* @__PURE__ */ d(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]}),/* @__PURE__ */ d(`div`,{className:`wui-modal-body`,ref:G,onClick:Z,children:ue}),(k||q)&&/* @__PURE__ */ f(`div`,{className:q?`wui-modal-footer wui-drawer-discarding`:`wui-modal-footer`,onClick:Z,children:[q&&/* @__PURE__ */ d(e,{text:P,confirmRef:K,onDiscard:fe,onKeep:pe}),k]})]})}export{_ as default};
1
+ import e from"../lib/DiscardPrompt.js";import{devWarn as t}from"../lib/devWarn.js";import{lockPageScroll as n}from"../lib/pageScrollLock.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppIcon.js";import a from"./assertValidValue.js";import o from"./warnUnknownProps.js";import{useCallback as ee,useEffect as s,useRef as c,useState as l}from"react";import{Modal as te}from"react-bootstrap";import{jsx as u,jsxs as d}from"react/jsx-runtime";var f=[`neutral`,`danger`,`success`,`warning`],p=[`center`,`top`],m=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`,h={sm:380,md:440,lg:640,xl:880},ne=`wui-modal-fullscreen`,g=!1;function re(){let e=!0;try{e=process.env.NODE_ENV!==`production`}catch{e=!0}e&&!g&&(g=!0,t("[@webority/ui-react] <AppModal hideHeader> has no accessible name: pass `ariaLabel` (or a string `title`)."))}function ie(e,t){if(e.key!==`Tab`)return;let n=Array.from(t.querySelectorAll(m));if(!n.length){e.preventDefault(),t.focus();return}let r=n[0],i=n[n.length-1],a=document.activeElement;e.shiftKey&&(a===r||a===t)?(e.preventDefault(),i.focus()):!e.shiftKey&&a===i&&(e.preventDefault(),r.focus())}function ae(){let e=[];for(let t of document.body.children)t.hasAttribute(`inert`)||t.matches(`.modal, .modal-backdrop`)||(t.setAttribute(`inert`,``),e.push(t));return e}function oe(){return typeof document<`u`&&document.querySelector(`wui-drawer[open], .offcanvas.show`)!==null}function _(t){let{marker:g,props:_}=r(`AppModal`,t),{open:v,eyebrow:y,title:b,subtitle:x,headerIcon:S,tone:C=`neutral`,dismissible:se=!0,onClose:w,onBack:T,backLabel:E=`Back`,headerActions:D,footer:O,size:k=`md`,placement:A=`center`,hideHeader:j=!1,staticBackdrop:ce=!0,closeOnEscape:le=!0,confirmDiscard:M,dirty:ue=!1,ariaLabel:N,closeLabel:de=`Close`,className:P=``,children:F,...I}=_;o(`AppModal`,I),a(`AppModal`,`tone`,C,f),a(`AppModal`,`placement`,A,p),a(`AppModal`,`size`,typeof k==`string`?k:null,[...Object.keys(h),`fullscreen`]);let{style:L,ref:R,"data-wui":z,"data-wui-props":B,...V}=I,H=z?{"data-wui":z,"data-wui-props":B}:g,U=H[`data-wui`],W=H[`data-wui-props`];j&&!N&&typeof b!=`string`&&re();let G=c(null),K=c(null),[q,J]=l(!1);s(()=>{v||J(!1)},[v]),s(()=>{q&&K.current?.focus()},[q]),s(()=>{if(v)return n()},[v]),s(()=>{let e=G.current?.closest(`.modal`);e&&(M?e.setAttribute(`confirm-discard`,M):e.removeAttribute(`confirm-discard`))},[v,M]);let Y=c(null),fe=ee(e=>{Y.current=e,typeof R==`function`?R(e):R&&(R.current=e)},[R]);s(()=>{let e=Y.current?.dialog;e&&(e.setAttribute(`data-wui`,U),W===void 0?e.removeAttribute(`data-wui-props`):e.setAttribute(`data-wui-props`,W))},[v,U,W]),s(()=>{if(!v)return;let e=G.current?.closest(`.modal-content`);if(!e)return;let t=()=>Array.from(e.querySelectorAll(m));(e.querySelector(`[data-autofocus]`)||t().find(e=>!e.classList.contains(`wui-modal-close`)&&!e.classList.contains(`wui-modal-back`))||t()[0]||e).focus?.({preventScroll:!0});let n=e.closest(`.modal`),r=ae(),i=e=>ie(e,n);return n?.addEventListener(`keydown`,i),()=>{n?.removeEventListener(`keydown`,i);for(let e of r)e.removeAttribute(`inert`);n&&setTimeout(()=>{n.isConnected&&!n.classList.contains(`show`)&&n.dispatchEvent(new Event(`transitionend`,{bubbles:!0}))},500)}},[v]);let X=()=>{M&&ue?J(!0):w?.()},Z=e=>{e.target.closest?.(`[data-wui-dismiss]`)&&X()},pe=()=>{J(!1),w?.()},me=()=>{J(!1),(G.current?.querySelector(`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled])`))?.focus()},Q=k===`fullscreen`,he=typeof k==`number`?k:h[k]??h.md,ge=[`wui-modal`,C===`neutral`?``:`tone-${C}`,P].filter(Boolean).join(` `),$=v&&oe(),_e=[`wui-modal-shell`,Q&&ne,$&&`wui-modal-stacked`].filter(Boolean).join(` `);return/* @__PURE__ */ d(te,{...V,ref:fe,show:v,onHide:X,backdrop:!ce||`static`,keyboard:le,autoFocus:!1,enforceFocus:!0,restoreFocus:!0,centered:A!==`top`,className:_e,style:Q?L:{"--wui-modal-max-width":`${he}px`,...L},dialogClassName:`wui-rb-dialog`,contentClassName:ge,backdropClassName:$?`wui-modal-dim wui-modal-backdrop-stacked`:`wui-modal-dim`,"aria-label":N||(typeof b==`string`?b:void 0),children:[!j&&/* @__PURE__ */ d(`div`,{className:`wui-modal-header`,children:[T&&/* @__PURE__ */ u(`button`,{type:`button`,className:`wui-modal-back`,onClick:T,"aria-label":E,children:/* @__PURE__ */ u(i,{name:`arrow-left`,size:18})}),/* @__PURE__ */ d(`div`,{className:`wui-modal-heading`,children:[S&&/* @__PURE__ */ u(`span`,{className:`wui-modal-headicon`,children:/* @__PURE__ */ u(i,{name:S,size:18})}),/* @__PURE__ */ d(`div`,{className:`wui-modal-headtext`,children:[y&&/* @__PURE__ */ u(`div`,{className:`wui-modal-eyebrow`,children:y}),/* @__PURE__ */ u(`div`,{className:`wui-modal-title`,children:b}),x&&/* @__PURE__ */ u(`div`,{className:`wui-modal-subtitle`,children:x})]})]}),D&&/* @__PURE__ */ u(`div`,{className:`wui-modal-header-actions`,children:D}),se&&/* @__PURE__ */ u(`button`,{type:`button`,className:`wui-modal-close`,onClick:X,"aria-label":de,children:/* @__PURE__ */ u(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:/* @__PURE__ */ u(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]}),/* @__PURE__ */ u(`div`,{className:`wui-modal-body`,ref:G,onClick:Z,children:F}),(O||q)&&/* @__PURE__ */ d(`div`,{className:q?`wui-modal-footer wui-drawer-discarding`:`wui-modal-footer`,onClick:Z,children:[q&&/* @__PURE__ */ u(e,{text:M,confirmRef:K,onDiscard:pe,onKeep:me}),O]})]})}export{_ as default};
@@ -2,7 +2,7 @@
2
2
  "format": "webority-guidance/1",
3
3
  "package": {
4
4
  "name": "@webority/ui-react",
5
- "version": "0.148.0"
5
+ "version": "0.149.0"
6
6
  },
7
7
  "components": [
8
8
  {
@@ -4952,7 +4952,7 @@
4952
4952
  "a11y": [
4953
4953
  "Focus stays inside the dialog: Tab and Shift+Tab wrap between its first and last control.",
4954
4954
  "The page behind an open dialog is made inert, and the dialog is named by a plain-text title or by ariaLabel; a headerless dialog with neither warns in development.",
4955
- "Escape and an outside click leave it open by default; set staticBackdrop to false to let them close it."
4955
+ "An outside click leaves it open by default (staticBackdrop); Escape closes it unless closeOnEscape is false."
4956
4956
  ]
4957
4957
  }
4958
4958
  },
@@ -19,7 +19,8 @@
19
19
  * @param {boolean} [props.hideHeader]
20
20
  * @param {string} [props.ariaLabel]
21
21
  * @param {string} [props.closeLabel] Default "Close".
22
- * @param {boolean} [props.staticBackdrop] Defaults to true: Escape and an outside click leave the modal open. Pass false to let them close it.
22
+ * @param {boolean} [props.staticBackdrop] Defaults to true: an outside click leaves the modal open. Pass false to let it close the modal. Escape is closeOnEscape's.
23
+ * @param {boolean} [props.closeOnEscape] Defaults to true: Escape closes the modal through onClose (and through confirmDiscard's question when a form changed). Pass false for a dialog that must not close from the keyboard.
23
24
  * @param {string} [props.confirmDiscard]
24
25
  * @param {boolean} [props.dirty]
25
26
  * @param {string} [props.className]
@@ -42,7 +43,7 @@ export default function AppModal(props: {
42
43
  */
43
44
  tone?: 'neutral' | 'danger' | 'success' | 'warning';
44
45
  /**
45
- * Shows the close button in the header. Pair it with staticBackdrop for a forced-choice dialog.
46
+ * Shows the close button in the header. For a forced-choice dialog, pair false with staticBackdrop and closeOnEscape false.
46
47
  * @default true
47
48
  */
48
49
  dismissible?: boolean;
@@ -80,10 +81,15 @@ export default function AppModal(props: {
80
81
  */
81
82
  closeLabel?: string;
82
83
  /**
83
- * The pop-up closes only through its own Close or Cancel by default. false lets Escape and an outside click close it.
84
+ * Covers outside clicks only: by default an outside click leaves the pop-up open. false lets an outside click close it.
84
85
  * @default true
85
86
  */
86
87
  staticBackdrop?: boolean;
88
+ /**
89
+ * Escape closes the modal through onClose, asking first when confirmDiscard applies. Set false for a dialog that must not close from the keyboard.
90
+ * @default true
91
+ */
92
+ closeOnEscape?: boolean;
87
93
  /** Asks before closing while dirty, with this text and Discard and Keep editing in the footer. */
88
94
  confirmDiscard?: string;
89
95
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/ui-react",
3
- "version": "0.148.0",
3
+ "version": "0.149.0",
4
4
  "description": "Webority shared React component library — App* primitives on react-bootstrap + the @webority/theme design system.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -29,13 +29,13 @@
29
29
  },
30
30
  "sideEffects": false,
31
31
  "dependencies": {
32
- "@webority/markdown-core": "0.148.0",
33
- "@webority/theme": "0.148.0",
34
- "@webority/ui-elements": "0.148.0",
35
- "@webority/web-core": "0.148.0"
32
+ "@webority/markdown-core": "0.149.0",
33
+ "@webority/theme": "0.149.0",
34
+ "@webority/ui-elements": "0.149.0",
35
+ "@webority/web-core": "0.149.0"
36
36
  },
37
37
  "peerDependencies": {
38
- "@webority/analytics": "^0.36.0",
38
+ "@webority/analytics": "^0.37.0",
39
39
  "bootstrap": "5.3.8",
40
40
  "react": "^19.0.0",
41
41
  "react-bootstrap": "^2.10.0",
@@ -49,9 +49,9 @@
49
49
  "@types/react": "^19.2.17",
50
50
  "@vitejs/plugin-react": "^6.0.1",
51
51
  "@vitest/coverage-v8": "5.1.0",
52
- "@webority/analytics": "0.36.1",
53
- "@webority/canvas-kit": "0.148.0",
54
- "@webority/tokens": "0.148.0",
52
+ "@webority/analytics": "0.37.0",
53
+ "@webority/canvas-kit": "0.149.0",
54
+ "@webority/tokens": "0.149.0",
55
55
  "bootstrap": "5.3.8",
56
56
  "jsdom": "30.1.1",
57
57
  "react": "^19.3.1",