@squiz/resource-browser 3.0.1-pre-alpha.0 → 3.0.1-pre-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.
Files changed (85) hide show
  1. package/.eslintrc +40 -0
  2. package/.storybook/main.ts +26 -0
  3. package/.storybook/preview-body.html +1 -0
  4. package/.storybook/preview-head.html +12 -0
  5. package/.storybook/preview.ts +16 -0
  6. package/CHANGELOG.md +281 -0
  7. package/README_DEVS.md +18 -0
  8. package/build.js +21 -0
  9. package/jest.config.ts +30 -0
  10. package/lib/BrowseToSource/BrowseToSource.js +52 -26
  11. package/lib/Hooks/useAuth.js +15 -11
  12. package/lib/Hooks/useSelectedState.js +7 -3
  13. package/lib/Hooks/useSources.js +7 -3
  14. package/lib/Icons/AdsClickIcon.js +11 -4
  15. package/lib/Icons/ArrowDownIcon.js +11 -4
  16. package/lib/Icons/CircledLoopIcon.js +11 -4
  17. package/lib/MainContainer/MainContainer.js +55 -27
  18. package/lib/Plugin/Plugin.js +14 -7
  19. package/lib/ResourceBrowserContext/AuthProvider.js +37 -9
  20. package/lib/ResourceBrowserContext/ResourceBrowserContext.js +39 -9
  21. package/lib/ResourceBrowserInput/ResourceBrowserInput.js +12 -5
  22. package/lib/ResourceLauncher/ResourceLauncher.js +13 -8
  23. package/lib/ResourcePicker/ResourcePicker.js +27 -20
  24. package/lib/ResourcePicker/States/Error.js +13 -6
  25. package/lib/ResourcePicker/States/Loading.js +11 -4
  26. package/lib/ResourcePicker/States/Selected.js +19 -12
  27. package/lib/SourceDropdown/SourceDropdown.js +48 -22
  28. package/lib/SourceDropdownContainer/SourceDropdownContainer.js +16 -10
  29. package/lib/SourceList/SourceList.js +16 -11
  30. package/lib/index.js +66 -26
  31. package/lib/types.js +5 -2
  32. package/lib/utils/authUtils.js +16 -9
  33. package/package.json +4 -16
  34. package/postcss.config.js +21 -0
  35. package/tailwind.config.cjs +99 -0
  36. package/tsconfig.json +22 -0
  37. package/tsconfig.storybook.json +4 -0
  38. package/tsconfig.test.json +12 -0
  39. package/vite.config.js +20 -0
  40. package/lib-esm/BrowseToSource/BrowseToSource.d.ts +0 -8
  41. package/lib-esm/BrowseToSource/BrowseToSource.js +0 -50
  42. package/lib-esm/Hooks/useAuth.d.ts +0 -7
  43. package/lib-esm/Hooks/useAuth.js +0 -54
  44. package/lib-esm/Hooks/useSelectedState.d.ts +0 -15
  45. package/lib-esm/Hooks/useSelectedState.js +0 -12
  46. package/lib-esm/Hooks/useSources.d.ts +0 -14
  47. package/lib-esm/Hooks/useSources.js +0 -44
  48. package/lib-esm/Icons/AdsClickIcon.d.ts +0 -4
  49. package/lib-esm/Icons/AdsClickIcon.js +0 -5
  50. package/lib-esm/Icons/ArrowDownIcon.d.ts +0 -4
  51. package/lib-esm/Icons/ArrowDownIcon.js +0 -5
  52. package/lib-esm/Icons/CircledLoopIcon.d.ts +0 -4
  53. package/lib-esm/Icons/CircledLoopIcon.js +0 -5
  54. package/lib-esm/MainContainer/MainContainer.d.ts +0 -19
  55. package/lib-esm/MainContainer/MainContainer.js +0 -43
  56. package/lib-esm/Plugin/Plugin.d.ts +0 -13
  57. package/lib-esm/Plugin/Plugin.js +0 -12
  58. package/lib-esm/ResourceBrowserContext/AuthProvider.d.ts +0 -16
  59. package/lib-esm/ResourceBrowserContext/AuthProvider.js +0 -18
  60. package/lib-esm/ResourceBrowserContext/ResourceBrowserContext.d.ts +0 -15
  61. package/lib-esm/ResourceBrowserContext/ResourceBrowserContext.js +0 -26
  62. package/lib-esm/ResourceBrowserInput/ResourceBrowserInput.d.ts +0 -26
  63. package/lib-esm/ResourceBrowserInput/ResourceBrowserInput.js +0 -9
  64. package/lib-esm/ResourceLauncher/ResourceLauncher.d.ts +0 -8
  65. package/lib-esm/ResourceLauncher/ResourceLauncher.js +0 -12
  66. package/lib-esm/ResourcePicker/ResourcePicker.d.ts +0 -16
  67. package/lib-esm/ResourcePicker/ResourcePicker.js +0 -25
  68. package/lib-esm/ResourcePicker/States/Error.d.ts +0 -7
  69. package/lib-esm/ResourcePicker/States/Error.js +0 -6
  70. package/lib-esm/ResourcePicker/States/Loading.d.ts +0 -2
  71. package/lib-esm/ResourcePicker/States/Loading.js +0 -4
  72. package/lib-esm/ResourcePicker/States/Selected.d.ts +0 -15
  73. package/lib-esm/ResourcePicker/States/Selected.js +0 -20
  74. package/lib-esm/SourceDropdown/SourceDropdown.d.ts +0 -7
  75. package/lib-esm/SourceDropdown/SourceDropdown.js +0 -46
  76. package/lib-esm/SourceDropdownContainer/SourceDropdownContainer.d.ts +0 -5
  77. package/lib-esm/SourceDropdownContainer/SourceDropdownContainer.js +0 -12
  78. package/lib-esm/SourceList/SourceList.d.ts +0 -8
  79. package/lib-esm/SourceList/SourceList.js +0 -16
  80. package/lib-esm/index.d.ts +0 -18
  81. package/lib-esm/index.js +0 -79
  82. package/lib-esm/types.d.ts +0 -97
  83. package/lib-esm/types.js +0 -5
  84. package/lib-esm/utils/authUtils.d.ts +0 -5
  85. package/lib-esm/utils/authUtils.js +0 -31
