@sensorario/sg-components 0.0.103 → 0.0.105

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 (34) hide show
  1. package/dist/components/AppLauncher/AppLauncher.d.ts +1 -1
  2. package/dist/components/Avatar/Avatar.d.ts +10 -0
  3. package/dist/components/Avatar/Avatar.stories.d.ts +8 -0
  4. package/dist/components/Badge/Badge.d.ts +17 -0
  5. package/dist/components/Badge/Badge.stories.d.ts +8 -0
  6. package/dist/components/Button/Button.d.ts +1 -0
  7. package/dist/components/Button/Button.stories.d.ts +1 -0
  8. package/dist/components/Card/Card.d.ts +20 -0
  9. package/dist/components/Card/Card.stories.d.ts +9 -0
  10. package/dist/components/ConfirmModal/ConfirmModal.d.ts +18 -0
  11. package/dist/components/ConfirmModal/ConfirmModal.stories.d.ts +7 -0
  12. package/dist/components/FormField/FormField.d.ts +19 -0
  13. package/dist/components/FormField/FormField.stories.d.ts +6 -0
  14. package/dist/components/LanguageSwitcher/LanguageSwitcher.d.ts +6 -0
  15. package/dist/components/LanguageSwitcher/LanguageSwitcher.stories.d.ts +5 -0
  16. package/dist/components/Modal/Modal.d.ts +1 -0
  17. package/dist/components/PasswordInput/PasswordInput.d.ts +1 -0
  18. package/dist/components/ProgressBar/ProgressBar.d.ts +16 -0
  19. package/dist/components/ProgressBar/ProgressBar.stories.d.ts +10 -0
  20. package/dist/components/Quadrato/Header/QuadratoHeader.d.ts +2 -0
  21. package/dist/components/Select/Select.d.ts +7 -0
  22. package/dist/components/StatusMessage/StatusMessage.d.ts +13 -0
  23. package/dist/components/StatusMessage/StatusMessage.stories.d.ts +10 -0
  24. package/dist/components/Table/Table.stories.d.ts +5 -0
  25. package/dist/components/Tabs/Tabs.d.ts +19 -0
  26. package/dist/components/Tabs/Tabs.stories.d.ts +8 -0
  27. package/dist/components/Textarea/Textarea.d.ts +7 -0
  28. package/dist/components/Toggle/Toggle.d.ts +5 -1
  29. package/dist/components/Toggle/Toggle.stories.d.ts +1 -0
  30. package/dist/i18n/index.d.ts +13 -0
  31. package/dist/index.d.ts +14 -0
  32. package/dist/index.es.js +846 -341
  33. package/dist/sg-components.css +1 -1
  34. package/package.json +13 -2
