@ckbox/core 1.6.0 → 2.0.0-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/README.md CHANGED
@@ -12,7 +12,7 @@ Using a build served from the CDN is the simplest and fastest way of embedding C
12
12
  To start using CKBox on your website, embed the following `script` element in the HTML code of the page:
13
13
 
14
14
  ```html
15
- <script src="https://cdn.ckbox.io/ckbox/1.6.0/ckbox.js"></script>
15
+ <script src="https://cdn.ckbox.io/ckbox/2.0.0-rc.0/ckbox.js"></script>
16
16
  ```
17
17
 
18
18
  Quick implementation example:
@@ -22,7 +22,7 @@ Quick implementation example:
22
22
  <html>
23
23
  <head>
24
24
  <meta charset="UTF-8" />
25
- <script src="https://cdn.ckbox.io/ckbox/1.6.0/ckbox.js"></script>
25
+ <script src="https://cdn.ckbox.io/ckbox/2.0.0-rc.0/ckbox.js"></script>
26
26
  </head>
27
27
  <body>
28
28
  <div id="ckbox"></div>
@@ -48,7 +48,7 @@ The code snippet below presents the simplest scenario for integration of CKEdito
48
48
  <head>
49
49
  <meta charset="UTF-8" />
50
50
  <script src="https://cdn.ckeditor.com/ckeditor5/36.0.0/classic/ckeditor.js"></script>
51
- <script src="https://cdn.ckbox.io/ckbox/1.6.0/ckbox.js"></script>
51
+ <script src="https://cdn.ckbox.io/ckbox/2.0.0-rc.0/ckbox.js"></script>
52
52
  </head>
53
53
  <body>
54
54
  <div id="editor"></div>
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import { IconRenderProp } from '@ckbox/components';
7
7
 
8
8
  type ApiAssetImageProcessingStatus = 'queued' | 'success' | 'error';
9
9
 
