@copilotkit/react-textarea 0.10.0 → 0.12.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 (69) hide show
  1. package/.turbo/turbo-build.log +179 -164
  2. package/CHANGELOG.md +13 -0
  3. package/dist/chunk-AOEXKPIX.mjs +83 -0
  4. package/dist/chunk-AOEXKPIX.mjs.map +1 -0
  5. package/dist/{chunk-6SYD77G6.mjs → chunk-CSGFJU3L.mjs} +2 -2
  6. package/dist/chunk-CSGFJU3L.mjs.map +1 -0
  7. package/dist/chunk-DCQ27XRF.mjs +32 -0
  8. package/dist/chunk-DCQ27XRF.mjs.map +1 -0
  9. package/dist/chunk-DE5K76I2.mjs +3 -0
  10. package/dist/{chunk-E2UEE45I.mjs → chunk-HZGSG7ST.mjs} +1 -1
  11. package/dist/chunk-HZGSG7ST.mjs.map +1 -0
  12. package/dist/{chunk-THWPPG6M.mjs → chunk-IGQI27NI.mjs} +20 -2
  13. package/dist/chunk-IGQI27NI.mjs.map +1 -0
  14. package/dist/chunk-M6QFKIBE.mjs +161 -0
  15. package/dist/chunk-M6QFKIBE.mjs.map +1 -0
  16. package/dist/chunk-WADHCMPK.mjs +3 -0
  17. package/dist/components/base-copilot-textarea/base-copilot-textarea.d.ts +10 -14
  18. package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +9 -8
  19. package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +1 -1
  20. package/dist/components/copilot-textarea/copilot-textarea.d.ts +4 -4
  21. package/dist/components/copilot-textarea/copilot-textarea.mjs +10 -9
  22. package/dist/components/index.d.ts +4 -2
  23. package/dist/components/index.mjs +10 -9
  24. package/dist/hooks/{use-autosuggestions.d.ts → base-copilot-textarea-implementation/use-autosuggestions.d.ts} +3 -3
  25. package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +7 -0
  26. package/dist/hooks/{use-copilot-textarea-editor.d.ts → base-copilot-textarea-implementation/use-copilot-textarea-editor.d.ts} +1 -1
  27. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +5 -0
  28. package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map +1 -0
  29. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.d.ts +7 -0
  30. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +6 -0
  31. package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -0
  32. package/dist/index.css +4 -0
  33. package/dist/index.css.map +1 -1
  34. package/dist/index.d.ts +3 -1
  35. package/dist/index.mjs +13 -11
  36. package/dist/types/base/base-copilot-textarea-props.d.ts +38 -0
  37. package/dist/types/base/base-copilot-textarea-props.mjs +3 -0
  38. package/dist/types/base/base-copilot-textarea-props.mjs.map +1 -0
  39. package/dist/types/base/index.d.ts +2 -0
  40. package/dist/types/html-copilot-textarea-element.d.ts +7 -0
  41. package/dist/types/html-copilot-textarea-element.mjs +3 -0
  42. package/dist/types/html-copilot-textarea-element.mjs.map +1 -0
  43. package/dist/types/index.d.ts +3 -0
  44. package/dist/types/index.mjs +2 -1
  45. package/package.json +3 -3
  46. package/src/components/base-copilot-textarea/base-copilot-textarea.tsx +191 -161
  47. package/src/components/base-copilot-textarea/use-add-branding-css.tsx +25 -1
  48. package/src/components/copilot-textarea/copilot-textarea.tsx +33 -25
  49. package/src/components/index.ts +0 -1
  50. package/src/hooks/{use-autosuggestions.ts → base-copilot-textarea-implementation/use-autosuggestions.ts} +5 -5
  51. package/src/hooks/{use-copilot-textarea-editor.tsx → base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx} +5 -5
  52. package/src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts +101 -0
  53. package/src/types/base/base-copilot-textarea-props.tsx +37 -0
  54. package/src/types/base/index.ts +3 -1
  55. package/src/types/html-copilot-textarea-element.ts +5 -0
  56. package/src/types/index.ts +1 -0
  57. package/dist/chunk-6SYD77G6.mjs.map +0 -1
  58. package/dist/chunk-CU2M5BIJ.mjs +0 -133
  59. package/dist/chunk-CU2M5BIJ.mjs.map +0 -1
  60. package/dist/chunk-E2UEE45I.mjs.map +0 -1
  61. package/dist/chunk-FD6FGKYY.mjs +0 -3
  62. package/dist/chunk-NHLYAJCQ.mjs +0 -25
  63. package/dist/chunk-NHLYAJCQ.mjs.map +0 -1
  64. package/dist/chunk-THWPPG6M.mjs.map +0 -1
  65. package/dist/hooks/use-autosuggestions.mjs +0 -7
  66. package/dist/hooks/use-copilot-textarea-editor.mjs +0 -5
  67. /package/dist/{chunk-FD6FGKYY.mjs.map → chunk-DE5K76I2.mjs.map} +0 -0
  68. /package/dist/{hooks/use-autosuggestions.mjs.map → chunk-WADHCMPK.mjs.map} +0 -0
  69. /package/dist/hooks/{use-copilot-textarea-editor.mjs.map → base-copilot-textarea-implementation/use-autosuggestions.mjs.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/styles.css","../src/components/base-copilot-textarea/base-copilot-textarea.css"],"sourcesContent":["/*\n! tailwindcss v3.3.0 | MIT License | https://tailwindcss.com\n*//*\n1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\n2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)\n*/\n\n*,\n::before,\n::after {\n box-sizing: border-box; /* 1 */\n border-width: 0; /* 2 */\n border-style: solid; /* 2 */\n border-color: #e5e7eb; /* 2 */\n}\n\n::before,\n::after {\n --tw-content: '';\n}\n\n/*\n1. Use a consistent sensible line-height in all browsers.\n2. Prevent adjustments of font size after orientation changes in iOS.\n3. Use a more readable tab size.\n4. Use the user's configured `sans` font-family by default.\n5. Use the user's configured `sans` font-feature-settings by default.\n6. Use the user's configured `sans` font-variation-settings by default.\n*/\n\nhtml {\n line-height: 1.5; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n -moz-tab-size: 4; /* 3 */\n -o-tab-size: 4;\n tab-size: 4; /* 3 */\n font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"; /* 4 */\n font-feature-settings: normal; /* 5 */\n font-variation-settings: normal; /* 6 */\n}\n\n/*\n1. Remove the margin in all browsers.\n2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.\n*/\n\nbody {\n margin: 0; /* 1 */\n line-height: inherit; /* 2 */\n}\n\n/*\n1. Add the correct height in Firefox.\n2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\n3. Ensure horizontal rules are visible by default.\n*/\n\nhr {\n height: 0; /* 1 */\n color: inherit; /* 2 */\n border-top-width: 1px; /* 3 */\n}\n\n/*\nAdd the correct text decoration in Chrome, Edge, and Safari.\n*/\n\nabbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n}\n\n/*\nRemove the default font size and weight for headings.\n*/\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n font-size: inherit;\n font-weight: inherit;\n}\n\n/*\nReset links to optimize for opt-in styling instead of opt-out.\n*/\n\na {\n color: inherit;\n text-decoration: inherit;\n}\n\n/*\nAdd the correct font weight in Edge and Safari.\n*/\n\nb,\nstrong {\n font-weight: bolder;\n}\n\n/*\n1. Use the user's configured `mono` font family by default.\n2. Correct the odd `em` font sizing in all browsers.\n*/\n\ncode,\nkbd,\nsamp,\npre {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace; /* 1 */\n font-size: 1em; /* 2 */\n}\n\n/*\nAdd the correct font size in all browsers.\n*/\n\nsmall {\n font-size: 80%;\n}\n\n/*\nPrevent `sub` and `sup` elements from affecting the line height in all browsers.\n*/\n\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\n/*\n1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\n2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\n3. Remove gaps between table borders by default.\n*/\n\ntable {\n text-indent: 0; /* 1 */\n border-color: inherit; /* 2 */\n border-collapse: collapse; /* 3 */\n}\n\n/*\n1. Change the font styles in all browsers.\n2. Remove the margin in Firefox and Safari.\n3. Remove default padding in all browsers.\n*/\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n font-family: inherit; /* 1 */\n font-size: 100%; /* 1 */\n font-weight: inherit; /* 1 */\n line-height: inherit; /* 1 */\n color: inherit; /* 1 */\n margin: 0; /* 2 */\n padding: 0; /* 3 */\n}\n\n/*\nRemove the inheritance of text transform in Edge and Firefox.\n*/\n\nbutton,\nselect {\n text-transform: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Remove default button styles.\n*/\n\nbutton,\n[type='button'],\n[type='reset'],\n[type='submit'] {\n -webkit-appearance: button; /* 1 */\n background-color: transparent; /* 2 */\n background-image: none; /* 2 */\n}\n\n/*\nUse the modern Firefox focus style for all focusable elements.\n*/\n\n:-moz-focusring {\n outline: auto;\n}\n\n/*\nRemove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\n*/\n\n:-moz-ui-invalid {\n box-shadow: none;\n}\n\n/*\nAdd the correct vertical alignment in Chrome and Firefox.\n*/\n\nprogress {\n vertical-align: baseline;\n}\n\n/*\nCorrect the cursor style of increment and decrement buttons in Safari.\n*/\n\n::-webkit-inner-spin-button,\n::-webkit-outer-spin-button {\n height: auto;\n}\n\n/*\n1. Correct the odd appearance in Chrome and Safari.\n2. Correct the outline style in Safari.\n*/\n\n[type='search'] {\n -webkit-appearance: textfield; /* 1 */\n outline-offset: -2px; /* 2 */\n}\n\n/*\nRemove the inner padding in Chrome and Safari on macOS.\n*/\n\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Change font properties to `inherit` in Safari.\n*/\n\n::-webkit-file-upload-button {\n -webkit-appearance: button; /* 1 */\n font: inherit; /* 2 */\n}\n\n/*\nAdd the correct display in Chrome and Safari.\n*/\n\nsummary {\n display: list-item;\n}\n\n/*\nRemoves the default spacing and border for appropriate elements.\n*/\n\nblockquote,\ndl,\ndd,\nh1,\nh2,\nh3,\nh4,\nh5,\nh6,\nhr,\nfigure,\np,\npre {\n margin: 0;\n}\n\nfieldset {\n margin: 0;\n padding: 0;\n}\n\nlegend {\n padding: 0;\n}\n\nol,\nul,\nmenu {\n list-style: none;\n margin: 0;\n padding: 0;\n}\n\n/*\nPrevent resizing textareas horizontally by default.\n*/\n\ntextarea {\n resize: vertical;\n}\n\n/*\n1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\n2. Set the default placeholder color to the user's configured gray 400 color.\n*/\n\ninput::-moz-placeholder, textarea::-moz-placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n\ninput::placeholder,\ntextarea::placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n\n/*\nSet the default cursor for buttons.\n*/\n\nbutton,\n[role=\"button\"] {\n cursor: pointer;\n}\n\n/*\nMake sure disabled buttons don't get the pointer cursor.\n*/\n:disabled {\n cursor: default;\n}\n\n/*\n1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)\n2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\n This can trigger a poorly considered lint error in some tools but is included by design.\n*/\n\nimg,\nsvg,\nvideo,\ncanvas,\naudio,\niframe,\nembed,\nobject {\n display: block; /* 1 */\n vertical-align: middle; /* 2 */\n}\n\n/*\nConstrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\n*/\n\nimg,\nvideo {\n max-width: 100%;\n height: auto;\n}\n\n/* Make elements with the HTML hidden attribute stay hidden by default */\n[hidden] {\n display: none;\n}\n\n*, ::before, ::after {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n}\n\n::backdrop {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n}\n.block {\n display: block;\n}\n.inline {\n display: inline;\n}\n.resize-y {\n resize: vertical;\n}\n.overflow-y-auto {\n overflow-y: auto;\n}\n.border {\n border-width: 1px;\n}\n.bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity));\n}\n.italic {\n font-style: italic;\n}\n.filter {\n filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);\n}\n",".copilot-textarea.with-branding::after {\n content: ''; /* Initially empty because we overrdie this CSS dynamically and we want to avoid flashing */\n position: absolute;\n}\n \n \n.copilot-textarea.no-branding::after {\n content: '';\n}"],"mappings":";AAOA;AAAA;AAAA;AAGE;AACA;AACA;AACA;AAAA;AAGF;AAAA;AAEE;AAAA;AAYF;AACE;AACA;AACA;AACA;AACG;AACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AAAA;AAQF;AACE;AACA;AAAA;AASF;AACE;AACA;AACA;AAAA;AAOF;AACE;AACQ;AAAA;AAOV;AAAA;AAAA;AAAA;AAAA;AAAA;AAME;AACA;AAAA;AAOF;AACE;AACA;AAAA;AAOF;AAAA;AAEE;AAAA;AAQF;AAAA;AAAA;AAAA;AAIE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAOF;AACE;AAAA;AAOF;AAAA;AAEE;AACA;AACA;AACA;AAAA;AAGF;AACE;AAAA;AAGF;AACE;AAAA;AASF;AACE;AACA;AACA;AAAA;AASF;AAAA;AAAA;AAAA;AAAA;AAKE;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAOF;AAAA;AAEE;AAAA;AAQF;AAAA;AAAA;AAAA;AAIE;AACA;AACA;AAAA;AAOF;AACE;AAAA;AAOF;AACE;AAAA;AAOF;AACE;AAAA;AAOF;AAAA;AAEE;AAAA;AAQF;AACE;AACA;AAAA;AAOF;AACE;AAAA;AAQF;AACE;AACA;AAAA;AAOF;AACE;AAAA;AAOF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaE;AAAA;AAGF;AACE;AACA;AAAA;AAGF;AACE;AAAA;AAGF;AAAA;AAAA;AAGE;AACA;AACA;AAAA;AAOF;AACE;AAAA;AAQF;AAAA;AACE;AACA;AAAA;AAGF;AAAA;AAEE;AACA;AAAA;AAOF;AAAA;AAEE;AAAA;AAMF;AACE;AAAA;AASF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQE;AACA;AAAA;AAOF;AAAA;AAEE;AACA;AAAA;AAIF;AACE;AAAA;AAGF;AAAA;AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGF;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AACA;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;;;AC/eF;AACI;AACA;AAAA;AAIJ;AACI;AAAA;","names":[]}
1
+ {"version":3,"sources":["../src/styles.css","../src/components/base-copilot-textarea/base-copilot-textarea.css"],"sourcesContent":["/*\n! tailwindcss v3.3.0 | MIT License | https://tailwindcss.com\n*//*\n1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\n2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)\n*/\n\n*,\n::before,\n::after {\n box-sizing: border-box; /* 1 */\n border-width: 0; /* 2 */\n border-style: solid; /* 2 */\n border-color: #e5e7eb; /* 2 */\n}\n\n::before,\n::after {\n --tw-content: '';\n}\n\n/*\n1. Use a consistent sensible line-height in all browsers.\n2. Prevent adjustments of font size after orientation changes in iOS.\n3. Use a more readable tab size.\n4. Use the user's configured `sans` font-family by default.\n5. Use the user's configured `sans` font-feature-settings by default.\n6. Use the user's configured `sans` font-variation-settings by default.\n*/\n\nhtml {\n line-height: 1.5; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n -moz-tab-size: 4; /* 3 */\n -o-tab-size: 4;\n tab-size: 4; /* 3 */\n font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"; /* 4 */\n font-feature-settings: normal; /* 5 */\n font-variation-settings: normal; /* 6 */\n}\n\n/*\n1. Remove the margin in all browsers.\n2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.\n*/\n\nbody {\n margin: 0; /* 1 */\n line-height: inherit; /* 2 */\n}\n\n/*\n1. Add the correct height in Firefox.\n2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\n3. Ensure horizontal rules are visible by default.\n*/\n\nhr {\n height: 0; /* 1 */\n color: inherit; /* 2 */\n border-top-width: 1px; /* 3 */\n}\n\n/*\nAdd the correct text decoration in Chrome, Edge, and Safari.\n*/\n\nabbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n}\n\n/*\nRemove the default font size and weight for headings.\n*/\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n font-size: inherit;\n font-weight: inherit;\n}\n\n/*\nReset links to optimize for opt-in styling instead of opt-out.\n*/\n\na {\n color: inherit;\n text-decoration: inherit;\n}\n\n/*\nAdd the correct font weight in Edge and Safari.\n*/\n\nb,\nstrong {\n font-weight: bolder;\n}\n\n/*\n1. Use the user's configured `mono` font family by default.\n2. Correct the odd `em` font sizing in all browsers.\n*/\n\ncode,\nkbd,\nsamp,\npre {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace; /* 1 */\n font-size: 1em; /* 2 */\n}\n\n/*\nAdd the correct font size in all browsers.\n*/\n\nsmall {\n font-size: 80%;\n}\n\n/*\nPrevent `sub` and `sup` elements from affecting the line height in all browsers.\n*/\n\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\n/*\n1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\n2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\n3. Remove gaps between table borders by default.\n*/\n\ntable {\n text-indent: 0; /* 1 */\n border-color: inherit; /* 2 */\n border-collapse: collapse; /* 3 */\n}\n\n/*\n1. Change the font styles in all browsers.\n2. Remove the margin in Firefox and Safari.\n3. Remove default padding in all browsers.\n*/\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n font-family: inherit; /* 1 */\n font-size: 100%; /* 1 */\n font-weight: inherit; /* 1 */\n line-height: inherit; /* 1 */\n color: inherit; /* 1 */\n margin: 0; /* 2 */\n padding: 0; /* 3 */\n}\n\n/*\nRemove the inheritance of text transform in Edge and Firefox.\n*/\n\nbutton,\nselect {\n text-transform: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Remove default button styles.\n*/\n\nbutton,\n[type='button'],\n[type='reset'],\n[type='submit'] {\n -webkit-appearance: button; /* 1 */\n background-color: transparent; /* 2 */\n background-image: none; /* 2 */\n}\n\n/*\nUse the modern Firefox focus style for all focusable elements.\n*/\n\n:-moz-focusring {\n outline: auto;\n}\n\n/*\nRemove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\n*/\n\n:-moz-ui-invalid {\n box-shadow: none;\n}\n\n/*\nAdd the correct vertical alignment in Chrome and Firefox.\n*/\n\nprogress {\n vertical-align: baseline;\n}\n\n/*\nCorrect the cursor style of increment and decrement buttons in Safari.\n*/\n\n::-webkit-inner-spin-button,\n::-webkit-outer-spin-button {\n height: auto;\n}\n\n/*\n1. Correct the odd appearance in Chrome and Safari.\n2. Correct the outline style in Safari.\n*/\n\n[type='search'] {\n -webkit-appearance: textfield; /* 1 */\n outline-offset: -2px; /* 2 */\n}\n\n/*\nRemove the inner padding in Chrome and Safari on macOS.\n*/\n\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Change font properties to `inherit` in Safari.\n*/\n\n::-webkit-file-upload-button {\n -webkit-appearance: button; /* 1 */\n font: inherit; /* 2 */\n}\n\n/*\nAdd the correct display in Chrome and Safari.\n*/\n\nsummary {\n display: list-item;\n}\n\n/*\nRemoves the default spacing and border for appropriate elements.\n*/\n\nblockquote,\ndl,\ndd,\nh1,\nh2,\nh3,\nh4,\nh5,\nh6,\nhr,\nfigure,\np,\npre {\n margin: 0;\n}\n\nfieldset {\n margin: 0;\n padding: 0;\n}\n\nlegend {\n padding: 0;\n}\n\nol,\nul,\nmenu {\n list-style: none;\n margin: 0;\n padding: 0;\n}\n\n/*\nPrevent resizing textareas horizontally by default.\n*/\n\ntextarea {\n resize: vertical;\n}\n\n/*\n1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\n2. Set the default placeholder color to the user's configured gray 400 color.\n*/\n\ninput::-moz-placeholder, textarea::-moz-placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n\ninput::placeholder,\ntextarea::placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n\n/*\nSet the default cursor for buttons.\n*/\n\nbutton,\n[role=\"button\"] {\n cursor: pointer;\n}\n\n/*\nMake sure disabled buttons don't get the pointer cursor.\n*/\n:disabled {\n cursor: default;\n}\n\n/*\n1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)\n2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\n This can trigger a poorly considered lint error in some tools but is included by design.\n*/\n\nimg,\nsvg,\nvideo,\ncanvas,\naudio,\niframe,\nembed,\nobject {\n display: block; /* 1 */\n vertical-align: middle; /* 2 */\n}\n\n/*\nConstrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\n*/\n\nimg,\nvideo {\n max-width: 100%;\n height: auto;\n}\n\n/* Make elements with the HTML hidden attribute stay hidden by default */\n[hidden] {\n display: none;\n}\n\n*, ::before, ::after {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n}\n\n::backdrop {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n}\n.block {\n display: block;\n}\n.inline {\n display: inline;\n}\n.resize-y {\n resize: vertical;\n}\n.overflow-y-auto {\n overflow-y: auto;\n}\n.border {\n border-width: 1px;\n}\n.bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity));\n}\n.italic {\n font-style: italic;\n}\n.blur {\n --tw-blur: blur(8px);\n filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);\n}\n.filter {\n filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);\n}\n",".copilot-textarea.with-branding::after {\n content: ''; /* Initially empty because we overrdie this CSS dynamically and we want to avoid flashing */\n position: absolute;\n}\n \n \n.copilot-textarea.no-branding::after {\n content: '';\n}"],"mappings":";AAOA;AAAA;AAAA;AAGE;AACA;AACA;AACA;AAAA;AAGF;AAAA;AAEE;AAAA;AAYF;AACE;AACA;AACA;AACA;AACG;AACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AAAA;AAQF;AACE;AACA;AAAA;AASF;AACE;AACA;AACA;AAAA;AAOF;AACE;AACQ;AAAA;AAOV;AAAA;AAAA;AAAA;AAAA;AAAA;AAME;AACA;AAAA;AAOF;AACE;AACA;AAAA;AAOF;AAAA;AAEE;AAAA;AAQF;AAAA;AAAA;AAAA;AAIE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAOF;AACE;AAAA;AAOF;AAAA;AAEE;AACA;AACA;AACA;AAAA;AAGF;AACE;AAAA;AAGF;AACE;AAAA;AASF;AACE;AACA;AACA;AAAA;AASF;AAAA;AAAA;AAAA;AAAA;AAKE;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAOF;AAAA;AAEE;AAAA;AAQF;AAAA;AAAA;AAAA;AAIE;AACA;AACA;AAAA;AAOF;AACE;AAAA;AAOF;AACE;AAAA;AAOF;AACE;AAAA;AAOF;AAAA;AAEE;AAAA;AAQF;AACE;AACA;AAAA;AAOF;AACE;AAAA;AAQF;AACE;AACA;AAAA;AAOF;AACE;AAAA;AAOF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaE;AAAA;AAGF;AACE;AACA;AAAA;AAGF;AACE;AAAA;AAGF;AAAA;AAAA;AAGE;AACA;AACA;AAAA;AAOF;AACE;AAAA;AAQF;AAAA;AACE;AACA;AAAA;AAGF;AAAA;AAEE;AACA;AAAA;AAOF;AAAA;AAEE;AAAA;AAMF;AACE;AAAA;AASF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQE;AACA;AAAA;AAOF;AAAA;AAEE;AACA;AAAA;AAIF;AACE;AAAA;AAGF;AAAA;AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGF;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AACA;AAAA;AAEF;AACE;AAAA;AAEF;AACE;AACA;AAAA;AAEF;AACE;AAAA;;;ACnfF;AACI;AACA;AAAA;AAIJ;AACI;AAAA;","names":[]}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- export { BaseCopilotTextarea, BaseCopilotTextareaProps } from './components/base-copilot-textarea/base-copilot-textarea.js';
1
+ export { BaseCopilotTextarea } from './components/base-copilot-textarea/base-copilot-textarea.js';
2
2
  export { CopilotTextarea, CopilotTextareaProps } from './components/copilot-textarea/copilot-textarea.js';
