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,508 +0,0 @@
1
- import { useList } from 'lkb-core/admin-ui/context';
2
- import { Field as Field$1 } from 'lkb-core/fields/types/relationship/views';
3
- import { GroupIndicatorLine } from 'lkb-core/admin-ui/utils';
4
- import { ActionButton, ButtonGroup, Button } from '@keystar/ui/button';
5
- import { DialogContainer, Dialog } from '@keystar/ui/dialog';
6
- import { Field } from '@keystar/ui/field';
7
- import { Heading, Text } from '@keystar/ui/typography';
8
- import { Icon } from '@keystar/ui/icon';
9
- import { ListView, Item } from '@keystar/ui/list-view';
10
- import { useDragAndDrop, move } from '@keystar/ui/drag-and-drop';
11
- import { TooltipTrigger, Tooltip } from '@keystar/ui/tooltip';
12
- import { VStack, HStack } from '@keystar/ui/layout';
13
- import { trash2Icon } from '@keystar/ui/icon/icons/trash2Icon';
14
- import { memo, useState, useMemo, useRef, useCallback, useEffect } from 'react';
15
- import { p as clientSideValidateProp, q as createGetPreviewProps, a as assertNever, s as setKeysForArrayValue, f as getKeysForArrayValue } from './utils-bc6a0b82.esm.js';
16
- import { Content } from '@keystar/ui/slots';
17
- import { jsx, jsxs } from 'react/jsx-runtime';
18
-
19
- const previewPropsToValueConverter = {
20
- child() {
21
- return null;
22
- },
23
- form(props) {
24
- return props.value;
25
- },
26
- array(props) {
27
- const values = props.elements.map(x => previewPropsToValue(x));
28
- setKeysForArrayValue(values, props.elements.map(x => x.key));
29
- return values;
30
- },
31
- conditional(props) {
32
- return {
33
- discriminant: props.discriminant,
34
- value: previewPropsToValue(props.value)
35
- };
36
- },
37
- object(props) {
38
- return Object.fromEntries(Object.entries(props.fields).map(([key, val]) => [key, previewPropsToValue(val)]));
39
- },
40
- relationship(props) {
41
- return props.value;
42
- }
43
- };
44
- const valueToUpdaters = {
45
- child() {
46
- return undefined;
47
- },
48
- form(value) {
49
- return value;
50
- },
51
- array(value, schema) {
52
- const keys = getKeysForArrayValue(value);
53
- return value.map((x, i) => ({
54
- key: keys[i],
55
- value: valueToUpdater(x, schema.element)
56
- }));
57
- },
58
- conditional(value, schema) {
59
- return {
60
- discriminant: value.discriminant,
61
- value: valueToUpdater(value.value, schema.values[value.discriminant.toString()])
62
- };
63
- },
64
- object(value, schema) {
65
- return Object.fromEntries(Object.entries(schema.fields).map(([key, schema]) => [key, valueToUpdater(value[key], schema)]));
66
- },
67
- relationship(value) {
68
- return value;
69
- }
70
- };
71
- function previewPropsToValue(props) {
72
- return previewPropsToValueConverter[props.schema.kind](props);
73
- }
74
- function valueToUpdater(value, schema) {
75
- return valueToUpdaters[schema.kind](value, schema);
76
- }
77
-
78
- // this exists because for props.schema.kind === 'form', ts doesn't narrow props, only props.schema
79
- function isKind(props, kind) {
80
- return props.schema.kind === kind;
81
- }
82
- function previewPropsOnChange(value, props) {
83
- // child fields can't be updated through preview props, so we don't do anything here
84
- if (isKind(props, 'child')) return;
85
- if (isKind(props, 'form') || isKind(props, 'relationship') || isKind(props, 'object') || isKind(props, 'array')) {
86
- props.onChange(valueToUpdater(value, props.schema));
87
- return;
88
- }
89
- if (isKind(props, 'conditional')) {
90
- const updater = valueToUpdater(value, props.schema);
91
- props.onChange(updater.discriminant, updater.value);
92
- return;
93
- }
94
- assertNever(props);
95
- }
96
- function ArrayFieldPreview(props) {
97
- const {
98
- elements,
99
- onChange,
100
- schema
101
- } = props;
102
- const {
103
- label
104
- } = schema;
105
- const [modalState, setModalState] = useState('closed');
106
- return /*#__PURE__*/jsx(Field, {
107
- label: label,
108
- labelElementType: "span",
109
- children: groupProps => /*#__PURE__*/jsxs(VStack, {
110
- gap: "medium",
111
- role: "group",
112
- minWidth: 0,
113
- ...groupProps,
114
- children: [/*#__PURE__*/jsx(ArrayFieldListView, {
115
- ...props,
116
- "aria-label": label !== null && label !== void 0 ? label : '',
117
- onOpenItem: index => {
118
- const element = elements.at(index);
119
- if (!element) return;
120
- setModalState({
121
- index,
122
- value: previewPropsToValue(element),
123
- forceValidation: false
124
- });
125
- }
126
- }), /*#__PURE__*/jsx(ActionButton, {
127
- alignSelf: "start",
128
- autoFocus: props.autoFocus,
129
- onPress: () => {
130
- onChange([...elements.map(x => ({
131
- key: x.key
132
- })), {
133
- key: undefined
134
- }]);
135
- },
136
- children: "\u6DFB\u52A0\u9009\u9879"
137
- }), /*#__PURE__*/jsx(DialogContainer, {
138
- onDismiss: () => {
139
- setModalState('closed');
140
- },
141
- children: (() => {
142
- if (props.schema.element.kind === 'child') return;
143
- if (modalState === 'closed') return;
144
- const element = elements.at(modalState.index);
145
- if (!element) return;
146
- const onModalChange = cb => {
147
- setModalState(state => {
148
- if (state === 'closed') return state;
149
- return {
150
- index: modalState.index,
151
- forceValidation: state.forceValidation,
152
- value: cb(state.value)
153
- };
154
- });
155
- };
156
- return /*#__PURE__*/jsxs(Dialog, {
157
- children: [/*#__PURE__*/jsx(Heading, {
158
- children: "\u7F16\u8F91\u9009\u9879"
159
- }), /*#__PURE__*/jsx(Content, {
160
- children: /*#__PURE__*/jsx(ArrayFieldItemModalContent, {
161
- onChange: onModalChange,
162
- schema: element.schema /* TODO FIXME */,
163
- value: modalState.value
164
- })
165
- }), /*#__PURE__*/jsxs(ButtonGroup, {
166
- children: [/*#__PURE__*/jsx(Button, {
167
- prominence: "low",
168
- onPress: () => {
169
- setModalState('closed');
170
- },
171
- children: "\u53D6\u6D88"
172
- }), /*#__PURE__*/jsx(Button, {
173
- prominence: "high",
174
- onPress: () => {
175
- if (!clientSideValidateProp(element.schema, modalState.value)) {
176
- setModalState(state => ({
177
- ...state /* TODO FIXME */,
178
- forceValidation: true
179
- }));
180
- return;
181
- }
182
- previewPropsOnChange(modalState.value, element);
183
- setModalState('closed');
184
- },
185
- children: "\u786E\u5B9A"
186
- })]
187
- })]
188
- });
189
- })()
190
- })]
191
- })
192
- });
193
- }
194
- function RelationshipFieldPreview(props) {
195
- const {
196
- autoFocus,
197
- onChange,
198
- schema,
199
- value
200
- } = props;
201
- const {
202
- label,
203
- listKey,
204
- many
205
- } = schema;
206
- const list = useList(listKey);
207
- const formValue = function () {
208
- if (many) {
209
- if (value !== null && !('length' in value)) throw TypeError('bad value');
210
- const manyValue = value === null ? [] : value.map(x => ({
211
- id: x.id,
212
- label: x.label || x.id.toString(),
213
- data: x.data,
214
- built: undefined
215
- }));
216
- return {
217
- kind: 'many',
218
- id: '',
219
- // unused
220
- initialValue: manyValue,
221
- value: manyValue
222
- };
223
- }
224
- if (value !== null && 'length' in value) throw TypeError('bad value');
225
- const oneValue = value ? {
226
- id: value.id,
227
- label: value.label || value.id.toString(),
228
- data: value.data,
229
- built: undefined
230
- } : null;
231
- return {
232
- kind: 'one',
233
- id: '',
234
- // unused
235
- initialValue: oneValue,
236
- value: oneValue
237
- };
238
- }();
239
- return /*#__PURE__*/jsx(Field$1, {
240
- autoFocus: autoFocus,
241
- isRequired: false,
242
- field: {
243
- path: '',
244
- // unused
245
- label,
246
- description: '',
247
- // TODO
248
- display: 'select',
249
- listKey: '',
250
- // unused
251
- refListKey: list.key,
252
- refLabelField: list.labelField,
253
- refSearchFields: list.initialSearchFields,
254
- hideCreate: true,
255
- many
256
- },
257
- onChange: val => {
258
- if (val.kind === 'count') return; // shouldnt happen
259
- const {
260
- value
261
- } = val;
262
- if (value === null) {
263
- onChange(null);
264
- return;
265
- }
266
- if (Array.isArray(value)) {
267
- onChange(value.map(x => ({
268
- id: x.id,
269
- label: x.label
270
- })));
271
- return;
272
- }
273
- onChange({
274
- id: value.id,
275
- label: value.label
276
- });
277
- },
278
- value: formValue,
279
- itemValue: {}
280
- });
281
- }
282
- function FormFieldPreview({
283
- schema,
284
- autoFocus,
285
- forceValidation,
286
- onChange,
287
- value
288
- }) {
289
- return /*#__PURE__*/jsx(schema.Input, {
290
- autoFocus: !!autoFocus,
291
- value: value,
292
- onChange: onChange,
293
- forceValidation: !!forceValidation
294
- });
295
- }
296
- function canFieldBeFocused(schema) {
297
- if (schema.kind === 'child') return false;
298
- if (schema.kind === 'array') return true;
299
- if (schema.kind === 'conditional') return true;
300
- if (schema.kind === 'form') return true;
301
- if (schema.kind === 'relationship') return true;
302
- if (schema.kind === 'object') {
303
- for (const innerProp of Object.values(schema.fields)) {
304
- if (canFieldBeFocused(innerProp)) return true;
305
- }
306
- return false;
307
- }
308
- assertNever(schema);
309
- }
310
- function findFocusableObjectFieldKey(schema) {
311
- for (const [key, innerProp] of Object.entries(schema.fields)) {
312
- const childFocusable = canFieldBeFocused(innerProp);
313
- if (childFocusable) return key;
314
- }
315
- }
316
- function ObjectFieldPreview({
317
- schema,
318
- autoFocus,
319
- fields
320
- }) {
321
- const firstFocusable = autoFocus ? findFocusableObjectFieldKey(schema) : undefined;
322
- return /*#__PURE__*/jsxs(HStack, {
323
- gap: "medium",
324
- paddingTop: "medium",
325
- children: [/*#__PURE__*/jsx(GroupIndicatorLine, {}), /*#__PURE__*/jsx(VStack, {
326
- gap: "xlarge",
327
- flex: true,
328
- minWidth: 0,
329
- children: [...function* () {
330
- for (const [key, propVal] of Object.entries(fields)) {
331
- if (!isNonChildFieldPreviewProps(propVal)) continue;
332
- yield /*#__PURE__*/jsx(FormValueContentFromPreviewProps, {
333
- autoFocus: key === firstFocusable,
334
- ...propVal
335
- }, key);
336
- }
337
- }()]
338
- })]
339
- });
340
- }
341
- function ConditionalFieldPreview({
342
- schema,
343
- autoFocus,
344
- discriminant,
345
- onChange,
346
- value
347
- }) {
348
- const schemaDiscriminant = schema.discriminant;
349
- return /*#__PURE__*/jsxs(HStack, {
350
- gap: "xlarge",
351
- children: [useMemo(() => /*#__PURE__*/jsx(schemaDiscriminant.Input, {
352
- autoFocus: !!autoFocus,
353
- value: discriminant,
354
- onChange: onChange,
355
- forceValidation: false
356
- }), [autoFocus, schemaDiscriminant, discriminant, onChange]), isNonChildFieldPreviewProps(value) && /*#__PURE__*/jsx(FormValueContentFromPreviewProps, {
357
- ...value
358
- })]
359
- });
360
- }
361
- function isNonChildFieldPreviewProps(props) {
362
- return props.schema.kind !== 'child';
363
- }
364
- const fieldRenderers = {
365
- array: ArrayFieldPreview,
366
- relationship: RelationshipFieldPreview,
367
- child: () => null,
368
- form: FormFieldPreview,
369
- object: ObjectFieldPreview,
370
- conditional: ConditionalFieldPreview
371
- };
372
- const FormValueContentFromPreviewProps = /*#__PURE__*/memo(function FormValueContentFromPreview(props) {
373
- const Comp = fieldRenderers[props.schema.kind];
374
- return /*#__PURE__*/jsx(Comp, {
375
- ...props
376
- });
377
- });
378
- function useEventCallback(callback) {
379
- const callbackRef = useRef(callback);
380
- const cb = useCallback((...args) => {
381
- return callbackRef.current(...args);
382
- }, []);
383
- useEffect(() => {
384
- callbackRef.current = callback;
385
- });
386
- return cb;
387
- }
388
- function ArrayFieldListView(props) {
389
- const onMove = (keys, target) => {
390
- const targetIndex = props.elements.findIndex(x => x.key === target.key);
391
- if (targetIndex === -1) return;
392
- const allKeys = props.elements.map(x => ({
393
- key: x.key
394
- }));
395
- const indexToMoveTo = target.dropPosition === 'before' ? targetIndex : targetIndex + 1;
396
- const indices = keys.map(key => allKeys.findIndex(x => x.key === key));
397
- props.onChange(move(allKeys, indices, indexToMoveTo));
398
- };
399
- const dragType = useMemo(() => Math.random().toString(36), []);
400
- const {
401
- dragAndDropHooks
402
- } = useDragAndDrop({
403
- getItems(keys) {
404
- // Use a drag type so the items can only be reordered within this list
405
- // and not dragged elsewhere.
406
- return [...keys].map(key => {
407
- key = JSON.stringify(key);
408
- return {
409
- [dragType]: key,
410
- 'text/plain': key
411
- };
412
- });
413
- },
414
- getAllowedDropOperations() {
415
- return ['move', 'cancel'];
416
- },
417
- async onDrop(e) {
418
- if (e.target.type !== 'root' && e.target.dropPosition !== 'on') {
419
- let keys = [];
420
- for (let item of e.items) {
421
- if (item.kind === 'text') {
422
- let key;
423
- if (item.types.has(dragType)) {
424
- key = JSON.parse(await item.getText(dragType));
425
- keys.push(key);
426
- } else if (item.types.has('text/plain')) {
427
- // Fallback for Chrome Android case: https://bugs.chromium.org/p/chromium/issues/detail?id=1293803
428
- // Multiple drag items are contained in a single string so we need to split them out
429
- key = await item.getText('text/plain');
430
- keys = key.split('\n').map(val => val.replaceAll('"', ''));
431
- }
432
- }
433
- }
434
- onMove(keys, e.target);
435
- }
436
- },
437
- getDropOperation(target) {
438
- if (target.type === 'root' || target.dropPosition === 'on') return 'cancel';
439
- return 'move';
440
- }
441
- });
442
- const onRemoveKey = useEventCallback(key => {
443
- props.onChange(props.elements.map(x => ({
444
- key: x.key
445
- })).filter(val => val.key !== key));
446
- });
447
- return /*#__PURE__*/jsx(ListView, {
448
- items: props.elements,
449
- dragAndDropHooks: dragAndDropHooks,
450
- height: props.elements.length ? undefined : 'scale.2000',
451
- selectionMode: "none",
452
- renderEmptyState: arrayFieldEmptyState,
453
- onAction: key => {
454
- const i = props.elements.findIndex(x => x.key === key);
455
- if (i === -1) return;
456
- props.onOpenItem(i);
457
- },
458
- children: item => {
459
- var _props$schema$itemLab, _props$schema;
460
- const label = ((_props$schema$itemLab = (_props$schema = props.schema).itemLabel) === null || _props$schema$itemLab === void 0 ? void 0 : _props$schema$itemLab.call(_props$schema, item)) || `选项 ${props.elements.indexOf(item) + 1}`;
461
- return /*#__PURE__*/jsxs(Item, {
462
- textValue: label,
463
- children: [/*#__PURE__*/jsx(Text, {
464
- children: label
465
- }), /*#__PURE__*/jsxs(TooltipTrigger, {
466
- placement: "start",
467
- children: [/*#__PURE__*/jsx(ActionButton, {
468
- onPress: () => onRemoveKey(item.key),
469
- children: /*#__PURE__*/jsx(Icon, {
470
- src: trash2Icon
471
- })
472
- }), /*#__PURE__*/jsx(Tooltip, {
473
- children: "\u5220\u9664"
474
- })]
475
- })]
476
- }, item.key);
477
- }
478
- });
479
- }
480
- function ArrayFieldItemModalContent(props) {
481
- const previewProps = useMemo(() => createGetPreviewProps(props.schema, props.onChange, () => undefined), [props.schema, props.onChange])(props.value);
482
- return /*#__PURE__*/jsx(FormValueContentFromPreviewProps, {
483
- ...previewProps
484
- });
485
- }
486
- function arrayFieldEmptyState() {
487
- return /*#__PURE__*/jsxs(VStack, {
488
- gap: "large",
489
- alignItems: "center",
490
- justifyContent: "center",
491
- height: "100%",
492
- padding: "regular",
493
- children: [/*#__PURE__*/jsx(Text, {
494
- elementType: "h3",
495
- align: "center",
496
- color: "neutralSecondary",
497
- size: "large",
498
- weight: "medium",
499
- children: "Empty list"
500
- }), /*#__PURE__*/jsx(Text, {
501
- align: "center",
502
- color: "neutralTertiary",
503
- children: "Add the first item to see it here."
504
- })]
505
- });
506
- }
507
-
508
- export { FormValueContentFromPreviewProps as F, previewPropsOnChange as a, previewPropsToValue as p };
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- var slate = require('slate');
4
- var sanitizeUrl = require('@braintree/sanitize-url');
5
-
6
- function isValidURL(url) {
7
- return url === sanitizeUrl.sanitizeUrl(url) || new URL(url, 'https://a').toString() === new URL(sanitizeUrl.sanitizeUrl(url), 'https://a').toString();
8
- }
9
- function serializeSlateNodes(nodes) {
10
- return nodes === null || nodes === void 0 ? void 0 : nodes.map(n => slate.Node.string(n)).join('\n');
11
- }
12
-
13
- exports.isValidURL = isValidURL;
14
- exports.serializeSlateNodes = serializeSlateNodes;
@@ -1,11 +0,0 @@
1
- import { Node } from 'slate';
2
- import { sanitizeUrl } from '@braintree/sanitize-url';
3
-
4
- function isValidURL(url) {
5
- return url === sanitizeUrl(url) || new URL(url, 'https://a').toString() === new URL(sanitizeUrl(url), 'https://a').toString();
6
- }
7
- function serializeSlateNodes(nodes) {
8
- return nodes === null || nodes === void 0 ? void 0 : nodes.map(n => Node.string(n)).join('\n');
9
- }
10
-
11
- export { isValidURL as i, serializeSlateNodes as s };
@@ -1,11 +0,0 @@
1
- import { Node } from 'slate';
2
- import { sanitizeUrl } from '@braintree/sanitize-url';
3
-
4
- function isValidURL(url) {
5
- return url === sanitizeUrl(url) || new URL(url, 'https://a').toString() === new URL(sanitizeUrl(url), 'https://a').toString();
6
- }
7
- function serializeSlateNodes(nodes) {
8
- return nodes === null || nodes === void 0 ? void 0 : nodes.map(n => Node.string(n)).join('\n');
9
- }
10
-
11
- export { isValidURL as i, serializeSlateNodes as s };
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- var slate = require('slate');
4
- var sanitizeUrl = require('@braintree/sanitize-url');
5
-
6
- function isValidURL(url) {
7
- return url === sanitizeUrl.sanitizeUrl(url) || new URL(url, 'https://a').toString() === new URL(sanitizeUrl.sanitizeUrl(url), 'https://a').toString();
8
- }
9
- function serializeSlateNodes(nodes) {
10
- return nodes === null || nodes === void 0 ? void 0 : nodes.map(n => slate.Node.string(n)).join('\n');
11
- }
12
-
13
- exports.isValidURL = isValidURL;
14
- exports.serializeSlateNodes = serializeSlateNodes;