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