3
3
  export { BaseAutosuggestionsConfig, defaultBaseAutosuggestionsConfig } from './types/base/base-autosuggestions-config.js';
4
4
  export { AutosuggestionsBareFunction } from './types/base/autosuggestions-bare-function.js';
5
+ export { BaseCopilotTextareaProps } from './types/base/base-copilot-textarea-props.js';
6
+ export { HTMLCopilotTextAreaElement } from './types/html-copilot-textarea-element.js';
5
7
  export { AutosuggestionsConfig, MakeSystemPrompt, defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt } from './types/standard-autosuggestions/autosuggestions-config.js';
6
8
  export { MinimalChatGPTMessage } from './types/standard-autosuggestions/minimal-chat-gpt-message.js';
7
9
  import 'react';
package/dist/index.mjs CHANGED
@@ -1,27 +1,29 @@
1
- import './chunk-FD6FGKYY.mjs';
2
- import './chunk-IU3WTXLQ.mjs';
1
+ import './chunk-DE5K76I2.mjs';
2
+ import './chunk-WADHCMPK.mjs';
3
3
  import './chunk-MMVDU6DF.mjs';
4
- export { CopilotTextarea } from './chunk-NHLYAJCQ.mjs';
4
+ export { CopilotTextarea } from './chunk-DCQ27XRF.mjs';
5
5
  import './chunk-A3SFEHWZ.mjs';
