lkb-fields-document 1.0.0 → 1.0.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.
Files changed (109) hide show
  1. package/component-blocks/dist/lkb-fields-document-component-blocks.cjs.d.ts +2 -2
  2. package/component-blocks/dist/lkb-fields-document-component-blocks.cjs.js +16 -306
  3. package/component-blocks/dist/lkb-fields-document-component-blocks.node.cjs.js +16 -306
  4. package/dist/lkb-fields-document.cjs.d.ts +2 -2
  5. package/dist/lkb-fields-document.cjs.js +16 -1167
  6. package/dist/lkb-fields-document.node.cjs.js +16 -1167
  7. package/package.json +6 -6
  8. package/structure-views/dist/lkb-fields-document-structure-views.cjs.d.ts +2 -2
  9. package/structure-views/dist/lkb-fields-document-structure-views.cjs.js +16 -138
  10. package/structure-views/dist/lkb-fields-document-structure-views.node.cjs.js +16 -138
  11. package/views/dist/lkb-fields-document-views.cjs.d.ts +2 -2
  12. package/views/dist/lkb-fields-document-views.cjs.js +13 -111
  13. package/views/dist/lkb-fields-document-views.node.cjs.js +13 -111
  14. package/component-blocks/dist/lkb-fields-document-component-blocks.esm.js +0 -300
  15. package/component-blocks/dist/lkb-fields-document-component-blocks.node.esm.js +0 -300
  16. package/dist/Cell-0ac0ac66.node.cjs.js +0 -21
  17. package/dist/Cell-242f7404.esm.js +0 -17
  18. package/dist/Cell-3103f73d.node.esm.js +0 -17
  19. package/dist/Cell-bfb56d74.cjs.js +0 -21
  20. package/dist/Field-0e0f75ed.node.cjs.js +0 -1628
  21. package/dist/Field-28177061.cjs.js +0 -1628
  22. package/dist/Field-35b79e6b.node.esm.js +0 -1619
  23. package/dist/Field-92d13205.esm.js +0 -1619
  24. package/dist/api-2f524611.esm.js +0 -502
  25. package/dist/api-73636987.cjs.js +0 -506
  26. package/dist/api-8e2b20b8.node.cjs.js +0 -506
  27. package/dist/api-c32e360e.node.esm.js +0 -502
  28. package/dist/callout-ui-2aded278.cjs.js +0 -131
  29. package/dist/callout-ui-3e5ca544.node.esm.js +0 -126
  30. package/dist/callout-ui-8b5f2376.esm.js +0 -126
  31. package/dist/callout-ui-ad50f301.node.cjs.js +0 -131
  32. package/dist/declarations/src/component-blocks.d.ts +0 -4
  33. package/dist/declarations/src/component-blocks.d.ts.map +0 -1
  34. package/dist/declarations/src/document-editor/component-blocks/api.d.ts +0 -120
  35. package/dist/declarations/src/document-editor/component-blocks/api.d.ts.map +0 -1
  36. package/dist/declarations/src/document-editor/component-blocks/types.d.ts +0 -241
  37. package/dist/declarations/src/document-editor/component-blocks/types.d.ts.map +0 -1
  38. package/dist/declarations/src/document-editor/toolset/relationship/relationship-shared.d.ts +0 -10
  39. package/dist/declarations/src/document-editor/toolset/relationship/relationship-shared.d.ts.map +0 -1
  40. package/dist/declarations/src/index.d.ts +0 -7
  41. package/dist/declarations/src/index.d.ts.map +0 -1
  42. package/dist/declarations/src/my-component-blocks/index.d.ts +0 -46
  43. package/dist/declarations/src/my-component-blocks/index.d.ts.map +0 -1
  44. package/dist/declarations/src/structure/Cell.d.ts +0 -5
  45. package/dist/declarations/src/structure/Cell.d.ts.map +0 -1
  46. package/dist/declarations/src/structure/Field.d.ts +0 -5
  47. package/dist/declarations/src/structure/Field.d.ts.map +0 -1
  48. package/dist/declarations/src/structure/controller.d.ts +0 -10
  49. package/dist/declarations/src/structure/controller.d.ts.map +0 -1
  50. package/dist/declarations/src/structure/structure.d.ts +0 -4
  51. package/dist/declarations/src/structure/structure.d.ts.map +0 -1
  52. package/dist/declarations/src/structure-views.d.ts +0 -5
  53. package/dist/declarations/src/structure-views.d.ts.map +0 -1
  54. package/dist/declarations/src/types/DocumentFeatures.d.ts +0 -33
  55. package/dist/declarations/src/types/DocumentFeatures.d.ts.map +0 -1
  56. package/dist/declarations/src/types/DocumentFieldConfig.d.ts +0 -18
  57. package/dist/declarations/src/types/DocumentFieldConfig.d.ts.map +0 -1
  58. package/dist/declarations/src/types/FormattingConfig.d.ts +0 -28
  59. package/dist/declarations/src/types/FormattingConfig.d.ts.map +0 -1
  60. package/dist/declarations/src/types/RelationshipsConfig.d.ts +0 -9
  61. package/dist/declarations/src/types/RelationshipsConfig.d.ts.map +0 -1
  62. package/dist/declarations/src/types/StructureFieldConfig.d.ts +0 -10
  63. package/dist/declarations/src/types/StructureFieldConfig.d.ts.map +0 -1
  64. package/dist/declarations/src/validation/structure-validation.d.ts +0 -218
  65. package/dist/declarations/src/validation/structure-validation.d.ts.map +0 -1
  66. package/dist/declarations/src/views/Cell.d.ts +0 -5
  67. package/dist/declarations/src/views/Cell.d.ts.map +0 -1
  68. package/dist/declarations/src/views/Field.d.ts +0 -5
  69. package/dist/declarations/src/views/Field.d.ts.map +0 -1
  70. package/dist/declarations/src/views/controller.d.ts +0 -15
  71. package/dist/declarations/src/views/controller.d.ts.map +0 -1
  72. package/dist/declarations/src/views/document.d.ts +0 -4
  73. package/dist/declarations/src/views/document.d.ts.map +0 -1
  74. package/dist/declarations/src/views.d.ts +0 -7
  75. package/dist/declarations/src/views.d.ts.map +0 -1
  76. package/dist/editor-shared-a6e340e6.node.esm.js +0 -1993
  77. package/dist/editor-shared-a997ae98.node.cjs.js +0 -2007
  78. package/dist/editor-shared-cc1293ed.cjs.js +0 -2007
  79. package/dist/editor-shared-da518ba3.esm.js +0 -1993
  80. package/dist/form-from-preview-2042b9ef.cjs.js +0 -512
  81. package/dist/form-from-preview-5df6e492.node.esm.js +0 -508
  82. package/dist/form-from-preview-9e501058.node.cjs.js +0 -512
  83. package/dist/form-from-preview-b3a66f37.esm.js +0 -508
  84. package/dist/index-06c36775.cjs.js +0 -14
  85. package/dist/index-586adb8f.node.esm.js +0 -11
  86. package/dist/index-67d52357.esm.js +0 -11
  87. package/dist/index-c3223fdc.node.cjs.js +0 -14
  88. package/dist/layouts-6412fa2a.esm.js +0 -189
  89. package/dist/layouts-a4a3cf0b.node.cjs.js +0 -196
  90. package/dist/layouts-ba9a558b.cjs.js +0 -196
  91. package/dist/layouts-e653b908.node.esm.js +0 -189
  92. package/dist/lkb-fields-document.esm.js +0 -1162
  93. package/dist/lkb-fields-document.node.esm.js +0 -1162
  94. package/dist/shared-0533009e.cjs.js +0 -594
  95. package/dist/shared-4684cc24.node.cjs.js +0 -594
  96. package/dist/shared-5e864055.node.esm.js +0 -579
  97. package/dist/shared-aaba5901.esm.js +0 -579
  98. package/dist/toolbar-state-3359e2f3.cjs.js +0 -994
  99. package/dist/toolbar-state-945823b8.node.esm.js +0 -971
  100. package/dist/toolbar-state-9611743f.node.cjs.js +0 -994
  101. package/dist/toolbar-state-bc8fe661.esm.js +0 -971
  102. package/dist/utils-06bcddc4.node.cjs.js +0 -747
  103. package/dist/utils-200ff260.node.esm.js +0 -722
  104. package/dist/utils-6409f730.cjs.js +0 -747
  105. package/dist/utils-bc6a0b82.esm.js +0 -722
  106. package/structure-views/dist/lkb-fields-document-structure-views.esm.js +0 -131
  107. package/structure-views/dist/lkb-fields-document-structure-views.node.esm.js +0 -131
  108. package/views/dist/lkb-fields-document-views.esm.js +0 -95
  109. package/views/dist/lkb-fields-document-views.node.esm.js +0 -95
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "lkb-fields-document",
3
- "description": "LKB Document Field Type",
4
- "version": "1.0.0",
3
+ "version": "1.0.1",
5
4
  "license": "MIT",
