@starlightcms/react-sdk 1.1.0 → 2.1.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.
Files changed (122) hide show
  1. package/dist/cjs/VisualContent/blocks/{HTML.d.ts → HTML/index.d.ts} +2 -2
  2. package/dist/cjs/VisualContent/blocks/HTML/index.d.ts.map +1 -0
  3. package/dist/cjs/VisualContent/blocks/{HTML.js → HTML/index.js} +5 -2
  4. package/dist/cjs/VisualContent/blocks/HTML/index.js.map +1 -0
  5. package/dist/cjs/VisualContent/blocks/HTML/styles.d.ts +6 -0
  6. package/dist/cjs/VisualContent/blocks/HTML/styles.d.ts.map +1 -0
  7. package/dist/cjs/VisualContent/blocks/HTML/styles.js +13 -0
  8. package/dist/cjs/VisualContent/blocks/HTML/styles.js.map +1 -0
  9. package/dist/cjs/VisualContent/blocks/Header.d.ts.map +1 -1
  10. package/dist/cjs/VisualContent/blocks/Header.js +3 -1
  11. package/dist/cjs/VisualContent/blocks/Header.js.map +1 -1
  12. package/dist/{esm/VisualContent/blocks/Image.d.ts → cjs/VisualContent/blocks/Image/index.d.ts} +2 -2
  13. package/dist/cjs/VisualContent/blocks/Image/index.d.ts.map +1 -0
  14. package/dist/cjs/VisualContent/blocks/{Image.js → Image/index.js} +17 -11
  15. package/dist/cjs/VisualContent/blocks/Image/index.js.map +1 -0
  16. package/dist/cjs/VisualContent/blocks/Image/styles.d.ts +19 -0
  17. package/dist/cjs/VisualContent/blocks/Image/styles.d.ts.map +1 -0
  18. package/dist/cjs/VisualContent/blocks/Image/styles.js +41 -0
  19. package/dist/cjs/VisualContent/blocks/Image/styles.js.map +1 -0
  20. package/dist/{esm/VisualContent/blocks/List.d.ts → cjs/VisualContent/blocks/List/index.d.ts} +2 -2
  21. package/dist/cjs/VisualContent/blocks/List/index.d.ts.map +1 -0
  22. package/dist/cjs/VisualContent/blocks/{List.js → List/index.js} +6 -3
  23. package/dist/cjs/VisualContent/blocks/List/index.js.map +1 -0
  24. package/dist/cjs/VisualContent/blocks/List/styles.d.ts +6 -0
  25. package/dist/cjs/VisualContent/blocks/List/styles.d.ts.map +1 -0
  26. package/dist/cjs/VisualContent/blocks/List/styles.js +21 -0
  27. package/dist/cjs/VisualContent/blocks/List/styles.js.map +1 -0
  28. package/dist/cjs/VisualContent/blocks/Paragraph.d.ts +1 -1
  29. package/dist/cjs/VisualContent/blocks/Paragraph.d.ts.map +1 -1
  30. package/dist/cjs/VisualContent/blocks/Paragraph.js +6 -3
  31. package/dist/cjs/VisualContent/blocks/Paragraph.js.map +1 -1
  32. package/dist/cjs/VisualContent/blocks/Quote.d.ts +1 -1
  33. package/dist/cjs/VisualContent/blocks/Quote.d.ts.map +1 -1
  34. package/dist/cjs/VisualContent/blocks/Quote.js +3 -1
  35. package/dist/cjs/VisualContent/blocks/Quote.js.map +1 -1
  36. package/dist/cjs/VisualContent/blocks/Video/index.d.ts +16 -0
  37. package/dist/cjs/VisualContent/blocks/Video/index.d.ts.map +1 -0
  38. package/dist/cjs/VisualContent/blocks/Video/index.js +29 -0
  39. package/dist/cjs/VisualContent/blocks/Video/index.js.map +1 -0
  40. package/dist/cjs/VisualContent/blocks/Video/styles.d.ts +14 -0
  41. package/dist/cjs/VisualContent/blocks/Video/styles.d.ts.map +1 -0
  42. package/dist/cjs/VisualContent/blocks/Video/styles.js +41 -0
  43. package/dist/cjs/VisualContent/blocks/Video/styles.js.map +1 -0
  44. package/dist/cjs/VisualContent/index.d.ts +3 -3
  45. package/dist/cjs/VisualContent/index.d.ts.map +1 -1
  46. package/dist/cjs/VisualContent/index.js +9 -7
  47. package/dist/cjs/VisualContent/index.js.map +1 -1
  48. package/dist/cjs/VisualContent/styles.d.ts +12 -12
  49. package/dist/cjs/VisualContent/styles.d.ts.map +1 -1
  50. package/dist/cjs/VisualContent/styles.js +81 -42
  51. package/dist/cjs/VisualContent/styles.js.map +1 -1
  52. package/dist/cjs/VisualContent/types.d.ts +2 -1
  53. package/dist/cjs/VisualContent/types.d.ts.map +1 -1
  54. package/dist/cjs/VisualContent/types.js.map +1 -1
  55. package/dist/esm/VisualContent/blocks/{HTML.d.ts → HTML/index.d.ts} +2 -2
  56. package/dist/esm/VisualContent/blocks/HTML/index.d.ts.map +1 -0
  57. package/dist/esm/VisualContent/blocks/{HTML.js → HTML/index.js} +5 -2
  58. package/dist/esm/VisualContent/blocks/HTML/index.js.map +1 -0
  59. package/dist/esm/VisualContent/blocks/HTML/styles.d.ts +6 -0
  60. package/dist/esm/VisualContent/blocks/HTML/styles.d.ts.map +1 -0
  61. package/dist/esm/VisualContent/blocks/HTML/styles.js +7 -0
  62. package/dist/esm/VisualContent/blocks/HTML/styles.js.map +1 -0
  63. package/dist/esm/VisualContent/blocks/Header.d.ts.map +1 -1
  64. package/dist/esm/VisualContent/blocks/Header.js +3 -1
  65. package/dist/esm/VisualContent/blocks/Header.js.map +1 -1
  66. package/dist/{cjs/VisualContent/blocks/Image.d.ts → esm/VisualContent/blocks/Image/index.d.ts} +2 -2
  67. package/dist/esm/VisualContent/blocks/Image/index.d.ts.map +1 -0
  68. package/dist/esm/VisualContent/blocks/Image/index.js +45 -0
  69. package/dist/esm/VisualContent/blocks/Image/index.js.map +1 -0
  70. package/dist/esm/VisualContent/blocks/Image/styles.d.ts +19 -0
  71. package/dist/esm/VisualContent/blocks/Image/styles.d.ts.map +1 -0
  72. package/dist/esm/VisualContent/blocks/Image/styles.js +35 -0
  73. package/dist/esm/VisualContent/blocks/Image/styles.js.map +1 -0
  74. package/dist/{cjs/VisualContent/blocks/List.d.ts → esm/VisualContent/blocks/List/index.d.ts} +2 -2
  75. package/dist/esm/VisualContent/blocks/List/index.d.ts.map +1 -0
  76. package/dist/esm/VisualContent/blocks/{List.js → List/index.js} +6 -3
  77. package/dist/esm/VisualContent/blocks/List/index.js.map +1 -0
  78. package/dist/esm/VisualContent/blocks/List/styles.d.ts +6 -0
  79. package/dist/esm/VisualContent/blocks/List/styles.d.ts.map +1 -0
  80. package/dist/esm/VisualContent/blocks/List/styles.js +15 -0
  81. package/dist/esm/VisualContent/blocks/List/styles.js.map +1 -0
  82. package/dist/esm/VisualContent/blocks/Paragraph.d.ts +1 -1
  83. package/dist/esm/VisualContent/blocks/Paragraph.d.ts.map +1 -1
  84. package/dist/esm/VisualContent/blocks/Paragraph.js +6 -3
  85. package/dist/esm/VisualContent/blocks/Paragraph.js.map +1 -1
  86. package/dist/esm/VisualContent/blocks/Quote.d.ts +1 -1
  87. package/dist/esm/VisualContent/blocks/Quote.d.ts.map +1 -1
  88. package/dist/esm/VisualContent/blocks/Quote.js +3 -1
  89. package/dist/esm/VisualContent/blocks/Quote.js.map +1 -1
  90. package/dist/esm/VisualContent/blocks/Video/index.d.ts +16 -0
  91. package/dist/esm/VisualContent/blocks/Video/index.d.ts.map +1 -0
  92. package/dist/esm/VisualContent/blocks/Video/index.js +24 -0
  93. package/dist/esm/VisualContent/blocks/Video/index.js.map +1 -0
  94. package/dist/esm/VisualContent/blocks/Video/styles.d.ts +14 -0
  95. package/dist/esm/VisualContent/blocks/Video/styles.d.ts.map +1 -0
  96. package/dist/esm/VisualContent/blocks/Video/styles.js +35 -0
  97. package/dist/esm/VisualContent/blocks/Video/styles.js.map +1 -0
  98. package/dist/esm/VisualContent/index.d.ts +3 -3
  99. package/dist/esm/VisualContent/index.d.ts.map +1 -1
  100. package/dist/esm/VisualContent/index.js +7 -5
  101. package/dist/esm/VisualContent/index.js.map +1 -1
  102. package/dist/esm/VisualContent/styles.d.ts +12 -12
  103. package/dist/esm/VisualContent/styles.d.ts.map +1 -1
  104. package/dist/esm/VisualContent/styles.js +80 -40
  105. package/dist/esm/VisualContent/styles.js.map +1 -1
  106. package/dist/esm/VisualContent/types.d.ts +2 -1
  107. package/dist/esm/VisualContent/types.d.ts.map +1 -1
  108. package/dist/esm/VisualContent/types.js.map +1 -1
  109. package/package.json +4 -2
  110. package/dist/cjs/VisualContent/blocks/HTML.d.ts.map +0 -1
  111. package/dist/cjs/VisualContent/blocks/HTML.js.map +0 -1
  112. package/dist/cjs/VisualContent/blocks/Image.d.ts.map +0 -1
  113. package/dist/cjs/VisualContent/blocks/Image.js.map +0 -1
  114. package/dist/cjs/VisualContent/blocks/List.d.ts.map +0 -1
  115. package/dist/cjs/VisualContent/blocks/List.js.map +0 -1
  116. package/dist/esm/VisualContent/blocks/HTML.d.ts.map +0 -1
  117. package/dist/esm/VisualContent/blocks/HTML.js.map +0 -1
  118. package/dist/esm/VisualContent/blocks/Image.d.ts.map +0 -1
  119. package/dist/esm/VisualContent/blocks/Image.js +0 -39
  120. package/dist/esm/VisualContent/blocks/Image.js.map +0 -1
  121. package/dist/esm/VisualContent/blocks/List.d.ts.map +0 -1
  122. package/dist/esm/VisualContent/blocks/List.js.map +0 -1