6
6
  import './chunk-AZQCUNBV.mjs';
7
7
  export { defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt } from './chunk-EHQ5TN4R.mjs';
8
- export { BaseCopilotTextarea } from './chunk-CU2M5BIJ.mjs';
8
+ export { BaseCopilotTextarea } from './chunk-M6QFKIBE.mjs';
9
+ import './chunk-HZGSG7ST.mjs';
10
+ import './chunk-UW3ITU2Y.mjs';
11
+ import './chunk-CSGFJU3L.mjs';
12
+ import './chunk-AOEXKPIX.mjs';
9
13
  import './chunk-WJYQWL4I.mjs';
10
14
  import './chunk-4XYYSJ5C.mjs';
11
15
  import './chunk-TSF4AJIK.mjs';
12
- import './chunk-3UQM3NLM.mjs';
16
+ import './chunk-KCHYD3EB.mjs';
17
+ import './chunk-KGKLUWKW.mjs';
13
18
  import './chunk-WJHSY5T6.mjs';
14
19
  export { defaultBaseAutosuggestionsConfig } from './chunk-7KWRVIYV.mjs';
15
20
  import './chunk-LNAIMEB2.mjs';
16
21
  import './chunk-OELUUJZY.mjs';
17
- import './chunk-THWPPG6M.mjs';
22
+ import './chunk-IGQI27NI.mjs';
23
+ import './chunk-IU3WTXLQ.mjs';
18
24
  import './chunk-H4VKQGVU.mjs';
