@squiz/resource-browser 1.64.1 → 1.66.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @squiz/resource-browser
2
2
 
3
+ ## 1.66.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5032c38: Added content page asset icon.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [5032c38]
12
+ - @squiz/generic-browser-lib@1.65.0
13
+
14
+ ## 1.65.0
15
+
16
+ ### Minor Changes
17
+
18
+ - ac68ec6: Unpinned Squiz dependencies, they should now be following semver.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [ac68ec6]
23
+ - @squiz/dx-json-schema-lib@1.65.0
24
+
3
25
  ## 1.64.1
4
26
 
5
27
  ### Patch Changes
@@ -1,6 +1,7 @@
1
+ import React from 'react';
1
2
  import { Resource } from '../../types';
2
3
  type MatrixResourceProps = {
3
4
  resource: Resource;
4
5
  };
5
- declare const MatrixResource: ({ resource: { id, type, name, status } }: MatrixResourceProps) => JSX.Element;
6
+ declare const MatrixResource: ({ resource: { id, type, name, status } }: MatrixResourceProps) => React.JSX.Element;
6
7
  export default MatrixResource;
@@ -1,8 +1,9 @@
1
+ import React from 'react';
1
2
  import { Hierarchy } from '../types';
2
3
  export interface ResourceBreadcrumbProps<T> {
3
4
  hierarchy: Hierarchy<T>;
4
5
  onBreadcrumbSelect: (node: T) => void;
5
6
  onReturnToRoot: () => void;
6
7
  }
7
- declare const ResourceBreadcrumb: <T>({ hierarchy, onBreadcrumbSelect, onReturnToRoot }: ResourceBreadcrumbProps<T>) => JSX.Element;
8
+ declare const ResourceBreadcrumb: <T>({ hierarchy, onBreadcrumbSelect, onReturnToRoot }: ResourceBreadcrumbProps<T>) => React.JSX.Element;
8
9
  export default ResourceBreadcrumb;
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { OverlayTriggerState } from 'react-stately';
2
3
  import { DOMAttributes, FocusableElement } from '@react-types/shared';
3
4
  import { Resource } from '../types';
@@ -13,5 +14,5 @@ export interface ResourceListProps {
13
14
  handleReload: () => void;
14
15
  error: Error | null;
15
16
  }
16
- declare const ResourceList: ({ resources, selectedResource, previewModalState, isLoading, onResourceSelect, onResourceDrillDown, allowedTypes, handleReturnToRoot, handleReload, error, }: ResourceListProps) => JSX.Element;
17
+ declare const ResourceList: ({ resources, selectedResource, previewModalState, isLoading, onResourceSelect, onResourceDrillDown, allowedTypes, handleReturnToRoot, handleReload, error, }: ResourceListProps) => React.JSX.Element;
17
18
  export default ResourceList;
@@ -10,5 +10,5 @@ export type ResourcePickerProps = {
10
10
  children: (onClose: () => void, titleProps: DOMAttributes) => React.ReactElement;
11
11
  onClear: () => void;
12
12
  };
13
- declare const ResourcePicker: ({ resource, allowedTypes, error, isLoading, isDisabled, children, onClear, }: ResourcePickerProps) => JSX.Element;
13
+ declare const ResourcePicker: ({ resource, allowedTypes, error, isLoading, isDisabled, children, onClear, }: ResourcePickerProps) => React.JSX.Element;
14
14
  export default ResourcePicker;
@@ -1,6 +1,7 @@
1
+ import React from 'react';
1
2
  export type ErrorStateProps = {
2
3
  error: Error;
3
4
  isDisabled?: boolean;
4
5
  onClear: () => void;
5
6
  };
6
- export declare const ErrorState: ({ error, isDisabled, onClear }: ErrorStateProps) => JSX.Element;
7
+ export declare const ErrorState: ({ error, isDisabled, onClear }: ErrorStateProps) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const LoadingState: () => JSX.Element;
1
+ import React from 'react';
2
+ export declare const LoadingState: () => React.JSX.Element;
@@ -1,7 +1,8 @@
1
+ import React from 'react';
1
2
  import { Resource } from '../../types';
2
3
  export type SelectedStateProps = {
3
4
  resource: Resource;
4
5
  isDisabled?: boolean;
5
6
  onClear: () => void;
6
7
  };
7
- export declare const SelectedState: ({ resource: { id, type, name, status, squizImage }, isDisabled, onClear, }: SelectedStateProps) => JSX.Element;
8
+ export declare const SelectedState: ({ resource: { id, type, name, status, squizImage }, isDisabled, onClear, }: SelectedStateProps) => React.JSX.Element;
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { DOMAttributes, FocusableElement } from '@react-types/shared';
2
3
  import { Source, Resource, HydratedResourceReference } from '../types';
