@flowgram.ai/form-materials 0.4.4 → 0.4.5

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.
package/dist/esm/index.js CHANGED
@@ -245,6 +245,23 @@ var FlowValueUtils;
245
245
  FlowValueUtils2.inferJsonSchema = inferJsonSchema;
246
246
  })(FlowValueUtils || (FlowValueUtils = {}));
247
247
 
248
+ // src/shared/polyfill-create-root/index.tsx
249
+ import * as ReactDOM from "react-dom";
250
+ var unstableCreateRoot = (dom) => ({
251
+ render(children) {
252
+ ReactDOM.render(children, dom);
253
+ },
254
+ unmount() {
255
+ ReactDOM.unmountComponentAtNode(dom);
256
+ }
257
+ });
258
+ function polyfillCreateRoot(dom) {
259
+ return unstableCreateRoot(dom);
260
+ }
261
+ function unstableSetCreateRoot(createRoot) {
262
+ unstableCreateRoot = createRoot;
263
+ }
264
+
248
265
  // src/components/variable-selector/use-variable-tree.tsx
249
266
  import React11, { useCallback } from "react";
250
267
  import { JsonSchemaUtils as JsonSchemaUtils3 } from "@flowgram.ai/json-schema";
@@ -365,54 +382,55 @@ import { themes } from "@coze-editor/editor/preset-code";
365
382
  // src/components/code-editor/theme/light.ts
366
383
  import { createTheme, tags as t } from "@coze-editor/editor/preset-code";
367
384
  var colors = {
368
- background: "#F7F7FC",
369
- // syntax
370
- comment: "#000A298A",
371
- key: "#00818C",
372
- string: "#D1009D",
373
- number: "#C74200",
374
- boolean: "#2B57D9",
375
- null: "#2B57D9",
376
- separator: "#0F1529D1"
385
+ background: "#FFFFFF",
386
+ comment: "#6B7280",
387
+ key: "#2563EB",
388
+ variable: "#DC2626",
389
+ string: "#059669",
390
+ number: "#EA580C",
391
+ boolean: "#7C3AED",
392
+ null: "#7C3AED",
393
+ separator: "#374151"
377
394
  };
