@servicetitan/navigation 8.2.1 → 9.0.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.
- package/dist/components/counter-tag.d.ts +2 -4
- package/dist/components/counter-tag.d.ts.map +1 -1
- package/dist/components/counter-tag.js +3 -4
- package/dist/components/counter-tag.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-content.d.ts +2 -2
- package/dist/components/header-navigation/header-navigation-content.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-content.js +4 -4
- package/dist/components/header-navigation/header-navigation-content.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-extra.stories.js +3 -3
- package/dist/components/header-navigation/header-navigation-extra.stories.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-links.js +4 -4
- package/dist/components/header-navigation/header-navigation-links.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-stacked.stories.js +1 -1
- package/dist/components/header-navigation/header-navigation-stacked.stories.js.map +1 -1
- package/dist/components/header-navigation/header-navigation.module.less +2 -1
- package/dist/components/header-navigation/header-navigation.stories.js +1 -1
- package/dist/components/header-navigation/header-navigation.stories.js.map +1 -1
- package/dist/components/layout.stories.js +2 -2
- package/dist/components/layout.stories.js.map +1 -1
- package/dist/components/left-navigation/header-navigation-tiny-links.d.ts +1 -1
- package/dist/components/left-navigation/header-navigation-tiny-links.d.ts.map +1 -1
- package/dist/components/left-navigation/header-navigation-tiny-links.js +6 -6
- package/dist/components/left-navigation/header-navigation-tiny-links.js.map +1 -1
- package/dist/components/left-navigation/header-navigation-tiny.stories.js +2 -2
- package/dist/components/left-navigation/header-navigation-tiny.stories.js.map +1 -1
- package/dist/components/left-navigation/side-navigation.d.ts +8 -4
- package/dist/components/left-navigation/side-navigation.d.ts.map +1 -1
- package/dist/components/left-navigation/side-navigation.js +30 -20
- package/dist/components/left-navigation/side-navigation.js.map +1 -1
- package/dist/components/left-navigation/side-navigation.module.less +20 -12
- package/dist/components/left-navigation/side-navigation.stories.d.ts.map +1 -1
- package/dist/components/left-navigation/side-navigation.stories.js +7 -7
- package/dist/components/left-navigation/side-navigation.stories.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.d.ts +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.js +3 -3
- package/dist/components/profile-dropdown/profile-dropdown.js.map +1 -1
- package/dist/test/data.d.ts +1 -0
- package/dist/test/data.d.ts.map +1 -1
- package/dist/test/data.js +10 -8
- package/dist/test/data.js.map +1 -1
- package/dist/utils/navigation.d.ts +9 -5
- package/dist/utils/navigation.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/components/counter-tag.tsx +12 -9
- package/src/components/header-navigation/header-navigation-content.tsx +7 -7
- package/src/components/header-navigation/header-navigation-extra.stories.tsx +3 -3
- package/src/components/header-navigation/header-navigation-links.tsx +4 -4
- package/src/components/header-navigation/header-navigation-stacked.stories.tsx +2 -2
- package/src/components/header-navigation/header-navigation.module.less +2 -1
- package/src/components/header-navigation/header-navigation.stories.tsx +2 -2
- package/src/components/layout.stories.tsx +2 -2
- package/src/components/left-navigation/header-navigation-tiny-links.tsx +8 -8
- package/src/components/left-navigation/header-navigation-tiny.stories.tsx +2 -2
- package/src/components/left-navigation/side-navigation.module.less +20 -12
- package/src/components/left-navigation/side-navigation.module.less.d.ts +1 -0
- package/src/components/left-navigation/side-navigation.stories.tsx +14 -8
- package/src/components/left-navigation/side-navigation.tsx +56 -43
- package/src/components/profile-dropdown/profile-dropdown.tsx +6 -9
- package/src/test/data.tsx +24 -12
- package/src/utils/navigation.ts +10 -5
package/src/test/data.tsx
CHANGED
|
@@ -33,15 +33,15 @@ import SvgTasks from '@servicetitan/anvil2/assets/icons/st/gnav_tasks_inactive.s
|
|
|
33
33
|
import { BodyText, Popover } from '@servicetitan/design-system';
|
|
34
34
|
|
|
35
35
|
import classNames from 'classnames';
|
|
36
|
-
import { forwardRef, useState } from 'react';
|
|
36
|
+
import { Fragment, forwardRef, useState } from 'react';
|
|
37
37
|
// needed only for storybook and added in root dependencies
|
|
38
38
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
39
|
-
import { MemoryRouter, useHistory, useLocation } from 'react-router-dom';
|
|
39
|
+
import { MemoryRouter, Redirect, Switch, useHistory, useLocation } from 'react-router-dom';
|
|
40
40
|
import { HeaderNavigationTrigger } from '../components/links';
|
|
41
41
|
import {
|
|
42
42
|
HeaderNavigationItemData,
|
|
43
|
-
HeaderNavigationItemLinkProps,
|
|
44
43
|
HeaderNavigationItemSubmenuGroup,
|
|
44
|
+
HeaderNavigationItemSubmenuLink,
|
|
45
45
|
NavLinkComponentProps,
|
|
46
46
|
} from '../utils/navigation';
|
|
47
47
|
import { NavigationComponentContext } from '../utils/navigation-context';
|
|
@@ -145,8 +145,8 @@ const getItem = (
|
|
|
145
145
|
|
|
146
146
|
const getSubItem = (
|
|
147
147
|
id: string,
|
|
148
|
-
data: Partial<
|
|
149
|
-
):
|
|
148
|
+
data: Partial<HeaderNavigationItemSubmenuLink>
|
|
149
|
+
): HeaderNavigationItemSubmenuLink => ({
|
|
150
150
|
id,
|
|
151
151
|
to: id,
|
|
152
152
|
title: id[0].toUpperCase() + id.substring(1),
|
|
@@ -155,7 +155,7 @@ const getSubItem = (
|
|
|
155
155
|
|
|
156
156
|
const getGroup = (
|
|
157
157
|
title: string,
|
|
158
|
-
links:
|
|
158
|
+
links: HeaderNavigationItemSubmenuLink[]
|
|
159
159
|
): HeaderNavigationItemSubmenuGroup => ({
|
|
160
160
|
title,
|
|
161
161
|
links,
|
|
@@ -176,7 +176,7 @@ export const items = {
|
|
|
176
176
|
iconName: 'local_phone',
|
|
177
177
|
icon: SvgCalls,
|
|
178
178
|
iconActive: SvgCallsActive,
|
|
179
|
-
|
|
179
|
+
tag: 12,
|
|
180
180
|
}),
|
|
181
181
|
dashboard: getItem('dashboard', {
|
|
182
182
|
iconName: 'odometer',
|
|
@@ -187,7 +187,7 @@ export const items = {
|
|
|
187
187
|
iconName: 'location_disabled',
|
|
188
188
|
icon: SvgDispatch,
|
|
189
189
|
iconActive: SvgDispatchActive,
|
|
190
|
-
|
|
190
|
+
tag: 1,
|
|
191
191
|
}),
|
|
192
192
|
fleet: getItem('fleet', {
|
|
193
193
|
iconName: 'fleet-pro',
|
|
@@ -241,6 +241,7 @@ export const items = {
|
|
|
241
241
|
iconName: 'assignment',
|
|
242
242
|
icon: SvgAccounting,
|
|
243
243
|
iconActive: SvgAccountingActive,
|
|
244
|
+
tag: true,
|
|
244
245
|
}),
|
|
245
246
|
accountingWithSubmenu: getItem('accounting', {
|
|
246
247
|
iconName: 'assignment',
|
|
@@ -250,9 +251,9 @@ export const items = {
|
|
|
250
251
|
groups: [
|
|
251
252
|
getGroup('Accounts Receivable', [
|
|
252
253
|
getSubItem('ar', { title: 'AR Management' }),
|
|
253
|
-
getSubItem('export', { title: 'Batch/Export Transactions' }),
|
|
254
|
-
getSubItem('invoices', { title: 'Invoices' }),
|
|
255
|
-
getSubItem('payments', { title: 'Customer Payments' }),
|
|
254
|
+
getSubItem('export', { title: 'Batch/Export Transactions', tag: true }),
|
|
255
|
+
getSubItem('invoices', { title: 'Invoices', tag: 3 }),
|
|
256
|
+
getSubItem('payments', { title: 'Customer Payments', tag: 2 }),
|
|
256
257
|
getSubItem('deposits', { title: 'Bank Deposits' }),
|
|
257
258
|
]),
|
|
258
259
|
getGroup('Accounts Payable', [getSubItem('bills', { title: 'Bills' })]),
|
|
@@ -306,7 +307,7 @@ export const CallsNavigationTrigger = () => {
|
|
|
306
307
|
<HeaderNavigationTrigger
|
|
307
308
|
id="dialpad"
|
|
308
309
|
iconName="phone"
|
|
309
|
-
|
|
310
|
+
tag={2}
|
|
310
311
|
icon={SvgPhone}
|
|
311
312
|
iconActive={SvgPhoneActive}
|
|
312
313
|
onClick={() => setOpen(!open)}
|
|
@@ -318,3 +319,14 @@ export const CallsNavigationTrigger = () => {
|
|
|
318
319
|
</Popover>
|
|
319
320
|
);
|
|
320
321
|
};
|
|
322
|
+
|
|
323
|
+
export const withDefaultRedirects = (Story: any) => (
|
|
324
|
+
<Fragment>
|
|
325
|
+
<Switch>
|
|
326
|
+
<Redirect from="/accounting" exact to="/accounting/export" />
|
|
327
|
+
<Redirect from="/purchasing" exact to="/purchasing/repl" />
|
|
328
|
+
<Redirect from="/followUps" exact to="/followUps/sold" />
|
|
329
|
+
</Switch>
|
|
330
|
+
<Story />
|
|
331
|
+
</Fragment>
|
|
332
|
+
);
|
package/src/utils/navigation.ts
CHANGED
|
@@ -25,8 +25,8 @@ export interface HeaderNavigationItemData extends HeaderNavigationItemLinkProps
|
|
|
25
25
|
/** icon component of item (<svg />) */
|
|
26
26
|
iconComponent?: FC;
|
|
27
27
|
|
|
28
|
-
/** item
|
|
29
|
-
|
|
28
|
+
/** item tag (optional). shown if it is set and true or greater than 0 */
|
|
29
|
+
tag?: CounterTagPropsType;
|
|
30
30
|
|
|
31
31
|
/** class name of link item */
|
|
32
32
|
className?: string;
|
|
@@ -54,12 +54,17 @@ export interface HeaderNavigationItemSubmenu {
|
|
|
54
54
|
groups: HeaderNavigationItemSubmenuGroup[];
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
export interface HeaderNavigationItemSubmenuLink extends HeaderNavigationItemLinkProps {
|
|
58
|
+
/** item tag (optional). shown if it is set and true or greater than 0 */
|
|
59
|
+
tag?: CounterTagPropsType;
|
|
60
|
+
}
|
|
61
|
+
|
|
57
62
|
export interface HeaderNavigationItemSubmenuGroup {
|
|
58
63
|
/** submenu group title */
|
|
59
64
|
title: string;
|
|
60
65
|
|
|
61
66
|
/** submenu group links */
|
|
62
|
-
links:
|
|
67
|
+
links: HeaderNavigationItemSubmenuLink[];
|
|
63
68
|
}
|
|
64
69
|
|
|
65
70
|
export interface NavLinkComponentPropsStrict {
|
|
@@ -91,8 +96,8 @@ export interface HeaderNavigationTriggerPropsStrict {
|
|
|
91
96
|
labelClassName?: string;
|
|
92
97
|
/** isActive */
|
|
93
98
|
isActive?: boolean;
|
|
94
|
-
/** counter shown for item */
|
|
95
|
-
|
|
99
|
+
/** counter tag shown for item */
|
|
100
|
+
tag?: CounterTagPropsType;
|
|
96
101
|
/** counter component class name */
|
|
97
102
|
counterClassName?: string;
|
|
98
103
|
/** icon component class name */
|