5
+ "description": "负责处理富文档编辑器相关的逻辑。",
6
6
  "main": "dist/lkb-fields-document.cjs.js",
7
7
  "module": "dist/lkb-fields-document.esm.js",
8
8
  "exports": {
@@ -102,11 +102,11 @@
102
102
  "zod": "^3.23.8"
103
103
  },
104
104
  "devDependencies": {
105
- "lkb-core": "workspace:^",
106
- "@types/is-hotkey": "^0.1.7"
105
+ "@types/is-hotkey": "^0.1.7",
106
+ "lkb-core": "^1.0.1"
107
107
  },
108
108
  "peerDependencies": {
109
- "lkb-core": "workspace:^"
109
+ "lkb-core": "^1.0.1"
110
110
  },
111
111
  "imports": {
112
112
  "#fields-ui": {
@@ -115,4 +115,4 @@
115
115
  "default": "./src/document-editor/component-blocks/fields-ui.tsx"
116
116
  }
117
117
  }
118
- }
118
+ }
@@ -1,2 +1,2 @@
1
- export * from "../../dist/declarations/src/structure-views.js";
2
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGtiLWZpZWxkcy1kb2N1bWVudC1zdHJ1Y3R1cmUtdmlld3MuY2pzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9kaXN0L2RlY2xhcmF0aW9ucy9zcmMvc3RydWN0dXJlLXZpZXdzLmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
1
+ export * from "../../src/structure-views.js";
2
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGtiLWZpZWxkcy1kb2N1bWVudC1zdHJ1Y3R1cmUtdmlld3MuY2pzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc3RydWN0dXJlLXZpZXdzLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9
@@ -1,138 +1,16 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var utils = require('../../dist/utils-6409f730.cjs.js');
6
- var React = require('react');
7
- var field = require('@keystar/ui/field');
8
- var formFromPreview = require('../../dist/form-from-preview-2042b9ef.cjs.js');
9
- var jsxRuntime = require('react/jsx-runtime');
10
- var typography = require('@keystar/ui/typography');
11
- require('slate');
12
- require('lkb-core/admin-ui/context');
13
- require('lkb-core/fields/types/relationship/views');
14
- require('lkb-core/admin-ui/utils');
15
- require('@keystar/ui/button');
16
- require('@keystar/ui/dialog');
17
- require('@keystar/ui/icon');
18
- require('@keystar/ui/list-view');
19
- require('@keystar/ui/drag-and-drop');
20
- require('@keystar/ui/tooltip');
21
- require('@keystar/ui/layout');
22
- require('@keystar/ui/icon/icons/trash2Icon');
23
- require('@keystar/ui/slots');
24
-
25
- function serializeValue(schema, value, kind) {
26
- if (schema.kind === 'conditional') {
27
- return {
28
- [value.discriminant]: serializeValue(schema.values[value.discriminant], value.value, kind)
29
- };
30
- }
31
- if (schema.kind === 'array') {
32
- if (value === null) return [];
33
- return value.map(x => serializeValue(schema.element, x, kind));
34
- }
35
- if (schema.kind === 'form') return value;
36
- if (schema.kind === 'object') {
37
- return Object.fromEntries(Object.entries(schema.fields).map(([key, val]) => {
38
- return [key, serializeValue(val, value[key], kind)];
39
- }));
40
- }
41
- if (schema.kind === 'relationship') {
42
- if (Array.isArray(value)) {
43
- return {
44
- [kind === 'create' ? 'connect' : 'set']: value.map(x => ({
45
- id: x.id
46
- }))
47
- };
48
- }
49
- if (value === null) {
50
- if (kind === 'create') return;
51
- return {
52
- disconnect: true
53
- };
54
- }
55
- return {
56
- connect: {
57
- id: value.id
58
- }
59
- };
60
- }
61
- if (schema.kind === 'child') {
62
- throw new Error('Child fields are not supported in the structure field');
63
- }
64
- utils.assertNever(schema);
65
- }
66
-
67
- function controller(config) {
68
- if (!config.customViews.schema) throw new Error(`No schema in custom view. Did you forgot to set \`views\` to a file that exports a \`schema\` on ${config.listKey}.${config.path}`);
69
- return {
70
- path: config.path,
71
- label: config.label,
72
- description: config.description,
73
- graphqlSelection: `${config.path} { json(hydrateRelationships: true) }`,
74
- schema: config.customViews.schema,
75
- defaultValue: {
76
- kind: 'create',
77
- value: utils.getInitialPropsValue(config.customViews.schema)
78
- },
79
- validate: value => utils.clientSideValidateProp(config.customViews.schema, value.value),
80
- deserialize: data => {
81
- var _data$json, _data;
82
- return {
83
- kind: 'update',
84
- value: (_data$json = (_data = data[`${config.path}`]) === null || _data === void 0 ? void 0 : _data.json) !== null && _data$json !== void 0 ? _data$json : null
85
- };
86
- },
87
- serialize: value => {
88
- return {
89
- [config.path]: serializeValue(config.customViews.schema, value.value, value.kind)
90
- };
91
- }
92
- };
93
- }
94
-
95
- function Field({
96
- field: field$1,
97
- value,
98
- onChange,
99
- autoFocus,
100
- forceValidation
101
- }) {
102
- const valueRef = React.useRef(value);
103
- React.useEffect(() => {
104
- valueRef.current = value;
105
- });
106
- const createPreviewProps = React.useMemo(() => {
107
- return utils.createGetPreviewProps(field$1.schema, getNewVal => {
108
- onChange === null || onChange === void 0 || onChange({
109
- kind: valueRef.current.kind,
110
- value: getNewVal(valueRef.current.value)
111
- });
112
- }, () => undefined);
113
- }, [field$1.schema, onChange]);
114
- return /*#__PURE__*/jsxRuntime.jsx(field.Field, {
115
- label: field$1.label,
116
- description: field$1.description,
117
- children: inputProps => /*#__PURE__*/jsxRuntime.jsx(formFromPreview.FormValueContentFromPreviewProps, {
118
- autoFocus: autoFocus,
119
- forceValidation: forceValidation,
120
- ...createPreviewProps(value.value)
121
- })
122
- });
123
- }
124
-
125
- const Cell = ({
126
- value
127
- }) => {
128
- return /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
129
- children: JSON.stringify(value.json)
130
- });
131
- };
132
-
133
- const allowedExportsOnCustomViews = ['schema'];
134
-
135
- exports.Cell = Cell;
136
- exports.Field = Field;
137
- exports.allowedExportsOnCustomViews = allowedExportsOnCustomViews;
138
- exports.controller = controller;
1
+ "use strict";
2
+ // this file might look strange and you might be wondering what it's for
3
+ // it's lets you import your source files by importing this entrypoint
4
+ // as you would import it if it was built with preconstruct build
5
+ // this file is slightly different to some others though
6
+ // it has a require hook which compiles your code with Babel
7
+ // this means that you don't have to set up @babel/register or anything like that
8
+ // but you can still require this module and it'll be compiled
9
+
10
+ // this bit of code imports the require hook and registers it
11
+ let unregister = require("../../../../node_modules/.pnpm/@preconstruct+hook@0.4.0/node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../..", "../..");
12
+
13
+ // this re-exports the source file
14
+ module.exports = require("../../src/structure-views.tsx");
15
+
16
+ unregister();
@@ -1,138 +1,16 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var utils = require('../../dist/utils-06bcddc4.node.cjs.js');
6
- var React = require('react');
7
- var field = require('@keystar/ui/field');
8
- var formFromPreview = require('../../dist/form-from-preview-9e501058.node.cjs.js');
9
- var jsxRuntime = require('react/jsx-runtime');
10
- var typography = require('@keystar/ui/typography');
11
- require('slate');
12
- require('lkb-core/admin-ui/context');
13
- require('lkb-core/fields/types/relationship/views');
14
- require('lkb-core/admin-ui/utils');
15
- require('@keystar/ui/button');
16
- require('@keystar/ui/dialog');
17
- require('@keystar/ui/icon');
18
- require('@keystar/ui/list-view');
19
- require('@keystar/ui/drag-and-drop');
20
- require('@keystar/ui/tooltip');
21
- require('@keystar/ui/layout');
22
- require('@keystar/ui/icon/icons/trash2Icon');
23
- require('@keystar/ui/slots');
24
-
25
- function serializeValue(schema, value, kind) {
26
- if (schema.kind === 'conditional') {
27
- return {
28
- [value.discriminant]: serializeValue(schema.values[value.discriminant], value.value, kind)
29
- };
30
- }
31
- if (schema.kind === 'array') {
32
- if (value === null) return [];
33
- return value.map(x => serializeValue(schema.element, x, kind));
34
- }
35
- if (schema.kind === 'form') return value;
36
- if (schema.kind === 'object') {
37
- return Object.fromEntries(Object.entries(schema.fields).map(([key, val]) => {
38
- return [key, serializeValue(val, value[key], kind)];
39
- }));
40
- }
41
- if (schema.kind === 'relationship') {
42
- if (Array.isArray(value)) {
43
- return {
44
- [kind === 'create' ? 'connect' : 'set']: value.map(x => ({
45
- id: x.id
46
- }))
47
- };
48
- }
49
- if (value === null) {
50
- if (kind === 'create') return;
51
- return {
52
- disconnect: true
53
- };
54
- }
55
- return {
56
- connect: {
57
- id: value.id
58
- }
59
- };
60
- }
61
- if (schema.kind === 'child') {
62
- throw new Error('Child fields are not supported in the structure field');
63
- }
64
- utils.assertNever(schema);
65
- }
66
-
67
- function controller(config) {
68
- if (!config.customViews.schema) throw new Error(`No schema in custom view. Did you forgot to set \`views\` to a file that exports a \`schema\` on ${config.listKey}.${config.path}`);
69
- return {
70
- path: config.path,
71
- label: config.label,
72
- description: config.description,
73
- graphqlSelection: `${config.path} { json(hydrateRelationships: true) }`,
74
- schema: config.customViews.schema,
75
- defaultValue: {
76
- kind: 'create',
77
- value: utils.getInitialPropsValue(config.customViews.schema)
78
- },
79
- validate: value => utils.clientSideValidateProp(config.customViews.schema, value.value),
80
- deserialize: data => {
81
- var _data$json, _data;
82
- return {
83
- kind: 'update',
84
- value: (_data$json = (_data = data[`${config.path}`]) === null || _data === void 0 ? void 0 : _data.json) !== null && _data$json !== void 0 ? _data$json : null
85
- };
86
- },
87
- serialize: value => {
88
- return {
89
- [config.path]: serializeValue(config.customViews.schema, value.value, value.kind)
90
- };
91
- }
92
- };
93
- }
94
-
95
- function Field({
96
- field: field$1,
97
- value,
98
- onChange,
99
- autoFocus,
100
- forceValidation
101
- }) {
102
- const valueRef = React.useRef(value);
103
- React.useEffect(() => {
104
- valueRef.current = value;
105
- });
106
- const createPreviewProps = React.useMemo(() => {
107
- return utils.createGetPreviewProps(field$1.schema, getNewVal => {
108
- onChange === null || onChange === void 0 || onChange({
109
- kind: valueRef.current.kind,
110
- value: getNewVal(valueRef.current.value)
111
- });
112
- }, () => undefined);
113
- }, [field$1.schema, onChange]);
114
- return /*#__PURE__*/jsxRuntime.jsx(field.Field, {
115
- label: field$1.label,
116
- description: field$1.description,
117
- children: inputProps => /*#__PURE__*/jsxRuntime.jsx(formFromPreview.FormValueContentFromPreviewProps, {
118
- autoFocus: autoFocus,
119
- forceValidation: forceValidation,
120
- ...createPreviewProps(value.value)
121
- })
122
- });
123
- }
124
-
125
- const Cell = ({
126
- value
127
- }) => {
128
- return /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
129
- children: JSON.stringify(value.json)
130
- });
131
- };
132
-
133
- const allowedExportsOnCustomViews = ['schema'];
134
-
135
- exports.Cell = Cell;
136
- exports.Field = Field;
137
- exports.allowedExportsOnCustomViews = allowedExportsOnCustomViews;
138
- exports.controller = controller;
1
+ "use strict";
2
+ // this file might look strange and you might be wondering what it's for
3
+ // it's lets you import your source files by importing this entrypoint
4
+ // as you would import it if it was built with preconstruct build
5
+ // this file is slightly different to some others though
6
+ // it has a require hook which compiles your code with Babel
7
+ // this means that you don't have to set up @babel/register or anything like that
8
+ // but you can still require this module and it'll be compiled
9
+
10
+ // this bit of code imports the require hook and registers it
11
+ let unregister = require("../../../../node_modules/.pnpm/@preconstruct+hook@0.4.0/node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../..", "../..");
12
+
13
+ // this re-exports the source file
14
+ module.exports = require("../../src/structure-views.tsx");
15
+
16
+ unregister();
@@ -1,2 +1,2 @@
1
- export * from "../../dist/declarations/src/views.js";
2
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGtiLWZpZWxkcy1kb2N1bWVudC12aWV3cy5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL2Rpc3QvZGVjbGFyYXRpb25zL3NyYy92aWV3cy5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
1
+ export * from "../../src/views.js";
2
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGtiLWZpZWxkcy1kb2N1bWVudC12aWV3cy5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92aWV3cy50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
@@ -1,114 +1,16 @@
1
- 'use client';
2
- 'use strict';
1
+ "use strict";
2
+ // this file might look strange and you might be wondering what it's for
3
+ // it's lets you import your source files by importing this entrypoint
4
+ // as you would import it if it was built with preconstruct build
5
+ // this file is slightly different to some others though
6
+ // it has a require hook which compiles your code with Babel
7
+ // this means that you don't have to set up @babel/register or anything like that
8
+ // but you can still require this module and it'll be compiled
3
9
 
