@lokalise/harmony 1.11.0 → 1.11.1

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.
@@ -1,89 +1,5 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
2
  import { Sidebar } from './Sidebar';
3
- /**
4
- * ## Overview
5
- * Sidebar is a self-contained component using widgets.
6
- *
7
- * ## Available Widgets
8
- *
9
- * ### `Sidebar.Top`
10
- * Use to wrap up a top section of the Sidebar
11
- *
12
- * ### `Sidebar.Bottom`
13
- * Use to wrap up a bottom section of the Sidebar
14
- *
15
- * ### `Sidebar.Avatar`
16
- * Display company main avatar / logo in the top section
17
- * ```
18
- * src: string;
19
- * href?: string; ('/')
20
- * ariaLabel?: string; ('Home')
21
- * alt?: string; ('Lokalise')
22
- * ```
23
- *
24
- * ### `Sidebar.IconLink`
25
- * Display link with an icon. Mainly used in the top section
26
- * ```
27
- * to: string;
28
- * label: string;
29
- * icon: FC<SvgIconProps>
30
- * ```
31
- *
32
- * ### `Sidebar.Menu`
33
- * Use this widget for simple side menu. Currently utilised for `Help` section
34
- * ```
35
- * icon: FC<SvgIconProps>
36
- * children: ReactNode; (representing menu list)
37
- * ```
38
- *
39
- * ### `Sidebar.ProfileMenu`
40
- * Contextual component, requires initial configuration
41
- * ```
42
- * teams: SidebarTeam[];
43
- * currentTeamId: number;
44
- * planId: number;
45
- * isLimitedView: boolean;
46
- * isTeamSuspended: boolean;
47
- * canAccessTeamSettings: boolean;
48
- * isEndOfTrialActive: boolean;
49
- * trialDaysLeft: number;
50
- * isProviderAlpha: boolean;
51
- * ```
52
- * and works with internal widgets
53
- *
54
- * #### `Sidebar.TeamSwitch`
55
- * Uses available teams (other than current) and allows user to switch between them
56
- * ```
57
- * onSwitchTeam: (team: SidebarTeam) => void;
58
- * ```
59
- *
60
- * #### `Sidebar.TeamMenuItem`
61
- * Uses context of current team, and depending on ability to switch team or not,
62
- * it renders as a div or clickable MenuItem. If used with TeamSwitch, it triggers `onSwitchTeams`
63
- * callback, passing relevant team as an argument
64
- * ```
65
- * team?: SidebarTeam; (fallbacks to currentTeam from context if not passed)
66
- * onClick?: (team: SidebarTeam) => void;
67
- * hidePlanLabel?: boolean;
68
- * ```
69
- *
70
- * #### `Sidebar.ProfileSettingsMenuItem`
71
- * Menu item that comes with a small user's email and renders conditionally, only if team
72
- * is not suspended or is not at the end of a trial
73
- * ```
74
- * href: string;
75
- * userEmail: string;
76
- * onClick?: () => void; (additional onClick for any tracking events)
77
- * hideBottomDivider?: boolean;
78
- * ```
79
- *
80
- * #### `Sidebar.UpgradeMenuItem`
81
- * Menu item conditionally rendering only if `showUpgradeButton` is `true`. It renders correct
82
- * upgrade note depending on the current team plan and red arrow up to indicate an update option
83
- * ```
84
- * upgradeOptionHref: string;
85
- * ```
86
- */
87
3
  declare const meta: Meta<typeof Sidebar>;
88
4
  type Story = StoryObj<typeof Sidebar>;
89
5
  export declare const FullSidebar: Story;
@@ -1,11 +1,16 @@
1
1
  type AvatarProps = {
2
+ /** URL of the avatar/logo image */
2
3
  src: string;
4
+ /** Link destination when avatar is clicked. Defaults to '/' */
3
5
  href?: string;
6
+ /** Accessibility label for the avatar link. Defaults to 'Home' */
4
7
  ariaLabel?: string;
8
+ /** Alt text for the avatar image. Defaults to 'Lokalise' */
5
9
  alt?: string;
6
10
  };