19
- import './chunk-E2UEE45I.mjs';
20
- import './chunk-UW3ITU2Y.mjs';
21
- import './chunk-KGKLUWKW.mjs';
22
- import './chunk-6SYD77G6.mjs';
23
- import './chunk-KCHYD3EB.mjs';
24
25
  import './chunk-NKW5OU2S.mjs';
26
+ import './chunk-3UQM3NLM.mjs';
25
27
  import './chunk-MRXNTQOX.mjs';
26
28
  //# sourceMappingURL=out.js.map
27
29
  //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,38 @@
1
+ import { TextareaHTMLAttributes } from 'react';
2
+ import { BaseAutosuggestionsConfig } from './base-autosuggestions-config.js';
3
+
4
+ /**
5
+ * `BaseCopilotTextareaProps` defines the properties for the `BaseCopilotTextarea` component.
6
+ *
7
+ * @extends {Omit<TextareaHTMLAttributes<HTMLDivElement>, "onChange">}
8
+ *
9
+ * @property {boolean} [disableBranding=false] - Determines whether branding should be disabled. Default is `false`.
10
+ *
11
+ * @property {React.CSSProperties} [placeholderStyle] - Specifies the CSS styles to apply to the placeholder text.
12
+ *
13
+ * @property {React.CSSProperties} [suggestionsStyle] - Specifies the CSS styles to apply to the suggestions list.
14
+ *
15
+ * @property {string} [value] - The initial value of the textarea. Can be controlled via `onValueChange`.
16
+ *
17
+ * @property {(value: string) => void} [onValueChange] - Callback invoked when the value of the textarea changes.
18
+ *
19
+ * @property {(event: React.ChangeEvent<HTMLTextAreaElement>) => void} [onChange] - Callback invoked when a `change` event is triggered on the textarea element. The event only actually includes the `event.target.value` and `event.currentTarget.value` properties (all that is required in 99% of cases).
20
+ *
21
+ * @property {Partial<BaseAutosuggestionsConfig> & {
22
+ * purposePrompt: string;
23
+ * }} autosuggestionsConfig - Configuration settings for the autosuggestions feature.
24
+ * Includes a mandatory `purposePrompt` to guide the autosuggestions.
25
+ */
26
+ interface BaseCopilotTextareaProps extends Omit<TextareaHTMLAttributes<HTMLDivElement>, "onChange"> {
27
+ disableBranding?: boolean;
28
+ placeholderStyle?: React.CSSProperties;
29
+ suggestionsStyle?: React.CSSProperties;
30
+ value?: string;
31
+ onValueChange?: (value: string) => void;
32
+ onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
33
+ autosuggestionsConfig: Partial<BaseAutosuggestionsConfig> & {
34
+ purposePrompt: string;
35
+ };
36
+ }
37
+
38
+ export { BaseCopilotTextareaProps };
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=out.js.map
3
+ //# sourceMappingURL=base-copilot-textarea-props.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,2 +1,4 @@
1
1
  export { BaseAutosuggestionsConfig, defaultBaseAutosuggestionsConfig } from './base-autosuggestions-config.js';
