@squiz/resource-browser 1.35.1-alpha.6 → 1.38.0-alpha.2
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/lib/Hooks/useChildResources.d.ts +1 -1
- package/lib/Hooks/useChildResources.js +2 -2
- package/lib/Hooks/useResource.js +2 -2
- package/lib/PreviewPanel/PreviewPanel.d.ts +5 -13
- package/lib/PreviewPanel/PreviewPanel.js +2 -53
- package/lib/PreviewPanel/details/MatrixResource.js +2 -2
- package/lib/ResourceBreadcrumb/ResourceBreadcrumb.js +2 -5
- package/lib/ResourceList/ResourceList.js +9 -15
- package/lib/ResourcePicker/ResourcePicker.js +2 -2
- package/lib/ResourcePicker/States/Error.js +3 -4
- package/lib/ResourcePicker/States/Loading.js +2 -2
- package/lib/ResourcePicker/States/Selected.js +3 -4
- package/lib/ResourcePickerContainer/ResourcePickerContainer.js +4 -3
- package/lib/SourceDropdown/SourceDropdown.js +9 -10
- package/lib/SourceList/SourceList.js +10 -13
- package/lib/index.css +3 -51
- package/package.json +4 -3
- package/src/Hooks/useChildResources.ts +1 -1
- package/src/Hooks/useResource.ts +1 -1
- package/src/Hooks/useSources.ts +1 -1
- package/src/PreviewPanel/PreviewPanel.tsx +3 -84
- package/src/PreviewPanel/details/MatrixResource.tsx +1 -1
- package/src/ResourceBreadcrumb/ResourceBreadcrumb.tsx +1 -1
- package/src/ResourceList/ResourceList.tsx +9 -18
- package/src/ResourcePicker/ResourcePicker.tsx +1 -1
- package/src/ResourcePicker/States/Error.tsx +1 -3
- package/src/ResourcePicker/States/Loading.tsx +1 -2
- package/src/ResourcePicker/States/Selected.tsx +1 -2
- package/src/ResourcePickerContainer/ResourcePickerContainer.spec.tsx +28 -0
- package/src/ResourcePickerContainer/ResourcePickerContainer.tsx +11 -9
- package/src/SourceDropdown/SourceDropdown.spec.tsx +5 -1
- package/src/SourceDropdown/SourceDropdown.tsx +2 -3
- package/src/SourceList/SourceList.tsx +16 -20
- package/src/index.scss +1 -3
- package/tailwind.config.cjs +6 -1
- package/vite.config.js +20 -0
- package/lib/Hooks/useAsync.d.ts +0 -21
- package/lib/Hooks/useAsync.js +0 -53
- package/lib/Icons/Generics/ArrowDown.d.ts +0 -15
- package/lib/Icons/Generics/ArrowDown.js +0 -23
- package/lib/Icons/Generics/ArrowRight.d.ts +0 -15
- package/lib/Icons/Generics/ArrowRight.js +0 -23
- package/lib/Icons/Generics/Back.d.ts +0 -4
- package/lib/Icons/Generics/Back.js +0 -12
- package/lib/Icons/Generics/Close.d.ts +0 -15
- package/lib/Icons/Generics/Close.js +0 -23
- package/lib/Icons/Generics/Empty.d.ts +0 -4
- package/lib/Icons/Generics/Empty.js +0 -12
- package/lib/Icons/Generics/Error.d.ts +0 -4
- package/lib/Icons/Generics/Error.js +0 -12
- package/lib/Icons/Generics/GenericIconMap.d.ts +0 -14
- package/lib/Icons/Generics/GenericIconMap.js +0 -18
- package/lib/Icons/Generics/ResourceSelect.d.ts +0 -15
- package/lib/Icons/Generics/ResourceSelect.js +0 -28
- package/lib/Icons/Generics/Retry.d.ts +0 -4
- package/lib/Icons/Generics/Retry.js +0 -12
- package/lib/Icons/Generics/Root.d.ts +0 -15
- package/lib/Icons/Generics/Root.js +0 -23
- package/lib/Icons/Generics/Selected.d.ts +0 -15
- package/lib/Icons/Generics/Selected.js +0 -23
- package/lib/Icons/Generics/index.d.ts +0 -10
- package/lib/Icons/Generics/index.js +0 -27
- package/lib/Icons/Icon.d.ts +0 -51
- package/lib/Icons/Icon.js +0 -42
- package/lib/Icons/MatrixResources/Audio.d.ts +0 -15
- package/lib/Icons/MatrixResources/Audio.js +0 -28
- package/lib/Icons/MatrixResources/Excel.d.ts +0 -15
- package/lib/Icons/MatrixResources/Excel.js +0 -27
- package/lib/Icons/MatrixResources/Folder.d.ts +0 -15
- package/lib/Icons/MatrixResources/Folder.js +0 -24
- package/lib/Icons/MatrixResources/GenericFile.d.ts +0 -15
- package/lib/Icons/MatrixResources/GenericFile.js +0 -28
- package/lib/Icons/MatrixResources/Image.d.ts +0 -15
- package/lib/Icons/MatrixResources/Image.js +0 -26
- package/lib/Icons/MatrixResources/MatrixResourceMap.d.ts +0 -15
- package/lib/Icons/MatrixResources/MatrixResourceMap.js +0 -19
- package/lib/Icons/MatrixResources/Page.d.ts +0 -15
- package/lib/Icons/MatrixResources/Page.js +0 -30
- package/lib/Icons/MatrixResources/Pdf.d.ts +0 -15
- package/lib/Icons/MatrixResources/Pdf.js +0 -31
- package/lib/Icons/MatrixResources/Powerpoint.d.ts +0 -15
- package/lib/Icons/MatrixResources/Powerpoint.js +0 -28
- package/lib/Icons/MatrixResources/Site.d.ts +0 -15
- package/lib/Icons/MatrixResources/Site.js +0 -30
- package/lib/Icons/MatrixResources/Video.d.ts +0 -15
- package/lib/Icons/MatrixResources/Video.js +0 -24
- package/lib/Icons/MatrixResources/Word.d.ts +0 -17
- package/lib/Icons/MatrixResources/Word.js +0 -28
- package/lib/Icons/MatrixResources/index.d.ts +0 -11
- package/lib/Icons/MatrixResources/index.js +0 -29
- package/lib/Modal/Modal.d.ts +0 -11
- package/lib/Modal/Modal.js +0 -46
- package/lib/Modal/ModalOpeningButton.d.ts +0 -10
- package/lib/Modal/ModalOpeningButton.js +0 -13
- package/lib/Modal/ModalTrigger.d.ts +0 -10
- package/lib/Modal/ModalTrigger.js +0 -25
- package/lib/PreviewPanel/PreviewModal.d.ts +0 -11
- package/lib/PreviewPanel/PreviewModal.js +0 -81
- package/lib/ResourceItem/ResourceItem.d.ts +0 -16
- package/lib/ResourceItem/ResourceItem.js +0 -28
- package/lib/ResourcePicker/ResetButton.d.ts +0 -5
- package/lib/ResourcePicker/ResetButton.js +0 -11
- package/lib/ResourceState/ResourceState.d.ts +0 -7
- package/lib/ResourceState/ResourceState.js +0 -16
- package/lib/Skeleton/List/SkeletonList.d.ts +0 -5
- package/lib/Skeleton/List/SkeletonList.js +0 -13
- package/lib/Skeleton/ListItem/SkeletonListItem.d.ts +0 -1
- package/lib/Skeleton/ListItem/SkeletonListItem.js +0 -15
- package/lib/Spinner/Spinner.d.ts +0 -8
- package/lib/Spinner/Spinner.js +0 -12
- package/src/Hooks/useAsync.spec.ts +0 -106
- package/src/Hooks/useAsync.ts +0 -62
- package/src/Icons/Generics/ArrowDown.tsx +0 -27
- package/src/Icons/Generics/ArrowRight.tsx +0 -27
- package/src/Icons/Generics/Back.tsx +0 -13
- package/src/Icons/Generics/Close.tsx +0 -26
- package/src/Icons/Generics/Empty.tsx +0 -13
- package/src/Icons/Generics/Error.tsx +0 -13
- package/src/Icons/Generics/GenericIconMap.ts +0 -18
- package/src/Icons/Generics/ResourceSelect.tsx +0 -40
- package/src/Icons/Generics/Retry.tsx +0 -13
- package/src/Icons/Generics/Root.tsx +0 -24
- package/src/Icons/Generics/Selected.tsx +0 -27
- package/src/Icons/Generics/index.tsx +0 -11
- package/src/Icons/Icon.spec.tsx +0 -62
- package/src/Icons/Icon.stories.tsx +0 -110
- package/src/Icons/Icon.tsx +0 -56
- package/src/Icons/MatrixResources/Audio.tsx +0 -30
- package/src/Icons/MatrixResources/Excel.tsx +0 -29
- package/src/Icons/MatrixResources/Folder.tsx +0 -29
- package/src/Icons/MatrixResources/GenericFile.tsx +0 -34
- package/src/Icons/MatrixResources/Image.tsx +0 -36
- package/src/Icons/MatrixResources/MatrixResourceMap.ts +0 -19
- package/src/Icons/MatrixResources/Page.tsx +0 -33
- package/src/Icons/MatrixResources/Pdf.tsx +0 -34
- package/src/Icons/MatrixResources/Powerpoint.tsx +0 -34
- package/src/Icons/MatrixResources/Site.tsx +0 -37
- package/src/Icons/MatrixResources/Video.tsx +0 -27
- package/src/Icons/MatrixResources/Word.tsx +0 -30
- package/src/Icons/MatrixResources/index.tsx +0 -12
- package/src/Modal/Modal.spec.tsx +0 -269
- package/src/Modal/Modal.tsx +0 -58
- package/src/Modal/ModalContainer.stories.tsx +0 -33
- package/src/Modal/ModalOpeningButton.tsx +0 -20
- package/src/Modal/ModalTrigger.tsx +0 -57
- package/src/PreviewPanel/PreviewModal.spec.tsx +0 -164
- package/src/PreviewPanel/PreviewModal.tsx +0 -92
- package/src/ResourceItem/ResourceItem.spec.tsx +0 -65
- package/src/ResourceItem/ResourceItem.tsx +0 -84
- package/src/ResourcePicker/ResetButton.tsx +0 -20
- package/src/ResourceState/ResourceState.spec.tsx +0 -26
- package/src/ResourceState/ResourceState.stories.tsx +0 -24
- package/src/ResourceState/ResourceState.tsx +0 -31
- package/src/Skeleton/List/SkeletonList.spec.tsx +0 -18
- package/src/Skeleton/List/SkeletonList.stories.tsx +0 -15
- package/src/Skeleton/List/SkeletonList.tsx +0 -16
- package/src/Skeleton/ListItem/SkeletonListItem.stories.tsx +0 -15
- package/src/Skeleton/ListItem/SkeletonListItem.tsx +0 -14
- package/src/Skeleton/_skeleton.scss +0 -15
- package/src/Spinner/Spinner.spec.tsx +0 -18
- package/src/Spinner/Spinner.stories.tsx +0 -26
- package/src/Spinner/Spinner.tsx +0 -18
- package/src/Spinner/_spinner.scss +0 -14
- /package/src/ResourceBreadcrumb/{ResourceBreadcrumb.scss → resource-breadcrumb.scss} +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
|
3
3
|
import { Resource } from '../../types';
|
4
|
-
import Icon,
|
4
|
+
import { Icon, IconOptions } from '@squiz/generic-browser-lib';
|
5
5
|
import StatusIndicator from '../../StatusIndicator/StatusIndicator';
|
6
6
|
|
7
7
|
type MatrixResourceProps = {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { useState, useCallback, useEffect } from 'react';
|
2
2
|
|
3
|
-
import Icon,
|
3
|
+
import { Icon, IconOptions } from '@squiz/generic-browser-lib';
|
4
4
|
import { Hierarchy } from '../types';
|
5
5
|
|
6
6
|
export interface ResourceBreadcrumbProps<T> {
|
@@ -1,11 +1,9 @@
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
2
2
|
import { OverlayTriggerState } from 'react-stately';
|
3
3
|
import { DOMAttributes, FocusableElement } from '@react-types/shared';
|
4
|
+
import { ResourceItem, ResourceState, SkeletonList } from '@squiz/generic-browser-lib';
|
4
5
|
|
5
|
-
import ResourceItem from '../ResourceItem/ResourceItem';
|
6
6
|
import { Resource } from '../types';
|
7
|
-
import { SkeletonListItem } from '../Skeleton/ListItem/SkeletonListItem';
|
8
|
-
import ResourceState from '../ResourceState/ResourceState';
|
9
7
|
|
10
8
|
export interface ResourceListProps {
|
11
9
|
resources: Array<Resource>;
|
@@ -43,31 +41,24 @@ const ResourceList = function ({
|
|
43
41
|
}
|
44
42
|
}, [resources]);
|
45
43
|
|
44
|
+
if (isLoading) {
|
45
|
+
return <SkeletonList itemCount={8} ariaLabel="loading Resource list" className="text-sm font-semibold" />;
|
46
|
+
}
|
47
|
+
|
46
48
|
return (
|
47
49
|
<ul
|
48
50
|
ref={listRef}
|
49
51
|
tabIndex={-1}
|
50
|
-
aria-label={
|
52
|
+
aria-label={`Resource list`}
|
51
53
|
className="flex flex-col text-sm font-semibold px-7 my-4 focus-visible:outline-0"
|
52
54
|
>
|
53
|
-
{isLoading && (
|
54
|
-
<>
|
55
|
-
{[...Array(8)].map((_item, index: number) => {
|
56
|
-
return <SkeletonListItem key={index} />;
|
57
|
-
})}
|
58
|
-
</>
|
59
|
-
)}
|
60
|
-
|
61
55
|
{/* Error State */}
|
62
|
-
{
|
56
|
+
{error && <ResourceState state="error" message={error.message} handleReload={handleReload} />}
|
63
57
|
|
64
58
|
{/* Empty State */}
|
65
|
-
{!
|
66
|
-
<ResourceState state="empty" handleReload={handleReturnToRoot} />
|
67
|
-
)}
|
59
|
+
{!error && resources.length === 0 && <ResourceState state="empty" handleReload={handleReturnToRoot} />}
|
68
60
|
|
69
|
-
{!
|
70
|
-
!error &&
|
61
|
+
{!error &&
|
71
62
|
resources.map((resource) => {
|
72
63
|
return (
|
73
64
|
<ResourceItem
|
@@ -3,8 +3,8 @@ import AdsClickRoundedIcon from '@mui/icons-material/AdsClickRounded';
|
|
3
3
|
import AddCircleOutlineRoundedIcon from '@mui/icons-material/AddCircleOutlineRounded';
|
4
4
|
import PhotoLibraryRoundedIcon from '@mui/icons-material/PhotoLibraryRounded';
|
5
5
|
import { DOMAttributes } from '@react-types/shared';
|
6
|
+
import { ModalTrigger } from '@squiz/generic-browser-lib';
|
6
7
|
import { Resource } from '../types';
|
7
|
-
import ModalTrigger from '../Modal/ModalTrigger';
|
8
8
|
import { ErrorState } from './States/Error';
|
9
9
|
import { LoadingState } from './States/Loading';
|
10
10
|
import { SelectedState } from './States/Selected';
|
@@ -1,10 +1,9 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import prettyBytes from 'pretty-bytes';
|
3
|
+
import { Icon, IconOptions, ResetButton } from '@squiz/generic-browser-lib';
|
3
4
|
|
4
5
|
import { Resource } from '../../types';
|
5
|
-
import Icon, { IconOptions } from '../../Icons/Icon';
|
6
6
|
import StatusIndicator from '../../StatusIndicator/StatusIndicator';
|
7
|
-
import { ResetButton } from '../ResetButton';
|
8
7
|
|
9
8
|
export type SelectedStateProps = {
|
10
9
|
resource: Resource;
|
@@ -584,4 +584,32 @@ describe('ResourcePickerContainer', () => {
|
|
584
584
|
},
|
585
585
|
]);
|
586
586
|
});
|
587
|
+
|
588
|
+
it('handleDetailSelect() works', async () => {
|
589
|
+
const onChangeMock = jest.fn();
|
590
|
+
const onCloseMock = jest.fn();
|
591
|
+
const { getAllByText } = render(
|
592
|
+
<ResourcePickerContainer {...baseProps} onChange={onChangeMock} onClose={onCloseMock} />,
|
593
|
+
);
|
594
|
+
|
595
|
+
await waitFor(() => {
|
596
|
+
expect(getAllByText('Test system')[0]).toBeInTheDocument();
|
597
|
+
});
|
598
|
+
|
599
|
+
const user = userEvent.setup();
|
600
|
+
user.click(screen.getByRole('button', { name: 'Drill down to Test Website children' }));
|
601
|
+
await waitFor(() => expect(screen.getByRole('button', { name: 'page Test Page' })).toBeInTheDocument());
|
602
|
+
|
603
|
+
// Select the resource
|
604
|
+
user.click(screen.getByRole('button', { name: 'page Test Page' }));
|
605
|
+
|
606
|
+
// Wait for the preview panel to open
|
607
|
+
await waitFor(() => expect(screen.getByText('Mocked Page')).toBeInTheDocument());
|
608
|
+
await waitFor(() => expect(screen.getByText('#123')).toBeInTheDocument());
|
609
|
+
|
610
|
+
user.click(screen.getByRole('button', { name: 'Select' }));
|
611
|
+
|
612
|
+
await waitFor(() => expect(onChangeMock).toHaveBeenCalled());
|
613
|
+
await waitFor(() => expect(onCloseMock).toHaveBeenCalled());
|
614
|
+
});
|
587
615
|
});
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import React, { useState, useCallback, useEffect } from 'react';
|
2
2
|
import { DOMAttributes, FocusableElement } from '@react-types/shared';
|
3
3
|
import { useOverlayTriggerState } from 'react-stately';
|
4
|
+
import { useAsync } from '@squiz/generic-browser-lib';
|
4
5
|
|
5
6
|
import SourceList from '../SourceList/SourceList';
|
6
7
|
import ResourceList from '../ResourceList/ResourceList';
|
@@ -10,7 +11,6 @@ import SourceDropdown from '../SourceDropdown/SourceDropdown';
|
|
10
11
|
|
11
12
|
import { Source, Resource, HydratedResourceReference, ScopedSource } from '../types';
|
12
13
|
import { useResourcePath } from '../Hooks/useResourcePath';
|
13
|
-
import { useAsync } from '../Hooks/useAsync';
|
14
14
|
import { useChildResources } from '../Hooks/useChildResources';
|
15
15
|
|
16
16
|
interface ResourcePickerContainerProps {
|
@@ -155,14 +155,16 @@ function ResourcePickerContainer({
|
|
155
155
|
/>
|
156
156
|
)}
|
157
157
|
</div>
|
158
|
-
<
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
158
|
+
<div className="sm:overflow-y-scroll sm:flex-1 sm:grow-[2] bg-white">
|
159
|
+
<PreviewPanel
|
160
|
+
resource={selectedResource}
|
161
|
+
modalState={previewModalState}
|
162
|
+
previewModalOverlayProps={previewModalOverlayProps}
|
163
|
+
allowedTypes={allowedTypes}
|
164
|
+
onSelect={handleDetailSelect}
|
165
|
+
onClose={handleDetailClose}
|
166
|
+
/>
|
167
|
+
</div>
|
166
168
|
</div>
|
167
169
|
</div>
|
168
170
|
);
|
@@ -207,7 +207,11 @@ describe('SourceDropdown', () => {
|
|
207
207
|
expect(screen.getByRole('button', { name: 'Site Node 4' })).toBeTruthy();
|
208
208
|
});
|
209
209
|
|
210
|
-
|
210
|
+
//fireEvent.keyDown(buttonDropdown, { keyCode: 13 })
|
211
|
+
|
212
|
+
userEvent.keyboard('{escape}');
|
213
|
+
|
214
|
+
//user.type(buttonDropdown, '{escape}');
|
211
215
|
|
212
216
|
await waitFor(() => {
|
213
217
|
expect(screen.queryByRole('button', { name: 'All available sources' })).toBeFalsy();
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import React, { useState, useRef } from 'react';
|
2
2
|
import { useFocusWithin, useKeyboard } from '@react-aria/interactions';
|
3
|
+
import { Icon, IconOptions, Spinner } from '@squiz/generic-browser-lib';
|
3
4
|
|
4
5
|
import type { Source, ScopedSource } from '../types';
|
5
|
-
import Spinner from '../Spinner/Spinner';
|
6
|
-
import Icon, { IconOptions } from '../Icons/Icon';
|
7
6
|
|
8
7
|
import uuid from '../uuid';
|
9
8
|
import { useCategorisedSources } from '../Hooks/useCategorisedSources';
|
@@ -92,7 +91,7 @@ export default function SourceDropdown({
|
|
92
91
|
<ul
|
93
92
|
id={`${uniqueId}-button-menu`}
|
94
93
|
aria-hidden={!isOpen}
|
95
|
-
className={`absolute z-50 top-[calc(100%+5px)] -left-0.5 w-[calc(100%+4px)] bg-gray-100 border-2 rounded border-gray-300 p-2 ${
|
94
|
+
className={`absolute z-50 top-[calc(100%+5px)] -left-0.5 w-[calc(100%+4px)] bg-gray-100 border-2 rounded border-gray-300 p-2 overflow-y-scroll max-h-80 ${
|
96
95
|
!isOpen ? 'hidden' : ''
|
97
96
|
}`}
|
98
97
|
>
|
@@ -1,13 +1,11 @@
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
2
2
|
import { OverlayTriggerState } from 'react-stately';
|
3
3
|
import { DOMAttributes, FocusableElement } from '@react-types/shared';
|
4
|
+
import { SkeletonList, ResourceItem, ResourceState } from '@squiz/generic-browser-lib';
|
5
|
+
import clsx from 'clsx';
|
4
6
|
|
5
|
-
import ResourceItem from '../ResourceItem/ResourceItem';
|
6
7
|
import { Source, ScopedSource } from '../types';
|
7
|
-
import { SkeletonList } from '../Skeleton/List/SkeletonList';
|
8
|
-
import clsx from 'clsx';
|
9
8
|
import { useCategorisedSources } from '../Hooks/useCategorisedSources';
|
10
|
-
import ResourceState from '../ResourceState/ResourceState';
|
11
9
|
|
12
10
|
export interface SourceListProps {
|
13
11
|
sources: Source[];
|
@@ -37,28 +35,25 @@ const SourceList = function ({
|
|
37
35
|
}
|
38
36
|
}, []);
|
39
37
|
|
38
|
+
if (isLoading) {
|
39
|
+
return (
|
40
|
+
<div className="flex flex-col bg-gray-100 min-h-full" aria-label="loading Source list">
|
41
|
+
<SkeletonList itemCount={3} />
|
42
|
+
<SkeletonList itemCount={3} />
|
43
|
+
</div>
|
44
|
+
);
|
45
|
+
}
|
46
|
+
|
40
47
|
return (
|
41
48
|
<ul
|
42
49
|
ref={listRef}
|
43
50
|
tabIndex={-1}
|
44
|
-
aria-label={
|
45
|
-
className={clsx('flex flex-col bg-gray-100 min-h-full focus-visible:outline-0
|
51
|
+
aria-label={`Source list`}
|
52
|
+
className={clsx('flex flex-col bg-gray-100 min-h-full focus-visible:outline-0 px-7 py-4')}
|
46
53
|
>
|
47
|
-
{
|
48
|
-
<>
|
49
|
-
<li>
|
50
|
-
<SkeletonList itemCount={3} />
|
51
|
-
</li>
|
52
|
-
<li>
|
53
|
-
<SkeletonList itemCount={3} />
|
54
|
-
</li>
|
55
|
-
</>
|
56
|
-
)}
|
57
|
-
|
58
|
-
{!isLoading && error && <ResourceState state="error" message={error.message} handleReload={handleReload} />}
|
54
|
+
{error && <ResourceState state="error" message={error.message} handleReload={handleReload} />}
|
59
55
|
|
60
|
-
{!
|
61
|
-
!error &&
|
56
|
+
{!error &&
|
62
57
|
categorisedSources.map(({ key, label, sources }, index) => {
|
63
58
|
return (
|
64
59
|
<li key={key} className={`flex flex-col text-sm font-semibold text-grey-800 ${index > 0 ? 'mt-3' : ''}`}>
|
@@ -77,6 +72,7 @@ const SourceList = function ({
|
|
77
72
|
previewModalState={previewModalState}
|
78
73
|
onSelect={onSourceSelect}
|
79
74
|
className="mt-3 rounded-lg"
|
75
|
+
showChevron
|
80
76
|
/>
|
81
77
|
);
|
82
78
|
})}
|
package/src/index.scss
CHANGED
@@ -4,9 +4,7 @@
|
|
4
4
|
@import 'tailwindcss/utilities';
|
5
5
|
|
6
6
|
// Components
|
7
|
-
@import './
|
8
|
-
@import './Skeleton/skeleton';
|
9
|
-
@import './ResourceBreadcrumb/ResourceBreadcrumb';
|
7
|
+
@import './ResourceBreadcrumb/resource-breadcrumb';
|
10
8
|
@import './ResourcePicker/resource-picker';
|
11
9
|
|
12
10
|
*,
|
package/tailwind.config.cjs
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
/** @type {import('tailwindcss').Config} */
|
2
2
|
module.exports = {
|
3
|
-
content: [
|
3
|
+
content: [
|
4
|
+
'../generic-browser-lib/src/**/*.{js,ts,jsx,tsx}',
|
5
|
+
'./index.html',
|
6
|
+
'./src/**/*.{js,ts,jsx,tsx}',
|
7
|
+
'./node_modules/flowbite/**/*.js',
|
8
|
+
],
|
4
9
|
theme: {
|
5
10
|
extend: {
|
6
11
|
borderWidth: {
|
package/vite.config.js
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
import { defineConfig } from 'vite';
|
2
|
+
import react from '@vitejs/plugin-react';
|
3
|
+
|
4
|
+
// https://vitejs.dev/config/
|
5
|
+
// Dependencies from within the monorepo need to be configured in a special way, relates to:
|
6
|
+
// https://github.com/vitejs/vite/issues/5668
|
7
|
+
export default defineConfig({
|
8
|
+
optimizeDeps: {
|
9
|
+
include: ['@squiz/generic-browser-lib'],
|
10
|
+
},
|
11
|
+
plugins: [
|
12
|
+
react({
|
13
|
+
babel: {
|
14
|
+
parserOpts: {
|
15
|
+
plugins: ['decorators-legacy'],
|
16
|
+
},
|
17
|
+
},
|
18
|
+
}),
|
19
|
+
],
|
20
|
+
});
|
package/lib/Hooks/useAsync.d.ts
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
import { DependencyList } from 'react';
|
2
|
-
export type UseAsyncProps<TReturnType, TDefaultValueType> = {
|
3
|
-
/** The async callback to call for fetching data. */
|
4
|
-
callback: () => TReturnType | Promise<TReturnType>;
|
5
|
-
/** The default value to populate the data as when initially mounted or reloading data. */
|
6
|
-
defaultValue: TReturnType | TDefaultValueType;
|
7
|
-
};
|
8
|
-
/**
|
9
|
-
* Hook for invoking a piece of async code and keeping track of its state.
|
10
|
-
*
|
11
|
-
* Data is loaded in 3 different ways:
|
12
|
-
* 1. On initial mount.
|
13
|
-
* 2. When any of the `deps` change.
|
14
|
-
* 3. When the `relaod` function is called.
|
15
|
-
*/
|
16
|
-
export declare const useAsync: <TReturnType, TDefaultValueType>({ callback, defaultValue }: UseAsyncProps<TReturnType, TDefaultValueType>, deps: DependencyList) => {
|
17
|
-
data: TReturnType | TDefaultValueType;
|
18
|
-
error: Error | null;
|
19
|
-
isLoading: boolean;
|
20
|
-
reload: () => void;
|
21
|
-
};
|
package/lib/Hooks/useAsync.js
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.useAsync = void 0;
|
4
|
-
const react_1 = require("react");
|
5
|
-
/**
|
6
|
-
* Hook for invoking a piece of async code and keeping track of its state.
|
7
|
-
*
|
8
|
-
* Data is loaded in 3 different ways:
|
9
|
-
* 1. On initial mount.
|
10
|
-
* 2. When any of the `deps` change.
|
11
|
-
* 3. When the `relaod` function is called.
|
12
|
-
*/
|
13
|
-
const useAsync = ({ callback, defaultValue }, deps) => {
|
14
|
-
const [data, setData] = (0, react_1.useState)(defaultValue);
|
15
|
-
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
16
|
-
const [error, setError] = (0, react_1.useState)(null);
|
17
|
-
const reload = (0, react_1.useCallback)(() => {
|
18
|
-
setIsLoading(true);
|
19
|
-
setError(null);
|
20
|
-
setData(defaultValue);
|
21
|
-
try {
|
22
|
-
const result = callback();
|
23
|
-
if (result instanceof Promise) {
|
24
|
-
// if the callback returned a promise wait for it to either resolve or reject.
|
25
|
-
result
|
26
|
-
.then((resolved) => {
|
27
|
-
setData(resolved);
|
28
|
-
setIsLoading(false);
|
29
|
-
})
|
30
|
-
.catch((e) => {
|
31
|
-
setError(e instanceof Error ? e : new Error(String(e)));
|
32
|
-
setIsLoading(false);
|
33
|
-
});
|
34
|
-
}
|
35
|
-
else {
|
36
|
-
// if the callback returned something other than a promise assume it is the data we want.
|
37
|
-
setData(result);
|
38
|
-
setIsLoading(false);
|
39
|
-
}
|
40
|
-
}
|
41
|
-
catch (e) {
|
42
|
-
// callback threw outside of the scope of the promise.
|
43
|
-
setError(e instanceof Error ? e : new Error(String(e)));
|
44
|
-
setIsLoading(false);
|
45
|
-
}
|
46
|
-
}, deps);
|
47
|
-
// reload data on dependency change (and initial mount)
|
48
|
-
(0, react_1.useEffect)(() => {
|
49
|
-
reload();
|
50
|
-
}, deps);
|
51
|
-
return { data, error, isLoading, reload };
|
52
|
-
};
|
53
|
-
exports.useAsync = useAsync;
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
/**
|
3
|
-
* Renders the ArrowDown icon
|
4
|
-
* @param {React.SVGProps<SVGSVGElement>} props - The props for the ArrowDown component
|
5
|
-
* @returns {JSX.Element} - The ArrowDown component
|
6
|
-
* @example
|
7
|
-
* <ArrowDown />
|
8
|
-
* @example
|
9
|
-
* <ArrowDown height={24} width={24} />
|
10
|
-
* @example
|
11
|
-
* <ArrowDown className="custom-class" />
|
12
|
-
*/
|
13
|
-
export default function ArrowDown({ isDecorative, ...props }: {
|
14
|
-
isDecorative: boolean;
|
15
|
-
} & React.SVGProps<SVGSVGElement>): JSX.Element;
|
@@ -1,23 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const react_1 = __importDefault(require("react"));
|
7
|
-
/**
|
8
|
-
* Renders the ArrowDown icon
|
9
|
-
* @param {React.SVGProps<SVGSVGElement>} props - The props for the ArrowDown component
|
10
|
-
* @returns {JSX.Element} - The ArrowDown component
|
11
|
-
* @example
|
12
|
-
* <ArrowDown />
|
13
|
-
* @example
|
14
|
-
* <ArrowDown height={24} width={24} />
|
15
|
-
* @example
|
16
|
-
* <ArrowDown className="custom-class" />
|
17
|
-
*/
|
18
|
-
function ArrowDown({ isDecorative, ...props }) {
|
19
|
-
return (react_1.default.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props },
|
20
|
-
react_1.default.createElement("path", { d: "M8.12508 8.99999L12.0051 12.88L15.8851 8.99999C16.2751 8.60999 16.9051 8.60999 17.2951 8.99999C17.6851 9.38999 17.6851 10.02 17.2951 10.41L12.7051 15C12.3151 15.39 11.6851 15.39 11.2951 15L6.70508 10.41C6.51783 10.2232 6.4126 9.96951 6.4126 9.70499C6.4126 9.44047 6.51783 9.18682 6.70508 8.99999C7.09508 8.61999 7.73508 8.60999 8.12508 8.99999Z", fill: "#707070" }),
|
21
|
-
!isDecorative && react_1.default.createElement("title", null, "arrow down icon")));
|
22
|
-
}
|
23
|
-
exports.default = ArrowDown;
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
/**
|
3
|
-
* Renders the ArrowRight icon
|
4
|
-
* @param {React.SVGProps<SVGSVGElement>} props - The props for the ArrowRight component
|
5
|
-
* @returns {JSX.Element} - The ArrowRight component
|
6
|
-
* @example
|
7
|
-
* <ArrowRight />
|
8
|
-
* @example
|
9
|
-
* <ArrowRight height={24} width={24} />
|
10
|
-
* @example
|
11
|
-
* <ArrowRight className="custom-class" />
|
12
|
-
*/
|
13
|
-
export default function ArrowRight({ isDecorative, ...props }: {
|
14
|
-
isDecorative: boolean;
|
15
|
-
} & React.SVGProps<SVGSVGElement>): JSX.Element;
|
@@ -1,23 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const react_1 = __importDefault(require("react"));
|
7
|
-
/**
|
8
|
-
* Renders the ArrowRight icon
|
9
|
-
* @param {React.SVGProps<SVGSVGElement>} props - The props for the ArrowRight component
|
10
|
-
* @returns {JSX.Element} - The ArrowRight component
|
11
|
-
* @example
|
12
|
-
* <ArrowRight />
|
13
|
-
* @example
|
14
|
-
* <ArrowRight height={24} width={24} />
|
15
|
-
* @example
|
16
|
-
* <ArrowRight className="custom-class" />
|
17
|
-
*/
|
18
|
-
function ArrowRight({ isDecorative, ...props }) {
|
19
|
-
return (react_1.default.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props },
|
20
|
-
react_1.default.createElement("path", { d: "M9.00001 15.875L12.88 11.995L9.00001 8.11501C8.81275 7.92817 8.70752 7.67452 8.70752 7.41001C8.70752 7.14549 8.81275 6.89184 9.00001 6.70501C9.39001 6.31501 10.02 6.31501 10.41 6.70501L15 11.295C15.39 11.685 15.39 12.315 15 12.705L10.41 17.295C10.02 17.685 9.39001 17.685 9.00001 17.295C8.62001 16.905 8.61001 16.265 9.00001 15.875Z", fill: "#707070" }),
|
21
|
-
!isDecorative && react_1.default.createElement("title", null, "arrow right icon")));
|
22
|
-
}
|
23
|
-
exports.default = ArrowRight;
|
@@ -1,12 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const react_1 = __importDefault(require("react"));
|
7
|
-
function Back({ isDecorative, ...props }) {
|
8
|
-
return (react_1.default.createElement("svg", { width: "17", height: "16", viewBox: "0 0 17 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props },
|
9
|
-
react_1.default.createElement("path", { d: "M15.2912 7.00501H4.12124L9.00124 2.12501C9.39124 1.73501 9.39124 1.09501 9.00124 0.705006C8.61124 0.315006 7.98124 0.315006 7.59124 0.705006L1.00124 7.29501C0.61124 7.68501 0.61124 8.31501 1.00124 8.70501L7.59124 15.295C7.98124 15.685 8.61124 15.685 9.00124 15.295C9.39124 14.905 9.39124 14.275 9.00124 13.885L4.12124 9.00501H15.2912C15.8412 9.00501 16.2912 8.55501 16.2912 8.00501C16.2912 7.45501 15.8412 7.00501 15.2912 7.00501Z", fill: "#3D3D3D" }),
|
10
|
-
!isDecorative && react_1.default.createElement("title", null, "back icon")));
|
11
|
-
}
|
12
|
-
exports.default = Back;
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
/**
|
3
|
-
* Renders the Close icon
|
4
|
-
* @param {React.SVGProps<SVGSVGElement>} props - The props for the Close component
|
5
|
-
* @returns {JSX.Element} - The Close component
|
6
|
-
* @example
|
7
|
-
* <Close />
|
8
|
-
* @example
|
9
|
-
* <Close height={24} width={24} />
|
10
|
-
* @example
|
11
|
-
* <Close className="custom-class" />
|
12
|
-
*/
|
13
|
-
export default function Close({ isDecorative, ...props }: {
|
14
|
-
isDecorative: boolean;
|
15
|
-
} & React.SVGProps<SVGSVGElement>): JSX.Element;
|
@@ -1,23 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const react_1 = __importDefault(require("react"));
|
7
|
-
/**
|
8
|
-
* Renders the Close icon
|
9
|
-
* @param {React.SVGProps<SVGSVGElement>} props - The props for the Close component
|
10
|
-
* @returns {JSX.Element} - The Close component
|
11
|
-
* @example
|
12
|
-
* <Close />
|
13
|
-
* @example
|
14
|
-
* <Close height={24} width={24} />
|
15
|
-
* @example
|
16
|
-
* <Close className="custom-class" />
|
17
|
-
*/
|
18
|
-
function Close({ isDecorative, ...props }) {
|
19
|
-
return (react_1.default.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props },
|
20
|
-
react_1.default.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M2 12C2 6.47 6.47 2 12 2C17.53 2 22 6.47 22 12C22 17.53 17.53 22 12 22C6.47 22 2 17.53 2 12ZM14.89 16.3C15.28 16.69 15.91 16.69 16.3 16.3C16.68 15.91 16.68 15.27 16.3 14.89L13.41 12L16.3 9.11C16.69 8.72 16.69 8.09 16.3 7.7C15.91 7.31 15.28 7.31 14.89 7.7L12 10.59L9.11 7.7C8.72 7.31 8.09 7.31 7.7 7.7C7.51275 7.88683 7.40751 8.14048 7.40751 8.405C7.40751 8.66952 7.51275 8.92317 7.7 9.11L10.59 12L7.7 14.89C7.51275 15.0768 7.40751 15.3305 7.40751 15.595C7.40751 15.8595 7.51275 16.1132 7.7 16.3C8.09 16.69 8.72 16.69 9.11 16.3L12 13.41L14.89 16.3Z", fill: "#949494" }),
|
21
|
-
!isDecorative && react_1.default.createElement("title", null, "close icon")));
|
22
|
-
}
|
23
|
-
exports.default = Close;
|
@@ -1,12 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const react_1 = __importDefault(require("react"));
|
7
|
-
function Empty({ isDecorative, ...props }) {
|
8
|
-
return (react_1.default.createElement("svg", { width: "42", height: "42", viewBox: "0 0 42 42", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props },
|
9
|
-
react_1.default.createElement("path", { d: "M1.3925 3.82749C0.612495 4.60749 0.612495 5.88749 1.3925 6.66749L4.5125 9.78749C2.0125 13.5475 0.752495 18.1875 1.3325 23.1675C2.37249 32.2475 9.75249 39.6275 18.8325 40.6675C23.8125 41.2475 28.4525 39.9875 32.2125 37.4875L35.3325 40.6075C36.1125 41.3875 37.3725 41.3875 38.1525 40.6075C38.9325 39.8275 38.9325 38.5675 38.1525 37.7875L4.21249 3.82749C3.4325 3.04749 2.17249 3.04749 1.3925 3.82749ZM21.1925 36.8075C12.3725 36.8075 5.19249 29.6275 5.19249 20.8075C5.19249 17.8475 6.01249 15.0875 7.43249 12.6875L29.3125 34.5675C26.9125 35.9875 24.1525 36.8075 21.1925 36.8075ZM13.0725 7.04749L10.1725 4.12749C13.3325 2.0275 17.1125 0.807495 21.1925 0.807495C32.2325 0.807495 41.1925 9.76749 41.1925 20.8075C41.1925 24.8875 39.9725 28.6675 37.8725 31.8275L34.9525 28.9075C36.3725 26.5275 37.1925 23.7675 37.1925 20.8075C37.1925 11.9875 30.0125 4.80749 21.1925 4.80749C18.2325 4.80749 15.4725 5.62749 13.0725 7.04749Z", fill: "#949494" }),
|
10
|
-
!isDecorative && react_1.default.createElement("title", null, "empty icon")));
|
11
|
-
}
|
12
|
-
exports.default = Empty;
|
@@ -1,12 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const react_1 = __importDefault(require("react"));
|
7
|
-
function Error({ isDecorative, ...props }) {
|
8
|
-
return (react_1.default.createElement("svg", { width: "48", height: "48", viewBox: "0 0 48 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props },
|
9
|
-
react_1.default.createElement("path", { d: "M30.6498 6H17.3698C16.8498 6 16.3298 6.22 15.9698 6.58L6.58977 15.96C6.22977 16.32 6.00977 16.84 6.00977 17.36V30.62C6.00977 31.16 6.22977 31.66 6.58977 32.04L15.9498 41.4C16.3298 41.78 16.8498 42 17.3698 42H30.6298C31.1698 42 31.6698 41.78 32.0498 41.42L41.4098 32.06C41.7898 31.68 41.9898 31.18 41.9898 30.64V17.36C41.9898 16.82 41.7698 16.32 41.4098 15.94L32.0498 6.58C31.6898 6.22 31.1698 6 30.6498 6ZM24.0098 34.6C22.5698 34.6 21.4098 33.44 21.4098 32C21.4098 30.56 22.5698 29.4 24.0098 29.4C25.4498 29.4 26.6098 30.56 26.6098 32C26.6098 33.44 25.4498 34.6 24.0098 34.6ZM24.0098 26C22.9098 26 22.0098 25.1 22.0098 24V16C22.0098 14.9 22.9098 14 24.0098 14C25.1098 14 26.0098 14.9 26.0098 16V24C26.0098 25.1 25.1098 26 24.0098 26Z", fill: "#D72321" }),
|
10
|
-
!isDecorative && react_1.default.createElement("title", null, "error icon")));
|
11
|
-
}
|
12
|
-
exports.default = Error;
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { ArrowRight, ArrowDown, Selected, Root, ResourceSelect, Close, Error, Retry, Empty, Back } from '.';
|
2
|
-
declare const GenericIconMap: {
|
3
|
-
'arrow-right': typeof ArrowRight;
|
4
|
-
'arrow-down': typeof ArrowDown;
|
5
|
-
'resource-select': typeof ResourceSelect;
|
6
|
-
selected: typeof Selected;
|
7
|
-
root: typeof Root;
|
8
|
-
close: typeof Close;
|
9
|
-
error: typeof Error;
|
10
|
-
retry: typeof Retry;
|
11
|
-
empty: typeof Empty;
|
12
|
-
back: typeof Back;
|
13
|
-
};
|
14
|
-
export default GenericIconMap;
|
@@ -1,18 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const _1 = require(".");
|
4
|
-
// Define our map of matrix types to icons
|
5
|
-
const GenericIconMap = {
|
6
|
-
'arrow-right': _1.ArrowRight,
|
7
|
-
'arrow-down': _1.ArrowDown,
|
8
|
-
'resource-select': _1.ResourceSelect,
|
9
|
-
selected: _1.Selected,
|
10
|
-
root: _1.Root,
|
11
|
-
close: _1.Close,
|
12
|
-
error: _1.Error,
|
13
|
-
retry: _1.Retry,
|
14
|
-
empty: _1.Empty,
|
15
|
-
back: _1.Back,
|
16
|
-
};
|
17
|
-
// Export our map
|
18
|
-
exports.default = GenericIconMap;
|