@attraccess/plugins-frontend-ui 1.10.0 → 1.11.0-beta.2

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 (31) hide show
  1. package/README.md +40 -1
  2. package/index.js +1847 -2467
  3. package/lib/components/AlertStatusIcon.d.ts +6 -0
  4. package/lib/components/EmptyState.d.ts +5 -0
  5. package/lib/components/LabeledSwitch.d.ts +11 -0
  6. package/lib/components/ResourceSelector/ResourceSelector.d.ts +2 -2
  7. package/lib/components/StandardDrawer.d.ts +12 -0
  8. package/lib/components/StandardModal.d.ts +21 -0
  9. package/lib/components/StatusAlert.d.ts +9 -0
  10. package/lib/components/attraccess-user/AttraccessUser.d.ts +1 -1
  11. package/lib/components/attraccess-user/AttraccessUserActionsContext.d.ts +1 -1
  12. package/lib/components/button/index.d.ts +3 -0
  13. package/lib/components/datetime-display/DateTimeDisplay.d.ts +1 -1
  14. package/lib/components/delete-confirmation-modal/index.d.ts +10 -0
  15. package/lib/components/index.d.ts +13 -0
  16. package/lib/components/loading-indicator/index.d.ts +4 -0
  17. package/lib/components/page-header/accessory.d.ts +15 -0
  18. package/lib/components/page-header/actions.d.ts +39 -0
  19. package/lib/components/page-header/index.d.ts +19 -0
  20. package/lib/components/password-input/PasswordInput.d.ts +15 -0
  21. package/lib/components/status-dialog/index.d.ts +33 -0
  22. package/lib/components/string-list-field/StringListField.d.ts +25 -0
  23. package/lib/components/user-search/UserSearch.d.ts +2 -3
  24. package/lib/hooks/index.d.ts +4 -1
  25. package/lib/hooks/useDateTimeFormatter.d.ts +8 -0
  26. package/lib/hooks/useDateTimeLocale.d.ts +1 -0
  27. package/lib/hooks/useDateTimePreferences.d.ts +4 -0
  28. package/lib/hooks/useFormatDateTime.d.ts +1 -6
  29. package/lib/hooks/{useFormatDuration.d.ts → useFormatedDuration.d.ts} +2 -2
  30. package/lib/i18n.d.ts +18 -2
  31. package/package.json +6 -1
@@ -0,0 +1,6 @@
1
+ type AlertStatus = 'default' | 'accent' | 'success' | 'warning' | 'danger';
2
+ interface Props {
3
+ status: AlertStatus;
4
+ }
5
+ export declare function AlertStatusIcon({ status }: Props): import('react').JSX.Element;
6
+ export {};
@@ -0,0 +1,5 @@
1
+ interface Props {
2
+ message?: string;
3
+ }
4
+ export declare function EmptyState(props: Props): import('react').JSX.Element;
5
+ export {};
@@ -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 {};
@@ -5,6 +5,6 @@ interface Props {
5
5
  multiple?: boolean;
6
6
  listClassName?: string;
7
7
  }
8
- export declare const ListboxWrapper: ({ children }: PropsWithChildren) => import("react").JSX.Element;
9
- export declare function ResourceSelector(props: Readonly<Props>): import("react").JSX.Element;
8
+ export declare const ListboxWrapper: ({ children }: PropsWithChildren) => import('react').JSX.Element;
9
+ export declare function ResourceSelector(props: Readonly<Props>): import('react').JSX.Element;
10
10
  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 {};
@@ -10,5 +10,5 @@ interface AttraccessUserProps {
10
10
  /** When false, render as plain display without the direct-message popover. Defaults to true. */
11
11
  interactive?: boolean;
12
12
  }
13
- export declare function AttraccessUser({ user, description, className, onStartDirectMessage, variant, interactive, }: Readonly<AttraccessUserProps>): import("react").JSX.Element;
13
+ export declare function AttraccessUser({ user, description, className, onStartDirectMessage, variant, interactive, }: Readonly<AttraccessUserProps>): import('react').JSX.Element;
14
14
  export {};