378
395
  var lightTheme = createTheme({
379
396
  variant: "light",
380
397
  settings: {
381
- background: "#fff",
382
- foreground: "#000",
383
- caret: "#000",
384
- selection: "#d9d9d9",
385
- gutterBackground: "#f0f0f0",
386
- gutterForeground: "#666",
398
+ background: "#FFFFFF",
399
+ foreground: "#1F2937",
400
+ caret: "#2563EB",
401
+ selection: "#E5E7EB",
402
+ gutterBackground: "#F9FAFB",
403
+ gutterForeground: "#6B7280",
387
404
  gutterBorderColor: "transparent",
388
405
  gutterBorderWidth: 0,
389
- lineHighlight: "#e1e1e180",
390
- bracketColors: ["#FFD700", "#DD99FF", "#78B0FF"],
406
+ lineHighlight: "#F3F4F680",
407
+ bracketColors: ["#F59E0B", "#8B5CF6", "#06B6D4"],
391
408
  tooltip: {
392
- backgroundColor: "#f0f0f0",
393
- color: "#000",
394
- border: "1px solid #ccc"
409
+ backgroundColor: "#FFFFFF",
410
+ color: "#1F2937",
411
+ border: "1px solid #E5E7EB",
412
+ boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"
395
413
  },
396
414
  link: {
397
- color: "#007bff"
415
+ color: "#2563EB"
398
416
  },
399
417
  completionItemHover: {
400
- backgroundColor: "#f0f0f0"
418
+ backgroundColor: "#F3F4F6"
401
419
  },
402
420
  completionItemSelected: {
403
- backgroundColor: "#e0e0e0"
421
+ backgroundColor: "#E5E7EB"
404
422
  },
405
423
  completionItemIcon: {
406
- color: "#333"
424
+ color: "#4B5563"
407
425
  },
408
426
  completionItemLabel: {
409
- color: "#333"
427
+ color: "#1F2937"
410
428
  },
411
429
  completionItemInfo: {
412
- color: "#333"
430
+ color: "#4B5563"
413
431
  },
414
432
  completionItemDetail: {
415
- color: "#666"
433
+ color: "#6B7280"
416
434
  }
417
435
  },
418
436
  styles: [
@@ -425,6 +443,10 @@ var lightTheme = createTheme({
425
443
  tag: [t.propertyName],
426
444
  color: colors.key
427
445
  },
446
+ {
447
+ tag: [t.variableName],
448
+ color: colors.variable
449
+ },
428
450
  {
429
451
  tag: [t.string],
430
452
  color: colors.string
@@ -448,27 +470,44 @@ var lightTheme = createTheme({
448
470
  // markdown
449
471
  {
450
472
  tag: [t.heading],
451
- color: "#3e76ef"
473
+ color: "#2563EB"
452
474
  },
453
475
  {
454
476
  tag: [t.processingInstruction],
455
- color: "#3e76ef"
477
+ color: "#2563EB"
478
+ },
479
+ // js
480
+ {
481
+ tag: [t.definitionKeyword],
482
+ color: "#9333EA"
483
+ },
484
+ {
485
+ tag: [t.modifier],
486
+ color: "#9333EA"
487
+ },
488
+ {
489
+ tag: [t.controlKeyword],
490
+ color: "#9333EA"
491
+ },
492
+ {
493
+ tag: [t.operatorKeyword],
494
+ color: "#9333EA"
456
495
  },
457
496
  // shell
458
497
  // curl
459
498
  {
460
499
  tag: [t.standard(t.variableName)],
461
- color: "#00804A"
500
+ color: "#059669"
462
501
  },
463
502
  // -X
464
503
  {
465
504
  tag: [t.attributeName],
466
- color: "#C74200"
505
+ color: "#EA580C"
467
506
  },
468
507
  // url in string (includes quotes), e.g. "https://..."
469
508
  {
470
509
  tag: [t.special(t.string)],
471
- color: "#2B57D9"
510
+ color: "#2563EB"
472
511
  }
473
512
  ]
474
513
  });
@@ -476,54 +515,55 @@ var lightTheme = createTheme({
476
515
  // src/components/code-editor/theme/dark.ts
477
516
  import { createTheme as createTheme2, tags as t2 } from "@coze-editor/editor/preset-code";
478
517
  var colors2 = {
479
- background: "#151B27",
480
- // syntax
481
- comment: "#FFFFFF63",
482
- key: "#39E5D7",
483
- string: "#FF94D2",
484
- number: "#FF9933",
485
- boolean: "#78B0FF",
486
- null: "#78B0FF",
487
- separator: "#FFFFFFC9"
518
+ background: "#0D1117",
519
+ // syntax - 现代化暗色主题配色
520
+ comment: "#8B949E",
521
+ key: "#7DD3FC",
522
+ variable: "#F472B6",
523
+ string: "#34D399",
524
+ number: "#FBBF24",
525
+ boolean: "#A78BFA",
526
+ null: "#A78BFA",
527
+ separator: "#E6EDF3"
488
528
  };
489
529
  var darkTheme = createTheme2({
490
530
  variant: "dark",
491
531
  settings: {
492
532
  background: colors2.background,
493
- foreground: "#fff",
494
- caret: "#AEAFAD",
495
- selection: "#d9d9d942",
533
+ foreground: "#E6EDF3",
534
+ caret: "#7DD3FC",
535
+ selection: "#264F7833",
496
536
  gutterBackground: colors2.background,
497
- gutterForeground: "#FFFFFF63",
537
+ gutterForeground: "#6E7681",
498
538
  gutterBorderColor: "transparent",
499
539
  gutterBorderWidth: 0,
500
- lineHighlight: "#272e3d36",
501
- bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
540
+ lineHighlight: "#21262D",
541
+ bracketColors: ["#FBBF24", "#A78BFA", "#7DD3FC"],
502
542
  tooltip: {
503
- backgroundColor: "#363D4D",
504
- color: "#fff",
505
- border: "none"
543
+ backgroundColor: "#21262D",
544
+ color: "#E6EDF3",
545
+ border: "1px solid #30363D"
506
546
  },
507
547
  link: {
508
- color: "#4daafc"
548
+ color: "#58A6FF"
509
549
  },
510
550
  completionItemHover: {
511
- backgroundColor: "#FFFFFF0F"
551
+ backgroundColor: "#21262D"
512
552
  },
513
553
  completionItemSelected: {
514
- backgroundColor: "#FFFFFF17"
554
+ backgroundColor: "#1F6EEB"
515
555
  },
516
556
  completionItemIcon: {
517
- color: "#FFFFFFC9"
557
+ color: "#8B949E"
518
558
  },
519
559
  completionItemLabel: {
520
- color: "#FFFFFFC9"
560
+ color: "#E6EDF3"
521
561
  },
522
562
  completionItemInfo: {
523
- color: "#FFFFFFC9"
563
+ color: "#8B949E"
524
564
  },
525
565
  completionItemDetail: {
526
- color: "#FFFFFF63"
566
+ color: "#6E7681"
527
567
  }
528
568
  },
529
569
  styles: [
@@ -556,30 +596,47 @@ var darkTheme = createTheme2({
556
596
  tag: [t2.separator],
557
597
  color: colors2.separator
558
598
  },
599
+ // js
600
+ {
601
+ tag: [t2.definitionKeyword],
602
+ color: "#C084FC"
603
+ },
604
+ {
605
+ tag: [t2.modifier],
606
+ color: "#C084FC"
607
+ },
608
+ {
609
+ tag: [t2.controlKeyword],
610
+ color: "#C084FC"
611
+ },
612
+ {
613
+ tag: [t2.operatorKeyword],
614
+ color: "#C084FC"
615
+ },
559
616
  // markdown
560
617
  {
561
618
  tag: [t2.heading],
562
- color: "#6b6bff"
619
+ color: "#7DD3FC"
563
620
  },
564
621
  {
565
622
  tag: [t2.processingInstruction],
566
- color: "#6b6bff"
623
+ color: "#7DD3FC"
567
624
  },
568
625
  // shell
569
626
  // curl
570
627
  {
571
628
  tag: [t2.standard(t2.variableName)],
572
- color: "#3BEB84"
629
+ color: "#34D399"
573
630
  },
574
631
  // -X
575
632
  {
576
633
  tag: [t2.attributeName],
577
- color: "#FF9933"
634
+ color: "#FBBF24"
578
635
  },
579
636
  // url in string (includes quotes), e.g. "https://..."
580
637
  {
581
638
  tag: [t2.special(t2.string)],
582
- color: "#78B0FF"
639
+ color: "#7DD3FC"
583
640
  }
584
641
  ]
585
642
  });
@@ -2438,7 +2495,6 @@ function VariableTree() {
2438
2495
  }
2439
2496
 
2440
2497
  // src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
2441
- import ReactDOM from "react-dom";
2442
2498
  import React26, { useLayoutEffect as useLayoutEffect4 } from "react";
2443
2499
  import { isEqual, last } from "lodash";
2444
2500
  import {
@@ -2508,36 +2564,32 @@ var VariableTagWidget = class extends WidgetType {
2508
2564
  this.keyPath = keyPath;
2509
2565
  this.scope = scope;
2510
2566
  }
2511
- renderReact(jsx) {
2512
- ReactDOM.render(jsx, this.rootDOM);
2513
- }
2514
2567
  renderVariable(v) {
2515
2568
  if (!v) {
2516
- this.renderReact(
2569
+ this.root.render(
2517
2570
  /* @__PURE__ */ React26.createElement(UITag2, { prefixIcon: /* @__PURE__ */ React26.createElement(IconIssueStroked2, null), color: "amber" }, "Unknown")
2518
2571
  );
2519
2572
  return;
2520
2573
  }
2521
- const rootField = last(v.parentFields) || v;
2522
- const isRoot = v.parentFields.length === 0;
2523
- const rootTitle = /* @__PURE__ */ React26.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
2574
+ const rootField = last(v.parentFields);
2575
+ const rootTitle = /* @__PURE__ */ React26.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
2524
2576
  const rootIcon = this.renderIcon(rootField?.meta.icon);
2525
- this.renderReact(
2577
+ this.root.render(
2526
2578
  /* @__PURE__ */ React26.createElement(
2527
2579
  Popover3,
2528
2580
  {
2529
2581
  content: /* @__PURE__ */ React26.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ React26.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
2530
2582
  },
2531
- /* @__PURE__ */ React26.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ React26.createElement(UIVarName2, null, v?.key))
2583
+ /* @__PURE__ */ React26.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ React26.createElement(UIVarName2, null, v?.key))
2532
2584
  )
2533
2585
  );
2534
2586
  }
2535
2587
  toDOM(view) {
2536
2588
  const dom = document.createElement("span");
2537
- this.rootDOM = dom;
2589
+ this.root = polyfillCreateRoot(dom);
2538
2590
  this.toDispose.push(
2539
2591
  Disposable.create(() => {
2540
- ReactDOM.unmountComponentAtNode(this.rootDOM);
2592
+ this.root.unmount();
2541
2593
  })
2542
2594
  );
2543
2595
  this.toDispose.push(
@@ -2827,7 +2879,6 @@ function VariableTree2() {
2827
2879
 
2828
2880
  // src/components/json-editor-with-variables/extensions/variable-tag.tsx
2829
2881
  import React32, { useLayoutEffect as useLayoutEffect5 } from "react";
2830
- import { createRoot } from "react-dom/client";
2831
2882
  import { isEqual as isEqual2, last as last3 } from "lodash";
2832
2883
  import {
2833
2884
  Disposable as Disposable2,
@@ -2918,7 +2969,7 @@ var VariableTagWidget2 = class extends WidgetType2 {
2918
2969
  }
2919
2970
  toDOM(view) {
2920
2971
  const dom = document.createElement("span");
2921
- this.root = createRoot(dom);
2972
+ this.root = polyfillCreateRoot(dom);
2922
2973
  this.toDispose.push(
2923
2974
  Disposable2.create(() => {
2924
2975
  this.root.unmount();
@@ -4285,10 +4336,12 @@ export {
4285
4336
  listenRefSchemaChange,
4286
4337
  listenRefValueChange,
4287
4338
  parseTypeSelectValue,
4339
+ polyfillCreateRoot,
4288
4340
  provideBatchInputEffect,
4289
4341
  provideBatchOutputsEffect,
4290
4342
  provideJsonSchemaOutputs,
4291
4343
  syncVariableTitle,
4344
+ unstableSetCreateRoot,
4292
4345
  useObjectList,
4293
4346
  useTypeManager,
4294
4347
  useVariableTree,