7
11
  /**
8
- * Display company main avatar / logo in the top section
12
+ * Display company main avatar / logo in the top section of the Sidebar.
13
+ * Used as the main branding element and home navigation link.
9
14
  */
10
15
  export declare const Avatar: ({ src, href, ariaLabel, alt }: AvatarProps) => import("react/jsx-runtime").JSX.Element;
11
16
  export {};
@@ -1,12 +1,22 @@
1
1
  import { SvgIconProps } from '@lokalise/louis';
2
2
  import { FC } from 'react';
3
3
  type IconLinkProps = {
4
+ /** URL destination for the link */
4
5
  to: string;
6
+ /** Text to display in the tooltip when hovering over the icon */
5
7
  label: string;
8
+ /** Icon component from @lokalise/louis to display */
6
9
  icon: FC<SvgIconProps>;
7
10
  };
8
11
  /**
9
- * Display link with an icon. Mainly used in the top section
12
+ * A navigation link component that displays an icon with a tooltip.
13
+ * When hovered, shows a tooltip with the label text.
14
+ * The link is highlighted when the current URL matches its destination.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * <IconLink to="/projects" label="Projects" icon={FolderOpenIcon} />
19
+ * ```
10
20
  */
11
21
  export declare const IconLink: ({ label, to, icon: Icon }: IconLinkProps) => import("react/jsx-runtime").JSX.Element;
12
22
  export {};
@@ -1,10 +1,24 @@
1
1
  import { SvgIconProps } from '@lokalise/louis';
2
2
  import { FC, PropsWithChildren } from 'react';
3
3
  type MenuProps = PropsWithChildren<{
4
+ /** Icon component from @lokalise/louis to display in the menu button */
4
5
  icon: FC<SvgIconProps>;
5
6
  }>;
6
7
  /**
7
- * Use this widget for simple side menu. Currently utilised for `Help` section
8
+ * A dropdown menu component that displays an icon button which reveals a menu list when clicked.
9
+ * The menu is positioned to the right of the button and includes a tooltip.
10
+ *
11
+ * Used primarily for dropdown menus in the Sidebar, such as the Help menu.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * <Menu icon={HelpCenterIcon}>
16
+ * <MenuItem href="/docs">Documentation</MenuItem>
17
+ * <MenuItem href="/tutorial">Tutorials</MenuItem>
18
+ * <MenuDivider />
19
+ * <MenuItem href="/blog">Blog</MenuItem>
20
+ * </Menu>
21
+ * ```
8
22
  */
9
23
  export declare const Menu: ({ children, icon: Icon }: MenuProps) => import("react/jsx-runtime").JSX.Element;
10
24
  export {};
@@ -1,12 +1,30 @@
1
1
  import { ProfileMenuContentProps } from './ProfileMenuContent';
2
2
  import { SidebarProfileMenuConfig } from './types';
3
3
  type ProfileMenuProps = {
4
+ /** Configuration object containing team and user settings */
4
5
  config: SidebarProfileMenuConfig;
6
+ /** Render function for the menu content */
5
7
  children: ProfileMenuContentProps['children'];
6
8
  };
7
9
  /**
8
- * Contextual component, requires initial configuration
9
- * and works with internal widgets
10
+ * A contextual menu component that provides team management functionality.
11
+ * It manages team switching, profile settings, billing options, and upgrade prompts.
12
+ *
13
+ * The component uses a render prop pattern to provide context values to its children,
14
+ * allowing flexible composition of menu items based on user permissions and team status.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * <ProfileMenu config={profileMenuConfig}>
19
+ * {({ allowTeamCreation, showBillingButton }) => (
20
+ * <>
21
+ * <TeamSwitch onSwitchTeam={handleTeamSwitch} />
22
+ * {allowTeamCreation && <MenuItem>Create new team</MenuItem>}
23
+ * {showBillingButton && <MenuItem href="/billing">Billing</MenuItem>}
24
+ * </>
25
+ * )}
26
+ * </ProfileMenu>
27
+ * ```
10
28
  */