2
2
  export { AutosuggestionsBareFunction } from './autosuggestions-bare-function.js';
3
+ export { BaseCopilotTextareaProps } from './base-copilot-textarea-props.js';
4
+ import 'react';
@@ -0,0 +1,7 @@
1
+ interface HTMLCopilotTextAreaElement extends HTMLElement {
2
+ value: string;
3
+ focus: () => void;
4
+ blur: () => void;
5
+ }
6
+
7
+ export { HTMLCopilotTextAreaElement };
@@ -0,0 +1,3 @@
1
+ import '../chunk-WADHCMPK.mjs';
2
+ //# sourceMappingURL=out.js.map
3
+ //# sourceMappingURL=html-copilot-textarea-element.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -1,4 +1,7 @@
1
1
  export { BaseAutosuggestionsConfig, defaultBaseAutosuggestionsConfig } from './base/base-autosuggestions-config.js';
2
2
  export { AutosuggestionsBareFunction } from './base/autosuggestions-bare-function.js';
3
+ export { BaseCopilotTextareaProps } from './base/base-copilot-textarea-props.js';
4
+ export { HTMLCopilotTextAreaElement } from './html-copilot-textarea-element.js';
3
5
  export { AutosuggestionsConfig, MakeSystemPrompt, defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt } from './standard-autosuggestions/autosuggestions-config.js';
