@copilotkit/shared 1.85.0 → 1.86.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 (116) hide show
  1. package/dist/event-transforms/recorded-events.cjs +7 -1
  2. package/dist/event-transforms/recorded-events.cjs.map +1 -1
  3. package/dist/event-transforms/recorded-events.mjs +8 -2
  4. package/dist/event-transforms/recorded-events.mjs.map +1 -1
  5. package/dist/generative-ui/clone-value.cjs +364 -0
  6. package/dist/generative-ui/clone-value.cjs.map +1 -0
  7. package/dist/generative-ui/clone-value.d.cts +51 -0
  8. package/dist/generative-ui/clone-value.d.cts.map +1 -0
  9. package/dist/generative-ui/clone-value.d.mts +51 -0
  10. package/dist/generative-ui/clone-value.d.mts.map +1 -0
  11. package/dist/generative-ui/clone-value.mjs +363 -0
  12. package/dist/generative-ui/clone-value.mjs.map +1 -0
  13. package/dist/generative-ui/index.cjs +39 -0
  14. package/dist/generative-ui/index.d.cts +8 -2
  15. package/dist/generative-ui/index.d.mts +8 -2
  16. package/dist/generative-ui/index.mjs +8 -2
  17. package/dist/generative-ui/is-record.d.cts +3 -1
  18. package/dist/generative-ui/is-record.d.cts.map +1 -1
  19. package/dist/generative-ui/is-record.d.mts +3 -1
  20. package/dist/generative-ui/is-record.d.mts.map +1 -1
  21. package/dist/generative-ui/schema-render.cjs +2 -1
  22. package/dist/generative-ui/schema-render.cjs.map +1 -1
  23. package/dist/generative-ui/schema-render.d.cts.map +1 -1
  24. package/dist/generative-ui/schema-render.d.mts.map +1 -1
  25. package/dist/generative-ui/schema-render.mjs +2 -1
  26. package/dist/generative-ui/schema-render.mjs.map +1 -1
  27. package/dist/generative-ui/standard/chart-config.cjs +347 -0
  28. package/dist/generative-ui/standard/chart-config.cjs.map +1 -0
  29. package/dist/generative-ui/standard/chart-config.d.cts +97 -0
  30. package/dist/generative-ui/standard/chart-config.d.cts.map +1 -0
  31. package/dist/generative-ui/standard/chart-config.d.mts +97 -0
  32. package/dist/generative-ui/standard/chart-config.d.mts.map +1 -0
  33. package/dist/generative-ui/standard/chart-config.mjs +342 -0
  34. package/dist/generative-ui/standard/chart-config.mjs.map +1 -0
  35. package/dist/generative-ui/standard/chart.d.cts +10 -10
  36. package/dist/generative-ui/standard/chart.d.mts +10 -10
  37. package/dist/generative-ui/standard/composites.d.cts +46 -46
  38. package/dist/generative-ui/standard/composites.d.mts +46 -46
  39. package/dist/generative-ui/standard/data.d.cts +42 -42
  40. package/dist/generative-ui/standard/data.d.mts +42 -42
  41. package/dist/generative-ui/standard/declarations.d.cts +226 -226
  42. package/dist/generative-ui/standard/declarations.d.mts +226 -226
  43. package/dist/generative-ui/standard/feedback.d.cts +4 -4
  44. package/dist/generative-ui/standard/feedback.d.mts +4 -4
  45. package/dist/generative-ui/standard/index.d.mts +5 -1
  46. package/dist/generative-ui/standard/inputs.d.cts +72 -72
  47. package/dist/generative-ui/standard/inputs.d.mts +72 -72
  48. package/dist/generative-ui/standard/layout.d.cts +156 -156
  49. package/dist/generative-ui/standard/layout.d.mts +156 -156
  50. package/dist/generative-ui/standard/map-helpers.cjs +104 -0
  51. package/dist/generative-ui/standard/map-helpers.cjs.map +1 -0
  52. package/dist/generative-ui/standard/map-helpers.d.cts +88 -0
  53. package/dist/generative-ui/standard/map-helpers.d.cts.map +1 -0
  54. package/dist/generative-ui/standard/map-helpers.d.mts +88 -0
  55. package/dist/generative-ui/standard/map-helpers.d.mts.map +1 -0
  56. package/dist/generative-ui/standard/map-helpers.mjs +95 -0
  57. package/dist/generative-ui/standard/map-helpers.mjs.map +1 -0
  58. package/dist/generative-ui/standard/map.d.cts +10 -10
  59. package/dist/generative-ui/standard/map.d.mts +10 -10
  60. package/dist/generative-ui/standard/media.d.cts +76 -76
  61. package/dist/generative-ui/standard/media.d.mts +76 -76
  62. package/dist/generative-ui/standard/style-helpers.cjs +151 -0
  63. package/dist/generative-ui/standard/style-helpers.cjs.map +1 -0
  64. package/dist/generative-ui/standard/style-helpers.d.cts +56 -0
  65. package/dist/generative-ui/standard/style-helpers.d.cts.map +1 -0
  66. package/dist/generative-ui/standard/style-helpers.d.mts +56 -0
  67. package/dist/generative-ui/standard/style-helpers.d.mts.map +1 -0
  68. package/dist/generative-ui/standard/style-helpers.mjs +142 -0
  69. package/dist/generative-ui/standard/style-helpers.mjs.map +1 -0
  70. package/dist/generative-ui/standard/text.d.cts +28 -28
  71. package/dist/generative-ui/standard/text.d.mts +28 -28
  72. package/dist/generative-ui/standard/url.cjs +54 -0
  73. package/dist/generative-ui/standard/url.cjs.map +1 -0
  74. package/dist/generative-ui/standard/url.d.cts +32 -0
  75. package/dist/generative-ui/standard/url.d.cts.map +1 -0
  76. package/dist/generative-ui/standard/url.d.mts +32 -0
  77. package/dist/generative-ui/standard/url.d.mts.map +1 -0
  78. package/dist/generative-ui/standard/url.mjs +50 -0
  79. package/dist/generative-ui/standard/url.mjs.map +1 -0
  80. package/dist/generative-ui/thrown.cjs +69 -0
  81. package/dist/generative-ui/thrown.cjs.map +1 -0
  82. package/dist/generative-ui/thrown.d.cts +21 -0
  83. package/dist/generative-ui/thrown.d.cts.map +1 -0
  84. package/dist/generative-ui/thrown.d.mts +21 -0
  85. package/dist/generative-ui/thrown.d.mts.map +1 -0
  86. package/dist/generative-ui/thrown.mjs +67 -0
  87. package/dist/generative-ui/thrown.mjs.map +1 -0
  88. package/dist/index.cjs +2 -0
  89. package/dist/index.cjs.map +1 -1
  90. package/dist/index.d.cts +2 -1
  91. package/dist/index.d.cts.map +1 -1
  92. package/dist/index.d.mts +2 -1
  93. package/dist/index.d.mts.map +1 -1
  94. package/dist/index.mjs +2 -1
  95. package/dist/index.mjs.map +1 -1
  96. package/dist/index.umd.js +368 -2
  97. package/dist/index.umd.js.map +1 -1
  98. package/dist/package.cjs +1 -1
  99. package/dist/package.mjs +1 -1
  100. package/package.json +2 -2
  101. package/src/__tests__/schema-render.test.ts +78 -0
  102. package/src/event-transforms/recorded-events.test.ts +35 -3
  103. package/src/event-transforms/recorded-events.ts +15 -2
  104. package/src/generative-ui/__tests__/clone-value-differential.test.ts +480 -0
  105. package/src/generative-ui/__tests__/clone-value.test.ts +226 -0
  106. package/src/generative-ui/clone-value.ts +511 -0
  107. package/src/generative-ui/index.ts +6 -2
  108. package/src/generative-ui/schema-render.ts +2 -1
  109. package/src/generative-ui/standard/__tests__/standard-helpers.test.ts +407 -0
  110. package/src/generative-ui/standard/chart-config.ts +434 -0
  111. package/src/generative-ui/standard/index.ts +36 -0
  112. package/src/generative-ui/standard/map-helpers.ts +155 -0
  113. package/src/generative-ui/standard/style-helpers.ts +170 -0
  114. package/src/generative-ui/standard/url.ts +51 -0
  115. package/src/generative-ui/thrown.ts +90 -0
  116. package/src/index.ts +5 -0