3
4
  interface ResourcePickerContainerProps {
@@ -9,5 +10,5 @@ interface ResourcePickerContainerProps {
9
10
  onChange(resource: HydratedResourceReference | null): void;
10
11
  onClose: () => void;
11
12
  }
12
- declare function ResourcePickerContainer({ title, titleAriaProps, allowedTypes, onRequestSources, onRequestChildren, onChange, onClose, }: ResourcePickerContainerProps): JSX.Element;
13
+ declare function ResourcePickerContainer({ title, titleAriaProps, allowedTypes, onRequestSources, onRequestChildren, onChange, onClose, }: ResourcePickerContainerProps): React.JSX.Element;
13
14
  export default ResourcePickerContainer;
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import type { Source, ScopedSource } from '../types';
2
3
  export default function SourceDropdown({ sources, selectedSource, isLoading, onRootSelect, onSourceSelect, }: {
3
4
  sources: Source[];
@@ -5,4 +6,4 @@ export default function SourceDropdown({ sources, selectedSource, isLoading, onR
5
6
  isLoading: boolean;
6
7
  onRootSelect: () => void;
7
8
  onSourceSelect: (source: ScopedSource) => void;
8
- }): JSX.Element;
9
+ }): React.JSX.Element;
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { OverlayTriggerState } from 'react-stately';
2
3
  import { DOMAttributes, FocusableElement } from '@react-types/shared';
3
4
  import { Source, ScopedSource } from '../types';
@@ -9,5 +10,5 @@ export interface SourceListProps {
9
10
  handleReload: () => void;
10
11
  error: Error | null;
11
12
  }
12
- declare const SourceList: ({ sources, previewModalState, isLoading, onSourceSelect, handleReload, error, }: SourceListProps) => JSX.Element;
13
+ declare const SourceList: ({ sources, previewModalState, isLoading, onSourceSelect, handleReload, error, }: SourceListProps) => React.JSX.Element;
13
14
  export default SourceList;
@@ -1,7 +1,8 @@
1
+ import React from 'react';
1
2
  import { Status } from '../types';
2
3
  export type StatusIndicatorProps = {
3
4
  className?: string;
4
5
  status: Status;
5
6
  };
6
- declare const StatusIndicator: ({ className, status }: StatusIndicatorProps) => JSX.Element;
7
+ declare const StatusIndicator: ({ className, status }: StatusIndicatorProps) => React.JSX.Element;
7
8
  export default StatusIndicator;
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { HydratedResourceReference, Resource, ResourceReference, Source } from './types';
2
3
  import { ResourceBrowserContext, ResourceBrowserContextProps } from './ResourceBrowserContext/ResourceBrowserContext';
3
4
  export type { HydratedResourceReference, Resource, ResourceReference, Source, ResourceBrowserContextProps };
@@ -10,4 +11,4 @@ export type ResourceBrowserInputProps = {
10
11
  onChange(resource: HydratedResourceReference | null): void;
11
12
  onClear?(): void;
12
13
  };
13
- export declare const ResourceBrowserInput: ({ modalTitle, allowedTypes, onChange, value, isDisabled, onClear, }: ResourceBrowserInputProps) => JSX.Element;
14
+ export declare const ResourceBrowserInput: ({ modalTitle, allowedTypes, onChange, value, isDisabled, onClear, }: ResourceBrowserInputProps) => React.JSX.Element;
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@squiz/resource-browser",
3
- "version": "1.64.1",
3
+ "version": "1.66.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
+ "private": false,
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
6
10
  "scripts": {
7
11
  "compile": "npm run clean && npm run compile:styles && npm run compile:code",
8
12
  "compile:code": "tsc",
@@ -15,8 +19,8 @@
15
19
  },
16
20
  "dependencies": {
17
21
  "@mui/icons-material": "5.11.16",
18
- "@squiz/dx-json-schema-lib": "1.64.0",
19
- "@squiz/generic-browser-lib": "1.64.0",
22
+ "@squiz/dx-json-schema-lib": "^1.65.0",
23
+ "@squiz/generic-browser-lib": "^1.65.0",
20
24
  "pretty-bytes": "5.6.0",
21
25
  "react-aria": "3.23.1",
22
26
  "react-responsive": "9.0.2",
@@ -35,8 +39,8 @@
35
39
  "@testing-library/react": "14.0.0",
36
40
  "@testing-library/user-event": "14.4.3",
37
41
  "@types/postcss-js": "4.0.0",
38
- "@types/react": "18.0.26",
39
- "@types/react-dom": "18.0.9",
42
+ "@types/react": "^18.2.45",
43
+ "@types/react-dom": "^18.2.18",
40
44
  "@vitejs/plugin-react-swc": "3.0.0",
41
45
  "autoprefixer": "10.4.14",
42
46
  "esbuild": "0.17.17",
@@ -19,7 +19,7 @@ describe('useResourcePath', () => {
19
19
  });
20
20
  });