4
- Object.defineProperty(exports, '__esModule', { value: true });
10
+ // this bit of code imports the require hook and registers it
11
+ let unregister = require("../../../../node_modules/.pnpm/@preconstruct+hook@0.4.0/node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../..", "../..");
5
12
 
6
- var slate = require('slate');
7
- var weakMemoize = require('@emotion/weak-memoize');
8
- var index = require('../../dist/index-06c36775.cjs.js');
9
- var editorShared = require('../../dist/editor-shared-cc1293ed.cjs.js');
10
- var utils = require('../../dist/utils-6409f730.cjs.js');
11
- var Field = require('../../dist/Field-28177061.cjs.js');
12
- var Cell = require('../../dist/Cell-bfb56d74.cjs.js');
13
- require('@braintree/sanitize-url');
14
- require('slate-history');
15
- require('../../dist/shared-0533009e.cjs.js');
16
- require('mdast-util-from-markdown');
17
- require('mdast-util-gfm-autolink-literal/from-markdown');
18
- require('micromark-extension-gfm-autolink-literal');
19
- require('mdast-util-gfm-strikethrough/from-markdown');
20
- require('micromark-extension-gfm-strikethrough');
13
+ // this re-exports the source file
14
+ module.exports = require("../../src/views.tsx");
21
15
 