@@ -26,22 +26,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.ListComponent = exports.HTMLComponent = exports.ImageComponent = exports.QuoteComponent = exports.HeaderComponent = exports.ParagraphComponent = exports.VisualContentStyles = exports.VisualContent = void 0;
30
- const react_1 = __importStar(require("react"));
31
- const styles_1 = require("./styles");
32
- Object.defineProperty(exports, "VisualContentStyles", { enumerable: true, get: function () { return styles_1.VisualContentStyles; } });
29
+ exports.VideoComponent = exports.ListComponent = exports.HTMLComponent = exports.ImageComponent = exports.QuoteComponent = exports.HeaderComponent = exports.ParagraphComponent = exports.VisualContent = void 0;
30
+ const Image_1 = __importDefault(require("./blocks/Image"));
31
+ exports.ImageComponent = Image_1.default;
33
32
  const Paragraph_1 = __importDefault(require("./blocks/Paragraph"));
34
33
  exports.ParagraphComponent = Paragraph_1.default;
34
+ const styles_1 = require("./styles");
35
+ const react_1 = __importStar(require("react"));
35
36
  const Header_1 = __importDefault(require("./blocks/Header"));
36
37
  exports.HeaderComponent = Header_1.default;
37
38
  const Quote_1 = __importDefault(require("./blocks/Quote"));
38
39
  exports.QuoteComponent = Quote_1.default;
39
- const Image_1 = __importDefault(require("./blocks/Image"));
40
- exports.ImageComponent = Image_1.default;
41
40
  const HTML_1 = __importDefault(require("./blocks/HTML"));
42
41
  exports.HTMLComponent = HTML_1.default;
43
42
  const List_1 = __importDefault(require("./blocks/List"));
44
43
  exports.ListComponent = List_1.default;
