@valbuild/react 0.31.0 → 0.33.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 (43) hide show
  1. package/dist/{ValProviderInternal-61d82ec0.esm.js → ValProvider-0620664e.esm.js} +64 -16
  2. package/dist/{ValProviderInternal-62bd0c14.browser.esm.js → ValProvider-14179159.browser.esm.js} +63 -15
  3. package/dist/{ValProviderInternal-d20f3c34.cjs.dev.js → ValProvider-7513c6ec.cjs.dev.js} +81 -16
  4. package/dist/ValProvider-b2e83d12.cjs.js +7 -0
  5. package/dist/{ValProviderInternal-757e00dc.cjs.prod.js → ValProvider-b2e83d12.cjs.prod.js} +81 -16
  6. package/dist/{ValProviderInternal-f64d019a.worker.esm.js → ValProvider-d46ec16a.worker.esm.js} +63 -20
  7. package/dist/{ValUI-82ba086a.cjs.dev.js → ValUI-33562b10.cjs.dev.js} +5 -43
  8. package/dist/{ValUI-eb3ed9e3.worker.esm.js → ValUI-3b9f6c17.worker.esm.js} +6 -44
  9. package/dist/{ValUI-c969250a.esm.js → ValUI-4ba5efea.esm.js} +6 -44
  10. package/dist/{ValUI-d049362e.browser.esm.js → ValUI-75338157.browser.esm.js} +6 -44
  11. package/dist/ValUI-8ea90ec3.cjs.js +7 -0
  12. package/dist/{ValUI-596c6129.cjs.prod.js → ValUI-8ea90ec3.cjs.prod.js} +5 -43
  13. package/dist/declarations/src/index.d.ts +11 -3
  14. package/dist/declarations/src/internal/ValProvider.d.ts +16 -0
  15. package/dist/declarations/src/{ValStore.d.ts → internal/ValStore.d.ts} +1 -1
  16. package/dist/declarations/src/internal/index.d.ts +2 -0
  17. package/dist/declarations/src/stega/stegaEncode.d.ts +1 -1
  18. package/dist/valbuild-react.browser.esm.js +11 -160
  19. package/dist/valbuild-react.cjs.d.ts +1 -0
  20. package/dist/valbuild-react.cjs.dev.js +12 -192
  21. package/dist/valbuild-react.cjs.prod.js +12 -192
  22. package/dist/valbuild-react.esm.js +11 -160
  23. package/dist/valbuild-react.worker.esm.js +11 -152
  24. package/internal/dist/valbuild-react-internal.browser.esm.js +146 -0
  25. package/internal/dist/valbuild-react-internal.cjs.d.ts +2 -0
  26. package/internal/dist/valbuild-react-internal.cjs.d.ts.map +1 -0
  27. package/internal/dist/valbuild-react-internal.cjs.dev.js +166 -0
  28. package/internal/dist/valbuild-react-internal.cjs.js +7 -0
  29. package/internal/dist/valbuild-react-internal.cjs.prod.js +166 -0
  30. package/internal/dist/valbuild-react-internal.esm.js +146 -0
  31. package/internal/dist/valbuild-react-internal.worker.esm.js +146 -0
  32. package/internal/package.json +7 -0
  33. package/package.json +16 -5
  34. package/stega/dist/valbuild-react-stega.browser.esm.js +1 -1
  35. package/stega/dist/valbuild-react-stega.cjs.dev.js +3 -3
  36. package/stega/dist/valbuild-react-stega.cjs.prod.js +3 -3
  37. package/stega/dist/valbuild-react-stega.esm.js +1 -1
  38. package/stega/dist/valbuild-react-stega.worker.esm.js +1 -1
  39. package/dist/ValProviderInternal-757e00dc.cjs.js +0 -7
  40. package/dist/ValUI-596c6129.cjs.js +0 -7
  41. package/dist/declarations/src/ValProvider.d.ts +0 -3
  42. package/dist/declarations/src/ValProviderInternal.d.ts +0 -15
  43. /package/dist/declarations/src/{ValRichText.d.ts → internal/ValRichText.d.ts} +0 -0