22
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
23
-
24
- var weakMemoize__default = /*#__PURE__*/_interopDefault(weakMemoize);
25
- var Field__default = /*#__PURE__*/_interopDefault(Field);
26
- var Cell__default = /*#__PURE__*/_interopDefault(Cell);
27
-
28
- function controller(config) {
29
- const memoizedIsComponentBlockValid = weakMemoize__default["default"](componentBlock => weakMemoize__default["default"](props => utils.clientSideValidateProp({
30
- kind: 'object',
31
- fields: componentBlock.schema
32
- }, props)));
33
- const componentBlocks = config.customViews.componentBlocks || {};
34
- const serverSideComponentBlocksSet = new Set(config.fieldMeta.componentBlocksPassedOnServer);
35
- const componentBlocksOnlyBeingPassedOnTheClient = Object.keys(componentBlocks).filter(x => !serverSideComponentBlocksSet.has(x));
36
- if (componentBlocksOnlyBeingPassedOnTheClient.length) {
37
- throw new Error(`(${config.listKey}:${config.path}) The following component blocks are being passed in the custom view but not in the server-side field config: ${JSON.stringify(componentBlocksOnlyBeingPassedOnTheClient)}`);
38
- }
39
- const clientSideComponentBlocksSet = new Set(Object.keys(componentBlocks));
40
- const componentBlocksOnlyBeingPassedOnTheServer = config.fieldMeta.componentBlocksPassedOnServer.filter(x => !clientSideComponentBlocksSet.has(x));
41
- if (componentBlocksOnlyBeingPassedOnTheServer.length) {
42
- throw new Error(`(${config.listKey}:${config.path}) The following component blocks are being passed in the server-side field config but not in the custom view: ${JSON.stringify(componentBlocksOnlyBeingPassedOnTheServer)}`);
43
- }
44
- const validateNode = weakMemoize__default["default"](node => {
45
- if (slate.Text.isText(node)) {
46
- return true;
47
- }
48
- if (node.type === 'component-block') {
49
- const componentBlock = componentBlocks[node.component];
50
- if (componentBlock) {
51
- if (!memoizedIsComponentBlockValid(componentBlock)(node.props)) {
52
- return false;
53
- }
54
- }
55
- }
56
- if (node.type === 'link' && (typeof node.href !== 'string' || !index.isValidURL(node.href))) {
57
- return false;
58
- }
59
- return node.children.every(node => validateNode(node));
60
- });
61
- return {
62
- path: config.path,
63
- label: config.label,
64
- description: config.description,
65
- graphqlSelection: `${config.path} {document(hydrateRelationships: true)}`,
66
- componentBlocks: config.customViews.componentBlocks || {},
67
- documentFeatures: config.fieldMeta.documentFeatures,
68
- relationships: config.fieldMeta.relationships,
69
- defaultValue: [{
70
- type: 'paragraph',
71
- children: [{
72
- text: ''
73
- }]
74
- }],
75
- deserialize: data => {
76
- var _data$config$path;
77
- const documentFromServer = (_data$config$path = data[config.path]) === null || _data$config$path === void 0 ? void 0 : _data$config$path.document;
78
- if (!documentFromServer) {
79
- return [{
80
- type: 'paragraph',
81
- children: [{
82
- text: ''
83
- }]
84
- }];
85
- }
86
- // make a temporary editor to normalize the document
87
- const editor = editorShared.createDocumentEditor(config.fieldMeta.documentFeatures, componentBlocks, config.fieldMeta.relationships);
88
- editor.children = documentFromServer;
89
- slate.Editor.normalize(editor, {
90
- force: true
91
- });
92
- return editor.children;
93
- },
94
- serialize: value => ({
95
- [config.path]: value
96
- }),
97
- validate(value) {
98
- return value.every(node => validateNode(node));
99
- }
100
- };
101
- }
102
-
103
- const allowedExportsOnCustomViews = ['componentBlocks'];
104
-
105
- Object.defineProperty(exports, 'Field', {
106
- enumerable: true,
107
- get: function () { return Field__default["default"]; }
108
- });
109
- Object.defineProperty(exports, 'Cell', {
110
- enumerable: true,
111
- get: function () { return Cell__default["default"]; }
112
- });
113
- exports.allowedExportsOnCustomViews = allowedExportsOnCustomViews;
114
- exports.controller = controller;
16
+ unregister();
@@ -1,114 +1,16 @@
1
- 'use client';
2
- 'use strict';
1
+ "use strict";
2
+ // this file might look strange and you might be wondering what it's for
3
+ // it's lets you import your source files by importing this entrypoint
4
+ // as you would import it if it was built with preconstruct build
5
+ // this file is slightly different to some others though
6
+ // it has a require hook which compiles your code with Babel
7
+ // this means that you don't have to set up @babel/register or anything like that
8
+ // but you can still require this module and it'll be compiled
3
9
 
