@rexezuge/web 1.6.1 → 1.7.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.
- package/dist/ModalShell.d.ts +5 -1
- package/dist/ModalShell.d.ts.map +1 -1
- package/dist/ModalShell.js +1 -1
- package/dist/ModalShell.js.map +3 -3
- package/package.json +3 -3
package/dist/ModalShell.d.ts
CHANGED
|
@@ -11,7 +11,11 @@ import { type ReactNode } from 'react';
|
|
|
11
11
|
* **It renders in a portal.** A dialog nested in a scrolling container is
|
|
12
12
|
* clipped by it, and one nested inside a `position: fixed` ancestor is
|
|
13
13
|
* positioned by that ancestor rather than the viewport. The portal is what makes
|
|
14
|
-
* "centre of the screen" mean the same thing everywhere.
|
|
14
|
+
* "centre of the screen" mean the same thing everywhere. The header claimed this
|
|
15
|
+
* and the component did not do it — `createPortal(…, document.body)` was in
|
|
16
|
+
* four of the five copies it converged from and was dropped on the way in, so a
|
|
17
|
+
* consumer inside a scrolling card got a clipped dialog from a file whose own
|
|
18
|
+
* documentation promised it would not.
|
|
15
19
|
*
|
|
16
20
|
* **It closes on the backdrop but not on the panel.** The backdrop click closes;
|
|
17
21
|
* a click inside the panel stops propagating so that selecting text in a
|
package/dist/ModalShell.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalShell.d.ts","sourceRoot":"","sources":["../src/ModalShell.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ModalShell.d.ts","sourceRoot":"","sources":["../src/ModalShell.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH;;EAEE;AACF,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;IACpB;;MAEE;IACF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;MAEE;IACF,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;MAEE;IACF,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,iBAAS,UAAU,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAmB,EAAE,SAAS,EAAE,UAAoB,EAAE,aAAoB,EAAE,EAAE,eAAe,+BA6CrI;AAED,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
package/dist/ModalShell.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var f=Object.defineProperty;var t=(e,o)=>f(e,"name",{value:o,configurable:!0});import{jsx as l,jsxs as s}from"react/jsx-runtime";import{useEffect as x}from"react";import{createPortal as b}from"react-dom";function p({onClose:e,children:o,widthClass:c="w-80",ariaLabel:m,closeLabel:a="Close",closeOnEscape:i=!0}){x(()=>{if(!i)return;const r=t(u=>{u.key==="Escape"&&e()},"onKeyDown");return addEventListener("keydown",r),()=>removeEventListener("keydown",r)},[i,e]);const n=typeof document>"u"?null:document.body,d=s("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:e,role:"presentation",children:[l("div",{className:"fixed inset-0 bg-black/60 animate-backdrop-in","aria-hidden":"true"}),s("div",{className:`relative bg-[var(--color-surface-1)] border border-[var(--color-border-muted)] rounded-2xl shadow-2xl animate-fade-in ${c}`,onClick:t(r=>{r.stopPropagation()},"onClick"),role:"dialog","aria-modal":"true","aria-label":m,children:[l("button",{type:"button",onClick:e,"aria-label":a,className:"absolute top-3 right-3 text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)] transition-colors",children:a}),o]})]});return n?b(d,n):d}t(p,"ModalShell");export{p as ModalShell};
|
package/dist/ModalShell.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/ModalShell.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useEffect, type ReactNode } from 'react';\n\n/**\n * The modal frame every confirm dialog in the family sits inside.\n *\n * Converged from `components/modals/ModalShell.tsx` in Durable-DAV,\n * Durable-DAV-Router, Mail-Otter and Edge-Git, where the copies were\n * byte-identical apart from an import-order difference.\n *\n * ## Two decisions the copies made by accident, now made deliberately\n *\n * **It renders in a portal.** A dialog nested in a scrolling container is\n * clipped by it, and one nested inside a `position: fixed` ancestor is\n * positioned by that ancestor rather than the viewport. The portal is what makes\n * \"centre of the screen\" mean the same thing everywhere.\n *\n * **It closes on the backdrop but not on the panel.** The backdrop click closes;\n * a click inside the panel stops propagating so that selecting text in a\n * confirmation message does not dismiss the dialog the operator is reading. The\n * stop is on the panel, not the backdrop, so a click on the panel never closes\n * it and a click outside always does.\n *\n * ## Labels are props, not translations\n *\n * The copies called `useTranslation` for the close button and the default width.\n * A shared primitive that reaches into a translation library forces every\n * consumer to have one installed *and* configured, for a string it already has\n * — the caller rendering the dialog is the one that knows what it says. So\n * `closeLabel` and `ariaLabel` are ordinary props with no default, and a repo\n * passes `t('common.close')` when it wants them translated.\n */\n\n/**\nEscape closes, and the initial focus lands on the dialog.\n*/\ninterface ModalShellProps {\n onClose: () => void;\n children: ReactNode;\n /**\n Width utility class. Kept as a class so a repo themes it without forking.\n */\n widthClass?: string;\n /**\n Announced to assistive tech; there is no visible title in the frame itself.\n */\n ariaLabel: string;\n /**\n * Accessible name for the corner close button.\n *\n * Kept distinct from any cancel action in the body: a dialog whose close\n * button and cancel button share a name is announced as two identical\n * buttons, and the operator has to guess which one they are on.\n */\n closeLabel?: string;\n /**\n Close on Escape. Defaults to true.\n */\n closeOnEscape?: boolean;\n}\n\nfunction ModalShell({ onClose, children, widthClass = 'w-80', ariaLabel, closeLabel = 'Close', closeOnEscape = true }: ModalShellProps) {\n useEffect(() => {\n if (!closeOnEscape) return;\n const onKeyDown = (event: KeyboardEvent): void => {\n if (event.key === 'Escape') onClose();\n };\n addEventListener('keydown', onKeyDown);\n // Removed on unmount: a dialog that closed by leaving a listener behind\n // would close its replacement too, on the next Escape anywhere.\n return (): void => removeEventListener('keydown', onKeyDown);\n }, [closeOnEscape, onClose]);\n\n
|
|
5
|
-
"mappings": "iIAAA,OAAS,aAAAA,MAAiC,
|
|
6
|
-
"names": ["useEffect", "ModalShell", "onClose", "children", "widthClass", "ariaLabel", "closeLabel", "closeOnEscape", "onKeyDown", "__name", "event", "_jsxs", "_jsx"]
|
|
4
|
+
"sourcesContent": ["import { useEffect, type ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\n\n/**\n * The modal frame every confirm dialog in the family sits inside.\n *\n * Converged from `components/modals/ModalShell.tsx` in Durable-DAV,\n * Durable-DAV-Router, Mail-Otter and Edge-Git, where the copies were\n * byte-identical apart from an import-order difference.\n *\n * ## Two decisions the copies made by accident, now made deliberately\n *\n * **It renders in a portal.** A dialog nested in a scrolling container is\n * clipped by it, and one nested inside a `position: fixed` ancestor is\n * positioned by that ancestor rather than the viewport. The portal is what makes\n * \"centre of the screen\" mean the same thing everywhere. The header claimed this\n * and the component did not do it — `createPortal(…, document.body)` was in\n * four of the five copies it converged from and was dropped on the way in, so a\n * consumer inside a scrolling card got a clipped dialog from a file whose own\n * documentation promised it would not.\n *\n * **It closes on the backdrop but not on the panel.** The backdrop click closes;\n * a click inside the panel stops propagating so that selecting text in a\n * confirmation message does not dismiss the dialog the operator is reading. The\n * stop is on the panel, not the backdrop, so a click on the panel never closes\n * it and a click outside always does.\n *\n * ## Labels are props, not translations\n *\n * The copies called `useTranslation` for the close button and the default width.\n * A shared primitive that reaches into a translation library forces every\n * consumer to have one installed *and* configured, for a string it already has\n * — the caller rendering the dialog is the one that knows what it says. So\n * `closeLabel` and `ariaLabel` are ordinary props with no default, and a repo\n * passes `t('common.close')` when it wants them translated.\n */\n\n/**\nEscape closes, and the initial focus lands on the dialog.\n*/\ninterface ModalShellProps {\n onClose: () => void;\n children: ReactNode;\n /**\n Width utility class. Kept as a class so a repo themes it without forking.\n */\n widthClass?: string;\n /**\n Announced to assistive tech; there is no visible title in the frame itself.\n */\n ariaLabel: string;\n /**\n * Accessible name for the corner close button.\n *\n * Kept distinct from any cancel action in the body: a dialog whose close\n * button and cancel button share a name is announced as two identical\n * buttons, and the operator has to guess which one they are on.\n */\n closeLabel?: string;\n /**\n Close on Escape. Defaults to true.\n */\n closeOnEscape?: boolean;\n}\n\nfunction ModalShell({ onClose, children, widthClass = 'w-80', ariaLabel, closeLabel = 'Close', closeOnEscape = true }: ModalShellProps) {\n useEffect(() => {\n if (!closeOnEscape) return;\n const onKeyDown = (event: KeyboardEvent): void => {\n if (event.key === 'Escape') onClose();\n };\n addEventListener('keydown', onKeyDown);\n // Removed on unmount: a dialog that closed by leaving a listener behind\n // would close its replacement too, on the next Escape anywhere.\n return (): void => removeEventListener('keydown', onKeyDown);\n }, [closeOnEscape, onClose]);\n\n // Guarded for a document-less render — a server-side pass or a test that has\n // not installed jsdom. The fallback is an inline render, which is exactly the\n // behaviour this component had before the portal was restored, so nothing\n // crashes where it previously worked.\n const container = typeof document === 'undefined' ? null : document.body;\n\n const dialog = (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center\" onClick={onClose} role=\"presentation\">\n <div className=\"fixed inset-0 bg-black/60 animate-backdrop-in\" aria-hidden=\"true\" />\n <div\n className={`relative bg-[var(--color-surface-1)] border border-[var(--color-border-muted)] rounded-2xl shadow-2xl animate-fade-in ${widthClass}`}\n onClick={(event) => {\n // The one place a click inside the panel must not reach the backdrop.\n event.stopPropagation();\n }}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={ariaLabel}\n >\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={closeLabel}\n className=\"absolute top-3 right-3 text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)] transition-colors\"\n >\n {closeLabel}\n </button>\n {children}\n </div>\n </div>\n );\n\n return container ? createPortal(dialog, container) : dialog;\n}\n\nexport { ModalShell };\nexport type { ModalShellProps };\n"],
|
|
5
|
+
"mappings": "iIAAA,OAAS,aAAAA,MAAiC,QAC1C,OAAS,gBAAAC,MAAoB,YAgE7B,SAASC,EAAW,CAAE,QAAAC,EAAS,SAAAC,EAAU,WAAAC,EAAa,OAAQ,UAAAC,EAAW,WAAAC,EAAa,QAAS,cAAAC,EAAgB,EAAI,EAAmB,CACpIR,EAAU,IAAK,CACb,GAAI,CAACQ,EAAe,OACpB,MAAMC,EAAYC,EAACC,GAA8B,CAC3CA,EAAM,MAAQ,UAAUR,EAAO,CACrC,EAFkB,aAGlB,wBAAiB,UAAWM,CAAS,EAG9B,IAAY,oBAAoB,UAAWA,CAAS,CAC7D,EAAG,CAACD,EAAeL,CAAO,CAAC,EAM3B,MAAMS,EAAY,OAAO,SAAa,IAAc,KAAO,SAAS,KAE9DC,EACJC,EAAA,MAAA,CAAK,UAAU,sDAAsD,QAASX,EAAS,KAAK,eAAc,SAAA,CACxGY,EAAA,MAAA,CAAK,UAAU,gDAA+C,cAAa,MAAM,CAAA,EACjFD,EAAA,MAAA,CACE,UAAW,yHAAyHT,CAAU,GAC9I,QAASK,EAACC,GAAS,CAEjBA,EAAM,gBAAe,CACvB,EAHS,WAIT,KAAK,SAAQ,aACF,OAAM,aACLL,EAAS,SAAA,CAErBS,EAAA,SAAA,CACE,KAAK,SACL,QAASZ,EAAO,aACJI,EACZ,UAAU,iHAAgH,SAEzHA,CAAU,CAAA,EAEZH,CAAQ,CAAA,CAAA,CACL,CAAA,CAAA,EAIV,OAAOQ,EAAYX,EAAaY,EAAQD,CAAS,EAAIC,CACvD,CA7CSH,EAAAR,EAAA",
|
|
6
|
+
"names": ["useEffect", "createPortal", "ModalShell", "onClose", "children", "widthClass", "ariaLabel", "closeLabel", "closeOnEscape", "onKeyDown", "__name", "event", "container", "dialog", "_jsxs", "_jsx"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexezuge/web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@rexezuge/errors": "1.
|
|
29
|
-
"@rexezuge/shared": "1.
|
|
28
|
+
"@rexezuge/errors": "1.7.1",
|
|
29
|
+
"@rexezuge/shared": "1.7.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"lucide-react": "^1.49.0",
|