@squiz/resource-browser 1.69.2 → 2.1.8-rc.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 +85 -38
- package/LICENSE.md +15 -0
- package/README.md +9 -0
- package/jest.config.ts +22 -21
- package/lib/Hooks/useSelectedState.d.ts +15 -0
- package/lib/Hooks/useSelectedState.js +16 -0
- package/lib/Hooks/useSources.d.ts +5 -4
- package/lib/Hooks/useSources.js +25 -1
- package/lib/MainContainer/MainContainer.d.ts +17 -0
- package/lib/MainContainer/MainContainer.js +61 -0
- package/lib/Plugin/Plugin.d.ts +13 -0
- package/lib/Plugin/Plugin.js +17 -0
- package/lib/ResourceBrowserContext/ResourceBrowserContext.d.ts +2 -3
- package/lib/ResourceBrowserContext/ResourceBrowserContext.js +4 -17
- package/lib/ResourceBrowserInput/ResourceBrowserInput.d.ts +24 -0
- package/lib/ResourceBrowserInput/ResourceBrowserInput.js +16 -0
- package/lib/ResourcePicker/ResourcePicker.d.ts +6 -4
- package/lib/ResourcePicker/ResourcePicker.js +14 -8
- package/lib/ResourcePicker/States/Selected.d.ts +10 -4
- package/lib/ResourcePicker/States/Selected.js +11 -32
- package/lib/SourceDropdown/SourceDropdown.d.ts +5 -11
- package/lib/SourceDropdown/SourceDropdown.js +20 -99
- package/lib/SourceList/SourceList.d.ts +5 -16
- package/lib/SourceList/SourceList.js +14 -75
- package/lib/index.css +42 -202
- package/lib/index.d.ts +7 -7
- package/lib/index.js +69 -13
- package/lib/types.d.ts +41 -59
- package/package.json +82 -80
- package/src/Hooks/useSelectedState.spec.ts +46 -0
- package/src/Hooks/useSelectedState.ts +22 -0
- package/src/Hooks/useSources.spec.ts +30 -12
- package/src/Hooks/useSources.ts +33 -4
- package/src/Icons/CircledLoopIcon.tsx +8 -8
- package/src/MainContainer/MainContainer.spec.tsx +203 -0
- package/src/MainContainer/MainContainer.stories.tsx +62 -0
- package/src/MainContainer/MainContainer.tsx +101 -0
- package/src/Plugin/Plugin.spec.tsx +46 -0
- package/src/Plugin/Plugin.tsx +20 -0
- package/src/ResourceBrowserContext/ResourceBrowserContext.spec.tsx +65 -106
- package/src/ResourceBrowserContext/ResourceBrowserContext.tsx +24 -39
- package/src/ResourceBrowserInput/ResourceBrowserInput.spec.tsx +192 -0
- package/src/ResourceBrowserInput/ResourceBrowserInput.tsx +81 -0
- package/src/ResourcePicker/ResourcePicker.spec.tsx +159 -116
- package/src/ResourcePicker/ResourcePicker.stories.tsx +28 -24
- package/src/ResourcePicker/ResourcePicker.tsx +79 -59
- package/src/ResourcePicker/States/Error.tsx +8 -8
- package/src/ResourcePicker/States/Loading.tsx +3 -3
- package/src/ResourcePicker/States/Selected.tsx +66 -73
- package/src/ResourcePicker/mock-image-resource.json +25 -47
- package/src/ResourcePicker/mock-resource.json +11 -13
- package/src/ResourcePicker/resource-picker.scss +13 -13
- package/src/SourceDropdown/SourceDropdown.spec.tsx +65 -391
- package/src/SourceDropdown/SourceDropdown.stories.tsx +21 -24
- package/src/SourceDropdown/SourceDropdown.tsx +80 -258
- package/src/SourceList/SourceList.spec.tsx +37 -430
- package/src/SourceList/SourceList.stories.tsx +17 -37
- package/src/SourceList/SourceList.tsx +28 -155
- package/src/__mocks__/MockModels.ts +56 -25
- package/src/__mocks__/PluginExample.tsx +98 -0
- package/src/__mocks__/StorybookHelpers.tsx +141 -0
- package/src/__mocks__/renderWithContext.tsx +14 -18
- package/src/__mocks__/sample-sources.json +32 -0
- package/src/index.scss +18 -8
- package/src/index.spec.tsx +277 -99
- package/src/index.stories.tsx +65 -39
- package/src/index.tsx +119 -57
- package/src/types.ts +54 -63
- package/tailwind.config.cjs +92 -92
- package/vite.config.js +12 -12
- package/lib/Hooks/useCategorisedSources.d.ts +0 -14
- package/lib/Hooks/useCategorisedSources.js +0 -38
- package/lib/Hooks/useChildResources.d.ts +0 -16
- package/lib/Hooks/useChildResources.js +0 -13
- package/lib/Hooks/usePreselectedResourcePath.d.ts +0 -20
- package/lib/Hooks/usePreselectedResourcePath.js +0 -31
- package/lib/Hooks/useRecentLocations.d.ts +0 -5
- package/lib/Hooks/useRecentLocations.js +0 -38
- package/lib/Hooks/useRecentResourcesPaths.d.ts +0 -20
- package/lib/Hooks/useRecentResourcesPaths.js +0 -30
- package/lib/Hooks/useResource.d.ts +0 -28
- package/lib/Hooks/useResource.js +0 -25
- package/lib/Hooks/useResourcePath.d.ts +0 -16
- package/lib/Hooks/useResourcePath.js +0 -64
- package/lib/Icons/HistoryIcon.d.ts +0 -4
- package/lib/Icons/HistoryIcon.js +0 -13
- package/lib/PreviewPanel/PreviewPanel.d.ts +0 -5
- package/lib/PreviewPanel/PreviewPanel.js +0 -8
- package/lib/PreviewPanel/details/MatrixResource.d.ts +0 -7
- package/lib/PreviewPanel/details/MatrixResource.js +0 -35
- package/lib/ResourceBreadcrumb/ResourceBreadcrumb.d.ts +0 -9
- package/lib/ResourceBreadcrumb/ResourceBreadcrumb.js +0 -54
- package/lib/ResourceList/ResourceList.d.ts +0 -18
- package/lib/ResourceList/ResourceList.js +0 -49
- package/lib/ResourcePickerContainer/ResourcePickerContainer.d.ts +0 -17
- package/lib/ResourcePickerContainer/ResourcePickerContainer.js +0 -166
- package/lib/StatusIndicator/StatusIndicator.d.ts +0 -8
- package/lib/StatusIndicator/StatusIndicator.js +0 -27
- package/lib/utils/findBestMatchLineage.d.ts +0 -2
- package/lib/utils/findBestMatchLineage.js +0 -28
- package/lib/utils/uuid.d.ts +0 -1
- package/lib/utils/uuid.js +0 -6
- package/src/Hooks/useCategorisedSources.spec.ts +0 -39
- package/src/Hooks/useCategorisedSources.ts +0 -46
- package/src/Hooks/useChildResources.spec.ts +0 -29
- package/src/Hooks/useChildResources.ts +0 -21
- package/src/Hooks/usePreselectedResourcePath.ts +0 -54
- package/src/Hooks/useRecentLocations.spec.ts +0 -81
- package/src/Hooks/useRecentLocations.ts +0 -44
- package/src/Hooks/useRecentResourcesPaths.ts +0 -54
- package/src/Hooks/useResource.spec.ts +0 -61
- package/src/Hooks/useResource.ts +0 -40
- package/src/Hooks/useResourcePath.spec.ts +0 -120
- package/src/Hooks/useResourcePath.ts +0 -76
- package/src/Icons/HistoryIcon.tsx +0 -17
- package/src/PreviewPanel/PreviewPanel.spec.tsx +0 -198
- package/src/PreviewPanel/PreviewPanel.stories.tsx +0 -76
- package/src/PreviewPanel/PreviewPanel.tsx +0 -6
- package/src/PreviewPanel/details/MatrixResource.tsx +0 -54
- package/src/PreviewPanel/details/matrix-resource.scss +0 -16
- package/src/ResourceBreadcrumb/ResourceBreadcrumb.spec.tsx +0 -133
- package/src/ResourceBreadcrumb/ResourceBreadcrumb.stories.tsx +0 -24
- package/src/ResourceBreadcrumb/ResourceBreadcrumb.tsx +0 -79
- package/src/ResourceBreadcrumb/resource-breadcrumb.scss +0 -28
- package/src/ResourceBreadcrumb/sample-hierarchy.json +0 -27
- package/src/ResourceList/ResourceList.spec.tsx +0 -202
- package/src/ResourceList/ResourceList.stories.tsx +0 -40
- package/src/ResourceList/ResourceList.tsx +0 -83
- package/src/ResourceList/sample-resources.json +0 -851
- package/src/ResourcePickerContainer/ResourcePickerContainer.spec.tsx +0 -780
- package/src/ResourcePickerContainer/ResourcePickerContainer.stories.tsx +0 -45
- package/src/ResourcePickerContainer/ResourcePickerContainer.tsx +0 -290
- package/src/SourceList/sample-sources.json +0 -251
- package/src/StatusIndicator/StatusIndicator.stories.tsx +0 -83
- package/src/StatusIndicator/StatusIndicator.tsx +0 -38
- package/src/__mocks__/JestHelpers.ts +0 -65
- package/src/__mocks__/StorybookHelpers.ts +0 -128
- package/src/__mocks__/jestHelpers.spec.ts +0 -38
- package/src/utils/findBestMatchLineage.spec.ts +0 -81
- package/src/utils/findBestMatchLineage.ts +0 -30
- package/src/utils/uuid.ts +0 -5
package/CHANGELOG.md
CHANGED
@@ -1,107 +1,154 @@
|
|
1
|
-
#
|
1
|
+
# Change Log
|
2
2
|
|
3
|
-
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
4
5
|
|
5
|
-
|
6
|
+
## 2.1.8-rc.0 (2024-05-30)
|
6
7
|
|
7
|
-
|
8
|
+
**Note:** Version bump only for package @squiz/resource-browser
|
8
9
|
|
9
|
-
## 1.
|
10
|
+
## [2.1.7-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser-v2@2.1.6-rc.0...@squiz/resource-browser-v2@2.1.7-rc.0) (2024-05-27)
|
10
11
|
|
11
|
-
|
12
|
+
**Note:** Version bump only for package @squiz/resource-browser-v2
|
12
13
|
|
13
|
-
-
|
14
|
+
## [2.1.6-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser-v2@2.1.5-rc.0...@squiz/resource-browser-v2@2.1.6-rc.0) (2024-05-27)
|
14
15
|
|
15
|
-
|
16
|
+
**Note:** Version bump only for package @squiz/resource-browser-v2
|
16
17
|
|
17
|
-
|
18
|
+
## [2.1.5-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser-v2@2.1.4-rc.0...@squiz/resource-browser-v2@2.1.5-rc.0) (2024-05-23)
|
18
19
|
|
19
|
-
|
20
|
+
**Note:** Version bump only for package @squiz/resource-browser-v2
|
20
21
|
|
21
|
-
## 1.
|
22
|
+
## [2.1.4-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser-v2@2.1.3-rc.0...@squiz/resource-browser-v2@2.1.4-rc.0) (2024-05-20)
|
22
23
|
|
23
|
-
|
24
|
+
**Note:** Version bump only for package @squiz/resource-browser-v2
|
24
25
|
|
25
|
-
-
|
26
|
-
- Updated dependencies [7c324d7]
|
27
|
-
- @squiz/generic-browser-lib@1.67.0
|
26
|
+
## [2.1.3-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser-v2@2.1.2-rc.0...@squiz/resource-browser-v2@2.1.3-rc.0) (2024-05-20)
|
28
27
|
|
29
|
-
|
28
|
+
**Note:** Version bump only for package @squiz/resource-browser-v2
|
30
29
|
|
31
|
-
|
30
|
+
## [2.1.2-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser-v2@2.1.1-rc.0...@squiz/resource-browser-v2@2.1.2-rc.0) (2024-05-15)
|
31
|
+
|
32
|
+
**Note:** Version bump only for package @squiz/resource-browser-v2
|
33
|
+
|
34
|
+
## [2.1.1-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser-v2@2.1.0-rc.0...@squiz/resource-browser-v2@2.1.1-rc.0) (2024-05-13)
|
35
|
+
|
36
|
+
**Note:** Version bump only for package @squiz/resource-browser-v2
|
37
|
+
|
38
|
+
# [2.1.0-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser-v2@2.0.9-rc.0...@squiz/resource-browser-v2@2.1.0-rc.0) (2024-05-13)
|
39
|
+
|
40
|
+
### Features
|
41
|
+
|
42
|
+
- **prodam-133:** add source dropdown to rb wrapper ([a258b0f](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/commit/a258b0febebca94aad1885f602d6a10a323ab95f))
|
43
|
+
|
44
|
+
## [2.0.9-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser-v2@2.0.8-rc.0...@squiz/resource-browser-v2@2.0.9-rc.0) (2024-05-13)
|
45
|
+
|
46
|
+
**Note:** Version bump only for package @squiz/resource-browser-v2
|
47
|
+
|
48
|
+
## [2.0.8-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser-v2@2.0.7-rc.0...@squiz/resource-browser-v2@2.0.8-rc.0) (2024-05-10)
|
49
|
+
|
50
|
+
**Note:** Version bump only for package @squiz/resource-browser-v2
|
32
51
|
|
33
|
-
-
|
52
|
+
## [2.0.7-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser-v2@2.0.6-rc.0...@squiz/resource-browser-v2@2.0.7-rc.0) (2024-05-09)
|
53
|
+
|
54
|
+
**Note:** Version bump only for package @squiz/resource-browser-v2
|
55
|
+
|
56
|
+
## [2.0.6-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser-v2@2.0.5-rc.0...@squiz/resource-browser-v2@2.0.6-rc.0) (2024-05-07)
|
57
|
+
|
58
|
+
**Note:** Version bump only for package @squiz/resource-browser-v2
|
59
|
+
|
60
|
+
## [2.0.5-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser-v2@2.0.4-rc.0...@squiz/resource-browser-v2@2.0.5-rc.0) (2024-05-07)
|
61
|
+
|
62
|
+
**Note:** Version bump only for package @squiz/resource-browser-v2
|
63
|
+
|
64
|
+
## [2.0.4-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser-v2@2.0.3-rc.0...@squiz/resource-browser-v2@2.0.4-rc.0) (2024-05-03)
|
65
|
+
|
66
|
+
**Note:** Version bump only for package @squiz/resource-browser-v2
|
67
|
+
|
68
|
+
## [2.0.3-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser-v2@2.0.2-rc.0...@squiz/resource-browser-v2@2.0.3-rc.0) (2024-05-02)
|
69
|
+
|
70
|
+
**Note:** Version bump only for package @squiz/resource-browser-v2
|
71
|
+
|
72
|
+
## [2.0.2-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser-v2@2.0.1-rc.0...@squiz/resource-browser-v2@2.0.2-rc.0) (2024-04-29)
|
73
|
+
|
74
|
+
**Note:** Version bump only for package @squiz/resource-browser-v2
|
75
|
+
|
76
|
+
## 2.0.1-rc.0 (2024-04-26)
|
77
|
+
|
78
|
+
**Note:** Version bump only for package @squiz/resource-browser-v2
|
79
|
+
|
80
|
+
# @squiz/resource-browser
|
34
81
|
|
35
82
|
## 1.67.1
|
36
83
|
|
37
84
|
### Patch Changes
|
38
85
|
|
39
|
-
-
|
86
|
+
- 9e4cad8: Fixed minor issue with finding best matched lineage in resource browser
|
40
87
|
|
41
88
|
## 1.67.0
|
42
89
|
|
43
90
|
### Minor Changes
|
44
91
|
|
45
|
-
-
|
92
|
+
- 5fa9b39: Updated resource browser to allow replacing the previously selected resource. Replacing will open the resource browser to the location where the resource resides.
|
46
93
|
|
47
94
|
### Patch Changes
|
48
95
|
|
49
|
-
-
|
50
|
-
-
|
51
|
-
|
52
|
-
|
96
|
+
- Updated dependencies [5fa9b39]
|
97
|
+
- Updated dependencies [5fa9b39]
|
98
|
+
- @squiz/dx-json-schema-lib@1.67.0
|
99
|
+
- @squiz/generic-browser-lib@1.66.0
|
53
100
|
|
54
101
|
## 1.66.3
|
55
102
|
|
56
103
|
### Patch Changes
|
57
104
|
|
58
|
-
-
|
105
|
+
- 8421756: Selected image assets in the resource browser will now display the actual image instead of just the image asset icon if they have a URL specified
|
59
106
|
|
60
107
|
## 1.66.2
|
61
108
|
|
62
109
|
### Patch Changes
|
63
110
|
|
64
|
-
-
|
111
|
+
- 6d41052: Added white background to resource picker input to avoid it inheriting the background colour of its parent element.
|
65
112
|
|
66
113
|
## 1.66.1
|
67
114
|
|
68
115
|
### Patch Changes
|
69
116
|
|
70
|
-
-
|
71
|
-
|
117
|
+
- 81c7cba: Image asset previews will now display the image if there is a URL in the returned resource data
|
118
|
+
Also fixes a bug around the selected resource name not having break-word applied so the filename was not wrapping as expected
|
72
119
|
|
73
120
|
## 1.66.0
|
74
121
|
|
75
122
|
### Minor Changes
|
76
123
|
|
77
|
-
-
|
124
|
+
- 5032c38: Added content page asset icon.
|
78
125
|
|
79
126
|
### Patch Changes
|
80
127
|
|
81
|
-
-
|
82
|
-
|
128
|
+
- Updated dependencies [5032c38]
|
129
|
+
- @squiz/generic-browser-lib@1.65.0
|
83
130
|
|
84
131
|
## 1.65.0
|
85
132
|
|
86
133
|
### Minor Changes
|
87
134
|
|
88
|
-
-
|
135
|
+
- ac68ec6: Unpinned Squiz dependencies, they should now be following semver.
|
89
136
|
|
90
137
|
### Patch Changes
|
91
138
|
|
92
|
-
-
|
93
|
-
|
139
|
+
- Updated dependencies [ac68ec6]
|
140
|
+
- @squiz/dx-json-schema-lib@1.65.0
|
94
141
|
|
95
142
|
## 1.64.1
|
96
143
|
|
97
144
|
### Patch Changes
|
98
145
|
|
99
|
-
-
|
100
|
-
|
101
|
-
|
146
|
+
- Updated dependencies [e717e6e]
|
147
|
+
- @squiz/generic-browser-lib@1.64.0
|
148
|
+
- @squiz/dx-json-schema-lib@1.64.0
|
102
149
|
|
103
150
|
## 1.64.0
|
104
151
|
|
105
152
|
### Minor Changes
|
106
153
|
|
107
|
-
-
|
154
|
+
- e7d4c0f: Updated disabled styling for component-editing-ui & resource browser
|
package/LICENSE.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
This software is copyright Squiz and may only be used with the explicit
|
2
|
+
permission of the copyright holder.
|
3
|
+
|
4
|
+
1. Squiz shall make the Services available to You pursuant to your Agreement and these terms.
|
5
|
+
2. Squiz shall provide the Services only in accordance with applicable laws and government regulations and where applicable your Agreement.
|
6
|
+
3. You shall:
|
7
|
+
(a) be responsible for Your compliance with these terms and the Agreement;
|
8
|
+
(b) prevent unauthorised access to or use of the Services, and notify Squiz promptly of any such unauthorised access or use, and
|
9
|
+
(c) use the Services only in accordance with the Documentation and applicable laws and government regulations.
|
10
|
+
4. You shall not:
|
11
|
+
(a) sell, resell, rent or lease the Services;
|
12
|
+
(b) use the Services to store or transmit Malicious Code;
|
13
|
+
(c) interfere with or disrupt the integrity or performance of the Services or third-party data contained therein, or
|
14
|
+
(d) attempt to gain unauthorised access to the Services or their related systems or networks.
|
15
|
+
5. You acknowledge that Squiz retains ownership of the Software, the Documentation and the source code and all proprietary rights relating thereto and You agree all Intellectual Property Rights in the Software and Documentation are and shall remain the exclusive property of Squiz and its third party suppliers, as applicable. Unless expressly permitted in this Subscription Agreement, You must not use any of Squiz's or its third party suppliers' intellectual property without Squiz or its third party suppliers' prior written consent. Nothing in these terms should be construed as transferring any aspects of such rights mentioned in this clause to You or any Third Party. Squiz reserves any and all rights not expressly granted herein.
|
package/README.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Resource Browser
|
2
|
+
|
3
|
+
The Resource Browser is a generic frontend intended for use across the Squiz DXP when a end user needs to browse for and select a resource via a React frontend UI. It is intended to allow rendering of various compatible sources and to move from one source to another seamlessly. It is not intended to provide an actual UI for any specific datasource; these must be provided via the plugin framework.
|
4
|
+
|
5
|
+
## Plugins
|
6
|
+
|
7
|
+
The Resource Browser does not know how to interface with any source systems; this support needs to be plugged into it. A plugin interface has been defined to allow any source system to be added into the Resource Browser as needed with as complex a UI as that source needs. These plugin can be defined inline when simple (e.g testing) or published to NPM as a packages and consumed by a specific application.
|
8
|
+
|
9
|
+
An example plugin with comments as documentation can be found [here](./src/__mocks__/PluginExample.tsx).
|
package/jest.config.ts
CHANGED
@@ -2,28 +2,29 @@ import type { Config } from 'jest';
|
|
2
2
|
|
3
3
|
// Sync object
|
4
4
|
const config: Config = {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
preset: 'ts-jest',
|
6
|
+
clearMocks: true,
|
7
|
+
collectCoverage: true,
|
8
|
+
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/**/*.stories.{ts,tsx}'],
|
9
|
+
coverageThreshold: {
|
10
|
+
global: {
|
11
|
+
branches: 90,
|
12
|
+
functions: 90,
|
13
|
+
lines: 90,
|
14
|
+
statements: 90,
|
15
|
+
},
|
15
16
|
},
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
17
|
+
errorOnDeprecated: true,
|
18
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
|
19
|
+
testTimeout: 60_000,
|
20
|
+
testEnvironment: 'jsdom',
|
21
|
+
testPathIgnorePatterns: ['/lib/', `/node_modules/`],
|
22
|
+
maxWorkers: 1,
|
23
|
+
moduleNameMapper: {
|
24
|
+
'^.+\\.(css|scss)$': '<rootDir>/src/__mocks__/styleMock.ts',
|
25
|
+
'^@squiz/resource-browser-ui-lib$': '<rootDir>/../resource-browser-ui-lib/src/index',
|
26
|
+
},
|
27
|
+
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
|
27
28
|
};
|
28
29
|
|
29
30
|
export default config;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { ResourceBrowserPlugin, ResourceBrowserResource } from '../types';
|
2
|
+
type UseResourceProps = {
|
3
|
+
plugin: ResourceBrowserPlugin | null;
|
4
|
+
resource: ResourceBrowserResource | null;
|
5
|
+
};
|
6
|
+
/**
|
7
|
+
* Loads the selected state for the provided resource
|
8
|
+
*/
|
9
|
+
export declare const useSelectedState: ({ plugin, resource }: UseResourceProps) => {
|
10
|
+
data: import("../types").ResourceBrowserSelectedState | null;
|
11
|
+
error: Error | null;
|
12
|
+
isLoading: boolean;
|
13
|
+
reload: () => void;
|
14
|
+
};
|
15
|
+
export {};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.useSelectedState = void 0;
|
4
|
+
const generic_browser_lib_1 = require("@squiz/generic-browser-lib");
|
5
|
+
/**
|
6
|
+
* Loads the selected state for the provided resource
|
7
|
+
*/
|
8
|
+
const useSelectedState = ({ plugin, resource }) => {
|
9
|
+
// Find the resolver for this resource
|
10
|
+
const renderSelectedResource = resource && plugin?.renderSelectedResource;
|
11
|
+
return (0, generic_browser_lib_1.useAsync)({
|
12
|
+
callback: () => (resource && renderSelectedResource ? renderSelectedResource(resource) : null),
|
13
|
+
defaultValue: null,
|
14
|
+
}, [resource]);
|
15
|
+
};
|
16
|
+
exports.useSelectedState = useSelectedState;
|
@@ -1,12 +1,13 @@
|
|
1
|
-
import {
|
1
|
+
import { ResourceBrowserSource, ResourceBrowserPlugin } from '../types';
|
2
2
|
type UseSourcesProps = {
|
3
|
-
onRequestSources: () => Promise<
|
3
|
+
onRequestSources: () => Promise<ResourceBrowserSource[]>;
|
4
|
+
plugins: Array<ResourceBrowserPlugin>;
|
4
5
|
};
|
5
6
|
/**
|
6
7
|
* Loads and caches the source list when a component using the hook is mounted.
|
7
8
|
*/
|
8
|
-
export declare const useSources: ({ onRequestSources }: UseSourcesProps) => {
|
9
|
-
data:
|
9
|
+
export declare const useSources: ({ onRequestSources, plugins }: UseSourcesProps) => {
|
10
|
+
data: ResourceBrowserSource[];
|
10
11
|
error: Error | null;
|
11
12
|
isLoading: boolean;
|
12
13
|
reload: () => void;
|
package/lib/Hooks/useSources.js
CHANGED
@@ -5,5 +5,29 @@ const generic_browser_lib_1 = require("@squiz/generic-browser-lib");
|
|
5
5
|
/**
|
6
6
|
* Loads and caches the source list when a component using the hook is mounted.
|
7
7
|
*/
|
8
|
-
const useSources = ({ onRequestSources }) =>
|
8
|
+
const useSources = ({ onRequestSources, plugins }) => {
|
9
|
+
return (0, generic_browser_lib_1.useAsync)({
|
10
|
+
callback: () => {
|
11
|
+
return new Promise((resolve, reject) => {
|
12
|
+
// Get all the sources from the outer context
|
13
|
+
onRequestSources()
|
14
|
+
.then((sources) => {
|
15
|
+
// Remove any sources which we don't have a plugin to handle
|
16
|
+
resolve(sources.filter((source) => {
|
17
|
+
return !!plugins.find((plugin) => {
|
18
|
+
if (plugin.type === source.type) {
|
19
|
+
return true;
|
20
|
+
}
|
21
|
+
return false;
|
22
|
+
});
|
23
|
+
}));
|
24
|
+
})
|
25
|
+
.catch((e) => {
|
26
|
+
reject(e);
|
27
|
+
});
|
28
|
+
});
|
29
|
+
},
|
30
|
+
defaultValue: [],
|
31
|
+
}, [plugins]);
|
32
|
+
};
|
9
33
|
exports.useSources = useSources;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { DOMAttributes, FocusableElement } from '@react-types/shared';
|
3
|
+
import { ResourceBrowserPlugin, ResourceBrowserSource, ResourceBrowserResource } from '../types';
|
4
|
+
interface MainContainerProps {
|
5
|
+
title: string;
|
6
|
+
titleAriaProps: DOMAttributes<FocusableElement>;
|
7
|
+
allowedTypes: string[] | undefined;
|
8
|
+
sources: ResourceBrowserSource[];
|
9
|
+
selectedSource: ResourceBrowserSource | null;
|
10
|
+
onSourceSelect(source: ResourceBrowserSource | null): void;
|
11
|
+
onChange(resource: ResourceBrowserResource | null): void;
|
12
|
+
onClose: () => void;
|
13
|
+
preselectedResource?: ResourceBrowserResource | null;
|
14
|
+
plugin: ResourceBrowserPlugin | null;
|
15
|
+
}
|
16
|
+
declare function MainContainer({ title, titleAriaProps, allowedTypes, sources, selectedSource, onSourceSelect, onChange, onClose, preselectedResource, plugin, }: MainContainerProps): React.JSX.Element;
|
17
|
+
export default MainContainer;
|
@@ -0,0 +1,61 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
+
};
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
const react_1 = __importStar(require("react"));
|
30
|
+
const SourceDropdown_1 = __importDefault(require("../SourceDropdown/SourceDropdown"));
|
31
|
+
const SourceList_1 = __importDefault(require("../SourceList/SourceList"));
|
32
|
+
function MainContainer({ title, titleAriaProps, allowedTypes, sources, selectedSource, onSourceSelect, onChange, onClose, preselectedResource, plugin, }) {
|
33
|
+
const [headerPortal, setHeaderPortal] = (0, react_1.useState)(null);
|
34
|
+
const SourceBrowser = plugin?.sourceBrowserComponent();
|
35
|
+
// Can't use a useRef as it wont update on change when a source is selected, so need to use a ref callback to store in state
|
36
|
+
const setHeaderPortalRef = (0, react_1.useCallback)((node) => {
|
37
|
+
if (node !== null) {
|
38
|
+
setHeaderPortal(node);
|
39
|
+
}
|
40
|
+
}, [setHeaderPortal]);
|
41
|
+
// MainContainer will either render the source list view if no source is set or the plugins UI if a source has been selected
|
42
|
+
return (react_1.default.createElement("div", { className: "relative flex flex-col h-full text-gray-800" },
|
43
|
+
react_1.default.createElement("div", { className: "flex items-center p-4.5" },
|
44
|
+
react_1.default.createElement("h2", { ...titleAriaProps, className: "text-xl leading-6 text-gray-800 font-semibold mr-6" },
|
45
|
+
!plugin && 'Environment Selector',
|
46
|
+
plugin && title),
|
47
|
+
plugin && selectedSource && (react_1.default.createElement(react_1.default.Fragment, null,
|
48
|
+
sources.length > 1 && (react_1.default.createElement("div", { className: "px-3 border-l border-gray-300 w-300px" },
|
49
|
+
react_1.default.createElement(SourceDropdown_1.default, { sources: sources, selectedSource: selectedSource, onSourceSelect: onSourceSelect }))),
|
50
|
+
plugin.createHeaderPortal && (react_1.default.createElement("div", { ref: setHeaderPortalRef, className: "px-3 border-l border-gray-300 w-300px" })))),
|
51
|
+
react_1.default.createElement("button", { type: "button", "aria-label": `Close ${title} dialog`, onClick: onClose, className: "absolute top-2 right-2 p-2.5 rounded hover:bg-blue-100 focus:bg-blue-100" },
|
52
|
+
react_1.default.createElement("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
53
|
+
react_1.default.createElement("path", { d: "M13.3 0.710017C13.1131 0.522765 12.8595 0.417532 12.595 0.417532C12.3305 0.417532 12.0768 0.522765 11.89 0.710017L6.99997 5.59002L2.10997 0.700017C1.92314 0.512765 1.66949 0.407532 1.40497 0.407532C1.14045 0.407532 0.886802 0.512765 0.699971 0.700017C0.309971 1.09002 0.309971 1.72002 0.699971 2.11002L5.58997 7.00002L0.699971 11.89C0.309971 12.28 0.309971 12.91 0.699971 13.3C1.08997 13.69 1.71997 13.69 2.10997 13.3L6.99997 8.41002L11.89 13.3C12.28 13.69 12.91 13.69 13.3 13.3C13.69 12.91 13.69 12.28 13.3 11.89L8.40997 7.00002L13.3 2.11002C13.68 1.73002 13.68 1.09002 13.3 0.710017Z", fill: "currentColor" })))),
|
54
|
+
react_1.default.createElement("div", { className: "border-t border-gray-300 h-[calc(100%-72px)]" },
|
55
|
+
plugin && selectedSource && SourceBrowser && (react_1.default.createElement(SourceBrowser, { source: selectedSource, allowedTypes: allowedTypes, headerPortal: plugin.createHeaderPortal && headerPortal ? headerPortal : undefined, preselectedResource: preselectedResource || undefined, onSelected: (resource) => {
|
56
|
+
onChange(resource);
|
57
|
+
onClose();
|
58
|
+
} })),
|
59
|
+
!selectedSource && react_1.default.createElement(SourceList_1.default, { sources: sources, onSourceSelect: onSourceSelect }))));
|
60
|
+
}
|
61
|
+
exports.default = MainContainer;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { ResourceBrowserInputProps } from '../ResourceBrowserInput/ResourceBrowserInput';
|
3
|
+
/**
|
4
|
+
* This plugin component exsits to deal with React rules of Hooks stupidity.
|
5
|
+
*
|
6
|
+
* For it to not freak out when we want to change from one plugin to another we have to render
|
7
|
+
* something to the ReactDom for each plugin and 'activate' that component when that plugin
|
8
|
+
* needs to render its UI etc.
|
9
|
+
*/
|
10
|
+
export type PluginRenderType = ResourceBrowserInputProps & {
|
11
|
+
render: boolean;
|
12
|
+
};
|
13
|
+
export declare const PluginRender: ({ render, ...props }: PluginRenderType) => React.JSX.Element;
|
@@ -0,0 +1,17 @@
|
|
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
|
+
exports.PluginRender = void 0;
|
7
|
+
const react_1 = __importDefault(require("react"));
|
8
|
+
const ResourceBrowserInput_1 = require("../ResourceBrowserInput/ResourceBrowserInput");
|
9
|
+
const PluginRender = ({ render, ...props }) => {
|
10
|
+
if (render) {
|
11
|
+
return react_1.default.createElement(ResourceBrowserInput_1.ResourceBrowserInput, { ...props });
|
12
|
+
}
|
13
|
+
else {
|
14
|
+
return react_1.default.createElement(react_1.default.Fragment, null);
|
15
|
+
}
|
16
|
+
};
|
17
|
+
exports.PluginRender = PluginRender;
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
2
|
-
import {
|
2
|
+
import { OnRequestSources, ResourceBrowserPlugin } from '../types';
|
3
3
|
export type ResourceBrowserContextProps = {
|
4
4
|
onRequestSources: OnRequestSources;
|
5
|
-
|
6
|
-
onRequestResource: OnRequestResource;
|
5
|
+
plugins: Array<ResourceBrowserPlugin>;
|
7
6
|
};
|
8
7
|
/**
|
9
8
|
* @internal Direct usage of this object is discouraged. It will be privated in a future major version.
|
@@ -38,31 +38,18 @@ exports.ResourceBrowserContext = react_1.default.createContext({
|
|
38
38
|
onRequestSources: () => {
|
39
39
|
throw new Error('onRequestSources has not been configured.');
|
40
40
|
},
|
41
|
-
|
42
|
-
throw new Error('onRequestChildren has not been configured.');
|
43
|
-
},
|
44
|
-
onRequestResource: () => {
|
45
|
-
throw new Error('onRequestResource has not been configured.');
|
46
|
-
},
|
41
|
+
plugins: [],
|
47
42
|
});
|
48
43
|
const ResourceBrowserContextProvider = (props) => {
|
49
44
|
const CACHE_DURATION = 30000; // 30 seconds
|
50
|
-
const { value: { onRequestSources,
|
45
|
+
const { value: { onRequestSources, ...other }, children, } = props;
|
51
46
|
const cache = new expiry_map_1.default(CACHE_DURATION);
|
52
47
|
const memoized = (0, react_1.useMemo)(() => ({
|
53
48
|
onRequestSources: (0, p_memoize_1.default)(onRequestSources, {
|
54
49
|
cache,
|
55
50
|
cacheKey: () => 'onRequestSources',
|
56
51
|
}),
|
57
|
-
|
58
|
-
|
59
|
-
cacheKey: ([source, resource]) => `onRequestChildren.${source.id}.${resource?.id}`,
|
60
|
-
}),
|
61
|
-
onRequestResource: (0, p_memoize_1.default)(onRequestResource, {
|
62
|
-
cache,
|
63
|
-
cacheKey: ([reference]) => `onRequestResource.${reference.source}.${reference.resource}`,
|
64
|
-
}),
|
65
|
-
}), [onRequestSources, onRequestChildren, onRequestResource]);
|
66
|
-
return (react_1.default.createElement(exports.ResourceBrowserContext.Provider, { value: { ...memoized, ...other } }, children));
|
52
|
+
}), [onRequestSources]);
|
53
|
+
return react_1.default.createElement(exports.ResourceBrowserContext.Provider, { value: { ...memoized, ...other } }, children);
|
67
54
|
};
|
68
55
|
exports.ResourceBrowserContextProvider = ResourceBrowserContextProvider;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { ResourceBrowserPlugin, ResourceBrowserSource, ResourceBrowserUnresolvedResource, ResourceBrowserResource } from '../types';
|
3
|
+
export type ResourceBrowserInputProps = {
|
4
|
+
modalTitle: string;
|
5
|
+
allowedTypes?: string[];
|
6
|
+
isDisabled?: boolean;
|
7
|
+
value: ResourceBrowserUnresolvedResource | null;
|
8
|
+
useResource(referenceId: string | null, source: ResourceBrowserSource | null): {
|
9
|
+
data: ResourceBrowserResource | null;
|
10
|
+
error: Error | null;
|
11
|
+
isLoading: boolean;
|
12
|
+
};
|
13
|
+
onChange(resource: ResourceBrowserResource | null): void;
|
14
|
+
onClear?(): void;
|
15
|
+
plugin: ResourceBrowserPlugin | null;
|
16
|
+
source: ResourceBrowserSource | null;
|
17
|
+
sources: ResourceBrowserSource[];
|
18
|
+
isLoading: boolean;
|
19
|
+
error: Error | null;
|
20
|
+
setSource(source: ResourceBrowserSource | null): void;
|
21
|
+
isModalOpen: boolean;
|
22
|
+
onModalStateChange(isOpen: boolean): void;
|
23
|
+
};
|
24
|
+
export declare const ResourceBrowserInput: ({ modalTitle, allowedTypes, onChange, value, useResource, isDisabled, onClear, plugin, source, sources, isLoading, error, setSource, isModalOpen, onModalStateChange, }: ResourceBrowserInputProps) => React.JSX.Element;
|
@@ -0,0 +1,16 @@
|
|
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
|
+
exports.ResourceBrowserInput = void 0;
|
7
|
+
const react_1 = __importDefault(require("react"));
|
8
|
+
const MainContainer_1 = __importDefault(require("../MainContainer/MainContainer"));
|
9
|
+
const ResourcePicker_1 = require("../ResourcePicker/ResourcePicker");
|
10
|
+
const ResourceBrowserInput = ({ modalTitle, allowedTypes, onChange, value, useResource, isDisabled, onClear, plugin, source, sources, isLoading, error, setSource, isModalOpen, onModalStateChange, }) => {
|
11
|
+
const { data: resource, error: resourceError, isLoading: isResourceLoading } = useResource(value?.resourceId || null, source);
|
12
|
+
const defaultOnClear = () => onChange(null);
|
13
|
+
const onClearFunction = onClear ?? defaultOnClear;
|
14
|
+
return (react_1.default.createElement(ResourcePicker_1.ResourcePicker, { resource: resource, plugin: plugin, allowedTypes: allowedTypes, error: resourceError || error, isLoading: isResourceLoading || isLoading, isDisabled: isDisabled, onClear: onClearFunction, isModalOpen: isModalOpen, onModalStateChange: onModalStateChange }, (onClose, titleProps) => (react_1.default.createElement(MainContainer_1.default, { selectedSource: source, sources: sources, preselectedResource: resource, plugin: plugin, title: modalTitle, titleAriaProps: titleProps, allowedTypes: allowedTypes, onSourceSelect: setSource, onClose: onClose, onChange: onChange }))));
|
15
|
+
};
|
16
|
+
exports.ResourceBrowserInput = ResourceBrowserInput;
|
@@ -1,14 +1,16 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { DOMAttributes } from '@react-types/shared';
|
3
|
-
import {
|
3
|
+
import { ResourceBrowserResource, ResourceBrowserPlugin } from '../types';
|
4
4
|
export type ResourcePickerProps = {
|
5
|
-
resource:
|
5
|
+
resource: ResourceBrowserResource | null;
|
6
|
+
plugin: ResourceBrowserPlugin | null;
|
6
7
|
allowedTypes: string[] | undefined;
|
7
8
|
error: Error | null;
|
8
9
|
isLoading: boolean;
|
9
10
|
isDisabled?: boolean;
|
10
11
|
children: (onClose: () => void, titleProps: DOMAttributes) => React.ReactElement;
|
11
12
|
onClear: () => void;
|
13
|
+
isModalOpen: boolean;
|
14
|
+
onModalStateChange(isOpen: boolean): void;
|
12
15
|
};
|
13
|
-
declare const ResourcePicker: ({ resource, allowedTypes, error, isLoading, isDisabled, children, onClear, }: ResourcePickerProps) => React.JSX.Element;
|
14
|
-
export default ResourcePicker;
|
16
|
+
export declare const ResourcePicker: ({ resource, plugin, allowedTypes, error: externalError, isLoading: isExternalLoading, isDisabled, children, onClear, isModalOpen, onModalStateChange, }: ResourcePickerProps) => React.JSX.Element;
|
@@ -3,24 +3,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.ResourcePicker = void 0;
|
6
7
|
const react_1 = __importDefault(require("react"));
|
7
8
|
const AdsClickRounded_1 = __importDefault(require("@mui/icons-material/AdsClickRounded"));
|
8
9
|
const AddCircleOutlineRounded_1 = __importDefault(require("@mui/icons-material/AddCircleOutlineRounded"));
|
9
10
|
const PhotoLibraryRounded_1 = __importDefault(require("@mui/icons-material/PhotoLibraryRounded"));
|
10
|
-
const
|
11
|
+
const resource_browser_ui_lib_1 = require("@squiz/resource-browser-ui-lib");
|
11
12
|
const Error_1 = require("./States/Error");
|
12
13
|
const Loading_1 = require("./States/Loading");
|
13
14
|
const Selected_1 = require("./States/Selected");
|
15
|
+
const useSelectedState_1 = require("../Hooks/useSelectedState");
|
14
16
|
const clsx_1 = __importDefault(require("clsx"));
|
15
|
-
const ResourcePicker = ({ resource, allowedTypes, error, isLoading, isDisabled, children, onClear, }) => {
|
17
|
+
const ResourcePicker = ({ resource, plugin, allowedTypes, error: externalError, isLoading: isExternalLoading, isDisabled, children, onClear, isModalOpen, onModalStateChange, }) => {
|
18
|
+
const { data: selectedState, error, isLoading } = (0, useSelectedState_1.useSelectedState)({ resource, plugin });
|
16
19
|
const isImagePicker = allowedTypes && allowedTypes.length === 1 && allowedTypes.includes('image');
|
17
|
-
const isEmpty = resource === null && !
|
20
|
+
const isEmpty = resource === null && !isExternalLoading && !externalError;
|
18
21
|
return (react_1.default.createElement("div", { className: (0, clsx_1.default)('resource-picker', isDisabled && 'resource-picker--disabled') },
|
19
22
|
isImagePicker ? (react_1.default.createElement(PhotoLibraryRounded_1.default, { "aria-hidden": true, className: "w-6 h-6" })) : (react_1.default.createElement(AdsClickRounded_1.default, { "aria-hidden": true, className: "w-6 h-6" })),
|
20
|
-
isEmpty ? (react_1.default.createElement(
|
23
|
+
isEmpty ? (react_1.default.createElement(resource_browser_ui_lib_1.ModalTrigger, { overlayTriggerState: {
|
24
|
+
isOpen: isModalOpen,
|
25
|
+
onOpenChange: onModalStateChange,
|
26
|
+
}, showLabel: true, label: isImagePicker ? `Choose image` : `Choose asset`, icon: react_1.default.createElement(AddCircleOutlineRounded_1.default, { "aria-hidden": true, className: `!w-4 !h-4 text-blue-300 ${isDisabled ? 'text-gray-600' : ''}` }), isDisabled: isDisabled, scope: "squiz-rb-scope" }, children)) : (react_1.default.createElement("div", { className: "resource-picker-info" },
|
21
27
|
react_1.default.createElement("div", { className: "resource-picker-info__layout" },
|
22
|
-
isLoading && react_1.default.createElement(Loading_1.LoadingState, null),
|
23
|
-
error && react_1.default.createElement(Error_1.ErrorState, { error: error, isDisabled: isDisabled, onClear: onClear }),
|
24
|
-
resource && (react_1.default.createElement(Selected_1.SelectedState, { resource: resource, isDisabled: isDisabled, onClear: onClear, resourcePickerContainer: children })))))));
|
28
|
+
(isExternalLoading || isLoading) && react_1.default.createElement(Loading_1.LoadingState, null),
|
29
|
+
(externalError || error) && (react_1.default.createElement(Error_1.ErrorState, { error: externalError || error, isDisabled: isDisabled, onClear: onClear })),
|
30
|
+
!isExternalLoading && resource && selectedState && (react_1.default.createElement(Selected_1.SelectedState, { isModalOpen: isModalOpen, onModalStateChange: onModalStateChange, resource: resource, showThumbnail: selectedState?.showThumbnail || false, icon: selectedState?.icon, label: selectedState?.label, description: selectedState?.description, isDisabled: isDisabled, onClear: onClear, resourcePickerContainer: children })))))));
|
25
31
|
};
|
26
|
-
exports.
|
32
|
+
exports.ResourcePicker = ResourcePicker;
|