@lokalise/harmony 1.4.0-exp-sidebarComponent.6 → 1.5.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.
Files changed (27) hide show
  1. package/dist/harmony.cjs +1 -1
  2. package/dist/harmony.css +1 -1
  3. package/dist/harmony.mjs +542 -883
  4. package/dist/types/src/components/Sidebar/Sidebar.d.ts +8 -6
  5. package/dist/types/src/components/Sidebar/Sidebar.stories.d.ts +85 -2
  6. package/dist/types/src/components/Sidebar/Widgets/IconLink/IconLink.d.ts +4 -3
  7. package/dist/types/src/components/Sidebar/Widgets/Menu/Menu.d.ts +7 -2
  8. package/dist/types/src/components/Sidebar/Widgets/ProfileMenu/ProfileMenu.d.ts +1 -1
  9. package/dist/types/src/components/Sidebar/Widgets/ProfileMenu/ProfileSettingsMenuItem/ProfileSettingsMenuItem.d.ts +2 -1
  10. package/dist/types/src/node.d.ts +2 -0
  11. package/dist/types/tests/mocks/sidebar/profileMenu.d.ts +2 -0
  12. package/package.json +4 -5
  13. package/dist/types/fixtures/sidebar/profileMenu.d.ts +0 -2
  14. package/dist/types/fixtures/sidebar/tasks.d.ts +0 -2
  15. package/dist/types/src/components/Sidebar/Widgets/Tasks/TaskLanguage/TaskLanguage.d.ts +0 -6
  16. package/dist/types/src/components/Sidebar/Widgets/Tasks/TaskLanguageCompleted/TaskLanguageCompleted.d.ts +0 -7
  17. package/dist/types/src/components/Sidebar/Widgets/Tasks/TaskOverview/TaskOverview.d.ts +0 -5
  18. package/dist/types/src/components/Sidebar/Widgets/Tasks/Tasks.d.ts +0 -3
  19. package/dist/types/src/components/Sidebar/Widgets/Tasks/TasksContext.d.ts +0 -2
  20. package/dist/types/src/components/Sidebar/Widgets/Tasks/TasksPopover/TasksPopover.d.ts +0 -1
  21. package/dist/types/src/components/Sidebar/Widgets/Tasks/TasksProvider.d.ts +0 -10
  22. package/dist/types/src/components/Sidebar/Widgets/Tasks/index.d.ts +0 -2
  23. package/dist/types/src/components/Sidebar/Widgets/Tasks/types.d.ts +0 -85
  24. package/dist/types/src/components/Sidebar/Widgets/Tasks/utils/content.d.ts +0 -16
  25. package/dist/types/src/components/Sidebar/Widgets/Tasks/utils/taskEvents.d.ts +0 -23
  26. package/dist/types/src/components/Sidebar/Widgets/index.d.ts +0 -5
  27. package/dist/types/vite.config.d.ts +0 -2
@@ -12,14 +12,15 @@ declare const Sidebar: {
12
12
  ariaLabel?: string;
13
13
  alt?: string;
14
14
  }) => import("react/jsx-runtime").JSX.Element;
