@puckeditor/plugin-ai 0.1.0-canary.2e4dc235 → 0.1.0-canary.2ef56cc2
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/index.css +74 -33
- package/dist/index.js +109 -88
- package/dist/index.mjs +97 -76
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -602,13 +602,13 @@ p {
|
|
|
602
602
|
}
|
|
603
603
|
|
|
604
604
|
/* css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Page/Page.module.css/#css-module-data */
|
|
605
|
-
.
|
|
605
|
+
._Page_1pzwy_1 {
|
|
606
606
|
display: flex;
|
|
607
607
|
flex-direction: column;
|
|
608
608
|
height: 100%;
|
|
609
609
|
overflow: hidden;
|
|
610
610
|
}
|
|
611
|
-
._Page-
|
|
611
|
+
._Page-masthead_1pzwy_8 {
|
|
612
612
|
align-items: center;
|
|
613
613
|
display: flex;
|
|
614
614
|
gap: 16px;
|
|
@@ -617,43 +617,75 @@ p {
|
|
|
617
617
|
border-bottom: 1px solid var(--puck-color-grey-10);
|
|
618
618
|
min-height: 64px;
|
|
619
619
|
}
|
|
620
|
-
._Page-
|
|
620
|
+
._Page-crumbs_1pzwy_18 {
|
|
621
621
|
display: flex;
|
|
622
622
|
gap: 32px;
|
|
623
623
|
}
|
|
624
|
-
._Page-
|
|
624
|
+
._Page-crumb_1pzwy_18 {
|
|
625
625
|
color: var(--puck-color-grey-05);
|
|
626
626
|
position: relative;
|
|
627
627
|
}
|
|
628
|
-
._Page-
|
|
628
|
+
._Page-crumbLink_1pzwy_28 {
|
|
629
629
|
color: var(--puck-color-grey-05);
|
|
630
630
|
text-decoration: none;
|
|
631
631
|
}
|
|
632
|
-
._Page-
|
|
632
|
+
._Page-crumbLink_1pzwy_28:hover {
|
|
633
633
|
color: var(--puck-color-azure-04);
|
|
634
634
|
}
|
|
635
|
-
._Page-
|
|
635
|
+
._Page-crumb_1pzwy_18:last-of-type {
|
|
636
636
|
color: var(--puck-color-grey-01);
|
|
637
637
|
font-weight: 600;
|
|
638
638
|
}
|
|
639
|
-
._Page-
|
|
639
|
+
._Page-crumb_1pzwy_18::before {
|
|
640
640
|
position: absolute;
|
|
641
641
|
content: "/";
|
|
642
642
|
left: -19px;
|
|
643
643
|
color: var(--puck-color-grey-09);
|
|
644
644
|
font-weight: 400;
|
|
645
645
|
}
|
|
646
|
-
._Page-
|
|
646
|
+
._Page-crumb_1pzwy_18:first-of-type::before {
|
|
647
647
|
display: none;
|
|
648
648
|
}
|
|
649
|
-
._Page-
|
|
649
|
+
._Page-crumb_1pzwy_18 {
|
|
650
650
|
color: var(--puck-color-grey-05);
|
|
651
651
|
position: relative;
|
|
652
652
|
text-decoration: none;
|
|
653
653
|
}
|
|
654
|
-
._Page-
|
|
654
|
+
._Page-actions_1pzwy_60 {
|
|
655
655
|
margin-left: auto;
|
|
656
656
|
}
|
|
657
|
+
._Page-footer_1pzwy_64 {
|
|
658
|
+
border-top: 1px solid var(--puck-color-grey-10);
|
|
659
|
+
padding: 16px 24px;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/* css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Pagination/Pagination.module.css/#css-module-data */
|
|
663
|
+
._Pagination_1okv2_1 {
|
|
664
|
+
align-items: baseline;
|
|
665
|
+
display: flex;
|
|
666
|
+
gap: 4px;
|
|
667
|
+
}
|
|
668
|
+
._PaginationButton_1okv2_8 {
|
|
669
|
+
align-items: center;
|
|
670
|
+
border-radius: 4px;
|
|
671
|
+
color: var(--puck-color-grey-05);
|
|
672
|
+
display: flex;
|
|
673
|
+
justify-content: center;
|
|
674
|
+
text-decoration: none;
|
|
675
|
+
min-width: 40px;
|
|
676
|
+
height: 40px;
|
|
677
|
+
}
|
|
678
|
+
._PaginationButton--isActive_1okv2_20 {
|
|
679
|
+
background-color: var(--puck-color-azure-11);
|
|
680
|
+
color: var(--puck-color-azure-04);
|
|
681
|
+
}
|
|
682
|
+
._PaginationButton_1okv2_8:hover {
|
|
683
|
+
background-color: var(--puck-color-azure-11);
|
|
684
|
+
color: var(--puck-color-azure-04);
|
|
685
|
+
}
|
|
686
|
+
._Pagination-ellipsis_1okv2_30 {
|
|
687
|
+
color: var(--puck-color-grey-05);
|
|
688
|
+
}
|
|
657
689
|
|
|
658
690
|
/* css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Section/Section.module.css/#css-module-data */
|
|
659
691
|
._Section-inner_1uwo0_1 {
|
|
@@ -737,23 +769,26 @@ p {
|
|
|
737
769
|
}
|
|
738
770
|
|
|
739
771
|
/* css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Table/Table.module.css/#css-module-data */
|
|
740
|
-
.
|
|
772
|
+
._Table_1w0os_1 {
|
|
741
773
|
color: black;
|
|
742
774
|
display: flex;
|
|
743
775
|
flex-direction: column;
|
|
744
776
|
flex-grow: 1;
|
|
777
|
+
overflow-y: auto;
|
|
745
778
|
}
|
|
746
|
-
._Table-
|
|
779
|
+
._Table-filters_1w0os_9 {
|
|
747
780
|
margin: 16px;
|
|
748
781
|
}
|
|
749
|
-
._Table-
|
|
782
|
+
._Table-inner_1w0os_13 {
|
|
750
783
|
text-align: left;
|
|
751
784
|
}
|
|
752
|
-
._Table-
|
|
785
|
+
._Table-table_1w0os_17 {
|
|
786
|
+
color: var(--puck-color-grey-02);
|
|
787
|
+
font-size: var(--puck-font-size-xxs);
|
|
753
788
|
position: relative;
|
|
754
789
|
width: 100%;
|
|
755
790
|
}
|
|
756
|
-
.
|
|
791
|
+
._Table_1w0os_1 thead {
|
|
757
792
|
background: white;
|
|
758
793
|
font-size: var(--puck-font-size-xxs);
|
|
759
794
|
position: sticky;
|
|
@@ -761,55 +796,58 @@ p {
|
|
|
761
796
|
white-space: nowrap;
|
|
762
797
|
z-index: 1;
|
|
763
798
|
}
|
|
764
|
-
.
|
|
799
|
+
._Table_1w0os_1 thead::after {
|
|
765
800
|
content: "";
|
|
766
801
|
position: absolute;
|
|
767
802
|
height: 1px;
|
|
768
803
|
width: 100%;
|
|
769
|
-
background-color: var(--puck-color-grey-
|
|
804
|
+
background-color: var(--puck-color-grey-10);
|
|
770
805
|
}
|
|
771
|
-
.
|
|
806
|
+
._Table_1w0os_1 tbody tr {
|
|
772
807
|
z-index: 0;
|
|
773
808
|
}
|
|
774
|
-
.
|
|
775
|
-
background:
|
|
776
|
-
font-weight:
|
|
809
|
+
._Table_1w0os_1 th {
|
|
810
|
+
background: var(--puck-color-grey-12);
|
|
811
|
+
font-weight: 400;
|
|
777
812
|
padding-left: 24px;
|
|
778
813
|
padding-right: 24px;
|
|
779
|
-
padding-bottom:
|
|
780
|
-
padding-top:
|
|
814
|
+
padding-bottom: 12px;
|
|
815
|
+
padding-top: 12px;
|
|
781
816
|
}
|
|
782
817
|
@media (--standard-viewport) {
|
|
783
|
-
.
|
|
818
|
+
._Table_1w0os_1 th {
|
|
784
819
|
padding-left: 32px;
|
|
785
820
|
padding-right: 32px;
|
|
786
821
|
}
|
|
787
822
|
}
|
|
788
|
-
.
|
|
823
|
+
._Table_1w0os_1 td {
|
|
789
824
|
border-bottom: 1px solid var(--puck-color-grey-10);
|
|
790
825
|
padding-left: 24px;
|
|
791
826
|
padding-right: 24px;
|
|
792
|
-
padding-bottom:
|
|
793
|
-
padding-top:
|
|
827
|
+
padding-bottom: 16px;
|
|
828
|
+
padding-top: 16px;
|
|
794
829
|
white-space: nowrap;
|
|
795
830
|
}
|
|
796
|
-
.
|
|
831
|
+
._Table_1w0os_1 td:not(:first-of-type) {
|
|
832
|
+
color: var(--puck-color-grey-05);
|
|
833
|
+
}
|
|
834
|
+
._Table_1w0os_1 tbody tr:last-of-type td {
|
|
797
835
|
border-bottom: none;
|
|
798
836
|
}
|
|
799
837
|
@media (--standard-viewport) {
|
|
800
|
-
.
|
|
838
|
+
._Table_1w0os_1 td {
|
|
801
839
|
padding-left: 32px;
|
|
802
840
|
padding-right: 32px;
|
|
803
841
|
}
|
|
804
842
|
}
|
|
805
|
-
._Table-
|
|
843
|
+
._Table-footer_1w0os_85 {
|
|
806
844
|
border-top: 1px solid var(--puck-color-grey-09);
|
|
807
845
|
}
|
|
808
|
-
._Table--
|
|
846
|
+
._Table--clickableRows_1w0os_89 tbody tr:hover {
|
|
809
847
|
background: var(--puck-color-azure-12);
|
|
810
848
|
cursor: pointer;
|
|
811
849
|
}
|
|
812
|
-
._Table-
|
|
850
|
+
._Table-placeholder_1w0os_94 {
|
|
813
851
|
align-items: center;
|
|
814
852
|
color: var(--puck-color-grey-06);
|
|
815
853
|
justify-content: center;
|
|
@@ -819,6 +857,9 @@ p {
|
|
|
819
857
|
width: 100%;
|
|
820
858
|
height: 100%;
|
|
821
859
|
}
|
|
860
|
+
._Table-loader_1w0os_105 {
|
|
861
|
+
padding: 16px 24px;
|
|
862
|
+
}
|
|
822
863
|
|
|
823
864
|
/* css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/VerticalSpace/VerticalSpace.module.css/#css-module-data */
|
|
824
865
|
._VerticalSpace_1tjaw_1 {
|
package/dist/index.js
CHANGED
|
@@ -20681,7 +20681,7 @@ function useChat(_a17 = {}) {
|
|
|
20681
20681
|
|
|
20682
20682
|
// src/components/Chat/index.tsx
|
|
20683
20683
|
var import_puck2 = require("@measured/puck");
|
|
20684
|
-
var
|
|
20684
|
+
var import_react20 = require("react");
|
|
20685
20685
|
var import_ulid = require("ulid");
|
|
20686
20686
|
|
|
20687
20687
|
// ../utils/lib/get-class-name-factory.ts
|
|
@@ -20721,7 +20721,7 @@ var styles_module_default = { "Chat": "_Chat_1mv7h_1", "Chat-header": "_Chat-hea
|
|
|
20721
20721
|
|
|
20722
20722
|
// src/components/ChatBody/index.tsx
|
|
20723
20723
|
init_react_import();
|
|
20724
|
-
var
|
|
20724
|
+
var import_react18 = require("react");
|
|
20725
20725
|
var import_use_stick_to_bottom = require("use-stick-to-bottom");
|
|
20726
20726
|
var import_react_markdown = __toESM(require("react-markdown"));
|
|
20727
20727
|
|
|
@@ -21182,12 +21182,28 @@ init_react_import();
|
|
|
21182
21182
|
|
|
21183
21183
|
// css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Page/Page.module.css#css-module
|
|
21184
21184
|
init_react_import();
|
|
21185
|
-
var Page_module_default = { "Page": "
|
|
21185
|
+
var Page_module_default = { "Page": "_Page_1pzwy_1", "Page-masthead": "_Page-masthead_1pzwy_8", "Page-crumbs": "_Page-crumbs_1pzwy_18", "Page-crumb": "_Page-crumb_1pzwy_18", "Page-crumbLink": "_Page-crumbLink_1pzwy_28", "Page-actions": "_Page-actions_1pzwy_60", "Page-footer": "_Page-footer_1pzwy_64" };
|
|
21186
21186
|
|
|
21187
21187
|
// ../platform-client/components/Page/Page.tsx
|
|
21188
21188
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
21189
21189
|
var cx2 = getClassNameFactory2("Page", Page_module_default);
|
|
21190
21190
|
|
|
21191
|
+
// ../platform-client/components/Pagination/index.ts
|
|
21192
|
+
init_react_import();
|
|
21193
|
+
|
|
21194
|
+
// ../platform-client/components/Pagination/Pagination.tsx
|
|
21195
|
+
init_react_import();
|
|
21196
|
+
var import_react13 = require("react");
|
|
21197
|
+
|
|
21198
|
+
// css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Pagination/Pagination.module.css#css-module
|
|
21199
|
+
init_react_import();
|
|
21200
|
+
var Pagination_module_default = { "Pagination": "_Pagination_1okv2_1", "PaginationButton": "_PaginationButton_1okv2_8", "PaginationButton--isActive": "_PaginationButton--isActive_1okv2_20", "Pagination-ellipsis": "_Pagination-ellipsis_1okv2_30" };
|
|
21201
|
+
|
|
21202
|
+
// ../platform-client/components/Pagination/Pagination.tsx
|
|
21203
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
21204
|
+
var cx3 = getClassNameFactory2("Pagination", Pagination_module_default);
|
|
21205
|
+
var cxButton = getClassNameFactory2("PaginationButton", Pagination_module_default);
|
|
21206
|
+
|
|
21191
21207
|
// ../platform-client/components/Section/index.ts
|
|
21192
21208
|
init_react_import();
|
|
21193
21209
|
|
|
@@ -21199,7 +21215,7 @@ init_react_import();
|
|
|
21199
21215
|
var Section_module_default = { "Section-inner": "_Section-inner_1uwo0_1", "Section--flush": "_Section--flush_1uwo0_8", "Section": "_Section_1uwo0_1", "Section--full": "_Section--full_1uwo0_17" };
|
|
21200
21216
|
|
|
21201
21217
|
// ../platform-client/components/Section/Section.tsx
|
|
21202
|
-
var
|
|
21218
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
21203
21219
|
var getClassName12 = getClassNameFactory2("Section", Section_module_default);
|
|
21204
21220
|
|
|
21205
21221
|
// ../platform-client/components/StatusTag/index.ts
|
|
@@ -21219,25 +21235,25 @@ init_react_import();
|
|
|
21219
21235
|
var Tag_module_default = { "Tag": "_Tag_1baze_1", "Tag--colorBlue": "_Tag--colorBlue_1baze_19", "Tag--colorGreen": "_Tag--colorGreen_1baze_23", "Tag--colorRed": "_Tag--colorRed_1baze_27", "Tag--colorMuted": "_Tag--colorMuted_1baze_31", "Tag-sprite": "_Tag-sprite_1baze_35", "Tag--pulse": "_Tag--pulse_1baze_39", "pulse": "_pulse_1baze_1" };
|
|
21220
21236
|
|
|
21221
21237
|
// ../platform-client/components/Tag/Tag.tsx
|
|
21222
|
-
var
|
|
21238
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
21223
21239
|
var getClassName13 = getClassNameFactory2("Tag", Tag_module_default);
|
|
21224
21240
|
|
|
21225
21241
|
// ../platform-client/components/StatusTag/StatusTag.tsx
|
|
21226
|
-
var
|
|
21242
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
21227
21243
|
|
|
21228
21244
|
// ../platform-client/components/Table/index.ts
|
|
21229
21245
|
init_react_import();
|
|
21230
21246
|
|
|
21231
21247
|
// ../platform-client/components/Table/Table.tsx
|
|
21232
21248
|
init_react_import();
|
|
21233
|
-
var
|
|
21249
|
+
var import_react14 = require("react");
|
|
21234
21250
|
|
|
21235
21251
|
// css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Table/Table.module.css#css-module
|
|
21236
21252
|
init_react_import();
|
|
21237
|
-
var Table_module_default = { "Table": "
|
|
21253
|
+
var Table_module_default = { "Table": "_Table_1w0os_1", "Table-filters": "_Table-filters_1w0os_9", "Table-inner": "_Table-inner_1w0os_13", "Table-table": "_Table-table_1w0os_17", "Table-footer": "_Table-footer_1w0os_85", "Table--clickableRows": "_Table--clickableRows_1w0os_89", "Table-placeholder": "_Table-placeholder_1w0os_94", "Table-loader": "_Table-loader_1w0os_105" };
|
|
21238
21254
|
|
|
21239
21255
|
// ../platform-client/components/Table/Table.tsx
|
|
21240
|
-
var
|
|
21256
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
21241
21257
|
var getClassName14 = get_class_name_factory_default("Table", Table_module_default);
|
|
21242
21258
|
|
|
21243
21259
|
// ../platform-client/components/Textarea/index.tsx
|
|
@@ -21255,14 +21271,14 @@ init_react_import();
|
|
|
21255
21271
|
var VerticalSpace_module_default = { "VerticalSpace": "_VerticalSpace_1tjaw_1", "VerticalSpace--size4": "_VerticalSpace--size4_1tjaw_5", "VerticalSpace--size8": "_VerticalSpace--size8_1tjaw_9", "VerticalSpace--size16": "_VerticalSpace--size16_1tjaw_13", "VerticalSpace--size32": "_VerticalSpace--size32_1tjaw_17", "VerticalSpace--size40": "_VerticalSpace--size40_1tjaw_21", "VerticalSpace--size48": "_VerticalSpace--size48_1tjaw_25", "VerticalSpace--size56": "_VerticalSpace--size56_1tjaw_29", "VerticalSpace--size96": "_VerticalSpace--size96_1tjaw_33", "VerticalSpace--size128": "_VerticalSpace--size128_1tjaw_37" };
|
|
21256
21272
|
|
|
21257
21273
|
// ../platform-client/components/VerticalSpace/VerticalSpace.tsx
|
|
21258
|
-
var
|
|
21274
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
21259
21275
|
var getClassName15 = get_class_name_factory_default("VerticalSpace", VerticalSpace_module_default);
|
|
21260
21276
|
|
|
21261
21277
|
// ../platform-client/context/editor.tsx
|
|
21262
21278
|
init_react_import();
|
|
21263
|
-
var
|
|
21264
|
-
var
|
|
21265
|
-
var ctx = (0,
|
|
21279
|
+
var import_react15 = require("react");
|
|
21280
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
21281
|
+
var ctx = (0, import_react15.createContext)({});
|
|
21266
21282
|
|
|
21267
21283
|
// css-module:/home/runner/work/puck-platform/puck-platform/packages/plugin-ai/src/components/ChatBody/styles.module.css#css-module
|
|
21268
21284
|
init_react_import();
|
|
@@ -21270,15 +21286,15 @@ var styles_module_default3 = { "Chat": "_Chat_14j71_1", "Chat-inner": "_Chat-inn
|
|
|
21270
21286
|
|
|
21271
21287
|
// src/components/PromptForm/index.tsx
|
|
21272
21288
|
init_react_import();
|
|
21273
|
-
var
|
|
21289
|
+
var import_react16 = require("react");
|
|
21274
21290
|
|
|
21275
21291
|
// css-module:/home/runner/work/puck-platform/puck-platform/packages/plugin-ai/src/components/PromptForm/styles.module.css#css-module
|
|
21276
21292
|
init_react_import();
|
|
21277
21293
|
var styles_module_default4 = { "PromptForm": "_PromptForm_136g1_1", "PromptForm-inner": "_PromptForm-inner_136g1_8", "PromptForm--dark": "_PromptForm--dark_136g1_14", "PromptForm--glow": "_PromptForm--glow_136g1_19", "PromptForm-glow": "_PromptForm-glow_136g1_19", "loop": "_loop_136g1_1", "PromptForm-formInner": "_PromptForm-formInner_136g1_60", "PromptForm-input": "_PromptForm-input_136g1_64", "PromptForm--disabled": "_PromptForm--disabled_136g1_92", "PromptForm-helper": "_PromptForm-helper_136g1_97", "PromptForm-actions": "_PromptForm-actions_136g1_107", "PromptForm-actionsLeft": "_PromptForm-actionsLeft_136g1_118", "PromptForm-actionsRight": "_PromptForm-actionsRight_136g1_124", "PromptForm-actionSubmit": "_PromptForm-actionSubmit_136g1_128", "PromptForm--isDisabled": "_PromptForm--isDisabled_136g1_147", "PromptForm--isLoading": "_PromptForm--isLoading_136g1_152" };
|
|
21278
21294
|
|
|
21279
21295
|
// src/components/PromptForm/index.tsx
|
|
21280
|
-
var
|
|
21281
|
-
var
|
|
21296
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
21297
|
+
var cx4 = getClassNameFactory2("PromptForm", styles_module_default4);
|
|
21282
21298
|
function PromptForm({
|
|
21283
21299
|
actions,
|
|
21284
21300
|
colorScheme = "light",
|
|
@@ -21290,8 +21306,8 @@ function PromptForm({
|
|
|
21290
21306
|
isLoading,
|
|
21291
21307
|
placeholder = "Create a page for..."
|
|
21292
21308
|
}) {
|
|
21293
|
-
const hasSetInitialPrompt = (0,
|
|
21294
|
-
const [prompt, setPrompt] = (0,
|
|
21309
|
+
const hasSetInitialPrompt = (0, import_react16.useRef)(false);
|
|
21310
|
+
const [prompt, setPrompt] = (0, import_react16.useState)("");
|
|
21295
21311
|
const sendPrompt = () => {
|
|
21296
21312
|
if (isLoading || isDisabled) return;
|
|
21297
21313
|
if (handleSubmit) {
|
|
@@ -21299,7 +21315,7 @@ function PromptForm({
|
|
|
21299
21315
|
}
|
|
21300
21316
|
setPrompt("");
|
|
21301
21317
|
};
|
|
21302
|
-
(0,
|
|
21318
|
+
(0, import_react16.useEffect)(() => {
|
|
21303
21319
|
const currentUrl = new URL(location.href);
|
|
21304
21320
|
const initialPrompt = currentUrl.searchParams.get("initialPrompt");
|
|
21305
21321
|
if (!hasSetInitialPrompt.current && initialPrompt && prompt === "") {
|
|
@@ -21307,31 +21323,31 @@ function PromptForm({
|
|
|
21307
21323
|
setPrompt(initialPrompt);
|
|
21308
21324
|
}
|
|
21309
21325
|
}, [setPrompt]);
|
|
21310
|
-
return /* @__PURE__ */ (0,
|
|
21326
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
21311
21327
|
"div",
|
|
21312
21328
|
{
|
|
21313
|
-
className:
|
|
21329
|
+
className: cx4({
|
|
21314
21330
|
isDisabled,
|
|
21315
21331
|
isLoading,
|
|
21316
21332
|
dark: colorScheme === "dark",
|
|
21317
21333
|
glow
|
|
21318
21334
|
}),
|
|
21319
21335
|
children: [
|
|
21320
|
-
helperText ? /* @__PURE__ */ (0,
|
|
21321
|
-
/* @__PURE__ */ (0,
|
|
21322
|
-
/* @__PURE__ */ (0,
|
|
21323
|
-
/* @__PURE__ */ (0,
|
|
21336
|
+
helperText ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: cx4("helper"), children: helperText }) : null,
|
|
21337
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: cx4("inner"), children: [
|
|
21338
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: cx4("glow") }),
|
|
21339
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
21324
21340
|
"form",
|
|
21325
21341
|
{
|
|
21326
21342
|
onSubmit: (e) => {
|
|
21327
21343
|
e.preventDefault();
|
|
21328
21344
|
sendPrompt();
|
|
21329
21345
|
},
|
|
21330
|
-
children: /* @__PURE__ */ (0,
|
|
21331
|
-
/* @__PURE__ */ (0,
|
|
21346
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: cx4("formInner"), children: [
|
|
21347
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
21332
21348
|
import_react_textarea_autosize.default,
|
|
21333
21349
|
{
|
|
21334
|
-
className:
|
|
21350
|
+
className: cx4("input"),
|
|
21335
21351
|
name: "prompt",
|
|
21336
21352
|
minRows: 2,
|
|
21337
21353
|
placeholder,
|
|
@@ -21352,15 +21368,15 @@ function PromptForm({
|
|
|
21352
21368
|
}
|
|
21353
21369
|
}
|
|
21354
21370
|
),
|
|
21355
|
-
/* @__PURE__ */ (0,
|
|
21356
|
-
/* @__PURE__ */ (0,
|
|
21357
|
-
/* @__PURE__ */ (0,
|
|
21371
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: cx4("actions"), children: [
|
|
21372
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: cx4("actionsLeft"), children: actions }),
|
|
21373
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: cx4("actionsRight"), children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
21358
21374
|
"button",
|
|
21359
21375
|
{
|
|
21360
|
-
className:
|
|
21376
|
+
className: cx4("actionSubmit"),
|
|
21361
21377
|
type: "submit",
|
|
21362
21378
|
disabled: isLoading,
|
|
21363
|
-
children: /* @__PURE__ */ (0,
|
|
21379
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ArrowUp, {})
|
|
21364
21380
|
}
|
|
21365
21381
|
) })
|
|
21366
21382
|
] })
|
|
@@ -21375,13 +21391,13 @@ function PromptForm({
|
|
|
21375
21391
|
|
|
21376
21392
|
// src/lib/context.ts
|
|
21377
21393
|
init_react_import();
|
|
21378
|
-
var
|
|
21379
|
-
var toolStatusContext = (0,
|
|
21394
|
+
var import_react17 = require("react");
|
|
21395
|
+
var toolStatusContext = (0, import_react17.createContext)({});
|
|
21380
21396
|
var ToolStatusProvider = toolStatusContext.Provider;
|
|
21381
21397
|
|
|
21382
21398
|
// src/components/ChatBody/index.tsx
|
|
21383
|
-
var
|
|
21384
|
-
var
|
|
21399
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
21400
|
+
var cx5 = getClassNameFactory2("Chat", styles_module_default3);
|
|
21385
21401
|
var cxMessage = getClassNameFactory2("ChatMessage", styles_module_default3);
|
|
21386
21402
|
function ChatBody({
|
|
21387
21403
|
children,
|
|
@@ -21396,17 +21412,17 @@ function ChatBody({
|
|
|
21396
21412
|
}) {
|
|
21397
21413
|
const { scrollRef, contentRef } = (0, import_use_stick_to_bottom.useStickToBottom)();
|
|
21398
21414
|
const hasMessages = messages && messages.length > 0;
|
|
21399
|
-
return /* @__PURE__ */ (0,
|
|
21400
|
-
children ? /* @__PURE__ */ (0,
|
|
21401
|
-
/* @__PURE__ */ (0,
|
|
21402
|
-
/* @__PURE__ */ (0,
|
|
21403
|
-
status === "submitted" && /* @__PURE__ */ (0,
|
|
21404
|
-
error45 && /* @__PURE__ */ (0,
|
|
21405
|
-
/* @__PURE__ */ (0,
|
|
21406
|
-
handleRetry && /* @__PURE__ */ (0,
|
|
21415
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: cx5({ hasMessages, hasChildren: !!children, hideInput }), children: [
|
|
21416
|
+
children ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: cx5("default"), children }) : null,
|
|
21417
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: cx5("inner"), ref: scrollRef, children: [
|
|
21418
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: cx5("messages"), ref: contentRef, children: messages.toReversed().map((message) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ChatMessage, { message }, message.id)) }),
|
|
21419
|
+
status === "submitted" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: cx5("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Loader, { size: 14 }) }),
|
|
21420
|
+
error45 && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: cx5("error"), children: [
|
|
21421
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: cx5("errorLabel"), children: "Something went wrong." }),
|
|
21422
|
+
handleRetry && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: cx5("errorAction"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(IconButton, { title: "Retry", onClick: handleRetry, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(RotateCcw, { size: "14" }) }) })
|
|
21407
21423
|
] }),
|
|
21408
|
-
/* @__PURE__ */ (0,
|
|
21409
|
-
/* @__PURE__ */ (0,
|
|
21424
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: cx5("form"), children: [
|
|
21425
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
21410
21426
|
PromptForm,
|
|
21411
21427
|
{
|
|
21412
21428
|
glow: !hasMessages,
|
|
@@ -21416,19 +21432,19 @@ function ChatBody({
|
|
|
21416
21432
|
placeholder: "What do you want to build?"
|
|
21417
21433
|
}
|
|
21418
21434
|
),
|
|
21419
|
-
examplePrompts ? /* @__PURE__ */ (0,
|
|
21435
|
+
examplePrompts ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: cx5("examplePrompts"), children: examplePrompts }) : null
|
|
21420
21436
|
] })
|
|
21421
21437
|
] })
|
|
21422
21438
|
] });
|
|
21423
21439
|
}
|
|
21424
21440
|
function ChatMessage({ message }) {
|
|
21425
21441
|
const { role, parts } = message;
|
|
21426
|
-
return /* @__PURE__ */ (0,
|
|
21442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
21427
21443
|
"div",
|
|
21428
21444
|
{
|
|
21429
21445
|
className: cxMessage({ [`${role}Role`]: true }),
|
|
21430
21446
|
"data-message-id": message.id,
|
|
21431
|
-
children: parts.map((part, i) => /* @__PURE__ */ (0,
|
|
21447
|
+
children: parts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
21432
21448
|
ChatMessagePart,
|
|
21433
21449
|
{
|
|
21434
21450
|
part,
|
|
@@ -21444,25 +21460,25 @@ function ChatMessageWrapper({
|
|
|
21444
21460
|
role
|
|
21445
21461
|
}) {
|
|
21446
21462
|
if (role === "assistant") {
|
|
21447
|
-
return /* @__PURE__ */ (0,
|
|
21463
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_react_markdown.default, { children });
|
|
21448
21464
|
}
|
|
21449
|
-
return /* @__PURE__ */ (0,
|
|
21465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children });
|
|
21450
21466
|
}
|
|
21451
21467
|
function ChatMessagePart({
|
|
21452
21468
|
part,
|
|
21453
21469
|
role
|
|
21454
21470
|
}) {
|
|
21455
21471
|
if (part.type === "text") {
|
|
21456
|
-
return /* @__PURE__ */ (0,
|
|
21472
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: cxMessage("text"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ChatMessageWrapper, { role, children: part.text }) });
|
|
21457
21473
|
}
|
|
21458
21474
|
if (part.type === "tool-createPage") {
|
|
21459
|
-
return /* @__PURE__ */ (0,
|
|
21475
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PuckTool, __spreadValues({}, part));
|
|
21460
21476
|
}
|
|
21461
21477
|
if (part.type === "tool-updatePage") {
|
|
21462
|
-
return /* @__PURE__ */ (0,
|
|
21478
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PuckTool, __spreadValues({}, part));
|
|
21463
21479
|
}
|
|
21464
21480
|
if (part.type === "tool-userTool") {
|
|
21465
|
-
return /* @__PURE__ */ (0,
|
|
21481
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PuckTool, __spreadValues({}, part));
|
|
21466
21482
|
}
|
|
21467
21483
|
return null;
|
|
21468
21484
|
}
|
|
@@ -21471,30 +21487,30 @@ function PuckTool({
|
|
|
21471
21487
|
output,
|
|
21472
21488
|
defaultLabel = "Thinking..."
|
|
21473
21489
|
}) {
|
|
21474
|
-
const toolStatus = (0,
|
|
21490
|
+
const toolStatus = (0, import_react18.useContext)(toolStatusContext)[toolCallId];
|
|
21475
21491
|
const outputObj = output;
|
|
21476
21492
|
const status = outputObj && "status" in outputObj ? outputObj.status : toolStatus != null ? toolStatus : { loading: true, label: defaultLabel };
|
|
21477
|
-
return /* @__PURE__ */ (0,
|
|
21493
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ToolStatus, { status });
|
|
21478
21494
|
}
|
|
21479
21495
|
function ToolStatus({ status }) {
|
|
21480
|
-
return /* @__PURE__ */ (0,
|
|
21481
|
-
/* @__PURE__ */ (0,
|
|
21482
|
-
/* @__PURE__ */ (0,
|
|
21496
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: cxMessage("data"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: cxMessage("dataInner"), children: [
|
|
21497
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: cxMessage("dataIcon"), children: status.error ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TriangleAlert, { size: 18 }) : status.loading ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Loader, { size: 16 }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Check, { size: 18 }) }),
|
|
21498
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { children: status.label })
|
|
21483
21499
|
] }) });
|
|
21484
21500
|
}
|
|
21485
21501
|
function ExamplePrompt({
|
|
21486
21502
|
label,
|
|
21487
21503
|
href
|
|
21488
21504
|
}) {
|
|
21489
|
-
return /* @__PURE__ */ (0,
|
|
21490
|
-
/* @__PURE__ */ (0,
|
|
21491
|
-
/* @__PURE__ */ (0,
|
|
21505
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("a", { className: cx5("examplePrompt"), href, children: [
|
|
21506
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { children: label }),
|
|
21507
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: cx5("examplePromptArrow"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ArrowRight, { size: "16" }) })
|
|
21492
21508
|
] });
|
|
21493
21509
|
}
|
|
21494
21510
|
|
|
21495
21511
|
// src/components/Chat/index.tsx
|
|
21496
21512
|
var import_qler = __toESM(require("qler"));
|
|
21497
|
-
var
|
|
21513
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
21498
21514
|
var q = (0, import_qler.default)();
|
|
21499
21515
|
var BENCHMARK = false;
|
|
21500
21516
|
var prefixedUlid = (prefix = "") => `${prefix ? `${prefix}_` : ""}${(0, import_ulid.ulid)()}`;
|
|
@@ -21508,11 +21524,11 @@ function Chat2({
|
|
|
21508
21524
|
}) {
|
|
21509
21525
|
const puckDispatch = usePuck((s) => s.dispatch);
|
|
21510
21526
|
const getPuck = (0, import_puck2.useGetPuck)();
|
|
21511
|
-
const localChatId = (0,
|
|
21512
|
-
const inputRef = (0,
|
|
21513
|
-
const pluginRef = (0,
|
|
21514
|
-
const [error45, setError] = (0,
|
|
21515
|
-
const [toolStatus, setToolStatus] = (0,
|
|
21527
|
+
const localChatId = (0, import_react20.useRef)(chatId);
|
|
21528
|
+
const inputRef = (0, import_react20.useRef)(null);
|
|
21529
|
+
const pluginRef = (0, import_react20.useRef)(null);
|
|
21530
|
+
const [error45, setError] = (0, import_react20.useState)();
|
|
21531
|
+
const [toolStatus, setToolStatus] = (0, import_react20.useState)({});
|
|
21516
21532
|
const { messages, status, sendMessage, regenerate } = useChat({
|
|
21517
21533
|
generateId: () => prefixedUlid("msg"),
|
|
21518
21534
|
messages: initialMessages,
|
|
@@ -21566,6 +21582,7 @@ function Chat2({
|
|
|
21566
21582
|
case "data-build-op": {
|
|
21567
21583
|
const data = dataPart.data;
|
|
21568
21584
|
q.queue(() => {
|
|
21585
|
+
var _a17, _b, _c, _d;
|
|
21569
21586
|
const puckDispatch2 = getPuck().dispatch;
|
|
21570
21587
|
try {
|
|
21571
21588
|
if (data.op === "add") {
|
|
@@ -21612,11 +21629,13 @@ function Chat2({
|
|
|
21612
21629
|
recordHistory: false
|
|
21613
21630
|
});
|
|
21614
21631
|
} else if (data.op === "updateRoot") {
|
|
21615
|
-
const
|
|
21632
|
+
const { appState, config: config2 } = getPuck();
|
|
21633
|
+
const existing = appState.data.root;
|
|
21634
|
+
const defaultProps = (_b = (_a17 = config2.root) == null ? void 0 : _a17.defaultProps) != null ? _b : {};
|
|
21616
21635
|
puckDispatch2({
|
|
21617
21636
|
type: "replaceRoot",
|
|
21618
21637
|
root: __spreadProps(__spreadValues({}, existing), {
|
|
21619
|
-
props: __spreadValues(__spreadValues({}, existing.props), data.props)
|
|
21638
|
+
props: __spreadValues(__spreadValues(__spreadValues({}, defaultProps), existing.props), data.props)
|
|
21620
21639
|
}),
|
|
21621
21640
|
recordHistory: false
|
|
21622
21641
|
});
|
|
@@ -21662,9 +21681,11 @@ function Chat2({
|
|
|
21662
21681
|
recordHistory: false
|
|
21663
21682
|
});
|
|
21664
21683
|
} else if (data.op === "reset") {
|
|
21684
|
+
const { config: config2 } = getPuck();
|
|
21685
|
+
const defaultRootProps = (_d = (_c = config2.root) == null ? void 0 : _c.defaultProps) != null ? _d : {};
|
|
21665
21686
|
puckDispatch2({
|
|
21666
21687
|
type: "setData",
|
|
21667
|
-
data: { content: [], root:
|
|
21688
|
+
data: { content: [], root: defaultRootProps },
|
|
21668
21689
|
recordHistory: false
|
|
21669
21690
|
});
|
|
21670
21691
|
} else {
|
|
@@ -21717,7 +21738,7 @@ function Chat2({
|
|
|
21717
21738
|
console.error(e);
|
|
21718
21739
|
});
|
|
21719
21740
|
};
|
|
21720
|
-
const messagesWithStatuses = (0,
|
|
21741
|
+
const messagesWithStatuses = (0, import_react20.useMemo)(() => {
|
|
21721
21742
|
return messages.map((msg) => {
|
|
21722
21743
|
return __spreadProps(__spreadValues({}, msg), {
|
|
21723
21744
|
parts: msg.parts.map((part) => {
|
|
@@ -21729,22 +21750,22 @@ function Chat2({
|
|
|
21729
21750
|
});
|
|
21730
21751
|
});
|
|
21731
21752
|
}, [messages, toolStatus]);
|
|
21732
|
-
return /* @__PURE__ */ (0,
|
|
21733
|
-
/* @__PURE__ */ (0,
|
|
21734
|
-
/* @__PURE__ */ (0,
|
|
21753
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassName16(), ref: pluginRef, children: [
|
|
21754
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassName16("header"), children: "AI page builder" }),
|
|
21755
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ToolStatusProvider, { value: toolStatus, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
21735
21756
|
ChatBody,
|
|
21736
21757
|
{
|
|
21737
21758
|
messages: messagesWithStatuses,
|
|
21738
21759
|
handleSubmit,
|
|
21739
21760
|
inputRef,
|
|
21740
21761
|
status,
|
|
21741
|
-
examplePrompts: examplePrompts == null ? void 0 : examplePrompts.map(({ label, href }) => /* @__PURE__ */ (0,
|
|
21762
|
+
examplePrompts: examplePrompts == null ? void 0 : examplePrompts.map(({ label, href }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ExamplePrompt, { label, href }, label)),
|
|
21742
21763
|
error: error45,
|
|
21743
21764
|
handleRetry: () => {
|
|
21744
21765
|
setError("");
|
|
21745
21766
|
regenerate();
|
|
21746
21767
|
},
|
|
21747
|
-
children: /* @__PURE__ */ (0,
|
|
21768
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
21748
21769
|
Placeholder,
|
|
21749
21770
|
{
|
|
21750
21771
|
dispatch: puckDispatch,
|
|
@@ -21775,11 +21796,11 @@ function Placeholder({
|
|
|
21775
21796
|
}
|
|
21776
21797
|
}, 10);
|
|
21777
21798
|
};
|
|
21778
|
-
return /* @__PURE__ */ (0,
|
|
21779
|
-
/* @__PURE__ */ (0,
|
|
21780
|
-
/* @__PURE__ */ (0,
|
|
21781
|
-
/* @__PURE__ */ (0,
|
|
21782
|
-
/* @__PURE__ */ (0,
|
|
21799
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassName16("placeholder"), children: [
|
|
21800
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Bot, { size: "24" }),
|
|
21801
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { children: "Use AI to build a page using your own components" }),
|
|
21802
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: getClassName16("actions"), children: [
|
|
21803
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
21783
21804
|
"button",
|
|
21784
21805
|
{
|
|
21785
21806
|
className: getClassName16("action"),
|
|
@@ -21787,7 +21808,7 @@ function Placeholder({
|
|
|
21787
21808
|
children: "Enter prompt"
|
|
21788
21809
|
}
|
|
21789
21810
|
),
|
|
21790
|
-
/* @__PURE__ */ (0,
|
|
21811
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
21791
21812
|
"button",
|
|
21792
21813
|
{
|
|
21793
21814
|
className: getClassName16("actionOutlined"),
|
|
@@ -21811,13 +21832,13 @@ function isScrolledIntoView(el) {
|
|
|
21811
21832
|
}
|
|
21812
21833
|
|
|
21813
21834
|
// src/index.tsx
|
|
21814
|
-
var
|
|
21835
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
21815
21836
|
function createAIPlugin(opts) {
|
|
21816
21837
|
return {
|
|
21817
21838
|
label: "AI",
|
|
21818
21839
|
name: "ai",
|
|
21819
|
-
render: () => /* @__PURE__ */ (0,
|
|
21820
|
-
icon: /* @__PURE__ */ (0,
|
|
21840
|
+
render: () => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Chat2, __spreadValues({}, opts)),
|
|
21841
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Bot, {}),
|
|
21821
21842
|
mobilePanelHeight: "min-content"
|
|
21822
21843
|
};
|
|
21823
21844
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -20672,7 +20672,7 @@ function useChat(_a17 = {}) {
|
|
|
20672
20672
|
|
|
20673
20673
|
// src/components/Chat/index.tsx
|
|
20674
20674
|
import { createUsePuck, useGetPuck } from "@measured/puck";
|
|
20675
|
-
import { useMemo, useRef as
|
|
20675
|
+
import { useMemo as useMemo3, useRef as useRef7, useState as useState10 } from "react";
|
|
20676
20676
|
import { ulid as ulid3 } from "ulid";
|
|
20677
20677
|
|
|
20678
20678
|
// ../utils/lib/get-class-name-factory.ts
|
|
@@ -21173,12 +21173,28 @@ init_react_import();
|
|
|
21173
21173
|
|
|
21174
21174
|
// css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Page/Page.module.css#css-module
|
|
21175
21175
|
init_react_import();
|
|
21176
|
-
var Page_module_default = { "Page": "
|
|
21176
|
+
var Page_module_default = { "Page": "_Page_1pzwy_1", "Page-masthead": "_Page-masthead_1pzwy_8", "Page-crumbs": "_Page-crumbs_1pzwy_18", "Page-crumb": "_Page-crumb_1pzwy_18", "Page-crumbLink": "_Page-crumbLink_1pzwy_28", "Page-actions": "_Page-actions_1pzwy_60", "Page-footer": "_Page-footer_1pzwy_64" };
|
|
21177
21177
|
|
|
21178
21178
|
// ../platform-client/components/Page/Page.tsx
|
|
21179
21179
|
import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
21180
21180
|
var cx2 = getClassNameFactory2("Page", Page_module_default);
|
|
21181
21181
|
|
|
21182
|
+
// ../platform-client/components/Pagination/index.ts
|
|
21183
|
+
init_react_import();
|
|
21184
|
+
|
|
21185
|
+
// ../platform-client/components/Pagination/Pagination.tsx
|
|
21186
|
+
init_react_import();
|
|
21187
|
+
import { useMemo } from "react";
|
|
21188
|
+
|
|
21189
|
+
// css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Pagination/Pagination.module.css#css-module
|
|
21190
|
+
init_react_import();
|
|
21191
|
+
var Pagination_module_default = { "Pagination": "_Pagination_1okv2_1", "PaginationButton": "_PaginationButton_1okv2_8", "PaginationButton--isActive": "_PaginationButton--isActive_1okv2_20", "Pagination-ellipsis": "_Pagination-ellipsis_1okv2_30" };
|
|
21192
|
+
|
|
21193
|
+
// ../platform-client/components/Pagination/Pagination.tsx
|
|
21194
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
21195
|
+
var cx3 = getClassNameFactory2("Pagination", Pagination_module_default);
|
|
21196
|
+
var cxButton = getClassNameFactory2("PaginationButton", Pagination_module_default);
|
|
21197
|
+
|
|
21182
21198
|
// ../platform-client/components/Section/index.ts
|
|
21183
21199
|
init_react_import();
|
|
21184
21200
|
|
|
@@ -21190,7 +21206,7 @@ init_react_import();
|
|
|
21190
21206
|
var Section_module_default = { "Section-inner": "_Section-inner_1uwo0_1", "Section--flush": "_Section--flush_1uwo0_8", "Section": "_Section_1uwo0_1", "Section--full": "_Section--full_1uwo0_17" };
|
|
21191
21207
|
|
|
21192
21208
|
// ../platform-client/components/Section/Section.tsx
|
|
21193
|
-
import { jsx as
|
|
21209
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
21194
21210
|
var getClassName12 = getClassNameFactory2("Section", Section_module_default);
|
|
21195
21211
|
|
|
21196
21212
|
// ../platform-client/components/StatusTag/index.ts
|
|
@@ -21210,25 +21226,25 @@ init_react_import();
|
|
|
21210
21226
|
var Tag_module_default = { "Tag": "_Tag_1baze_1", "Tag--colorBlue": "_Tag--colorBlue_1baze_19", "Tag--colorGreen": "_Tag--colorGreen_1baze_23", "Tag--colorRed": "_Tag--colorRed_1baze_27", "Tag--colorMuted": "_Tag--colorMuted_1baze_31", "Tag-sprite": "_Tag-sprite_1baze_35", "Tag--pulse": "_Tag--pulse_1baze_39", "pulse": "_pulse_1baze_1" };
|
|
21211
21227
|
|
|
21212
21228
|
// ../platform-client/components/Tag/Tag.tsx
|
|
21213
|
-
import { jsx as
|
|
21229
|
+
import { jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
21214
21230
|
var getClassName13 = getClassNameFactory2("Tag", Tag_module_default);
|
|
21215
21231
|
|
|
21216
21232
|
// ../platform-client/components/StatusTag/StatusTag.tsx
|
|
21217
|
-
import { jsx as
|
|
21233
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
21218
21234
|
|
|
21219
21235
|
// ../platform-client/components/Table/index.ts
|
|
21220
21236
|
init_react_import();
|
|
21221
21237
|
|
|
21222
21238
|
// ../platform-client/components/Table/Table.tsx
|
|
21223
21239
|
init_react_import();
|
|
21224
|
-
import { useState as useState7 } from "react";
|
|
21240
|
+
import { useEffect as useEffect6, useMemo as useMemo2, useRef as useRef5, useState as useState7 } from "react";
|
|
21225
21241
|
|
|
21226
21242
|
// css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Table/Table.module.css#css-module
|
|
21227
21243
|
init_react_import();
|
|
21228
|
-
var Table_module_default = { "Table": "
|
|
21244
|
+
var Table_module_default = { "Table": "_Table_1w0os_1", "Table-filters": "_Table-filters_1w0os_9", "Table-inner": "_Table-inner_1w0os_13", "Table-table": "_Table-table_1w0os_17", "Table-footer": "_Table-footer_1w0os_85", "Table--clickableRows": "_Table--clickableRows_1w0os_89", "Table-placeholder": "_Table-placeholder_1w0os_94", "Table-loader": "_Table-loader_1w0os_105" };
|
|
21229
21245
|
|
|
21230
21246
|
// ../platform-client/components/Table/Table.tsx
|
|
21231
|
-
import { jsx as
|
|
21247
|
+
import { jsx as jsx19, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
21232
21248
|
var getClassName14 = get_class_name_factory_default("Table", Table_module_default);
|
|
21233
21249
|
|
|
21234
21250
|
// ../platform-client/components/Textarea/index.tsx
|
|
@@ -21246,13 +21262,13 @@ init_react_import();
|
|
|
21246
21262
|
var VerticalSpace_module_default = { "VerticalSpace": "_VerticalSpace_1tjaw_1", "VerticalSpace--size4": "_VerticalSpace--size4_1tjaw_5", "VerticalSpace--size8": "_VerticalSpace--size8_1tjaw_9", "VerticalSpace--size16": "_VerticalSpace--size16_1tjaw_13", "VerticalSpace--size32": "_VerticalSpace--size32_1tjaw_17", "VerticalSpace--size40": "_VerticalSpace--size40_1tjaw_21", "VerticalSpace--size48": "_VerticalSpace--size48_1tjaw_25", "VerticalSpace--size56": "_VerticalSpace--size56_1tjaw_29", "VerticalSpace--size96": "_VerticalSpace--size96_1tjaw_33", "VerticalSpace--size128": "_VerticalSpace--size128_1tjaw_37" };
|
|
21247
21263
|
|
|
21248
21264
|
// ../platform-client/components/VerticalSpace/VerticalSpace.tsx
|
|
21249
|
-
import { jsx as
|
|
21265
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
21250
21266
|
var getClassName15 = get_class_name_factory_default("VerticalSpace", VerticalSpace_module_default);
|
|
21251
21267
|
|
|
21252
21268
|
// ../platform-client/context/editor.tsx
|
|
21253
21269
|
init_react_import();
|
|
21254
21270
|
import { createContext as createContext2, useContext as useContext2, useState as useState8 } from "react";
|
|
21255
|
-
import { jsx as
|
|
21271
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
21256
21272
|
var ctx = createContext2({});
|
|
21257
21273
|
|
|
21258
21274
|
// css-module:/home/runner/work/puck-platform/puck-platform/packages/plugin-ai/src/components/ChatBody/styles.module.css#css-module
|
|
@@ -21262,8 +21278,8 @@ var styles_module_default3 = { "Chat": "_Chat_14j71_1", "Chat-inner": "_Chat-inn
|
|
|
21262
21278
|
// src/components/PromptForm/index.tsx
|
|
21263
21279
|
init_react_import();
|
|
21264
21280
|
import {
|
|
21265
|
-
useEffect as
|
|
21266
|
-
useRef as
|
|
21281
|
+
useEffect as useEffect7,
|
|
21282
|
+
useRef as useRef6,
|
|
21267
21283
|
useState as useState9
|
|
21268
21284
|
} from "react";
|
|
21269
21285
|
|
|
@@ -21272,8 +21288,8 @@ init_react_import();
|
|
|
21272
21288
|
var styles_module_default4 = { "PromptForm": "_PromptForm_136g1_1", "PromptForm-inner": "_PromptForm-inner_136g1_8", "PromptForm--dark": "_PromptForm--dark_136g1_14", "PromptForm--glow": "_PromptForm--glow_136g1_19", "PromptForm-glow": "_PromptForm-glow_136g1_19", "loop": "_loop_136g1_1", "PromptForm-formInner": "_PromptForm-formInner_136g1_60", "PromptForm-input": "_PromptForm-input_136g1_64", "PromptForm--disabled": "_PromptForm--disabled_136g1_92", "PromptForm-helper": "_PromptForm-helper_136g1_97", "PromptForm-actions": "_PromptForm-actions_136g1_107", "PromptForm-actionsLeft": "_PromptForm-actionsLeft_136g1_118", "PromptForm-actionsRight": "_PromptForm-actionsRight_136g1_124", "PromptForm-actionSubmit": "_PromptForm-actionSubmit_136g1_128", "PromptForm--isDisabled": "_PromptForm--isDisabled_136g1_147", "PromptForm--isLoading": "_PromptForm--isLoading_136g1_152" };
|
|
21273
21289
|
|
|
21274
21290
|
// src/components/PromptForm/index.tsx
|
|
21275
|
-
import { jsx as
|
|
21276
|
-
var
|
|
21291
|
+
import { jsx as jsx22, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
21292
|
+
var cx4 = getClassNameFactory2("PromptForm", styles_module_default4);
|
|
21277
21293
|
function PromptForm({
|
|
21278
21294
|
actions,
|
|
21279
21295
|
colorScheme = "light",
|
|
@@ -21285,7 +21301,7 @@ function PromptForm({
|
|
|
21285
21301
|
isLoading,
|
|
21286
21302
|
placeholder = "Create a page for..."
|
|
21287
21303
|
}) {
|
|
21288
|
-
const hasSetInitialPrompt =
|
|
21304
|
+
const hasSetInitialPrompt = useRef6(false);
|
|
21289
21305
|
const [prompt, setPrompt] = useState9("");
|
|
21290
21306
|
const sendPrompt = () => {
|
|
21291
21307
|
if (isLoading || isDisabled) return;
|
|
@@ -21294,7 +21310,7 @@ function PromptForm({
|
|
|
21294
21310
|
}
|
|
21295
21311
|
setPrompt("");
|
|
21296
21312
|
};
|
|
21297
|
-
|
|
21313
|
+
useEffect7(() => {
|
|
21298
21314
|
const currentUrl = new URL(location.href);
|
|
21299
21315
|
const initialPrompt = currentUrl.searchParams.get("initialPrompt");
|
|
21300
21316
|
if (!hasSetInitialPrompt.current && initialPrompt && prompt === "") {
|
|
@@ -21305,28 +21321,28 @@ function PromptForm({
|
|
|
21305
21321
|
return /* @__PURE__ */ jsxs11(
|
|
21306
21322
|
"div",
|
|
21307
21323
|
{
|
|
21308
|
-
className:
|
|
21324
|
+
className: cx4({
|
|
21309
21325
|
isDisabled,
|
|
21310
21326
|
isLoading,
|
|
21311
21327
|
dark: colorScheme === "dark",
|
|
21312
21328
|
glow
|
|
21313
21329
|
}),
|
|
21314
21330
|
children: [
|
|
21315
|
-
helperText ? /* @__PURE__ */
|
|
21316
|
-
/* @__PURE__ */ jsxs11("div", { className:
|
|
21317
|
-
/* @__PURE__ */
|
|
21318
|
-
/* @__PURE__ */
|
|
21331
|
+
helperText ? /* @__PURE__ */ jsx22("div", { className: cx4("helper"), children: helperText }) : null,
|
|
21332
|
+
/* @__PURE__ */ jsxs11("div", { className: cx4("inner"), children: [
|
|
21333
|
+
/* @__PURE__ */ jsx22("span", { className: cx4("glow") }),
|
|
21334
|
+
/* @__PURE__ */ jsx22(
|
|
21319
21335
|
"form",
|
|
21320
21336
|
{
|
|
21321
21337
|
onSubmit: (e) => {
|
|
21322
21338
|
e.preventDefault();
|
|
21323
21339
|
sendPrompt();
|
|
21324
21340
|
},
|
|
21325
|
-
children: /* @__PURE__ */ jsxs11("div", { className:
|
|
21326
|
-
/* @__PURE__ */
|
|
21341
|
+
children: /* @__PURE__ */ jsxs11("div", { className: cx4("formInner"), children: [
|
|
21342
|
+
/* @__PURE__ */ jsx22(
|
|
21327
21343
|
default2,
|
|
21328
21344
|
{
|
|
21329
|
-
className:
|
|
21345
|
+
className: cx4("input"),
|
|
21330
21346
|
name: "prompt",
|
|
21331
21347
|
minRows: 2,
|
|
21332
21348
|
placeholder,
|
|
@@ -21347,15 +21363,15 @@ function PromptForm({
|
|
|
21347
21363
|
}
|
|
21348
21364
|
}
|
|
21349
21365
|
),
|
|
21350
|
-
/* @__PURE__ */ jsxs11("div", { className:
|
|
21351
|
-
/* @__PURE__ */
|
|
21352
|
-
/* @__PURE__ */
|
|
21366
|
+
/* @__PURE__ */ jsxs11("div", { className: cx4("actions"), children: [
|
|
21367
|
+
/* @__PURE__ */ jsx22("div", { className: cx4("actionsLeft"), children: actions }),
|
|
21368
|
+
/* @__PURE__ */ jsx22("div", { className: cx4("actionsRight"), children: /* @__PURE__ */ jsx22(
|
|
21353
21369
|
"button",
|
|
21354
21370
|
{
|
|
21355
|
-
className:
|
|
21371
|
+
className: cx4("actionSubmit"),
|
|
21356
21372
|
type: "submit",
|
|
21357
21373
|
disabled: isLoading,
|
|
21358
|
-
children: /* @__PURE__ */
|
|
21374
|
+
children: /* @__PURE__ */ jsx22(ArrowUp, {})
|
|
21359
21375
|
}
|
|
21360
21376
|
) })
|
|
21361
21377
|
] })
|
|
@@ -21375,8 +21391,8 @@ var toolStatusContext = createContext3({});
|
|
|
21375
21391
|
var ToolStatusProvider = toolStatusContext.Provider;
|
|
21376
21392
|
|
|
21377
21393
|
// src/components/ChatBody/index.tsx
|
|
21378
|
-
import { jsx as
|
|
21379
|
-
var
|
|
21394
|
+
import { jsx as jsx23, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
21395
|
+
var cx5 = getClassNameFactory2("Chat", styles_module_default3);
|
|
21380
21396
|
var cxMessage = getClassNameFactory2("ChatMessage", styles_module_default3);
|
|
21381
21397
|
function ChatBody({
|
|
21382
21398
|
children,
|
|
@@ -21391,17 +21407,17 @@ function ChatBody({
|
|
|
21391
21407
|
}) {
|
|
21392
21408
|
const { scrollRef, contentRef } = useStickToBottom();
|
|
21393
21409
|
const hasMessages = messages && messages.length > 0;
|
|
21394
|
-
return /* @__PURE__ */ jsxs12("div", { className:
|
|
21395
|
-
children ? /* @__PURE__ */
|
|
21396
|
-
/* @__PURE__ */ jsxs12("div", { className:
|
|
21397
|
-
/* @__PURE__ */
|
|
21398
|
-
status === "submitted" && /* @__PURE__ */
|
|
21399
|
-
error45 && /* @__PURE__ */ jsxs12("div", { className:
|
|
21400
|
-
/* @__PURE__ */
|
|
21401
|
-
handleRetry && /* @__PURE__ */
|
|
21410
|
+
return /* @__PURE__ */ jsxs12("div", { className: cx5({ hasMessages, hasChildren: !!children, hideInput }), children: [
|
|
21411
|
+
children ? /* @__PURE__ */ jsx23("div", { className: cx5("default"), children }) : null,
|
|
21412
|
+
/* @__PURE__ */ jsxs12("div", { className: cx5("inner"), ref: scrollRef, children: [
|
|
21413
|
+
/* @__PURE__ */ jsx23("div", { className: cx5("messages"), ref: contentRef, children: messages.toReversed().map((message) => /* @__PURE__ */ jsx23(ChatMessage, { message }, message.id)) }),
|
|
21414
|
+
status === "submitted" && /* @__PURE__ */ jsx23("div", { className: cx5("loader"), children: /* @__PURE__ */ jsx23(Loader, { size: 14 }) }),
|
|
21415
|
+
error45 && /* @__PURE__ */ jsxs12("div", { className: cx5("error"), children: [
|
|
21416
|
+
/* @__PURE__ */ jsx23("div", { className: cx5("errorLabel"), children: "Something went wrong." }),
|
|
21417
|
+
handleRetry && /* @__PURE__ */ jsx23("div", { className: cx5("errorAction"), children: /* @__PURE__ */ jsx23(IconButton, { title: "Retry", onClick: handleRetry, children: /* @__PURE__ */ jsx23(RotateCcw, { size: "14" }) }) })
|
|
21402
21418
|
] }),
|
|
21403
|
-
/* @__PURE__ */ jsxs12("div", { className:
|
|
21404
|
-
/* @__PURE__ */
|
|
21419
|
+
/* @__PURE__ */ jsxs12("div", { className: cx5("form"), children: [
|
|
21420
|
+
/* @__PURE__ */ jsx23(
|
|
21405
21421
|
PromptForm,
|
|
21406
21422
|
{
|
|
21407
21423
|
glow: !hasMessages,
|
|
@@ -21411,19 +21427,19 @@ function ChatBody({
|
|
|
21411
21427
|
placeholder: "What do you want to build?"
|
|
21412
21428
|
}
|
|
21413
21429
|
),
|
|
21414
|
-
examplePrompts ? /* @__PURE__ */
|
|
21430
|
+
examplePrompts ? /* @__PURE__ */ jsx23("div", { className: cx5("examplePrompts"), children: examplePrompts }) : null
|
|
21415
21431
|
] })
|
|
21416
21432
|
] })
|
|
21417
21433
|
] });
|
|
21418
21434
|
}
|
|
21419
21435
|
function ChatMessage({ message }) {
|
|
21420
21436
|
const { role, parts } = message;
|
|
21421
|
-
return /* @__PURE__ */
|
|
21437
|
+
return /* @__PURE__ */ jsx23(
|
|
21422
21438
|
"div",
|
|
21423
21439
|
{
|
|
21424
21440
|
className: cxMessage({ [`${role}Role`]: true }),
|
|
21425
21441
|
"data-message-id": message.id,
|
|
21426
|
-
children: parts.map((part, i) => /* @__PURE__ */
|
|
21442
|
+
children: parts.map((part, i) => /* @__PURE__ */ jsx23(
|
|
21427
21443
|
ChatMessagePart,
|
|
21428
21444
|
{
|
|
21429
21445
|
part,
|
|
@@ -21439,25 +21455,25 @@ function ChatMessageWrapper({
|
|
|
21439
21455
|
role
|
|
21440
21456
|
}) {
|
|
21441
21457
|
if (role === "assistant") {
|
|
21442
|
-
return /* @__PURE__ */
|
|
21458
|
+
return /* @__PURE__ */ jsx23(Markdown, { children });
|
|
21443
21459
|
}
|
|
21444
|
-
return /* @__PURE__ */
|
|
21460
|
+
return /* @__PURE__ */ jsx23("span", { children });
|
|
21445
21461
|
}
|
|
21446
21462
|
function ChatMessagePart({
|
|
21447
21463
|
part,
|
|
21448
21464
|
role
|
|
21449
21465
|
}) {
|
|
21450
21466
|
if (part.type === "text") {
|
|
21451
|
-
return /* @__PURE__ */
|
|
21467
|
+
return /* @__PURE__ */ jsx23("div", { className: cxMessage("text"), children: /* @__PURE__ */ jsx23(ChatMessageWrapper, { role, children: part.text }) });
|
|
21452
21468
|
}
|
|
21453
21469
|
if (part.type === "tool-createPage") {
|
|
21454
|
-
return /* @__PURE__ */
|
|
21470
|
+
return /* @__PURE__ */ jsx23(PuckTool, __spreadValues({}, part));
|
|
21455
21471
|
}
|
|
21456
21472
|
if (part.type === "tool-updatePage") {
|
|
21457
|
-
return /* @__PURE__ */
|
|
21473
|
+
return /* @__PURE__ */ jsx23(PuckTool, __spreadValues({}, part));
|
|
21458
21474
|
}
|
|
21459
21475
|
if (part.type === "tool-userTool") {
|
|
21460
|
-
return /* @__PURE__ */
|
|
21476
|
+
return /* @__PURE__ */ jsx23(PuckTool, __spreadValues({}, part));
|
|
21461
21477
|
}
|
|
21462
21478
|
return null;
|
|
21463
21479
|
}
|
|
@@ -21469,27 +21485,27 @@ function PuckTool({
|
|
|
21469
21485
|
const toolStatus = useContext3(toolStatusContext)[toolCallId];
|
|
21470
21486
|
const outputObj = output;
|
|
21471
21487
|
const status = outputObj && "status" in outputObj ? outputObj.status : toolStatus != null ? toolStatus : { loading: true, label: defaultLabel };
|
|
21472
|
-
return /* @__PURE__ */
|
|
21488
|
+
return /* @__PURE__ */ jsx23(ToolStatus, { status });
|
|
21473
21489
|
}
|
|
21474
21490
|
function ToolStatus({ status }) {
|
|
21475
|
-
return /* @__PURE__ */
|
|
21476
|
-
/* @__PURE__ */
|
|
21477
|
-
/* @__PURE__ */
|
|
21491
|
+
return /* @__PURE__ */ jsx23("div", { className: cxMessage("data"), children: /* @__PURE__ */ jsxs12("div", { className: cxMessage("dataInner"), children: [
|
|
21492
|
+
/* @__PURE__ */ jsx23("div", { className: cxMessage("dataIcon"), children: status.error ? /* @__PURE__ */ jsx23(TriangleAlert, { size: 18 }) : status.loading ? /* @__PURE__ */ jsx23(Loader, { size: 16 }) : /* @__PURE__ */ jsx23(Check, { size: 18 }) }),
|
|
21493
|
+
/* @__PURE__ */ jsx23("div", { children: status.label })
|
|
21478
21494
|
] }) });
|
|
21479
21495
|
}
|
|
21480
21496
|
function ExamplePrompt({
|
|
21481
21497
|
label,
|
|
21482
21498
|
href
|
|
21483
21499
|
}) {
|
|
21484
|
-
return /* @__PURE__ */ jsxs12("a", { className:
|
|
21485
|
-
/* @__PURE__ */
|
|
21486
|
-
/* @__PURE__ */
|
|
21500
|
+
return /* @__PURE__ */ jsxs12("a", { className: cx5("examplePrompt"), href, children: [
|
|
21501
|
+
/* @__PURE__ */ jsx23("div", { children: label }),
|
|
21502
|
+
/* @__PURE__ */ jsx23("div", { className: cx5("examplePromptArrow"), children: /* @__PURE__ */ jsx23(ArrowRight, { size: "16" }) })
|
|
21487
21503
|
] });
|
|
21488
21504
|
}
|
|
21489
21505
|
|
|
21490
21506
|
// src/components/Chat/index.tsx
|
|
21491
21507
|
import qler from "qler";
|
|
21492
|
-
import { jsx as
|
|
21508
|
+
import { jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
21493
21509
|
var q = qler();
|
|
21494
21510
|
var BENCHMARK = false;
|
|
21495
21511
|
var prefixedUlid = (prefix = "") => `${prefix ? `${prefix}_` : ""}${ulid3()}`;
|
|
@@ -21503,9 +21519,9 @@ function Chat2({
|
|
|
21503
21519
|
}) {
|
|
21504
21520
|
const puckDispatch = usePuck((s) => s.dispatch);
|
|
21505
21521
|
const getPuck = useGetPuck();
|
|
21506
|
-
const localChatId =
|
|
21507
|
-
const inputRef =
|
|
21508
|
-
const pluginRef =
|
|
21522
|
+
const localChatId = useRef7(chatId);
|
|
21523
|
+
const inputRef = useRef7(null);
|
|
21524
|
+
const pluginRef = useRef7(null);
|
|
21509
21525
|
const [error45, setError] = useState10();
|
|
21510
21526
|
const [toolStatus, setToolStatus] = useState10({});
|
|
21511
21527
|
const { messages, status, sendMessage, regenerate } = useChat({
|
|
@@ -21561,6 +21577,7 @@ function Chat2({
|
|
|
21561
21577
|
case "data-build-op": {
|
|
21562
21578
|
const data = dataPart.data;
|
|
21563
21579
|
q.queue(() => {
|
|
21580
|
+
var _a17, _b, _c, _d;
|
|
21564
21581
|
const puckDispatch2 = getPuck().dispatch;
|
|
21565
21582
|
try {
|
|
21566
21583
|
if (data.op === "add") {
|
|
@@ -21607,11 +21624,13 @@ function Chat2({
|
|
|
21607
21624
|
recordHistory: false
|
|
21608
21625
|
});
|
|
21609
21626
|
} else if (data.op === "updateRoot") {
|
|
21610
|
-
const
|
|
21627
|
+
const { appState, config: config2 } = getPuck();
|
|
21628
|
+
const existing = appState.data.root;
|
|
21629
|
+
const defaultProps = (_b = (_a17 = config2.root) == null ? void 0 : _a17.defaultProps) != null ? _b : {};
|
|
21611
21630
|
puckDispatch2({
|
|
21612
21631
|
type: "replaceRoot",
|
|
21613
21632
|
root: __spreadProps(__spreadValues({}, existing), {
|
|
21614
|
-
props: __spreadValues(__spreadValues({}, existing.props), data.props)
|
|
21633
|
+
props: __spreadValues(__spreadValues(__spreadValues({}, defaultProps), existing.props), data.props)
|
|
21615
21634
|
}),
|
|
21616
21635
|
recordHistory: false
|
|
21617
21636
|
});
|
|
@@ -21657,9 +21676,11 @@ function Chat2({
|
|
|
21657
21676
|
recordHistory: false
|
|
21658
21677
|
});
|
|
21659
21678
|
} else if (data.op === "reset") {
|
|
21679
|
+
const { config: config2 } = getPuck();
|
|
21680
|
+
const defaultRootProps = (_d = (_c = config2.root) == null ? void 0 : _c.defaultProps) != null ? _d : {};
|
|
21660
21681
|
puckDispatch2({
|
|
21661
21682
|
type: "setData",
|
|
21662
|
-
data: { content: [], root:
|
|
21683
|
+
data: { content: [], root: defaultRootProps },
|
|
21663
21684
|
recordHistory: false
|
|
21664
21685
|
});
|
|
21665
21686
|
} else {
|
|
@@ -21712,7 +21733,7 @@ function Chat2({
|
|
|
21712
21733
|
console.error(e);
|
|
21713
21734
|
});
|
|
21714
21735
|
};
|
|
21715
|
-
const messagesWithStatuses =
|
|
21736
|
+
const messagesWithStatuses = useMemo3(() => {
|
|
21716
21737
|
return messages.map((msg) => {
|
|
21717
21738
|
return __spreadProps(__spreadValues({}, msg), {
|
|
21718
21739
|
parts: msg.parts.map((part) => {
|
|
@@ -21725,21 +21746,21 @@ function Chat2({
|
|
|
21725
21746
|
});
|
|
21726
21747
|
}, [messages, toolStatus]);
|
|
21727
21748
|
return /* @__PURE__ */ jsxs13("div", { className: getClassName16(), ref: pluginRef, children: [
|
|
21728
|
-
/* @__PURE__ */
|
|
21729
|
-
/* @__PURE__ */
|
|
21749
|
+
/* @__PURE__ */ jsx24("div", { className: getClassName16("header"), children: "AI page builder" }),
|
|
21750
|
+
/* @__PURE__ */ jsx24(ToolStatusProvider, { value: toolStatus, children: /* @__PURE__ */ jsx24(
|
|
21730
21751
|
ChatBody,
|
|
21731
21752
|
{
|
|
21732
21753
|
messages: messagesWithStatuses,
|
|
21733
21754
|
handleSubmit,
|
|
21734
21755
|
inputRef,
|
|
21735
21756
|
status,
|
|
21736
|
-
examplePrompts: examplePrompts == null ? void 0 : examplePrompts.map(({ label, href }) => /* @__PURE__ */
|
|
21757
|
+
examplePrompts: examplePrompts == null ? void 0 : examplePrompts.map(({ label, href }) => /* @__PURE__ */ jsx24(ExamplePrompt, { label, href }, label)),
|
|
21737
21758
|
error: error45,
|
|
21738
21759
|
handleRetry: () => {
|
|
21739
21760
|
setError("");
|
|
21740
21761
|
regenerate();
|
|
21741
21762
|
},
|
|
21742
|
-
children: /* @__PURE__ */
|
|
21763
|
+
children: /* @__PURE__ */ jsx24(
|
|
21743
21764
|
Placeholder,
|
|
21744
21765
|
{
|
|
21745
21766
|
dispatch: puckDispatch,
|
|
@@ -21771,10 +21792,10 @@ function Placeholder({
|
|
|
21771
21792
|
}, 10);
|
|
21772
21793
|
};
|
|
21773
21794
|
return /* @__PURE__ */ jsxs13("div", { className: getClassName16("placeholder"), children: [
|
|
21774
|
-
/* @__PURE__ */
|
|
21775
|
-
/* @__PURE__ */
|
|
21795
|
+
/* @__PURE__ */ jsx24(Bot, { size: "24" }),
|
|
21796
|
+
/* @__PURE__ */ jsx24("div", { children: "Use AI to build a page using your own components" }),
|
|
21776
21797
|
/* @__PURE__ */ jsxs13("div", { className: getClassName16("actions"), children: [
|
|
21777
|
-
/* @__PURE__ */
|
|
21798
|
+
/* @__PURE__ */ jsx24(
|
|
21778
21799
|
"button",
|
|
21779
21800
|
{
|
|
21780
21801
|
className: getClassName16("action"),
|
|
@@ -21782,7 +21803,7 @@ function Placeholder({
|
|
|
21782
21803
|
children: "Enter prompt"
|
|
21783
21804
|
}
|
|
21784
21805
|
),
|
|
21785
|
-
/* @__PURE__ */
|
|
21806
|
+
/* @__PURE__ */ jsx24(
|
|
21786
21807
|
"button",
|
|
21787
21808
|
{
|
|
21788
21809
|
className: getClassName16("actionOutlined"),
|
|
@@ -21806,13 +21827,13 @@ function isScrolledIntoView(el) {
|
|
|
21806
21827
|
}
|
|
21807
21828
|
|
|
21808
21829
|
// src/index.tsx
|
|
21809
|
-
import { jsx as
|
|
21830
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
21810
21831
|
function createAIPlugin(opts) {
|
|
21811
21832
|
return {
|
|
21812
21833
|
label: "AI",
|
|
21813
21834
|
name: "ai",
|
|
21814
|
-
render: () => /* @__PURE__ */
|
|
21815
|
-
icon: /* @__PURE__ */
|
|
21835
|
+
render: () => /* @__PURE__ */ jsx25(Chat2, __spreadValues({}, opts)),
|
|
21836
|
+
icon: /* @__PURE__ */ jsx25(Bot, {}),
|
|
21816
21837
|
mobilePanelHeight: "min-content"
|
|
21817
21838
|
};
|
|
21818
21839
|
}
|
package/package.json
CHANGED