4
- Object.defineProperty(exports, '__esModule', { value: true });
10
+ // this bit of code imports the require hook and registers it
11
+ let unregister = require("../../../../node_modules/.pnpm/@preconstruct+hook@0.4.0/node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../..", "../..");
5
12
 
6
- var slate = require('slate');
7
- var weakMemoize = require('@emotion/weak-memoize');
8
- var index = require('../../dist/index-c3223fdc.node.cjs.js');
9
- var editorShared = require('../../dist/editor-shared-a997ae98.node.cjs.js');
10
- var utils = require('../../dist/utils-06bcddc4.node.cjs.js');
11
- var Field = require('../../dist/Field-0e0f75ed.node.cjs.js');
12
- var Cell = require('../../dist/Cell-0ac0ac66.node.cjs.js');
13
- require('@braintree/sanitize-url');
14
- require('slate-history');
15
- require('../../dist/shared-4684cc24.node.cjs.js');
16
- require('mdast-util-from-markdown');
17
- require('mdast-util-gfm-autolink-literal/from-markdown');
18
- require('micromark-extension-gfm-autolink-literal');
19
- require('mdast-util-gfm-strikethrough/from-markdown');
20
- require('micromark-extension-gfm-strikethrough');
13
+ // this re-exports the source file
14
+ module.exports = require("../../src/views.tsx");
21
15
 