@@ -56,6 +56,7 @@ declare const imageSchema: z.ZodObject<{
56
56
  }, "strip", z.ZodTypeAny, {
57
57
  url: string;
58
58
  description?: string | undefined;
59
+ height?: string | number | undefined;
59
60
  background?: string | undefined;
60
61
  radius?: string | number | {
61
62
  topLeft?: string | undefined;
@@ -64,7 +65,6 @@ declare const imageSchema: z.ZodObject<{
64
65
  bottomRight?: string | undefined;
65
66
  } | undefined;
66
67
  width?: string | number | undefined;
67
- height?: string | number | undefined;
68
68
  minWidth?: string | number | undefined;
69
69
  maxWidth?: string | number | undefined;
70
70
  minHeight?: string | number | undefined;
@@ -87,6 +87,7 @@ declare const imageSchema: z.ZodObject<{
87
87
  }, {
88
88
  url: string;
89
89
  description?: string | undefined;
90
+ height?: string | number | undefined;
90
91
  background?: string | undefined;
91
92
  radius?: string | number | {
92
93
  topLeft?: string | undefined;
@@ -95,7 +96,6 @@ declare const imageSchema: z.ZodObject<{
95
96
  bottomRight?: string | undefined;
96
97
  } | undefined;
97
98
  width?: string | number | undefined;
98
- height?: string | number | undefined;
99
99
  minWidth?: string | number | undefined;
100
100
  maxWidth?: string | number | undefined;
101
101
  minHeight?: string | number | undefined;
@@ -160,15 +160,15 @@ declare const faviconSchema: z.ZodObject<{
160
160
  }, "strip", z.ZodTypeAny, {
161
161
  url: string;
162
162
  inline?: boolean | undefined;
163
+ alt?: string | undefined;
163
164
  size?: number | undefined;
164
165
  frame?: boolean | undefined;
165
- alt?: string | undefined;
166
166
  }, {
167
167
  url: string;
168
168
  inline?: boolean | undefined;
169
+ alt?: string | undefined;
169
170
  size?: number | undefined;
170
171
  frame?: boolean | undefined;
171
- alt?: string | undefined;
172
172
  }>;
173
173
  declare const svgSchema: z.ZodObject<{
174
174
  viewBox: z.ZodOptional<z.ZodString>;
@@ -227,16 +227,16 @@ declare const svgSchema: z.ZodObject<{
227
227
  fill: z.ZodOptional<z.ZodString>;
228
228
  stroke: z.ZodOptional<z.ZodString>;
229
229
  }, "strip", z.ZodTypeAny, {
230
- width: number;
231
230
  height: number;
231
+ width: number;
232
232
  x: number;
233
233
  y: number;
234
234
  fill?: string | undefined;
235
235
  stroke?: string | undefined;
236
236
  rx?: number | undefined;
237
237
  }, {
238
- width: number;
239
238
  height: number;
239
+ width: number;
240
240
  x: number;
241
241
  y: number;
242
242
  fill?: string | undefined;
@@ -287,22 +287,22 @@ declare const svgSchema: z.ZodObject<{
287
287
  }, "strip", z.ZodTypeAny, {
288
288
  fill?: string | undefined;
289
289
  label?: string | undefined;
290
- width?: string | number | undefined;
290
+ paths?: {
291
+ d: string;
292
+ fill?: string | undefined;
293
+ stroke?: string | undefined;
294
+ strokeWidth?: number | undefined;
295
+ }[] | undefined;
296
+ viewBox?: string | undefined;
291
297
  height?: string | number | undefined;
298
+ width?: string | number | undefined;
292
299
  size?: string | number | undefined;
293
300
  color?: string | undefined;
294
- viewBox?: string | undefined;
295
301
  stroke?: string | undefined;
296
302
  strokeWidth?: number | undefined;
297
303
  strokeLinecap?: "round" | "square" | "butt" | undefined;
298
304
  strokeLinejoin?: "round" | "miter" | "bevel" | undefined;
299
305
  preserveAspectRatio?: string | undefined;
300
- paths?: {
301
- d: string;
302
- fill?: string | undefined;
303
- stroke?: string | undefined;
304
- strokeWidth?: number | undefined;
305
- }[] | undefined;
306
306
  circles?: {
307
307
  cx: number;
308
308
  cy: number;
@@ -311,8 +311,8 @@ declare const svgSchema: z.ZodObject<{
311
311
  stroke?: string | undefined;
312
312
  }[] | undefined;
313
313
  rects?: {
314
- width: number;
315
314
  height: number;
315
+ width: number;
316
316
  x: number;
317
317
  y: number;
318
318
  fill?: string | undefined;
@@ -337,22 +337,22 @@ declare const svgSchema: z.ZodObject<{
337
337
  }, {
338
338
  fill?: string | undefined;
339
339
  label?: string | undefined;
340
- width?: string | number | undefined;
340
+ paths?: {
341
+ d: string;
342
+ fill?: string | undefined;
343
+ stroke?: string | undefined;
344
+ strokeWidth?: number | undefined;
345
+ }[] | undefined;
346
+ viewBox?: string | undefined;
341
347
  height?: string | number | undefined;
348
+ width?: string | number | undefined;
342
349
  size?: string | number | undefined;
343
350
  color?: string | undefined;
344
- viewBox?: string | undefined;
345
351
  stroke?: string | undefined;
346
352
  strokeWidth?: number | undefined;
347
353
  strokeLinecap?: "round" | "square" | "butt" | undefined;
348
354
  strokeLinejoin?: "round" | "miter" | "bevel" | undefined;
349
355
  preserveAspectRatio?: string | undefined;
350
- paths?: {
351
- d: string;
352
- fill?: string | undefined;
353
- stroke?: string | undefined;
354
- strokeWidth?: number | undefined;
355
- }[] | undefined;
356
356
  circles?: {
357
357
  cx: number;
358
358
  cy: number;
@@ -361,8 +361,8 @@ declare const svgSchema: z.ZodObject<{
361
361
  stroke?: string | undefined;
362
362
  }[] | undefined;
363
363
  rects?: {
364
- width: number;
365
364
  height: number;
365
+ width: number;
366
366
  x: number;
367
367
  y: number;
368
368
  fill?: string | undefined;
@@ -398,12 +398,12 @@ declare const videoSchema: z.ZodObject<{
398
398
  url: string;
399
399
  label?: string | undefined;
400
400
  language?: string | undefined;
401
- kind?: "subtitles" | "captions" | "descriptions" | undefined;
401
+ kind?: "captions" | "subtitles" | "descriptions" | undefined;
402
402
  }, {
403
403
  url: string;
404
404
  label?: string | undefined;
405
405
  language?: string | undefined;
406
- kind?: "subtitles" | "captions" | "descriptions" | undefined;
406
+ kind?: "captions" | "subtitles" | "descriptions" | undefined;
407
407
  }>, "many">>;
408
408
  aspectRatio: z.ZodOptional<z.ZodString>;
409
409
  width: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
@@ -412,31 +412,31 @@ declare const videoSchema: z.ZodObject<{
412
412
  }, "strip", z.ZodTypeAny, {
413
413
  url: string;
414
414
  title?: string | undefined;
415
- width?: string | number | undefined;
416
- maxWidth?: string | number | undefined;
417
- weight?: number | undefined;
418
- aspectRatio?: string | undefined;
419
- posterUrl?: string | undefined;
420
415
  captions?: {
421
416
  url: string;
422
417
  label?: string | undefined;
423
418
  language?: string | undefined;
424
- kind?: "subtitles" | "captions" | "descriptions" | undefined;
419
+ kind?: "captions" | "subtitles" | "descriptions" | undefined;
425
420
  }[] | undefined;
426
- }, {
427
- url: string;
428
- title?: string | undefined;
429
421
  width?: string | number | undefined;
430
422
  maxWidth?: string | number | undefined;
431
423
  weight?: number | undefined;
432
424
  aspectRatio?: string | undefined;
433
425
  posterUrl?: string | undefined;
426
+ }, {
427
+ url: string;
428
+ title?: string | undefined;
434
429
  captions?: {
435
430
  url: string;
436
431
  label?: string | undefined;
437
432
  language?: string | undefined;
438
- kind?: "subtitles" | "captions" | "descriptions" | undefined;
433
+ kind?: "captions" | "subtitles" | "descriptions" | undefined;
439
434
  }[] | undefined;
435
+ width?: string | number | undefined;
436
+ maxWidth?: string | number | undefined;
437
+ weight?: number | undefined;
438
+ aspectRatio?: string | undefined;
439
+ posterUrl?: string | undefined;
440
440
  }>;
441
441
  declare const audioPlayerSchema: z.ZodObject<{
442
442
  url: z.ZodString;
@@ -459,13 +459,13 @@ declare const htmlViewSchema: z.ZodObject<{
459
459
  }, "strip", z.ZodTypeAny, {
460
460
  html: string;
461
461
  title?: string | undefined;
462
- width?: string | number | undefined;
463
462
  height?: string | number | undefined;
463
+ width?: string | number | undefined;
464
464
  }, {
465
465
  html: string;
466
466
  title?: string | undefined;
467
- width?: string | number | undefined;
468
467
  height?: string | number | undefined;
468
+ width?: string | number | undefined;
469
469
  }>;
470
470
  /**
471
471
  * The standard media components, without their framework components. Each
@@ -526,6 +526,7 @@ declare const mediaDeclarations: {
526
526
  }, "strip", z.ZodTypeAny, {
527
527
  url: string;
528
528
  description?: string | undefined;
529
+ height?: string | number | undefined;
529
530
  background?: string | undefined;
530
531
  radius?: string | number | {
531
532
  topLeft?: string | undefined;
@@ -534,7 +535,6 @@ declare const mediaDeclarations: {
534
535
  bottomRight?: string | undefined;
535
536
  } | undefined;
536
537
  width?: string | number | undefined;
537
- height?: string | number | undefined;
538
538
  minWidth?: string | number | undefined;
539
539
  maxWidth?: string | number | undefined;
540
540
  minHeight?: string | number | undefined;
@@ -557,6 +557,7 @@ declare const mediaDeclarations: {
557
557
  }, {
558
558
  url: string;
559
559
  description?: string | undefined;
560
+ height?: string | number | undefined;
560
561
  background?: string | undefined;
561
562
  radius?: string | number | {
562
563
  topLeft?: string | undefined;
@@ -565,7 +566,6 @@ declare const mediaDeclarations: {
565
566
  bottomRight?: string | undefined;
566
567
  } | undefined;
567
568
  width?: string | number | undefined;
568
- height?: string | number | undefined;
569
569
  minWidth?: string | number | undefined;
570
570
  maxWidth?: string | number | undefined;
571
571
  minHeight?: string | number | undefined;
@@ -642,15 +642,15 @@ declare const mediaDeclarations: {
642
642
  }, "strip", z.ZodTypeAny, {
643
643
  url: string;
644
644
  inline?: boolean | undefined;
645
+ alt?: string | undefined;
645
646
  size?: number | undefined;
646
647
  frame?: boolean | undefined;
647
- alt?: string | undefined;
648
648
  }, {
649
649
  url: string;
650
650
  inline?: boolean | undefined;
651
+ alt?: string | undefined;
651
652
  size?: number | undefined;
652
653
  frame?: boolean | undefined;
653
- alt?: string | undefined;
654
654
  }>;
655
655
  };
656
656
  Svg: {
@@ -712,16 +712,16 @@ declare const mediaDeclarations: {
712
712
  fill: z.ZodOptional<z.ZodString>;
713
713
  stroke: z.ZodOptional<z.ZodString>;
714
714
  }, "strip", z.ZodTypeAny, {
715
- width: number;
716
715
  height: number;
716
+ width: number;
717
717
  x: number;
718
718
  y: number;
719
719
  fill?: string | undefined;
720
720
  stroke?: string | undefined;
721
721
  rx?: number | undefined;
722
722
  }, {
723
- width: number;
724
723
  height: number;
724
+ width: number;
725
725
  x: number;
726
726
  y: number;
727
727
  fill?: string | undefined;
@@ -772,22 +772,22 @@ declare const mediaDeclarations: {
772
772
  }, "strip", z.ZodTypeAny, {
773
773
  fill?: string | undefined;
774
774
  label?: string | undefined;
775
- width?: string | number | undefined;
775
+ paths?: {
776
+ d: string;
777
+ fill?: string | undefined;
778
+ stroke?: string | undefined;
779
+ strokeWidth?: number | undefined;
780
+ }[] | undefined;
781
+ viewBox?: string | undefined;
776
782
  height?: string | number | undefined;
783
+ width?: string | number | undefined;
777
784
  size?: string | number | undefined;
778
785
  color?: string | undefined;
779
- viewBox?: string | undefined;
780
786
  stroke?: string | undefined;
781
787
  strokeWidth?: number | undefined;
782
788
  strokeLinecap?: "round" | "square" | "butt" | undefined;
783
789
  strokeLinejoin?: "round" | "miter" | "bevel" | undefined;
784
790
  preserveAspectRatio?: string | undefined;
785
- paths?: {
786
- d: string;
787
- fill?: string | undefined;
788
- stroke?: string | undefined;
789
- strokeWidth?: number | undefined;
790
- }[] | undefined;
791
791
  circles?: {
792
792
  cx: number;
793
793
  cy: number;
@@ -796,8 +796,8 @@ declare const mediaDeclarations: {
796
796
  stroke?: string | undefined;
797
797
  }[] | undefined;
798
798
  rects?: {
799
- width: number;
800
799
  height: number;
800
+ width: number;
801
801
  x: number;
802
802
  y: number;
803
803
  fill?: string | undefined;
@@ -822,22 +822,22 @@ declare const mediaDeclarations: {
822
822
  }, {
823
823
  fill?: string | undefined;
824
824
  label?: string | undefined;
825
- width?: string | number | undefined;
825
+ paths?: {
826
+ d: string;
827
+ fill?: string | undefined;
828
+ stroke?: string | undefined;
829
+ strokeWidth?: number | undefined;
830
+ }[] | undefined;
831
+ viewBox?: string | undefined;
826
832
  height?: string | number | undefined;
833
+ width?: string | number | undefined;
827
834
  size?: string | number | undefined;
828
835
  color?: string | undefined;
829
- viewBox?: string | undefined;
830
836
  stroke?: string | undefined;
831
837
  strokeWidth?: number | undefined;
832
838
  strokeLinecap?: "round" | "square" | "butt" | undefined;
833
839
  strokeLinejoin?: "round" | "miter" | "bevel" | undefined;
834
840
  preserveAspectRatio?: string | undefined;
835
- paths?: {
836
- d: string;
837
- fill?: string | undefined;
838
- stroke?: string | undefined;
839
- strokeWidth?: number | undefined;
840
- }[] | undefined;
841
841
  circles?: {
842
842
  cx: number;
843
843
  cy: number;
@@ -846,8 +846,8 @@ declare const mediaDeclarations: {
846
846
  stroke?: string | undefined;
847
847
  }[] | undefined;
848
848
  rects?: {
849
- width: number;
850
849
  height: number;
850
+ width: number;
851
851
  x: number;
852
852
  y: number;
853
853
  fill?: string | undefined;
@@ -886,12 +886,12 @@ declare const mediaDeclarations: {
886
886
  url: string;
887
887
  label?: string | undefined;
888
888
  language?: string | undefined;
889
- kind?: "subtitles" | "captions" | "descriptions" | undefined;
889
+ kind?: "captions" | "subtitles" | "descriptions" | undefined;
890
890
  }, {
891
891
  url: string;
892
892
  label?: string | undefined;
893
893
  language?: string | undefined;
894
- kind?: "subtitles" | "captions" | "descriptions" | undefined;
894
+ kind?: "captions" | "subtitles" | "descriptions" | undefined;
895
895
  }>, "many">>;
896
896
  aspectRatio: z.ZodOptional<z.ZodString>;
897
897
  width: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
@@ -900,31 +900,31 @@ declare const mediaDeclarations: {
900
900
  }, "strip", z.ZodTypeAny, {
901
901
  url: string;
902
902
  title?: string | undefined;
903
- width?: string | number | undefined;
904
- maxWidth?: string | number | undefined;
905
- weight?: number | undefined;
906
- aspectRatio?: string | undefined;
907
- posterUrl?: string | undefined;
908
903
  captions?: {
909
904
  url: string;
910
905
  label?: string | undefined;
911
906
  language?: string | undefined;
912
- kind?: "subtitles" | "captions" | "descriptions" | undefined;
907
+ kind?: "captions" | "subtitles" | "descriptions" | undefined;
913
908
  }[] | undefined;
914
- }, {
915
- url: string;
916
- title?: string | undefined;
917
909
  width?: string | number | undefined;
918
910
  maxWidth?: string | number | undefined;
919
911
  weight?: number | undefined;
920
912
  aspectRatio?: string | undefined;
921
913
  posterUrl?: string | undefined;
914
+ }, {
915
+ url: string;
916
+ title?: string | undefined;
922
917
  captions?: {
923
918
  url: string;
924
919
  label?: string | undefined;
925
920
  language?: string | undefined;
926
- kind?: "subtitles" | "captions" | "descriptions" | undefined;
921
+ kind?: "captions" | "subtitles" | "descriptions" | undefined;
927
922
  }[] | undefined;
923
+ width?: string | number | undefined;
924
+ maxWidth?: string | number | undefined;
925
+ weight?: number | undefined;
926
+ aspectRatio?: string | undefined;
927
+ posterUrl?: string | undefined;
928
928
  }>;
929
929
  };
930
930
  AudioPlayer: {
@@ -953,13 +953,13 @@ declare const mediaDeclarations: {
953
953
  }, "strip", z.ZodTypeAny, {
954
954
  html: string;
955
955
  title?: string | undefined;
956
- width?: string | number | undefined;
957
956
  height?: string | number | undefined;
957
+ width?: string | number | undefined;
958
958
  }, {
959
959
  html: string;
960
960
  title?: string | undefined;
961
- width?: string | number | undefined;
962
961
  height?: string | number | undefined;
962
+ width?: string | number | undefined;
963
963
  }>;
964
964
  };
965
965
  };
@@ -0,0 +1,151 @@
1
+ const require_tokens = require('./tokens.cjs');
2
+
3
+ //#region src/generative-ui/standard/style-helpers.ts
4
+ /**
5
+ * Equal when the JSON is equal. Use it as the equality check of a computed
6
+ * value over agent data, so a new object with the same content does not
7
+ * trigger a redraw.
8
+ */
9
+ const jsonEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
10
+ /** Hides an element on screen. Screen readers still read it. */
11
+ const VISUALLY_HIDDEN = {
12
+ position: "absolute",
13
+ width: "1px",
14
+ height: "1px",
15
+ padding: 0,
16
+ margin: "-1px",
17
+ overflow: "hidden",
18
+ clipPath: "inset(50%)",
19
+ whiteSpace: "nowrap",
20
+ border: 0
21
+ };
22
+ /** The outline of a focused control, for a `:focus-visible` rule. */
23
+ const FOCUS_RING = "2px solid var(--a2ui-color-focus, #0285ff)";
24
+ /**
25
+ * Cuts the text after `lines` lines, with an ellipsis.
26
+ *
27
+ * @param lines - The number of lines to show.
28
+ */
29
+ function lineClamp(lines) {
30
+ return {
31
+ display: "-webkit-box",
32
+ WebkitLineClamp: lines,
33
+ WebkitBoxOrient: "vertical",
34
+ overflow: "hidden"
35
+ };
36
+ }
37
+ /** The `align-items` value of each `align` prop value. */
38
+ const ALIGN_CSS = {
39
+ start: "flex-start",
40
+ end: "flex-end",
41
+ center: "center",
42
+ baseline: "baseline",
43
+ stretch: "stretch"
44
+ };
45
+ /** The `justify-content` value of each `justify` prop value. */
46
+ const JUSTIFY_CSS = {
47
+ start: "flex-start",
48
+ end: "flex-end",
49
+ center: "center",
50
+ spaceBetween: "space-between",
51
+ spaceAround: "space-around",
52
+ spaceEvenly: "space-evenly",
53
+ stretch: "stretch"
54
+ };
55
+ /**
56
+ * A CSS length: pixels when `value` is a number, the raw CSS when it is a
57
+ * string, and `undefined` when it is not set.
58
+ *
59
+ * @example px(12) // "12px"
60
+ */
61
+ function px(value) {
62
+ if (value === void 0) return void 0;
63
+ return typeof value === "number" ? `${value}px` : value;
64
+ }
65
+ /**
66
+ * The CSS of a `radius` prop: one radius for all corners, or one radius for
67
+ * each corner.
68
+ *
69
+ * @param value - A radius token, a raw CSS value, or an object of corners.
70
+ */
71
+ function radiusStyle(value) {
72
+ if (typeof value === "string" || typeof value === "number") return { borderRadius: require_tokens.radius(value) };
73
+ if (value === void 0) return {};
74
+ return {
75
+ borderTopLeftRadius: require_tokens.radius(value.topLeft),
76
+ borderTopRightRadius: require_tokens.radius(value.topRight),
77
+ borderBottomLeftRadius: require_tokens.radius(value.bottomLeft),
78
+ borderBottomRightRadius: require_tokens.radius(value.bottomRight)
79
+ };
80
+ }
81
+ /**
82
+ * A copy of `style` without the undefined entries, so a later spread never
83
+ * erases a value. An undefined longhand next to a shorthand is a removal:
84
+ * clearing `row-gap` resets the `gap` shorthand in real browsers.
85
+ */
86
+ function defined(style) {
87
+ const result = {};
88
+ for (const [key, value] of Object.entries(style)) if (value !== void 0) result[key] = value;
89
+ return result;
90
+ }
91
+ /**
92
+ * The `gap` of the layout props, with `rowGap` and `columnGap` winning over
93
+ * it. A renderer can apply a style object in sorted key order (Angular does),
94
+ * so `columnGap` would come before the `gap` shorthand and lose to it. A
95
+ * longhand therefore sets both longhands and no shorthand.
96
+ */
97
+ function gapStyle(props) {
98
+ const gap = require_tokens.spacing(props.gap) ?? (props.disableAutoSpacing ? 0 : void 0);
99
+ const rowGap = require_tokens.spacing(props.rowGap);
100
+ const columnGap = require_tokens.spacing(props.columnGap);
101
+ if (rowGap === void 0 && columnGap === void 0) return { gap };
102
+ return {
103
+ rowGap: rowGap ?? gap,
104
+ columnGap: columnGap ?? gap
105
+ };
106
+ }
107
+ /**
108
+ * The flex container CSS of the shared layout props (`align`, `gap`,
109
+ * `padding`, `radius`, sizes and the rest). An unset prop gives no CSS.
110
+ *
111
+ * @param props - The layout props of a container component.
112
+ */
113
+ function layoutStyle(props) {
114
+ const overflow = props.scrollable ? "auto" : props.clip ? "hidden" : void 0;
115
+ return defined({
116
+ display: props.inline ? "inline-flex" : "flex",
117
+ alignItems: props.align ? ALIGN_CSS[props.align] : void 0,
118
+ justifyContent: props.justify ? JUSTIFY_CSS[props.justify] : void 0,
119
+ flexWrap: props.wrap,
120
+ ...gapStyle(props),
121
+ padding: props.flush ? 0 : require_tokens.spacing(props.padding),
122
+ background: require_tokens.backgroundColor(props.background),
123
+ border: props.border ? `1px solid ${require_tokens.borderColor(props.borderColor ?? "default")}` : void 0,
124
+ ...radiusStyle(props.radius),
125
+ width: require_tokens.spacing(props.width),
126
+ height: require_tokens.spacing(props.height),
127
+ minWidth: require_tokens.spacing(props.minWidth ?? props.minSize) ?? 0,
128
+ maxWidth: require_tokens.spacing(props.maxWidth ?? props.maxSize) ?? "100%",
129
+ minHeight: require_tokens.spacing(props.minHeight ?? props.minSize),
130
+ maxHeight: require_tokens.spacing(props.maxHeight ?? props.maxSize),
131
+ flex: props.flex,
132
+ flexGrow: props.weight,
133
+ aspectRatio: props.aspectRatio,
134
+ overflow,
135
+ boxShadow: props.shadow ? require_tokens.SHADOW_SM : void 0,
136
+ boxSizing: "border-box"
137
+ });
138
+ }
139
+
140
+ //#endregion
141
+ exports.ALIGN_CSS = ALIGN_CSS;
142
+ exports.FOCUS_RING = FOCUS_RING;
143
+ exports.JUSTIFY_CSS = JUSTIFY_CSS;
144
+ exports.VISUALLY_HIDDEN = VISUALLY_HIDDEN;
145
+ exports.defined = defined;
146
+ exports.jsonEqual = jsonEqual;
147
+ exports.layoutStyle = layoutStyle;
148
+ exports.lineClamp = lineClamp;
149
+ exports.px = px;
150
+ exports.radiusStyle = radiusStyle;
151
+ //# sourceMappingURL=style-helpers.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style-helpers.cjs","names":["radius","spacing","backgroundColor","borderColor","SHADOW_SM"],"sources":["../../../src/generative-ui/standard/style-helpers.ts"],"sourcesContent":["// Framework-free style helpers of the standard components. Each framework\n// binds the returned style objects to its own elements.\nimport {\n SHADOW_SM,\n backgroundColor,\n borderColor,\n radius,\n spacing,\n} from \"./tokens\";\nimport type { ALIGN, JUSTIFY } from \"./tokens\";\nimport type { LayoutProps } from \"./layout\";\n\n/** An inline style object, with camelCase CSS properties as keys. */\nexport type StyleMap = Record<string, string | number | undefined>;\n\n/**\n * Equal when the JSON is equal. Use it as the equality check of a computed\n * value over agent data, so a new object with the same content does not\n * trigger a redraw.\n */\nexport const jsonEqual = (a: unknown, b: unknown) =>\n JSON.stringify(a) === JSON.stringify(b);\n\n/** Hides an element on screen. Screen readers still read it. */\nexport const VISUALLY_HIDDEN: StyleMap = {\n position: \"absolute\",\n width: \"1px\",\n height: \"1px\",\n padding: 0,\n margin: \"-1px\",\n overflow: \"hidden\",\n clipPath: \"inset(50%)\",\n whiteSpace: \"nowrap\",\n border: 0,\n};\n\n/** The outline of a focused control, for a `:focus-visible` rule. */\nexport const FOCUS_RING = \"2px solid var(--a2ui-color-focus, #0285ff)\";\n\n/**\n * Cuts the text after `lines` lines, with an ellipsis.\n *\n * @param lines - The number of lines to show.\n */\nexport function lineClamp(lines: number): StyleMap {\n return {\n display: \"-webkit-box\",\n WebkitLineClamp: lines,\n WebkitBoxOrient: \"vertical\",\n overflow: \"hidden\",\n };\n}\n\n/** The `align-items` value of each `align` prop value. */\nexport const ALIGN_CSS: Record<(typeof ALIGN)[number], string> = {\n start: \"flex-start\",\n end: \"flex-end\",\n center: \"center\",\n baseline: \"baseline\",\n stretch: \"stretch\",\n};\n\n/** The `justify-content` value of each `justify` prop value. */\nexport const JUSTIFY_CSS: Record<(typeof JUSTIFY)[number], string> = {\n start: \"flex-start\",\n end: \"flex-end\",\n center: \"center\",\n spaceBetween: \"space-between\",\n spaceAround: \"space-around\",\n spaceEvenly: \"space-evenly\",\n stretch: \"stretch\",\n};\n\n/**\n * A CSS length: pixels when `value` is a number, the raw CSS when it is a\n * string, and `undefined` when it is not set.\n *\n * @example px(12) // \"12px\"\n */\nexport function px(value: number | string | undefined) {\n if (value === undefined) return undefined;\n return typeof value === \"number\" ? `${value}px` : value;\n}\n\n/**\n * The CSS of a `radius` prop: one radius for all corners, or one radius for\n * each corner.\n *\n * @param value - A radius token, a raw CSS value, or an object of corners.\n */\nexport function radiusStyle(value: LayoutProps[\"radius\"]): StyleMap {\n if (typeof value === \"string\" || typeof value === \"number\") {\n return { borderRadius: radius(value) };\n }\n if (value === undefined) return {};\n return {\n borderTopLeftRadius: radius(value.topLeft),\n borderTopRightRadius: radius(value.topRight),\n borderBottomLeftRadius: radius(value.bottomLeft),\n borderBottomRightRadius: radius(value.bottomRight),\n };\n}\n\n/**\n * A copy of `style` without the undefined entries, so a later spread never\n * erases a value. An undefined longhand next to a shorthand is a removal:\n * clearing `row-gap` resets the `gap` shorthand in real browsers.\n */\nexport function defined(style: StyleMap): StyleMap {\n const result: StyleMap = {};\n for (const [key, value] of Object.entries(style)) {\n if (value !== undefined) result[key] = value;\n }\n return result;\n}\n\n/**\n * The `gap` of the layout props, with `rowGap` and `columnGap` winning over\n * it. A renderer can apply a style object in sorted key order (Angular does),\n * so `columnGap` would come before the `gap` shorthand and lose to it. A\n * longhand therefore sets both longhands and no shorthand.\n */\nfunction gapStyle(props: LayoutProps): StyleMap {\n const gap = spacing(props.gap) ?? (props.disableAutoSpacing ? 0 : undefined);\n const rowGap = spacing(props.rowGap);\n const columnGap = spacing(props.columnGap);\n if (rowGap === undefined && columnGap === undefined) return { gap };\n return { rowGap: rowGap ?? gap, columnGap: columnGap ?? gap };\n}\n\n/**\n * The flex container CSS of the shared layout props (`align`, `gap`,\n * `padding`, `radius`, sizes and the rest). An unset prop gives no CSS.\n *\n * @param props - The layout props of a container component.\n */\nexport function layoutStyle(props: LayoutProps): StyleMap {\n const overflow = props.scrollable\n ? \"auto\"\n : props.clip\n ? \"hidden\"\n : undefined;\n return defined({\n display: props.inline ? \"inline-flex\" : \"flex\",\n alignItems: props.align ? ALIGN_CSS[props.align] : undefined,\n justifyContent: props.justify ? JUSTIFY_CSS[props.justify] : undefined,\n flexWrap: props.wrap,\n ...gapStyle(props),\n padding: props.flush ? 0 : spacing(props.padding),\n background: backgroundColor(props.background),\n border: props.border\n ? `1px solid ${borderColor(props.borderColor ?? \"default\")}`\n : undefined,\n ...radiusStyle(props.radius),\n width: spacing(props.width),\n height: spacing(props.height),\n // A container can shrink below its content and never gets wider than\n // its parent.\n minWidth: spacing(props.minWidth ?? props.minSize) ?? 0,\n maxWidth: spacing(props.maxWidth ?? props.maxSize) ?? \"100%\",\n minHeight: spacing(props.minHeight ?? props.minSize),\n maxHeight: spacing(props.maxHeight ?? props.maxSize),\n flex: props.flex,\n flexGrow: props.weight,\n aspectRatio: props.aspectRatio,\n overflow,\n boxShadow: props.shadow ? SHADOW_SM : undefined,\n boxSizing: \"border-box\",\n });\n}\n"],"mappings":";;;;;;;;AAoBA,MAAa,aAAa,GAAY,MACpC,KAAK,UAAU,EAAE,KAAK,KAAK,UAAU,EAAE;;AAGzC,MAAa,kBAA4B;CACvC,UAAU;CACV,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,UAAU;CACV,UAAU;CACV,YAAY;CACZ,QAAQ;CACT;;AAGD,MAAa,aAAa;;;;;;AAO1B,SAAgB,UAAU,OAAyB;AACjD,QAAO;EACL,SAAS;EACT,iBAAiB;EACjB,iBAAiB;EACjB,UAAU;EACX;;;AAIH,MAAa,YAAoD;CAC/D,OAAO;CACP,KAAK;CACL,QAAQ;CACR,UAAU;CACV,SAAS;CACV;;AAGD,MAAa,cAAwD;CACnE,OAAO;CACP,KAAK;CACL,QAAQ;CACR,cAAc;CACd,aAAa;CACb,aAAa;CACb,SAAS;CACV;;;;;;;AAQD,SAAgB,GAAG,OAAoC;AACrD,KAAI,UAAU,OAAW,QAAO;AAChC,QAAO,OAAO,UAAU,WAAW,GAAG,MAAM,MAAM;;;;;;;;AASpD,SAAgB,YAAY,OAAwC;AAClE,KAAI,OAAO,UAAU,YAAY,OAAO,UAAU,SAChD,QAAO,EAAE,cAAcA,sBAAO,MAAM,EAAE;AAExC,KAAI,UAAU,OAAW,QAAO,EAAE;AAClC,QAAO;EACL,qBAAqBA,sBAAO,MAAM,QAAQ;EAC1C,sBAAsBA,sBAAO,MAAM,SAAS;EAC5C,wBAAwBA,sBAAO,MAAM,WAAW;EAChD,yBAAyBA,sBAAO,MAAM,YAAY;EACnD;;;;;;;AAQH,SAAgB,QAAQ,OAA2B;CACjD,MAAM,SAAmB,EAAE;AAC3B,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,KAAI,UAAU,OAAW,QAAO,OAAO;AAEzC,QAAO;;;;;;;;AAST,SAAS,SAAS,OAA8B;CAC9C,MAAM,MAAMC,uBAAQ,MAAM,IAAI,KAAK,MAAM,qBAAqB,IAAI;CAClE,MAAM,SAASA,uBAAQ,MAAM,OAAO;CACpC,MAAM,YAAYA,uBAAQ,MAAM,UAAU;AAC1C,KAAI,WAAW,UAAa,cAAc,OAAW,QAAO,EAAE,KAAK;AACnE,QAAO;EAAE,QAAQ,UAAU;EAAK,WAAW,aAAa;EAAK;;;;;;;;AAS/D,SAAgB,YAAY,OAA8B;CACxD,MAAM,WAAW,MAAM,aACnB,SACA,MAAM,OACJ,WACA;AACN,QAAO,QAAQ;EACb,SAAS,MAAM,SAAS,gBAAgB;EACxC,YAAY,MAAM,QAAQ,UAAU,MAAM,SAAS;EACnD,gBAAgB,MAAM,UAAU,YAAY,MAAM,WAAW;EAC7D,UAAU,MAAM;EAChB,GAAG,SAAS,MAAM;EAClB,SAAS,MAAM,QAAQ,IAAIA,uBAAQ,MAAM,QAAQ;EACjD,YAAYC,+BAAgB,MAAM,WAAW;EAC7C,QAAQ,MAAM,SACV,aAAaC,2BAAY,MAAM,eAAe,UAAU,KACxD;EACJ,GAAG,YAAY,MAAM,OAAO;EAC5B,OAAOF,uBAAQ,MAAM,MAAM;EAC3B,QAAQA,uBAAQ,MAAM,OAAO;EAG7B,UAAUA,uBAAQ,MAAM,YAAY,MAAM,QAAQ,IAAI;EACtD,UAAUA,uBAAQ,MAAM,YAAY,MAAM,QAAQ,IAAI;EACtD,WAAWA,uBAAQ,MAAM,aAAa,MAAM,QAAQ;EACpD,WAAWA,uBAAQ,MAAM,aAAa,MAAM,QAAQ;EACpD,MAAM,MAAM;EACZ,UAAU,MAAM;EAChB,aAAa,MAAM;EACnB;EACA,WAAW,MAAM,SAASG,2BAAY;EACtC,WAAW;EACZ,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { ALIGN, JUSTIFY } from "./tokens.cjs";
2
+ import { LayoutProps } from "./layout.cjs";
3
+
4
+ //#region src/generative-ui/standard/style-helpers.d.ts
5
+ /** An inline style object, with camelCase CSS properties as keys. */
6
+ type StyleMap = Record<string, string | number | undefined>;
7
+ /**
8
+ * Equal when the JSON is equal. Use it as the equality check of a computed
9
+ * value over agent data, so a new object with the same content does not
10
+ * trigger a redraw.
11
+ */
12
+ declare const jsonEqual: (a: unknown, b: unknown) => boolean;
13
+ /** Hides an element on screen. Screen readers still read it. */
14
+ declare const VISUALLY_HIDDEN: StyleMap;
15
+ /** The outline of a focused control, for a `:focus-visible` rule. */
16
+ declare const FOCUS_RING = "2px solid var(--a2ui-color-focus, #0285ff)";
17
+ /**
18
+ * Cuts the text after `lines` lines, with an ellipsis.
19
+ *
20
+ * @param lines - The number of lines to show.
21
+ */
22
+ declare function lineClamp(lines: number): StyleMap;
23
+ /** The `align-items` value of each `align` prop value. */
24
+ declare const ALIGN_CSS: Record<(typeof ALIGN)[number], string>;
25
+ /** The `justify-content` value of each `justify` prop value. */
26
+ declare const JUSTIFY_CSS: Record<(typeof JUSTIFY)[number], string>;
27
+ /**
28
+ * A CSS length: pixels when `value` is a number, the raw CSS when it is a
29
+ * string, and `undefined` when it is not set.
30
+ *
31
+ * @example px(12) // "12px"
32
+ */
33
+ declare function px(value: number | string | undefined): string | undefined;
34
+ /**
35
+ * The CSS of a `radius` prop: one radius for all corners, or one radius for
36
+ * each corner.
37
+ *
38
+ * @param value - A radius token, a raw CSS value, or an object of corners.
39
+ */
40
+ declare function radiusStyle(value: LayoutProps["radius"]): StyleMap;
41
+ /**
42
+ * A copy of `style` without the undefined entries, so a later spread never
43
+ * erases a value. An undefined longhand next to a shorthand is a removal:
44
+ * clearing `row-gap` resets the `gap` shorthand in real browsers.
45
+ */
46
+ declare function defined(style: StyleMap): StyleMap;
47
+ /**
48
+ * The flex container CSS of the shared layout props (`align`, `gap`,
49
+ * `padding`, `radius`, sizes and the rest). An unset prop gives no CSS.
50
+ *
51
+ * @param props - The layout props of a container component.
52
+ */
53
+ declare function layoutStyle(props: LayoutProps): StyleMap;
54
+ //#endregion
55
+ export { ALIGN_CSS, FOCUS_RING, JUSTIFY_CSS, StyleMap, VISUALLY_HIDDEN, defined, jsonEqual, layoutStyle, lineClamp, px, radiusStyle };
56
+ //# sourceMappingURL=style-helpers.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style-helpers.d.cts","names":[],"sources":["../../../src/generative-ui/standard/style-helpers.ts"],"mappings":";;;;;KAaY,QAAA,GAAW,MAAA;AAAvB;;;;;AAAA,cAOa,SAAA,GAAa,CAAA,WAAY,CAAA;;cAIzB,eAAA,EAAiB,QAAA;;cAajB,UAAA;AAbb;;;;;AAAA,iBAoBgB,SAAA,CAAU,KAAA,WAAgB,QAAA;;cAU7B,SAAA,EAAW,MAAA,SAAe,KAAA;;cAS1B,WAAA,EAAa,MAAA,SAAe,OAAA;AAnBzC;;;;;AAUA;AAVA,iBAmCgB,EAAA,CAAG,KAAA;;;;AAhBnB;;;iBA2BgB,WAAA,CAAY,KAAA,EAAO,WAAA,aAAwB,QAAA;;AAX3D;;;;iBA6BgB,OAAA,CAAQ,KAAA,EAAO,QAAA,GAAW,QAAA;AAlB1C;;;;;;AAAA,iBA8CgB,WAAA,CAAY,KAAA,EAAO,WAAA,GAAc,QAAA"}