@@ -6,6 +6,6 @@ interface AttraccessUserActions {
6
6
  interface AttraccessUserActionsProviderProps extends AttraccessUserActions {
7
7
  children: ReactNode;
8
8
  }
9
- export declare function AttraccessUserActionsProvider({ children, onStartDirectMessage, }: Readonly<AttraccessUserActionsProviderProps>): import("react").JSX.Element;
9
+ export declare function AttraccessUserActionsProvider({ children, onStartDirectMessage, }: Readonly<AttraccessUserActionsProviderProps>): import('react').JSX.Element;
10
10
  export declare function useAttraccessUserActions(): AttraccessUserActions;
11
11
  export {};
@@ -0,0 +1,3 @@
1
+ import { ButtonProps as HeroButtonProps } from '@heroui/react';
2
+ export type ButtonProps = HeroButtonProps;
3
+ export declare function Button(props: ButtonProps): import('react').JSX.Element;
@@ -3,5 +3,5 @@ interface DateTimeDisplayProps {
3
3
  date?: Date | string | number | null;
4
4
  options?: DateTimeOptions;
5
5
  }
6
- export declare function DateTimeDisplay(props: DateTimeDisplayProps & React.HTMLAttributes<HTMLSpanElement>): import("react").JSX.Element;
6
+ export declare function DateTimeDisplay(props: DateTimeDisplayProps & React.HTMLAttributes<HTMLSpanElement>): import('react').JSX.Element;
7
7
  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,4 @@
1
+ /** `label` names the indicator for screen readers; it defaults to a generic "Loading". */
2
+ export declare const TableDataLoadingIndicator: ({ label }: Readonly<{
3
+ label?: string;
4
+ }>) => import('react').JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { ComponentType, PropsWithChildren, RefObject } from 'react';
2
+ export interface PageHeaderAccessoryProviderProps {
3
+ /** Rendered beside the actions of the page's main header. It decides itself whether to show anything. */
4
+ accessory: ComponentType;
5
+ }
6
+ /**
7
+ * Host only: plugins must not render this provider, or they replace the host's control on their pages.
8
+ *
9
+ * Lets the host add a page-level control, such as the dashboard pin, to every PageHeader below it, including those
10
+ * of plugin pages. Only the first header in document order shows it, so section headers on the same page never
11
+ * repeat it. Without a provider, PageHeader renders exactly as before.
12
+ */
13
+ export declare function PageHeaderAccessoryProvider({ accessory, children, }: PropsWithChildren<PageHeaderAccessoryProviderProps>): import('react').JSX.Element;
14
+ /** The host accessory for this header, or null when there is none or another header on the page shows it. */
15
+ export declare function usePageHeaderAccessory(header: RefObject<HTMLElement | null>): ComponentType | null;
@@ -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,19 @@
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
+ export { PageHeaderAccessoryProvider, type PageHeaderAccessoryProviderProps } from './accessory';
6
+ interface PageHeaderProps {
7
+ title: string | ReactNode;
8
+ subtitle?: string | ReactNode;
9
+ backTo?: string;
10
+ onBack?: () => void;
11
+ actions?: PageAction[];
12
+ maxVisibleActions?: number;
13
+ moreActionsLabel?: string;
14
+ icon?: ReactNode;
15
+ noMargin?: boolean;
16
+ thumbnailSrc?: string;
17
+ thumbnailAlt?: string;
18
+ }
19
+ 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';
@@ -12,5 +12,4 @@ interface UserSearchProps {
12
12
  afterAutocomplete?: React.ReactNode;
13
13
  afterSelection?: React.ReactNode;
14
14
  }
15
- export declare function UserSearch(props: Readonly<UserSearchProps>): import("react").JSX.Element;
16
- export {};
15
+ export declare function UserSearch(props: Readonly<UserSearchProps>): import('react').JSX.Element;
@@ -1,5 +1,8 @@
1
1
  export * from './useDebounce';
2
+ export * from './useDateTimeFormatter';
2
3
  export * from './useFormatDateTime';
3
- export * from './useFormatDuration';
4
+ export * from './useFormatedDuration';
4
5
  export * from './useUrlQuery';
5
6
  export * from './useFormatNumber';
7
+ export * from './useDateTimeLocale';
8
+ export * from './useDateTimePreferences';
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from 'react';
2
+ export interface DateTimeOptions {
3
+ showTime?: boolean;
4
+ showDate?: boolean;
5
+ showSeconds?: boolean;
6
+ dateTimeLocale?: string | null;
7
+ }
8
+ export declare function useDateTimeFormatter(options?: DateTimeOptions): (date?: Date | string | number | null, fallback?: string | ReactNode) => ReactNode;
@@ -0,0 +1 @@
1
+ export declare function useDateTimeLocale(override?: string | null): string;
@@ -0,0 +1,4 @@
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
+ }>>;
@@ -1,7 +1,2 @@
1
- export interface DateTimeOptions {
2
- showTime?: boolean;
3
- showDate?: boolean;
4
- showSeconds?: boolean;
5
- }
6
- export declare function useDateTimeFormatter(options?: DateTimeOptions): (date?: Date | string | number | null, fallback?: string | React.ReactNode) => import('react').ReactNode;
1
+ import { DateTimeOptions } from './useDateTimeFormatter';
7
2
  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 function that formats minutes into a localized duration string
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,39 @@ 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
  }
14
+ /** Global language store: the host app and every plugin's useTranslations hook must follow the same active language. */
12
15
  export declare const useTranslationState: import('zustand').UseBoundStore<import('zustand').StoreApi<TranslationState>>;
13
16
  export type TFunction = (key: string, data?: Record<string, unknown>) => string;
17
+ /** Retained translations stay reactive; literal API errors remain intact. */
18
+ export interface TranslationMessage {
19
+ key: string;
20
+ data?: Record<string, unknown>;
21
+ }
22
+ interface TranslationOptions {
23
+ /** Disable only for React text rendering, never for messages rendered as HTML. */
24
+ escapeValues?: boolean;
25
+ }
14
26
  interface TExistsOptions {
15
27
  succeedIfKeyIsObject?: boolean;
16
28
  }
17
29
  export type TExists = (key: string, options?: TExistsOptions) => boolean;
18
30
  interface UseTranslationsResponse {
19
31
  t: TFunction;
32
+ tMessage: (message: TranslationMessage | string) => string;
20
33
  tExists: TExists;
21
34
  language: Language;
22
35
  setLanguage: (language: Language) => void;
23
36
  }
24
- export declare function useTranslations(translations: TranslationModules): UseTranslationsResponse;
37
+ export declare function useTranslations(translations: TranslationModules, options?: TranslationOptions): UseTranslationsResponse;
38
+ /** Explicit browser choices precede supported browser languages, then the system fallback. */
39
+ export declare function detectPreferredLanguage(): Language | undefined;
40
+ export declare function detectLanguage(fallback?: Language): Language;
25
41
  export declare function detectAndSetLanguage(): void;
26
42
  export {};
package/package.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "name": "@attraccess/plugins-frontend-ui",
3
- "version": "1.10.0",
3
+ "version": "1.11.0-beta.2",
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",