box-ui-elements 23.4.0-beta.17 → 23.4.0-beta.19

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 (60) hide show
  1. package/dist/explorer.css +1 -1
  2. package/dist/explorer.js +1 -1
  3. package/dist/preview.css +1 -1
  4. package/dist/preview.js +1 -1
  5. package/dist/sidebar.css +1 -1
  6. package/dist/sidebar.js +1 -1
  7. package/es/elements/common/back-button/BackButton.js.map +1 -0
  8. package/es/elements/common/back-button/index.js +3 -0
  9. package/es/elements/common/{nav-button → back-button}/index.js.flow +1 -1
  10. package/es/elements/common/back-button/index.js.map +1 -0
  11. package/{src/elements/common/types/SidebarNavigation.flow.js → es/elements/common/types/SidebarNavigation.js.flow} +9 -23
  12. package/es/elements/content-sidebar/SidebarNavButton.js +29 -22
  13. package/es/elements/content-sidebar/SidebarNavButton.js.flow +28 -21
  14. package/es/elements/content-sidebar/SidebarNavButton.js.map +1 -1
  15. package/es/elements/content-sidebar/SidebarNavButton.scss +13 -0
  16. package/es/elements/content-sidebar/versions/StaticVersionSidebar.js +1 -1
  17. package/es/elements/content-sidebar/versions/StaticVersionSidebar.js.flow +1 -1
  18. package/es/elements/content-sidebar/versions/StaticVersionSidebar.js.map +1 -1
  19. package/es/elements/content-sidebar/versions/VersionsGroup.js.flow +3 -0
  20. package/es/elements/content-sidebar/versions/VersionsGroup.js.map +1 -1
  21. package/es/elements/content-sidebar/versions/VersionsList.js +16 -8
  22. package/es/elements/content-sidebar/versions/VersionsList.js.flow +35 -17
  23. package/es/elements/content-sidebar/versions/VersionsList.js.map +1 -1
  24. package/es/elements/content-sidebar/versions/VersionsMenu.js.flow +3 -0
  25. package/es/elements/content-sidebar/versions/VersionsMenu.js.map +1 -1
  26. package/es/elements/content-sidebar/versions/VersionsSidebar.js +1 -1
  27. package/es/elements/content-sidebar/versions/VersionsSidebar.js.flow +1 -1
  28. package/es/elements/content-sidebar/versions/VersionsSidebar.js.map +1 -1
  29. package/package.json +3 -3
  30. package/src/elements/common/{nav-button → back-button}/__tests__/BackButton.test.js +1 -1
  31. package/src/elements/common/{nav-button → back-button}/index.js +1 -1
  32. package/{es/elements/common/types/SidebarNavigation.flow.js.flow → src/elements/common/types/SidebarNavigation.js.flow} +9 -23
  33. package/src/elements/content-sidebar/SidebarNavButton.js +28 -21
  34. package/src/elements/content-sidebar/SidebarNavButton.scss +13 -0
  35. package/src/elements/content-sidebar/__tests__/SidebarNavButton.test.js +208 -26
  36. package/src/elements/content-sidebar/versions/StaticVersionSidebar.js +1 -1
  37. package/src/elements/content-sidebar/versions/VersionsGroup.js +3 -0
  38. package/src/elements/content-sidebar/versions/VersionsList.js +35 -17
  39. package/src/elements/content-sidebar/versions/VersionsMenu.js +3 -0
  40. package/src/elements/content-sidebar/versions/VersionsSidebar.js +1 -1
  41. package/src/elements/content-sidebar/versions/__tests__/StaticVersionSidebar.test.js +5 -7
  42. package/src/elements/content-sidebar/versions/__tests__/VersionsList.test.js +138 -13
  43. package/src/elements/content-sidebar/versions/__tests__/VersionsMenu.test.js +75 -23
  44. package/src/elements/content-sidebar/versions/__tests__/VersionsSidebar.test.js +5 -7
  45. package/es/elements/common/nav-button/BackButton.js.map +0 -1
  46. package/es/elements/common/nav-button/NavButton.js +0 -63
  47. package/es/elements/common/nav-button/NavButton.js.flow +0 -80
  48. package/es/elements/common/nav-button/NavButton.js.map +0 -1
  49. package/es/elements/common/nav-button/index.js +0 -3
  50. package/es/elements/common/nav-button/index.js.map +0 -1
  51. package/es/elements/common/types/SidebarNavigation.flow.js +0 -14
  52. package/es/elements/common/types/SidebarNavigation.flow.js.map +0 -1
  53. package/src/elements/common/nav-button/NavButton.js +0 -80
  54. package/src/elements/common/nav-button/__tests__/NavButton.test.js +0 -265
  55. package/src/elements/content-sidebar/versions/__tests__/__snapshots__/VersionsList.test.js.snap +0 -45
  56. /package/es/elements/common/{nav-button → back-button}/BackButton.js +0 -0
  57. /package/es/elements/common/{nav-button → back-button}/BackButton.js.flow +0 -0
  58. /package/es/elements/common/{nav-button → back-button}/BackButton.scss +0 -0
  59. /package/src/elements/common/{nav-button → back-button}/BackButton.js +0 -0
  60. /package/src/elements/common/{nav-button → back-button}/BackButton.scss +0 -0