21
21
 
22
- it('setSource should update the source and clear the current hierarchy', async () => {
22
+ it('setSource should update the source and clear the current hierarchy', () => {
23
23
  const { result } = renderHook(() => useResourcePath());
24
24
  const source = mockScopedSource({
25
25
  source: { id: '1', name: 'Test source' },
@@ -27,15 +27,15 @@ describe('useResourcePath', () => {
27
27
  });
28
28
  const resource = mockResource({ id: '3', name: 'Test resource 2' });
29
29
 
30
- await act(() => result.current.setSource(source));
31
- await act(() => result.current.push(resource));
30
+ act(() => result.current.setSource(source));
31
+ act(() => result.current.push(resource));
32
32
 
33
33
  // make sure the current resource/hierarchy is populated
34
34
  expect(result.current.currentResource).toBe(resource);
35
35
  expect(result.current.hierarchy).toHaveLength(2);
36
36
 
37
37
  // set the source again
38
- await act(() => result.current.setSource(source));
38
+ act(() => result.current.setSource(source));
39
39
 
40
40
  // make sure the current resource and hierarchy are reset
41
41
  expect(result.current.source).toBe(source);
@@ -43,15 +43,15 @@ describe('useResourcePath', () => {
43
43
  expect(result.current.hierarchy).toEqual([{ key: 'source:1-resource:2', label: 'Test resource', node: source }]);
44
44
  });
45
45
 
46
- it('push should add the node to the hierarchy', async () => {
46
+ it('push should add the node to the hierarchy', () => {
47
47
  const { result } = renderHook(() => useResourcePath());
48
48
  const source = mockScopedSource({ source: { id: '1' } });
49
49
  const site = mockResource({ id: '1', type: { code: 'site', name: 'Site' }, name: 'My site' });
50
50
  const page = mockResource({ id: '2', type: { code: 'page', name: 'Page' }, name: 'My page' });
51
51
 
52
- await act(() => result.current.setSource(source));
53
- await act(() => result.current.push(site));
54
- await act(() => result.current.push(page));
52
+ act(() => result.current.setSource(source));
53
+ act(() => result.current.push(site));
54
+ act(() => result.current.push(page));
55
55
 
56
56
  expect(result.current.source).toBe(source);
57
57
  expect(result.current.currentResource).toBe(page);
@@ -94,11 +94,7 @@ describe('useResourcePath', () => {
94
94
  ],
95
95
  ])(
96
96
  'popUntil should remove from the hierarchy until the node being popped to is hit - %s',
97
- async (
98
- description: string,
99
- node: ScopedSource | Resource,
100
- expectedHierarchy: Hierarchy<ScopedSource | Resource>,
101
- ) => {
97
+ (description: string, node: ScopedSource | Resource, expectedHierarchy: Hierarchy<ScopedSource | Resource>) => {
102
98
  const { result } = renderHook(() => useResourcePath());
103
99
  const source = mockScopedSource({ source: { id: '1' } });
104
100
  const mockResources = [
@@ -107,16 +103,16 @@ describe('useResourcePath', () => {
107
103
  mockResource({ id: '3', name: 'Resource 3' }),
108
104
  ];
109
105
 
110
- await act(() => result.current.setSource(source));
111
- await act(() => result.current.push(mockResources[0]));
112
- await act(() => result.current.push(mockResources[1]));
113
- await act(() => result.current.push(mockResources[2]));
106
+ act(() => result.current.setSource(source));
107
+ act(() => result.current.push(mockResources[0]));
108
+ act(() => result.current.push(mockResources[1]));
109
+ act(() => result.current.push(mockResources[2]));
114
110
 
115
111
  // make sure hierarchy has expected length before popping
116
112
  expect(result.current.source).toBe(source);
117
113
  expect(result.current.hierarchy).toHaveLength(4);
118
114
 
119
- await act(() => result.current.popUntil(node));
115
+ act(() => result.current.popUntil(node));
120
116
 
121
117
  expect(result.current.hierarchy).toEqual(expectedHierarchy);
122
118
  },
@@ -154,6 +154,19 @@
154
154
  },
155
155
  "name": "Word document",
156
156
  "childCount": 0
157
+ },
158
+ {
159
+ "id": "111",
160
+ "type": {
161
+ "code": "page_content",
162
+ "name": "Content Page"
163
+ },
164
+ "status": {
165
+ "code": "live",
166
+ "name": "Live"
167
+ },
168
+ "name": "Content page",
169
+ "childCount": 0
157
170
  }
158
171
  ]
159
172
  },