@rexezuge/web 1.0.9 → 1.2.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.
Files changed (54) hide show
  1. package/README.md +28 -13
  2. package/dist/AppPage.d.ts +33 -0
  3. package/dist/AppPage.d.ts.map +1 -0
  4. package/dist/AppPage.js +7 -0
  5. package/dist/AppPage.js.map +1 -0
  6. package/dist/ContextBar.d.ts +43 -0
  7. package/dist/ContextBar.d.ts.map +1 -0
  8. package/dist/ContextBar.js +7 -0
  9. package/dist/ContextBar.js.map +1 -0
  10. package/dist/LanguageSelector.d.ts +57 -0
  11. package/dist/LanguageSelector.d.ts.map +1 -0
  12. package/dist/LanguageSelector.js +12 -0
  13. package/dist/LanguageSelector.js.map +1 -0
  14. package/dist/ModalShell.d.ts +53 -0
  15. package/dist/ModalShell.d.ts.map +1 -0
  16. package/dist/ModalShell.js +22 -0
  17. package/dist/ModalShell.js.map +1 -0
  18. package/dist/NoticeBar.d.ts +50 -0
  19. package/dist/NoticeBar.d.ts.map +1 -0
  20. package/dist/NoticeBar.js +12 -0
  21. package/dist/NoticeBar.js.map +1 -0
  22. package/dist/PageHeaderCard.d.ts +40 -0
  23. package/dist/PageHeaderCard.d.ts.map +1 -0
  24. package/dist/PageHeaderCard.js +7 -0
  25. package/dist/PageHeaderCard.js.map +1 -0
  26. package/dist/PageState.d.ts +47 -0
  27. package/dist/PageState.d.ts.map +1 -0
  28. package/dist/PageState.js +47 -0
  29. package/dist/PageState.js.map +1 -0
  30. package/dist/ReadOnlyField.d.ts +49 -0
  31. package/dist/ReadOnlyField.d.ts.map +1 -0
  32. package/dist/ReadOnlyField.js +17 -0
  33. package/dist/ReadOnlyField.js.map +1 -0
  34. package/dist/RefreshButton.d.ts +36 -0
  35. package/dist/RefreshButton.d.ts.map +1 -0
  36. package/dist/RefreshButton.js +8 -0
  37. package/dist/RefreshButton.js.map +1 -0
  38. package/dist/TypeToConfirmModal.d.ts +47 -0
  39. package/dist/TypeToConfirmModal.d.ts.map +1 -0
  40. package/dist/TypeToConfirmModal.js +24 -0
  41. package/dist/TypeToConfirmModal.js.map +1 -0
  42. package/dist/Unauthorized.d.ts +45 -0
  43. package/dist/Unauthorized.d.ts.map +1 -0
  44. package/dist/Unauthorized.js +11 -0
  45. package/dist/Unauthorized.js.map +1 -0
  46. package/dist/index.d.ts +44 -1
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +41 -1
  49. package/dist/index.js.map +1 -1
  50. package/dist/useCopyToClipboard.d.ts +54 -0
  51. package/dist/useCopyToClipboard.d.ts.map +1 -0
  52. package/dist/useCopyToClipboard.js +40 -0
  53. package/dist/useCopyToClipboard.js.map +1 -0
  54. package/package.json +5 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCopyToClipboard.js","sourceRoot":"","sources":["../src/useCopyToClipboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAsDvD,SAAS,kBAAkB;IACzB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,MAAM,CAAuC,IAAI,CAAC,CAAC;IAEtE,SAAS,CACP,GAAG,EAAE,CAAC,GAAG,EAAE;QACT,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI;YAAE,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACpE,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,IAAY,EAAQ,EAAE;QAC9C,wEAAwE;QACxE,0EAA0E;QAC1E,sEAAsE;QACtE,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,EAAE,SAAkC,CAAC;QAC3E,yEAAyE;QACzE,IAAI,CAAC,SAAS;YAAE,OAAO;QAEvB,KAAK,SAAS;aACX,SAAS,CAAC,IAAI,CAAC;aACf,IAAI,CAAC,GAAG,EAAE;YACT,SAAS,CAAC,IAAI,CAAC,CAAC;YAChB,kEAAkE;YAClE,oEAAoE;YACpE,+DAA+D;YAC/D,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI;gBAAE,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAClE,UAAU,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;gBACnC,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;gBAC1B,SAAS,CAAC,KAAK,CAAC,CAAC;YACnB,CAAC,EAAE,wBAAwB,CAAC,CAAC;QAC/B,CAAC,CAAC;YACF,yEAAyE;YACzE,uEAAuE;YACvE,uBAAuB;aACtB,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAC1B,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { COPY_FEEDBACK_TIMEOUT_MS } from './constants';\n\n/**\n * Copy text to the clipboard, reporting success only when it happened.\n *\n * ## Provenance\n *\n * `hooks/useCopyToClipboard.ts` in **Durable-DAV** — the one copy that had\n * solved the two failures the others carried. The other three handlers were\n * inlined into `ReadOnlyField` (Edge-Git, Mail-Otter, Durable-DAV-Router) and\n * `TypeToConfirmModal`, and were byte-identical to each other.\n *\n * ## The two live bugs this converges away\n *\n * 1. **`navigator.clipboard` is absent in an insecure context.** A plain\n * `navigator.clipboard.writeText` throws *synchronously* there, so the\n * handler dies before setting state. Where it was guarded with\n * `if (clipboard)`, the guard fell through to `setCopied(true)` anyway and\n * showed a checkmark for a copy that never happened.\n * 2. **The write is a promise that rejects on a denied permission.** Awaiting\n * it is not enough; the rejection has to be handled, or it surfaces as an\n * unhandled rejection *and* the checkmark still appears.\n *\n * That second case is why this is a hook rather than a helper. The honest\n * answer — \"nothing was copied, so there is nothing to undo\" — is expressed by\n * `copied` simply never becoming true, which is state a helper function cannot\n * hold.\n *\n * Every call site in the family is a secret reveal: a bucket credential's\n * copy-once password, a resource name typed to confirm a destructive action.\n * A false success sends the operator away believing they have something they do\n * not.\n *\n * ## Timer handling\n *\n * The reset timer is a ref and is cleared on unmount. Local `setTimeout` handles\n * in the inlined copies leaked both ways: a modal closed inside the feedback\n * window set state on an unmounted component, and repeated clicks each replaced\n * the timer without cancelling the previous one, so an early timer could clear\n * the checkmark while a later copy was still pending.\n */\n\ninterface UseCopyToClipboardResult {\n /**\n * True only after a write that actually resolved.\n *\n * Never optimistically set: a denied permission or an insecure context leaves\n * this `false`, which is the answer that matters — there is nothing to undo.\n */\n copied: boolean;\n /** Writes `text`, or does nothing if the clipboard is unavailable. */\n copy: (text: string) => void;\n}\n\nfunction useCopyToClipboard(): UseCopyToClipboardResult {\n const [copied, setCopied] = useState(false);\n const resetTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(\n () => () => {\n if (resetTimer.current !== null) clearTimeout(resetTimer.current);\n },\n [],\n );\n\n const copy = useCallback((text: string): void => {\n // Optional chaining rather than an assumption: `navigator.clipboard` is\n // genuinely absent over plain HTTP, and for a self-hosted deployment over\n // plain HTTP that is a normal configuration, not an error to surface.\n const clipboard = globalThis.navigator?.clipboard as Clipboard | undefined;\n // Nothing was copied, so there is nothing to report and nothing to undo.\n if (!clipboard) return;\n\n void clipboard\n .writeText(text)\n .then(() => {\n setCopied(true);\n // Cancel any pending reset before arming a new one. Replacing the\n // handle without clearing leaves the earlier timer live, and it can\n // clear the checkmark for a copy that is still being reported.\n if (resetTimer.current !== null) clearTimeout(resetTimer.current);\n resetTimer.current = setTimeout(() => {\n resetTimer.current = null;\n setCopied(false);\n }, COPY_FEEDBACK_TIMEOUT_MS);\n })\n // Leave `copied` false rather than flashing and clearing it: a rejection\n // means the text is still on screen and unread, so the affordance must\n // not claim otherwise.\n .catch(() => undefined);\n }, []);\n\n return { copied, copy };\n}\n\nexport { useCopyToClipboard };\nexport type { UseCopyToClipboardResult };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rexezuge/web",
3
- "version": "1.0.9",
3
+ "version": "1.2.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -25,10 +25,11 @@
25
25
  "dist"
26
26
  ],
27
27
  "dependencies": {
28
- "@rexezuge/errors": "1.0.9",
29
- "@rexezuge/shared": "1.0.9"
28
+ "@rexezuge/errors": "1.2.0",
29
+ "@rexezuge/shared": "1.2.0"
30
30
  },
31
31
  "peerDependencies": {
32
+ "lucide-react": "^1.49.0",
32
33
  "react": "^19.3.0",
33
34
  "react-dom": "^19.3.0"
34
35
  },
@@ -40,6 +41,7 @@
40
41
  "@types/react-dom": "19.3.0",
41
42
  "i18next": "26.4.2",
42
43
  "jsdom": "30.1.1",
44
+ "lucide-react": "1.52.0",
43
45
  "react": "19.3.0",
44
46
  "react-dom": "19.3.0",
45
47
  "react-i18next": "17.0.15",