11
29
  export declare const ProfileMenu: ({ config, children }: ProfileMenuProps) => import("react/jsx-runtime").JSX.Element;
12
30
  export {};
@@ -1,12 +1,42 @@
1
1
  type ProfileSettingsMenuItemProps = {
2
+ /** URL to the profile settings page */
2
3
  href: string;
4
+ /** User's email address to display below "Profile Settings" */
3
5
  userEmail: string;
6
+ /** Optional callback function for tracking or additional actions */
4
7
  onClick?: () => void;
8
+ /** Whether to hide the divider that appears below this menu item */
5
9
  hideBottomDivider?: boolean;
6
10
  };
7
11
  /**
8
- * Menu item that comes with a small user's email and renders conditionally,
9
- * only if team is not suspended or is not at the end of a trial
12
+ * A menu item component that provides access to profile settings.
13
+ *
14
+ * Features:
15
+ * - Displays "Profile Settings" with the user's email address below
16
+ * - Conditionally renders based on team status
17
+ * - Includes an optional divider below the item
18
+ * - Will not render if:
19
+ * - Team is suspended
20
+ * - Team's trial period has ended
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * <ProfileSettingsMenuItem
25
+ * href="/settings/profile"
26
+ * userEmail="user@example.com"
27
+ * onClick={() => trackSettingsClick()}
28
+ * />
29
+ *
30
+ * // Without bottom divider
31
+ * <ProfileSettingsMenuItem
32
+ * href="/settings/profile"
33
+ * userEmail="user@example.com"
34
+ * hideBottomDivider
35
+ * />
36
+ * ```
37
+ *
38
+ * @note This component must be used within a ProfileMenu component
39
+ * as it requires access to the ProfileMenu context for team status information.
10
40
  */
11
41
  export declare const ProfileSettingsMenuItem: ({ href, onClick, userEmail, hideBottomDivider, }: ProfileSettingsMenuItemProps) => import("react/jsx-runtime").JSX.Element | null;
12
42
  export {};
@@ -1,13 +1,36 @@
1
1
  import { SidebarTeam } from '../../../types';
2
2
  type TeamMenuItemProps = {
3
+ /** Team to display. If not provided, uses the current team from context */
3
4
  team?: SidebarTeam;
5
+ /** Callback for when the team item is clicked. If provided, renders as a clickable MenuItem */
4
6
  onClick?: (team: SidebarTeam) => void;
7
+ /** Whether to hide the plan label (Free/Trial). Useful when displaying multiple teams */
5
8
  hidePlanLabel?: boolean;
6
9
  };
7
10
  /**
8
- * Uses context of current team, and depending on ability to switch team or not,
9
- * it renders as a div or clickable MenuItem. If used with TeamSwitch, it triggers `onSwitchTeams`
10
- * callback, passing relevant team as an argument
11
+ * A component that displays team information in a menu item format.
12
+ * Renders team logo (or default user icon), team name, role, and plan label.
13
+ *
14
+ * The component can be used in two modes:
15
+ * 1. As a static display of the current team (when no onClick handler is provided)
16
+ * 2. As a clickable menu item for team switching (when onClick handler is provided)
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * // Static current team display
21
+ * <TeamMenuItem />
22
+ *
23
+ * // Clickable team item for switching
24
+ * <TeamMenuItem
25
+ * team={someTeam}
26
+ * onClick={(team) => handleTeamSwitch(team)}
27
+ * hidePlanLabel
28
+ * />
29
+ * ```
30
+ *
31
+ * @note This component must be used within a ProfileMenu component
32
+ * as it requires access to the ProfileMenu context for current team
33
+ * and plan information.
11
34
  */