10
- interface ParsedAssetMetadata {
10
+ interface ParsedAssetMetadata extends Record<string, unknown> {
11
11
  /**
12
12
  * Asset blurhash.
13
13
  */
@@ -34,7 +34,7 @@ interface ParsedAssetMetadata {
34
34
  customAttributes?: Record<string, unknown>;
35
35
  }
36
36
 
37
- interface ParsedAsset {
37
+ interface ParsedAsset extends Record<string, unknown> {
38
38
  /**
39
39
  * Asset id.
40
40
  */
@@ -79,33 +79,84 @@ interface ParsedAsset {
79
79
  * Asset tags.
80
80
  */
81
81
  tags: string[];
82
+ /**
83
+ * Maps image width to image URL. URLs link to image in `webp` format.
84
+ * Provides `default` URL that links to image in its original format.
85
+ */
86
+ imageUrls?: Record<string, string>;
87
+ /**
88
+ * URL to original file.
89
+ */
90
+ url?: string;
82
91
  }
83
92
 
84
- interface AssetExtraProps {
93
+ interface ParsedCategory {
94
+ /**
95
+ * Category id.
96
+ */
97
+ id: string;
98
+ /**
99
+ * Total number of assets in the category.
100
+ */
101
+ assetsCount: number;
102
+ /**
103
+ * Category name.
104
+ */
105
+ name: string;
106
+ /**
107
+ * Allowed extensions.
108
+ */
109
+ extensions: string[];
110
+ }
111
+
112
+ interface ParsedFolder {
113
+ /**
114
+ * Folder ID.
115
+ */
116
+ id: string;
117
+ /**
118
+ * Folder name.
119
+ */
120
+ name: string;
121
+ /**
122
+ * Folder's root category ID.
123
+ */
124
+ categoryId: string;
125
+ /**
126
+ * Folder's parent ID. Present unless it's a root folder.
127
+ */
128
+ parentId?: string;
85
129
  /**
86
- * API origin.
130
+ * Date of folder creation.
87
131
  */
88
- origin: string;
132
+ createdAt?: string;
89
133
  /**
90
- * Callback that returns URL to the resource.
134
+ * Date of last folder update.
91
135
  */
92
- getUrl: (forceDownload?: boolean) => string;
136
+ updatedAt?: string;
93
137
  /**
94
- * Callback that returns URL to image of specified dimensions. Resource at URL is cached on CDN.
95
- * Returns `false` if there is no image available for the asset.
138
+ * List of children.
96
139
  */
97
- getResponsiveImageUrl: (width: number, heightOrFormat?: number | string, format?: string) => string | false;
140
+ folders: ParsedFolder[];
141
+ /**
142
+ * Number of assets in the folder.
143
+ */
144
+ assetsCount?: number;
98
145
  }
99
- interface Asset$1 extends AssetExtraProps {
146
+
147
+ interface AssetsConfigOnChooseParams {
148
+ /**
149
+ * Chosen asset.
150
+ */
100
151
  data: ParsedAsset;
101
152
  }
102
- type AssetsConfigOnChooseEnhanced = (assets: Asset$1[]) => void;
153
+ type AssetsConfigOnChooseWithParams = (assets: AssetsConfigOnChooseParams[]) => void;
103
154
  interface AssetsConfig {
104
155
  /**
105
- * Callback invoked upon clicking on `Choose` button.
156
+ * Callback invoked upon clicking on "Choose" button.
106
157
  * List of currently selected assets is passed as an argument.
107
158
  */
108
- onChoose?: AssetsConfigOnChooseEnhanced;
159
+ onChoose?: AssetsConfigOnChooseWithParams;
109
160
  }
110
161
 
111
162
  type CategoriesConfig = {
@@ -115,23 +166,42 @@ type CategoriesConfig = {
115
166
  icons?: Record<string, IconRenderProp>;
116
167
  };
117
168
 
118
- interface LanguageConfig {
169
+ type LanguageConfig = string;
170
+
171
+ type NavigationViewType = 'category' | 'fallback' | 'folder' | 'recent' | 'search' | 'settings';
172
+ type NavigationViewBase<Type extends NavigationViewType> = {
119
173
  /**
120
- * Turns on debugging mode for simplifying translation process (info logged to JS console).
174
+ * View type.
121
175
  */
122
- debug?: boolean;
176
+ type: Type;
177
+ };
178
+ type NavigationViewBaseData<Data> = {
123
179
  /**
124
- * Defines language code in case if an object is passed, e.g. 'en'.
180
+ * View data.
125
181
  */
126
- ui?: string;
127
- }
128
- type LanguageConfigProp = string | LanguageConfig;
129
-
182
+ data: Data;
183
+ };
184
+ type NavigationCategoryView = NavigationViewBase<'category'> & NavigationViewBaseData<ParsedCategory>;
185
+ type NavigationFallbackView = NavigationViewBase<'fallback'>;
186
+ type NavigationFolderView = NavigationViewBase<'folder'> & NavigationViewBaseData<ParsedFolder>;
187
+ type NavigationRecentView = NavigationViewBase<'recent'>;
188
+ type NavigationSearchView = NavigationViewBase<'search'>;
189
+ type NavigationSettingsView = NavigationViewBase<'settings'>;
190
+ type NavigationView = NavigationCategoryView | NavigationFallbackView | NavigationFolderView | NavigationRecentView | NavigationSearchView | NavigationSettingsView;
130
191
  interface NavigationProviderConfig {
131
192
  /**
132
193
  * If set to `false`, last selected view will not be re-opened on startup.
133
194
  */
134
195
  openLastView?: boolean;
196
+ /**
197
+ * Callback invoked upon view change.
198
+ *
199
+ * Callback will receive view data: `{ type: 'view-type' }`.
200
+ * Additionally, if view type is `category` or `folder`, `data` property will be provided that will be category or folder data, respectively.
201
+ *
202
+ * @param view current view
203
+ */
204
+ onViewChange?: (view: NavigationView) => void;
135
205
  /**
136
206
  * ID of the folder that will be opened on startup.
137
207
  * This option can be paired with setting `openLastView` to `false` to enforce CKBox to always open in a given folder at start.
@@ -164,16 +234,12 @@ interface DialogModeProps {
164
234
  }
165
235
  type DialogProps = boolean | DialogModeProps;
166
236
 
167
- type Asset = Asset$1;
168
- interface CoreContext extends NavigationProviderConfig {
237
+ type Asset = AssetsConfigOnChooseParams;
238
+ interface CoreContext {
169
239
  /**
170
240
  * Configures assets options.
171
241
  */
172
242
  assets?: AssetsConfig;
173
- /**
174
- * Configures origin for public assets.
175
- */
176
- assetsOrigin?: string;
177
243
  /**
178
244
  * Configures categories options.
179
245
  */
@@ -190,11 +256,37 @@ interface CoreContext extends NavigationProviderConfig {
190
256
  /**
191
257
  * Language options.
192
258
  */
193
- language?: LanguageConfigProp;
259
+ language?: LanguageConfig;
260
+ /**
261
+ * If set to `false`, last selected view will not be re-opened on startup.
262
+ *
263
+ * This option is deprecated. Use `view.openLastView` instead.
264
+ *
265
+ * @deprecated
266
+ */
267
+ openLastView?: NavigationProviderConfig['openLastView'];
194
268
  /**
195
269
  * Origin of the backend API service.
196
270
  */
197
271
  serviceOrigin?: string;
272
+ /**
273
+ * ID of the category that will be opened on startup.
274
+ * This option can be paired with setting `openLastView` to `false` to enforce CKBox to always open in a given category at start.
275
+ *
276
+ * This option is deprecated. Use `view.startupCategoryId` instead.
277
+ *
278
+ * @deprecated
279
+ */
280
+ startupCategoryId?: NavigationProviderConfig['startupCategoryId'];
281
+ /**
282
+ * ID of the folder that will be opened on startup.
283
+ * This option can be paired with setting `openLastView` to `false` to enforce CKBox to always open in a given folder at start.
284
+ *
285
+ * This option is deprecated. Use `view.startupFolderId` instead.
286
+ *
287
+ * @deprecated
288
+ */
289
+ startupFolderId?: NavigationProviderConfig['startupFolderId'];
198
290
  /**
199
291
  * Theme to use.
200
292
  */
@@ -203,6 +295,10 @@ interface CoreContext extends NavigationProviderConfig {
203
295
  * Token endpoint URL.
204
296
  */
205
297
  tokenUrl: string;
298
+ /**
299
+ * Configures view and navigation-related options.
300
+ */
301
+ view?: NavigationProviderConfig;
206
302
  }
207
303
  declare const CoreContext: React.Context<CoreContext>;
208
304