next-cloudinary 0.1.1 → 0.3.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.
@@ -1,6 +1,9 @@
1
1
  import Image from 'next/image';
2
2
  import { Cloudinary } from '@cloudinary/url-gen';
3
- import { jsx } from 'react/jsx-runtime';
3
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
+ import Head from 'next/head';
5
+ import { useRef } from 'react';
6
+ import Script from 'next/script';
4
7
 
5
8
  function _extends() {
6
9
  _extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -34,95 +37,32 @@ function _objectWithoutPropertiesLoose(source, excluded) {
34
37
  return target;
35
38
  }
36
39
 
37
- const cld$1 = new Cloudinary({
38
- cloud: {
39
- cloudName: process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
40
- },
41
- url: {
42
- // Used to avoid issues with SSR particularly for the blurred placeholder
43
- analytics: false
44
- }
45
- });
46
- /**
47
- * Retrieves the public id of a cloudiary image url. If no url is recognized it returns the parameter it self.
48
- * If it's recognized that is a url and it's not possible to get the public id, it warns the user.
49
- *
50
- * @param {string} src The cloudiary url or public id.
51
- *
52
- * @return {string} The images public id
53
- */
54
-
55
- function getPublicId(src) {
56
- if (src.includes('res.cloudinary.com')) {
57
- const regexWithTransformations = /(https?)\:\/\/(res.cloudinary.com)\/([^\/]+)\/(image|video|raw)\/(upload|authenticated)\/(.*)\/(v[0-9]+)\/(.+)(?:\.[a-z]{3})?/;
58
- const regexWithoutTransformations = /(https?)\:\/\/(res.cloudinary.com)\/([^\/]+)\/(image|video|raw)\/(upload|authenticated)\/(v[0-9]+)\/(.+)(?:\.[a-z]{3})?/;
59
- const withTransformations = src.match(regexWithTransformations);
60
- const withoutTransformations = src.match(regexWithoutTransformations);
61
-
62
- if (withTransformations) {
63
- return withTransformations[withTransformations.length - 1];
64
- } else if (withoutTransformations) {
65
- return withoutTransformations[withoutTransformations.length - 1];
66
- } else {
67
- console.warn(`Not possible to retrieve the publicUrl from ${src}, make sure it's a valid cloudinary image url.`);
68
- }
69
- }
70
-
71
- return src;
72
- }
73
- /**
74
- * createPlaceholderUrl
75
- */
76
-
77
- function createPlaceholderUrl({
78
- src,
79
- placeholder
80
- }) {
81
- const cldImage = cld$1.image(src).resize('c_limit,w_100').delivery('q_1').format('auto');
82
-
83
- if (placeholder === 'grayscale') {
84
- cldImage.effect('e_grayscale');
85
- }
86
-
87
- if (placeholder.includes('color:')) {
88
- const color = placeholder.split(':').splice(1).join(':');
89
- cldImage.effect('e_grayscale');
90
- cldImage.effect(`e_colorize:60,co_${color}`);
91
- }
92
-
93
- return cldImage.toURL();
94
- }
95
-
96
40
  const cropsGravityAuto = ['crop', 'fill', 'lfill', 'fill_pad', 'thumb'];
97
41
  const props$6 = ['crop', 'gravity'];
98
42
  function plugin$6({
99
43
  cldImage,
100
- options,
101
- cldOptions
44
+ options
102
45
  } = {}) {
103
46
  const {
104
47
  width,
105
- height
48
+ height,
49
+ crop = 'limit'
106
50
  } = options;
107
- const {
108
- crop = 'limit',
109
- gravity
110
- } = cldOptions;
111
51
  let transformationString = `c_${crop},w_${width}`;
112
52
 
113
- if (!gravity && cropsGravityAuto.includes(crop)) {
114
- gravity = 'auto';
53
+ if (!options.gravity && cropsGravityAuto.includes(crop)) {
54
+ options.gravity = 'auto';
115
55
  }
116
56
 
117
57
  if (!['limit'].includes(crop)) {
118
58
  transformationString = `${transformationString},h_${height}`;
119
59
  }
120
60
 
121
- if (gravity) {
122
- if (gravity === 'auto' && !cropsGravityAuto.includes(crop)) {
61
+ if (options.gravity) {
62
+ if (options.gravity === 'auto' && !cropsGravityAuto.includes(crop)) {
123
63
  console.warn('Auto gravity can only be used with crop, fill, lfill, fill_pad or thumb. Not applying gravity.');
124
64
  } else {
125
- transformationString = `${transformationString},g_${gravity}`;
65
+ transformationString = `${transformationString},g_${options.gravity}`;
126
66
  }
127
67
  }
128
68
 
@@ -184,20 +124,16 @@ const params = ['art', {
184
124
  const props$5 = params.map(param => param.prop || param);
185
125
  function plugin$5({
186
126
  cldImage,
187
- cldOptions
127
+ options
188
128
  } = {}) {
189
129
  params.forEach(key => {
190
130
  const prop = key.prop || key;
191
131
  const effect = key.effect || key;
192
132
 
193
- if (prop === 'oilPaint' && cldOptions[prop]) {
194
- console.log('cldOptions[prop]', cldOptions[prop]);
195
- }
196
-
197
- if (cldOptions[prop] === true) {
133
+ if (options[prop] === true) {
198
134
  cldImage.effect(`e_${effect}`);
199
- } else if (typeof cldOptions[prop] === 'string') {
200
- cldImage.effect(`e_${effect}:${cldOptions[prop]}`);
135
+ } else if (typeof options[prop] === 'string') {
136
+ cldImage.effect(`e_${effect}:${options[prop]}`);
201
137
  }
202
138
  });
203
139
  }
@@ -262,29 +198,56 @@ const text = {
262
198
  }
263
199
  };
264
200
 
265
- const _excluded$1 = ["publicId", "position", "text", "effects"];
266
- const props$4 = ['overlays'];
201
+ const _excluded$3 = ["publicId", "position", "text", "effects"];
202
+ const props$4 = ['text', 'overlays'];
203
+ const DEFAULT_TEXT_OPTIONS = {
204
+ color: 'black',
205
+ fontFamily: 'Arial',
206
+ fontSize: 200,
207
+ fontWeight: 'bold'
208
+ };
267
209
  function plugin$4({
268
210
  cldImage,
269
- options,
270
- cldOptions
211
+ options
271
212
  } = {}) {
272
213
  const {
214
+ text: text$1,
273
215
  overlays = []
274
- } = cldOptions;
216
+ } = options;
275
217
  const type = 'overlay';
276
218
  const typeQualifier = 'l';
277
- overlays.forEach(_ref => {
219
+
220
+ if (Array.isArray(overlays)) {
221
+ overlays.forEach(applyOverlay);
222
+ }
223
+
224
+ if (typeof text$1 === 'string') {
225
+ applyOverlay({
226
+ text: _extends({}, DEFAULT_TEXT_OPTIONS, {
227
+ text: text$1
228
+ })
229
+ });
230
+ } else if (typeof text$1 === 'object') {
231
+ applyOverlay({
232
+ text: _extends({}, DEFAULT_TEXT_OPTIONS, text$1)
233
+ });
234
+ }
235
+ /**
236
+ * applyOverlay
237
+ */
238
+
239
+
240
+ function applyOverlay(_ref) {
278
241
  let {
279
242
  publicId,
280
243
  position: position$1,
281
244
  text: text$1,
282
245
  effects: layerEffects = []
283
246
  } = _ref,
284
- options = _objectWithoutPropertiesLoose(_ref, _excluded$1);
247
+ options = _objectWithoutPropertiesLoose(_ref, _excluded$3);
285
248
 
286
249
  const hasPublicId = typeof publicId === 'string';
287
- const hasText = typeof text$1 === 'object';
250
+ const hasText = typeof text$1 === 'object' || typeof text$1 === 'string';
288
251
  const hasPosition = typeof position$1 === 'object';
289
252
 
290
253
  if (!hasPublicId && !hasText) {
@@ -326,6 +289,12 @@ function plugin$4({
326
289
  }); // Text styling
327
290
 
328
291
  if (hasText) {
292
+ if (typeof text$1 === 'string') {
293
+ text$1 = _extends({}, DEFAULT_TEXT_OPTIONS, {
294
+ text: text$1
295
+ });
296
+ }
297
+
329
298
  const textTransformations = [];
330
299
  Object.keys(text$1).forEach(key => {
331
300
  if (!text[key]) return;
@@ -357,7 +326,7 @@ function plugin$4({
357
326
 
358
327
  layerTransformation = `${layerTransformation},${primary$1.join(',')}`; // Add all applied transformations
359
328
 
360
- layerTransformation = `${layerTransformation}/fl_layer_apply`;
329
+ layerTransformation = `${layerTransformation}/fl_layer_apply,fl_no_overflow`;
361
330
 
362
331
  if (applied.length > 0) {
363
332
  layerTransformation = `${layerTransformation},${applied.join(',')}`;
@@ -365,23 +334,24 @@ function plugin$4({
365
334
 
366
335
 
367
336
  cldImage.addTransformation(layerTransformation);
368
- });
337
+ }
369
338
  }
370
339
 
371
340
  var overlaysPlugin = {
372
341
  __proto__: null,
373
342
  props: props$4,
343
+ DEFAULT_TEXT_OPTIONS: DEFAULT_TEXT_OPTIONS,
374
344
  plugin: plugin$4
375
345
  };
376
346
 
377
347
  const props$3 = ['rawTransformations'];
378
348
  function plugin$3({
379
349
  cldImage,
380
- cldOptions
350
+ options
381
351
  } = {}) {
382
352
  const {
383
353
  rawTransformations = []
384
- } = cldOptions;
354
+ } = options;
385
355
  rawTransformations.forEach(transformation => {
386
356
  cldImage.addTransformation(transformation);
387
357
  });
@@ -396,12 +366,11 @@ var rawTransformationsPlugin = {
396
366
  const props$2 = ['removeBackground'];
397
367
  function plugin$2({
398
368
  cldImage,
399
- options,
400
- cldOptions
369
+ options
401
370
  } = {}) {
402
371
  const {
403
372
  removeBackground = false
404
- } = cldOptions;
373
+ } = options;
405
374
 
406
375
  if (removeBackground) {
407
376
  cldImage.effect('e_background_removal');
@@ -414,25 +383,51 @@ var removeBackgroundPlugin = {
414
383
  plugin: plugin$2
415
384
  };
416
385
 
417
- const _excluded = ["publicId", "type", "position", "text", "effects"];
418
- const props$1 = ['underlays'];
386
+ const _excluded$2 = ["publicId", "type", "position", "text", "effects"];
387
+ const props$1 = ['underlay', 'underlays'];
419
388
  function plugin$1({
420
389
  cldImage,
421
- options,
422
- cldOptions
390
+ options
423
391
  } = {}) {
424
392
  const {
393
+ underlay,
425
394
  underlays = []
426
- } = cldOptions;
395
+ } = options;
427
396
  const typeQualifier = 'u';
428
- underlays.forEach(_ref => {
397
+
398
+ if (Array.isArray(underlays)) {
399
+ underlays.forEach(applyUnderlay);
400
+ }
401
+
402
+ if (typeof underlay === 'string') {
403
+ const underlayOptions = {
404
+ publicId: underlay,
405
+ crop: 'fill'
406
+ };
407
+
408
+ if (options.width) {
409
+ underlayOptions.width = options.width;
410
+ }
411
+
412
+ if (options.height) {
413
+ underlayOptions.height = options.height;
414
+ }
415
+
416
+ applyUnderlay(underlayOptions);
417
+ }
418
+ /**
419
+ * applyUnderlay
420
+ */
421
+
422
+
423
+ function applyUnderlay(_ref) {
429
424
  let {
430
425
  publicId,
431
426
  type,
432
427
  position: position$1,
433
428
  effects: layerEffects = []
434
429
  } = _ref,
435
- options = _objectWithoutPropertiesLoose(_ref, _excluded);
430
+ options = _objectWithoutPropertiesLoose(_ref, _excluded$2);
436
431
 
437
432
  const hasPublicId = typeof publicId === 'string';
438
433
  const hasPosition = typeof position$1 === 'object';
@@ -481,7 +476,7 @@ function plugin$1({
481
476
 
482
477
  layerTransformation = `${layerTransformation},${primary$1.join(',')}`; // Add all applied transformations
483
478
 
484
- layerTransformation = `${layerTransformation}/fl_layer_apply`;
479
+ layerTransformation = `${layerTransformation}/fl_layer_apply,fl_no_overflow`;
485
480
 
486
481
  if (applied.length > 0) {
487
482
  layerTransformation = `${layerTransformation},${applied.join(',')}`;
@@ -489,7 +484,7 @@ function plugin$1({
489
484
 
490
485
 
491
486
  cldImage.addTransformation(layerTransformation);
492
- });
487
+ }
493
488
  }
494
489
 
495
490
  var underlaysPlugin = {
@@ -501,12 +496,12 @@ var underlaysPlugin = {
501
496
  const props = ['zoompan'];
502
497
  function plugin({
503
498
  cldImage,
504
- cldOptions
499
+ options
505
500
  } = {}) {
506
501
  const {
507
502
  zoompan = false
508
- } = cldOptions;
509
- const options = {};
503
+ } = options;
504
+ const overrides = {};
510
505
 
511
506
  if (zoompan === true) {
512
507
  cldImage.effect('e_zoompan');
@@ -539,11 +534,11 @@ function plugin({
539
534
  }
540
535
 
541
536
  if (zoompan !== false) {
542
- options.format = 'gif';
537
+ overrides.format = 'gif';
543
538
  }
544
539
 
545
540
  return {
546
- options
541
+ options: overrides
547
542
  };
548
543
  }
549
544
 
@@ -553,12 +548,19 @@ var zoompanPlugin = {
553
548
  plugin: plugin
554
549
  };
555
550
 
556
- let cld;
557
551
  const transformationPlugins = [// Background Removal must always come first
558
552
  removeBackgroundPlugin, croppingPlugin, effectsPlugin, overlaysPlugin, underlaysPlugin, zoompanPlugin, // Raw transformations needs to be last simply to make sure
559
553
  // it's always expected to applied the same way
560
554
  rawTransformationsPlugin];
561
- function cloudinaryLoader(defaultOptions, cldOptions, cldConfig = {}) {
555
+ let cld;
556
+ /**
557
+ * constructCloudinaryUrl
558
+ */
559
+
560
+ function constructCloudinaryUrl({
561
+ options,
562
+ config
563
+ }) {
562
564
  if (!cld) {
563
565
  cld = new Cloudinary(_extends({
564
566
  cloud: {
@@ -568,14 +570,9 @@ function cloudinaryLoader(defaultOptions, cldOptions, cldConfig = {}) {
568
570
  // Used to avoid issues with SSR particularly for the blurred placeholder
569
571
  analytics: false
570
572
  }
571
- }, cldConfig));
573
+ }, config));
572
574
  }
573
575
 
574
- const options = _extends({
575
- format: 'auto',
576
- quality: 'auto'
577
- }, defaultOptions);
578
-
579
576
  const publicId = getPublicId(options.src);
580
577
  const cldImage = cld.image(publicId);
581
578
  transformationPlugins.forEach(({
@@ -585,15 +582,83 @@ function cloudinaryLoader(defaultOptions, cldOptions, cldConfig = {}) {
585
582
  options: pluginOptions
586
583
  } = plugin({
587
584
  cldImage,
588
- options,
589
- cldOptions
585
+ options
590
586
  }) || {};
591
587
 
592
588
  if (pluginOptions != null && pluginOptions.format) {
593
589
  options.format = pluginOptions.format;
594
590
  }
595
591
  });
596
- return cldImage.format(options.format).delivery(`q_${options.quality}`).toURL();
592
+ return cldImage.setDeliveryType(options.deliveryType || 'upload').format(options.format || 'auto').delivery(`q_${options.quality || 'auto'}`).toURL();
593
+ }
594
+ /**
595
+ * Retrieves the public id of a cloudiary image url. If no url is recognized it returns the parameter it self.
596
+ * If it's recognized that is a url and it's not possible to get the public id, it warns the user.
597
+ *
598
+ * @param {string} src The cloudiary url or public id.
599
+ *
600
+ * @return {string} The images public id
601
+ */
602
+
603
+ function getPublicId(src) {
604
+ if (typeof src !== 'string') {
605
+ throw new Error(`Invalid src of type ${typeof src}`);
606
+ }
607
+
608
+ if (src.includes('res.cloudinary.com')) {
609
+ const regexWithTransformations = /(https?)\:\/\/(res.cloudinary.com)\/([^\/]+)\/(image|video|raw)\/(upload|authenticated)\/(.*)\/(v[0-9]+)\/(.+)(?:\.[a-z]{3})?/;
610
+ const regexWithoutTransformations = /(https?)\:\/\/(res.cloudinary.com)\/([^\/]+)\/(image|video|raw)\/(upload|authenticated)\/(v[0-9]+)\/(.+)(?:\.[a-z]{3})?/;
611
+ const withTransformations = src.match(regexWithTransformations);
612
+ const withoutTransformations = src.match(regexWithoutTransformations);
613
+
614
+ if (withTransformations) {
615
+ return withTransformations[withTransformations.length - 1];
616
+ } else if (withoutTransformations) {
617
+ return withoutTransformations[withoutTransformations.length - 1];
618
+ } else {
619
+ console.warn(`Not possible to retrieve the publicUrl from ${src}, make sure it's a valid cloudinary image url.`);
620
+ }
621
+ }
622
+
623
+ return src;
624
+ }
625
+ /**
626
+ * createPlaceholderUrl
627
+ */
628
+
629
+ function createPlaceholderUrl({
630
+ src,
631
+ placeholder = true,
632
+ config
633
+ }) {
634
+ const rawTransformations = [];
635
+
636
+ if (placeholder === 'grayscale') {
637
+ rawTransformations.push('e_grayscale');
638
+ }
639
+
640
+ if (typeof placeholder === 'string' && placeholder.includes('color:')) {
641
+ const color = placeholder.split(':').splice(1).join(':');
642
+ rawTransformations.push('e_grayscale');
643
+ rawTransformations.push(`e_colorize:60,co_${color}`);
644
+ }
645
+
646
+ return constructCloudinaryUrl({
647
+ options: {
648
+ src,
649
+ width: 100,
650
+ quality: 1,
651
+ rawTransformations
652
+ },
653
+ config
654
+ });
655
+ }
656
+
657
+ function cloudinaryLoader(defaultOptions, cldOptions, cldConfig = {}) {
658
+ return constructCloudinaryUrl({
659
+ options: _extends({}, defaultOptions, cldOptions),
660
+ config: cldConfig
661
+ });
597
662
  }
598
663
 
599
664
  const CldImage = props => {
@@ -646,5 +711,190 @@ const CldImage = props => {
646
711
  }));
647
712
  };
648
713
 
649
- export { CldImage, cloudinaryLoader, position, primary, text };
714
+ const _excluded$1 = ["excludeTags", "twitterTitle"];
715
+ const IMAGE_WIDTH = 2400;
716
+ const IMAGE_HEIGHT = 1200;
717
+ const TWITTER_CARD = 'summary_large_image';
718
+
719
+ const CldOgImage = _ref => {
720
+ let {
721
+ excludeTags = [],
722
+ twitterTitle
723
+ } = _ref,
724
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
725
+
726
+ const options = _extends({}, props, {
727
+ width: props.width || IMAGE_WIDTH,
728
+ height: props.height || IMAGE_HEIGHT,
729
+ crop: props.crop || 'fill',
730
+ gravity: props.gravity || 'center'
731
+ });
732
+
733
+ const ogImageUrl = constructCloudinaryUrl({
734
+ options
735
+ }); // We need to include the tags within the Next.js Head component rather than
736
+ // direcly adding them inside of the Head otherwise we get unexpected results
737
+
738
+ return /*#__PURE__*/jsxs(Head, {
739
+ children: [/*#__PURE__*/jsx("meta", {
740
+ property: "og:image",
741
+ content: ogImageUrl
742
+ }), /*#__PURE__*/jsx("meta", {
743
+ property: "og:image:secure_url",
744
+ content: ogImageUrl
745
+ }), /*#__PURE__*/jsx("meta", {
746
+ property: "og:image:width",
747
+ content: options.width
748
+ }), /*#__PURE__*/jsx("meta", {
749
+ property: "og:image:height",
750
+ content: options.height
751
+ }), options.alt && /*#__PURE__*/jsx("meta", {
752
+ property: "og:image:alt",
753
+ content: options.alt
754
+ }), !excludeTags.includes('twitter:title') && /*#__PURE__*/jsx("meta", {
755
+ property: "twitter:title",
756
+ content: twitterTitle || ' '
757
+ }), /*#__PURE__*/jsx("meta", {
758
+ property: "twitter:card",
759
+ content: TWITTER_CARD
760
+ }), /*#__PURE__*/jsx("meta", {
761
+ property: "twitter:image",
762
+ content: ogImageUrl
763
+ })]
764
+ });
765
+ };
766
+
767
+ const CldUploadWidget = ({
768
+ children,
769
+ onUpload,
770
+ options,
771
+ signed,
772
+ signatureEndpoint
773
+ }) => {
774
+ const cloudinary = useRef();
775
+ const widget = useRef();
776
+ /**
777
+ * generateSignature
778
+ * @description Makes a request to an endpoint to sign Cloudinary parameters as part of widget creation
779
+ */
780
+
781
+ function generateSignature(callback, paramsToSign) {
782
+ fetch(signatureEndpoint, {
783
+ method: "POST",
784
+ body: JSON.stringify({
785
+ paramsToSign
786
+ })
787
+ }).then(r => r.json()).then(({
788
+ signature
789
+ }) => {
790
+ callback(signature);
791
+ });
792
+ }
793
+ /**
794
+ * createWidget
795
+ * @description Creates a new instance of the Cloudinary widget and stores in a ref
796
+ */
797
+
798
+
799
+ function createWidget() {
800
+ var _cloudinary$current;
801
+
802
+ // When creating a signed upload, you need to provide both your Cloudinary API Key
803
+ // as well as a signature generator function that will sign any paramters
804
+ // either on page load or during the upload process. Read more about signed uploads at:
805
+ // https://cloudinary.com/documentation/upload_widget#signed_uploads
806
+ const totalOptions = _extends({}, options, !!signed && {
807
+ uploadSignature: generateSignature
808
+ }); // no need for apiSecret because of api/sign-cloudinary-params
809
+
810
+
811
+ if (signed && !totalOptions.apiKey) {
812
+ return new Error("Signed Upload needs apiKey!");
813
+ }
814
+
815
+ return (_cloudinary$current = cloudinary.current) == null ? void 0 : _cloudinary$current.createUploadWidget(totalOptions, function (error, result) {
816
+ // The callback is a bit more chatty than failed or success so
817
+ // only trigger when one of those are the case. You can additionally
818
+ // create a separate handler such as onEvent and trigger it on
819
+ // ever occurance
820
+ if (error || result.event === "success") {
821
+ onUpload(error, result, widget == null ? void 0 : widget.current);
822
+ }
823
+ });
824
+ }
825
+ /**
826
+ * open
827
+ * @description When triggered, uses the current widget instance to open the upload modal
828
+ */
829
+
830
+
831
+ function open() {
832
+ if (!(widget != null && widget.current)) {
833
+ widget.current = createWidget();
834
+ }
835
+
836
+ (widget == null ? void 0 : widget.current) && widget.current.open();
837
+ }
838
+ /**
839
+ * handleOnLoad
840
+ * @description Stores the Cloudinary window instance to a ref when the widget script loads
841
+ */
842
+
843
+
844
+ function handleOnLoad() {
845
+ cloudinary.current = window.cloudinary;
846
+ }
847
+
848
+ return /*#__PURE__*/jsxs(Fragment, {
849
+ children: [children({
850
+ cloudinary: cloudinary.current,
851
+ widget: widget.current,
852
+ open
853
+ }), /*#__PURE__*/jsx(Script, {
854
+ id: `cloudinary-${Math.floor(Math.random() * 100)}`,
855
+ src: "https://widget.cloudinary.com/v2.0/global/all.js",
856
+ onLoad: handleOnLoad,
857
+ onError: e => {
858
+ console.error("Script failed to load", e);
859
+ }
860
+ })]
861
+ });
862
+ };
863
+
864
+ const _excluded = ["onUpload", "options", "signed", "label", "children"];
865
+
866
+ const CldUploadButton = _ref => {
867
+ let {
868
+ onUpload,
869
+ options,
870
+ signed,
871
+ children
872
+ } = _ref,
873
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
874
+
875
+ return /*#__PURE__*/jsx(Fragment, {
876
+ children: /*#__PURE__*/jsx(CldUploadWidget, {
877
+ signed: signed,
878
+ options: options,
879
+ onUpload: onUpload,
880
+ signatureEndpoint: signed != null ? signed : props.signatureEndpoint,
881
+ children: ({
882
+ open
883
+ }) => {
884
+ function handleOnClick(e) {
885
+ e.preventDefault();
886
+ open();
887
+ }
888
+
889
+ return /*#__PURE__*/jsx("button", _extends({
890
+ onClick: handleOnClick
891
+ }, props, {
892
+ children: children
893
+ }));
894
+ }
895
+ })
896
+ });
897
+ };
898
+
899
+ export { CldImage, CldOgImage, CldUploadButton, CldUploadWidget, cloudinaryLoader, position, primary, text };
650
900
  //# sourceMappingURL=next-cloudinary.modern.mjs.map