@@ -1,23 +1,148 @@
1
1
  import * as React from 'react';
2
- import { shallow } from 'enzyme/build';
2
+ import { MemoryRouter, Route } from 'react-router-dom';
3
+ import { render, screen } from '../../../../test-utils/testing-library';
3
4
  import VersionsList from '../VersionsList';
4
5
 
6
+ jest.mock('../VersionsItem', () => {
7
+ const MockVersionsItem = jest.fn(({ isCurrent, isSelected, version, fileId, versionCount, versionLimit }) => (
8
+ <div data-testid={`versions-item-${version.id}`}>
9
+ <span>Version {version.id}</span>
10
+ {isCurrent && <span>Current</span>}
11
+ {isSelected && <span>Selected</span>}
12
+ {fileId && <span>FileID: {fileId}</span>}
13
+ {versionCount && <span>VersionCount: {versionCount}</span>}
14
+ {versionLimit && <span>VersionLimit: {versionLimit}</span>}
15
+ </div>
16
+ ));
17
+ return MockVersionsItem;
18
+ });
19
+
5
20
  describe('elements/content-sidebar/versions/VersionsList', () => {
6
- const getWrapper = (props = {}) => shallow(<VersionsList {...props} />);
21
+ beforeEach(() => {
22
+ jest.clearAllMocks();
23
+ });
24
+
25
+ const renderComponent = (props = {}, routePath = '/activity/versions/12345') => {
26
+ if (props.routerDisabled) {
27
+ return render(<VersionsList {...props} />);
28
+ }
29
+
30
+ return render(
31
+ <MemoryRouter initialEntries={[routePath]}>
32
+ <Route path="/:sidebar(activity|details)/versions/:versionId?">
33
+ <VersionsList {...props} />
34
+ </Route>
35
+ </MemoryRouter>,
36
+ );
37
+ };
7
38
 
8
39
  describe('render', () => {
9
- test.each`
10
- versions
11
- ${[]}
12
- ${[{ id: '12345' }]}
13
- ${[{ id: '12345' }, { id: '45678' }]}
14
- `('should match its snapshot', ({ versions }) => {
15
- const match = {
16
- params: { versionId: '12345' },
17
- path: '/versions/:versionId',
40
+ test('should render empty list when no versions provided', () => {
41
+ renderComponent({ versions: [] });
42
+ const list = screen.getByRole('list');
43
+ const listItems = screen.queryAllByRole('listitem');
44
+
45
+ expect(list).toBeInTheDocument();
46
+ expect(listItems).toHaveLength(0);
47
+ });
48
+
49
+ test('should render single version item', () => {
50
+ const versions = [{ id: '12345' }];
51
+ renderComponent({ versions });
52
+ const list = screen.getByRole('list');
53
+ const listItems = screen.getAllByRole('listitem');
54
+
55
+ expect(list).toBeInTheDocument();
56
+ expect(listItems).toHaveLength(1);
57
+ expect(screen.getByText('Version 12345')).toBeInTheDocument();
58
+ });
59
+
60
+ test('should render multiple version items', () => {
61
+ const versions = [{ id: '12345' }, { id: '45678' }];
62
+ renderComponent({ versions });
63
+ const list = screen.getByRole('list');
64
+ const listItems = screen.getAllByRole('listitem');
65
+
66
+ expect(list).toBeInTheDocument();
67
+ expect(listItems).toHaveLength(2);
68
+ expect(screen.getByText('Version 12345')).toBeInTheDocument();
69
+ expect(screen.getByText('Version 45678')).toBeInTheDocument();
70
+ });
71
+
72
+ test('should pass correct isCurrent prop based on currentId', () => {
73
+ const versions = [{ id: '12345' }, { id: '67890' }];
74
+ const currentId = '12345';
75
+ renderComponent({ versions, currentId, routerDisabled: true });
76
+
77
+ // Version 12345 should be marked as current
78
+ const version12345Container = screen.getByTestId('versions-item-12345');
79
+ expect(version12345Container).toBeInTheDocument();
80
+ expect(screen.getByText('Current')).toBeInTheDocument();
81
+
82
+ // Only one "Current" text should exist
83
+ expect(screen.getAllByText('Current')).toHaveLength(1);
84
+ });
85
+
86
+ test('should use router selection when routerDisabled is false', () => {
87
+ const versions = [{ id: '12345' }, { id: '67890' }];
88
+ renderComponent({ versions, routerDisabled: false }, '/activity/versions/12345');
89
+
90
+ // Version 12345 should be marked as selected based on route
91
+ const version12345Container = screen.getByTestId('versions-item-12345');
92
+ expect(version12345Container).toBeInTheDocument();
93
+ expect(version12345Container).toHaveTextContent('Selected');
94
+ expect(screen.getAllByText('Selected')).toHaveLength(1);
95
+ });
96
+
97
+ test('should use internalSidebarNavigation selection when routerDisabled is true', () => {
98
+ const versions = [{ id: '12345' }, { id: '67890' }];
99
+ const internalSidebarNavigation = { versionId: '67890', open: true };
100
+
101
+ renderComponent({
102
+ versions,
103
+ routerDisabled: true,
104
+ internalSidebarNavigation,
105
+ });
106
+
107
+ // Version 67890 should be marked as selected based on internal navigation
108
+ const version67890Container = screen.getByTestId('versions-item-67890');
109
+ expect(version67890Container).toBeInTheDocument();
110
+ expect(version67890Container).toHaveTextContent('Selected');
111
+ expect(screen.getAllByText('Selected')).toHaveLength(1);
112
+ });
113
+
114
+ test('should handle no selection when internalSidebarNavigation is not provided', () => {
115
+ const versions = [{ id: '12345' }, { id: '67890' }];
116
+
117
+ renderComponent({ versions, routerDisabled: true });
118
+
119
+ // No version should be selected
120
+ expect(screen.queryByText('Selected')).not.toBeInTheDocument();
121
+ });
122
+
123
+ test('should render items with correct version IDs', () => {
124
+ const versions = [{ id: 'version-abc' }, { id: 'version-xyz' }];
125
+
126
+ renderComponent({ versions, routerDisabled: true });
127
+
128
+ expect(screen.getByText('Version version-abc')).toBeInTheDocument();
129
+ expect(screen.getByText('Version version-xyz')).toBeInTheDocument();
130
+ });
131
+
132
+ test('should pass down other props to VersionsItem', () => {
133
+ const versions = [{ id: '12345' }];
134
+ const props = {
135
+ versions,
136
+ fileId: 'f_123',
137
+ versionCount: 10,
138
+ versionLimit: 100,
139
+ routerDisabled: true,
18
140
  };
19
- const wrapper = getWrapper({ match, versions });
20
- expect(wrapper).toMatchSnapshot();
141
+ renderComponent(props);
142
+
143
+ expect(screen.getByText('FileID: f_123')).toBeInTheDocument();
144
+ expect(screen.getByText('VersionCount: 10')).toBeInTheDocument();
145
+ expect(screen.getByText('VersionLimit: 100')).toBeInTheDocument();
21
146
  });
22
147
  });
23
148
  });
@@ -1,10 +1,35 @@
1
1
  import * as React from 'react';
2
- import { IntlProvider } from 'react-intl';
3
- import messages from '../messages';
4
- import VersionsGroup from '../VersionsGroup';
2
+ import { render, screen } from '../../../../test-utils/testing-library';
5
3
  import VersionsMenu from '../VersionsMenu';
6
4
 
7
- jest.unmock('react-intl');
5
+ jest.mock('../VersionsGroup', () => {
6
+ const MockVersionsGroup = jest.fn(
7
+ ({
8
+ heading,
9
+ versions,
10
+ fileId,
11
+ versionCount,
12
+ versionLimit,
13
+ currentId,
14
+ routerDisabled,
15
+ internalSidebarNavigation,
16
+ }) => (
17
+ <div>
18
+ <h1>{heading}</h1>
19
+ <span>{versions.length} versions</span>
20
+ {fileId && <span data-testid="fileId">{fileId}</span>}
21
+ {versionCount !== undefined && <span data-testid="versionCount">{versionCount}</span>}
22
+ {versionLimit !== undefined && <span data-testid="versionLimit">{versionLimit}</span>}
23
+ {currentId && <span data-testid="currentId">{currentId}</span>}
24
+ {routerDisabled !== undefined && <span data-testid="routerDisabled">{String(routerDisabled)}</span>}
25
+ {internalSidebarNavigation && (
26
+ <span data-testid="internalSidebarNavigation">{JSON.stringify(internalSidebarNavigation)}</span>
27
+ )}
28
+ </div>
29
+ ),
30
+ );
31
+ return MockVersionsGroup;
32
+ });
8
33
 
9
34
  describe('elements/content-sidebar/versions/VersionsMenu', () => {
10
35
  const defaultDate = '2019-06-20T20:00:00.000Z';
@@ -17,15 +42,11 @@ describe('elements/content-sidebar/versions/VersionsMenu', () => {
17
42
  modified_by: { name: 'Test User', id: '098765' },
18
43
  };
19
44
  const getVersion = (overrides = {}) => ({ ...defaultVersion, ...overrides });
20
- const getWrapper = (props = {}) =>
21
- shallow(<VersionsMenu {...props} />, {
22
- wrappingComponent: wrapperProps => <IntlProvider locale="en" messages={messages} {...wrapperProps} />,
23
- })
24
- .shallow() // <Memo .../>
25
- .dive(); // <ul .../>
45
+ const renderComponent = (props = {}) => render(<VersionsMenu {...props} />);
26
46
  const GlobalDate = Date;
27
47
 
28
48
  beforeEach(() => {
49
+ jest.clearAllMocks();
29
50
  global.Date = jest.fn(date => new GlobalDate(date || defaultDate));
30
51
  global.Date.now = () => defaultDateMs;
31
52
  });
@@ -48,20 +69,51 @@ describe('elements/content-sidebar/versions/VersionsMenu', () => {
48
69
  getVersion({ created_at: '2019-02-01T20:00:00.000Z', id: '2' }),
49
70
  getVersion({ created_at: '2018-05-01T20:00:00.000Z', id: '1' }),
50
71
  ];
51
- const wrapper = getWrapper({ versions });
52
- const groups = wrapper.find(VersionsGroup);
72
+ renderComponent({ versions });
73
+ const headings = [
74
+ 'Today',
75
+ 'Yesterday',
76
+ 'Tuesday',
77
+ 'Monday',
78
+ 'Last Week',
79
+ 'This Month',
80
+ 'May',
81
+ 'February',
82
+ '2018',
83
+ ];
84
+ const versionCounts = [2, 1, 1, 1, 1, 1, 1, 1, 1];
85
+
86
+ expect(screen.getAllByRole('heading', { level: 1 })).toHaveLength(9);
87
+
88
+ headings.forEach((heading, index) => {
89
+ const headingElement = screen.getByText(heading);
90
+ const groupContainer = headingElement.parentElement;
91
+
92
+ expect(groupContainer).toHaveTextContent(`${versionCounts[index]} versions`);
93
+ });
94
+ });
95
+
96
+ test('should pass down other props to VersionsGroup', () => {
97
+ const versions = [getVersion({ id: '10' })];
98
+ const props = {
99
+ versions,
100
+ fileId: 'f_123',
101
+ versionCount: 10,
102
+ versionLimit: 100,
103
+ currentId: '10',
104
+ routerDisabled: false,
105
+ internalSidebarNavigation: { open: false, sidebar: 'activity' },
106
+ };
107
+ renderComponent(props);
53
108
 
54
- expect(groups.length).toBe(9);
55
- expect(groups.at(0).prop('versions').length).toBe(2); // Multiple versions collapse into a group
56
- expect(groups.at(0).prop('heading')).toBe('Today');
57
- expect(groups.at(1).prop('heading')).toBe('Yesterday');
58
- expect(groups.at(2).prop('heading')).toBe('Tuesday');
59
- expect(groups.at(3).prop('heading')).toBe('Monday');
60
- expect(groups.at(4).prop('heading')).toBe('Last Week');
61
- expect(groups.at(5).prop('heading')).toBe('This Month');
62
- expect(groups.at(6).prop('heading')).toBe('May');
63
- expect(groups.at(7).prop('heading')).toBe('February');
64
- expect(groups.at(8).prop('heading')).toBe('2018');
109
+ expect(screen.getByTestId('fileId')).toHaveTextContent('f_123');
110
+ expect(screen.getByTestId('versionCount')).toHaveTextContent('10');
111
+ expect(screen.getByTestId('versionLimit')).toHaveTextContent('100');
112
+ expect(screen.getByTestId('currentId')).toHaveTextContent('10');
113
+ expect(screen.getByTestId('routerDisabled')).toHaveTextContent('false');
114
+ expect(screen.getByTestId('internalSidebarNavigation')).toHaveTextContent(
115
+ JSON.stringify(props.internalSidebarNavigation),
116
+ );
65
117
  });
66
118
  });
67
119
  });
@@ -4,13 +4,11 @@ import { render, screen, userEvent } from '../../../../test-utils/testing-librar
4
4
  import messages from '../messages';
5
5
  import VersionsSidebar from '../VersionsSidebar';
6
6
 
7
- jest.mock('../../../common/nav-button', () => ({
8
- BackButton: ({ onClick, 'data-resin-target': dataResinTarget }) => (
9
- <button type="button" onClick={onClick} data-resin-target={dataResinTarget} data-testid="back-button">
10
- Back
11
- </button>
12
- ),
13
- }));
7
+ jest.mock('../../../common/back-button', () => ({ onClick, 'data-resin-target': dataResinTarget }) => (
8
+ <button type="button" onClick={onClick} data-resin-target={dataResinTarget} data-testid="back-button">
9
+ Back
10
+ </button>
11
+ ));
14
12
 
15
13
  jest.mock('../VersionsMenu', () => ({ versions, fileId, versionCount, versionLimit }) => (
16
14
  <div data-testid="versions-menu">
@@ -1 +0,0 @@
1
- {"version":3,"file":"BackButton.js","names":["React","classNames","FormattedMessage","IconNavigateLeft","messages","PlainButton","BackButton","_ref","className","onClick","rest","_objectWithoutProperties","_excluded","createElement","_extends","type","height","width","back"],"sources":["../../../../src/elements/common/nav-button/BackButton.js"],"sourcesContent":["/**\n * @flow\n * @file Back Button component\n * @author Box\n */\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { FormattedMessage } from 'react-intl';\nimport IconNavigateLeft from '../../../icons/general/IconNavigateLeft';\nimport messages from '../messages';\nimport PlainButton from '../../../components/plain-button';\nimport './BackButton.scss';\n\ntype Props = {\n className?: string,\n onClick: () => void,\n};\n\nconst BackButton = ({ className, onClick, ...rest }: Props) => (\n <PlainButton className={classNames('bdl-BackButton', className)} onClick={onClick} type=\"button\" {...rest}>\n <IconNavigateLeft height={24} width={24} />\n <span className=\"accessibility-hidden\">\n <FormattedMessage {...messages.back} />\n </span>\n </PlainButton>\n);\n\nexport default BackButton;\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,OAAOC,gBAAgB,MAAM,yCAAyC;AACtE,OAAOC,QAAQ,MAAM,aAAa;AAClC,OAAOC,WAAW,MAAM,kCAAkC;AAC1D,OAAO,mBAAmB;AAO1B,MAAMC,UAAU,GAAGC,IAAA;EAAA,IAAC;MAAEC,SAAS;MAAEC;IAAwB,CAAC,GAAAF,IAAA;IAAbG,IAAI,GAAAC,wBAAA,CAAAJ,IAAA,EAAAK,SAAA;EAAA,oBAC7CZ,KAAA,CAAAa,aAAA,CAACR,WAAW,EAAAS,QAAA;IAACN,SAAS,EAAEP,UAAU,CAAC,gBAAgB,EAAEO,SAAS,CAAE;IAACC,OAAO,EAAEA,OAAQ;IAACM,IAAI,EAAC;EAAQ,GAAKL,IAAI,gBACrGV,KAAA,CAAAa,aAAA,CAACV,gBAAgB;IAACa,MAAM,EAAE,EAAG;IAACC,KAAK,EAAE;EAAG,CAAE,CAAC,eAC3CjB,KAAA,CAAAa,aAAA;IAAML,SAAS,EAAC;EAAsB,gBAClCR,KAAA,CAAAa,aAAA,CAACX,gBAAgB,EAAKE,QAAQ,CAACc,IAAO,CACpC,CACG,CAAC;AAAA,CACjB;AAED,eAAeZ,UAAU","ignoreList":[]}
@@ -1,63 +0,0 @@
1
- const _excluded = ["activeClassName", "children", "className", "component", "exact", "isActive", "isDisabled", "onClick", "replace", "strict", "to"];
2
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
4
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
5
- /**
6
- *
7
- * @file Nav Button component intended to mimic React Router's NavLink component for non-anchor elements
8
- * @author Box
9
- */
10
-
11
- import * as React from 'react';
12
- import classNames from 'classnames';
13
- import { Route } from 'react-router-dom';
14
- import PlainButton from '../../../components/plain-button';
15
- import { isLeftClick } from '../../../utils/dom';
16
- const NavButton = /*#__PURE__*/React.forwardRef((props, ref) => {
17
- const {
18
- activeClassName = 'bdl-is-active',
19
- children,
20
- className = 'bdl-NavButton',
21
- component: Component = PlainButton,
22
- exact,
23
- isActive,
24
- isDisabled,
25
- onClick,
26
- replace,
27
- strict,
28
- to
29
- } = props,
30
- rest = _objectWithoutProperties(props, _excluded);
31
- const path = typeof to === 'object' ? to.pathname : to;
32
- const disabledClassName = 'bdl-is-disabled';
33
- return /*#__PURE__*/React.createElement(Route, {
34
- exact: exact,
35
- path: path,
36
- strict: strict
37
- }, ({
38
- history,
39
- location,
40
- match
41
- }) => {
42
- const isActiveValue = !!(isActive ? isActive(match, location) : match);
43
- return /*#__PURE__*/React.createElement(Component, _extends({
44
- className: classNames(className, {
45
- [activeClassName]: isActiveValue,
46
- [disabledClassName]: isDisabled
47
- }),
48
- isDisabled: isDisabled,
49
- onClick: event => {
50
- if (onClick) {
51
- onClick(event);
52
- }
53
- if (!event.defaultPrevented && isLeftClick(event)) {
54
- const method = replace ? history.replace : history.push;
55
- method(to);
56
- }
57
- },
58
- ref: ref
59
- }, rest), children);
60
- });
61
- });
62
- export default NavButton;
63
- //# sourceMappingURL=NavButton.js.map
@@ -1,80 +0,0 @@
1
- /**
2
- * @flow
3
- * @file Nav Button component intended to mimic React Router's NavLink component for non-anchor elements
4
- * @author Box
5
- */
6
-
7
- import * as React from 'react';
8
- import classNames from 'classnames';
9
- import { Route } from 'react-router-dom';
10
- import type { Match, Location } from 'react-router-dom';
11
- import PlainButton from '../../../components/plain-button';
12
- import { isLeftClick } from '../../../utils/dom';
13
-
14
- type Props = {
15
- activeClassName?: string,
16
- children: React.Node,
17
- className?: string,
18
- component?: React.ComponentType<any>,
19
- exact?: boolean,
20
- isActive?: (match: Match, location: Location) => ?boolean,
21
- isDisabled?: boolean,
22
- onClick?: (event: SyntheticEvent<>) => void,
23
- replace?: boolean,
24
- strict?: boolean,
25
- to: string | Location,
26
- };
27
-
28
- const NavButton = React.forwardRef<Props, React.Ref<any>>((props: Props, ref: React.Ref<any>) => {
29
- const {
30
- activeClassName = 'bdl-is-active',
31
- children,
32
- className = 'bdl-NavButton',
33
- component: Component = PlainButton,
34
- exact,
35
- isActive,
36
- isDisabled,
37
- onClick,
38
- replace,
39
- strict,
40
- to,
41
- ...rest
42
- } = props;
43
- const path = typeof to === 'object' ? to.pathname : to;
44
-
45
- const disabledClassName = 'bdl-is-disabled';
46
-
47
- return (
48
- <Route exact={exact} path={path} strict={strict}>
49
- {({ history, location, match }) => {
50
- const isActiveValue = !!(isActive ? isActive(match, location) : match);
51
-
52
- return (
53
- <Component
54
- className={classNames(className, {
55
- [activeClassName]: isActiveValue,
56
- [disabledClassName]: isDisabled,
57
- })}
58
- isDisabled={isDisabled}
59
- onClick={event => {
60
- if (onClick) {
61
- onClick(event);
62
- }
63
-
64
- if (!event.defaultPrevented && isLeftClick(event)) {
65
- const method = replace ? history.replace : history.push;
66
- method(to);
67
- }
68
- }}
69
- ref={ref}
70
- {...rest}
71
- >
72
- {children}
73
- </Component>
74
- );
75
- }}
76
- </Route>
77
- );
78
- });
79
-
80
- export default NavButton;
@@ -1 +0,0 @@
1
- {"version":3,"file":"NavButton.js","names":["React","classNames","Route","PlainButton","isLeftClick","NavButton","forwardRef","props","ref","activeClassName","children","className","component","Component","exact","isActive","isDisabled","onClick","replace","strict","to","rest","_objectWithoutProperties","_excluded","path","pathname","disabledClassName","createElement","history","location","match","isActiveValue","_extends","event","defaultPrevented","method","push"],"sources":["../../../../src/elements/common/nav-button/NavButton.js"],"sourcesContent":["/**\n * @flow\n * @file Nav Button component intended to mimic React Router's NavLink component for non-anchor elements\n * @author Box\n */\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { Route } from 'react-router-dom';\nimport type { Match, Location } from 'react-router-dom';\nimport PlainButton from '../../../components/plain-button';\nimport { isLeftClick } from '../../../utils/dom';\n\ntype Props = {\n activeClassName?: string,\n children: React.Node,\n className?: string,\n component?: React.ComponentType<any>,\n exact?: boolean,\n isActive?: (match: Match, location: Location) => ?boolean,\n isDisabled?: boolean,\n onClick?: (event: SyntheticEvent<>) => void,\n replace?: boolean,\n strict?: boolean,\n to: string | Location,\n};\n\nconst NavButton = React.forwardRef<Props, React.Ref<any>>((props: Props, ref: React.Ref<any>) => {\n const {\n activeClassName = 'bdl-is-active',\n children,\n className = 'bdl-NavButton',\n component: Component = PlainButton,\n exact,\n isActive,\n isDisabled,\n onClick,\n replace,\n strict,\n to,\n ...rest\n } = props;\n const path = typeof to === 'object' ? to.pathname : to;\n\n const disabledClassName = 'bdl-is-disabled';\n\n return (\n <Route exact={exact} path={path} strict={strict}>\n {({ history, location, match }) => {\n const isActiveValue = !!(isActive ? isActive(match, location) : match);\n\n return (\n <Component\n className={classNames(className, {\n [activeClassName]: isActiveValue,\n [disabledClassName]: isDisabled,\n })}\n isDisabled={isDisabled}\n onClick={event => {\n if (onClick) {\n onClick(event);\n }\n\n if (!event.defaultPrevented && isLeftClick(event)) {\n const method = replace ? history.replace : history.push;\n method(to);\n }\n }}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n }}\n </Route>\n );\n});\n\nexport default NavButton;\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,KAAK,QAAQ,kBAAkB;AAExC,OAAOC,WAAW,MAAM,kCAAkC;AAC1D,SAASC,WAAW,QAAQ,oBAAoB;AAgBhD,MAAMC,SAAS,gBAAGL,KAAK,CAACM,UAAU,CAAwB,CAACC,KAAY,EAAEC,GAAmB,KAAK;EAC7F,MAAM;MACFC,eAAe,GAAG,eAAe;MACjCC,QAAQ;MACRC,SAAS,GAAG,eAAe;MAC3BC,SAAS,EAAEC,SAAS,GAAGV,WAAW;MAClCW,KAAK;MACLC,QAAQ;MACRC,UAAU;MACVC,OAAO;MACPC,OAAO;MACPC,MAAM;MACNC;IAEJ,CAAC,GAAGb,KAAK;IADFc,IAAI,GAAAC,wBAAA,CACPf,KAAK,EAAAgB,SAAA;EACT,MAAMC,IAAI,GAAG,OAAOJ,EAAE,KAAK,QAAQ,GAAGA,EAAE,CAACK,QAAQ,GAAGL,EAAE;EAEtD,MAAMM,iBAAiB,GAAG,iBAAiB;EAE3C,oBACI1B,KAAA,CAAA2B,aAAA,CAACzB,KAAK;IAACY,KAAK,EAAEA,KAAM;IAACU,IAAI,EAAEA,IAAK;IAACL,MAAM,EAAEA;EAAO,GAC3C,CAAC;IAAES,OAAO;IAAEC,QAAQ;IAAEC;EAAM,CAAC,KAAK;IAC/B,MAAMC,aAAa,GAAG,CAAC,EAAEhB,QAAQ,GAAGA,QAAQ,CAACe,KAAK,EAAED,QAAQ,CAAC,GAAGC,KAAK,CAAC;IAEtE,oBACI9B,KAAA,CAAA2B,aAAA,CAACd,SAAS,EAAAmB,QAAA;MACNrB,SAAS,EAAEV,UAAU,CAACU,SAAS,EAAE;QAC7B,CAACF,eAAe,GAAGsB,aAAa;QAChC,CAACL,iBAAiB,GAAGV;MACzB,CAAC,CAAE;MACHA,UAAU,EAAEA,UAAW;MACvBC,OAAO,EAAEgB,KAAK,IAAI;QACd,IAAIhB,OAAO,EAAE;UACTA,OAAO,CAACgB,KAAK,CAAC;QAClB;QAEA,IAAI,CAACA,KAAK,CAACC,gBAAgB,IAAI9B,WAAW,CAAC6B,KAAK,CAAC,EAAE;UAC/C,MAAME,MAAM,GAAGjB,OAAO,GAAGU,OAAO,CAACV,OAAO,GAAGU,OAAO,CAACQ,IAAI;UACvDD,MAAM,CAACf,EAAE,CAAC;QACd;MACJ,CAAE;MACFZ,GAAG,EAAEA;IAAI,GACLa,IAAI,GAEPX,QACM,CAAC;EAEpB,CACG,CAAC;AAEhB,CAAC,CAAC;AAEF,eAAeL,SAAS","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- export { default as BackButton } from './BackButton';
2
- export { default } from './NavButton';
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["default","BackButton"],"sources":["../../../../src/elements/common/nav-button/index.js"],"sourcesContent":["export { default as BackButton } from './BackButton';\nexport { default } from './NavButton';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,UAAU,QAAQ,cAAc;AACpD,SAASD,OAAO,QAAQ,aAAa","ignoreList":[]}
@@ -1,14 +0,0 @@
1
- export const ViewType = Object.freeze({
2
- BOXAI: 'boxai',
3
- SKILLS: 'skills',
4
- ACTIVITY: 'activity',
5
- DETAILS: 'details',
6
- METADATA: 'metadata',
7
- DOCGEN: 'docgen'
8
- });
9
- export const FeedEntryType = Object.freeze({
10
- ANNOTATIONS: 'annotations',
11
- COMMENTS: 'comments',
12
- TASKS: 'tasks'
13
- });
14
- //# sourceMappingURL=SidebarNavigation.flow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SidebarNavigation.flow.js","names":["ViewType","Object","freeze","BOXAI","SKILLS","ACTIVITY","DETAILS","METADATA","DOCGEN","FeedEntryType","ANNOTATIONS","COMMENTS","TASKS"],"sources":["../../../../src/elements/common/types/SidebarNavigation.flow.js"],"sourcesContent":["/* @flow */\n\nexport const ViewType = Object.freeze({\n BOXAI: 'boxai',\n SKILLS: 'skills',\n ACTIVITY: 'activity',\n DETAILS: 'details',\n METADATA: 'metadata',\n DOCGEN: 'docgen',\n});\n\nexport const FeedEntryType = Object.freeze({\n ANNOTATIONS: 'annotations',\n COMMENTS: 'comments',\n TASKS: 'tasks',\n});\n\nexport type ViewTypeValues = $Values<typeof ViewType>;\nexport type FeedEntryTypeValues = $Values<typeof FeedEntryType>;\n\ntype VersionSidebarView = {\n sidebar: 'activity' | 'details',\n versionId: string,\n};\n\nexport type ActivityAnnotationsSidebarView = {\n sidebar: 'activity',\n activeFeedEntryType: 'annotations',\n fileVersionId: string,\n activeFeedEntryId: string,\n};\ntype ActivityCommentsSidebarView = {\n sidebar: 'activity',\n activeFeedEntryType: 'comments' | 'tasks',\n activeFeedEntryId: string,\n};\n\nexport type SidebarNavigation =\n | {|\n sidebar: ViewTypeValues,\n |}\n | VersionSidebarView\n | ActivityCommentsSidebarView\n | ActivityAnnotationsSidebarView;\n\nexport type InternalSidebarNavigation = SidebarNavigation & {\n open: boolean,\n};\n\nexport type SidebarNavigationHandler = (sidebar: SidebarNavigation, replace?: boolean) => void;\n\nexport type InternalSidebarNavigationHandler = (sidebar: InternalSidebarNavigation, replace?: boolean) => void;\n"],"mappings":"AAEA,OAAO,MAAMA,QAAQ,GAAGC,MAAM,CAACC,MAAM,CAAC;EAClCC,KAAK,EAAE,OAAO;EACdC,MAAM,EAAE,QAAQ;EAChBC,QAAQ,EAAE,UAAU;EACpBC,OAAO,EAAE,SAAS;EAClBC,QAAQ,EAAE,UAAU;EACpBC,MAAM,EAAE;AACZ,CAAC,CAAC;AAEF,OAAO,MAAMC,aAAa,GAAGR,MAAM,CAACC,MAAM,CAAC;EACvCQ,WAAW,EAAE,aAAa;EAC1BC,QAAQ,EAAE,UAAU;EACpBC,KAAK,EAAE;AACX,CAAC,CAAC","ignoreList":[]}
@@ -1,80 +0,0 @@
1
- /**
2
- * @flow
3
- * @file Nav Button component intended to mimic React Router's NavLink component for non-anchor elements
4
- * @author Box
5
- */
6
-
7
- import * as React from 'react';
8
- import classNames from 'classnames';
9
- import { Route } from 'react-router-dom';
10
- import type { Match, Location } from 'react-router-dom';
11
- import PlainButton from '../../../components/plain-button';
12
- import { isLeftClick } from '../../../utils/dom';
13
-
14
- type Props = {
15
- activeClassName?: string,
16
- children: React.Node,
17
- className?: string,
18
- component?: React.ComponentType<any>,
19
- exact?: boolean,
20
- isActive?: (match: Match, location: Location) => ?boolean,
21
- isDisabled?: boolean,
22
- onClick?: (event: SyntheticEvent<>) => void,
23
- replace?: boolean,
24
- strict?: boolean,
25
- to: string | Location,
26
- };
27
-
28
- const NavButton = React.forwardRef<Props, React.Ref<any>>((props: Props, ref: React.Ref<any>) => {
29
- const {
30
- activeClassName = 'bdl-is-active',
31
- children,
32
- className = 'bdl-NavButton',
33
- component: Component = PlainButton,
34
- exact,
35
- isActive,
36
- isDisabled,
37
- onClick,
38
- replace,
39
- strict,
40
- to,
41
- ...rest
42
- } = props;
43
- const path = typeof to === 'object' ? to.pathname : to;
44
-
45
- const disabledClassName = 'bdl-is-disabled';
46
-
47
- return (
48
- <Route exact={exact} path={path} strict={strict}>
49
- {({ history, location, match }) => {
50
- const isActiveValue = !!(isActive ? isActive(match, location) : match);
51
-
52
- return (
53
- <Component
54
- className={classNames(className, {
55
- [activeClassName]: isActiveValue,
56
- [disabledClassName]: isDisabled,
57
- })}
58
- isDisabled={isDisabled}
59
- onClick={event => {
60
- if (onClick) {
61
- onClick(event);
62
- }
63
-
64
- if (!event.defaultPrevented && isLeftClick(event)) {
65
- const method = replace ? history.replace : history.push;
66
- method(to);
67
- }
68
- }}
69
- ref={ref}
70
- {...rest}
71
- >
72
- {children}
73
- </Component>
74
- );
75
- }}
76
- </Route>
77
- );
78
- });
79
-
80
- export default NavButton;