@attraccess/plugins-frontend-ui 1.10.0 → 1.11.0-beta.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 +40 -1
- package/index.js +1843 -2273
- package/lib/components/AlertStatusIcon.d.ts +6 -0
- package/lib/components/EmptyState.d.ts +5 -0
- package/lib/components/LabeledSwitch.d.ts +11 -0
- package/lib/components/StandardDrawer.d.ts +12 -0
- package/lib/components/StandardModal.d.ts +21 -0
- package/lib/components/StatusAlert.d.ts +9 -0
- package/lib/components/button/index.d.ts +3 -0
- package/lib/components/delete-confirmation-modal/index.d.ts +10 -0
- package/lib/components/index.d.ts +13 -0
- package/lib/components/loading-indicator/index.d.ts +4 -0
- package/lib/components/page-header/actions.d.ts +39 -0
- package/lib/components/page-header/index.d.ts +18 -0
- package/lib/components/password-input/PasswordInput.d.ts +15 -0
- package/lib/components/status-dialog/index.d.ts +33 -0
- package/lib/components/string-list-field/StringListField.d.ts +25 -0
- package/lib/components/user-search/UserSearch.d.ts +1 -2
- package/lib/hooks/dateTimePreferences.d.ts +5 -0
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/useFormatDateTime.d.ts +1 -0
- package/lib/hooks/useFormatDuration.d.ts +2 -2
- package/lib/i18n.d.ts +17 -2
- package/package.json +6 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Switch } from '@heroui/react';
|
|
2
|
+
import { ComponentProps, ReactNode } from 'react';
|
|
3
|
+
type SwitchProps = ComponentProps<typeof Switch>;
|
|
4
|
+
export interface LabeledSwitchProps extends Omit<SwitchProps, 'children'> {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
/** Styles the row holding the control and label — the only flex container callers can
|
|
7
|
+
affect, since `className` lands on the outer Switch wrapper. */
|
|
8
|
+
contentClassName?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function LabeledSwitch({ children, contentClassName, ...rest }: LabeledSwitchProps): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DrawerBackdropProps, DrawerContentProps, DrawerDialogProps } from '@heroui/react';
|
|
2
|
+
interface Props {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
onOpenChange: (open: boolean) => void;
|
|
5
|
+
children: DrawerDialogProps['children'];
|
|
6
|
+
backdropProps?: Omit<DrawerBackdropProps, 'children' | 'isOpen' | 'onOpenChange'>;
|
|
7
|
+
contentProps?: Omit<DrawerContentProps, 'children'>;
|
|
8
|
+
dialogProps?: Omit<DrawerDialogProps, 'children'>;
|
|
9
|
+
}
|
|
10
|
+
/** Render DrawerHeading for the title, or name headerless content via dialogProps['aria-label']. */
|
|
11
|
+
export declare function StandardDrawer(props: Props): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ModalProps, ModalBackdropProps, ModalContainerProps, ModalDialogProps } from '@heroui/react';
|
|
2
|
+
interface Props extends Omit<ModalProps, 'children'> {
|
|
3
|
+
children: ModalDialogProps['children'];
|
|
4
|
+
/** Forwarded to ModalContainer (sm | md | lg | full, …). */
|
|
5
|
+
size?: ModalContainerProps['size'];
|
|
6
|
+
backdropProps?: Omit<ModalBackdropProps, 'children'>;
|
|
7
|
+
containerProps?: Omit<ModalContainerProps, 'children'>;
|
|
8
|
+
dialogProps?: Omit<ModalDialogProps, 'children'>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Single source of truth for modal chrome. Wraps HeroUI's Modal primitives and
|
|
12
|
+
* uses the shared overlay and field tokens, like StandardDrawer.
|
|
13
|
+
*
|
|
14
|
+
* Per-modal overrides pass through: `size` and `containerProps` reach the
|
|
15
|
+
* ModalContainer, `dialogProps` reach the ModalDialog, and any remaining props
|
|
16
|
+
* (isOpen, onOpenChange, data-cy, …) reach the Modal root.
|
|
17
|
+
* Render ModalHeading for the accessible title, or provide dialogProps['aria-label']
|
|
18
|
+
* when the content has no title heading. ModalHeader alone does not name the dialog.
|
|
19
|
+
*/
|
|
20
|
+
export declare function StandardModal(props: Props): import("react").JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface StatusAlertProps {
|
|
3
|
+
status: 'default' | 'accent' | 'success' | 'warning' | 'danger';
|
|
4
|
+
title?: ReactNode;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
'data-cy'?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function StatusAlert({ status, title, children, 'data-cy': dataCy }: Readonly<StatusAlertProps>): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface DeleteConfirmationModalProps {
|
|
2
|
+
isOpen: boolean;
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
onConfirm: () => unknown;
|
|
5
|
+
itemName: string;
|
|
6
|
+
isDeleting?: boolean;
|
|
7
|
+
'data-cy'?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function DeleteConfirmationModal({ isOpen, onClose, onConfirm, itemName, isDeleting, 'data-cy': dataCy, }: Readonly<DeleteConfirmationModalProps>): import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -5,3 +5,16 @@ export * from './duration-display/DurationDisplay';
|
|
|
5
5
|
export * from './user-search/UserSearch';
|
|
6
6
|
export * from './ResourceSelector/ResourceSelector';
|
|
7
7
|
export * from './Trans';
|
|
8
|
+
export * from './AlertStatusIcon';
|
|
9
|
+
export * from './EmptyState';
|
|
10
|
+
export * from './LabeledSwitch';
|
|
11
|
+
export * from './loading-indicator';
|
|
12
|
+
export * from './StandardDrawer';
|
|
13
|
+
export * from './StatusAlert';
|
|
14
|
+
export * from './StandardModal';
|
|
15
|
+
export * from './button';
|
|
16
|
+
export * from './delete-confirmation-modal';
|
|
17
|
+
export * from './page-header';
|
|
18
|
+
export * from './password-input/PasswordInput';
|
|
19
|
+
export * from './status-dialog';
|
|
20
|
+
export * from './string-list-field/StringListField';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type PageActionVariant = 'primary' | 'secondary' | 'destructive';
|
|
3
|
+
interface PageActionBase {
|
|
4
|
+
key: string;
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
variant?: PageActionVariant;
|
|
8
|
+
isDisabled?: boolean;
|
|
9
|
+
isPending?: boolean;
|
|
10
|
+
isHidden?: boolean;
|
|
11
|
+
isIconOnly?: boolean;
|
|
12
|
+
dataCy?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface PageActionTriggerProps {
|
|
15
|
+
variant: 'primary' | 'outline';
|
|
16
|
+
size: 'sm';
|
|
17
|
+
isDisabled?: boolean;
|
|
18
|
+
isPending?: boolean;
|
|
19
|
+
isIconOnly?: boolean;
|
|
20
|
+
'aria-label': string;
|
|
21
|
+
'data-cy'?: string;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
export interface PageActionPress extends PageActionBase {
|
|
25
|
+
onPress: () => void;
|
|
26
|
+
renderTrigger?: undefined;
|
|
27
|
+
}
|
|
28
|
+
export interface PageActionRender extends PageActionBase {
|
|
29
|
+
renderTrigger: (triggerProps: PageActionTriggerProps) => ReactNode;
|
|
30
|
+
onPress?: undefined;
|
|
31
|
+
}
|
|
32
|
+
export type PageAction = PageActionPress | PageActionRender;
|
|
33
|
+
interface PageHeaderActionsProps {
|
|
34
|
+
actions: PageAction[];
|
|
35
|
+
maxVisible?: number;
|
|
36
|
+
moreLabel?: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function PageHeaderActions({ actions, maxVisible, moreLabel }: PageHeaderActionsProps): import("react").JSX.Element;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { PageAction } from './actions';
|
|
3
|
+
export type { PageAction, PageActionPress, PageActionRender, PageActionTriggerProps, PageActionVariant, } from './actions';
|
|
4
|
+
export { PageHeaderActions } from './actions';
|
|
5
|
+
interface PageHeaderProps {
|
|
6
|
+
title: string | ReactNode;
|
|
7
|
+
subtitle?: string | ReactNode;
|
|
8
|
+
backTo?: string;
|
|
9
|
+
onBack?: () => void;
|
|
10
|
+
actions?: PageAction[];
|
|
11
|
+
maxVisibleActions?: number;
|
|
12
|
+
moreActionsLabel?: string;
|
|
13
|
+
icon?: ReactNode;
|
|
14
|
+
noMargin?: boolean;
|
|
15
|
+
thumbnailSrc?: string;
|
|
16
|
+
thumbnailAlt?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function PageHeader({ title, subtitle, backTo, onBack, actions, maxVisibleActions, moreActionsLabel, icon, noMargin, thumbnailSrc, thumbnailAlt, }: Readonly<PageHeaderProps>): import("react").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { TextFieldProps } from '@heroui/react';
|
|
3
|
+
export interface PasswordInputProps extends Omit<TextFieldProps, 'type' | 'children'> {
|
|
4
|
+
label?: React.ReactNode;
|
|
5
|
+
description?: React.ReactNode;
|
|
6
|
+
errorMessage?: React.ReactNode;
|
|
7
|
+
autoComplete: string;
|
|
8
|
+
onValueChange?: (value: string) => void;
|
|
9
|
+
id?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
'data-cy'?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const PasswordInput: React.FC<PasswordInputProps>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type StatusDialogStatus = 'default' | 'info' | 'success' | 'warning' | 'error';
|
|
3
|
+
export interface StatusDialogAction {
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
onPress: () => unknown;
|
|
6
|
+
isPending?: boolean;
|
|
7
|
+
isDisabled?: boolean;
|
|
8
|
+
'data-cy'?: string;
|
|
9
|
+
}
|
|
10
|
+
interface StatusDialogProps {
|
|
11
|
+
isOpen: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Called when the dialog is dismissed (close button or Escape). A backdrop click does nothing, and
|
|
14
|
+
* Escape is ignored while the action is pending, like the disabled close button.
|
|
15
|
+
*/
|
|
16
|
+
onClose: () => void;
|
|
17
|
+
status: StatusDialogStatus;
|
|
18
|
+
title: ReactNode;
|
|
19
|
+
/** The message; plain text or richer content such as an error log. */
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Optional primary action (confirm, retry, …). It is styled as destructive for errors only
|
|
23
|
+
* and does not close the dialog by itself.
|
|
24
|
+
*/
|
|
25
|
+
action?: StatusDialogAction;
|
|
26
|
+
/** Label of the dismiss button; defaults to "Close", or "Cancel" next to an action. */
|
|
27
|
+
closeLabel?: ReactNode;
|
|
28
|
+
/** Defaults to `<data-cy>-close`. */
|
|
29
|
+
closeDataCy?: string;
|
|
30
|
+
'data-cy'?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function StatusDialog(props: Readonly<StatusDialogProps>): import("react").JSX.Element;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type StringListEntryError = 'empty' | 'duplicate' | 'comma' | 'control' | 'tooLong' | 'limitReached';
|
|
3
|
+
/** Checks a candidate entry (already trimmed) against the list; returns why it cannot be added, if so. */
|
|
4
|
+
export declare function validateStringListEntry(entry: string, values: readonly string[], { maxEntries, maxLength }?: {
|
|
5
|
+
maxEntries?: number;
|
|
6
|
+
maxLength?: number;
|
|
7
|
+
}): StringListEntryError | null;
|
|
8
|
+
export interface StringListFieldProps {
|
|
9
|
+
label: string;
|
|
10
|
+
description?: React.ReactNode;
|
|
11
|
+
values: string[];
|
|
12
|
+
onChange: (values: string[]) => void;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
/** Shown while the list is empty, e.g. which defaults apply. */
|
|
15
|
+
emptyHint?: React.ReactNode;
|
|
16
|
+
maxEntries?: number;
|
|
17
|
+
maxLength?: number;
|
|
18
|
+
isDisabled?: boolean;
|
|
19
|
+
'data-cy'?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Edits an ordered list of strings, one entry at a time. Entries are never split on commas, so values
|
|
23
|
+
* that contain them cannot be created by accident; entries keep the order in which they were added.
|
|
24
|
+
*/
|
|
25
|
+
export declare const StringListField: React.FC<StringListFieldProps>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HTMLAttributes } from 'react';
|
|
2
2
|
import { UserIdentity } from '../attraccess-user/AttraccessUser';
|
|
3
|
-
interface UserSearchProps {
|
|
3
|
+
export interface UserSearchProps {
|
|
4
4
|
label?: string;
|
|
5
5
|
placeholder?: string;
|
|
6
6
|
size?: 'sm' | 'md' | 'lg';
|
|
@@ -13,4 +13,3 @@ interface UserSearchProps {
|
|
|
13
13
|
afterSelection?: React.ReactNode;
|
|
14
14
|
}
|
|
15
15
|
export declare function UserSearch(props: Readonly<UserSearchProps>): import("react").JSX.Element;
|
|
16
|
-
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DateTimePreferences } from '../../../libs/shared/src/index.ts';
|
|
2
|
+
export declare const useDateTimePreferences: import('zustand').UseBoundStore<import('zustand').StoreApi<DateTimePreferences & {
|
|
3
|
+
userId: number | null;
|
|
4
|
+
}>>;
|
|
5
|
+
export declare function useDateTimeLocale(override?: string | null): string;
|
package/lib/hooks/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export interface DateTimeOptions {
|
|
|
2
2
|
showTime?: boolean;
|
|
3
3
|
showDate?: boolean;
|
|
4
4
|
showSeconds?: boolean;
|
|
5
|
+
dateTimeLocale?: string | null;
|
|
5
6
|
}
|
|
6
7
|
export declare function useDateTimeFormatter(options?: DateTimeOptions): (date?: Date | string | number | null, fallback?: string | React.ReactNode) => import('react').ReactNode;
|
|
7
8
|
export declare function useFormatDateTime(date?: Date | string | number | null, options?: DateTimeOptions): import('react').ReactNode;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A hook for formatting duration values using the Intl.DurationFormat API (if supported)
|
|
3
|
-
* and respecting the current language settings.
|
|
3
|
+
* and respecting the current language settings, rounded to the nearest second.
|
|
4
4
|
*
|
|
5
|
-
* @returns A
|
|
5
|
+
* @returns A localized duration string without subsecond precision
|
|
6
6
|
*/
|
|
7
7
|
export declare function useFormatedDuration(minutes: number): any;
|
package/lib/i18n.d.ts
CHANGED
|
@@ -4,23 +4,38 @@ interface TranslationModules<T extends TranslationRecord = TranslationRecord> {
|
|
|
4
4
|
en: T;
|
|
5
5
|
de: T;
|
|
6
6
|
}
|
|
7
|
-
type Language = keyof TranslationModules;
|
|
7
|
+
export type Language = keyof TranslationModules;
|
|
8
8
|
interface TranslationState {
|
|
9
9
|
language: Language;
|
|
10
|
+
/** A personal choice survives disabled browser storage; resolved fallbacks do not set it. */
|
|
11
|
+
explicitLanguage: Language | undefined;
|
|
10
12
|
setLanguage: (language: Language) => void;
|
|
11
13
|
}
|
|
12
14
|
export declare const useTranslationState: import('zustand').UseBoundStore<import('zustand').StoreApi<TranslationState>>;
|
|
13
15
|
export type TFunction = (key: string, data?: Record<string, unknown>) => string;
|
|
16
|
+
/** Retained translations stay reactive; literal API errors remain intact. */
|
|
17
|
+
export interface TranslationMessage {
|
|
18
|
+
key: string;
|
|
19
|
+
data?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
interface TranslationOptions {
|
|
22
|
+
/** Disable only for React text rendering, never for messages rendered as HTML. */
|
|
23
|
+
escapeValues?: boolean;
|
|
24
|
+
}
|
|
14
25
|
interface TExistsOptions {
|
|
15
26
|
succeedIfKeyIsObject?: boolean;
|
|
16
27
|
}
|
|
17
28
|
export type TExists = (key: string, options?: TExistsOptions) => boolean;
|
|
18
29
|
interface UseTranslationsResponse {
|
|
19
30
|
t: TFunction;
|
|
31
|
+
tMessage: (message: TranslationMessage | string) => string;
|
|
20
32
|
tExists: TExists;
|
|
21
33
|
language: Language;
|
|
22
34
|
setLanguage: (language: Language) => void;
|
|
23
35
|
}
|
|
24
|
-
export declare function useTranslations(translations: TranslationModules): UseTranslationsResponse;
|
|
36
|
+
export declare function useTranslations(translations: TranslationModules, options?: TranslationOptions): UseTranslationsResponse;
|
|
37
|
+
/** Explicit browser choices precede supported browser languages, then the system fallback. */
|
|
38
|
+
export declare function detectPreferredLanguage(): Language | undefined;
|
|
39
|
+
export declare function detectLanguage(fallback?: Language): Language;
|
|
25
40
|
export declare function detectAndSetLanguage(): void;
|
|
26
41
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@attraccess/plugins-frontend-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0-beta.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/Attraccess/Attraccess.git",
|
|
7
|
+
"directory": "libs/plugins-frontend-ui"
|
|
8
|
+
},
|
|
4
9
|
"type": "module",
|
|
5
10
|
"main": "./index.js",
|
|
6
11
|
"types": "./index.d.ts",
|