@valbuild/react 0.20.2 → 0.21.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.
@@ -26,7 +26,7 @@ type ThemeOptions<O extends RichTextOptions> = {
26
26
  } & { p?: string };
27
27
  classes: {
28
28
  [Key in Classes & keyof O as O[Key] extends true ? Key : never]: string;
29
- } & (O["img"] extends true ? { imgContainer?: string } : {});
29
+ };
30
30
  };
31
31
 
32
32
  export function ValRichText<O extends RichTextOptions>({
@@ -83,15 +83,8 @@ export function ValRichText<O extends RichTextOptions>({
83
83
  );
84
84
  }
85
85
  if (node.tag === "img") {
86
- return (
87
- <div className={withRenderClass("imgContainer")} key={key}>
88
- <img className={withRenderTag("img")} src={node.src} />
89
- </div>
90
- );
86
+ return <img className={withRenderTag("img")} key={key} src={node.src} />;
91
87
  }
92
- // if (node.tag === "blockquote") {
93
- // return <blockquote key={key}>{node.children.map(toReact)}</blockquote>;
94
- // }
95
88
  if (node.tag === "ul") {
96
89
  return (
97
90
  <ul className={withRenderTag("ul")} key={key}>
@@ -176,9 +169,21 @@ export function ValRichText<O extends RichTextOptions>({
176
169
  </h6>
177
170
  );
178
171
  }
172
+
173
+ if (node.tag === "br") {
174
+ return <br key={key} />;
175
+ }
176
+ if (node.tag === "a") {
177
+ return (
178
+ <a href={node.href} key={key}>
179
+ {node.children.map(toReact)}
180
+ </a>
181
+ );
182
+ }
179
183
  console.error("Unknown tag", node.tag);
184
+ const _exhaustiveCheck: never = node.tag;
180
185
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
181
- const anyNode = node as any;
186
+ const anyNode = _exhaustiveCheck as any;
182
187
  if (!anyNode?.tag) {
183
188
  return null;
184
189
  }
package/src/ValUI.tsx CHANGED
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
4
  import { Internal } from "@valbuild/core";
3
5
  import { Style, ValOverlay } from "@valbuild/ui";
@@ -11,6 +11,7 @@ import { vercelStegaCombine } from "@vercel/stega";
11
11
  import { FileSource, Source, SourceObject } from "@valbuild/core";
12
12
  import { JsonPrimitive } from "@valbuild/core";
13
13
  import { SourceArray } from "@valbuild/core";
14
+ import { parseRichTextSource } from "@valbuild/ui";
14
15
 
15
16
  declare const brand: unique symbol;
16
17
 
@@ -73,12 +74,12 @@ export function stegaEncode(
73
74
  if (sourceOrSelector[VAL_EXTENSION] === "richtext") {
74
75
  if (recOpts?.path) {
75
76
  return {
76
- ...Internal.convertRichTextSource(sourceOrSelector),
77
+ ...parseRichTextSource(sourceOrSelector),
77
78
  valPath: recOpts.path,
78
79
  };
79
80
  }
80
81
 
81
- return Internal.convertRichTextSource(sourceOrSelector);
82
+ return parseRichTextSource(sourceOrSelector);
82
83
  }
83
84
 
84
85
  if (
@@ -6,6 +6,7 @@ import React from 'react';
6
6
  import { VERCEL_STEGA_REGEX, vercelStegaDecode, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
7
7
  import { a as _defineProperty } from '../../dist/defineProperty-034d0378.browser.esm.js';
8
8
  import { Internal, VAL_EXTENSION, FILE_REF_PROP } from '@valbuild/core';
9
+ import { parseRichTextSource } from '@valbuild/ui';
9
10
 
10
11
  var isIntrinsicElement = function isIntrinsicElement(type) {
11
12
  // TODO: think this is not correct, but good enough for now?
@@ -115,11 +116,11 @@ function stegaEncode(input, opts) {
115
116
  if (VAL_EXTENSION in sourceOrSelector) {
116
117
  if (sourceOrSelector[VAL_EXTENSION] === "richtext") {
117
118
  if (recOpts !== null && recOpts !== void 0 && recOpts.path) {
118
- return _objectSpread2(_objectSpread2({}, Internal.convertRichTextSource(sourceOrSelector)), {}, {
119
+ return _objectSpread2(_objectSpread2({}, parseRichTextSource(sourceOrSelector)), {}, {
119
120
  valPath: recOpts.path
120
121
  });
121
122
  }
122
- return Internal.convertRichTextSource(sourceOrSelector);
123
+ return parseRichTextSource(sourceOrSelector);
123
124
  }
124
125
  if (sourceOrSelector[VAL_EXTENSION] === "file" && typeof sourceOrSelector[FILE_REF_PROP] === "string") {
125
126
  var fileSelector = Internal.convertFileSource(sourceOrSelector);
@@ -10,6 +10,7 @@ var React = require('react');
10
10
  var stega = require('@vercel/stega');
11
11
  var defineProperty = require('../../dist/defineProperty-c82a49b0.cjs.dev.js');
12
12
  var core = require('@valbuild/core');
13
+ var ui = require('@valbuild/ui');
13
14
 
14
15
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
15
16
 
@@ -125,11 +126,11 @@ function stegaEncode(input, opts) {
125
126
  if (core.VAL_EXTENSION in sourceOrSelector) {
126
127
  if (sourceOrSelector[core.VAL_EXTENSION] === "richtext") {
127
128
  if (recOpts !== null && recOpts !== void 0 && recOpts.path) {
128
- return _objectSpread2(_objectSpread2({}, core.Internal.convertRichTextSource(sourceOrSelector)), {}, {
129
+ return _objectSpread2(_objectSpread2({}, ui.parseRichTextSource(sourceOrSelector)), {}, {
129
130
  valPath: recOpts.path
130
131
  });
131
132
  }
132
- return core.Internal.convertRichTextSource(sourceOrSelector);
133
+ return ui.parseRichTextSource(sourceOrSelector);
133
134
  }
134
135
  if (sourceOrSelector[core.VAL_EXTENSION] === "file" && typeof sourceOrSelector[core.FILE_REF_PROP] === "string") {
135
136
  var fileSelector = core.Internal.convertFileSource(sourceOrSelector);
@@ -10,6 +10,7 @@ var React = require('react');
10
10
  var stega = require('@vercel/stega');
11
11
  var defineProperty = require('../../dist/defineProperty-36ed93cd.cjs.prod.js');
12
12
  var core = require('@valbuild/core');
13
+ var ui = require('@valbuild/ui');
13
14
 
14
15
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
15
16
 
@@ -125,11 +126,11 @@ function stegaEncode(input, opts) {
125
126
  if (core.VAL_EXTENSION in sourceOrSelector) {
126
127
  if (sourceOrSelector[core.VAL_EXTENSION] === "richtext") {
127
128
  if (recOpts !== null && recOpts !== void 0 && recOpts.path) {
128
- return _objectSpread2(_objectSpread2({}, core.Internal.convertRichTextSource(sourceOrSelector)), {}, {
129
+ return _objectSpread2(_objectSpread2({}, ui.parseRichTextSource(sourceOrSelector)), {}, {
129
130
  valPath: recOpts.path
130
131
  });
131
132
  }
132
- return core.Internal.convertRichTextSource(sourceOrSelector);
133
+ return ui.parseRichTextSource(sourceOrSelector);
133
134
  }
134
135
  if (sourceOrSelector[core.VAL_EXTENSION] === "file" && typeof sourceOrSelector[core.FILE_REF_PROP] === "string") {
135
136
  var fileSelector = core.Internal.convertFileSource(sourceOrSelector);
@@ -6,6 +6,7 @@ import React from 'react';
6
6
  import { VERCEL_STEGA_REGEX, vercelStegaDecode, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
7
7
  import { a as _defineProperty } from '../../dist/defineProperty-b209a901.esm.js';
8
8
  import { Internal, VAL_EXTENSION, FILE_REF_PROP } from '@valbuild/core';
9
+ import { parseRichTextSource } from '@valbuild/ui';
9
10
 
10
11
  var isIntrinsicElement = function isIntrinsicElement(type) {
11
12
  // TODO: think this is not correct, but good enough for now?
@@ -115,11 +116,11 @@ function stegaEncode(input, opts) {
115
116
  if (VAL_EXTENSION in sourceOrSelector) {
116
117
  if (sourceOrSelector[VAL_EXTENSION] === "richtext") {
117
118
  if (recOpts !== null && recOpts !== void 0 && recOpts.path) {
118
- return _objectSpread2(_objectSpread2({}, Internal.convertRichTextSource(sourceOrSelector)), {}, {
119
+ return _objectSpread2(_objectSpread2({}, parseRichTextSource(sourceOrSelector)), {}, {
119
120
  valPath: recOpts.path
120
121
  });
121
122
  }
122
- return Internal.convertRichTextSource(sourceOrSelector);
123
+ return parseRichTextSource(sourceOrSelector);
123
124
  }
124
125
  if (sourceOrSelector[VAL_EXTENSION] === "file" && typeof sourceOrSelector[FILE_REF_PROP] === "string") {
125
126
  var fileSelector = Internal.convertFileSource(sourceOrSelector);
@@ -6,6 +6,7 @@ import React from 'react';
6
6
  import { VERCEL_STEGA_REGEX, vercelStegaDecode, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
7
7
  import { a as _defineProperty } from '../../dist/defineProperty-18559492.worker.esm.js';
8
8
  import { Internal, VAL_EXTENSION, FILE_REF_PROP } from '@valbuild/core';
9
+ import { parseRichTextSource } from '@valbuild/ui';
9
10
 
10
11
  var isIntrinsicElement = function isIntrinsicElement(type) {
11
12
  // TODO: think this is not correct, but good enough for now?
@@ -115,11 +116,11 @@ function stegaEncode(input, opts) {
115
116
  if (VAL_EXTENSION in sourceOrSelector) {
116
117
  if (sourceOrSelector[VAL_EXTENSION] === "richtext") {
117
118
  if (recOpts !== null && recOpts !== void 0 && recOpts.path) {
118
- return _objectSpread2(_objectSpread2({}, Internal.convertRichTextSource(sourceOrSelector)), {}, {
119
+ return _objectSpread2(_objectSpread2({}, parseRichTextSource(sourceOrSelector)), {}, {
119
120
  valPath: recOpts.path
120
121
  });
121
122
  }
122
- return Internal.convertRichTextSource(sourceOrSelector);
123
+ return parseRichTextSource(sourceOrSelector);
123
124
  }
124
125
  if (sourceOrSelector[VAL_EXTENSION] === "file" && typeof sourceOrSelector[FILE_REF_PROP] === "string") {
125
126
  var fileSelector = Internal.convertFileSource(sourceOrSelector);