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
@@ -1,506 +0,0 @@
1
- 'use strict';
2
-
3
- var lkbCore = require('lkb-core');
4
- var layout = require('@keystar/ui/layout');
5
- var button = require('@keystar/ui/button');
6
- var dragAndDrop = require('@keystar/ui/drag-and-drop');
7
- var React = require('react');
8
- var index = require('./index-c3223fdc.node.cjs.js');
9
- var i18n = require('@react-aria/i18n');
10
- var numberField = require('@keystar/ui/number-field');
11
- var style = require('@keystar/ui/style');
12
- var picker = require('@keystar/ui/picker');
13
- var combobox = require('@keystar/ui/combobox');
14
- var textField = require('@keystar/ui/text-field');
15
- var tag = require('@keystar/ui/tag');
16
- var typography = require('@keystar/ui/typography');
17
- var jsxRuntime = require('react/jsx-runtime');
18
- var checkbox = require('@keystar/ui/checkbox');
19
-
20
- function makeIntegerFieldInput(opts) {
21
- return function IntegerFieldInput({
22
- autoFocus,
23
- forceValidation,
24
- onChange,
25
- value
26
- }) {
27
- const [isDirty, setDirty] = React.useState(false);
28
- return /*#__PURE__*/jsxRuntime.jsx(numberField.NumberField, {
29
- autoFocus: autoFocus,
30
- label: opts.label,
31
- errorMessage: (forceValidation || isDirty) && !opts.validate(value) ? 'Invalid integer' : null,
32
- step: 1,
33
- onBlur: () => setDirty(true),
34
- onChange: x => onChange === null || onChange === void 0 ? void 0 : onChange(!Number.isInteger(x) ? NaN : x),
35
- value: value !== null && value !== void 0 ? value : NaN
36
- });
37
- };
38
- }
39
- function makeUrlFieldInput(opts) {
40
- return function UrlFieldInput({
41
- autoFocus,
42
- forceValidation,
43
- onChange,
44
- value
45
- }) {
46
- const [isDirty, setDirty] = React.useState(false);
47
- return /*#__PURE__*/jsxRuntime.jsx(textField.TextField, {
48
- autoFocus: autoFocus,
49
- label: opts.label,
50
- errorMessage: (forceValidation || isDirty) && !opts.validate(value) ? 'Invalid URL' : null,
51
- onBlur: () => setDirty(true),
52
- onChange: x => onChange === null || onChange === void 0 ? void 0 : onChange(x),
53
- value: value
54
- });
55
- };
56
- }
57
- function makeSelectFieldInput({
58
- label,
59
- options
60
- }) {
61
- const longestLabelLength = options.reduce((a, item) => Math.max(a, item.label.length), 0);
62
- return function PickerFieldInput({
63
- autoFocus,
64
- forceValidation,
65
- onChange,
66
- value
67
- }) {
68
- var _options$find$value, _options$find2;
69
- return /*#__PURE__*/jsxRuntime.jsx(picker.Picker, {
70
- autoFocus: autoFocus,
71
- label: label,
72
- items: options,
73
- onSelectionChange: key => {
74
- var _options$find;
75
- const newVal = (_options$find = options.find(option => option.value === key)) === null || _options$find === void 0 ? void 0 : _options$find.value;
76
- if (newVal !== undefined) {
77
- onChange === null || onChange === void 0 || onChange(newVal);
78
- }
79
- },
80
- selectedKey: (_options$find$value = (_options$find2 = options.find(option => option.value === value)) === null || _options$find2 === void 0 ? void 0 : _options$find2.value) !== null && _options$find$value !== void 0 ? _options$find$value : null,
81
- flex: {
82
- mobile: true,
83
- desktop: 'initial'
84
- },
85
- UNSAFE_style: {
86
- fontSize: style.tokenSchema.typography.text.regular.size,
87
- width: `clamp(${style.tokenSchema.size.alias.singleLineWidth}, calc(${longestLabelLength}ex + ${style.tokenSchema.size.icon.regular}), 100%)`
88
- },
89
- children: item => /*#__PURE__*/jsxRuntime.jsx(picker.Item, {
90
- children: item.label
91
- }, item.value)
92
- });
93
- };
94
- }
95
- function makeMultiselectFieldInput({
96
- label,
97
- options
98
- }) {
99
- return function ComboFieldInput({
100
- autoFocus,
101
- forceValidation,
102
- onChange,
103
- value
104
- }) {
105
- const [filterText, setFilterText] = React.useState('');
106
- const {
107
- contains
108
- } = i18n.useFilter({
109
- sensitivity: 'base'
110
- });
111
- const items = options.filter(option => !value.some(x => x === option.value));
112
- const filteredItems = filterText ? items.filter(item => contains(item.label, filterText)) : items;
113
- return /*#__PURE__*/jsxRuntime.jsxs(layout.VStack, {
114
- gap: "regular",
115
- children: [/*#__PURE__*/jsxRuntime.jsx(combobox.Combobox, {
116
- label: label,
117
- isReadOnly: onChange === undefined,
118
- items: filteredItems,
119
- loadingState: "idle",
120
- onInputChange: setFilterText,
121
- inputValue: filterText
122
- // selectedKey={null}
123
- ,
124
- onSelectionChange: key => {
125
- if (key == null) return;
126
- onChange === null || onChange === void 0 || onChange([...value, ...options.filter(x => x.value === key).map(x => x.value)]);
127
- },
128
- width: "auto",
129
- children: item => /*#__PURE__*/jsxRuntime.jsx(combobox.Item, {
130
- children: item.label
131
- }, item.value)
132
- }), /*#__PURE__*/jsxRuntime.jsx(tag.TagGroup, {
133
- items: value,
134
- maxRows: 2,
135
- onRemove: keys => {
136
- const key = keys.values().next().value;
137
- onChange === null || onChange === void 0 || onChange(value.filter(x => x !== key));
138
- },
139
- renderEmptyState: () => /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
140
- color: "neutralSecondary",
141
- size: "small",
142
- children: "No items\u2026"
143
- }),
144
- children: item => /*#__PURE__*/jsxRuntime.jsx(combobox.Item, {
145
- children: item
146
- }, item)
147
- })]
148
- });
149
- };
150
- }
151
-
152
- const fields = {
153
- file({
154
- label,
155
- isImage,
156
- defaultValue = '',
157
- allowedFileTypes,
158
- onUpload
159
- }) {
160
- return {
161
- kind: 'form',
162
- Input({
163
- value,
164
- onChange
165
- }) {
166
- const [err, setErr] = React.useState(null);
167
- return /*#__PURE__*/jsxRuntime.jsxs(layout.Flex, {
168
- direction: "column",
169
- gap: "medium",
170
- children: [/*#__PURE__*/jsxRuntime.jsxs(layout.Flex, {
171
- gap: "medium",
172
- alignItems: "flex-end",
173
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
174
- style: {
175
- flex: 1
176
- },
177
- children: /*#__PURE__*/jsxRuntime.jsx(textField.TextField, {
178
- label: label,
179
- isDisabled: true,
180
- value: value
181
- })
182
- }), /*#__PURE__*/jsxRuntime.jsx(dragAndDrop.FileTrigger, {
183
- acceptedFileTypes: allowedFileTypes,
184
- allowsMultiple: false,
185
- onSelect: filelist => {
186
- let files = Array.from(filelist || []);
187
- if (files.length > 0) {
188
- onUpload === null || onUpload === void 0 || onUpload(files[0]).then(url => {
189
- onChange(url);
190
- }).catch(e => setErr(e.message));
191
- }
192
- },
193
- children: /*#__PURE__*/jsxRuntime.jsx(button.ActionButton, {
194
- children: "\u9009\u62E9\u56FE\u7247"
195
- })
196
- })]
197
- }), isImage && value && /*#__PURE__*/jsxRuntime.jsx("img", {
198
- src: value,
199
- style: {
200
- width: '100%'
201
- }
202
- }), err && /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
203
- color: "highlight",
204
- children: err
205
- })]
206
- });
207
- },
208
- options: undefined,
209
- defaultValue,
210
- validate(value) {
211
- return typeof value === 'string';
212
- },
213
- graphql: {
214
- input: lkbCore.g.String,
215
- output: lkbCore.g.field({
216
- type: lkbCore.g.String
217
- })
218
- }
219
- };
220
- },
221
- text({
222
- label,
223
- defaultValue = '',
224
- displayMode
225
- }) {
226
- return {
227
- kind: 'form',
228
- Input({
229
- value,
230
- onChange,
231
- autoFocus
232
- }) {
233
- if (displayMode === 'textarea') {
234
- return /*#__PURE__*/jsxRuntime.jsx(textField.TextArea, {
235
- autoFocus: autoFocus,
236
- label: label,
237
- onChange: x => onChange === null || onChange === void 0 ? void 0 : onChange(x),
238
- value: value
239
- });
240
- }
241
- return /*#__PURE__*/jsxRuntime.jsx(textField.TextField, {
242
- autoFocus: autoFocus,
243
- label: label,
244
- onChange: x => onChange === null || onChange === void 0 ? void 0 : onChange(x),
245
- value: value
246
- });
247
- },
248
- options: undefined,
249
- defaultValue,
250
- validate(value) {
251
- return typeof value === 'string';
252
- },
253
- graphql: {
254
- input: lkbCore.g.String,
255
- output: lkbCore.g.field({
256
- type: lkbCore.g.String
257
- })
258
- }
259
- };
260
- },
261
- integer({
262
- label,
263
- defaultValue = 0
264
- }) {
265
- const validate = value => {
266
- return typeof value === 'number' && Number.isFinite(value);
267
- };
268
- return {
269
- kind: 'form',
270
- Input: makeIntegerFieldInput({
271
- label,
272
- validate
273
- }),
274
- options: undefined,
275
- defaultValue,
276
- validate,
277
- graphql: {
278
- input: lkbCore.g.Int,
279
- output: lkbCore.g.field({
280
- type: lkbCore.g.Int
281
- })
282
- }
283
- };
284
- },
285
- url({
286
- label,
287
- defaultValue = ''
288
- }) {
289
- const validate = value => {
290
- return typeof value === 'string' && (value === '' || index.isValidURL(value));
291
- };
292
- return {
293
- kind: 'form',
294
- Input: makeUrlFieldInput({
295
- label,
296
- validate
297
- }),
298
- options: undefined,
299
- defaultValue,
300
- validate,
301
- graphql: {
302
- input: lkbCore.g.String,
303
- output: lkbCore.g.field({
304
- type: lkbCore.g.String
305
- })
306
- }
307
- };
308
- },
309
- select({
310
- label,
311
- options,
312
- defaultValue
313
- }) {
314
- const optionValuesSet = new Set(options.map(x => x.value));
315
- if (!optionValuesSet.has(defaultValue)) throw new Error(`A defaultValue of ${defaultValue} was provided to a select field but it does not match the value of one of the options provided`);
316
- return {
317
- kind: 'form',
318
- Input: makeSelectFieldInput({
319
- label,
320
- options
321
- }),
322
- options,
323
- defaultValue,
324
- validate(value) {
325
- return typeof value === 'string' && optionValuesSet.has(value);
326
- },
327
- graphql: {
328
- input: lkbCore.g.String,
329
- output: lkbCore.g.field({
330
- type: lkbCore.g.String,
331
- // TODO: FIXME why is this required
332
- resolve({
333
- value
334
- }) {
335
- return value;
336
- }
337
- })
338
- }
339
- };
340
- },
341
- multiselect({
342
- label,
343
- options,
344
- defaultValue
345
- }) {
346
- const valuesToOption = new Map(options.map(x => [x.value, x]));
347
- return {
348
- kind: 'form',
349
- Input: makeMultiselectFieldInput({
350
- label,
351
- options
352
- }),
353
- options,
354
- defaultValue,
355
- validate(value) {
356
- return Array.isArray(value) && value.every(value => typeof value === 'string' && valuesToOption.has(value));
357
- },
358
- graphql: {
359
- input: lkbCore.g.list(lkbCore.g.nonNull(lkbCore.g.String)),
360
- output: lkbCore.g.field({
361
- type: lkbCore.g.list(lkbCore.g.nonNull(lkbCore.g.String)),
362
- // TODO: why is this required
363
- resolve({
364
- value
365
- }) {
366
- return value;
367
- }
368
- })
369
- }
370
- };
371
- },
372
- checkbox({
373
- label,
374
- defaultValue = false
375
- }) {
376
- return {
377
- kind: 'form',
378
- Input({
379
- value,
380
- onChange,
381
- autoFocus
382
- }) {
383
- return /*#__PURE__*/jsxRuntime.jsx(checkbox.Checkbox, {
384
- autoFocus: autoFocus,
385
- isReadOnly: onChange == null,
386
- isSelected: value,
387
- onChange: onChange,
388
- children: /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
389
- children: label
390
- })
391
- });
392
- },
393
- options: undefined,
394
- defaultValue,
395
- validate(value) {
396
- return typeof value === 'boolean';
397
- },
398
- graphql: {
399
- input: lkbCore.g.Boolean,
400
- output: lkbCore.g.field({
401
- type: lkbCore.g.Boolean
402
- })
403
- }
404
- };
405
- },
406
- empty() {
407
- return {
408
- kind: 'form',
409
- Input() {
410
- return null;
411
- },
412
- options: undefined,
413
- defaultValue: null,
414
- validate(value) {
415
- return value === null || value === undefined;
416
- }
417
- };
418
- },
419
- child(options) {
420
- return {
421
- kind: 'child',
422
- options: options.kind === 'block' ? {
423
- kind: 'block',
424
- placeholder: options.placeholder,
425
- dividers: options.dividers,
426
- formatting: options.formatting === 'inherit' ? {
427
- blockTypes: 'inherit',
428
- headingLevels: 'inherit',
429
- inlineMarks: 'inherit',
430
- listTypes: 'inherit',
431
- alignment: 'inherit',
432
- softBreaks: 'inherit'
433
- } : options.formatting,
434
- links: options.links,
435
- relationships: options.relationships,
436
- componentBlocks: options.componentBlocks
437
- } : {
438
- kind: 'inline',
439
- placeholder: options.placeholder,
440
- formatting: options.formatting === 'inherit' ? {
441
- inlineMarks: 'inherit',
442
- softBreaks: 'inherit'
443
- } : options.formatting,
444
- links: options.links,
445
- relationships: options.relationships
446
- }
447
- };
448
- },
449
- object(fields) {
450
- return {
451
- kind: 'object',
452
- fields
453
- };
454
- },
455
- conditional(discriminant, values) {
456
- return {
457
- kind: 'conditional',
458
- discriminant,
459
- values
460
- };
461
- },
462
- relationship({
463
- listKey,
464
- label,
465
- labelField,
466
- selection,
467
- many
468
- }) {
469
- return {
470
- kind: 'relationship',
471
- listKey,
472
- label,
473
- labelField: labelField !== null && labelField !== void 0 ? labelField : null,
474
- selection: selection !== null && selection !== void 0 ? selection : null,
475
- many: many ? true : false
476
- };
477
- },
478
- array(element, opts) {
479
- return {
480
- kind: 'array',
481
- element,
482
- itemLabel: opts === null || opts === void 0 ? void 0 : opts.itemLabel,
483
- label: opts === null || opts === void 0 ? void 0 : opts.label
484
- };
485
- }
486
- };
487
- function component(options) {
488
- return options;
489
- }
490
- function NotEditable({
491
- children,
492
- ...props
493
- }) {
494
- return /*#__PURE__*/jsxRuntime.jsx("span", {
495
- style: {
496
- userSelect: 'none'
497
- },
498
- contentEditable: false,
499
- ...props,
500
- children: children
501
- });
502
- }
503
-
504
- exports.NotEditable = NotEditable;
505
- exports.component = component;
506
- exports.fields = fields;