22
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
23
-
24
- var weakMemoize__default = /*#__PURE__*/_interopDefault(weakMemoize);
25
- var Field__default = /*#__PURE__*/_interopDefault(Field);
26
- var Cell__default = /*#__PURE__*/_interopDefault(Cell);
27
-
28
- function controller(config) {
29
- const memoizedIsComponentBlockValid = weakMemoize__default["default"](componentBlock => weakMemoize__default["default"](props => utils.clientSideValidateProp({
30
- kind: 'object',
31
- fields: componentBlock.schema
32
- }, props)));
33
- const componentBlocks = config.customViews.componentBlocks || {};
34
- const serverSideComponentBlocksSet = new Set(config.fieldMeta.componentBlocksPassedOnServer);
35
- const componentBlocksOnlyBeingPassedOnTheClient = Object.keys(componentBlocks).filter(x => !serverSideComponentBlocksSet.has(x));
36
- if (componentBlocksOnlyBeingPassedOnTheClient.length) {
37
- throw new Error(`(${config.listKey}:${config.path}) The following component blocks are being passed in the custom view but not in the server-side field config: ${JSON.stringify(componentBlocksOnlyBeingPassedOnTheClient)}`);
38
- }
39
- const clientSideComponentBlocksSet = new Set(Object.keys(componentBlocks));
40
- const componentBlocksOnlyBeingPassedOnTheServer = config.fieldMeta.componentBlocksPassedOnServer.filter(x => !clientSideComponentBlocksSet.has(x));
41
- if (componentBlocksOnlyBeingPassedOnTheServer.length) {
42
- throw new Error(`(${config.listKey}:${config.path}) The following component blocks are being passed in the server-side field config but not in the custom view: ${JSON.stringify(componentBlocksOnlyBeingPassedOnTheServer)}`);
43
- }
44
- const validateNode = weakMemoize__default["default"](node => {
45
- if (slate.Text.isText(node)) {
46
- return true;
47
- }
48
- if (node.type === 'component-block') {
49
- const componentBlock = componentBlocks[node.component];
50
- if (componentBlock) {
51
- if (!memoizedIsComponentBlockValid(componentBlock)(node.props)) {
52
- return false;
53
- }
54
- }
55
- }
56
- if (node.type === 'link' && (typeof node.href !== 'string' || !index.isValidURL(node.href))) {
57
- return false;
58
- }
59
- return node.children.every(node => validateNode(node));
60
- });
61
- return {
62
- path: config.path,
63
- label: config.label,
64
- description: config.description,
65
- graphqlSelection: `${config.path} {document(hydrateRelationships: true)}`,
66
- componentBlocks: config.customViews.componentBlocks || {},
67
- documentFeatures: config.fieldMeta.documentFeatures,
68
- relationships: config.fieldMeta.relationships,
69
- defaultValue: [{
70
- type: 'paragraph',
71
- children: [{
72
- text: ''
73
- }]
74
- }],
75
- deserialize: data => {
76
- var _data$config$path;
77
- const documentFromServer = (_data$config$path = data[config.path]) === null || _data$config$path === void 0 ? void 0 : _data$config$path.document;
78
- if (!documentFromServer) {
79
- return [{
80
- type: 'paragraph',
81
- children: [{
82
- text: ''
83
- }]
84
- }];
85
- }
86
- // make a temporary editor to normalize the document
87
- const editor = editorShared.createDocumentEditor(config.fieldMeta.documentFeatures, componentBlocks, config.fieldMeta.relationships);
88
- editor.children = documentFromServer;
89
- slate.Editor.normalize(editor, {
90
- force: true
91
- });
92
- return editor.children;
93
- },
94
- serialize: value => ({
95
- [config.path]: value
96
- }),
97
- validate(value) {
98
- return value.every(node => validateNode(node));
99
- }
100
- };
101
- }
102
-
103
- const allowedExportsOnCustomViews = ['componentBlocks'];
104
-
105
- Object.defineProperty(exports, 'Field', {
106
- enumerable: true,
107
- get: function () { return Field__default["default"]; }
108
- });
109
- Object.defineProperty(exports, 'Cell', {
110
- enumerable: true,
111
- get: function () { return Cell__default["default"]; }
112
- });
113
- exports.allowedExportsOnCustomViews = allowedExportsOnCustomViews;
114
- exports.controller = controller;
16
+ unregister();