@@ -9,7 +9,7 @@ export type LauncherApp = {
9
9
  interface AppLauncherProps {
10
10
  /** Endpoint returning `{ apps: LauncherApp[] }` - the enabled apps, managed from Heimdall. */
11
11
  appsUrl?: string;
12
- /** Accessible name of the grid button - this library has no i18n of its own. */
12
+ /** Accessible name of the grid button. Default: the translated "App". */
13
13
  label?: string;
14
14
  /** Logged-in user's JWT: the API then lists only the apps this user may use. */
15
15
  token?: string | null;
@@ -0,0 +1,10 @@
1
+ import './Avatar.css';
2
+ interface AvatarProps {
3
+ src?: string | null;
4
+ /** Alt text, and its first letter is shown when there's no image. */
5
+ name?: string | null;
6
+ size?: number;
7
+ className?: string;
8
+ }
9
+ export declare const Avatar: ({ src, name, size, className }: AvatarProps) => import("react/jsx-runtime").JSX.Element;
10
+ export default Avatar;
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { Avatar } from './Avatar';
3
+ declare const meta: Meta<typeof Avatar>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Avatar>;
6
+ export declare const Initial: Story;
7
+ export declare const Image: Story;
8
+ export declare const Sizes: Story;
@@ -0,0 +1,17 @@
1
+ import type { ReactNode } from 'react';
2
+ import './Badge.css';
3
+ export type BadgeTone = 'neutral' | 'accent' | 'success' | 'danger';
4
+ interface BadgeProps {
5
+ children: ReactNode;
6
+ tone?: BadgeTone;
7
+ /** Makes the badge a toggle button (e.g. a pickable tag); `selected` is its pressed state. */
8
+ onClick?: () => void;
9
+ selected?: boolean;
10
+ /** Adds a "×" button, e.g. to take a user off a role. */
11
+ onRemove?: () => void;
12
+ /** Accessible name of the "×" button. Default: the translated "Remove". */
13
+ removeLabel?: string;
14
+ className?: string;
15
+ }
16
+ export declare const Badge: ({ children, tone, onClick, selected, onRemove, removeLabel, className }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
17
+ export default Badge;
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { Badge } from './Badge';
3
+ declare const meta: Meta<typeof Badge>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Badge>;
6
+ export declare const Tones: Story;
7
+ export declare const Selectable: Story;
8
+ export declare const Removable: Story;
@@ -5,6 +5,7 @@ type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
5
5
  label: string;
6
6
  icon?: IconName;
7
7
  iconOnly?: boolean;
8
+ variant?: 'primary' | 'secondary' | 'danger';
8
9
  };
9
10
  export declare const Button: React.FC<ButtonProps>;
10
11
  export default Button;
@@ -4,3 +4,4 @@ declare const meta: Meta<typeof Button>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof Button>;
6
6
  export declare const Default: Story;
7
+ export declare const Variants: Story;
@@ -0,0 +1,20 @@
1
+ import { type ReactNode } from 'react';
2
+ import './Card.css';
3
+ interface CardProps {
4
+ /** Rendered next to each other at the top: title on the left, e.g. a date on the right. */
5
+ header?: ReactNode;
6
+ /** Row of links/buttons below the content. */
7
+ actions?: ReactNode;
8
+ children?: ReactNode;
9
+ variant?: 'default' | 'mini';
10
+ /** Lifts on hover, for cards that are themselves a link or a button. */
11
+ interactive?: boolean;
12
+ as?: 'div' | 'li' | 'article' | 'section' | 'a';
13
+ href?: string;
14
+ className?: string;
15
+ }
16
+ export declare const Card: ({ header, actions, children, variant, interactive, as, href, className, }: CardProps) => import("react").DetailedReactHTMLElement<{
17
+ className: string;
18
+ href: string | undefined;
19
+ }, HTMLElement>;
20
+ export default Card;
@@ -0,0 +1,9 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { Card } from './Card';
3
+ declare const meta: Meta<typeof Card>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Card>;
6
+ export declare const Default: Story;
7
+ export declare const WithHeaderAndActions: Story;
8
+ export declare const Mini: Story;
9
+ export declare const InteractiveLink: Story;
@@ -0,0 +1,18 @@
1
+ import type { ReactNode } from 'react';
2
+ import './ConfirmModal.css';
3
+ interface ConfirmModalProps {
4
+ open: boolean;
5
+ title: string;
6
+ /** The question, e.g. "This can't be undone." */
7
+ children?: ReactNode;
8
+ onConfirm: () => void;
9
+ /** Also called on Escape, backdrop click and the "×". */
10
+ onCancel: () => void;
11
+ confirmLabel?: string;
12
+ cancelLabel?: string;
13
+ /** Red confirm button, for destructive actions. */
14
+ danger?: boolean;
15
+ icon?: ReactNode;
16
+ }
17
+ export declare const ConfirmModal: ({ open, title, children, onConfirm, onCancel, confirmLabel, cancelLabel, danger, icon, }: ConfirmModalProps) => import("react/jsx-runtime").JSX.Element;
18
+ export default ConfirmModal;
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { ConfirmModal } from './ConfirmModal';
3
+ declare const meta: Meta<typeof ConfirmModal>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof ConfirmModal>;
6
+ export declare const Default: Story;
7
+ export declare const Danger: Story;
@@ -0,0 +1,19 @@
1
+ import { type ReactElement, type ReactNode } from 'react';
2
+ import './FormField.css';
3
+ type ControlProps = {
4
+ id?: string;
5
+ 'aria-describedby'?: string;
6
+ 'aria-invalid'?: boolean;
7
+ invalid?: boolean;
8
+ };
9
+ interface FormFieldProps {
10
+ label: ReactNode;
11
+ /** A single control: Input-like element, Textarea, Select, or a native one. */
12
+ children: ReactElement<ControlProps>;
13
+ hint?: ReactNode;
14
+ /** Replaces the hint and marks the control invalid. */
15
+ error?: ReactNode;
16
+ className?: string;
17
+ }
18
+ export declare const FormField: ({ label, children, hint, error, className }: FormFieldProps) => import("react/jsx-runtime").JSX.Element;
19
+ export default FormField;
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { FormField } from './FormField';
3
+ declare const meta: Meta<typeof FormField>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof FormField>;
6
+ export declare const Form: Story;
@@ -0,0 +1,6 @@
1
+ import './LanguageSwitcher.css';
2
+ interface LanguageSwitcherProps {
3
+ className?: string;
4
+ }
5
+ export declare const LanguageSwitcher: ({ className }: LanguageSwitcherProps) => import("react/jsx-runtime").JSX.Element;
6
+ export default LanguageSwitcher;
@@ -0,0 +1,5 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { LanguageSwitcher } from './LanguageSwitcher';
3
+ declare const meta: Meta<typeof LanguageSwitcher>;
4
+ export default meta;
5
+ export declare const Default: StoryObj<typeof LanguageSwitcher>;
@@ -12,6 +12,7 @@ interface ModalProps {
12
12
  children: React.ReactNode;
13
13
  buttons?: ModalButton[];
14
14
  footer?: React.ReactNode;
15
+ /** Accessible name of the dismiss button. Default: the translated "Close". */
15
16
  closeLabel?: string;
16
17
  className?: string;
17
18
  }
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import './PasswordInput.css';
3
3
  type PasswordInputProps = React.InputHTMLAttributes<HTMLInputElement> & {
4
4
  label?: string;
5
+ invalid?: boolean;
5
6
  };
6
7
  export declare const PasswordInput: React.FC<PasswordInputProps>;
7
8
  export default PasswordInput;
@@ -0,0 +1,16 @@
1
+ import type { ReactNode } from 'react';
2
+ import './ProgressBar.css';
3
+ export type ProgressTone = 'accent' | 'success' | 'danger';
4
+ interface ProgressBarProps {
5
+ value: number;
6
+ max?: number;
7
+ /** Shown next to the track, e.g. "3/10" or "120g / 200g". */
8
+ label?: ReactNode;
9
+ /** Accessible name when there's no visible label saying what is being measured. */
10
+ ariaLabel?: string;
11
+ tone?: ProgressTone;
12
+ size?: 'sm' | 'md';
13
+ className?: string;
14
+ }
15
+ export declare const ProgressBar: ({ value, max, label, ariaLabel, tone, size, className, }: ProgressBarProps) => import("react/jsx-runtime").JSX.Element;
16
+ export default ProgressBar;
@@ -0,0 +1,10 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { ProgressBar } from './ProgressBar';
3
+ declare const meta: Meta<typeof ProgressBar>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof ProgressBar>;
6
+ export declare const Default: Story;
7
+ export declare const Small: Story;
8
+ export declare const Success: Story;
9
+ export declare const Over: Story;
10
+ export declare const WithoutLabel: Story;
@@ -1,4 +1,6 @@
1
1
  import './QuadratoHeader.css';
2
+ /** Dispatch on `window` with the new avatar (data URL or null) as `detail` after changing it, so the header updates without a reload. */
3
+ export declare const AVATAR_CHANGE_EVENT = "sg-avatar-change";
2
4
  interface QuadratoHeaderProps {
3
5
  title?: string;
4
6
  homePageKey?: string;
@@ -0,0 +1,7 @@
1
+ import type { SelectHTMLAttributes } from 'react';
2
+ import './Select.css';
3
+ type SelectProps = SelectHTMLAttributes<HTMLSelectElement> & {
4
+ invalid?: boolean;
5
+ };
6
+ export declare const Select: ({ invalid, className, children, ...props }: SelectProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default Select;
@@ -0,0 +1,13 @@
1
+ import type { ReactNode } from 'react';
2
+ import './StatusMessage.css';
3
+ export type StatusKind = 'info' | 'empty' | 'loading' | 'error';
4
+ interface StatusMessageProps {
5
+ kind?: StatusKind;
6
+ /** Draws a tinted box around the text instead of plain colored text. */
7
+ boxed?: boolean;
8
+ /** Defaults to the translated "Loading…" for `kind="loading"`. */
9
+ children?: ReactNode;
10
+ className?: string;
11
+ }
12
+ export declare const StatusMessage: ({ kind, boxed, children, className }: StatusMessageProps) => import("react/jsx-runtime").JSX.Element;
13
+ export default StatusMessage;
@@ -0,0 +1,10 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { StatusMessage } from './StatusMessage';
3
+ declare const meta: Meta<typeof StatusMessage>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof StatusMessage>;
6
+ export declare const Loading: Story;
7
+ export declare const Empty: Story;
8
+ export declare const Error: Story;
9
+ export declare const ErrorBoxed: Story;
10
+ export declare const InfoBoxed: Story;
@@ -0,0 +1,5 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import './Table.css';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ export declare const Default: StoryObj;
@@ -0,0 +1,19 @@
1
+ import { type ReactNode } from 'react';
2
+ import './Tabs.css';
3
+ export type TabItem<T extends string | number> = {
4
+ value: T;
5
+ label: ReactNode;
6
+ disabled?: boolean;
7
+ };
8
+ interface TabsProps<T extends string | number> {
9
+ items: TabItem<T>[];
10
+ value: T;
11
+ onChange: (value: T) => void;
12
+ /** underline: page sections; pills: filters; segmented: a few mutually exclusive views. */
13
+ variant?: 'underline' | 'pills' | 'segmented';
14
+ /** Accessible name of the tab list. */
15
+ ariaLabel?: string;
16
+ className?: string;
17
+ }
18
+ export declare const Tabs: <T extends string | number>({ items, value, onChange, variant, ariaLabel, className, }: TabsProps<T>) => import("react/jsx-runtime").JSX.Element;
19
+ export default Tabs;
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { Tabs } from './Tabs';
3
+ declare const meta: Meta<typeof Tabs>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Tabs>;
6
+ export declare const Underline: Story;
7
+ export declare const Pills: Story;
8
+ export declare const Segmented: Story;
@@ -0,0 +1,7 @@
1
+ import type { TextareaHTMLAttributes } from 'react';
2
+ import './Textarea.css';
3
+ type TextareaProps = TextareaHTMLAttributes<HTMLTextAreaElement> & {
4
+ invalid?: boolean;
5
+ };
6
+ export declare const Textarea: ({ invalid, className, rows, ...props }: TextareaProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default Textarea;
@@ -1,9 +1,13 @@
1
- import React from 'react';
1
+ import React, { type ReactNode } from 'react';
2
2
  import './Toggle.css';
3
3
  export interface ToggleProps {
4
4
  checked: boolean;
5
5
  onChange: (checked: boolean) => void;
6
6
  label: string;
7
+ /** Shown between the label and the switch, e.g. a preview of what the setting changes. */
8
+ icons?: ReactNode;
9
+ /** "row": label on the left, switch on the right, full width - for a list of settings. */
10
+ layout?: 'inline' | 'row';
7
11
  }
8
12
  export declare const Toggle: React.FC<ToggleProps>;
9
13
  export default Toggle;
@@ -4,3 +4,4 @@ declare const meta: Meta<typeof Toggle>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof Toggle>;
6
6
  export declare const Default: Story;
7
+ export declare const Row: Story;
@@ -0,0 +1,13 @@
1
+ import { type i18n } from 'i18next';
2
+ export declare const SUPPORTED_LANGUAGES: readonly ["it", "en", "fr", "de", "es", "ja"];
3
+ export type SupportedLanguage = typeof SUPPORTED_LANGUAGES[number];
4
+ export declare const LANGUAGE_NAMES: Record<SupportedLanguage, string>;
5
+ export declare const LANGUAGE_COOKIE = "sg-language";
6
+ export declare const readLanguageCookie: () => SupportedLanguage | null;
7
+ export declare const sgI18n: i18n;
8
+ type AppResources = Partial<Record<SupportedLanguage, Record<string, unknown>>>;
9
+ /** Adds the app's own texts (default namespace) to the shared instance and makes it the one react-i18next hooks use. */
10
+ export declare const createI18n: ({ resources }: {
11
+ resources: AppResources;
12
+ }) => i18n;
13
+ export {};
package/dist/index.d.ts CHANGED
@@ -17,3 +17,17 @@ export * from './components/FontPicker/FontPicker';
17
17
  export * from './components/Toggle/Toggle';
18
18
  export * from './components/AppLauncher/AppLauncher';
19
19
  export * from './components/AppAccessGate/AppAccessGate';
20
+ export * from './components/LanguageSwitcher/LanguageSwitcher';
21
+ export { createI18n, sgI18n, SUPPORTED_LANGUAGES, LANGUAGE_NAMES, LANGUAGE_COOKIE, readLanguageCookie } from './i18n';
22
+ export type { SupportedLanguage } from './i18n';
23
+ export * from './components/ProgressBar/ProgressBar';
24
+ export * from './components/StatusMessage/StatusMessage';
25
+ export * from './components/Card/Card';
26
+ export * from './components/Badge/Badge';
27
+ export * from './components/Avatar/Avatar';
28
+ export * from './components/ConfirmModal/ConfirmModal';
29
+ export * from './components/Textarea/Textarea';
30
+ export * from './components/Select/Select';
31
+ export * from './components/FormField/FormField';
32
+ export * from './components/Tabs/Tabs';
33
+ import './components/Table/Table.css';