44
+ const Video_1 = __importDefault(require("./blocks/Video"));
45
+ exports.VideoComponent = Video_1.default;
45
46
  const defaultComponents = {
46
47
  paragraph: Paragraph_1.default,
47
48
  header: Header_1.default,
@@ -49,6 +50,7 @@ const defaultComponents = {
49
50
  image: Image_1.default,
50
51
  raw: HTML_1.default,
51
52
  list: List_1.default,
53
+ video: Video_1.default,
52
54
  };
53
55
  /**
54
56
  * Renders HTML content from data returned by a Visual Editor field on Starlight.
@@ -117,7 +119,7 @@ const VisualContent = ({ content, components = {}, excerpt = false, excerptLengt
117
119
  const Component = componentList.paragraph;
118
120
  return (react_1.default.createElement(Component, { key: block.id, id: block.id, type: block.type, data: { text: excerptText } }));
119
121
  }
120
- return (react_1.default.createElement("div", { className: "sl-visual-content" }, content.blocks.map((block) => {
122
+ return (react_1.default.createElement(styles_1.OuterWrapper, { className: "sl-visual-content" }, content.blocks.map((block) => {
121
123
  const Component = componentList[block.type];
122
124
  if (!Component)
123
125
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/VisualContent/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAsC;AAGtC,qCAA8C;AA+H5C,oGA/HO,4BAAmB,OA+HP;AA9HrB,mEAA0C;AA+H3B,6BA/HR,mBAAS,CA+HiB;AA9HjC,6DAAoC;AA+HxB,0BA/HL,gBAAM,CA+Hc;AA9H3B,2DAAkC;AA+HvB,yBA/HJ,eAAK,CA+Ha;AA9HzB,2DAAoD;AA+HzC,yBA/HJ,eAAK,CA+Ha;AA9HzB,yDAAgC;AA+HtB,wBA/HH,cAAI,CA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;QAEzC,OAAO,CACL,8BAAC,SAAS,IACR,GAAG,EAAE,KAAK,CAAC,EAAE,EACb,EAAE,EAAE,KAAK,CAAC,EAAE,EACZ,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,IAAI,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,GAC3B,CACH,CAAA;KACF;IACD,OAAO,CACL,uCAAK,SAAS,EAAC,mBAAmB,IAC/B,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,MAAM,SAAS,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAE3C,IAAI,CAAC,SAAS;YAAE,OAAO,IAAI,CAAA;QAE3B,OAAO,CACL,8BAAC,SAAS,IACR,GAAG,EAAE,KAAK,CAAC,EAAE,EACb,EAAE,EAAE,KAAK,CAAC,EAAE,EACZ,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,IAAI,EAAE,KAAK,CAAC,IAAa,GACzB,CACH,CAAA;IACH,CAAC,CAAC,CACE,CACP,CAAA;AACH,CAAC,CAAA;AAxDY,QAAA,aAAa,iBAwDzB","sourcesContent":["import React, { useMemo } from 'react'\nimport { VisualDataBlock, ParagraphBlock } from '@starlightcms/js-sdk'\nimport { BlockComponents, VisualContentProps } from './types'\nimport { VisualContentStyles } from './styles'\nimport Paragraph from './blocks/Paragraph'\nimport Header from './blocks/Header'\nimport Quote from './blocks/Quote'\nimport Image, { ImageOptions } from './blocks/Image'\nimport HTML from './blocks/HTML'\nimport List from './blocks/List'\n\nconst defaultComponents: BlockComponents = {\n paragraph: Paragraph,\n header: Header,\n quote: Quote,\n image: Image,\n raw: HTML,\n list: List,\n}\n\n/**\n * Renders HTML content from data returned by a Visual Editor field on Starlight.\n *\n * The only required prop is `content`, which is the data returned by a Visual\n * Editor field. Additionally, you can provide custom components to render each\n * data block type.\n *\n * You can also pass the `excerpt` boolean prop to only render a portion of the\n * content, which is useful to summarize the content in lists.\n *\n * To learn how to customize the rendered content, take a look at the\n * [Customizing the output](#) guide page.\n *\n * @example Requesting an entry and rendering its content.\n *\n * Assume we created a \"Posts\" model with a slug of `posts`, and placed a Visual\n * Editor field with a key of `post_content` on it.\n *\n * ```jsx\n * import Starlight, { VisualContent } from '@starlightcms/react-sdk'\n *\n * const EntryComponent = ({ slug }) => {\n * const [entry, setEntry] = useState(null)\n *\n * // This is just an example, you could fetch\n * // the entry any way you want.\n * useEffect(async () => {\n * const response = await Starlight.posts.entries.get(slug)\n *\n * setEntry(response.data)\n * }, [ slug ])\n *\n * // After fetching, content will be on the `entry.data.post_content` property.\n * return (\n * entry ? (\n * <article>\n * <h1>{entry.title}</h1>\n * <VisualContent content={entry.data.post_content} />\n * </article>\n * ) : (\n * <div>Loading...</div>\n * )\n * )\n * }\n *\n * ```\n *\n * @param props Component props. See {@link VisualContentProps} to see the\n * available options.\n * @group VisualContent\n */\nexport const VisualContent = ({\n content,\n components = {},\n excerpt = false,\n excerptLength = 40,\n}: VisualContentProps): JSX.Element => {\n const componentList = useMemo(\n () => ({ ...defaultComponents, ...components }),\n [components]\n )\n\n if (!content) {\n return null as unknown as JSX.Element\n }\n\n if (excerpt) {\n const block = content.blocks.find((block) => block.type === 'paragraph') as\n | VisualDataBlock<ParagraphBlock>\n | undefined\n\n if (!block || !block.data.text) return null as unknown as JSX.Element\n\n const text = block.data.text.split(' ')\n const excerptText =\n text.length > excerptLength\n ? text.splice(0, excerptLength).join(' ') + '...'\n : text.join(' ')\n const Component = componentList.paragraph\n\n return (\n <Component\n key={block.id}\n id={block.id}\n type={block.type}\n data={{ text: excerptText }}\n />\n )\n }\n return (\n <div className=\"sl-visual-content\">\n {content.blocks.map((block) => {\n const Component = componentList[block.type]\n\n if (!Component) return null\n\n return (\n <Component\n key={block.id}\n id={block.id}\n type={block.type}\n data={block.data as never}\n />\n )\n })}\n </div>\n )\n}\n\nexport {\n VisualContentStyles,\n Paragraph as ParagraphComponent,\n Header as HeaderComponent,\n Quote as QuoteComponent,\n Image as ImageComponent,\n HTML as HTMLComponent,\n List as ListComponent,\n}\n\nexport type { VisualContentProps, ImageOptions }\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/VisualContent/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,2DAAoD;AAqIzC,yBArIJ,eAAK,CAqIa;AApIzB,mEAA0C;AAiI3B,6BAjIR,mBAAS,CAiIiB;AAhIjC,qCAAuC;AACvC,+CAAsC;AACtC,6DAAoC;AA+HxB,0BA/HL,gBAAM,CA+Hc;AA9H3B,2DAAkC;AA+HvB,yBA/HJ,eAAK,CA+Ha;AA9HzB,yDAAgC;AAgItB,wBAhIH,cAAI,CAgIY;AA/HvB,yDAAgC;AAgItB,wBAhIH,cAAI,CAgIY;AA/HvB,2DAAkC;AAgIvB,yBAhIJ,eAAK,CAgIa;AA9HzB,MAAM,iBAAiB,GAAoB;IACzC,SAAS,EAAE,mBAAS;IACpB,MAAM,EAAE,gBAAM;IACd,KAAK,EAAE,eAAK;IACZ,KAAK,EAAE,eAAK;IACZ,GAAG,EAAE,cAAI;IACT,IAAI,EAAE,cAAI;IACV,KAAK,EAAE,eAAK;CACb,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACI,MAAM,aAAa,GAAG,CAAC,EAC5B,OAAO,EACP,UAAU,GAAG,EAAE,EACf,OAAO,GAAG,KAAK,EACf,aAAa,GAAG,EAAE,GACC,EAAe,EAAE;IACpC,MAAM,aAAa,GAAG,IAAA,eAAO,EAC3B,GAAG,EAAE,CAAC,iCAAM,iBAAiB,GAAK,UAAU,EAAG,EAC/C,CAAC,UAAU,CAAC,CACb,CAAA;IAED,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,IAA8B,CAAA;KACtC;IAED,IAAI,OAAO,EAAE;QACX,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAA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wDzB","sourcesContent":["import { VisualDataBlock, ParagraphBlock } from '@starlightcms/js-sdk'\nimport { BlockComponents, VisualContentProps } from './types'\nimport Image, { ImageOptions } from './blocks/Image'\nimport Paragraph from './blocks/Paragraph'\nimport { OuterWrapper } from './styles'\nimport React, { useMemo } from 'react'\nimport Header from './blocks/Header'\nimport Quote from './blocks/Quote'\nimport HTML from './blocks/HTML'\nimport List from './blocks/List'\nimport Video from './blocks/Video'\n\nconst defaultComponents: BlockComponents = {\n paragraph: Paragraph,\n header: Header,\n quote: Quote,\n image: Image,\n raw: HTML,\n list: List,\n video: Video,\n}\n\n/**\n * Renders HTML content from data returned by a Visual Editor field on Starlight.\n *\n * The only required prop is `content`, which is the data returned by a Visual\n * Editor field. Additionally, you can provide custom components to render each\n * data block type.\n *\n * You can also pass the `excerpt` boolean prop to only render a portion of the\n * content, which is useful to summarize the content in lists.\n *\n * To learn how to customize the rendered content, take a look at the\n * [Customizing the output](#) guide page.\n *\n * @example Requesting an entry and rendering its content.\n *\n * Assume we created a \"Posts\" model with a slug of `posts`, and placed a Visual\n * Editor field with a key of `post_content` on it.\n *\n * ```jsx\n * import Starlight, { VisualContent } from '@starlightcms/react-sdk'\n *\n * const EntryComponent = ({ slug }) => {\n * const [entry, setEntry] = useState(null)\n *\n * // This is just an example, you could fetch\n * // the entry any way you want.\n * useEffect(async () => {\n * const response = await Starlight.posts.entries.get(slug)\n *\n * setEntry(response.data)\n * }, [ slug ])\n *\n * // After fetching, content will be on the `entry.data.post_content` property.\n * return (\n * entry ? (\n * <article>\n * <h1>{entry.title}</h1>\n * <VisualContent content={entry.data.post_content} />\n * </article>\n * ) : (\n * <div>Loading...</div>\n * )\n * )\n * }\n *\n * ```\n *\n * @param props Component props. See {@link VisualContentProps} to see the\n * available options.\n * @group VisualContent\n */\nexport const VisualContent = ({\n content,\n components = {},\n excerpt = false,\n excerptLength = 40,\n}: VisualContentProps): JSX.Element => {\n const componentList = useMemo(\n () => ({ ...defaultComponents, ...components }),\n [components]\n )\n\n if (!content) {\n return null as unknown as JSX.Element\n }\n\n if (excerpt) {\n const block = content.blocks.find((block) => block.type === 'paragraph') as\n | VisualDataBlock<ParagraphBlock>\n | undefined\n\n if (!block || !block.data.text) return null as unknown as JSX.Element\n\n const text = block.data.text.split(' ')\n const excerptText =\n text.length > excerptLength\n ? text.splice(0, excerptLength).join(' ') + '...'\n : text.join(' ')\n const Component = componentList.paragraph\n\n return (\n <Component\n key={block.id}\n id={block.id}\n type={block.type}\n data={{ text: excerptText }}\n />\n )\n }\n return (\n <OuterWrapper className=\"sl-visual-content\">\n {content.blocks.map((block) => {\n const Component = componentList[block.type]\n\n if (!Component) return null\n\n return (\n <Component\n key={block.id}\n id={block.id}\n type={block.type}\n data={block.data as never}\n />\n )\n })}\n </OuterWrapper>\n )\n}\n\nexport {\n Paragraph as ParagraphComponent,\n Header as HeaderComponent,\n Quote as QuoteComponent,\n Image as ImageComponent,\n HTML as HTMLComponent,\n List as ListComponent,\n Video as VideoComponent,\n}\n\nexport type { VisualContentProps, ImageOptions }\n"]}
@@ -1,14 +1,14 @@
1
1
  /// <reference types="react" />
2
- /**
3
- * Renders a `<style>` tag with rules that style the rendered
4
- * {@link VisualContent} HTML. While not required for VisualContent to work,
5
- * using these rules is a quick way to make the content look the same way as it
6
- * does on the Starlight content editor.
7
- *
8
- * You only need to render this component once in your application,
9
- * preferably in the `<head>` section.
10
- *
11
- * @group VisualContent
12
- */
13
- export declare const VisualContentStyles: () => JSX.Element;
2
+ export declare const OuterWrapper: import("@emotion/styled").StyledComponent<{
3
+ theme?: import("@emotion/react").Theme | undefined;
4
+ as?: import("react").ElementType<any> | undefined;
5
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
6
+ export declare const BlockWrapper: import("@emotion/styled").StyledComponent<{
7
+ theme?: import("@emotion/react").Theme | undefined;
8
+ as?: import("react").ElementType<any> | undefined;
9
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
10
+ export declare const FigureWrapper: import("@emotion/styled").StyledComponent<{
11
+ theme?: import("@emotion/react").Theme | undefined;
12
+ as?: import("react").ElementType<any> | undefined;
13
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, {}>;
14
14
  //# sourceMappingURL=styles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/VisualContent/styles.tsx"],"names":[],"mappings":";AA6BA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,QAAO,WAEtC,CAAA"}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/VisualContent/styles.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,YAAY;;;yGAiExB,CAAA;AAED,eAAO,MAAM,YAAY;;;yGAMxB,CAAA;AAED,eAAO,MAAM,aAAa;;;mGAMzB,CAAA"}
@@ -3,47 +3,86 @@ 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.VisualContentStyles = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const styles = `
9
- .sl-visual-content *{max-width:100%}
10
- .sl-visual-content>figure{margin:1em 0}
11
- .sl-list{list-style:none;padding-left:1em}
12
- .sl-list>li{margin:.5em 0}
13
- .sl-list>li::before{content: "•";margin-right:.5em}
14
- .sl__color{padding:2px 0;border-radius:4px}
15
- .sl__color__bg--red{background-color:rgb(253,235,236)}
16
- .sl__color__bg--pink{background-color:rgb(253,235,236)}
17
- .sl__color__bg--purple{background-color:rgb(244,240,247)}
18
- .sl__color__bg--blue{background-color:rgb(231,243,248)}
19
- .sl__color__bg--green{background-color:rgb(237,243,236)}
20
- .sl__color__bg--yellow{background-color:rgb(251,243,219)}
21
- .sl__color__bg--orange{background-color:rgb(251,236,221)}
22
- .sl__color__bg--brown{background-color:rgb(244,238,238)}
23
- .sl__color__bg--gray{background-color:rgb(241,241,239)}
24
- .sl__color__text--red{color:rgb(212,76,71)}
25
- .sl__color__text--pink{color:rgb(193,76,138)}
26
- .sl__color__text--purple{color:rgb(144,101,176)}
27
- .sl__color__text--blue{color:rgb(51,126,169)}
28
- .sl__color__text--green{color:rgb(68,131,97)}
29
- .sl__color__text--yellow{color:rgb(203,145,47)}
30
- .sl__color__text--orange{color:rgb(217,115,13)}
31
- .sl__color__text--brown{color:rgb(159,107,83)}
32
- .sl__color__text--gray{color:rgb(120,119,116)}
6
+ exports.FigureWrapper = exports.BlockWrapper = exports.OuterWrapper = void 0;
7
+ const styled_1 = __importDefault(require("@emotion/styled"));
8
+ exports.OuterWrapper = styled_1.default.div `
9
+ .sl__color {
10
+ padding: 2px 0;
11
+ border-radius: 4px;
12
+
13
+ &__bg {
14
+ &--red {
15
+ background-color: rgb(253, 235, 236);
16
+ }
17
+ &--pink {
18
+ background-color: rgb(253, 235, 236);
19
+ }
20
+ &--purple {
21
+ background-color: rgb(244, 240, 247);
22
+ }
23
+ &--blue {
24
+ background-color: rgb(231, 243, 248);
25
+ }
26
+ &--green {
27
+ background-color: rgb(237, 243, 236);
28
+ }
29
+ &--yellow {
30
+ background-color: rgb(251, 243, 219);
31
+ }
32
+ &--orange {
33
+ background-color: rgb(251, 236, 221);
34
+ }
35
+ &--brown {
36
+ background-color: rgb(244, 238, 238);
37
+ }
38
+ &--gray {
39
+ background-color: rgb(241, 241, 239);
40
+ }
41
+ }
42
+
43
+ &__text {
44
+ &--red {
45
+ color: rgb(212, 76, 71);
46
+ }
47
+ &--pink {
48
+ color: rgb(193, 76, 138);
49
+ }
50
+ &--purple {
51
+ color: rgb(144, 101, 176);
52
+ }
53
+ &--blue {
54
+ color: rgb(51, 126, 169);
55
+ }
56
+ &--green {
57
+ color: rgb(68, 131, 97);
58
+ }
59
+ &--yellow {
60
+ color: rgb(203, 145, 47);
61
+ }
62
+ &--orange {
63
+ color: rgb(217, 115, 13);
64
+ }
65
+ &--brown {
66
+ color: rgb(159, 107, 83);
67
+ }
68
+ &--gray {
69
+ color: rgb(120, 119, 116);
70
+ }
71
+ }
72
+ }
73
+ `;
74
+ exports.BlockWrapper = styled_1.default.div `
75
+ margin: auto;
76
+
77
+ &.sl-width-max {
78
+ max-width: 100%;
79
+ }
80
+ `;
81
+ exports.FigureWrapper = styled_1.default.figure `
82
+ figcaption {
83
+ display: flex;
84
+ justify-content: center;
85
+ margin-top: 6px;
86
+ }
33
87
  `;
34
- /**
35
- * Renders a `<style>` tag with rules that style the rendered
36
- * {@link VisualContent} HTML. While not required for VisualContent to work,
37
- * using these rules is a quick way to make the content look the same way as it
38
- * does on the Starlight content editor.
39
- *
40
- * You only need to render this component once in your application,
41
- * preferably in the `<head>` section.
42
- *
43
- * @group VisualContent
44
- */
45
- const VisualContentStyles = () => {
46
- return react_1.default.createElement("style", { dangerouslySetInnerHTML: { __html: styles } });
47
- };
48
- exports.VisualContentStyles = VisualContentStyles;
49
88
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/VisualContent/styles.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AAEzB,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;CAyBd,CAAA;AAED;;;;;;;;;;GAUG;AACI,MAAM,mBAAmB,GAAG,GAAgB,EAAE;IACnD,OAAO,yCAAO,uBAAuB,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAI,CAAA;AAC/D,CAAC,CAAA;AAFY,QAAA,mBAAmB,uBAE/B","sourcesContent":["import React from 'react'\n\nconst styles = `\n .sl-visual-content *{max-width:100%}\n .sl-visual-content>figure{margin:1em 0}\n .sl-list{list-style:none;padding-left:1em}\n .sl-list>li{margin:.5em 0}\n .sl-list>li::before{content: \"•\";margin-right:.5em}\n .sl__color{padding:2px 0;border-radius:4px}\n .sl__color__bg--red{background-color:rgb(253,235,236)}\n .sl__color__bg--pink{background-color:rgb(253,235,236)}\n .sl__color__bg--purple{background-color:rgb(244,240,247)}\n .sl__color__bg--blue{background-color:rgb(231,243,248)}\n .sl__color__bg--green{background-color:rgb(237,243,236)}\n .sl__color__bg--yellow{background-color:rgb(251,243,219)}\n .sl__color__bg--orange{background-color:rgb(251,236,221)}\n .sl__color__bg--brown{background-color:rgb(244,238,238)}\n .sl__color__bg--gray{background-color:rgb(241,241,239)}\n .sl__color__text--red{color:rgb(212,76,71)}\n .sl__color__text--pink{color:rgb(193,76,138)}\n .sl__color__text--purple{color:rgb(144,101,176)}\n .sl__color__text--blue{color:rgb(51,126,169)}\n .sl__color__text--green{color:rgb(68,131,97)}\n .sl__color__text--yellow{color:rgb(203,145,47)}\n .sl__color__text--orange{color:rgb(217,115,13)}\n .sl__color__text--brown{color:rgb(159,107,83)}\n .sl__color__text--gray{color:rgb(120,119,116)}\n`\n\n/**\n * Renders a `<style>` tag with rules that style the rendered\n * {@link VisualContent} HTML. While not required for VisualContent to work,\n * using these rules is a quick way to make the content look the same way as it\n * does on the Starlight content editor.\n *\n * You only need to render this component once in your application,\n * preferably in the `<head>` section.\n *\n * @group VisualContent\n */\nexport const VisualContentStyles = (): JSX.Element => {\n return <style dangerouslySetInnerHTML={{ __html: styles }} />\n}\n"]}
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/VisualContent/styles.ts"],"names":[],"mappings":";;;;;;AAAA,6DAAoC;AAEvB,QAAA,YAAY,GAAG,gBAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiErC,CAAA;AAEY,QAAA,YAAY,GAAG,gBAAM,CAAC,GAAG,CAAA;;;;;;CAMrC,CAAA;AAEY,QAAA,aAAa,GAAG,gBAAM,CAAC,MAAM,CAAA;;;;;;CAMzC,CAAA","sourcesContent":["import styled from '@emotion/styled'\n\nexport const OuterWrapper = styled.div`\n .sl__color {\n padding: 2px 0;\n border-radius: 4px;\n\n &__bg {\n &--red {\n background-color: rgb(253, 235, 236);\n }\n &--pink {\n background-color: rgb(253, 235, 236);\n }\n &--purple {\n background-color: rgb(244, 240, 247);\n }\n &--blue {\n background-color: rgb(231, 243, 248);\n }\n &--green {\n background-color: rgb(237, 243, 236);\n }\n &--yellow {\n background-color: rgb(251, 243, 219);\n }\n &--orange {\n background-color: rgb(251, 236, 221);\n }\n &--brown {\n background-color: rgb(244, 238, 238);\n }\n &--gray {\n background-color: rgb(241, 241, 239);\n }\n }\n\n &__text {\n &--red {\n color: rgb(212, 76, 71);\n }\n &--pink {\n color: rgb(193, 76, 138);\n }\n &--purple {\n color: rgb(144, 101, 176);\n }\n &--blue {\n color: rgb(51, 126, 169);\n }\n &--green {\n color: rgb(68, 131, 97);\n }\n &--yellow {\n color: rgb(203, 145, 47);\n }\n &--orange {\n color: rgb(217, 115, 13);\n }\n &--brown {\n color: rgb(159, 107, 83);\n }\n &--gray {\n color: rgb(120, 119, 116);\n }\n }\n }\n`\n\nexport const BlockWrapper = styled.div`\n margin: auto;\n\n &.sl-width-max {\n max-width: 100%;\n }\n`\n\nexport const FigureWrapper = styled.figure`\n figcaption {\n display: flex;\n justify-content: center;\n margin-top: 6px;\n }\n`\n"]}
@@ -1,5 +1,5 @@
1
1
  import { ComponentType } from 'react';
2
- import { HeaderBlock, ImageBlock, ParagraphBlock, QuoteBlock, VisualData, VisualDataBlock, BlockType, HTMLBlock, ListBlock } from '@starlightcms/js-sdk';
2
+ import { HeaderBlock, ImageBlock, ParagraphBlock, QuoteBlock, VisualData, VisualDataBlock, BlockType, HTMLBlock, ListBlock, VideoBlock } from '@starlightcms/js-sdk';
3
3
  declare type Implements<T, U extends T> = Record<string, unknown>;
4
4
  export interface BlockComponents extends Implements<Record<BlockType, unknown>, BlockComponents> {
5
5
  paragraph: ComponentType<VisualDataBlock<ParagraphBlock>>;
@@ -8,6 +8,7 @@ export interface BlockComponents extends Implements<Record<BlockType, unknown>,
8
8
  image: ComponentType<VisualDataBlock<ImageBlock>>;
9
9
  raw: ComponentType<VisualDataBlock<HTMLBlock>>;
10
10
  list: ComponentType<VisualDataBlock<ListBlock>>;
11
+ video: ComponentType<VisualDataBlock<VideoBlock>>;
11
12
  }
12
13
  /**
13
14
  * Props accepted by the {@link VisualContent} component.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/VisualContent/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACrC,OAAO,EACL,WAAW,EACX,UAAU,EACV,cAAc,EACd,UAAU,EACV,UAAU,EACV,eAAe,EACf,SAAS,EACT,SAAS,EACT,SAAS,EACV,MAAM,sBAAsB,CAAA;AAG7B,aAAK,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEzD,MAAM,WAAW,eACf,SAAQ,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,eAAe,CAAC;IAC/D,SAAS,EAAE,aAAa,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC,CAAA;IACzD,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAA;IACnD,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAA;IACjD,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAA;IACjD,GAAG,EAAE,aAAa,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAA;IAC9C,IAAI,EAAE,aAAa,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAA;CAChD;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,OAAO,CAAC,EAAE,UAAU,CAAA;IACpB;;;OAGG;IACH,UAAU,CAAC,EAA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AAA;IACrC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/VisualContent/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ComponentType } from 'react'\nimport {\n HeaderBlock,\n ImageBlock,\n ParagraphBlock,\n QuoteBlock,\n VisualData,\n VisualDataBlock,\n BlockType,\n HTMLBlock,\n ListBlock,\n} from '@starlightcms/js-sdk'\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype Implements<T, U extends T> = Record<string, unknown>\n\nexport interface BlockComponents\n extends Implements<Record<BlockType, unknown>, BlockComponents> {\n paragraph: ComponentType<VisualDataBlock<ParagraphBlock>>\n header: ComponentType<VisualDataBlock<HeaderBlock>>\n quote: ComponentType<VisualDataBlock<QuoteBlock>>\n image: ComponentType<VisualDataBlock<ImageBlock>>\n raw: ComponentType<VisualDataBlock<HTMLBlock>>\n list: ComponentType<VisualDataBlock<ListBlock>>\n}\n\n/**\n * Props accepted by the {@link VisualContent} component.\n * @group VisualContent\n */\nexport interface VisualContentProps {\n /**\n * The content to render. It should be the object returned by\n * Starlight on a Visual Editor field. Required.\n */\n content?: VisualData\n /**\n * An optional object of React components. You can pass any\n * number of replacement components that will render blocks of a given type.\n */\n components?: Partial<BlockComponents>\n /**\n * If true, only a small portion of the content will be rendered,\n * and block types other than text paragraphs will be ignored. Defaults to false.\n */\n excerpt?: boolean\n /**\n * Defines the maximum number of words to render when\n * excerpt is true. Defaults to 40.\n */\n excerptLength?: number\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/VisualContent/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ComponentType } from 'react'\nimport {\n HeaderBlock,\n ImageBlock,\n ParagraphBlock,\n QuoteBlock,\n VisualData,\n VisualDataBlock,\n BlockType,\n HTMLBlock,\n ListBlock,\n VideoBlock,\n} from '@starlightcms/js-sdk'\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype Implements<T, U extends T> = Record<string, unknown>\n\nexport interface BlockComponents\n extends Implements<Record<BlockType, unknown>, BlockComponents> {\n paragraph: ComponentType<VisualDataBlock<ParagraphBlock>>\n header: ComponentType<VisualDataBlock<HeaderBlock>>\n quote: ComponentType<VisualDataBlock<QuoteBlock>>\n image: ComponentType<VisualDataBlock<ImageBlock>>\n raw: ComponentType<VisualDataBlock<HTMLBlock>>\n list: ComponentType<VisualDataBlock<ListBlock>>\n video: ComponentType<VisualDataBlock<VideoBlock>>\n}\n\n/**\n * Props accepted by the {@link VisualContent} component.\n * @group VisualContent\n */\nexport interface VisualContentProps {\n /**\n * The content to render. It should be the object returned by\n * Starlight on a Visual Editor field. Required.\n */\n content?: VisualData\n /**\n * An optional object of React components. You can pass any\n * number of replacement components that will render blocks of a given type.\n */\n components?: Partial<BlockComponents>\n /**\n * If true, only a small portion of the content will be rendered,\n * and block types other than text paragraphs will be ignored. Defaults to false.\n */\n excerpt?: boolean\n /**\n * Defines the maximum number of words to render when\n * excerpt is true. Defaults to 40.\n */\n excerptLength?: number\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { FC } from 'react';
2
1
  import { HTMLBlock, VisualDataBlock } from '@starlightcms/js-sdk';
2
+ import { FC } from 'react';
3
3
  /**
4
4
  * VisualContent renderer component that renders `raw` type blocks
5
5
  * as inline HTML inside a `div` element.
@@ -13,4 +13,4 @@ import { HTMLBlock, VisualDataBlock } from '@starlightcms/js-sdk';
13
13
  */
14
14
  declare const HTML: FC<VisualDataBlock<HTMLBlock>>;
15
15
  export default HTML;
16
- //# sourceMappingURL=HTML.d.ts.map
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/VisualContent/blocks/HTML/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAGjE,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAEjC;;;;;;;;;;GAUG;AACH,QAAA,MAAM,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,CAMxC,CAAA;AAED,eAAe,IAAI,CAAA"}
@@ -1,3 +1,5 @@
1
+ import { BlockWrapper } from '../../styles';
2
+ import { HTMLWrapper } from './styles';
1
3
  import React from 'react';
2
4
  /**
3
5
  * VisualContent renderer component that renders `raw` type blocks
@@ -11,7 +13,8 @@ import React from 'react';
11
13
  * @group VisualContent Renderers
12
14
  */
13
15
  const HTML = ({ data }) => {
14
- return (React.createElement("div", { className: "sl-content-block sl-html test", dangerouslySetInnerHTML: { __html: data.html } }));
16
+ return (React.createElement(BlockWrapper, { className: "sl-content-block sl-html" },
17
+ React.createElement(HTMLWrapper, { dangerouslySetInnerHTML: { __html: data.html } })));
15
18
  };
16
19
  export default HTML;
17
- //# sourceMappingURL=HTML.js.map
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/VisualContent/blocks/HTML/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,KAAa,MAAM,OAAO,CAAA;AAEjC;;;;;;;;;;GAUG;AACH,MAAM,IAAI,GAAmC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IACxD,OAAO,CACL,oBAAC,YAAY,IAAC,SAAS,EAAC,0BAA0B;QAChD,oBAAC,WAAW,IAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,GAAI,CAClD,CAChB,CAAA;AACH,CAAC,CAAA;AAED,eAAe,IAAI,CAAA","sourcesContent":["import { HTMLBlock, VisualDataBlock } from '@starlightcms/js-sdk'\nimport { BlockWrapper } from '../../styles'\nimport { HTMLWrapper } from './styles'\nimport React, { FC } from 'react'\n\n/**\n * VisualContent renderer component that renders `raw` type blocks\n * as inline HTML inside a `div` element.\n *\n * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}\n * to learn how to customize block renderer components like this one.\n *\n * @param props VisualDataBlock object. See {@link HTMLBlock} to learn the\n * type of data this component receives.\n * @group VisualContent Renderers\n */\nconst HTML: FC<VisualDataBlock<HTMLBlock>> = ({ data }) => {\n return (\n <BlockWrapper className=\"sl-content-block sl-html\">\n <HTMLWrapper dangerouslySetInnerHTML={{ __html: data.html }} />\n </BlockWrapper>\n )\n}\n\nexport default HTML\n"]}
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare const HTMLWrapper: import("@emotion/styled").StyledComponent<{
3
+ theme?: import("@emotion/react").Theme | undefined;
4
+ as?: import("react").ElementType<any> | undefined;
5
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
6
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../src/VisualContent/blocks/HTML/styles.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,WAAW;;;yGAIvB,CAAA"}
@@ -0,0 +1,7 @@
1
+ import styled from '@emotion/styled';
2
+ export const HTMLWrapper = styled.div `
3
+ > * {
4
+ max-width: 100%;
5
+ }
6
+ `;
7
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../../src/VisualContent/blocks/HTML/styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAA;AAEpC,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAIpC,CAAA","sourcesContent":["import styled from '@emotion/styled'\n\nexport const HTMLWrapper = styled.div`\n > * {\n max-width: 100%;\n }\n`\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/Header.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEnE;;;;;;;;;;GAUG;AACH,QAAA,MAAM,MAAM,aAAc,gBAAgB,WAAW,CAAC,KAAG,WASxD,CAAA;AAED,eAAe,MAAM,CAAA"}
1
+ {"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/Header.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAInE;;;;;;;;;;GAUG;AACH,QAAA,MAAM,MAAM,aAAc,gBAAgB,WAAW,CAAC,KAAG,WAQxD,CAAA;AAED,eAAe,MAAM,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { BlockWrapper } from '../styles';
1
2
  import React from 'react';
2
3
  /**
3
4
  * VisualContent renderer component that renders `header` type blocks
@@ -12,7 +13,8 @@ import React from 'react';
12
13
  */
13
14
  const Header = ({ data }) => {
14
15
  const HeaderComponent = `h${data.level}`;
15
- return (React.createElement(HeaderComponent, { className: "sl-content-block sl-header", dangerouslySetInnerHTML: { __html: data.text } }));
16
+ return (React.createElement(BlockWrapper, { className: "sl-content-block sl-header" },
17
+ React.createElement(HeaderComponent, { dangerouslySetInnerHTML: { __html: data.text } })));
16
18
  };
17
19
  export default Header;
18
20
  //# sourceMappingURL=Header.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Header.js","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/Header.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB;;;;;;;;;;GAUG;AACH,MAAM,MAAM,GAAG,CAAC,EAAE,IAAI,EAAgC,EAAe,EAAE;IACrE,MAAM,eAAe,GAAG,IAAI,IAAI,CAAC,KAAK,EAAU,CAAA;IAEhD,OAAO,CACL,oBAAC,eAAe,IACd,SAAS,EAAC,4BAA4B,EACtC,uBAAuB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,GAC9C,CACH,CAAA;AACH,CAAC,CAAA;AAED,eAAe,MAAM,CAAA","sourcesContent":["import React from 'react'\nimport { HeaderBlock, VisualDataBlock } from '@starlightcms/js-sdk'\n\n/**\n * VisualContent renderer component that renders `header` type blocks\n * as HTML heading elements, like `<h1>`, `<h2>`, and so on.\n *\n * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}\n * to learn how to customize block renderer components like this one.\n *\n * @param props VisualDataBlock object. See {@link HeaderBlock} to learn the\n * type of data this component receives.\n * @group VisualContent Renderers\n */\nconst Header = ({ data }: VisualDataBlock<HeaderBlock>): JSX.Element => {\n const HeaderComponent = `h${data.level}` as 'h1'\n\n return (\n <HeaderComponent\n className=\"sl-content-block sl-header\"\n dangerouslySetInnerHTML={{ __html: data.text }}\n />\n )\n}\n\nexport default Header\n"]}
1
+ {"version":3,"file":"Header.js","sourceRoot":"","sources":["../../../../src/VisualContent/blocks/Header.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB;;;;;;;;;;GAUG;AACH,MAAM,MAAM,GAAG,CAAC,EAAE,IAAI,EAAgC,EAAe,EAAE;IACrE,MAAM,eAAe,GAAG,IAAI,IAAI,CAAC,KAAK,EAAU,CAAA;IAEhD,OAAO,CACL,oBAAC,YAAY,IAAC,SAAS,EAAC,4BAA4B;QAClD,oBAAC,eAAe,IAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,GAAI,CACtD,CAChB,CAAA;AACH,CAAC,CAAA;AAED,eAAe,MAAM,CAAA","sourcesContent":["import { HeaderBlock, VisualDataBlock } from '@starlightcms/js-sdk'\nimport { BlockWrapper } from '../styles'\nimport React from 'react'\n\n/**\n * VisualContent renderer component that renders `header` type blocks\n * as HTML heading elements, like `<h1>`, `<h2>`, and so on.\n *\n * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}\n * to learn how to customize block renderer components like this one.\n *\n * @param props VisualDataBlock object. See {@link HeaderBlock} to learn the\n * type of data this component receives.\n * @group VisualContent Renderers\n */\nconst Header = ({ data }: VisualDataBlock<HeaderBlock>): JSX.Element => {\n const HeaderComponent = `h${data.level}` as 'h1'\n\n return (\n <BlockWrapper className=\"sl-content-block sl-header\">\n <HeaderComponent dangerouslySetInnerHTML={{ __html: data.text }} />\n </BlockWrapper>\n )\n}\n\nexport default Header\n"]}
@@ -1,5 +1,5 @@
1
- import { FC } from 'react';
2
1
  import { ImageBlock, VisualDataBlock } from '@starlightcms/js-sdk';
2
+ import { FC } from 'react';
3
3
  /**
4
4
  * Type used by {@link ImageComponent} to accept a `sizes` prop.
5
5
  */
@@ -25,4 +25,4 @@ export declare type ImageOptions = {
25
25
  */
26
26
  declare const Image: FC<VisualDataBlock<ImageBlock> & ImageOptions>;
27
27
  export default Image;
28
- //# sourceMappingURL=Image.d.ts.map
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/VisualContent/blocks/Image/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAc,EAAE,EAAE,EAAgC,MAAM,OAAO,CAAA;AAI/D;;GAEG;AACH,oBAAY,YAAY,GAAG;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,UAAU,CAAC,GAAG,YAAY,CA8DzD,CAAA;AAED,eAAe,KAAK,CAAA"}
@@ -0,0 +1,45 @@
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
+ import { ImageWrapper, SelectedImage } from './styles';
3
+ import { BlockWrapper } from '../../styles';
4
+ /**
5
+ * VisualContent renderer component that renders `image` type blocks
6
+ * as a responsive image along with its caption (if defined). Optionally
7
+ * wraps the image in an anchor if a link is defined in the content.
8
+ *
9
+ * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}
10
+ * to learn how to customize block renderer components like this one.
11
+ *
12
+ * This component also supports an optional `sizes` prop to provide better image
13
+ * responsiveness, see {@doclink components/VisualContent/#responsive-images | the guide page on responsive images}
14
+ * to learn more.
15
+ *
16
+ * @param props VisualDataBlock object. See {@link ImageBlock} to learn the
17
+ * type of data this component receives. Also accepts
18
+ * an optional `sizes` string prop.
19
+ * @group VisualContent Renderers
20
+ */
21
+ const Image = ({ data, sizes = '(max-width: 480px) 90vw, 70vw', }) => {
22
+ const { url, alt = '', files, caption, width, href, responsive } = data;
23
+ const widthType = ['auto', 'justify', 'max'].includes(width) ? width : 'fixed';
24
+ const [target, setTarget] = useState('_self');
25
+ const [originalWidth, setOriginalWidth] = useState(undefined);
26
+ const srcSet = useMemo(() => {
27
+ return data.files.map((file) => `${file.url} ${file.width}w`).join(', ');
28
+ }, [data]);
29
+ useEffect(() => {
30
+ if (!href)
31
+ return;
32
+ setTarget(new URL(href).origin === window.location.origin ? '_self' : '_blank');
33
+ }, [href]);
34
+ useEffect(() => {
35
+ const optimizedFile = files.find((f) => f.variation === 'optimized');
36
+ setOriginalWidth(optimizedFile ? optimizedFile.width.toString() + 'px' : undefined);
37
+ }, []);
38
+ return (React.createElement(BlockWrapper, { className: `sl-content-block sl-image sl-width-${widthType}` },
39
+ React.createElement(ImageWrapper, null,
40
+ href ? (React.createElement("a", { href: href, target: target },
41
+ React.createElement(SelectedImage, { width: width, src: url, alt: alt, srcSet: srcSet, sizes: responsive ? sizes : undefined, originalWidth: data.responsive ? originalWidth : undefined }))) : (React.createElement(SelectedImage, { width: width, src: url, alt: alt, srcSet: srcSet, sizes: responsive ? sizes : undefined, originalWidth: data.responsive ? originalWidth : undefined })),
42
+ caption && (React.createElement("figcaption", { dangerouslySetInnerHTML: { __html: caption } })))));
43
+ };
44
+ export default Image;
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/VisualContent/blocks/Image/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAM,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAS3C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,KAAK,GAAmD,CAAC,EAC7D,IAAI,EACJ,KAAK,GAAG,+BAA+B,GACxC,EAAE,EAAE;IACH,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;IAEvE,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAA;IAE9E,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC7C,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAChD,SAAS,CACV,CAAA;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE;QAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC1E,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AAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EACrC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,GAC1D,CACH;YACA,OAAO,IAAI,CACV,oCAAY,uBAAuB,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,GAAI,CAC7D,CACY,CACF,CAChB,CAAA;AACH,CAAC,CAAA;AAED,eAAe,KAAK,CAAA","sourcesContent":["import { ImageBlock, VisualDataBlock } from '@starlightcms/js-sdk'\nimport React, { FC, useEffect, useMemo, useState } from 'react'\nimport { ImageWrapper, SelectedImage } from './styles'\nimport { BlockWrapper } from '../../styles'\n\n/**\n * Type used by {@link ImageComponent} to accept a `sizes` prop.\n */\nexport type ImageOptions = {\n sizes?: string\n}\n\n/**\n * VisualContent renderer component that renders `image` type blocks\n * as a responsive image along with its caption (if defined). Optionally\n * wraps the image in an anchor if a link is defined in the content.\n *\n * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}\n * to learn how to customize block renderer components like this one.\n *\n * This component also supports an optional `sizes` prop to provide better image\n * responsiveness, see {@doclink components/VisualContent/#responsive-images | the guide page on responsive images}\n * to learn more.\n *\n * @param props VisualDataBlock object. See {@link ImageBlock} to learn the\n * type of data this component receives. Also accepts\n * an optional `sizes` string prop.\n * @group VisualContent Renderers\n */\nconst Image: FC<VisualDataBlock<ImageBlock> & ImageOptions> = ({\n data,\n sizes = '(max-width: 480px) 90vw, 70vw',\n}) => {\n const { url, alt = '', files, caption, width, href, responsive } = data\n\n const widthType = ['auto', 'justify', 'max'].includes(width) ? width : 'fixed'\n\n const [target, setTarget] = useState('_self')\n const [originalWidth, setOriginalWidth] = useState<string | undefined>(\n undefined\n )\n\n const srcSet = useMemo(() => {\n return data.files.map((file) => `${file.url} ${file.width}w`).join(', ')\n }, [data])\n\n useEffect(() => {\n if (!href) return\n\n setTarget(\n new URL(href).origin === window.location.origin ? '_self' : '_blank'\n )\n }, [href])\n\n useEffect(() => {\n const optimizedFile = files.find((f) => f.variation === 'optimized')\n setOriginalWidth(\n optimizedFile ? optimizedFile.width.toString() + 'px' : undefined\n )\n }, [])\n\n return (\n <BlockWrapper className={`sl-content-block sl-image sl-width-${widthType}`}>\n <ImageWrapper>\n {href ? (\n <a href={href} target={target}>\n <SelectedImage\n width={width}\n src={url}\n alt={alt}\n srcSet={srcSet}\n sizes={responsive ? sizes : undefined}\n originalWidth={data.responsive ? originalWidth : undefined}\n />\n </a>\n ) : (\n <SelectedImage\n width={width}\n src={url}\n alt={alt}\n srcSet={srcSet}\n sizes={responsive ? sizes : undefined}\n originalWidth={data.responsive ? originalWidth : undefined}\n />\n )}\n {caption && (\n <figcaption dangerouslySetInnerHTML={{ __html: caption }} />\n )}\n </ImageWrapper>\n </BlockWrapper>\n )\n}\n\nexport default Image\n"]}
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ export declare const ImageWrapper: import("@emotion/styled").StyledComponent<{
3
+ theme?: import("@emotion/react").Theme | undefined;
4
+ as?: import("react").ElementType<any> | undefined;
5
+ } & import("react").ClassAttributes<HTMLElement> & import("react").HTMLAttributes<HTMLElement> & {
6
+ children?: import("react").ReactNode;
7
+ } & {
8
+ theme?: import("@emotion/react").Theme | undefined;
9
+ }, {}, {}>;
10
+ declare type ImageProps = {
11
+ width: string;
12
+ originalWidth?: string | undefined;
13
+ };
14
+ export declare const SelectedImage: import("@emotion/styled").StyledComponent<{
15
+ theme?: import("@emotion/react").Theme | undefined;
16
+ as?: import("react").ElementType<any> | undefined;
17
+ } & ImageProps, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
18
+ export {};
19
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../src/VisualContent/blocks/Image/styles.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,YAAY;;;;;;;UAExB,CAAA;AAED,aAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACnC,CAAA;AAED,eAAO,MAAM,aAAa;;;6HA4BzB,CAAA"}
@@ -0,0 +1,35 @@
1
+ import { FigureWrapper } from '../../styles';
2
+ import styled from '@emotion/styled';
3
+ export const ImageWrapper = styled(FigureWrapper) `
4
+ margin: 1em auto;
5
+ `;
6
+ export const SelectedImage = styled.img `
7
+ display: block;
8
+ margin: auto;
9
+ object-fit: cover;
10
+
11
+ max-width: ${({ width, originalWidth }) => {
12
+ if (originalWidth && width === 'auto')
13
+ return originalWidth;
14
+ switch (width) {
15
+ case 'auto':
16
+ return '100%';
17
+ case 'justify':
18
+ case 'max':
19
+ return 'initial';
20
+ }
21
+ }};
22
+
23
+ width: ${({ width }) => {
24
+ switch (width) {
25
+ case 'auto':
26
+ return 'initial';
27
+ case 'justify':
28
+ case 'max':
29
+ return '100%';
30
+ default:
31
+ return width;
32
+ }
33
+ }};
34
+ `;
35
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../../src/VisualContent/blocks/Image/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,MAAM,MAAM,iBAAiB,CAAA;AAEpC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;;CAEhD,CAAA;AAOD,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAY;;;;;eAKpC,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,EAAE;IACxC,IAAI,aAAa,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,aAAa,CAAA;IAE3D,QAAQ,KAAK,EAAE;QACb,KAAK,MAAM;YACT,OAAO,MAAM,CAAA;QACf,KAAK,SAAS,CAAC;QACf,KAAK,KAAK;YACR,OAAO,SAAS,CAAA;KACnB;AACH,CAAC;;WAEQ,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACrB,QAAQ,KAAK,EAAE;QACb,KAAK,MAAM;YACT,OAAO,SAAS,CAAA;QAClB,KAAK,SAAS,CAAC;QACf,KAAK,KAAK;YACR,OAAO,MAAM,CAAA;QACf;YACE,OAAO,KAAK,CAAA;KACf;AACH,CAAC;CACF,CAAA","sourcesContent":["import { FigureWrapper } from '../../styles'\nimport styled from '@emotion/styled'\n\nexport const ImageWrapper = styled(FigureWrapper)`\n margin: 1em auto;\n`\n\ntype ImageProps = {\n width: string\n originalWidth?: string | undefined\n}\n\nexport const SelectedImage = styled.img<ImageProps>`\n display: block;\n margin: auto;\n object-fit: cover;\n\n max-width: ${({ width, originalWidth }) => {\n if (originalWidth && width === 'auto') return originalWidth\n\n switch (width) {\n case 'auto':\n return '100%'\n case 'justify':\n case 'max':\n return 'initial'\n }\n }};\n\n width: ${({ width }) => {\n switch (width) {\n case 'auto':\n return 'initial'\n case 'justify':\n case 'max':\n return '100%'\n default:\n return width\n }\n }};\n`\n"]}
@@ -1,5 +1,5 @@
1
- import { FC } from 'react';
2
1
  import { ListBlock, VisualDataBlock } from '@starlightcms/js-sdk';
2
+ import { FC } from 'react';
3
3
  /**
4
4
  * VisualContent renderer component that renders `list` type blocks
5
5
  * as `<ul>` or `<ol>` elements, depending on the list style.
@@ -13,4 +13,4 @@ import { ListBlock, VisualDataBlock } from '@starlightcms/js-sdk';
13
13
  */
14
14
  declare const List: FC<VisualDataBlock<ListBlock>>;
15
15
  export default List;
16
- //# sourceMappingURL=List.d.ts.map
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/VisualContent/blocks/List/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAY,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAG3E,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAuBjC;;;;;;;;;;GAUG;AACH,QAAA,MAAM,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,CAYxC,CAAA;AAED,eAAe,IAAI,CAAA"}
@@ -1,3 +1,5 @@
1
+ import { BlockWrapper } from '../../styles';
2
+ import { ListWrapper } from './styles';
1
3
  import React from 'react';
2
4
  const SubList = ({ item, Wrapper }) => {
3
5
  return (React.createElement("li", null,
@@ -17,8 +19,9 @@ const SubList = ({ item, Wrapper }) => {
17
19
  * @group VisualContent Renderers
18
20
  */
19
21
  const List = ({ data }) => {
20
- const ListWrapper = data.style === 'ordered' ? 'ol' : 'ul';
21
- return (React.createElement(ListWrapper, { className: "sl-content-block sl-list sl-list__root" }, data.items.map((item, index) => (React.createElement(SubList, { key: index, item: item, Wrapper: ListWrapper })))));
22
+ const listElement = data.style === 'ordered' ? 'ol' : 'ul';
23
+ return (React.createElement(BlockWrapper, { className: "sl-content-block sl-list" },
24
+ React.createElement(ListWrapper, { as: listElement, className: "sl-list__root" }, data.items.map((item, index) => (React.createElement(SubList, { key: index, item: item, Wrapper: listElement }))))));
22
25
  };
23
26
  export default List;
24
- //# sourceMappingURL=List.js.map
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/VisualContent/blocks/List/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,KAAa,MAAM,OAAO,CAAA;AAOjC,MAAM,OAAO,GAAqB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;IACtD,OAAO,CACL;QACE,8BAAM,uBAAuB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,GAAI;QAC1D,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CACjC,oBAAC,OAAO,QACL,IAAI,CAAC,KAAK;YACT,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CACjC,oBAAC,OAAO,IAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAI,CACzD,CAAC,CACI,CACX,CAAC,CAAC,CAAC,IAAI,CACL,CACN,CAAA;AACH,CAAC,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,IAAI,GAAmC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IACxD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA;IAE1D,OAAO,CACL,oBAAC,YAAY,IAAC,SAAS,EAAC,0BAA0B;QAChD,oBAAC,WAAW,IAAC,EAAE,EAAE,WAAW,EAAE,SAAS,EAAC,eAAe,IACpD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAC/B,oBAAC,OAAO,IAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,GAAI,CAC1D,CAAC,CACU,CACD,CAChB,CAAA;AACH,CAAC,CAAA;AAED,eAAe,IAAI,CAAA","sourcesContent":["import { ListBlock, ListItem, VisualDataBlock } from '@starlightcms/js-sdk'\nimport { BlockWrapper } from '../../styles'\nimport { ListWrapper } from './styles'\nimport React, { FC } from 'react'\n\ntype SubListProps = {\n item: ListItem\n Wrapper: 'ul' | 'ol'\n}\n\nconst SubList: FC<SubListProps> = ({ item, Wrapper }) => {\n return (\n <li>\n <span dangerouslySetInnerHTML={{ __html: item.content }} />\n {item.items && item.items.length ? (\n <Wrapper>\n {item.items &&\n item.items.map((subItem, index) => (\n <SubList key={index} item={subItem} Wrapper={Wrapper} />\n ))}\n </Wrapper>\n ) : null}\n </li>\n )\n}\n\n/**\n * VisualContent renderer component that renders `list` type blocks\n * as `<ul>` or `<ol>` elements, depending on the list style.\n *\n * See {@doclink components/VisualContent/#customizing-components | the guide page on the VisualContent component}\n * to learn how to customize block renderer components like this one.\n *\n * @param props VisualDataBlock object. See {@link ListBlock} to learn the\n * type of data this component receives.\n * @group VisualContent Renderers\n */\nconst List: FC<VisualDataBlock<ListBlock>> = ({ data }) => {\n const listElement = data.style === 'ordered' ? 'ol' : 'ul'\n\n return (\n <BlockWrapper className=\"sl-content-block sl-list\">\n <ListWrapper as={listElement} className=\"sl-list__root\">\n {data.items.map((item, index) => (\n <SubList key={index} item={item} Wrapper={listElement} />\n ))}\n </ListWrapper>\n </BlockWrapper>\n )\n}\n\nexport default List\n"]}
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare const ListWrapper: import("@emotion/styled").StyledComponent<{
3
+ theme?: import("@emotion/react").Theme | undefined;
4
+ as?: import("react").ElementType<any> | undefined;
5
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, {}>;
6
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../src/VisualContent/blocks/List/styles.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,WAAW;;;6GAYvB,CAAA"}