4
6
  export { MinimalChatGPTMessage } from './standard-autosuggestions/minimal-chat-gpt-message.js';
7
+ import 'react';
@@ -1,4 +1,5 @@
1
- import '../chunk-FD6FGKYY.mjs';
1
+ import '../chunk-DE5K76I2.mjs';
2
+ import '../chunk-WADHCMPK.mjs';
2
3
  import '../chunk-AZQCUNBV.mjs';
3
4
  export { defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt } from '../chunk-EHQ5TN4R.mjs';
4
5
  import '../chunk-WJHSY5T6.mjs';
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.10.0",
7
+ "version": "0.12.0",
8
8
  "sideEffects": [
9
9
  "**/*.css"
10
10
  ],
@@ -30,9 +30,9 @@
30
30
  "ts-jest": "^29.1.1",
31
31
  "tsup": "^6.1.3",
32
32
  "typescript": "^4.9.4",
33
+ "eslint-config-custom": "0.2.0",
33
34
  "tailwind-config": "0.1.0",
34
- "tsconfig": "0.3.0",
35
- "eslint-config-custom": "0.2.0"
35
+ "tsconfig": "0.3.0"
36
36
  },
37
37
  "dependencies": {
38
38
  "ai": "^2.1.22",
@@ -1,16 +1,10 @@
1
- import "./base-copilot-textarea.css";
2
- import {
3
- TextareaHTMLAttributes,
4
- useCallback,
5
- useEffect,
6
- useMemo,
7
- useState,
8
- } from "react";
1
+ import React, { useCallback, useEffect, useMemo, useState } from "react";
9
2
  import { Descendant, Editor } from "slate";
10
3
  import { Editable, Slate } from "slate-react";
11
4
  import { twMerge } from "tailwind-merge";
12
- import { useAutosuggestions } from "../../hooks/use-autosuggestions";
13
- import { useCopilotTextareaEditor } from "../../hooks/use-copilot-textarea-editor";
5
+ import { useAutosuggestions } from "../../hooks/base-copilot-textarea-implementation/use-autosuggestions";
6
+ import { useCopilotTextareaEditor } from "../../hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor";
7
+ import { usePopulateCopilotTextareaRef } from "../../hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref";
14
8
  import {
15
9
  getFullEditorTextWithNewlines,
16
10
  getTextAroundCursor,
@@ -24,164 +18,200 @@ import {
24
18
  defaultBaseAutosuggestionsConfig,
25
19
  } from "../../types/base";
26
20
  import { AutosuggestionState } from "../../types/base/autosuggestion-state";
21
+ import { BaseCopilotTextareaProps } from "../../types/base/base-copilot-textarea-props";
22
+ import "./base-copilot-textarea.css";
27
23
  import { makeRenderElementFunction } from "./render-element";
28
24
  import { makeRenderPlaceholderFunction } from "./render-placeholder";
29
25
  import { useAddBrandingCss } from "./use-add-branding-css";
30
26
 
31
- export interface BaseCopilotTextareaProps
32
- extends TextareaHTMLAttributes<HTMLDivElement> {
33
- disableBranding?: boolean;
34
- placeholderStyle?: React.CSSProperties;
35
- suggestionsStyle?: React.CSSProperties;
36
- value?: string;
37
- onValueChange?: (value: string) => void;
38
- autosuggestionsConfig: Partial<BaseAutosuggestionsConfig> & {
39
- purposePrompt: string;
40
- };
27
+ export interface HTMLCopilotTextAreaElement extends HTMLElement {
28
+ value: string;
29
+ focus: () => void;
30
+ blur: () => void;
41
31
  }
42
32
 
43
- export function BaseCopilotTextarea(
44
- props: BaseCopilotTextareaProps & {
45
- autosuggestionsFunction: AutosuggestionsBareFunction;
46
- }
47
- ): JSX.Element {
48
- const autosuggestionsConfig: BaseAutosuggestionsConfig = {
49
- ...defaultBaseAutosuggestionsConfig,
50
- ...props.autosuggestionsConfig,
51
- };
52
-
53
- const valueOnInitialRender = useMemo(() => props.value ?? "", []);
54
- const [lastKnownFullEditorText, setLastKnownFullEditorText] =
55
- useState(valueOnInitialRender);
56
-
57
- const initialValue: Descendant[] = useMemo(() => {
58
- return [
59
- {
60
- type: "paragraph",
61
- children: [{ text: valueOnInitialRender }],
62
- },
63
- ];
64
- }, [valueOnInitialRender]);
65
-
66
- const editor = useCopilotTextareaEditor();
67
-
68
- const insertText = useCallback(
69
- (autosuggestion: AutosuggestionState) => {
70
- Editor.insertText(editor, autosuggestion.text, {
71
- at: autosuggestion.point,
72
- });
33
+ export const BaseCopilotTextarea = React.forwardRef(
34
+ (
35
+ props: BaseCopilotTextareaProps & {
36
+ autosuggestionsFunction: AutosuggestionsBareFunction;
73
37
  },
74
- [editor]
75
- );
76
-
77
- const {
78
- currentAutocompleteSuggestion,
79
- onChangeHandler: onChangeHandlerForAutocomplete,
80
- onKeyDownHandler: onKeyDownHandlerForAutocomplete,
81
- } = useAutosuggestions(
82
- autosuggestionsConfig.debounceTime,
83
- autosuggestionsConfig.acceptAutosuggestionKey,
84
- props.autosuggestionsFunction,
85
- insertText,
86
- autosuggestionsConfig.disableWhenEmpty,
87
- autosuggestionsConfig.disabled
88
- );
89
-
90
- // sync autosuggestions state with the editor
91
- useEffect(() => {
92
- clearAutocompletionsFromEditor(editor);
93
- if (currentAutocompleteSuggestion) {
94
- addAutocompletionsToEditor(
95
- editor,
96
- currentAutocompleteSuggestion.text,
97
- currentAutocompleteSuggestion.point
98
- );
99
- }
100
- }, [currentAutocompleteSuggestion]);
101
-
102
- const suggestionStyleAugmented: React.CSSProperties = useMemo(() => {
103
- return {
104
- fontStyle: "italic",
105
- color: "gray",
106
- ...props.suggestionsStyle,
38
+ ref: React.Ref<HTMLCopilotTextAreaElement>
39
+ ): JSX.Element => {
40
+ const autosuggestionsConfig: BaseAutosuggestionsConfig = {
41
+ ...defaultBaseAutosuggestionsConfig,
42
+ ...props.autosuggestionsConfig,
107
43
  };
108
- }, [props.suggestionsStyle]);
109
-
110
- useAddBrandingCss(suggestionStyleAugmented, props.disableBranding);
111
-
112
- const renderElementMemoized = useMemo(() => {
113
- return makeRenderElementFunction(suggestionStyleAugmented);
114
- }, [suggestionStyleAugmented]);
115
44
 
116
- const renderPlaceholderMemoized = useMemo(() => {
117
- // For some reason slateJS specifies a top value of 0, which makes for strange styling. We override this here.
118
- const placeholderStyleSlatejsOverrides: React.CSSProperties = {
119
- top: undefined,
120
- };
121
-
122
- const placeholderStyleAugmented: React.CSSProperties = {
123
- ...placeholderStyleSlatejsOverrides,
124
- ...props.placeholderStyle,
125
- };
126
-
127
- return makeRenderPlaceholderFunction(placeholderStyleAugmented);
128
- }, [props.placeholderStyle]);
129
-
130
- // update the editor text, but only when the value changes from outside the component
131
- useEffect(() => {
132
- if (props.value === lastKnownFullEditorText) {
133
- return;
134
- }
135
-
136
- setLastKnownFullEditorText(props.value ?? "");
137
- replaceEditorText(editor, props.value ?? "");
138
- }, [props.value]);
139
-
140
- // separate into TextareaHTMLAttributes<HTMLDivElement> and CopilotTextareaProps
141
- const {
142
- placeholderStyle,
143
- value,
144
- onValueChange,
145
- autosuggestionsConfig: autosuggestionsConfigFromProps,
146
- autosuggestionsFunction,
147
- className,
148
- ...propsToForward
149
- } = props;
150
-
151
- const moddedClassName = (() => {
152
- const baseClassName = "copilot-textarea";
153
- const brandingClass = props.disableBranding
154
- ? "no-branding"
155
- : "with-branding";
156
- const defaultTailwindClassName = "bg-white overflow-y-auto resize-y";
157
- const mergedClassName = twMerge(defaultTailwindClassName, className ?? "");
158
- return `${baseClassName} ${brandingClass} ${mergedClassName}`;
159
- })();
160
-
161
- return (
162
- // Add the editable component inside the context.
163
- <Slate
164
- editor={editor}
165
- initialValue={initialValue}
166
- onChange={(value) => {
167
- const newEditorState = getTextAroundCursor(editor);
168
-
169
- const fullEditorText = newEditorState
170
- ? newEditorState.textBeforeCursor + newEditorState.textAfterCursor
171
- : getFullEditorTextWithNewlines(editor); // we don't double-parse the editor. When `newEditorState` is null, we didn't parse the editor yet.
172
-
173
- setLastKnownFullEditorText(fullEditorText);
174
- onChangeHandlerForAutocomplete(newEditorState);
175
- props.onValueChange?.(fullEditorText);
176
- }}
177
- >
178
- <Editable
179
- renderElement={renderElementMemoized}
180
- renderPlaceholder={renderPlaceholderMemoized}
181
- onKeyDown={onKeyDownHandlerForAutocomplete}
182
- className={moddedClassName}
183
- {...propsToForward}
184
- />
185
- </Slate>
186
- );
45
+ const valueOnInitialRender = useMemo(() => props.value ?? "", []);
46
+ const [lastKnownFullEditorText, setLastKnownFullEditorText] =
47
+ useState(valueOnInitialRender);
48
+
49
+ const initialValue: Descendant[] = useMemo(() => {
50
+ return [
51
+ {
52
+ type: "paragraph",
53
+ children: [{ text: valueOnInitialRender }],
54
+ },
55
+ ];
56
+ }, [valueOnInitialRender]);
57
+
58
+ const editor = useCopilotTextareaEditor();
59
+
60
+ const insertText = useCallback(
61
+ (autosuggestion: AutosuggestionState) => {
62
+ Editor.insertText(editor, autosuggestion.text, {
63
+ at: autosuggestion.point,
64
+ });
65
+ },
66
+ [editor]
67
+ );
68
+
69
+ const {
70
+ currentAutocompleteSuggestion,
71
+ onChangeHandler: onChangeHandlerForAutocomplete,
72
+ onKeyDownHandler: onKeyDownHandlerForAutocomplete,
73
+ } = useAutosuggestions(
74
+ autosuggestionsConfig.debounceTime,
75
+ autosuggestionsConfig.acceptAutosuggestionKey,
76
+ props.autosuggestionsFunction,
77
+ insertText,
78
+ autosuggestionsConfig.disableWhenEmpty,
79
+ autosuggestionsConfig.disabled
80
+ );
81
+
82
+ // sync autosuggestions state with the editor
83
+ useEffect(() => {
84
+ clearAutocompletionsFromEditor(editor);
85
+ if (currentAutocompleteSuggestion) {
86
+ addAutocompletionsToEditor(
87
+ editor,
88
+ currentAutocompleteSuggestion.text,
89
+ currentAutocompleteSuggestion.point
90
+ );
91
+ }
92
+ }, [currentAutocompleteSuggestion]);
93
+
94
+ const suggestionStyleAugmented: React.CSSProperties = useMemo(() => {
95
+ return {
96
+ fontStyle: "italic",
97
+ color: "gray",
98
+ ...props.suggestionsStyle,
99
+ };
100
+ }, [props.suggestionsStyle]);
101
+
102
+ useAddBrandingCss(suggestionStyleAugmented, props.disableBranding);
103
+
104
+ const renderElementMemoized = useMemo(() => {
105
+ return makeRenderElementFunction(suggestionStyleAugmented);
106
+ }, [suggestionStyleAugmented]);
107
+
108
+ const renderPlaceholderMemoized = useMemo(() => {
109
+ // For some reason slateJS specifies a top value of 0, which makes for strange styling. We override this here.
110
+ const placeholderStyleSlatejsOverrides: React.CSSProperties = {
111
+ top: undefined,
112
+ };
113
+
114
+ const placeholderStyleAugmented: React.CSSProperties = {
115
+ ...placeholderStyleSlatejsOverrides,
116
+ ...props.placeholderStyle,
117
+ };
118
+
119
+ return makeRenderPlaceholderFunction(placeholderStyleAugmented);
120
+ }, [props.placeholderStyle]);
121
+
122
+ // update the editor text, but only when the value changes from outside the component
123
+ useEffect(() => {
124
+ if (props.value === lastKnownFullEditorText) {
125
+ return;
126
+ }
127
+
128
+ setLastKnownFullEditorText(props.value ?? "");
129
+ replaceEditorText(editor, props.value ?? "");
130
+ }, [props.value]);
131
+
132
+ // separate into TextareaHTMLAttributes<HTMLDivElement> and CopilotTextareaProps
133
+ const {
134
+ placeholderStyle,
135
+ value,
136
+ onValueChange,
137
+ autosuggestionsConfig: autosuggestionsConfigFromProps,
138
+ autosuggestionsFunction,
139
+ className,
140
+ onChange,
141
+ onKeyDown,
142
+ ...propsToForward
143
+ } = props;
144
+
145
+ const moddedClassName = (() => {
146
+ const baseClassName = "copilot-textarea";
147
+ const brandingClass = props.disableBranding
148
+ ? "no-branding"
149
+ : "with-branding";
150
+ const defaultTailwindClassName = "bg-white overflow-y-auto resize-y";
151
+ const mergedClassName = twMerge(
152
+ defaultTailwindClassName,
153
+ className ?? ""
154
+ );
155
+ return `${baseClassName} ${brandingClass} ${mergedClassName}`;
156
+ })();
157
+
158
+ usePopulateCopilotTextareaRef(editor, ref);
159
+
160
+ return (
161
+ <Slate
162
+ editor={editor}
163
+ initialValue={initialValue}
164
+ onChange={(value) => {
165
+ const newEditorState = getTextAroundCursor(editor);
166
+
167
+ const fullEditorText = newEditorState
168
+ ? newEditorState.textBeforeCursor + newEditorState.textAfterCursor
169
+ : getFullEditorTextWithNewlines(editor); // we don't double-parse the editor. When `newEditorState` is null, we didn't parse the editor yet.
170
+
171
+ setLastKnownFullEditorText(fullEditorText);
172
+ onChangeHandlerForAutocomplete(newEditorState);
173
+
174
+ props.onValueChange?.(fullEditorText);
175
+ props.onChange?.(makeSemiFakeReactTextAreaEvent(fullEditorText));
176
+ }}
177
+ >
178
+ <Editable
179
+ renderElement={renderElementMemoized}
180
+ renderPlaceholder={renderPlaceholderMemoized}
181
+ onKeyDown={(event) => {
182
+ onKeyDownHandlerForAutocomplete(event); // forward the event for internal use
183
+ props.onKeyDown?.(event); // forward the event for external use
184
+ }}
185
+ className={moddedClassName}
186
+ {...propsToForward}
187
+ />
188
+ </Slate>
189
+ );
190
+ }
191
+ );
192
+
193
+ // Consumers of <textarea> expect a `onChange: (React.ChangeEvent<HTMLTextAreaElement>) => void` event handler to be passed in.
194
+ // This is *extremely* common, and we want to support it.
195
+ //
196
+ // We can't support the full functionality, but in 99% of cases, the consumer only cares about the `event.target.value` property --
197
+ // that's how they get the new value of the textarea.
198
+ //
199
+ // So, the tradeoff we are making is minimizing compiler complaint, with a small chance of runtime error.
200
+ // The alternative would be defining a different onChange entrypoint (we actually do have that in `onValueChange`),
201
+ // And starting to explain subtleties to users the moment they try to use the component for the first time for very basic functionality.
202
+ //
203
+ // If this proves problematic, we can always revisit this decision.
204
+ function makeSemiFakeReactTextAreaEvent(
205
+ currentText: string
206
+ ): React.ChangeEvent<HTMLTextAreaElement> {
207
+ return {
208
+ target: {
209
+ value: currentText,
210
+ type: "copilot-textarea",
211
+ },
212
+ currentTarget: {
213
+ value: currentText,
214
+ type: "copilot-textarea",
215
+ },
216
+ } as React.ChangeEvent<HTMLTextAreaElement>;
187
217
  }
@@ -4,11 +4,14 @@ export function useAddBrandingCss(
4
4
  suggestionStyleAugmented: React.CSSProperties,
5
5
  disableBranding: boolean | undefined
6
6
  ) {
7
+ const cssSelector = ".copilot-textarea.with-branding";
7
8
  useEffect(() => {
8
9
  if (disableBranding) {
9
10
  return;
10
11
  }
11
12
 
13
+ // ---
14
+ // 1: Add the CSS to the DOM
12
15
  const styleEl = document.createElement("style");
13
16
  styleEl.id = "dynamic-styles";
14
17
 
@@ -36,16 +39,37 @@ export function useAddBrandingCss(
36
39
 
37
40
  // Append it to the ::after class
38
41
  styleEl.innerHTML = `
39
- .copilot-textarea.with-branding::after {
42
+ ${cssSelector}::after {
40
43
  ${dynamicStyles}
41
44
  }
42
45
  `;
43
46
 
44
47
  document.head.appendChild(styleEl);
45
48
 
49
+ // ---
50
+ // 2: Add the scroll listener (to keep the branding in the bottom right as the textarea scrolls)
51
+ const textarea = document.querySelector(cssSelector);
52
+ const handleScroll = () => {
53
+ const styleEl = document.getElementById("dynamic-styles");
54
+ if (styleEl && textarea) {
55
+ const offsetFromBottom = -textarea.scrollTop + 6;
56
+ const offsetFromRight = -textarea.scrollLeft + 6;
57
+ styleEl.innerHTML = `
58
+ ${cssSelector}::after {
59
+ ${dynamicStyles}
60
+ bottom: ${offsetFromBottom}px;
61
+ right: ${offsetFromRight}px;
62
+ }
63
+ `;
64
+ }
65
+ };
66
+
67
+ textarea?.addEventListener("scroll", handleScroll);
68
+
46
69
  // Cleanup
47
70
  return () => {
48
71
  document.getElementById("dynamic-styles")?.remove();
72
+ textarea?.removeEventListener("scroll", handleScroll);
49
73
  };
50
74
  }, [disableBranding, suggestionStyleAugmented]);
51
75
  }