12
35
  export declare const TeamMenuItem: ({ team, onClick, hidePlanLabel }: TeamMenuItemProps) => import("react/jsx-runtime").JSX.Element | null;
13
36
  export {};
@@ -1,9 +1,28 @@
1
1
  import { SidebarTeam } from '../../../types';
2
2
  type TeamSwitchProps = {
3
+ /** Callback function triggered when a user selects a different team */
3
4
  onSwitchTeam: (team: SidebarTeam) => void;
4
5
  };
5
6
  /**
6
- * Uses available teams (other than current) and allows user to switch between them
7
+ * A component that displays a list of available teams for switching.
8
+ * It automatically excludes the current team from the list and renders
9
+ * nothing if there are no other teams available.
10
+ *
11
+ * Uses the ProfileMenu context to access the list of other teams and
12
+ * renders each team as a TeamMenuItem with click functionality.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * <TeamSwitch
17
+ * onSwitchTeam={(team) => {
18
+ * console.log(`Switching to team: ${team.name}`);
19
+ * // Handle team switch logic
20
+ * }}
21
+ * />
22
+ * ```
23
+ *
24
+ * @note This component must be used within a ProfileMenu component
25
+ * as it requires access to the ProfileMenu context.
7
26
  */
8
27
  export declare const TeamSwitch: ({ onSwitchTeam }: TeamSwitchProps) => import("react/jsx-runtime").JSX.Element | null;
9
28
  export {};
@@ -1,10 +1,26 @@
1
1
  type UpgradeMenuItemProps = {
2
+ /** URL to the upgrade page or pricing options */
2
3
  upgradeOptionHref: string;
3
4
  };
4
5
  /**
5
- * Menu item conditionally rendering only if `showUpgradeButton` is `true`.
6
- * It renders correct upgrade note depending on the current team plan
7
- * and red arrow up to indicate an update option.
6
+ * A menu item component that displays upgrade call-to-action information.
7
+ * Only renders when upgrade options should be shown (determined by context).
8
+ *
9
+ * The component displays different messages based on the team's current plan:
10
+ * - For free plans: "Your team is currently on the Free plan"
11
+ * - For trial plans: "Free trial ends in X days"
12
+ *
13
+ * Includes an upgrade icon and "See upgrade options" text, styled to draw attention
14
+ * to the upgrade opportunity.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * <UpgradeMenuItem upgradeOptionHref="/pricing" />
19
+ * ```
20
+ *
21
+ * @note This component must be used within a ProfileMenu component
22
+ * as it requires access to the ProfileMenu context for plan information
23
+ * and visibility control.
8
24
  */
9
25
  export declare const UpgradeMenuItem: ({ upgradeOptionHref }: UpgradeMenuItemProps) => import("react/jsx-runtime").JSX.Element | null;
10
26
  export {};
@@ -1,5 +1,9 @@
1
1
  import { SidebarTeam, SidebarTeamRole } from '../../types';
2
2
  export type { SidebarTeam, SidebarTeamRole } from '../../types';
3
+ /**
4
+ * Configuration object for the Sidebar's ProfileMenu component.
5
+ * Contains data from various API endpoints and JWT token.
6
+ */
3
7
  export type SidebarProfileMenuConfig = {
4
8
  teams: SidebarTeam[];
5
9
  isTeamSuspended: boolean;
@@ -12,6 +16,9 @@ export type SidebarProfileMenuConfig = {
12
16
  userTeamRole: SidebarTeamRole;
13
17
  userEmail: string;
14
18
  };
19
+ /**
20
+ * Extended configuration including computed properties used within the ProfileMenu context.
21
+ */
15
22
  export type SidebarProfileMenuContextProps = SidebarProfileMenuConfig & {
16
23
  currentTeam?: SidebarTeam;
17
24
  otherTeams: SidebarTeam[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lokalise/harmony",
3
- "version": "1.11.0",
3
+ "version": "1.11.1",
4
4
  "author": {
5
5
  "name": "Lokalise",
6
6
  "url": "https://lokalise.com/"