react-bricks 3.0.0 → 3.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-bricks",
3
- "version": "3.0.0",
3
+ "version": "3.1.1",
4
4
  "description": "React Bricks is a CMS with visual editing based on React components.",
5
5
  "keywords": [
6
6
  "react bricks",
@@ -16,8 +16,13 @@
16
16
  "license": "UNLICENSED",
17
17
  "author": "Matteo Frana @ F2 .net engineering s.r.l. <f2@f2.net>",
18
18
  "main": "index.js",
19
- "module": "react-bricks.esm.production.min.js",
19
+ "module": "react-bricks.esm.js",
20
20
  "typings": "react-bricks.d.ts",
21
+ "exports": {
22
+ "require": "./index.js",
23
+ "import": "./react-bricks.esm.js",
24
+ "default": "./react-bricks.esm.js"
25
+ },
21
26
  "peerDependencies": {
22
27
  "react": ">=17",
23
28
  "react-dom": ">=17"
package/react-bricks.d.ts CHANGED
@@ -1,11 +1,9 @@
1
- import * as React from 'react';
2
- import React__default from 'react';
1
+ import React, { FC, ReactElement, Context } from 'react';
3
2
  import { BaseEditor, Editor as Editor$1, Node, Descendant } from 'slate';
4
- import { ReactEditor, RenderElementProps, RenderLeafProps } from 'slate-react';
5
3
  import { HistoryEditor } from 'slate-history';
6
- import styleInject from '../node_modules/style-inject/dist/style-inject.es.js';
7
- import * as react_query from 'react-query';
4
+ import { ReactEditor, RenderElementProps, RenderLeafProps } from 'slate-react';
8
5
  import { UseQueryResult } from 'react-query';
6
+ import styleInject from '../node_modules/style-inject/dist/style-inject.es.js';
9
7
  export { v4 as uuid } from 'uuid';
10
8
 
11
9
  declare module 'slate' {
@@ -25,9 +23,9 @@ interface TextProps {
25
23
  children: any;
26
24
  }) => JSX.Element;
27
25
  propName: string;
28
- multiline: boolean;
26
+ multiline?: boolean;
29
27
  }
30
- declare const Text: React.FC<TextProps>;
28
+ declare const Text: FC<TextProps>;
31
29
 
32
30
  declare namespace types {
33
31
  /**
@@ -98,7 +96,7 @@ declare namespace types {
98
96
  /**
99
97
  * A Brick is a type of content block
100
98
  */
101
- type Brick<T = {}> = React__default.FC<T> & {
99
+ type Brick<T = {}> = React.FC<T> & {
102
100
  schema: IBlockType;
103
101
  };
104
102
  /**
@@ -154,6 +152,7 @@ declare namespace types {
154
152
  slug: string;
155
153
  meta: IMeta;
156
154
  customValues?: Props;
155
+ externalData?: Props;
157
156
  content: IContentBlock[];
158
157
  authorId?: string;
159
158
  author: Author;
@@ -235,8 +234,8 @@ declare namespace types {
235
234
  className?: string;
236
235
  activeClassName?: string;
237
236
  isAdmin?: boolean;
238
- children: React__default.ReactNode;
239
- }) => React__default.ReactElement;
237
+ children: React.ReactNode;
238
+ }) => React.ReactElement;
240
239
  /**
241
240
  * Props of a content block
242
241
  */
@@ -253,6 +252,7 @@ declare namespace types {
253
252
  hideFromAddMenu?: boolean;
254
253
  sideEditProps?: Array<ISideEditProp | ISideGroup>;
255
254
  repeaterItems?: IRepeaterItem[];
255
+ mapExternalDataToProps?: (externalData: Props, brickProps?: Props) => Props;
256
256
  playgroundLinkUrl?: string;
257
257
  playgroundLinkLabel?: string;
258
258
  category?: string;
@@ -300,7 +300,7 @@ declare namespace types {
300
300
  name: string;
301
301
  label: string;
302
302
  type: SideEditPropType;
303
- component?: React__default.FC<ICustomKnobProps>;
303
+ component?: React.FC<ICustomKnobProps>;
304
304
  validate?: (value: any, props?: Props) => boolean | string;
305
305
  show?: (props: Props) => boolean;
306
306
  textareaOptions?: {
@@ -347,6 +347,14 @@ declare namespace types {
347
347
  width: number;
348
348
  height: number;
349
349
  }
350
+ /**
351
+ * File value interface
352
+ */
353
+ interface IFileSource {
354
+ name: string;
355
+ url: string;
356
+ size: number;
357
+ }
350
358
  /**
351
359
  * A Color for a Select sidebar prop
352
360
  */
@@ -368,6 +376,7 @@ declare namespace types {
368
376
  defaultFeaturedImage?: string;
369
377
  getDefaultContent?: () => string[];
370
378
  customFields?: Array<ISideEditPropPage | ISideGroup>;
379
+ getExternalData?: (page: Page) => Promise<Props>;
371
380
  }
372
381
  /**
373
382
  * Structure returned by the cleanBlocks function
@@ -429,6 +438,7 @@ declare namespace types {
429
438
  isDarkColorMode?: boolean;
430
439
  toggleColorMode?: () => void;
431
440
  useCssInJs?: boolean;
441
+ appRootElement: string | HTMLElement;
432
442
  clickToEditSide?: ClickToEditSide;
433
443
  customFields?: Array<ISideEditPropPage | ISideGroup>;
434
444
  responsiveBreakpoints: ResponsiveBreakpoint[];
@@ -467,7 +477,7 @@ declare namespace types {
467
477
  renderLeaf?: (props: RenderLeafProps) => JSX.Element;
468
478
  toggle: (editor: Editor$1, plugins: RichTextPlugin[]) => void;
469
479
  button?: {
470
- icon: React__default.ReactElement;
480
+ icon: React.ReactElement;
471
481
  isActive: (editor: Editor$1) => boolean;
472
482
  };
473
483
  enhanceEditor?: (editor: Editor$1) => Editor$1;
@@ -480,7 +490,7 @@ declare namespace types {
480
490
  label?: string;
481
491
  hotKey?: string;
482
492
  render: (props: RenderLeafProps) => JSX.Element;
483
- icon: React__default.ReactElement;
493
+ icon: React.ReactElement;
484
494
  }
485
495
  /**
486
496
  * Constructor for a Mark plugin
@@ -497,7 +507,7 @@ declare namespace types {
497
507
  hotKey?: string;
498
508
  render: (props: RenderElementProps) => JSX.Element;
499
509
  renderItem?: (props: RenderElementProps) => JSX.Element;
500
- icon: React__default.ReactElement;
510
+ icon: React.ReactElement;
501
511
  }
502
512
  /**
503
513
  * Constructor for a Block plugin
@@ -518,7 +528,7 @@ interface RichTextProps {
518
528
  plugins?: types.RichTextPlugin[];
519
529
  multiline?: boolean;
520
530
  }
521
- declare const RichText: React.FC<RichTextProps>;
531
+ declare const RichText: FC<RichTextProps>;
522
532
 
523
533
  /**
524
534
  * Props for renderLink render function
@@ -533,6 +543,7 @@ interface CompatibleRichTextProps {
533
543
  renderBlock: (props: RenderElementProps) => JSX.Element;
534
544
  placeholder: string;
535
545
  propName: string;
546
+ multiline?: boolean;
536
547
  allowedFeatures?: types.RichTextFeatures[];
537
548
  renderBold?: (props: RenderLeafProps) => JSX.Element;
538
549
  renderItalic?: (props: RenderLeafProps) => JSX.Element;
@@ -550,7 +561,7 @@ interface CompatibleRichTextProps {
550
561
  renderH6?: (props: RenderElementProps) => JSX.Element;
551
562
  renderQuote?: (props: RenderElementProps) => JSX.Element;
552
563
  }
553
- declare const CompatibleRichText: React__default.FC<CompatibleRichTextProps>;
564
+ declare const CompatibleRichText: React.FC<CompatibleRichTextProps>;
554
565
 
555
566
  /**
556
567
  * Props for Image
@@ -566,7 +577,22 @@ interface ImageProps {
566
577
  imageClassName?: string;
567
578
  imageStyle?: object;
568
579
  }
569
- declare const Image: React.FC<ImageProps>;
580
+ declare const Image: FC<ImageProps>;
581
+
582
+ /**
583
+ * Props for Text
584
+ */
585
+ interface FileProps {
586
+ propName: string;
587
+ renderBlock: (props?: File) => JSX.Element;
588
+ allowedExtensions?: string[];
589
+ }
590
+ interface File {
591
+ name: string;
592
+ size: string;
593
+ url: string;
594
+ }
595
+ declare const File: React.FC<FileProps>;
570
596
 
571
597
  /**
572
598
  * Props for Repeater
@@ -574,29 +600,16 @@ declare const Image: React.FC<ImageProps>;
574
600
  interface RepeaterProps {
575
601
  propName: string;
576
602
  itemProps?: types.Props;
577
- renderWrapper?: (items: React.ReactElement) => React.ReactElement;
578
- renderItemWrapper?: (item: React.ReactElement, index: number, itemsCount: number) => React.ReactElement;
603
+ renderWrapper?: (items: ReactElement) => ReactElement;
604
+ renderItemWrapper?: (item: ReactElement, index: number, itemsCount: number) => ReactElement;
579
605
  }
580
- declare const Repeater: React.FC<RepeaterProps>;
606
+ declare const Repeater: FC<RepeaterProps>;
581
607
 
582
- declare const Link: React.FC<LinkProps>;
608
+ declare const Link: FC<LinkProps>;
583
609
 
584
- declare const ReactBricks: React.FC<types.ReactBricksConfig>;
610
+ declare const ReactBricks: FC<types.ReactBricksConfig>;
585
611
 
586
- declare const ReactBricksContext: React.Context<types.IReactBricksContext>;
587
-
588
- var css_248z = ".tippy-box[data-animation=fade][data-state=hidden]{opacity:0}[data-tippy-root]{max-width:calc(100vw - 10px)}.tippy-box{background-color:#333;border-radius:4px;color:#fff;font-size:14px;line-height:1.4;outline:0;position:relative;transition-property:transform,visibility,opacity}.tippy-box[data-placement^=top]>.tippy-arrow{bottom:0}.tippy-box[data-placement^=top]>.tippy-arrow:before{border-top-color:initial;border-width:8px 8px 0;bottom:-7px;left:0;transform-origin:center top}.tippy-box[data-placement^=bottom]>.tippy-arrow{top:0}.tippy-box[data-placement^=bottom]>.tippy-arrow:before{border-bottom-color:initial;border-width:0 8px 8px;left:0;top:-7px;transform-origin:center bottom}.tippy-box[data-placement^=left]>.tippy-arrow{right:0}.tippy-box[data-placement^=left]>.tippy-arrow:before{border-left-color:initial;border-width:8px 0 8px 8px;right:-7px;transform-origin:center left}.tippy-box[data-placement^=right]>.tippy-arrow{left:0}.tippy-box[data-placement^=right]>.tippy-arrow:before{border-right-color:initial;border-width:8px 8px 8px 0;left:-7px;transform-origin:center right}.tippy-box[data-inertia][data-state=visible]{transition-timing-function:cubic-bezier(.54,1.5,.38,1.11)}.tippy-arrow{color:#333;height:16px;width:16px}.tippy-arrow:before{border-color:transparent;border-style:solid;content:\"\";position:absolute}.tippy-content{padding:5px 9px;position:relative;z-index:1}";
589
- styleInject(css_248z);
590
-
591
- declare const Admin: React.FC<AdminProps>;
592
-
593
- declare const AdminContext: React.Context<types.IAdminContext>;
594
-
595
- declare const Header: React.FC<HeaderProps>;
596
-
597
- declare const Login: React.FC;
598
-
599
- declare const Editor: React.FC;
612
+ declare const ReactBricksContext: Context<types.IReactBricksContext>;
600
613
 
601
614
  /**
602
615
  * Props for PageViewer
@@ -604,48 +617,17 @@ declare const Editor: React.FC;
604
617
  interface PageViewerProps {
605
618
  page: types.Page | null | undefined;
606
619
  }
607
- declare const PageViewer: React.FC<PageViewerProps>;
620
+ declare const PageViewer: FC<PageViewerProps>;
608
621
 
609
- declare const Playground: () => JSX.Element;
622
+ declare const Editor: FC;
610
623
 
611
- declare const AppSettings: React.FC;
624
+ declare const Playground: () => JSX.Element;
612
625
 
613
- declare const useAuth: () => {
614
- loginUser: (email: string, password: string) => Promise<({
615
- id: string;
616
- email: string;
617
- firstName: string;
618
- lastName: string;
619
- company: string;
620
- avatarUrl?: string | undefined;
621
- isAdmin: boolean;
622
- token: string;
623
- appName: string;
624
- deployHookUrl?: string | undefined;
625
- deployHookMethod?: string | undefined;
626
- deployHookTriggerOnScheduledPublishing: boolean;
627
- deployHookStagingUrl?: string | undefined;
628
- deployHookStagingMethod?: string | undefined;
629
- deployHookStagingTriggerOnScheduledPublishing: boolean;
630
- eventsHookUrl?: string | undefined;
631
- eventsHookAuthToken?: string | undefined;
632
- canCreatePage: boolean;
633
- canDeletePage: boolean;
634
- canDeploy: boolean;
635
- canDeployStaging: boolean;
636
- role: string;
637
- plan: string;
638
- languages: types.Language[];
639
- defaultLanguage: string;
640
- } & {
641
- authToken: string;
642
- }) | null>;
643
- logoutUser: () => void;
644
- };
626
+ declare const AppSettings: FC;
645
627
 
646
- declare const usePage$1: (pageId: string, language?: string | undefined) => react_query.UseQueryResult<types.Page, unknown>;
628
+ declare const usePage: (pageId: string, language?: string | undefined) => UseQueryResult<types.Page, unknown>;
647
629
 
648
- declare const usePage: (slug: string, language?: string | undefined) => react_query.UseQueryResult<types.Page, unknown>;
630
+ declare const usePage$1: (slug: string, language?: string | undefined) => UseQueryResult<types.Page, unknown>;
649
631
 
650
632
  /**
651
633
  * Values returned from usePages
@@ -707,9 +689,7 @@ declare const usePageValues: () => [types.PageValues, (pageData: types.PartialPa
707
689
 
708
690
  declare const useReactBricksContext: () => types.IReactBricksContext;
709
691
 
710
- declare const useAdminContext: () => types.IReadAdminContext;
711
-
712
- declare const fetchPage: (slug: string, apiKey: string, language?: string | undefined) => Promise<types.Page>;
692
+ declare const fetchPage: (slug: string, apiKey: string, language?: string | undefined, pageTypes?: types.IPageType[] | undefined) => Promise<types.Page>;
713
693
 
714
694
  /**
715
695
  * Values returned from fetchPages
@@ -742,7 +722,7 @@ declare const cleanPage: (page: types.Page, pageTypes: types.IPageType[], bricks
742
722
 
743
723
  declare const getPagePlainText: (blocks: types.IContentBlock[]) => string[];
744
724
 
745
- declare const _default$1: {
725
+ declare const _default: {
746
726
  bold: types.RichTextPlugin;
747
727
  italic: types.RichTextPlugin;
748
728
  code: types.RichTextPlugin;
@@ -759,9 +739,56 @@ declare const _default$1: {
759
739
  unorderedList: types.RichTextPlugin;
760
740
  };
761
741
 
762
- declare const _default: {
742
+ declare const _default$1: {
763
743
  serialize: (nodes: Node[]) => string;
764
744
  deserialize: (input: string) => Descendant[];
745
+ isText: (value: any) => boolean;
746
+ };
747
+
748
+ var css_248z = ".tippy-box[data-animation=fade][data-state=hidden]{opacity:0}[data-tippy-root]{max-width:calc(100vw - 10px)}.tippy-box{background-color:#333;border-radius:4px;color:#fff;font-size:14px;line-height:1.4;outline:0;position:relative;transition-property:transform,visibility,opacity}.tippy-box[data-placement^=top]>.tippy-arrow{bottom:0}.tippy-box[data-placement^=top]>.tippy-arrow:before{border-top-color:initial;border-width:8px 8px 0;bottom:-7px;left:0;transform-origin:center top}.tippy-box[data-placement^=bottom]>.tippy-arrow{top:0}.tippy-box[data-placement^=bottom]>.tippy-arrow:before{border-bottom-color:initial;border-width:0 8px 8px;left:0;top:-7px;transform-origin:center bottom}.tippy-box[data-placement^=left]>.tippy-arrow{right:0}.tippy-box[data-placement^=left]>.tippy-arrow:before{border-left-color:initial;border-width:8px 0 8px 8px;right:-7px;transform-origin:center left}.tippy-box[data-placement^=right]>.tippy-arrow{left:0}.tippy-box[data-placement^=right]>.tippy-arrow:before{border-right-color:initial;border-width:8px 8px 8px 0;left:-7px;transform-origin:center right}.tippy-box[data-inertia][data-state=visible]{transition-timing-function:cubic-bezier(.54,1.5,.38,1.11)}.tippy-arrow{color:#333;height:16px;width:16px}.tippy-arrow:before{border-color:transparent;border-style:solid;content:\"\";position:absolute}.tippy-content{padding:5px 9px;position:relative;z-index:1}";
749
+ styleInject(css_248z);
750
+
751
+ declare const Admin: FC<AdminProps>;
752
+
753
+ declare const AdminContext: Context<types.IAdminContext>;
754
+
755
+ declare const Header: FC<HeaderProps>;
756
+
757
+ declare const Login: FC;
758
+
759
+ declare const useAuth: () => {
760
+ loginUser: (email: string, password: string) => Promise<({
761
+ id: string;
762
+ email: string;
763
+ firstName: string;
764
+ lastName: string;
765
+ company: string;
766
+ avatarUrl?: string | undefined;
767
+ isAdmin: boolean;
768
+ token: string;
769
+ appName: string;
770
+ deployHookUrl?: string | undefined;
771
+ deployHookMethod?: string | undefined;
772
+ deployHookTriggerOnScheduledPublishing: boolean;
773
+ deployHookStagingUrl?: string | undefined;
774
+ deployHookStagingMethod?: string | undefined;
775
+ deployHookStagingTriggerOnScheduledPublishing: boolean;
776
+ eventsHookUrl?: string | undefined;
777
+ eventsHookAuthToken?: string | undefined;
778
+ canCreatePage: boolean;
779
+ canDeletePage: boolean;
780
+ canDeploy: boolean;
781
+ canDeployStaging: boolean;
782
+ role: string;
783
+ plan: string;
784
+ languages: types.Language[];
785
+ defaultLanguage: string;
786
+ } & {
787
+ authToken: string;
788
+ }) | null>;
789
+ logoutUser: () => void;
765
790
  };
766
791
 
767
- export { Admin, AdminContext, AppSettings, Editor, Header, Image, Link, Login, PageViewer, _default as Plain, Playground, ReactBricks, ReactBricksContext, Repeater, CompatibleRichText as RichText, RichText as RichTextExt, Text, cleanPage, fetchPage, fetchPages, getPagePlainText, _default$1 as plugins, types, useAdminContext, useAuth, usePage$1 as usePage, usePage as usePagePublic, usePageValues, usePages, usePagesPublic, useReactBricksContext, useVisualEdit };
792
+ declare const useAdminContext: () => types.IReadAdminContext;
793
+
794
+ export { Admin, AdminContext, AppSettings, Editor, File, Header, Image, Link, Login, PageViewer, _default$1 as Plain, Playground, ReactBricks, ReactBricksContext, Repeater, CompatibleRichText as RichText, RichText as RichTextExt, Text, cleanPage, fetchPage, fetchPages, getPagePlainText, _default as plugins, types, useAdminContext, useAuth, usePage, usePage$1 as usePagePublic, usePageValues, usePages, usePagesPublic, useReactBricksContext, useVisualEdit };