@rexezuge/web 1.1.0 → 1.3.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.
- package/README.md +28 -13
- package/dist/AppPage.d.ts +33 -0
- package/dist/AppPage.d.ts.map +1 -0
- package/dist/AppPage.js +7 -0
- package/dist/AppPage.js.map +1 -0
- package/dist/Badge.js +1 -1
- package/dist/Badge.js.map +1 -1
- package/dist/Button.js +2 -2
- package/dist/Button.js.map +1 -1
- package/dist/Card.js +1 -1
- package/dist/Card.js.map +1 -1
- package/dist/ContextBar.d.ts +43 -0
- package/dist/ContextBar.d.ts.map +1 -0
- package/dist/ContextBar.js +7 -0
- package/dist/ContextBar.js.map +1 -0
- package/dist/FocusInput.js +2 -2
- package/dist/FocusInput.js.map +1 -1
- package/dist/Input.js +1 -1
- package/dist/Input.js.map +1 -1
- package/dist/LanguageSelector.d.ts +57 -0
- package/dist/LanguageSelector.d.ts.map +1 -0
- package/dist/LanguageSelector.js +12 -0
- package/dist/LanguageSelector.js.map +1 -0
- package/dist/LoadingButton.d.ts +1 -1
- package/dist/LoadingButton.d.ts.map +1 -1
- package/dist/LoadingButton.js +1 -1
- package/dist/LoadingButton.js.map +1 -1
- package/dist/NoticeBar.d.ts +50 -0
- package/dist/NoticeBar.d.ts.map +1 -0
- package/dist/NoticeBar.js +12 -0
- package/dist/NoticeBar.js.map +1 -0
- package/dist/PageHeaderCard.d.ts +40 -0
- package/dist/PageHeaderCard.d.ts.map +1 -0
- package/dist/PageHeaderCard.js +7 -0
- package/dist/PageHeaderCard.js.map +1 -0
- package/dist/PageState.js +1 -1
- package/dist/PageState.js.map +1 -1
- package/dist/Pagination.js +2 -2
- package/dist/Pagination.js.map +1 -1
- package/dist/ReadOnlyField.d.ts +49 -0
- package/dist/ReadOnlyField.d.ts.map +1 -0
- package/dist/ReadOnlyField.js +17 -0
- package/dist/ReadOnlyField.js.map +1 -0
- package/dist/RefreshButton.d.ts +36 -0
- package/dist/RefreshButton.d.ts.map +1 -0
- package/dist/RefreshButton.js +8 -0
- package/dist/RefreshButton.js.map +1 -0
- package/dist/Spinner.js +1 -1
- package/dist/Spinner.js.map +1 -1
- package/dist/TypeToConfirmModal.d.ts +47 -0
- package/dist/TypeToConfirmModal.d.ts.map +1 -0
- package/dist/TypeToConfirmModal.js +24 -0
- package/dist/TypeToConfirmModal.js.map +1 -0
- package/dist/Unauthorized.d.ts +45 -0
- package/dist/Unauthorized.d.ts.map +1 -0
- package/dist/Unauthorized.js +11 -0
- package/dist/Unauthorized.js.map +1 -0
- package/dist/index.d.ts +72 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -18
- package/dist/index.js.map +1 -1
- package/dist/useCopyToClipboard.d.ts +54 -0
- package/dist/useCopyToClipboard.d.ts.map +1 -0
- package/dist/useCopyToClipboard.js +40 -0
- package/dist/useCopyToClipboard.js.map +1 -0
- package/dist/useCurrentUser.d.ts +1 -1
- package/dist/useCurrentUser.d.ts.map +1 -1
- package/dist/useCurrentUser.js.map +1 -1
- package/dist/useNotice.js +1 -1
- package/dist/useNotice.js.map +1 -1
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* module for what it replaced and which copy won.
|
|
8
8
|
*
|
|
9
9
|
* ```ts
|
|
10
|
-
* import { Button, Card, createApiClient, useCurrentUser, useNotice, useSpaLanguage } from '@rexezuge/web';
|
|
10
|
+
* import { AppPage, Button, Card, createApiClient, useCurrentUser, useNotice, useSpaLanguage } from '@rexezuge/web';
|
|
11
11
|
* ```
|
|
12
12
|
*
|
|
13
13
|
* ## What a consumer must provide
|
|
@@ -23,6 +23,26 @@
|
|
|
23
23
|
* - **A dependency on `@rexezuge/errors`**, which `api.ts` imports for
|
|
24
24
|
* `ServiceError` and the status classes.
|
|
25
25
|
*
|
|
26
|
+
* ## Glyphs in, strings out
|
|
27
|
+
*
|
|
28
|
+
* Three components (`RefreshButton`, `ReadOnlyField`, `TypeToConfirmModal`) take
|
|
29
|
+
* their icon from `lucide-react`, which is why it is a peer rather than a
|
|
30
|
+
* dependency. Everything *sayable* is a prop: no component here calls
|
|
31
|
+
* `useTranslation`, because the app rendering a dialog knows what it says and a
|
|
32
|
+
* kit that hard-codes English for it has taken over the app's string catalogue.
|
|
33
|
+
*
|
|
34
|
+
* The dividing line is deliberate. `Button` keeps using this package's own
|
|
35
|
+
* `Spinner` rather than lucide's `Loader2` — chrome is cheap to draw, iconography
|
|
36
|
+
* is not, and vendoring a glyph's path data freezes it at whatever version was
|
|
37
|
+
* current when it was copied.
|
|
38
|
+
*
|
|
39
|
+
* ## Migrating the copies
|
|
40
|
+
*
|
|
41
|
+
* `codemods/` rewrites the family's `../components/…` imports onto this package
|
|
42
|
+
* for every component converged here, and names the ones it has not. Those
|
|
43
|
+
* imports are **relative**, so this is a separate transform from the
|
|
44
|
+
* `@scope/pkg` one — see `codemods/src/web-components.ts`.
|
|
45
|
+
*
|
|
26
46
|
* ## What is deliberately not here
|
|
27
47
|
*
|
|
28
48
|
* Domain badges (`ConnectionBadge`, `TaskRunStatusBadge`, …), the OAuth
|
|
@@ -31,35 +51,55 @@
|
|
|
31
51
|
* exactly one consumer, so each stays with it — see `constants.ts` and the
|
|
32
52
|
* per-module provenance notes for the list.
|
|
33
53
|
*/
|
|
34
|
-
export { Badge, badgeBaseClass, badgeClass, badgeVariantClass } from './Badge';
|
|
35
|
-
export type { BadgeProps, BadgeVariant } from './Badge';
|
|
36
|
-
export { Button, buttonBaseClass, buttonClass, buttonSizeClass, buttonVariantClass } from './Button';
|
|
37
|
-
export type { ButtonProps, ButtonSize, ButtonVariant } from './Button';
|
|
38
|
-
export { Card, cardClass, cardHeaderClass, cardTitleClass, CardHeader, CardTitle } from './Card';
|
|
39
|
-
export type { CardHeaderProps, CardProps, CardTitleProps } from './Card';
|
|
40
|
-
export { FocusInput } from './FocusInput';
|
|
41
|
-
export type { FocusInputProps } from './FocusInput';
|
|
42
|
-
export { Input, Label, Select, Textarea, fieldClass } from './Input';
|
|
43
|
-
export type { InputProps, LabelProps, SelectProps, TextareaProps } from './Input';
|
|
44
|
-
export { LoadingButton } from './LoadingButton';
|
|
45
|
-
export type { LoadingButtonProps } from './LoadingButton';
|
|
46
|
-
export { ModalShell } from './ModalShell';
|
|
47
|
-
export type { ModalShellProps } from './ModalShell';
|
|
48
|
-
export { ConfirmDeleteModal, EmptyState, LoadingSpinner } from './PageState';
|
|
49
|
-
export {
|
|
50
|
-
export type {
|
|
51
|
-
export {
|
|
52
|
-
export type {
|
|
53
|
-
export {
|
|
54
|
-
export {
|
|
55
|
-
export
|
|
56
|
-
export {
|
|
57
|
-
export {
|
|
58
|
-
export type {
|
|
59
|
-
export {
|
|
60
|
-
export type {
|
|
61
|
-
export {
|
|
62
|
-
export type {
|
|
63
|
-
export {
|
|
64
|
-
export type {
|
|
54
|
+
export { Badge, badgeBaseClass, badgeClass, badgeVariantClass } from './Badge.tsx';
|
|
55
|
+
export type { BadgeProps, BadgeVariant } from './Badge.tsx';
|
|
56
|
+
export { Button, buttonBaseClass, buttonClass, buttonSizeClass, buttonVariantClass } from './Button.tsx';
|
|
57
|
+
export type { ButtonProps, ButtonSize, ButtonVariant } from './Button.tsx';
|
|
58
|
+
export { Card, cardClass, cardHeaderClass, cardTitleClass, CardHeader, CardTitle } from './Card.tsx';
|
|
59
|
+
export type { CardHeaderProps, CardProps, CardTitleProps } from './Card.tsx';
|
|
60
|
+
export { FocusInput } from './FocusInput.tsx';
|
|
61
|
+
export type { FocusInputProps } from './FocusInput.tsx';
|
|
62
|
+
export { Input, Label, Select, Textarea, fieldClass } from './Input.tsx';
|
|
63
|
+
export type { InputProps, LabelProps, SelectProps, TextareaProps } from './Input.tsx';
|
|
64
|
+
export { LoadingButton } from './LoadingButton.tsx';
|
|
65
|
+
export type { LoadingButtonProps } from './LoadingButton.tsx';
|
|
66
|
+
export { ModalShell } from './ModalShell.tsx';
|
|
67
|
+
export type { ModalShellProps } from './ModalShell.tsx';
|
|
68
|
+
export { ConfirmDeleteModal, EmptyState, LoadingSpinner } from './PageState.tsx';
|
|
69
|
+
export { AppPage } from './AppPage.tsx';
|
|
70
|
+
export type { AppPageProps, AppPageVariant } from './AppPage.tsx';
|
|
71
|
+
export { PageHeaderCard } from './PageHeaderCard.tsx';
|
|
72
|
+
export type { PageHeaderCardProps } from './PageHeaderCard.tsx';
|
|
73
|
+
export { ContextBar } from './ContextBar.tsx';
|
|
74
|
+
export type { ContextBarProps } from './ContextBar.tsx';
|
|
75
|
+
export { Unauthorized } from './Unauthorized.tsx';
|
|
76
|
+
export type { UnauthorizedProps } from './Unauthorized.tsx';
|
|
77
|
+
export { NoticeBar } from './NoticeBar.tsx';
|
|
78
|
+
export type { NoticeBarProps, NoticeStatusLabels } from './NoticeBar.tsx';
|
|
79
|
+
export { LanguageSelector } from './LanguageSelector.tsx';
|
|
80
|
+
export type { LanguageSelectorProps } from './LanguageSelector.tsx';
|
|
81
|
+
export { RefreshButton } from './RefreshButton.tsx';
|
|
82
|
+
export type { RefreshButtonProps } from './RefreshButton.tsx';
|
|
83
|
+
export { ReadOnlyField } from './ReadOnlyField.tsx';
|
|
84
|
+
export type { ReadOnlyFieldProps } from './ReadOnlyField.tsx';
|
|
85
|
+
export { TypeToConfirmModal } from './TypeToConfirmModal.tsx';
|
|
86
|
+
export type { TypeToConfirmModalProps } from './TypeToConfirmModal.tsx';
|
|
87
|
+
export { useCopyToClipboard } from './useCopyToClipboard.ts';
|
|
88
|
+
export type { UseCopyToClipboardResult } from './useCopyToClipboard.ts';
|
|
89
|
+
export { Pagination, clampPage, pageCountFor, pageWindow } from './Pagination.tsx';
|
|
90
|
+
export type { PaginationLabels, PaginationProps } from './Pagination.tsx';
|
|
91
|
+
export { Spinner } from './Spinner.tsx';
|
|
92
|
+
export type { SpinnerProps } from './Spinner.tsx';
|
|
93
|
+
export { btnBase, btnBlueStyle, btnGreenStyle, btnSmallStyle, buttonColors, cardStyle, inputStyle, paginationBtnStyle, tableCardStyle, tdStyle, theme, thStyle, } from './theme.ts';
|
|
94
|
+
export { cn } from './utils.ts';
|
|
95
|
+
export type { ClassDictionary, ClassValue } from './utils.ts';
|
|
96
|
+
export { COPY_FEEDBACK_TIMEOUT_MS, NOTICE_TIMEOUT_MS, ZERO_TRUST_AUTHENTICATION_PATH } from './constants.ts';
|
|
97
|
+
export { useNotice } from './useNotice.ts';
|
|
98
|
+
export type { Notice, NoticeKind, ShowNotice, UseNoticeOptions, UseNoticeResult } from './useNotice.ts';
|
|
99
|
+
export { canonicalizeLanguageTag, DEFAULT_FALLBACK_LANGUAGE, DEFAULT_LANGUAGE_STORAGE_KEY, DEFAULT_SUPPORTED_LANGUAGES, resolveLanguageTag, useSpaLanguage, } from './useSpaLanguage.ts';
|
|
100
|
+
export type { LanguageTag, UseSpaLanguageOptions, UseSpaLanguageResult } from './useSpaLanguage.ts';
|
|
101
|
+
export { CURRENT_USER_PATH, useCurrentUser } from './useCurrentUser.ts';
|
|
102
|
+
export type { CurrentUser, UseCurrentUserOptions, UseCurrentUserResult } from './useCurrentUser.ts';
|
|
103
|
+
export { buildQuery, createApiClient, HttpStatusError, MAX_ERROR_MESSAGE_LENGTH } from './api.ts';
|
|
104
|
+
export type { ApiClient, ApiRequestInit, CreateApiClientOptions, FetchFn, QueryParams, QueryValue } from './api.ts';
|
|
65
105
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnF,YAA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AEpB,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAChC,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AAE7G,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAExG,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,4BAA4B,EAC5B,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEpG,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACxE,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEpG,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAClG,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,sBAAsB,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* module for what it replaced and which copy won.
|
|
8
8
|
*
|
|
9
9
|
* ```ts
|
|
10
|
-
* import { Button, Card, createApiClient, useCurrentUser, useNotice, useSpaLanguage } from '@rexezuge/web';
|
|
10
|
+
* import { AppPage, Button, Card, createApiClient, useCurrentUser, useNotice, useSpaLanguage } from '@rexezuge/web';
|
|
11
11
|
* ```
|
|
12
12
|
*
|
|
13
13
|
* ## What a consumer must provide
|
|
@@ -23,6 +23,26 @@
|
|
|
23
23
|
* - **A dependency on `@rexezuge/errors`**, which `api.ts` imports for
|
|
24
24
|
* `ServiceError` and the status classes.
|
|
25
25
|
*
|
|
26
|
+
* ## Glyphs in, strings out
|
|
27
|
+
*
|
|
28
|
+
* Three components (`RefreshButton`, `ReadOnlyField`, `TypeToConfirmModal`) take
|
|
29
|
+
* their icon from `lucide-react`, which is why it is a peer rather than a
|
|
30
|
+
* dependency. Everything *sayable* is a prop: no component here calls
|
|
31
|
+
* `useTranslation`, because the app rendering a dialog knows what it says and a
|
|
32
|
+
* kit that hard-codes English for it has taken over the app's string catalogue.
|
|
33
|
+
*
|
|
34
|
+
* The dividing line is deliberate. `Button` keeps using this package's own
|
|
35
|
+
* `Spinner` rather than lucide's `Loader2` — chrome is cheap to draw, iconography
|
|
36
|
+
* is not, and vendoring a glyph's path data freezes it at whatever version was
|
|
37
|
+
* current when it was copied.
|
|
38
|
+
*
|
|
39
|
+
* ## Migrating the copies
|
|
40
|
+
*
|
|
41
|
+
* `codemods/` rewrites the family's `../components/…` imports onto this package
|
|
42
|
+
* for every component converged here, and names the ones it has not. Those
|
|
43
|
+
* imports are **relative**, so this is a separate transform from the
|
|
44
|
+
* `@scope/pkg` one — see `codemods/src/web-components.ts`.
|
|
45
|
+
*
|
|
26
46
|
* ## What is deliberately not here
|
|
27
47
|
*
|
|
28
48
|
* Domain badges (`ConnectionBadge`, `TaskRunStatusBadge`, …), the OAuth
|
|
@@ -31,25 +51,39 @@
|
|
|
31
51
|
* exactly one consumer, so each stays with it — see `constants.ts` and the
|
|
32
52
|
* per-module provenance notes for the list.
|
|
33
53
|
*/
|
|
34
|
-
export { Badge, badgeBaseClass, badgeClass, badgeVariantClass } from
|
|
35
|
-
export { Button, buttonBaseClass, buttonClass, buttonSizeClass, buttonVariantClass } from
|
|
36
|
-
export { Card, cardClass, cardHeaderClass, cardTitleClass, CardHeader, CardTitle } from
|
|
37
|
-
export { FocusInput } from
|
|
38
|
-
export { Input, Label, Select, Textarea, fieldClass } from
|
|
39
|
-
export { LoadingButton } from
|
|
54
|
+
export { Badge, badgeBaseClass, badgeClass, badgeVariantClass } from "./Badge.js";
|
|
55
|
+
export { Button, buttonBaseClass, buttonClass, buttonSizeClass, buttonVariantClass } from "./Button.js";
|
|
56
|
+
export { Card, cardClass, cardHeaderClass, cardTitleClass, CardHeader, CardTitle } from "./Card.js";
|
|
57
|
+
export { FocusInput } from "./FocusInput.js";
|
|
58
|
+
export { Input, Label, Select, Textarea, fieldClass } from "./Input.js";
|
|
59
|
+
export { LoadingButton } from "./LoadingButton.js";
|
|
40
60
|
// Converged from the `ModalShell` / `ConfirmDeleteModal` / `PageState` copies
|
|
41
61
|
// that Durable-DAV, Durable-DAV-Router, Mail-Otter and Edge-Git each shipped.
|
|
42
62
|
// Deliberately dependency-free — labels are props, not `useTranslation` — so
|
|
43
63
|
// adopting these does not require a translation library or an icon set.
|
|
44
|
-
export { ModalShell } from
|
|
45
|
-
export { ConfirmDeleteModal, EmptyState, LoadingSpinner } from
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
export {
|
|
51
|
-
export {
|
|
52
|
-
export {
|
|
53
|
-
export {
|
|
54
|
-
export {
|
|
64
|
+
export { ModalShell } from "./ModalShell.js";
|
|
65
|
+
export { ConfirmDeleteModal, EmptyState, LoadingSpinner } from "./PageState.js";
|
|
66
|
+
// The second convergence round: page layout, the notice banner, the access
|
|
67
|
+
// page, the language picker, and the two clipboard-bearing controls. Same rule
|
|
68
|
+
// on labels — the app owns its string catalogue. Three of these need
|
|
69
|
+
// `lucide-react`, which is why it is a peer and not a dependency.
|
|
70
|
+
export { AppPage } from "./AppPage.js";
|
|
71
|
+
export { PageHeaderCard } from "./PageHeaderCard.js";
|
|
72
|
+
export { ContextBar } from "./ContextBar.js";
|
|
73
|
+
export { Unauthorized } from "./Unauthorized.js";
|
|
74
|
+
export { NoticeBar } from "./NoticeBar.js";
|
|
75
|
+
export { LanguageSelector } from "./LanguageSelector.js";
|
|
76
|
+
export { RefreshButton } from "./RefreshButton.js";
|
|
77
|
+
export { ReadOnlyField } from "./ReadOnlyField.js";
|
|
78
|
+
export { TypeToConfirmModal } from "./TypeToConfirmModal.js";
|
|
79
|
+
export { useCopyToClipboard } from "./useCopyToClipboard.js";
|
|
80
|
+
export { Pagination, clampPage, pageCountFor, pageWindow } from "./Pagination.js";
|
|
81
|
+
export { Spinner } from "./Spinner.js";
|
|
82
|
+
export { btnBase, btnBlueStyle, btnGreenStyle, btnSmallStyle, buttonColors, cardStyle, inputStyle, paginationBtnStyle, tableCardStyle, tdStyle, theme, thStyle, } from "./theme.js";
|
|
83
|
+
export { cn } from "./utils.js";
|
|
84
|
+
export { COPY_FEEDBACK_TIMEOUT_MS, NOTICE_TIMEOUT_MS, ZERO_TRUST_AUTHENTICATION_PATH } from "./constants.js";
|
|
85
|
+
export { useNotice } from "./useNotice.js";
|
|
86
|
+
export { canonicalizeLanguageTag, DEFAULT_FALLBACK_LANGUAGE, DEFAULT_LANGUAGE_STORAGE_KEY, DEFAULT_SUPPORTED_LANGUAGES, resolveLanguageTag, useSpaLanguage, } from "./useSpaLanguage.js";
|
|
87
|
+
export { CURRENT_USER_PATH, useCurrentUser } from "./useCurrentUser.js";
|
|
88
|
+
export { buildQuery, createApiClient, HttpStatusError, MAX_ERROR_MESSAGE_LENGTH } from "./api.js";
|
|
55
89
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAa,CAAC;AA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AE,UAAU,EAAE,MAAM,iBAAkB,CAAC;AAGnF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAe,CAAC;AAGxC,OAAO,EACL,OAAO,EACP,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,KAAK,EACL,OAAO,GACR,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAGhC,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AAE7G,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,4BAA4B,EAC5B,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGxE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC","sourcesContent":["/**\n * `@rexezuge/web` — the SPA layer of the kit.\n *\n * React primitives, the hooks every app's shell needs, and the one API client.\n * Every export is the converged form of a framework that lived as copies inside\n * the nine consumer repos; see the `## Provenance` block at the top of each\n * module for what it replaced and which copy won.\n *\n * ```ts\n * import { AppPage, Button, Card, createApiClient, useCurrentUser, useNotice, useSpaLanguage } from '@rexezuge/web';\n * ```\n *\n * ## What a consumer must provide\n *\n * - **The CSS variables the class-based components read.** All six Tailwind\n * repos define the same set, so this is usually already present:\n * `--color-accent`, `--color-accent-dim`, `--color-border`,\n * `--color-surface-base`, `--color-surface-1..4`,\n * `--color-text-primary`, `--color-text-secondary`, `--color-text-muted`, and\n * `--color-{success,error,warning,info,neutral}-{bg,text}`.\n * - **`animate-spin`**, for `Spinner` (and therefore `Button`'s busy state).\n * Tailwind ships it; a non-Tailwind app defines the keyframes once.\n * - **A dependency on `@rexezuge/errors`**, which `api.ts` imports for\n * `ServiceError` and the status classes.\n *\n * ## Glyphs in, strings out\n *\n * Three components (`RefreshButton`, `ReadOnlyField`, `TypeToConfirmModal`) take\n * their icon from `lucide-react`, which is why it is a peer rather than a\n * dependency. Everything *sayable* is a prop: no component here calls\n * `useTranslation`, because the app rendering a dialog knows what it says and a\n * kit that hard-codes English for it has taken over the app's string catalogue.\n *\n * The dividing line is deliberate. `Button` keeps using this package's own\n * `Spinner` rather than lucide's `Loader2` — chrome is cheap to draw, iconography\n * is not, and vendoring a glyph's path data freezes it at whatever version was\n * current when it was copied.\n *\n * ## Migrating the copies\n *\n * `codemods/` rewrites the family's `../components/…` imports onto this package\n * for every component converged here, and names the ones it has not. Those\n * imports are **relative**, so this is a separate transform from the\n * `@scope/pkg` one — see `codemods/src/web-components.ts`.\n *\n * ## What is deliberately not here\n *\n * Domain badges (`ConnectionBadge`, `TaskRunStatusBadge`, …), the OAuth\n * `?oauth2=` notice seeding, the D1 bookmark header, WebDAV `207` handling, the\n * authed-first public fallback, and every app's `SUPPORTED_LANGUAGES`. Each had\n * exactly one consumer, so each stays with it — see `constants.ts` and the\n * per-module provenance notes for the list.\n */\n\nexport { Badge, badgeBaseClass, badgeClass, badgeVariantClass } from './Badge.tsx';\nexport type { BadgeProps, BadgeVariant } from './Badge.tsx';\n\nexport { Button, buttonBaseClass, buttonClass, buttonSizeClass, buttonVariantClass } from './Button.tsx';\nexport type { ButtonProps, ButtonSize, ButtonVariant } from './Button.tsx';\n\nexport { Card, cardClass, cardHeaderClass, cardTitleClass, CardHeader, CardTitle } from './Card.tsx';\nexport type { CardHeaderProps, CardProps, CardTitleProps } from './Card.tsx';\n\nexport { FocusInput } from './FocusInput.tsx';\nexport type { FocusInputProps } from './FocusInput.tsx';\n\nexport { Input, Label, Select, Textarea, fieldClass } from './Input.tsx';\nexport type { InputProps, LabelProps, SelectProps, TextareaProps } from './Input.tsx';\n\nexport { LoadingButton } from './LoadingButton.tsx';\nexport type { LoadingButtonProps } from './LoadingButton.tsx';\n\n// Converged from the `ModalShell` / `ConfirmDeleteModal` / `PageState` copies\n// that Durable-DAV, Durable-DAV-Router, Mail-Otter and Edge-Git each shipped.\n// Deliberately dependency-free — labels are props, not `useTranslation` — so\n// adopting these does not require a translation library or an icon set.\nexport { ModalShell } from './ModalShell.tsx';\nexport type { ModalShellProps } from './ModalShell.tsx';\nexport { ConfirmDeleteModal, EmptyState, LoadingSpinner } from './PageState.tsx';\n\n// The second convergence round: page layout, the notice banner, the access\n// page, the language picker, and the two clipboard-bearing controls. Same rule\n// on labels — the app owns its string catalogue. Three of these need\n// `lucide-react`, which is why it is a peer and not a dependency.\nexport { AppPage } from './AppPage.tsx';\nexport type { AppPageProps, AppPageVariant } from './AppPage.tsx';\nexport { PageHeaderCard } from './PageHeaderCard.tsx';\nexport type { PageHeaderCardProps } from './PageHeaderCard.tsx';\nexport { ContextBar } from './ContextBar.tsx';\nexport type { ContextBarProps } from './ContextBar.tsx';\nexport { Unauthorized } from './Unauthorized.tsx';\nexport type { UnauthorizedProps } from './Unauthorized.tsx';\nexport { NoticeBar } from './NoticeBar.tsx';\nexport type { NoticeBarProps, NoticeStatusLabels } from './NoticeBar.tsx';\nexport { LanguageSelector } from './LanguageSelector.tsx';\nexport type { LanguageSelectorProps } from './LanguageSelector.tsx';\nexport { RefreshButton } from './RefreshButton.tsx';\nexport type { RefreshButtonProps } from './RefreshButton.tsx';\nexport { ReadOnlyField } from './ReadOnlyField.tsx';\nexport type { ReadOnlyFieldProps } from './ReadOnlyField.tsx';\nexport { TypeToConfirmModal } from './TypeToConfirmModal.tsx';\nexport type { TypeToConfirmModalProps } from './TypeToConfirmModal.tsx';\nexport { useCopyToClipboard } from './useCopyToClipboard.ts';\nexport type { UseCopyToClipboardResult } from './useCopyToClipboard.ts';\n\nexport { Pagination, clampPage, pageCountFor, pageWindow } from './Pagination.tsx';\nexport type { PaginationLabels, PaginationProps } from './Pagination.tsx';\n\nexport { Spinner } from './Spinner.tsx';\nexport type { SpinnerProps } from './Spinner.tsx';\n\nexport {\n btnBase,\n btnBlueStyle,\n btnGreenStyle,\n btnSmallStyle,\n buttonColors,\n cardStyle,\n inputStyle,\n paginationBtnStyle,\n tableCardStyle,\n tdStyle,\n theme,\n thStyle,\n} from './theme.ts';\n\nexport { cn } from './utils.ts';\nexport type { ClassDictionary, ClassValue } from './utils.ts';\n\nexport { COPY_FEEDBACK_TIMEOUT_MS, NOTICE_TIMEOUT_MS, ZERO_TRUST_AUTHENTICATION_PATH } from './constants.ts';\n\nexport { useNotice } from './useNotice.ts';\nexport type { Notice, NoticeKind, ShowNotice, UseNoticeOptions, UseNoticeResult } from './useNotice.ts';\n\nexport {\n canonicalizeLanguageTag,\n DEFAULT_FALLBACK_LANGUAGE,\n DEFAULT_LANGUAGE_STORAGE_KEY,\n DEFAULT_SUPPORTED_LANGUAGES,\n resolveLanguageTag,\n useSpaLanguage,\n} from './useSpaLanguage.ts';\nexport type { LanguageTag, UseSpaLanguageOptions, UseSpaLanguageResult } from './useSpaLanguage.ts';\n\nexport { CURRENT_USER_PATH, useCurrentUser } from './useCurrentUser.ts';\nexport type { CurrentUser, UseCurrentUserOptions, UseCurrentUserResult } from './useCurrentUser.ts';\n\nexport { buildQuery, createApiClient, HttpStatusError, MAX_ERROR_MESSAGE_LENGTH } from './api.ts';\nexport type { ApiClient, ApiRequestInit, CreateApiClientOptions, FetchFn, QueryParams, QueryValue } from './api.ts';\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy text to the clipboard, reporting success only when it happened.
|
|
3
|
+
*
|
|
4
|
+
* ## Provenance
|
|
5
|
+
*
|
|
6
|
+
* `hooks/useCopyToClipboard.ts` in **Durable-DAV** — the one copy that had
|
|
7
|
+
* solved the two failures the others carried. The other three handlers were
|
|
8
|
+
* inlined into `ReadOnlyField` (Edge-Git, Mail-Otter, Durable-DAV-Router) and
|
|
9
|
+
* `TypeToConfirmModal`, and were byte-identical to each other.
|
|
10
|
+
*
|
|
11
|
+
* ## The two live bugs this converges away
|
|
12
|
+
*
|
|
13
|
+
* 1. **`navigator.clipboard` is absent in an insecure context.** A plain
|
|
14
|
+
* `navigator.clipboard.writeText` throws *synchronously* there, so the
|
|
15
|
+
* handler dies before setting state. Where it was guarded with
|
|
16
|
+
* `if (clipboard)`, the guard fell through to `setCopied(true)` anyway and
|
|
17
|
+
* showed a checkmark for a copy that never happened.
|
|
18
|
+
* 2. **The write is a promise that rejects on a denied permission.** Awaiting
|
|
19
|
+
* it is not enough; the rejection has to be handled, or it surfaces as an
|
|
20
|
+
* unhandled rejection *and* the checkmark still appears.
|
|
21
|
+
*
|
|
22
|
+
* That second case is why this is a hook rather than a helper. The honest
|
|
23
|
+
* answer — "nothing was copied, so there is nothing to undo" — is expressed by
|
|
24
|
+
* `copied` simply never becoming true, which is state a helper function cannot
|
|
25
|
+
* hold.
|
|
26
|
+
*
|
|
27
|
+
* Every call site in the family is a secret reveal: a bucket credential's
|
|
28
|
+
* copy-once password, a resource name typed to confirm a destructive action.
|
|
29
|
+
* A false success sends the operator away believing they have something they do
|
|
30
|
+
* not.
|
|
31
|
+
*
|
|
32
|
+
* ## Timer handling
|
|
33
|
+
*
|
|
34
|
+
* The reset timer is a ref and is cleared on unmount. Local `setTimeout` handles
|
|
35
|
+
* in the inlined copies leaked both ways: a modal closed inside the feedback
|
|
36
|
+
* window set state on an unmounted component, and repeated clicks each replaced
|
|
37
|
+
* the timer without cancelling the previous one, so an early timer could clear
|
|
38
|
+
* the checkmark while a later copy was still pending.
|
|
39
|
+
*/
|
|
40
|
+
interface UseCopyToClipboardResult {
|
|
41
|
+
/**
|
|
42
|
+
* True only after a write that actually resolved.
|
|
43
|
+
*
|
|
44
|
+
* Never optimistically set: a denied permission or an insecure context leaves
|
|
45
|
+
* this `false`, which is the answer that matters — there is nothing to undo.
|
|
46
|
+
*/
|
|
47
|
+
copied: boolean;
|
|
48
|
+
/** Writes `text`, or does nothing if the clipboard is unavailable. */
|
|
49
|
+
copy: (text: string) => void;
|
|
50
|
+
}
|
|
51
|
+
declare function useCopyToClipboard(): UseCopyToClipboardResult;
|
|
52
|
+
export { useCopyToClipboard };
|
|
53
|
+
export type { UseCopyToClipboardResult };
|
|
54
|
+
//# sourceMappingURL=useCopyToClipboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopyToClipboard.d.ts","sourceRoot":"","sources":["../src/useCopyToClipboard.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,UAAU,wBAAwB;IAChC;;;;;OAKG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB,sEAAsE;IACtE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B;AAED,iBAAS,kBAAkB,IAAI,wBAAwB,CAuCtD;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAC9B,YAAY,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { COPY_FEEDBACK_TIMEOUT_MS } from "./constants.js";
|
|
3
|
+
function useCopyToClipboard() {
|
|
4
|
+
const [copied, setCopied] = useState(false);
|
|
5
|
+
const resetTimer = useRef(null);
|
|
6
|
+
useEffect(() => () => {
|
|
7
|
+
if (resetTimer.current !== null)
|
|
8
|
+
clearTimeout(resetTimer.current);
|
|
9
|
+
}, []);
|
|
10
|
+
const copy = useCallback((text) => {
|
|
11
|
+
// Optional chaining rather than an assumption: `navigator.clipboard` is
|
|
12
|
+
// genuinely absent over plain HTTP, and for a self-hosted deployment over
|
|
13
|
+
// plain HTTP that is a normal configuration, not an error to surface.
|
|
14
|
+
const clipboard = globalThis.navigator?.clipboard;
|
|
15
|
+
// Nothing was copied, so there is nothing to report and nothing to undo.
|
|
16
|
+
if (!clipboard)
|
|
17
|
+
return;
|
|
18
|
+
void clipboard
|
|
19
|
+
.writeText(text)
|
|
20
|
+
.then(() => {
|
|
21
|
+
setCopied(true);
|
|
22
|
+
// Cancel any pending reset before arming a new one. Replacing the
|
|
23
|
+
// handle without clearing leaves the earlier timer live, and it can
|
|
24
|
+
// clear the checkmark for a copy that is still being reported.
|
|
25
|
+
if (resetTimer.current !== null)
|
|
26
|
+
clearTimeout(resetTimer.current);
|
|
27
|
+
resetTimer.current = setTimeout(() => {
|
|
28
|
+
resetTimer.current = null;
|
|
29
|
+
setCopied(false);
|
|
30
|
+
}, COPY_FEEDBACK_TIMEOUT_MS);
|
|
31
|
+
})
|
|
32
|
+
// Leave `copied` false rather than flashing and clearing it: a rejection
|
|
33
|
+
// means the text is still on screen and unread, so the affordance must
|
|
34
|
+
// not claim otherwise.
|
|
35
|
+
.catch(() => undefined);
|
|
36
|
+
}, []);
|
|
37
|
+
return { copied, copy };
|
|
38
|
+
}
|
|
39
|
+
export { useCopyToClipboard };
|
|
40
|
+
//# sourceMappingURL=useCopyToClipboard.js.map
|
|
@@ -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,gBAAgB,CAAC;AAsD1D,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.ts';\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/dist/useCurrentUser.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrentUser.d.ts","sourceRoot":"","sources":["../src/useCurrentUser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useCurrentUser.d.ts","sourceRoot":"","sources":["../src/useCurrentUser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,+FAA+F;AAC/F,UAAU,WAAW;IACnB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,UAAU,qBAAqB;IAC7B,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,oBAAoB,CAAC,KAAK;IAClC,mEAAmE;IACnE,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACnB,sEAAsE;IACtE,OAAO,EAAE,OAAO,CAAC;IACjB,mEAAmE;IACnE,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAC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MAAM,CAAC;IAC7B,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,YAAY,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IACjC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,SAAS,CAAC,OAAO;aACd,GAAG,CAAQ,IAAI,CAAC;aAChB,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE;YACX,IAAI,SAAS,EAAE,CAAC;gBACd,OAAO;YACT,CAAC;YACD,OAAO,CAAC,EAAE,CAAC,CAAC;YACZ,QAAQ,CAAC,IAAI,CAAC,CAAC;YACf,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YACxB,IAAI,SAAS,EAAE,CAAC;gBACd,OAAO;YACT,CAAC;YACD,sEAAsE;YACtE,oEAAoE;YACpE,gDAAgD;YAChD,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YACnC,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;QACL,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;IAEtB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC1C,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { ServiceError } from '@rexezuge/errors';\nimport type { ApiClient } from './api';\n\n/**\n * The signed-in account, fetched once on mount.\n *\n * ## Provenance\n *\n * `hooks/useCurrentUser.ts` in **CalDAV-Bridge**, **Durable-DAV**,\n * **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six\n * copies that differ on the three questions this hook exists to answer:\n *\n * 1. **Who fetches.** CalDAV-Bridge, Edge-Git, Edge-Sonic and Mail-Otter call a\n * module-level `loadCurrentUser()` from `services/userService`; Durable-DAV\n * and Durable-DAV-Router call the same helper but keep the client injectable.\n * The kit normalizes to the injectable form: the hook takes the client, so\n * nothing about the request path is baked in and a test hands it a stub.\n * 2. **What a failure means.** Durable-DAV-Router records the bug in a comment:\n * `authorized` was set to `false` for *any* failure, so a 500 or a dropped\n * connection rendered \"Sign In With Cloudflare Access\" to a caller who was\n * signed in — and the only way back was a hard reload. Its fix is a separate\n * `error` flag meaning \"we could not find out\", rendered as a retry. That is\n * the shape here: `error` carries the failure, `user` stays `null`, and the\n * caller decides what a retry looks like. A 401 is not special-cased — a 401\n * *is* an error, and a shell that renders a sign-in prompt from it should do\n * so because the app says so.\n * 3. **Effect dependencies.** Durable-DAV documents the other half of the bug:\n * the effect listed `onError` (its only dependency), `SpaApp` passed an\n * inline arrow, so the effect re-ran on every render and issued an\n * unbounded stream of `GET /user/me` from first paint. The kit takes the\n * same cure: the client is read through a ref, and the effect is keyed on\n * `reloadKey` alone. A caller can pass a fresh client every render and the\n * request count is unchanged.\n *\n * ## Normalization\n *\n * `useCurrentUser(client)` returns `{ user, loading, error, reload }`. The\n * `authorized` tri-state (`null`/`true`/`false`) is gone: `loading` already\n * distinguishes \"in flight\" from \"answered\", and `error` distinguishes\n * \"answered badly\" from \"not signed in\" — a caller that wants `authorized`\n * derives it as `loading ? null : user !== null`. `setUser` is gone too; a\n * change to the account is a refresh (`reload()`), which is what the sources\n * do at every call site anyway.\n */\n\n/** The account shape a caller reads. `preferredLanguage` is what `useSpaLanguage` consumes. */\ninterface CurrentUser {\n preferredLanguage?: string | null;\n}\n\ninterface UseCurrentUserOptions {\n /** The path to GET. Defaults to `/user/me`, the family's profile route. */\n path?: string;\n}\n\ninterface UseCurrentUserResult<TUser> {\n /** The account, or `null` until it loads (and after a failure). */\n user: TUser | null;\n /** `true` while the request is in flight, including the first one. */\n loading: boolean;\n /** The normalized failure, or `null`. A `ServiceError`, always. */\n error: ServiceError | null;\n /** Re-runs the request. */\n reload: () => void;\n}\n\n/** The profile route every repo in the family serves. */\nconst CURRENT_USER_PATH = '/user/me';\n\nfunction useCurrentUser<TUser = CurrentUser>(\n client: ApiClient,\n { path = CURRENT_USER_PATH }: Readonly<UseCurrentUserOptions> = {},\n): UseCurrentUserResult<TUser> {\n const [user, setUser] = useState<TUser | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<ServiceError | null>(null);\n const [reloadKey, setReloadKey] = useState(0);\n\n // Read through a ref so a caller's fresh client instance cannot re-run the\n // effect; refreshing is explicit, through `reload`.\n const clientRef = useRef(client);\n useEffect(() => {\n clientRef.current = client;\n }, [client]);\n\n const reload = useCallback(() => {\n setReloadKey((key) => key + 1);\n }, []);\n\n useEffect(() => {\n let cancelled = false;\n setLoading(true);\n clientRef.current\n .get<TUser>(path)\n .then((me) => {\n if (cancelled) {\n return;\n }\n setUser(me);\n setError(null);\n setLoading(false);\n })\n .catch((cause: unknown) => {\n if (cancelled) {\n return;\n }\n // Normalized here as well as in the client: a client that is not this\n // package's (`createApiClient`) may throw anything, and a hook that\n // promises a `ServiceError` should deliver one.\n setError(ServiceError.from(cause));\n setLoading(false);\n });\n return () => {\n cancelled = true;\n };\n }, [path, reloadKey]);\n\n return { user, loading, error, reload };\n}\n\nexport { CURRENT_USER_PATH, useCurrentUser };\nexport type { CurrentUser, UseCurrentUserOptions, UseCurrentUserResult };\n"]}
|
|
1
|
+
{"version":3,"file":"useCurrentUser.js","sourceRoot":"","sources":["../src/useCurrentUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAA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U,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YACxB,IAAI,SAAS,EAAE,CAAC;gBACd,OAAO;YACT,CAAC;YACD,sEAAsE;YACtE,oEAAoE;YACpE,gDAAgD;YAChD,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YACnC,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;QACL,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;IAEtB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC1C,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { ServiceError } from '@rexezuge/errors';\nimport type { ApiClient } from './api.ts';\n\n/**\n * The signed-in account, fetched once on mount.\n *\n * ## Provenance\n *\n * `hooks/useCurrentUser.ts` in **CalDAV-Bridge**, **Durable-DAV**,\n * **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six\n * copies that differ on the three questions this hook exists to answer:\n *\n * 1. **Who fetches.** CalDAV-Bridge, Edge-Git, Edge-Sonic and Mail-Otter call a\n * module-level `loadCurrentUser()` from `services/userService`; Durable-DAV\n * and Durable-DAV-Router call the same helper but keep the client injectable.\n * The kit normalizes to the injectable form: the hook takes the client, so\n * nothing about the request path is baked in and a test hands it a stub.\n * 2. **What a failure means.** Durable-DAV-Router records the bug in a comment:\n * `authorized` was set to `false` for *any* failure, so a 500 or a dropped\n * connection rendered \"Sign In With Cloudflare Access\" to a caller who was\n * signed in — and the only way back was a hard reload. Its fix is a separate\n * `error` flag meaning \"we could not find out\", rendered as a retry. That is\n * the shape here: `error` carries the failure, `user` stays `null`, and the\n * caller decides what a retry looks like. A 401 is not special-cased — a 401\n * *is* an error, and a shell that renders a sign-in prompt from it should do\n * so because the app says so.\n * 3. **Effect dependencies.** Durable-DAV documents the other half of the bug:\n * the effect listed `onError` (its only dependency), `SpaApp` passed an\n * inline arrow, so the effect re-ran on every render and issued an\n * unbounded stream of `GET /user/me` from first paint. The kit takes the\n * same cure: the client is read through a ref, and the effect is keyed on\n * `reloadKey` alone. A caller can pass a fresh client every render and the\n * request count is unchanged.\n *\n * ## Normalization\n *\n * `useCurrentUser(client)` returns `{ user, loading, error, reload }`. The\n * `authorized` tri-state (`null`/`true`/`false`) is gone: `loading` already\n * distinguishes \"in flight\" from \"answered\", and `error` distinguishes\n * \"answered badly\" from \"not signed in\" — a caller that wants `authorized`\n * derives it as `loading ? null : user !== null`. `setUser` is gone too; a\n * change to the account is a refresh (`reload()`), which is what the sources\n * do at every call site anyway.\n */\n\n/** The account shape a caller reads. `preferredLanguage` is what `useSpaLanguage` consumes. */\ninterface CurrentUser {\n preferredLanguage?: string | null;\n}\n\ninterface UseCurrentUserOptions {\n /** The path to GET. Defaults to `/user/me`, the family's profile route. */\n path?: string;\n}\n\ninterface UseCurrentUserResult<TUser> {\n /** The account, or `null` until it loads (and after a failure). */\n user: TUser | null;\n /** `true` while the request is in flight, including the first one. */\n loading: boolean;\n /** The normalized failure, or `null`. A `ServiceError`, always. */\n error: ServiceError | null;\n /** Re-runs the request. */\n reload: () => void;\n}\n\n/** The profile route every repo in the family serves. */\nconst CURRENT_USER_PATH = '/user/me';\n\nfunction useCurrentUser<TUser = CurrentUser>(\n client: ApiClient,\n { path = CURRENT_USER_PATH }: Readonly<UseCurrentUserOptions> = {},\n): UseCurrentUserResult<TUser> {\n const [user, setUser] = useState<TUser | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<ServiceError | null>(null);\n const [reloadKey, setReloadKey] = useState(0);\n\n // Read through a ref so a caller's fresh client instance cannot re-run the\n // effect; refreshing is explicit, through `reload`.\n const clientRef = useRef(client);\n useEffect(() => {\n clientRef.current = client;\n }, [client]);\n\n const reload = useCallback(() => {\n setReloadKey((key) => key + 1);\n }, []);\n\n useEffect(() => {\n let cancelled = false;\n setLoading(true);\n clientRef.current\n .get<TUser>(path)\n .then((me) => {\n if (cancelled) {\n return;\n }\n setUser(me);\n setError(null);\n setLoading(false);\n })\n .catch((cause: unknown) => {\n if (cancelled) {\n return;\n }\n // Normalized here as well as in the client: a client that is not this\n // package's (`createApiClient`) may throw anything, and a hook that\n // promises a `ServiceError` should deliver one.\n setError(ServiceError.from(cause));\n setLoading(false);\n });\n return () => {\n cancelled = true;\n };\n }, [path, reloadKey]);\n\n return { user, loading, error, reload };\n}\n\nexport { CURRENT_USER_PATH, useCurrentUser };\nexport type { CurrentUser, UseCurrentUserOptions, UseCurrentUserResult };\n"]}
|
package/dist/useNotice.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { NOTICE_TIMEOUT_MS } from
|
|
2
|
+
import { NOTICE_TIMEOUT_MS } from "./constants.js";
|
|
3
3
|
function useNotice({ dismissAfterMs = NOTICE_TIMEOUT_MS, initial = null } = {}) {
|
|
4
4
|
const [notice, setNotice] = useState(initial);
|
|
5
5
|
const timerRef = useRef(null);
|
package/dist/useNotice.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNotice.js","sourceRoot":"","sources":["../src/useNotice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useNotice.js","sourceRoot":"","sources":["../src/useNotice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MA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EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAEhE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;AAC/C,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { NOTICE_TIMEOUT_MS } from './constants.ts';\n\n/**\n * A transient status message.\n *\n * ## Provenance\n *\n * `hooks/useNotice.ts` in **CalDAV-Bridge**, **Durable-DAV**,\n * **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six\n * copies of one hook, with AWS-AccessBridge's `useToast` as the seventh in\n * everything but name. Each contributes one thing:\n *\n * - **Durable-DAV** — the unmount cleanup. Its comment records the bug: the\n * timer was only ever cleared in favour of the *next* notice, so unmounting\n * with a notice showing left it live to call `setState` on a gone component.\n * - **Edge-Sonic** — `clearNotice`, a dismissal that is not just \"replace it\",\n * and the exported `ShowNotice` type so feature tabs stop re-spelling the\n * setter's signature.\n * - **CalDAV-Bridge / Mail-Otter** — seeding the first notice from the URL's\n * `?oauth2=` result. That is *left local*: the parameter names are\n * product-specific, and a hook that reads a query string is a hook a test\n * has to fake a location for. A consumer seeds its own notice by passing\n * `initial` — see `UseNoticeOptions`.\n * - **All six** — a ref-held timer, so a new notice replaces the old one's\n * dismissal instead of being cut short by it (\"the error banner vanished\n * before I read it\").\n *\n * ## Normalization\n *\n * The type is `{ kind, message }`. Every copy used `{ type, text }`, and the\n * field names collided with the DOM's `type` on unrelated elements often enough\n * that `kind`/`message` read better at the call sites that build one by hand\n * (`describeProbe` in Edge-Sonic returns a notice-shaped value). The imperative\n * API is `showNotice(kind, message)` — positional, as every copy had it, so a\n * call site reads as the event it reports — plus `dismissNotice()`.\n */\n\ntype NoticeKind = 'success' | 'error';\n\n/** One transient message. `kind` is the tone, `message` the sentence. */\ninterface Notice {\n kind: NoticeKind;\n message: string;\n}\n\n/** The setter views and hooks are handed. */\ntype ShowNotice = (kind: NoticeKind, message: string) => void;\n\ninterface UseNoticeOptions {\n /** How long a notice stays up. Defaults to `NOTICE_TIMEOUT_MS`. */\n dismissAfterMs?: number;\n /** A notice to start with — the URL-seeded OAuth result, in a consumer. */\n initial?: Notice | null;\n}\n\ninterface UseNoticeResult {\n /** The notice to render, or `null` when there is nothing to say. */\n notice: Notice | null;\n /** Shows a notice, replacing any notice already showing (and its timer). */\n showNotice: ShowNotice;\n /** Hides the notice and cancels its pending dismissal. */\n dismissNotice: () => void;\n}\n\nfunction useNotice({ dismissAfterMs = NOTICE_TIMEOUT_MS, initial = null }: Readonly<UseNoticeOptions> = {}): UseNoticeResult {\n const [notice, setNotice] = useState<Notice | null>(initial);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const clearPendingDismissal = useCallback(() => {\n if (timerRef.current === null) {\n return;\n }\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }, []);\n\n const dismissNotice = useCallback(() => {\n clearPendingDismissal();\n setNotice(null);\n }, [clearPendingDismissal]);\n\n const showNotice = useCallback<ShowNotice>(\n (kind, message) => {\n // Replace the pending dismissal rather than stacking a second timer: two\n // live timers mean the first notice's timeout fires while the second is\n // still on screen.\n clearPendingDismissal();\n setNotice({ kind, message });\n timerRef.current = setTimeout(() => {\n timerRef.current = null;\n setNotice(null);\n }, dismissAfterMs);\n },\n [clearPendingDismissal, dismissAfterMs],\n );\n\n // Unmounting cancels the dismissal. Without this the timer outlives the\n // component and calls `setState` on a tree that is gone.\n useEffect(() => clearPendingDismissal, [clearPendingDismissal]);\n\n return { notice, showNotice, dismissNotice };\n}\n\nexport { useNotice };\nexport type { Notice, NoticeKind, ShowNotice, UseNoticeOptions, UseNoticeResult };\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexezuge/web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.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.
|
|
29
|
-
"@rexezuge/shared": "1.
|
|
28
|
+
"@rexezuge/errors": "1.3.0",
|
|
29
|
+
"@rexezuge/shared": "1.3.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",
|