@@ -0,0 +1,146 @@
1
+ export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-0620664e.esm.js';
2
+ import React from 'react';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ /* eslint-disable @typescript-eslint/ban-types */
6
+ function ValRichText(_ref) {
7
+ var theme = _ref.theme,
8
+ className = _ref.className,
9
+ children = _ref.children;
10
+ var root = children;
11
+ function withRenderTag(clazz, current) {
12
+ var renderClass = theme.tags[clazz];
13
+ if (renderClass && current) {
14
+ return [current, renderClass].join(" ");
15
+ }
16
+ if (renderClass) {
17
+ return renderClass;
18
+ }
19
+ return current;
20
+ }
21
+ function withRenderClass(clazz, current) {
22
+ var renderClass = theme.classes[clazz];
23
+ if (renderClass && current) {
24
+ return [current, renderClass].join(" ");
25
+ }
26
+ if (renderClass) {
27
+ return renderClass;
28
+ }
29
+ return current;
30
+ }
31
+ function toReact(node, key) {
32
+ var _anyNode$class, _anyNode$children;
33
+ if (typeof node === "string") {
34
+ return node;
35
+ }
36
+ if (node.tag === "p") {
37
+ return /*#__PURE__*/jsx("p", {
38
+ className: withRenderTag("p"),
39
+ children: node.children.map(toReact)
40
+ }, key);
41
+ }
42
+ if (node.tag === "img") {
43
+ return /*#__PURE__*/jsx("img", {
44
+ className: withRenderTag("img"),
45
+ src: node.src
46
+ }, key);
47
+ }
48
+ if (node.tag === "ul") {
49
+ return /*#__PURE__*/jsx("ul", {
50
+ className: withRenderTag("ul"),
51
+ children: node.children.map(toReact)
52
+ }, key);
53
+ }
54
+ if (node.tag === "ol") {
55
+ return /*#__PURE__*/jsx("ol", {
56
+ className: withRenderTag("ol"),
57
+ children: node.children.map(toReact)
58
+ }, key);
59
+ }
60
+ if (node.tag === "li") {
61
+ return /*#__PURE__*/jsx("li", {
62
+ className: withRenderTag("li"),
63
+ children: node.children.map(toReact)
64
+ }, key);
65
+ }
66
+ if (node.tag === "span") {
67
+ return /*#__PURE__*/jsx("span", {
68
+ className: node.classes.map(function (nodeClass) {
69
+ switch (nodeClass) {
70
+ case "bold":
71
+ return withRenderClass("bold");
72
+ case "line-through":
73
+ return withRenderClass("lineThrough");
74
+ case "italic":
75
+ return withRenderClass("italic");
76
+ }
77
+ }).join(" "),
78
+ children: node.children.map(toReact)
79
+ }, key);
80
+ }
81
+ if (node.tag === "h1") {
82
+ return /*#__PURE__*/jsx("h1", {
83
+ className: withRenderTag("h1"),
84
+ children: node.children.map(toReact)
85
+ }, key);
86
+ }
87
+ if (node.tag === "h2") {
88
+ return /*#__PURE__*/jsx("h2", {
89
+ className: withRenderTag("h2"),
90
+ children: node.children.map(toReact)
91
+ }, key);
92
+ }
93
+ if (node.tag === "h3") {
94
+ return /*#__PURE__*/jsx("h3", {
95
+ className: withRenderTag("h3"),
96
+ children: node.children.map(toReact)
97
+ }, key);
98
+ }
99
+ if (node.tag === "h4") {
100
+ return /*#__PURE__*/jsx("h4", {
101
+ className: withRenderTag("h4"),
102
+ children: node.children.map(toReact)
103
+ }, key);
104
+ }
105
+ if (node.tag === "h5") {
106
+ return /*#__PURE__*/jsx("h5", {
107
+ className: withRenderTag("h5"),
108
+ children: node.children.map(toReact)
109
+ }, key);
110
+ }
111
+ if (node.tag === "h6") {
112
+ return /*#__PURE__*/jsx("h6", {
113
+ className: withRenderTag("h6"),
114
+ children: node.children.map(toReact)
115
+ }, key);
116
+ }
117
+ if (node.tag === "br") {
118
+ return /*#__PURE__*/jsx("br", {}, key);
119
+ }
120
+ if (node.tag === "a") {
121
+ return /*#__PURE__*/jsx("a", {
122
+ href: node.href,
123
+ children: node.children.map(toReact)
124
+ }, key);
125
+ }
126
+ console.error("Unknown tag", node.tag);
127
+ var _exhaustiveCheck = node.tag;
128
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
129
+ var anyNode = _exhaustiveCheck;
130
+ if (!(anyNode !== null && anyNode !== void 0 && anyNode.tag)) {
131
+ return null;
132
+ }
133
+ return /*#__PURE__*/React.createElement(anyNode.tag, {
134
+ key: key,
135
+ className: (_anyNode$class = anyNode["class"]) === null || _anyNode$class === void 0 ? void 0 : _anyNode$class.join(" "),
136
+ children: (_anyNode$children = anyNode.children) === null || _anyNode$children === void 0 ? void 0 : _anyNode$children.map(toReact)
137
+ });
138
+ }
139
+ return /*#__PURE__*/jsx("div", {
140
+ className: className,
141
+ "data-val-path": root.valPath,
142
+ children: root.children.map(toReact)
143
+ });
144
+ }
145
+
146
+ export { ValRichText };
@@ -0,0 +1,146 @@
1
+ export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-d46ec16a.worker.esm.js';
2
+ import React from 'react';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ /* eslint-disable @typescript-eslint/ban-types */
6
+ function ValRichText(_ref) {
7
+ var theme = _ref.theme,
8
+ className = _ref.className,
9
+ children = _ref.children;
10
+ var root = children;
11
+ function withRenderTag(clazz, current) {
12
+ var renderClass = theme.tags[clazz];
13
+ if (renderClass && current) {
14
+ return [current, renderClass].join(" ");
15
+ }
16
+ if (renderClass) {
17
+ return renderClass;
18
+ }
19
+ return current;
20
+ }
21
+ function withRenderClass(clazz, current) {
22
+ var renderClass = theme.classes[clazz];
23
+ if (renderClass && current) {
24
+ return [current, renderClass].join(" ");
25
+ }
26
+ if (renderClass) {
27
+ return renderClass;
28
+ }
29
+ return current;
30
+ }
31
+ function toReact(node, key) {
32
+ var _anyNode$class, _anyNode$children;
33
+ if (typeof node === "string") {
34
+ return node;
35
+ }
36
+ if (node.tag === "p") {
37
+ return /*#__PURE__*/jsx("p", {
38
+ className: withRenderTag("p"),
39
+ children: node.children.map(toReact)
40
+ }, key);
41
+ }
42
+ if (node.tag === "img") {
43
+ return /*#__PURE__*/jsx("img", {
44
+ className: withRenderTag("img"),
45
+ src: node.src
46
+ }, key);
47
+ }
48
+ if (node.tag === "ul") {
49
+ return /*#__PURE__*/jsx("ul", {
50
+ className: withRenderTag("ul"),
51
+ children: node.children.map(toReact)
52
+ }, key);
53
+ }
54
+ if (node.tag === "ol") {
55
+ return /*#__PURE__*/jsx("ol", {
56
+ className: withRenderTag("ol"),
57
+ children: node.children.map(toReact)
58
+ }, key);
59
+ }
60
+ if (node.tag === "li") {
61
+ return /*#__PURE__*/jsx("li", {
62
+ className: withRenderTag("li"),
63
+ children: node.children.map(toReact)
64
+ }, key);
65
+ }
66
+ if (node.tag === "span") {
67
+ return /*#__PURE__*/jsx("span", {
68
+ className: node.classes.map(function (nodeClass) {
69
+ switch (nodeClass) {
70
+ case "bold":
71
+ return withRenderClass("bold");
72
+ case "line-through":
73
+ return withRenderClass("lineThrough");
74
+ case "italic":
75
+ return withRenderClass("italic");
76
+ }
77
+ }).join(" "),
78
+ children: node.children.map(toReact)
79
+ }, key);
80
+ }
81
+ if (node.tag === "h1") {
82
+ return /*#__PURE__*/jsx("h1", {
83
+ className: withRenderTag("h1"),
84
+ children: node.children.map(toReact)
85
+ }, key);
86
+ }
87
+ if (node.tag === "h2") {
88
+ return /*#__PURE__*/jsx("h2", {
89
+ className: withRenderTag("h2"),
90
+ children: node.children.map(toReact)
91
+ }, key);
92
+ }
93
+ if (node.tag === "h3") {
94
+ return /*#__PURE__*/jsx("h3", {
95
+ className: withRenderTag("h3"),
96
+ children: node.children.map(toReact)
97
+ }, key);
98
+ }
99
+ if (node.tag === "h4") {
100
+ return /*#__PURE__*/jsx("h4", {
101
+ className: withRenderTag("h4"),
102
+ children: node.children.map(toReact)
103
+ }, key);
104
+ }
105
+ if (node.tag === "h5") {
106
+ return /*#__PURE__*/jsx("h5", {
107
+ className: withRenderTag("h5"),
108
+ children: node.children.map(toReact)
109
+ }, key);
110
+ }
111
+ if (node.tag === "h6") {
112
+ return /*#__PURE__*/jsx("h6", {
113
+ className: withRenderTag("h6"),
114
+ children: node.children.map(toReact)
115
+ }, key);
116
+ }
117
+ if (node.tag === "br") {
118
+ return /*#__PURE__*/jsx("br", {}, key);
119
+ }
120
+ if (node.tag === "a") {
121
+ return /*#__PURE__*/jsx("a", {
122
+ href: node.href,
123
+ children: node.children.map(toReact)
124
+ }, key);
125
+ }
126
+ console.error("Unknown tag", node.tag);
127
+ var _exhaustiveCheck = node.tag;
128
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
129
+ var anyNode = _exhaustiveCheck;
130
+ if (!(anyNode !== null && anyNode !== void 0 && anyNode.tag)) {
131
+ return null;
132
+ }
133
+ return /*#__PURE__*/React.createElement(anyNode.tag, {
134
+ key: key,
135
+ className: (_anyNode$class = anyNode["class"]) === null || _anyNode$class === void 0 ? void 0 : _anyNode$class.join(" "),
136
+ children: (_anyNode$children = anyNode.children) === null || _anyNode$children === void 0 ? void 0 : _anyNode$children.map(toReact)
137
+ });
138
+ }
139
+ return /*#__PURE__*/jsx("div", {
140
+ className: className,
141
+ "data-val-path": root.valPath,
142
+ children: root.children.map(toReact)
143
+ });
144
+ }
145
+
146
+ export { ValRichText };
@@ -0,0 +1,7 @@
1
+ {
2
+ "main": "dist/valbuild-react-internal.cjs.js",
3
+ "module": "dist/valbuild-react-internal.esm.js",
4
+ "browser": {
5
+ "./dist/valbuild-react-internal.esm.js": "./dist/valbuild-react-internal.browser.esm.js"
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/react",
3
- "version": "0.31.0",
3
+ "version": "0.33.0",
4
4
  "private": false,
5
5
  "description": "Val - React internal helpers",
6
6
  "sideEffects": false,
@@ -9,8 +9,9 @@
9
9
  "test": "jest"
10
10
  },
11
11
  "dependencies": {
12
- "@valbuild/core": "~0.31.0",
13
- "@valbuild/ui": "~0.31.0",
12
+ "@valbuild/core": "~0.33.0",
13
+ "@valbuild/ui": "~0.33.0",
14
+ "@valbuild/shared": "~0.33.0",
14
15
  "@vercel/stega": "^0.1.0",
15
16
  "base64-arraybuffer": "^1.0.2",
16
17
  "style-to-object": "^0.4.1"
@@ -36,7 +37,8 @@
36
37
  "./index.ts",
37
38
  "./jsx-runtime.js",
38
39
  "./jsx-dev-runtime.js",
39
- "./stega/index.ts"
40
+ "./stega/index.ts",
41
+ "./internal/index.ts"
40
42
  ],
41
43
  "exports": {
42
44
  "envConditions": [
@@ -78,6 +80,14 @@
78
80
  },
79
81
  "default": "./stega/dist/valbuild-react-stega.cjs.js"
80
82
  },
83
+ "./internal": {
84
+ "module": {
85
+ "worker": "./internal/dist/valbuild-react-internal.worker.esm.js",
86
+ "browser": "./internal/dist/valbuild-react-internal.browser.esm.js",
87
+ "default": "./internal/dist/valbuild-react-internal.esm.js"
88
+ },
89
+ "default": "./internal/dist/valbuild-react-internal.cjs.js"
90
+ },
81
91
  "./jsx-dev-runtime": {
82
92
  "module": {
83
93
  "worker": "./jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.worker.esm.js",
@@ -93,6 +103,7 @@
93
103
  "dist",
94
104
  "jsx-runtime",
95
105
  "jsx-dev-runtime",
96
- "stega"
106
+ "stega",
107
+ "internal"
97
108
  ]
98
109
  }
@@ -6,7 +6,7 @@ import React from 'react';
6
6
  import { VERCEL_STEGA_REGEX, vercelStegaDecode, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
7
7
  import { _ as _defineProperty } from '../../dist/defineProperty-f319cb47.browser.esm.js';
8
8
  import { Internal, VAL_EXTENSION, FILE_REF_PROP } from '@valbuild/core';
9
- import { parseRichTextSource } from '@valbuild/ui';
9
+ import { parseRichTextSource } from '@valbuild/shared/internal';
10
10
 
11
11
  var isIntrinsicElement = function isIntrinsicElement(type) {
12
12
  // TODO: think this is not correct, but good enough for now?
@@ -10,7 +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
+ var internal = require('@valbuild/shared/internal');
14
14
 
15
15
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
16
16
 
@@ -126,11 +126,11 @@ function stegaEncode(input, opts) {
126
126
  if (core.VAL_EXTENSION in sourceOrSelector) {
127
127
  if (sourceOrSelector[core.VAL_EXTENSION] === "richtext") {
128
128
  if (recOpts !== null && recOpts !== void 0 && recOpts.path) {
129
- return _objectSpread2(_objectSpread2({}, ui.parseRichTextSource(sourceOrSelector)), {}, {
129
+ return _objectSpread2(_objectSpread2({}, internal.parseRichTextSource(sourceOrSelector)), {}, {
130
130
  valPath: recOpts.path
131
131
  });
132
132
  }
133
- return ui.parseRichTextSource(sourceOrSelector);
133
+ return internal.parseRichTextSource(sourceOrSelector);
134
134
  }
135
135
  if (sourceOrSelector[core.VAL_EXTENSION] === "file" && typeof sourceOrSelector[core.FILE_REF_PROP] === "string") {
136
136
  var fileSelector = core.Internal.convertFileSource(sourceOrSelector);
@@ -10,7 +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
+ var internal = require('@valbuild/shared/internal');
14
14
 
15
15
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
16
16
 
@@ -126,11 +126,11 @@ function stegaEncode(input, opts) {
126
126
  if (core.VAL_EXTENSION in sourceOrSelector) {
127
127
  if (sourceOrSelector[core.VAL_EXTENSION] === "richtext") {
128
128
  if (recOpts !== null && recOpts !== void 0 && recOpts.path) {
129
- return _objectSpread2(_objectSpread2({}, ui.parseRichTextSource(sourceOrSelector)), {}, {
129
+ return _objectSpread2(_objectSpread2({}, internal.parseRichTextSource(sourceOrSelector)), {}, {
130
130
  valPath: recOpts.path
131
131
  });
132
132
  }
133
- return ui.parseRichTextSource(sourceOrSelector);
133
+ return internal.parseRichTextSource(sourceOrSelector);
134
134
  }
135
135
  if (sourceOrSelector[core.VAL_EXTENSION] === "file" && typeof sourceOrSelector[core.FILE_REF_PROP] === "string") {
136
136
  var fileSelector = core.Internal.convertFileSource(sourceOrSelector);
@@ -6,7 +6,7 @@ import React from 'react';
6
6
  import { VERCEL_STEGA_REGEX, vercelStegaDecode, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
7
7
  import { _ as _defineProperty } from '../../dist/defineProperty-12b5bd29.esm.js';
8
8
  import { Internal, VAL_EXTENSION, FILE_REF_PROP } from '@valbuild/core';
9
- import { parseRichTextSource } from '@valbuild/ui';
9
+ import { parseRichTextSource } from '@valbuild/shared/internal';
10
10
 
11
11
  var isIntrinsicElement = function isIntrinsicElement(type) {
12
12
  // TODO: think this is not correct, but good enough for now?
@@ -6,7 +6,7 @@ import React from 'react';
6
6
  import { VERCEL_STEGA_REGEX, vercelStegaDecode, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
7
7
  import { _ as _defineProperty } from '../../dist/defineProperty-a4bf59bc.worker.esm.js';
8
8
  import { Internal, VAL_EXTENSION, FILE_REF_PROP } from '@valbuild/core';
9
- import { parseRichTextSource } from '@valbuild/ui';
9
+ import { parseRichTextSource } from '@valbuild/shared/internal';
10
10
 
11
11
  var isIntrinsicElement = function isIntrinsicElement(type) {
12
12
  // TODO: think this is not correct, but good enough for now?
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./ValProviderInternal-757e00dc.cjs.prod.js");
5
- } else {
6
- module.exports = require("./ValProviderInternal-757e00dc.cjs.dev.js");
7
- }
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./ValUI-596c6129.cjs.prod.js");
5
- } else {
6
- module.exports = require("./ValUI-596c6129.cjs.dev.js");
7
- }
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { ValProviderProps } from "./ValProviderInternal.js";
3
- export declare function ValProvider({ children }: ValProviderProps): JSX.Element;
@@ -1,15 +0,0 @@
1
- import React from "react";
2
- import { ValStore } from "./ValStore.js";
3
- import { ValApi } from "@valbuild/core";
4
- export declare const useValStore: undefined | (() => ValStore | undefined);
5
- export declare const useValApi: undefined | (() => ValApi | undefined);
6
- export type ValContext = {
7
- readonly valStore?: ValStore;
8
- readonly valApi?: ValApi;
9
- };
10
- export declare const ValContext: React.Context<ValContext>;
11
- export type ValProviderProps = {
12
- children?: React.ReactNode;
13
- };
14
- declare function ValProviderInternal({ children }: ValProviderProps): JSX.Element;
15
- export default ValProviderInternal;