15
- IconLink: ({ label, to, icon }: {
15
+ IconLink: ({ label, to, icon: Icon }: {
16
16
  to: string;
17
17
  label: string;
18
- icon: ReactNode;
18
+ icon: import('react').FC<import('@lokalise/louis').SvgIconProps>;
19
19
  }) => import("react/jsx-runtime").JSX.Element;
20
- Menu: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
21
- Tasks: (props: {
22
- config: import('./Widgets/Tasks/types').SidebarTasksConfig;
20
+ Menu: ({ children, icon: Icon }: {
21
+ icon: import('react').FC<import('@lokalise/louis').SvgIconProps>;
22
+ } & {
23
+ children?: ReactNode | undefined;
23
24
  }) => import("react/jsx-runtime").JSX.Element;
24
25
  ProfileMenu: ({ config, children }: {
25
26
  config: import('./Widgets/ProfileMenu/types').SidebarProfileMenuConfig;
@@ -36,10 +37,11 @@ declare const Sidebar: {
36
37
  UpgradeMenuItem: ({ upgradeOptionHref }: {
37
38
  upgradeOptionHref: string;
38
39
  }) => import("react/jsx-runtime").JSX.Element | null;
39
- ProfileSettingsMenuItem: ({ href, onClick, userEmail }: {
40
+ ProfileSettingsMenuItem: ({ href, onClick, userEmail, hideBottomDivider, }: {
40
41
  href: string;
41
42
  userEmail: string;
42
43
  onClick?: () => void;
44
+ hideBottomDivider?: boolean;
43
45
  }) => import("react/jsx-runtime").JSX.Element | null;
44
46
  };
45
47
  export { Sidebar };
@@ -1,7 +1,90 @@
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
+ */
3
87
  declare const meta: Meta<typeof Sidebar>;
4
- export default meta;
5
88
  type Story = StoryObj<typeof Sidebar>;
6
- export declare const TopSectionOnly: Story;
7
89
  export declare const FullSidebar: Story;
90
+ export default meta;
@@ -1,8 +1,9 @@
1
- import { ReactNode } from 'react';
1
+ import { SvgIconProps } from '@lokalise/louis';
2
+ import { FC } from 'react';
2
3
  type IconLinkProps = {
3
4
  to: string;
4
5
  label: string;
5
- icon: ReactNode;
6
+ icon: FC<SvgIconProps>;
6
7
  };
7
- export declare const IconLink: ({ label, to, icon }: IconLinkProps) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const IconLink: ({ label, to, icon: Icon }: IconLinkProps) => import("react/jsx-runtime").JSX.Element;
8
9
  export {};
@@ -1,2 +1,7 @@
1
- import { PropsWithChildren } from 'react';
2
- export declare const Menu: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
1
+ import { SvgIconProps } from '@lokalise/louis';
2
+ import { FC, PropsWithChildren } from 'react';
3
+ type MenuProps = PropsWithChildren<{
4
+ icon: FC<SvgIconProps>;
5
+ }>;
6
+ export declare const Menu: ({ children, icon: Icon }: MenuProps) => import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -1,5 +1,5 @@
1
- import { SidebarProfileMenuConfig } from './types';
2
1
  import { ProfileMenuContentProps } from './ProfileMenuContent';
2
+ import { SidebarProfileMenuConfig } from './types';
3
3
  type ProfileMenuProps = {
4
4
  config: SidebarProfileMenuConfig;
5
5
  children: ProfileMenuContentProps['children'];
@@ -2,6 +2,7 @@ type ProfileSettingsMenuItemProps = {
2
2
  href: string;
3
3
  userEmail: string;
4
4
  onClick?: () => void;
5
+ hideBottomDivider?: boolean;
5
6
  };
6
- export declare const ProfileSettingsMenuItem: ({ href, onClick, userEmail }: ProfileSettingsMenuItemProps) => import("react/jsx-runtime").JSX.Element | null;
7
+ export declare const ProfileSettingsMenuItem: ({ href, onClick, userEmail, hideBottomDivider, }: ProfileSettingsMenuItemProps) => import("react/jsx-runtime").JSX.Element | null;
7
8
  export {};
@@ -3,4 +3,6 @@
3
3
  */
4
4
  export { NavigationPanel } from './components/NavigationPanel/NavigationPanel';
5
5
  export { Sidebar } from './components/Sidebar/Sidebar';
6
+ export { Breadcrumbs } from './components/NavigationPanel/components/Breadcrumbs/Breadcrumbs';
7
+ export { NavigationTabs } from './components/NavigationPanel/components/NavigationTabs/NavigationTabs';
6
8
  export * from './utils/node';
@@ -0,0 +1,2 @@
1
+ import { SidebarTeam } from '../../../src/components/Sidebar/types';
2
+ export declare const createTeam: () => SidebarTeam;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lokalise/harmony",
3
- "version": "1.4.0-exp-sidebarComponent.6",
3
+ "version": "1.5.0",
4
4
  "author": {
5
5
  "name": "Lokalise",
6
6
  "url": "https://lokalise.com/"
@@ -30,7 +30,7 @@
30
30
  "storybook:build": "storybook build"
31
31
  },
32
32
  "peerDependencies": {
33
- "@lokalise/louis": ">=26.1.1",
33
+ "@lokalise/louis": ">=26.0.0",
34
34
  "@lokalise/styled": ">=3.0.0",
35
35
  "@lokalise/token-dictionary": ">=2.42.1",
36
36
  "date-fns": ">=4.1",
@@ -82,15 +82,14 @@
82
82
  "main": "dist/harmony.cjs",
83
83
  "module": "dist/harmony.mjs",
84
84
  "types": "dist/types/index.d.ts",
85
+ "sideEffects": false,
85
86
  "exports": {
86
87
  ".": {
87
88
  "types": "./dist/types/index.d.ts",
88
89
  "require": "./dist/harmony.cjs",
89
90
  "import": "./dist/harmony.mjs"
90
- },
91
- "./harmony.css": "./dist/harmony.css"
91
+ }
92
92
  },
93
- "sideEffects": ["*.css"],
94
93
  "dependencies": {
95
94
  "clsx": "^2.1.1",
96
95
  "react-resize-detector": "^11.0.1"
@@ -1,2 +0,0 @@
1
- import { SidebarTeam } from '../../src/components/Sidebar/types';
2
- export declare const createTeam: () => SidebarTeam;
@@ -1,2 +0,0 @@
1
- import { SidebarTask } from '../../src/components/Sidebar/Widgets/Tasks/types';
2
- export declare const createTask: () => SidebarTask;
@@ -1,6 +0,0 @@
1
- import { SidebarLanguage, SidebarTask } from '../types';
2
- export type TaskLanguageProps = {
3
- task: SidebarTask;
4
- language: SidebarLanguage;
5
- };
6
- export declare const TaskLanguage: ({ language, task }: TaskLanguageProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +0,0 @@
1
- import { SidebarLanguage, SidebarTask } from '../types';
2
- type TaskLanguageCompletedProps = {
3
- task: SidebarTask;
4
- language: SidebarLanguage;
5
- };
6
- export declare const TaskLanguageCompleted: ({ task, language }: TaskLanguageCompletedProps) => import("react/jsx-runtime").JSX.Element;
7
- export {};
@@ -1,5 +0,0 @@
1
- import { SidebarTask } from '../types';
2
- export type TaskProps = {
3
- task: SidebarTask;
4
- };
5
- export declare const TaskOverview: ({ task }: TaskProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -1,3 +0,0 @@
1
- export declare const Tasks: (props: {
2
- config: import('./types').SidebarTasksConfig;
3
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +0,0 @@
1
- export declare const TasksContext: import('react').Context<TasksContextProps>;
2
- export declare const useTasks: () => TasksContextProps;
@@ -1 +0,0 @@
1
- export declare const TasksPopover: () => import("react/jsx-runtime").JSX.Element;
@@ -1,10 +0,0 @@
1
- import { FC, PropsWithChildren } from 'react';
2
- import { SidebarTasksConfig } from './types';
3
- type TasksProviderProps = PropsWithChildren<{
4
- config: SidebarTasksConfig;
5
- }>;
6
- export declare const TasksProvider: ({ children, config }: TasksProviderProps) => import("react/jsx-runtime").JSX.Element;
7
- export declare const withTasksContext: <P extends {
8
- config: SidebarTasksConfig;
9
- }>(WrappedComponent: FC<Omit<P, "config">>) => (props: P) => import("react/jsx-runtime").JSX.Element;
10
- export {};
@@ -1,2 +0,0 @@
1
- export { Tasks } from './Tasks';
2
- export { dispatchTaskEvent, TaskEvents } from './utils/taskEvents';
@@ -1,85 +0,0 @@
1
- import { TypesFromMap } from '../../../../utils/node.ts/typeUtils';
2
- export declare const SidebarTaskStatuses: {
3
- readonly Completed: "completed";
4
- readonly InProgress: "in_progress";
5
- readonly Created: "created";
6
- readonly Queued: "queued";
7
- };
8
- export type SidebarTaskStatus = TypesFromMap<typeof SidebarTaskStatuses>;
9
- export declare const SidebarTaskLanguageStatuses: {
10
- readonly Completed: "completed";
11
- readonly InProgress: "in_progress";
12
- readonly Created: "created";
13
- readonly Queued: "queued";
14
- };
15
- export type SidebarTaskLanguageStatus = TypesFromMap<typeof SidebarTaskLanguageStatuses>;
16
- export declare const SidebarTaskTypeOptions: {
17
- readonly translation: "translation";
18
- readonly review: "review";
19
- readonly lqa_by_ai: "lqa_by_ai";
20
- readonly automatic_translation: "automatic_translation";
21
- };
22
- export type SidebarTaskTypeOption = TypesFromMap<typeof SidebarTaskTypeOptions>;
23
- export type SidebarTaskStyleGuide = {
24
- id: string;
25
- name: string;
26
- };
27
- export type SidebarTaskLanguage = {
28
- lang_id: string;
29
- name: string;
30
- progress?: number;
31
- status: SidebarTaskLanguageStatus;
32
- base_words_total: `${number}`;
33
- base_words_done: `${number}`;
34
- };
35
- export type SidebarTask = {
36
- id: string;
37
- title: string;
38
- status: SidebarTaskStatus;
39
- langs: SidebarTaskLanguage[];
40
- team_id: number;
41
- created_by_fullname: string;
42
- source_lang_name: string;
43
- task_type: SidebarTaskTypeOption;
44
- style_guides: SidebarTaskStyleGuide[];
45
- description?: string;
46
- project_name: string;
47
- master_branching_enabled: '0' | '1';
48
- branch_name: string | null;
49
- due_date: string | null;
50
- };
51
- export type SidebarDefaultFnArgs = {
52
- task: SidebarTask;
53
- language: SidebarTaskLanguage;
54
- };
55
- export type SidebarDefaultFn = (props: SidebarDefaultFnArgs) => void;
56
- export type SidebarTasksGetProjectUrlFnArgs = {
57
- task: SidebarTask;
58
- language?: SidebarTaskLanguage;
59
- view?: 'single' | 'multi';
60
- taskUncompleted?: boolean;
61
- };
62
- export type SidebarTasksGetProjectUrlFn = (props: SidebarTasksGetProjectUrlFnArgs) => string;
63
- export type SidebarTaskTitleOnClickFn = (props: Pick<SidebarDefaultFnArgs, 'task'>) => void;
64
- export type SidebarOnLanguageCompleteConfirmFnArgs = SidebarDefaultFnArgs & {
65
- closePrompt: () => void;
66
- };
67
- export type SidebarOnLanguageCompleteConfirmFn = (props: SidebarOnLanguageCompleteConfirmFnArgs) => Promise<void>;
68
- export type SidebarTasksConfig = {
69
- getTasksCount: () => Promise<number>;
70
- getTasks: () => Promise<SidebarTask[]>;
71
- getProjectUrl: SidebarTasksGetProjectUrlFn;
72
- onLanguageCompleteConfirm: SidebarOnLanguageCompleteConfirmFn;
73
- onTasksWidgetOpen?: ({ tasks }: {
74
- tasks: SidebarTask[];
75
- }) => void;
76
- taskTitleOnClick?: SidebarTaskTitleOnClickFn;
77
- langNameOnClick?: SidebarDefaultFn;
78
- langProgressOnClick?: SidebarDefaultFn;
79
- };
80
- export type SidebarTasksContextProps = Pick<SidebarTasksConfig, 'onTasksWidgetOpen' | 'getProjectUrl' | 'taskTitleOnClick' | 'langNameOnClick' | 'langProgressOnClick' | 'onLanguageCompleteConfirm'> & {
81
- fetchTasks: () => Promise<void>;
82
- tasks: SidebarTask[];
83
- tasksCount: number;
84
- loadingTasks: boolean;
85
- };
@@ -1,16 +0,0 @@
1
- import { SidebarLanguage, SidebarLanguageStatus, SidebarTask, SidebarTaskTypeOption } from '../types';
2
- export declare const getStatusText: (status: SidebarLanguageStatus, progressValue: number) => "Closed" | "Completed" | "In progress" | "Not started" | "Queued" | "-";
3
- export declare const resolveStatus: (language: SidebarLanguage) => SidebarLanguageStatus;
4
- export declare const statusSortOrder: string[];
5
- /**
6
- * TODO - these should be taken from louis
7
- */
8
- export declare const tagColor: Record<SidebarTaskTypeOption, string>;
9
- export declare const getTaskLanguages: (langs: SidebarTask["langs"]) => {
10
- status: SidebarLanguageStatus;
11
- lang_id: string;
12
- name: string;
13
- progress?: number;
14
- base_words_total: `${number}`;
15
- base_words_done: `${number}`;
16
- }[];
@@ -1,23 +0,0 @@
1
- export declare const TaskEvents: {
2
- readonly TaskCompleted: "task_completed";
3
- readonly TaskClosed: "task_closed";
4
- readonly Refresh: "refresh";
5
- readonly ShowDialog: "show_dialog";
6
- };
7
- export type TaskEvent = (typeof TaskEvents)[keyof typeof TaskEvents];
8
- type SingleTaskPayload = {
9
- taskId: string | number;
10
- };
11
- type DispatchTaskEventPayload = {
12
- name: typeof TaskEvents.TaskCompleted;
13
- detail: SingleTaskPayload;
14
- } | {
15
- name: typeof TaskEvents.TaskClosed;
16
- detail: SingleTaskPayload;
17
- } | {
18
- name: typeof TaskEvents.Refresh;
19
- } | {
20
- name: typeof TaskEvents.ShowDialog;
21
- };
22
- export declare const dispatchTaskEvent: (props: DispatchTaskEventPayload) => void;
23
- export {};
@@ -1,5 +0,0 @@
1
- export { Avatar } from './Avatar/Avatar';
2
- export { IconLink } from './IconLink/IconLink';
3
- export { Menu } from './Menu/Menu';
4
- export { Tasks } from './Tasks';
5
- export { ProfileMenu } from './ProfileMenu/ProfileMenu';
@@ -1,2 +0,0 @@
1
- declare const _default: import('vite').UserConfig;
2
- export default _default;