package/.eslintrc ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "extends": ["@squiz"],
3
+ "plugins": ["import", "prettier"],
4
+ "rules": {
5
+ "prettier/prettier": "error",
6
+ },
7
+ "settings": {
8
+ "import/parsers": {
9
+ "@typescript-eslint/parser": [".ts", ".tsx"],
10
+ },
11
+ "import/resolver": {
12
+ "typescript": {
13
+ "alwaysTryTypes": true,
14
+ },
15
+ },
16
+ },
17
+ "ignorePatterns": ["**/lib/"],
18
+ "overrides": [
19
+ {
20
+ "files": ["*.spec.ts", "*.spec.tsx"],
21
+ "rules": {
22
+ "no-var": 0,
23
+ "import/no-extraneous-dependencies": 0,
24
+ },
25
+ },
26
+ {
27
+ "files": ["*.config.ts", "*.config.js", "build.js"],
28
+ "rules": {
29
+ "import/no-extraneous-dependencies": 0,
30
+ },
31
+ },
32
+ {
33
+ "files": ["*.stories.ts", "*.stories.tsx"],
34
+ "rules": {
35
+ "import/no-extraneous-dependencies": 0,
36
+ "no-console": "off",
37
+ },
38
+ },
39
+ ],
40
+ }
@@ -0,0 +1,26 @@
1
+ import type { StorybookConfig } from '@storybook/react-vite';
2
+ const config: StorybookConfig = {
3
+ stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
4
+ addons: [
5
+ '@storybook/addon-links',
6
+ '@storybook/addon-essentials',
7
+ '@storybook/addon-interactions',
8
+ {
9
+ name: '@storybook/addon-styling',
10
+ options: {
11
+ postCss: true,
12
+ },
13
+ },
14
+ ],
15
+ framework: {
16
+ name: '@storybook/react-vite',
17
+ options: {},
18
+ },
19
+ docs: {
20
+ autodocs: 'tag',
21
+ },
22
+ core: {
23
+ disableWhatsNewNotifications: true,
24
+ },
25
+ };
26
+ export default config;
@@ -0,0 +1 @@
1
+ <body class="squiz-rb-scope"></body>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ window.global = window;
3
+ </script>
4
+
5
+ <style>
6
+ .sb-show-main.sb-main-padded {
7
+ padding: 0;
8
+ }
9
+ body {
10
+ font-family: 'Open Sans';
11
+ }
12
+ </style>
@@ -0,0 +1,16 @@
1
+ import type { Preview } from '@storybook/react';
2
+ import '../src/index.scss';
3
+
4
+ const preview: Preview = {
5
+ parameters: {
6
+ actions: { argTypesRegex: '^on[A-Z].*' },
7
+ controls: {
8
+ matchers: {
9
+ color: /(background|color)$/i,
10
+ date: /Date$/,
11
+ },
12
+ },
13
+ },
14
+ };
15
+
16
+ export default preview;
package/CHANGELOG.md ADDED
@@ -0,0 +1,281 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [3.0.1-pre-alpha.2](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.4.12...@squiz/resource-browser@3.0.1-pre-alpha.2) (2024-11-22)
7
+
8
+
9
+ ### Features
10
+
11
+ * **prodam-346:** implement new top bar in matrix plugin ([b962c6f](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/commit/b962c6fc7d2c7a1d05d90fa57d149eabdfbee5b9))
12
+
13
+
14
+
15
+
16
+
17
+ ## [3.0.1-pre-alpha.1](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@3.0.0-pre-alpha.0...@squiz/resource-browser@3.0.1-pre-alpha.1) (2024-11-19)
18
+
19
+ **Note:** Version bump only for package @squiz/resource-browser
20
+
21
+
22
+
23
+
24
+
25
+ ## [3.0.1-pre-alpha.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@3.0.0-pre-alpha.0...@squiz/resource-browser@3.0.1-pre-alpha.0) (2024-11-18)
26
+
27
+ **Note:** Version bump only for package @squiz/resource-browser
28
+
29
+
30
+
31
+
32
+
33
+ # [3.0.0-pre-alpha.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.4.12...@squiz/resource-browser@3.0.0-pre-alpha.0) (2024-11-18)
34
+
35
+ ### Features
36
+
37
+ - **prodam-346:** implement new top bar in matrix plugin ([b962c6f](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/commit/b962c6fc7d2c7a1d05d90fa57d149eabdfbee5b9))
38
+
39
+ ## [3.0.0] Manual entry
40
+
41
+ **Note:** Major version bump as plugin interface and UI changed that will require updates to plugins to be compatible and render correctly.
42
+
43
+ ## [2.4.12](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.4.12-alpha.0...@squiz/resource-browser@2.4.12) (2024-06-17)
44
+
45
+ **Note:** Version bump only for package @squiz/resource-browser
46
+
47
+ ## [2.4.12-alpha.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.4.11-alpha.0...@squiz/resource-browser@2.4.12-alpha.0) (2024-06-14)
48
+
49
+ **Note:** Version bump only for package @squiz/resource-browser
50
+
51
+ ## [2.4.11-alpha.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.4.10-alpha.0...@squiz/resource-browser@2.4.11-alpha.0) (2024-06-14)
52
+
53
+ **Note:** Version bump only for package @squiz/resource-browser
54
+
55
+ ## [2.4.10-alpha.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.4.9-alpha.0...@squiz/resource-browser@2.4.10-alpha.0) (2024-06-14)
56
+
57
+ **Note:** Version bump only for package @squiz/resource-browser
58
+
59
+ ## [2.4.9-alpha.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.4.8-alpha.0...@squiz/resource-browser@2.4.9-alpha.0) (2024-06-14)
60
+
61
+ **Note:** Version bump only for package @squiz/resource-browser
62
+
63
+ ## [2.4.8-alpha.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.4.7-alpha.0...@squiz/resource-browser@2.4.8-alpha.0) (2024-06-14)
64
+
65
+ **Note:** Version bump only for package @squiz/resource-browser
66
+
67
+ ## [2.4.7-alpha.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.4.6-alpha.0...@squiz/resource-browser@2.4.7-alpha.0) (2024-06-14)
68
+
69
+ **Note:** Version bump only for package @squiz/resource-browser
70
+
71
+ ## [2.4.6-alpha.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.4.5-rc.0...@squiz/resource-browser@2.4.6-alpha.0) (2024-06-14)
72
+
73
+ **Note:** Version bump only for package @squiz/resource-browser
74
+
75
+ ## [2.4.5-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.4.4-alpha.0...@squiz/resource-browser@2.4.5-rc.0) (2024-06-14)
76
+
77
+ **Note:** Version bump only for package @squiz/resource-browser
78
+
79
+ ## [2.4.4-alpha.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.4.3-alpha.0...@squiz/resource-browser@2.4.4-alpha.0) (2024-06-14)
80
+
81
+ **Note:** Version bump only for package @squiz/resource-browser
82
+
83
+ ## [2.4.3-alpha.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.4.2-rc.0...@squiz/resource-browser@2.4.3-alpha.0) (2024-06-14)
84
+
85
+ **Note:** Version bump only for package @squiz/resource-browser
86
+
87
+ ## [2.4.2-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.4.1-alpha.0...@squiz/resource-browser@2.4.2-rc.0) (2024-06-14)
88
+
89
+ **Note:** Version bump only for package @squiz/resource-browser
90
+
91
+ ## [2.4.1-alpha.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.4.0-rc.0...@squiz/resource-browser@2.4.1-alpha.0) (2024-06-14)
92
+
93
+ ### Bug Fixes
94
+
95
+ - wip hooks fix ([274701c](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/commit/274701c0874888430d8dcdaecfb6e5a8efe4a98f))
96
+
97
+ # [2.4.0-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.3.0-rc.0...@squiz/resource-browser@2.4.0-rc.0) (2024-06-13)
98
+
99
+ ### Features
100
+
101
+ - **PRODAM-161:** updated versions ([8ed02b5](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/commit/8ed02b5aa5b818c27a0d23d98cbbee468e4e559e))
102
+
103
+ # [2.3.0-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.2.1...@squiz/resource-browser@2.3.0-rc.0) (2024-06-13)
104
+
105
+ ### Features
106
+
107
+ - **PRODAM-161:** lint ([7bc6f21](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/commit/7bc6f2112a0364efb6c7e6e56c1fcfac61dc1086))
108
+ - **PRODAM-161:** linting ([afef928](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/commit/afef928ac5a3fd05693f44995c144548e44b4392))
109
+ - **PRODAM-161:** route resource fetch tru internal api ([3073a7a](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/commit/3073a7a34b8700f63f3b60070c489a7476c62122))
110
+
111
+ ## [2.2.1](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.2.1-rc.0...@squiz/resource-browser@2.2.1) (2024-06-11)
112
+
113
+ **Note:** Version bump only for package @squiz/resource-browser
114
+
115
+ ## [2.2.1-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.2.0-rc.0...@squiz/resource-browser@2.2.1-rc.0) (2024-06-07)
116
+
117
+ **Note:** Version bump only for package @squiz/resource-browser
118
+
119
+ # [2.2.0-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.1.10-rc.0...@squiz/resource-browser@2.2.0-rc.0) (2024-06-06)
120
+
121
+ ### Features
122
+
123
+ - **PRODAM:92:** auth provider ([3c7136d](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/commit/3c7136da5f5ef148f713ad6a39f5d2328eaff4c7))
124
+
125
+ ## [2.1.10-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.1.9-rc.0...@squiz/resource-browser@2.1.10-rc.0) (2024-06-06)
126
+
127
+ **Note:** Version bump only for package @squiz/resource-browser
128
+
129
+ ## [2.1.9-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.1.8-rc.0...@squiz/resource-browser@2.1.9-rc.0) (2024-06-03)
130
+
131
+ **Note:** Version bump only for package @squiz/resource-browser
132
+
133
+ ## 2.1.8-rc.0 (2024-05-30)
134
+
135
+ **Note:** Version bump only for package @squiz/resource-browser
136
+
137
+ ## [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)
138
+
139
+ **Note:** Version bump only for package @squiz/resource-browser-v2
140
+
141
+ ## [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)
142
+
143
+ **Note:** Version bump only for package @squiz/resource-browser-v2
144
+
145
+ ## [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)
146
+
147
+ **Note:** Version bump only for package @squiz/resource-browser-v2
148
+
149
+ ## [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)
150
+
151
+ **Note:** Version bump only for package @squiz/resource-browser-v2
152
+
153
+ ## [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)
154
+
155
+ **Note:** Version bump only for package @squiz/resource-browser-v2
156
+
157
+ ## [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)
158
+
159
+ **Note:** Version bump only for package @squiz/resource-browser-v2
160
+
161
+ ## [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)
162
+
163
+ **Note:** Version bump only for package @squiz/resource-browser-v2
164
+
165
+ # [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)
166
+
167
+ ### Features
168
+
169
+ - **prodam-133:** add source dropdown to rb wrapper ([a258b0f](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/commit/a258b0febebca94aad1885f602d6a10a323ab95f))
170
+
171
+ ## [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)
172
+
173
+ **Note:** Version bump only for package @squiz/resource-browser-v2
174
+
175
+ ## [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)
176
+
177
+ **Note:** Version bump only for package @squiz/resource-browser-v2
178
+
179
+ ## [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)
180
+
181
+ **Note:** Version bump only for package @squiz/resource-browser-v2
182
+
183
+ ## [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)
184
+
185
+ **Note:** Version bump only for package @squiz/resource-browser-v2
186
+
187
+ ## [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)
188
+
189
+ **Note:** Version bump only for package @squiz/resource-browser-v2
190
+
191
+ ## [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)
192
+
193
+ **Note:** Version bump only for package @squiz/resource-browser-v2
194
+
195
+ ## [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)
196
+
197
+ **Note:** Version bump only for package @squiz/resource-browser-v2
198
+
199
+ ## [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)
200
+
201
+ **Note:** Version bump only for package @squiz/resource-browser-v2
202
+
203
+ ## 2.0.1-rc.0 (2024-04-26)
204
+
205
+ **Note:** Version bump only for package @squiz/resource-browser-v2
206
+
207
+ # @squiz/resource-browser
208
+
209
+ ## 1.67.1
210
+
211
+ ### Patch Changes
212
+
213
+ - 9e4cad8: Fixed minor issue with finding best matched lineage in resource browser
214
+
215
+ ## 1.67.0
216
+
217
+ ### Minor Changes
218
+
219
+ - 5fa9b39: Updated resource browser to allow replacing the previously selected resource. Replacing will open the resource browser to the location where the resource resides.
220
+
221
+ ### Patch Changes
222
+
223
+ - Updated dependencies [5fa9b39]
224
+ - Updated dependencies [5fa9b39]
225
+ - @squiz/dx-json-schema-lib@1.67.0
226
+ - @squiz/generic-browser-lib@1.66.0
227
+
228
+ ## 1.66.3
229
+
230
+ ### Patch Changes
231
+
232
+ - 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
233
+
234
+ ## 1.66.2
235
+
236
+ ### Patch Changes
237
+
238
+ - 6d41052: Added white background to resource picker input to avoid it inheriting the background colour of its parent element.
239
+
240
+ ## 1.66.1
241
+
242
+ ### Patch Changes
243
+
244
+ - 81c7cba: Image asset previews will now display the image if there is a URL in the returned resource data
245
+ Also fixes a bug around the selected resource name not having break-word applied so the filename was not wrapping as expected
246
+
247
+ ## 1.66.0
248
+
249
+ ### Minor Changes
250
+
251
+ - 5032c38: Added content page asset icon.
252
+
253
+ ### Patch Changes
254
+
255
+ - Updated dependencies [5032c38]
256
+ - @squiz/generic-browser-lib@1.65.0
257
+
258
+ ## 1.65.0
259
+
260
+ ### Minor Changes
261
+
262
+ - ac68ec6: Unpinned Squiz dependencies, they should now be following semver.
263
+
264
+ ### Patch Changes
265
+
266
+ - Updated dependencies [ac68ec6]
267
+ - @squiz/dx-json-schema-lib@1.65.0
268
+
269
+ ## 1.64.1
270
+
271
+ ### Patch Changes
272
+
273
+ - Updated dependencies [e717e6e]
274
+ - @squiz/generic-browser-lib@1.64.0
275
+ - @squiz/dx-json-schema-lib@1.64.0
276
+
277
+ ## 1.64.0
278
+
279
+ ### Minor Changes
280
+
281
+ - e7d4c0f: Updated disabled styling for component-editing-ui & resource browser
package/README_DEVS.md ADDED
@@ -0,0 +1,18 @@
1
+ # Resource Browser Developer Notes
2
+
3
+ ## Component usage / render order
4
+
5
+ 1. ResourceBrowser e.g. index.tsx
6
+ 2. PluginRender
7
+ . A plugin is create for each inputted plugin to the ResourceBrowser
8
+ . They are conditional rendered based on if that plugin is needed by a source that matches that plugin being selected
9
+ . This pattern allows React Hooks to continue working inside the plugins because React doesn't like functions that include hooks being switch out at runtime e.g. switching what functions are used based on the selected source.
10
+ 3. ResourceBrowserInput
11
+ . This renders the first thing you see in the UI, an input area for a Resource to be selected or changed.
12
+ . This has two states: empty where selecting opens directly opens the modal at the next Component in the chain or selected where it will use a function from the selected resources matching plugin to render what that plugin thinks the Resource looks like.
13
+ 4. MainContainer
14
+ . This is the main body of the modal which opens when a Resource needs to be selected
15
+ . This has two sub views which can show: a launcher selection where the user can pick which connected source they want to select from and whether they want to search or browser or a resource browser / search page for when either a source is being changed.
16
+ 5. (path 1) ResourceLauncher
17
+ . This will show a list of connected sources and render a small UI from each's plugin to allow a user to launch into that sources selector via a search or browser context based on what that plugin supports.
18
+ 6. (path 2) Plugin's `sourceBrowserComponent` or `sourceSearchComponent` depending on what was selected in the launcher or browse if the launcher wasn't used e.g. changing and existing resource.
package/build.js ADDED
@@ -0,0 +1,21 @@
1
+ const esbuild = require('esbuild');
2
+ const { sassPlugin } = require('esbuild-sass-plugin');
3
+ const postcss = require('postcss');
4
+ const postcssConfig = require('./postcss.config').plugins;
5
+
6
+ esbuild
7
+ .build({
8
+ entryPoints: ['src/index.scss'],
9
+ bundle: true,
10
+ outdir: 'lib',
11
+ plugins: [
12
+ sassPlugin({
13
+ type: 'css',
14
+ transform: async (source) => {
15
+ const { css } = postcss(postcssConfig).process(source);
16
+ return css;
17
+ },
18
+ }),
19
+ ],
20
+ })
21
+ .catch(() => process.exit(1));
package/jest.config.ts ADDED
@@ -0,0 +1,30 @@
1
+ import type { Config } from 'jest';
2
+
3
+ // Sync object
4
+ const config: Config = {
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
+ },
16
+ },
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'],
28
+ };
29
+
30
+ export default config;
@@ -1,20 +1,45 @@
1
- import React, { useRef, useState } from 'react';
2
- import { Icon, uuid } from '@squiz/generic-browser-lib';
3
- import { useFocusWithin, useKeyboard } from 'react-aria';
4
- import { AdsClickIcon } from '../Icons/AdsClickIcon';
5
- import { ArrowDownIcon } from '../Icons/ArrowDownIcon';
6
- export default function BrowseToSource({ sources, selectedSource, onSourceSelect, className = '', }) {
7
- const [uniqueId] = useState(uuid());
8
- const buttonRef = useRef(null);
9
- const [isOpen, setIsOpen] = useState(false);
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const react_1 = __importStar(require("react"));
27
+ const generic_browser_lib_1 = require("@squiz/generic-browser-lib");
28
+ const react_aria_1 = require("react-aria");
29
+ const AdsClickIcon_1 = require("../Icons/AdsClickIcon");
30
+ const ArrowDownIcon_1 = require("../Icons/ArrowDownIcon");
31
+ function BrowseToSource({ sources, selectedSource, onSourceSelect, className = '', }) {
32
+ const [uniqueId] = (0, react_1.useState)((0, generic_browser_lib_1.uuid)());
33
+ const buttonRef = (0, react_1.useRef)(null);
34
+ const [isOpen, setIsOpen] = (0, react_1.useState)(false);
10
35
  // Watch the focus and blur on the menu and close if focus leaves the control
11
- const { focusWithinProps } = useFocusWithin({
36
+ const { focusWithinProps } = (0, react_aria_1.useFocusWithin)({
12
37
  onBlurWithin: () => {
13
38
  setIsOpen(false);
14
39
  },
15
40
  });
16
41
  // Listen for Esc key within this element
17
- const { keyboardProps } = useKeyboard({
42
+ const { keyboardProps } = (0, react_aria_1.useKeyboard)({
18
43
  onKeyDown: (e) => {
19
44
  if (isOpen && e.key === 'Escape') {
20
45
  setIsOpen(false);
@@ -28,23 +53,24 @@ export default function BrowseToSource({ sources, selectedSource, onSourceSelect
28
53
  onSourceSelect(source);
29
54
  };
30
55
  if (!sources.length) {
31
- return React.createElement(React.Fragment, null);
56
+ return react_1.default.createElement(react_1.default.Fragment, null);
32
57
  }
33
- return (React.createElement("div", { className: `inline-block ${isOpen ? 'flex items-center border-2 border-gray-200 rounded-lg px-1 py-0.5 w-[350px]' : 'p-0'} ${className}` },
34
- isOpen && React.createElement(AdsClickIcon, { "aria-hidden": true, className: "ml-1 mr-2 shrink-0" }),
35
- sources.length > 1 && (React.createElement("div", { ...focusWithinProps, ...keyboardProps, className: `relative w-full ${isOpen && 'border-l border-gray-400 pl-1 '}` },
36
- React.createElement("button", { ref: buttonRef, type: "button", "aria-label": "Source quick select", "aria-expanded": isOpen, "aria-controls": `${uniqueId}-button-menu`, onClick: () => setIsOpen(!isOpen), className: `relative flex items-center p-2 w-full rounded-lg ${!isOpen && 'border-2 border-gray-200 hover:bg-gray-100'}` }, isOpen ? (React.createElement(React.Fragment, null,
37
- React.createElement("span", { className: "text-gray-700 text-md leading-5 mr-2" }, "Browse to ..."),
38
- React.createElement(ArrowDownIcon, { "aria-hidden": true, className: "absolute right-3" }))) : (React.createElement(React.Fragment, null,
39
- React.createElement(AdsClickIcon, { "aria-hidden": true, className: "ml-[6px] mr-2" }),
40
- React.createElement("span", { className: "text-gray-700 text-md font-semibold leading-5 mr-[6px]" }, "Browse")))),
41
- React.createElement("ul", { id: `${uniqueId}-button-menu`, "aria-hidden": !isOpen, className: `absolute z-50 top-[calc(100%+8px)] left-1 w-[calc(100%-2px)] bg-gray-100 border-1 shadow-md rounded border-gray-300 p-2 pb-0 overflow-y-auto max-h-80 ${!isOpen ? 'hidden' : ''}` }, sources.map((source) => {
58
+ return (react_1.default.createElement("div", { className: `inline-block ${isOpen ? 'flex items-center border-2 border-gray-200 rounded-lg px-1 py-0.5 w-[350px]' : 'p-0'} ${className}` },
59
+ isOpen && react_1.default.createElement(AdsClickIcon_1.AdsClickIcon, { "aria-hidden": true, className: "ml-1 mr-2 shrink-0" }),
60
+ sources.length > 1 && (react_1.default.createElement("div", { ...focusWithinProps, ...keyboardProps, className: `relative w-full ${isOpen && 'border-l border-gray-400 pl-1 '}` },
61
+ react_1.default.createElement("button", { ref: buttonRef, type: "button", "aria-label": "Source quick select", "aria-expanded": isOpen, "aria-controls": `${uniqueId}-button-menu`, onClick: () => setIsOpen(!isOpen), className: `relative flex items-center p-2 w-full rounded-lg ${!isOpen && 'border-2 border-gray-200 hover:bg-gray-100'}` }, isOpen ? (react_1.default.createElement(react_1.default.Fragment, null,
62
+ react_1.default.createElement("span", { className: "text-gray-700 text-md leading-5 mr-2" }, "Browse to ..."),
63
+ react_1.default.createElement(ArrowDownIcon_1.ArrowDownIcon, { "aria-hidden": true, className: "absolute right-3" }))) : (react_1.default.createElement(react_1.default.Fragment, null,
64
+ react_1.default.createElement(AdsClickIcon_1.AdsClickIcon, { "aria-hidden": true, className: "ml-[6px] mr-2" }),
65
+ react_1.default.createElement("span", { className: "text-gray-700 text-md font-semibold leading-5 mr-[6px]" }, "Browse")))),
66
+ react_1.default.createElement("ul", { id: `${uniqueId}-button-menu`, "aria-hidden": !isOpen, className: `absolute z-50 top-[calc(100%+8px)] left-1 w-[calc(100%-2px)] bg-gray-100 border-1 shadow-md rounded border-gray-300 p-2 pb-0 overflow-y-auto max-h-80 ${!isOpen ? 'hidden' : ''}` }, sources.map((source) => {
42
67
  const { id, name, type } = source;
43
68
  const isSelectedSource = id === selectedSource.id;
44
- return (React.createElement("li", { key: id, className: "flex items-center text-sm font-semibold mb-2 bg-white rounded" },
45
- React.createElement("button", { type: "button", onClick: () => handleSourceClick(source), className: `relative grow flex items-center p-2 border-1 border-white rounded hover:bg-gray-50 hover:border-gray-300 focus:bg-gray-100` },
46
- React.createElement(Icon, { icon: type, "aria-label": type, className: "shrink-0 mr-2.5" }),
47
- React.createElement("span", { className: "text-left mr-7" }, name),
48
- isSelectedSource && (React.createElement(Icon, { icon: 'selected', "aria-label": "selected", className: "absolute right-4" })))));
69
+ return (react_1.default.createElement("li", { key: id, className: "flex items-center text-sm font-semibold mb-2 bg-white rounded" },
70
+ react_1.default.createElement("button", { type: "button", onClick: () => handleSourceClick(source), className: `relative grow flex items-center p-2 border-1 border-white rounded hover:bg-gray-50 hover:border-gray-300 focus:bg-gray-100` },
71
+ react_1.default.createElement(generic_browser_lib_1.Icon, { icon: type, "aria-label": type, className: "shrink-0 mr-2.5" }),
72
+ react_1.default.createElement("span", { className: "text-left mr-7" }, name),
73
+ isSelectedSource && (react_1.default.createElement(generic_browser_lib_1.Icon, { icon: 'selected', "aria-label": "selected", className: "absolute right-4" })))));
49
74
  }))))));
50
75
  }
76
+ exports.default = BrowseToSource;
@@ -1,16 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAuth = void 0;
1
4
  /* eslint-disable no-console */
2
- import { useState, useCallback, useEffect } from 'react';
3
- import { getCookieValue, refreshAccessToken as refreshTokenUtil } from '../utils/authUtils';
4
- export const useAuth = (authConfig) => {
5
- const [authToken, setAuthToken] = useState(getCookieValue('authToken'));
6
- const [isAuthenticated, setIsAuthenticated] = useState(!!getCookieValue('authToken'));
7
- const refreshAccessToken = useCallback(async () => {
8
- const newToken = await refreshTokenUtil(authConfig);
5
+ const react_1 = require("react");
6
+ const authUtils_1 = require("../utils/authUtils");
7
+ const useAuth = (authConfig) => {
8
+ const [authToken, setAuthToken] = (0, react_1.useState)((0, authUtils_1.getCookieValue)('authToken'));
9
+ const [isAuthenticated, setIsAuthenticated] = (0, react_1.useState)(!!(0, authUtils_1.getCookieValue)('authToken'));
10
+ const refreshAccessToken = (0, react_1.useCallback)(async () => {
11
+ const newToken = await (0, authUtils_1.refreshAccessToken)(authConfig);
9
12
  setAuthToken(newToken);
10
13
  setIsAuthenticated(!!newToken);
11
14
  return newToken;
12
15
  }, [authConfig]);
13
- const handleLogin = useCallback(() => {
16
+ const handleLogin = (0, react_1.useCallback)(() => {
14
17
  if (!authConfig?.redirectUrl && !authConfig?.authUrl && !authConfig?.scope) {
15
18
  console.error('Auth config is misconfigured');
16
19
  return;
@@ -24,10 +27,10 @@ export const useAuth = (authConfig) => {
24
27
  }
25
28
  const checkPopup = setInterval(() => {
26
29
  try {
27
- if (getCookieValue('authToken') && getCookieValue('refreshToken')) {
30
+ if ((0, authUtils_1.getCookieValue)('authToken') && (0, authUtils_1.getCookieValue)('refreshToken')) {
28
31
  clearInterval(checkPopup);
29
32
  popup.close();
30
- setAuthToken(getCookieValue('authToken'));
33
+ setAuthToken((0, authUtils_1.getCookieValue)('authToken'));
31
34
  setIsAuthenticated(true);
32
35
  }
33
36
  }
@@ -40,7 +43,7 @@ export const useAuth = (authConfig) => {
40
43
  }
41
44
  }, 1000); // Check every second
42
45
  }, [authConfig]);
43
- useEffect(() => {
46
+ (0, react_1.useEffect)(() => {
44
47
  refreshAccessToken().catch(() => {
45
48
  setIsAuthenticated(false);
46
49
  });
@@ -52,3 +55,4 @@ export const useAuth = (authConfig) => {
52
55
  refreshAccessToken,
53
56
  };
54
57
  };
58
+ exports.useAuth = useAuth;
@@ -1,12 +1,16 @@
1
- import { useAsync } from '@squiz/generic-browser-lib';
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");
2
5
  /**
3
6
  * Loads the selected state for the provided resource
4
7
  */
5
- export const useSelectedState = ({ plugin, resource }) => {
8
+ const useSelectedState = ({ plugin, resource }) => {
6
9
  // Find the resolver for this resource
7
10
  const renderSelectedResource = resource && plugin?.renderSelectedResource;
8
- return useAsync({
11
+ return (0, generic_browser_lib_1.useAsync)({
9
12
  callback: () => (resource && renderSelectedResource ? renderSelectedResource(resource) : null),
10
13
  defaultValue: null,
11
14
  }, [resource]);
12
15
  };
16
+ exports.useSelectedState = useSelectedState;