@ai-stack/payloadcms 3.0.0-beta.65.2 → 3.0.0-beta.95.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 (131) hide show
  1. package/dist/ai/models/anthropic/index.d.ts.map +1 -1
  2. package/dist/ai/models/anthropic/index.js +3 -3
  3. package/dist/ai/models/anthropic/index.js.map +1 -1
  4. package/dist/ai/models/elevenLabs/index.d.ts.map +1 -1
  5. package/dist/ai/models/elevenLabs/index.js +1 -11
  6. package/dist/ai/models/elevenLabs/index.js.map +1 -1
  7. package/dist/ai/models/index.js +2 -2
  8. package/dist/ai/models/index.js.map +1 -1
  9. package/dist/ai/models/openai/index.d.ts.map +1 -1
  10. package/dist/ai/models/openai/index.js +3 -2
  11. package/dist/ai/models/openai/index.js.map +1 -1
  12. package/dist/ai/prompts.d.ts +1 -0
  13. package/dist/ai/prompts.d.ts.map +1 -1
  14. package/dist/ai/prompts.js +5 -2
  15. package/dist/ai/prompts.js.map +1 -1
  16. package/dist/ai/{editor → schemas}/lexical.schema.d.ts +2 -2
  17. package/dist/ai/schemas/lexical.schema.d.ts.map +1 -0
  18. package/dist/ai/schemas/lexical.schema.js.map +1 -0
  19. package/dist/collections/Instructions.d.ts.map +1 -1
  20. package/dist/collections/Instructions.js +9 -12
  21. package/dist/collections/Instructions.js.map +1 -1
  22. package/dist/endpoints/index.d.ts +1 -1
  23. package/dist/endpoints/index.d.ts.map +1 -1
  24. package/dist/endpoints/index.js +17 -50
  25. package/dist/endpoints/index.js.map +1 -1
  26. package/dist/exports/client.d.ts +4 -0
  27. package/dist/exports/client.d.ts.map +1 -0
  28. package/dist/exports/client.js +5 -0
  29. package/dist/exports/client.js.map +1 -0
  30. package/dist/exports/fields.d.ts +3 -1
  31. package/dist/exports/fields.d.ts.map +1 -1
  32. package/dist/exports/fields.js +3 -0
  33. package/dist/exports/fields.js.map +1 -1
  34. package/dist/fields/DescriptionField/DescriptionField.d.ts +1 -2
  35. package/dist/fields/DescriptionField/DescriptionField.d.ts.map +1 -1
  36. package/dist/fields/DescriptionField/DescriptionField.js +2 -1
  37. package/dist/fields/DescriptionField/DescriptionField.js.map +1 -1
  38. package/dist/fields/DescriptionField/DescriptionFieldComponent.d.ts +1 -2
  39. package/dist/fields/DescriptionField/DescriptionFieldComponent.d.ts.map +1 -1
  40. package/dist/fields/DescriptionField/DescriptionFieldComponent.js +2 -1
  41. package/dist/fields/DescriptionField/DescriptionFieldComponent.js.map +1 -1
  42. package/dist/fields/LexicalEditor/ActionsFeatureComponent.js +1 -1
  43. package/dist/fields/LexicalEditor/ActionsFeatureComponent.js.map +1 -1
  44. package/dist/fields/LexicalEditor/feature.server.d.ts.map +1 -1
  45. package/dist/fields/LexicalEditor/feature.server.js +2 -2
  46. package/dist/fields/LexicalEditor/feature.server.js.map +1 -1
  47. package/dist/fields/PromptEditorField/PromptEditorField.d.ts +1 -1
  48. package/dist/fields/PromptEditorField/PromptEditorField.d.ts.map +1 -1
  49. package/dist/fields/PromptEditorField/PromptEditorField.js +32 -51
  50. package/dist/fields/PromptEditorField/PromptEditorField.js.map +1 -1
  51. package/dist/fields/SelectField/SelectField.d.ts +9 -2
  52. package/dist/fields/SelectField/SelectField.d.ts.map +1 -1
  53. package/dist/fields/SelectField/SelectField.js +26 -23
  54. package/dist/fields/SelectField/SelectField.js.map +1 -1
  55. package/dist/index.d.ts +2 -2
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +3 -3
  58. package/dist/index.js.map +1 -1
  59. package/dist/init.d.ts.map +1 -1
  60. package/dist/init.js +14 -2
  61. package/dist/init.js.map +1 -1
  62. package/dist/libraries/autocomplete/AutocompleteTextArea.d.ts +8 -0
  63. package/dist/libraries/autocomplete/AutocompleteTextArea.d.ts.map +1 -0
  64. package/dist/libraries/autocomplete/AutocompleteTextArea.js +435 -0
  65. package/dist/libraries/autocomplete/AutocompleteTextArea.js.map +1 -0
  66. package/dist/libraries/autocomplete/AutocompleteTextArea.module.scss +35 -0
  67. package/dist/libraries/handlebars/asyncHandlebars.d.ts +2 -0
  68. package/dist/libraries/handlebars/asyncHandlebars.d.ts.map +1 -0
  69. package/dist/libraries/handlebars/asyncHandlebars.js +5 -0
  70. package/dist/libraries/handlebars/asyncHandlebars.js.map +1 -0
  71. package/dist/libraries/handlebars/helpers.d.ts +2 -0
  72. package/dist/libraries/handlebars/helpers.d.ts.map +1 -0
  73. package/dist/libraries/handlebars/helpers.js +22 -0
  74. package/dist/libraries/handlebars/helpers.js.map +1 -0
  75. package/dist/libraries/handlebars/helpersMap.d.ts +12 -0
  76. package/dist/libraries/handlebars/helpersMap.d.ts.map +1 -0
  77. package/dist/libraries/handlebars/helpersMap.js +13 -0
  78. package/dist/libraries/handlebars/helpersMap.js.map +1 -0
  79. package/dist/libraries/handlebars/replacePlaceholders.d.ts +2 -0
  80. package/dist/libraries/handlebars/replacePlaceholders.d.ts.map +1 -0
  81. package/dist/libraries/handlebars/replacePlaceholders.js +8 -0
  82. package/dist/libraries/handlebars/replacePlaceholders.js.map +1 -0
  83. package/dist/plugin.d.ts.map +1 -1
  84. package/dist/plugin.js +6 -3
  85. package/dist/plugin.js.map +1 -1
  86. package/dist/providers/InstructionsProvider/InstructionsProvider.d.ts +1 -3
  87. package/dist/providers/InstructionsProvider/InstructionsProvider.d.ts.map +1 -1
  88. package/dist/providers/InstructionsProvider/InstructionsProvider.js.map +1 -1
  89. package/dist/providers/InstructionsProvider/useInstructions.d.ts +4 -0
  90. package/dist/providers/InstructionsProvider/useInstructions.d.ts.map +1 -0
  91. package/dist/providers/InstructionsProvider/useInstructions.js +34 -0
  92. package/dist/providers/InstructionsProvider/useInstructions.js.map +1 -0
  93. package/dist/types.d.ts +1 -1
  94. package/dist/types.d.ts.map +1 -1
  95. package/dist/types.js.map +1 -1
  96. package/dist/ui/Actions/Actions.js +32 -39
  97. package/dist/ui/Actions/Actions.js.map +1 -1
  98. package/dist/ui/Actions/hooks/useGenerate.d.ts.map +1 -1
  99. package/dist/ui/Actions/hooks/useGenerate.js +4 -4
  100. package/dist/ui/Actions/hooks/useGenerate.js.map +1 -1
  101. package/dist/utilities/getFieldBySchemaPath.d.ts +2 -2
  102. package/dist/utilities/getFieldBySchemaPath.d.ts.map +1 -1
  103. package/dist/utilities/getFieldBySchemaPath.js.map +1 -1
  104. package/dist/utilities/getFieldInfo.d.ts +3 -0
  105. package/dist/utilities/getFieldInfo.d.ts.map +1 -0
  106. package/dist/utilities/getFieldInfo.js +14 -0
  107. package/dist/utilities/getFieldInfo.js.map +1 -0
  108. package/dist/utilities/updateFieldsConfig.d.ts.map +1 -1
  109. package/dist/utilities/updateFieldsConfig.js +1 -5
  110. package/dist/utilities/updateFieldsConfig.js.map +1 -1
  111. package/package.json +59 -38
  112. package/dist/ai/editor/lexical.schema.d.ts.map +0 -1
  113. package/dist/ai/editor/lexical.schema.js.map +0 -1
  114. package/dist/ai/models/style.d.ts +0 -2
  115. package/dist/ai/models/style.d.ts.map +0 -1
  116. package/dist/ai/models/style.js +0 -31
  117. package/dist/ai/models/style.js.map +0 -1
  118. package/dist/providers/InstructionsProvider/hook.d.ts +0 -9
  119. package/dist/providers/InstructionsProvider/hook.d.ts.map +0 -1
  120. package/dist/providers/InstructionsProvider/hook.js +0 -17
  121. package/dist/providers/InstructionsProvider/hook.js.map +0 -1
  122. package/dist/providers/InstructionsProvider/index.d.ts +0 -5
  123. package/dist/providers/InstructionsProvider/index.d.ts.map +0 -1
  124. package/dist/providers/InstructionsProvider/index.js +0 -10
  125. package/dist/providers/InstructionsProvider/index.js.map +0 -1
  126. package/dist/ui/Floatype/Floatype.d.ts +0 -21
  127. package/dist/ui/Floatype/Floatype.d.ts.map +0 -1
  128. package/dist/ui/Floatype/Floatype.js +0 -245
  129. package/dist/ui/Floatype/Floatype.js.map +0 -1
  130. package/dist/ui/Floatype/floatype.module.css +0 -25
  131. /package/dist/ai/{editor → schemas}/lexical.schema.js +0 -0
package/package.json CHANGED
@@ -1,14 +1,11 @@
1
1
  {
2
2
  "name": "@ai-stack/payloadcms",
3
- "version": "3.0.0-beta.65.2",
3
+ "version": "3.0.0-beta.95.0",
4
4
  "private": false,
5
5
  "bugs": "https://github.com/ashbuilds/payload-ai/issues",
6
6
  "repository": "https://github.com/ashbuilds/payload-ai",
7
7
  "license": "MIT",
8
8
  "author": "ashbuilds",
9
- "type": "module",
10
- "main": "./dist/index.js",
11
- "types": "./dist/index.d.ts",
12
9
  "keywords": [
13
10
  "plugin",
14
11
  "text-to-speech",
@@ -22,84 +19,108 @@
22
19
  "ai-translate",
23
20
  "ai-writing-tool"
24
21
  ],
22
+ "type": "module",
23
+ "main": "dist/index.js",
24
+ "types": "dist/index.d.ts",
25
25
  "exports": {
26
26
  ".": {
27
27
  "import": "./dist/index.js",
28
28
  "require": "./dist/index.js",
29
29
  "types": "./dist/index.d.ts"
30
+ },
31
+ "./client": {
32
+ "import": "./dist/exports/client.js",
33
+ "types": "./dist/exports/client.d.ts",
34
+ "default": "./dist/exports/client.js"
35
+ },
36
+ "./fields": {
37
+ "import": "./dist/exports/fields.js",
38
+ "types": "./dist/exports/fields.d.ts",
39
+ "default": "./dist/exports/fields.js"
40
+ },
41
+ "./types": {
42
+ "import": "./dist/exports/types.js",
43
+ "types": "./dist/exports/types.d.ts",
44
+ "default": "./dist/exports/types.js"
30
45
  }
31
46
  },
32
47
  "files": [
33
48
  "dist"
34
49
  ],
50
+ "scripts": {
51
+ "build": "pnpm build:types && pnpm build:swc",
52
+ "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths --copy-files",
53
+ "build:dev": "pnpm build --watch",
54
+ "build:types": "tsc --emitDeclarationOnly",
55
+ "clean": "rimraf dist && rimraf tsconfig.tsbuildinfo",
56
+ "lint": "eslint src",
57
+ "lint:fix": "eslint --fix src",
58
+ "prepublishOnly": "pnpm clean && pnpm build"
59
+ },
35
60
  "dependencies": {
36
61
  "@ai-sdk/anthropic": "^0.0.38",
37
62
  "@ai-sdk/openai": "^0.0.43",
38
- "@ai-sdk/provider-utils": "^1.0.8",
63
+ "@ai-sdk/provider-utils": "^1.0.17",
39
64
  "@ai-sdk/ui-utils": "^0.0.27",
40
65
  "@anthropic-ai/sdk": "^0.24.3",
41
- "@langchain/core": "^0.2.15",
42
- "@langchain/openai": "^0.2.1",
66
+ "@langchain/core": "^0.2.31",
67
+ "@langchain/openai": "^0.2.8",
43
68
  "@lexical/html": "^0.16.1",
44
- "ai": "^3.3.3",
69
+ "ai": "^3.3.20",
45
70
  "elevenlabs": "^0.8.2",
46
71
  "handlebars": "4.7.8",
47
72
  "handlebars-async-helpers": "^1.0.6",
48
- "langchain": "^0.2.9",
49
- "lexical": "^0.16.1",
73
+ "langchain": "^0.2.17",
74
+ "lexical": "^0.17.0",
50
75
  "locale-codes": "^1.3.1",
51
- "openai": "^4.47.1",
76
+ "openai": "^4.56.1",
52
77
  "zod": "^3.23.8",
53
- "zod-to-json-schema": "^3.23.1"
78
+ "zod-to-json-schema": "^3.23.2",
79
+ "get-input-selection": "^1.1.4",
80
+ "lodash.isequal": "^4.5.0",
81
+ "scroll-into-view-if-needed": "^3.1.0",
82
+ "textarea-caret": "^3.0.2"
54
83
  },
55
84
  "devDependencies": {
56
85
  "@eslint/compat": "^1.1.1",
57
- "@eslint/js": "^9.9.0",
86
+ "@eslint/js": "^9.9.1",
58
87
  "@swc/cli": "0.4.0",
59
88
  "@types/dot-object": "2.1.6",
60
89
  "@types/react": "npm:types-react@19.0.0-beta.2",
61
90
  "@types/react-dom": "npm:types-react-dom@19.0.0-beta.2",
62
- "@typescript-eslint/eslint-plugin": "^7.16.1",
63
- "@typescript-eslint/parser": "^7.16.1",
64
- "chokidar": "^3.6.0",
91
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
92
+ "@typescript-eslint/parser": "^7.18.0",
65
93
  "copyfiles": "2.4.1",
66
- "eslint": "^9.7.0",
94
+ "eslint": "^9.9.1",
67
95
  "eslint-config-prettier": "^9.1.0",
68
96
  "eslint-plugin-import": "^2.29.1",
69
- "eslint-plugin-import-x": "^3.0.1",
97
+ "eslint-plugin-import-x": "^3.1.0",
70
98
  "eslint-plugin-jsx-a11y": "^6.9.0",
71
99
  "eslint-plugin-perfectionist": "^2.11.0",
72
100
  "eslint-plugin-prettier": "^5.2.1",
73
101
  "eslint-plugin-react": "^7.35.0",
74
102
  "eslint-plugin-react-hooks": "^4.6.2",
75
103
  "eslint-plugin-regexp": "^2.6.0",
76
- "globals": "^15.8.0",
77
- "payload": "3.0.0-beta.65",
104
+ "globals": "^15.9.0",
105
+ "payload": "3.0.0-beta.95",
78
106
  "prettier": "^3.3.3",
79
107
  "react": "19.0.0-rc-f994737d14-20240522",
80
108
  "react-dom": "19.0.0-rc-f994737d14-20240522",
81
109
  "rimraf": "6.0.1",
82
- "typescript": "^5.5.3",
83
- "typescript-eslint": "^7.16.1"
110
+ "typescript": "^5.5.4",
111
+ "typescript-eslint": "^7.18.0"
84
112
  },
85
113
  "peerDependencies": {
86
- "@payloadcms/next": "3.0.0-beta.65",
87
- "@payloadcms/richtext-lexical": "3.0.0-beta.65",
88
- "@payloadcms/translations": "3.0.0-beta.65",
89
- "@payloadcms/ui": "3.0.0-beta.65",
90
- "payload": "3.0.0-beta.65"
114
+ "@payloadcms/richtext-lexical": "3.0.0-beta.95",
115
+ "@payloadcms/translations": "3.0.0-beta.95",
116
+ "@payloadcms/ui": "3.0.0-beta.95",
117
+ "payload": "3.0.0-beta.95"
91
118
  },
92
119
  "publishConfig": {
120
+ "main": "./dist/index.js",
121
+ "types": "./dist/index.d.ts",
93
122
  "@ai-stack:registry": "https://registry.npmjs.org",
94
- "access": "public"
95
- },
96
- "scripts": {
97
- "build": "pnpm build:types && pnpm build:swc",
98
- "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths --copy-files",
99
- "build:dev": "pnpm build --watch",
100
- "build:types": "tsc --emitDeclarationOnly",
101
- "clean": "rimraf dist && rimraf tsconfig.tsbuildinfo",
102
- "lint": "eslint src",
103
- "lint:fix": "eslint --fix src"
123
+ "access": "public",
124
+ "provenance": true
104
125
  }
105
- }
126
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"lexical.schema.d.ts","sourceRoot":"","sources":["../../../src/ai/editor/lexical.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;EAO1B,CAAA;AAEF,eAAO,MAAM,aAAa,iBAAkB,CAAC,OAAO,eAAe,CAAC,EAAE;;;;;;EA0ErE,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/ai/editor/lexical.schema.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const LexicalBaseNode = z.object({\n type: z.string(),\n children: z.array(z.any()).optional(),\n direction: z.enum(['ltr']).nullable().optional(),\n format: z.string().optional(),\n indent: z.number().optional(),\n version: z.number().optional(),\n})\n\nexport const lexicalSchema = (customNodes?: (typeof LexicalBaseNode)[]) => {\n const BaseNode = z.object({\n type: z.string(),\n children: z.array(z.lazy(() => Node)).optional(),\n direction: z.enum(['ltr']).nullable().optional(),\n format: z.string().optional(),\n indent: z.number().optional(),\n version: z.number().optional(),\n })\n\n const TextNode = BaseNode.extend({\n type: z.literal('text'),\n format: z.number().optional(),\n text: z.string(),\n })\n\n const LinkNode = BaseNode.extend({\n id: z.string(),\n type: z.literal('link'),\n fields: z.object({\n linkType: z.string(),\n newTab: z.boolean(),\n url: z.string(),\n }),\n })\n\n const ListItemNode = BaseNode.extend({\n type: z.literal('listitem'),\n checked: z.boolean().optional(),\n value: z.number(),\n })\n\n const ListNode = BaseNode.extend({\n type: z.literal('list'),\n listType: z.enum(['check', 'number', 'bullet']),\n start: z.number(),\n tag: z.enum(['ul', 'ol']),\n })\n\n const HeadingNode = BaseNode.extend({\n type: z.literal('heading'),\n tag: z.enum(['h1', 'h2', 'h3', 'h4']),\n })\n\n // Example of custom node - wip\n const MediaNode = BaseNode.extend({\n type: z.literal('block'),\n version: z.literal(2),\n fields: z.object({\n id: z.string(),\n media: z.string(),\n position: z.enum(['fullscreen', 'default']),\n blockName: z.string(),\n blockType: z.literal('mediaBlock'),\n }),\n })\n\n const Node = z.union([\n TextNode,\n LinkNode,\n ListItemNode,\n ListNode,\n HeadingNode,\n BaseNode.extend({ type: z.enum(['paragraph', 'quote', 'horizontalrule']) }),\n ...(customNodes || []),\n ])\n\n const RootNode = BaseNode.extend({\n type: z.literal('root'),\n })\n\n return z.object({\n root: RootNode,\n })\n}\n"],"names":["z","LexicalBaseNode","object","type","string","children","array","any","optional","direction","enum","nullable","format","indent","number","version","lexicalSchema","customNodes","BaseNode","lazy","Node","TextNode","extend","literal","text","LinkNode","id","fields","linkType","newTab","boolean","url","ListItemNode","checked","value","ListNode","listType","start","tag","HeadingNode","MediaNode","media","position","blockName","blockType","union","RootNode","root"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAK;AAEvB,OAAO,MAAMC,kBAAkBD,EAAEE,MAAM,CAAC;IACtCC,MAAMH,EAAEI,MAAM;IACdC,UAAUL,EAAEM,KAAK,CAACN,EAAEO,GAAG,IAAIC,QAAQ;IACnCC,WAAWT,EAAEU,IAAI,CAAC;QAAC;KAAM,EAAEC,QAAQ,GAAGH,QAAQ;IAC9CI,QAAQZ,EAAEI,MAAM,GAAGI,QAAQ;IAC3BK,QAAQb,EAAEc,MAAM,GAAGN,QAAQ;IAC3BO,SAASf,EAAEc,MAAM,GAAGN,QAAQ;AAC9B,GAAE;AAEF,OAAO,MAAMQ,gBAAgB,CAACC;IAC5B,MAAMC,WAAWlB,EAAEE,MAAM,CAAC;QACxBC,MAAMH,EAAEI,MAAM;QACdC,UAAUL,EAAEM,KAAK,CAACN,EAAEmB,IAAI,CAAC,IAAMC,OAAOZ,QAAQ;QAC9CC,WAAWT,EAAEU,IAAI,CAAC;YAAC;SAAM,EAAEC,QAAQ,GAAGH,QAAQ;QAC9CI,QAAQZ,EAAEI,MAAM,GA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AAOzC,EAAEI,MAAM;YACfsC,UAAU1C,EAAEU,IAAI,CAAC;gBAAC;gBAAc;aAAU;YAC1CiC,WAAW3C,EAAEI,MAAM;YACnBwC,WAAW5C,EAAEuB,OAAO,CAAC;QACvB;IACF;IAEA,MAAMH,OAAOpB,EAAE6C,KAAK,CAAC;QACnBxB;QACAI;QACAO;QACAG;QACAI;QACArB,SAASI,MAAM,CAAC;YAAEnB,MAAMH,EAAEU,IAAI,CAAC;gBAAC;gBAAa;gBAAS;aAAiB;QAAE;WACrEO,eAAe,EAAE;KACtB;IAED,MAAM6B,WAAW5B,SAASI,MAAM,CAAC;QAC/BnB,MAAMH,EAAEuB,OAAO,CAAC;IAClB;IAEA,OAAOvB,EAAEE,MAAM,CAAC;QACd6C,MAAMD;IACR;AACF,EAAC"}
@@ -1,2 +0,0 @@
1
- export declare const beerCssClasses = "\nabsolute left, right, top, bottom, front, back, small, medium, large\n\n<article> small, medium, large, border, round, no-round, left-round, top-round, right-round, bottom-round, padding, no-padding, tiny-padding small-padding, medium-padding, large-padding\n\nbadge min, left, right, top, bottom, none, border, circle, square, round, no-round, left-round, right-round, top-round, bottom-round\n\n<details> left, right, top, bottom, small, medium, large, modal, border, round, no-round, left-round, right-round, top-round, bottom-round, active\n\nfield small, medium, large, extra, label, border, round, fill, prefix, suffix, textarea\n\nfixed left, right, top, bottom, front, back, small, medium, large\n\n<h1>...<h6> small, medium, large\n\n<li> max, divider, small-divider, medium-divider, large-divider\n\nrow, <ul> or <ol> left-align, right-align, center-align, top-align, bottom-align, middle-align, no-space, small-space, medium-space, large-space, horizontal, vertical\n\nsnackbar top, bottom, active\n\n<summary>\n\n<table> left-align, right-align, center-align, no-space, space, small-space, medium-space, large-space, border, stripes, min, fixed\n\ntabs left-align, right-align, center-align, horizontal, vertical, min, max\n\ntooltip left, right, top, bottom, max\n";
2
- //# sourceMappingURL=style.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/ai/models/style.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,owCA4B1B,CAAA"}
@@ -1,31 +0,0 @@
1
- export const beerCssClasses = `
2
- absolute left, right, top, bottom, front, back, small, medium, large
3
-
4
- <article> small, medium, large, border, round, no-round, left-round, top-round, right-round, bottom-round, padding, no-padding, tiny-padding small-padding, medium-padding, large-padding
5
-
6
- badge min, left, right, top, bottom, none, border, circle, square, round, no-round, left-round, right-round, top-round, bottom-round
7
-
8
- <details> left, right, top, bottom, small, medium, large, modal, border, round, no-round, left-round, right-round, top-round, bottom-round, active
9
-
10
- field small, medium, large, extra, label, border, round, fill, prefix, suffix, textarea
11
-
12
- fixed left, right, top, bottom, front, back, small, medium, large
13
-
14
- <h1>...<h6> small, medium, large
15
-
16
- <li> max, divider, small-divider, medium-divider, large-divider
17
-
18
- row, <ul> or <ol> left-align, right-align, center-align, top-align, bottom-align, middle-align, no-space, small-space, medium-space, large-space, horizontal, vertical
19
-
20
- snackbar top, bottom, active
21
-
22
- <summary>
23
-
24
- <table> left-align, right-align, center-align, no-space, space, small-space, medium-space, large-space, border, stripes, min, fixed
25
-
26
- tabs left-align, right-align, center-align, horizontal, vertical, min, max
27
-
28
- tooltip left, right, top, bottom, max
29
- `;
30
-
31
- //# sourceMappingURL=style.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/ai/models/style.ts"],"sourcesContent":["export const beerCssClasses = `\nabsolute left, right, top, bottom, front, back, small, medium, large\n\n<article> small, medium, large, border, round, no-round, left-round, top-round, right-round, bottom-round, padding, no-padding, tiny-padding small-padding, medium-padding, large-padding\n\nbadge min, left, right, top, bottom, none, border, circle, square, round, no-round, left-round, right-round, top-round, bottom-round\n\n<details> left, right, top, bottom, small, medium, large, modal, border, round, no-round, left-round, right-round, top-round, bottom-round, active\n\nfield small, medium, large, extra, label, border, round, fill, prefix, suffix, textarea\n\nfixed left, right, top, bottom, front, back, small, medium, large\n\n<h1>...<h6> small, medium, large\n\n<li> max, divider, small-divider, medium-divider, large-divider\n\nrow, <ul> or <ol> left-align, right-align, center-align, top-align, bottom-align, middle-align, no-space, small-space, medium-space, large-space, horizontal, vertical\n\nsnackbar top, bottom, active\n\n<summary>\n\n<table> left-align, right-align, center-align, no-space, space, small-space, medium-space, large-space, border, stripes, min, fixed\n\ntabs left-align, right-align, center-align, horizontal, vertical, min, max\n\ntooltip left, right, top, bottom, max\n`\n"],"names":["beerCssClasses"],"mappings":"AAAA,OAAO,MAAMA,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B/B,CAAC,CAAA"}
@@ -1,9 +0,0 @@
1
- export declare const useInstructions: ({ path }: {
2
- path: any;
3
- }) => {
4
- id: any;
5
- fields: string[];
6
- map: any;
7
- instructions: any;
8
- };
9
- //# sourceMappingURL=hook.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../src/providers/InstructionsProvider/hook.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe;;;;;;;CAS3B,CAAA"}
@@ -1,17 +0,0 @@
1
- import { useContext } from 'react';
2
- import { InstructionsContext } from './InstructionsProvider.js';
3
- export const useInstructions = ({ path })=>{
4
- const context = useContext(InstructionsContext);
5
- //Fields are used for autocompletion in PromptTextareaField
6
- const fields = Object.keys(context.instructions || {}).map((key)=>{
7
- return key.split('.').slice(1).join('.');
8
- });
9
- return {
10
- ...context,
11
- id: context.instructions[path],
12
- fields,
13
- map: context.instructions
14
- };
15
- };
16
-
17
- //# sourceMappingURL=hook.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/providers/InstructionsProvider/hook.ts"],"sourcesContent":["import { useContext } from 'react'\n\nimport { InstructionsContext } from './InstructionsProvider.js'\n\nexport const useInstructions = ({ path }) => {\n const context = useContext(InstructionsContext)\n\n //Fields are used for autocompletion in PromptTextareaField\n const fields = Object.keys(context.instructions || {}).map((key) => {\n return key.split('.').slice(1).join('.')\n })\n\n return { ...context, id: context.instructions[path], fields, map: context.instructions }\n}\n"],"names":["useContext","InstructionsContext","useInstructions","path","context","fields","Object","keys","instructions","map","key","split","slice","join","id"],"mappings":"AAAA,SAASA,UAAU,QAAQ,QAAO;AAElC,SAASC,mBAAmB,QAAQ,4BAA2B;AAE/D,OAAO,MAAMC,kBAAkB,CAAC,EAAEC,IAAI,EAAE;IACtC,MAAMC,UAAUJ,WAAWC;IAE3B,2DAA2D;IAC3D,MAAMI,SAASC,OAAOC,IAAI,CAACH,QAAQI,YAAY,IAAI,CAAC,GAAGC,GAAG,CAAC,CAACC;QAC1D,OAAOA,IAAIC,KAAK,CAAC,KAAKC,KAAK,CAAC,GAAGC,IAAI,CAAC;IACtC;IAEA,OAAO;QAAE,GAAGT,OAAO;QAAEU,IAAIV,QAAQI,YAAY,CAACL,KAAK;QAAEE;QAAQI,KAAKL,QAAQI,YAAY;IAAC;AACzF,EAAC"}
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- export declare const InstructionsProvider: React.FC<{
3
- children: React.ReactNode;
4
- }>;
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/InstructionsProvider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC1C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAEA,CAAA"}
@@ -1,10 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import React from 'react';
3
- import { InstructionsProvider as Provider } from './InstructionsProvider.js';
4
- export const InstructionsProvider = ({ children })=>{
5
- return /*#__PURE__*/ _jsx(Provider, {
6
- children: children
7
- });
8
- };
9
-
10
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/providers/InstructionsProvider/index.tsx"],"sourcesContent":["import React from 'react'\n\nimport { InstructionsProvider as Provider } from './InstructionsProvider.js'\n\nexport const InstructionsProvider: React.FC<{\n children: React.ReactNode\n}> = ({ children }) => {\n return <Provider>{children}</Provider>\n}\n"],"names":["React","InstructionsProvider","Provider","children"],"mappings":";AAAA,OAAOA,WAAW,QAAO;AAEzB,SAASC,wBAAwBC,QAAQ,QAAQ,4BAA2B;AAE5E,OAAO,MAAMD,uBAER,CAAC,EAAEE,QAAQ,EAAE;IAChB,qBAAO,KAACD;kBAAUC;;AACpB,EAAC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * OG Creator: Kailash Nadh
3
- * Github: https://github.com/knadh/floatype.js
4
- *
5
- * Reacted By: Claude 3.5 Sonnet and Ashbuilds
6
- */
7
- import React from 'react';
8
- type Options = {
9
- debounce?: number;
10
- onNavigate?: (direction: number, items: any[], currentIndex: number) => void;
11
- onQuery: (query: string) => any[];
12
- onRender?: (item: any) => React.ReactNode;
13
- onSelect?: (item: any, query: string) => string;
14
- onUpdate: (value: string) => void;
15
- };
16
- type FloatypeProps = {
17
- options: Partial<Options>;
18
- };
19
- export declare const Floatype: React.ForwardRefExoticComponent<FloatypeProps & React.RefAttributes<HTMLTextAreaElement>>;
20
- export {};
21
- //# sourceMappingURL=Floatype.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Floatype.d.ts","sourceRoot":"","sources":["../../../src/ui/Floatype/Floatype.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAA+D,MAAM,OAAO,CAAA;AAInF,KAAK,OAAO,GAAG;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5E,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,GAAG,EAAE,CAAA;IACjC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,KAAK,CAAC,SAAS,CAAA;IACzC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IAC/C,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CAClC,CAAA;AAED,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,QAAQ,2FAkPnB,CAAA"}
@@ -1,245 +0,0 @@
1
- /**
2
- * OG Creator: Kailash Nadh
3
- * Github: https://github.com/knadh/floatype.js
4
- *
5
- * Reacted By: Claude 3.5 Sonnet and Ashbuilds
6
- */ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
- import React, { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
8
- import styles from './floatype.module.css';
9
- export const Floatype = /*#__PURE__*/ forwardRef(({ options }, inputRef)=>{
10
- const [items, setItems] = useState([]);
11
- const [currentIndex, setCurrentIndex] = useState(0);
12
- const [query, setQuery] = useState(null);
13
- const [coords, setCoords] = useState(null);
14
- const boxRef = useRef(null);
15
- const shadowRef = useRef(null);
16
- const opt = {
17
- debounce: 100,
18
- onNavigate: undefined,
19
- onQuery: ()=>[],
20
- onRender: undefined,
21
- onSelect: undefined,
22
- onUpdate: ()=>{},
23
- ...options
24
- };
25
- const destroy = useCallback(()=>{
26
- setItems([]);
27
- setCurrentIndex(0);
28
- setQuery(null);
29
- }, []);
30
- const getLastWord = useCallback((el)=>{
31
- const text = el.value.substring(0, el.selectionStart ?? 0);
32
- const match = text.match(/\S+\s*$/);
33
- return match ? match[0] : null;
34
- }, []);
35
- const insertWord = useCallback((el, val)=>{
36
- const start = Math.max(el.value.lastIndexOf(' ', (el.selectionStart ?? 0) - 1), el.value.lastIndexOf('\n', (el.selectionStart ?? 0) - 1)) + 1;
37
- el.value = el.value.substring(0, start) + val + (el.value[el.selectionStart ?? 0] !== ' ' ? ' ' : '') + el.value.substring(el.selectionStart ?? 0);
38
- el.setSelectionRange(start + val.length + 1, start + val.length + 1);
39
- opt.onUpdate(el.value);
40
- }, [
41
- opt
42
- ]);
43
- const getCaret = useCallback(()=>{
44
- if (!inputRef || !('current' in inputRef) || !inputRef.current || !shadowRef.current) return null;
45
- const el = inputRef.current;
46
- const shadow = shadowRef.current;
47
- const txt = el.value.substring(0, el.selectionStart ?? 0);
48
- const start = Math.max(txt.lastIndexOf('\n'), txt.lastIndexOf(' ')) + 1;
49
- const cl = 'floatype-caret';
50
- shadow.innerHTML = el.value.substring(0, start) + `<span id="${cl}" style="display: inline-block;">${el.value.substring(start)}</span>`;
51
- const m = shadow.querySelector(`#${cl}`);
52
- const elRect = el.getBoundingClientRect();
53
- const mRect = m?.getBoundingClientRect();
54
- if (!mRect) return null;
55
- let top = mRect.top - elRect.top + el.scrollTop;
56
- let left = mRect.left - elRect.left + el.scrollLeft;
57
- if (boxRef.current && currentIndex !== null) {
58
- const box = boxRef.current;
59
- const selected = box.children[currentIndex];
60
- if (selected) {
61
- top -= selected.offsetTop + (selected.clientHeight / 2 - 5);
62
- }
63
- }
64
- if (boxRef.current) {
65
- const box = boxRef.current;
66
- if (box.clientWidth + left + elRect.left + 50 > window.innerWidth) {
67
- left = left - box.offsetWidth - 50;
68
- }
69
- }
70
- return {
71
- x: left + elRect.left,
72
- y: top + elRect.top
73
- };
74
- }, [
75
- inputRef,
76
- shadowRef,
77
- boxRef,
78
- currentIndex
79
- ]);
80
- const handleInput = useCallback(()=>{
81
- if (!inputRef || !('current' in inputRef) || !inputRef.current) return;
82
- const w = getLastWord(inputRef.current);
83
- if (!w) {
84
- destroy();
85
- return;
86
- }
87
- setQuery(w);
88
- }, [
89
- inputRef,
90
- getLastWord,
91
- destroy
92
- ]);
93
- const handleKeyDown = useCallback((e)=>{
94
- if (!boxRef.current) return;
95
- switch(e.key){
96
- case 'ArrowUp':
97
- e.preventDefault();
98
- setCurrentIndex((prev)=>(prev - 1 + items.length) % items.length);
99
- break;
100
- case 'ArrowDown':
101
- e.preventDefault();
102
- setCurrentIndex((prev)=>(prev + 1) % items.length);
103
- break;
104
- case 'Enter':
105
- e.preventDefault();
106
- if (inputRef && 'current' in inputRef && inputRef.current) {
107
- const selectedItem = items[currentIndex];
108
- const newVal = opt.onSelect ? opt.onSelect(selectedItem, query) : selectedItem;
109
- insertWord(inputRef.current, newVal);
110
- }
111
- destroy();
112
- break;
113
- case 'Escape':
114
- destroy();
115
- break;
116
- }
117
- }, [
118
- boxRef,
119
- items,
120
- currentIndex,
121
- inputRef,
122
- opt.onSelect,
123
- insertWord,
124
- destroy,
125
- query
126
- ]);
127
- useEffect(()=>{
128
- if (!inputRef || !('current' in inputRef) || !inputRef.current) return;
129
- const el = inputRef.current;
130
- el.addEventListener('input', handleInput);
131
- el.addEventListener('keydown', handleKeyDown);
132
- el.addEventListener('blur', destroy);
133
- return ()=>{
134
- el.removeEventListener('input', handleInput);
135
- el.removeEventListener('keydown', handleKeyDown);
136
- el.removeEventListener('blur', destroy);
137
- };
138
- }, [
139
- inputRef,
140
- handleInput,
141
- handleKeyDown
142
- ]);
143
- useEffect(()=>{
144
- if (!shadowRef.current || !inputRef || !('current' in inputRef) || !inputRef.current) return;
145
- const shadow = shadowRef.current;
146
- const el = inputRef.current;
147
- const stylesCss = window.getComputedStyle(el);
148
- const { fontFamily, fontSize, fontWeight } = stylesCss;
149
- shadow.style.fontFamily = fontFamily;
150
- shadow.style.fontSize = fontSize;
151
- shadow.style.fontWeight = fontWeight;
152
- const updateShadowPosition = ()=>{
153
- const elRect = el.getBoundingClientRect();
154
- shadow.style.position = 'fixed';
155
- shadow.style.top = `${elRect.top}px`;
156
- shadow.style.left = `${elRect.left - 52}px`;
157
- shadow.style.width = `${elRect.width}px`;
158
- shadow.style.height = `${elRect.height}px`;
159
- shadow.style.opacity = '0';
160
- shadow.style.padding = '0';
161
- shadow.style.visibility = 'hidden';
162
- };
163
- setTimeout(updateShadowPosition, 300);
164
- window.addEventListener('resize', updateShadowPosition);
165
- window.addEventListener('scroll', updateShadowPosition);
166
- return ()=>{
167
- window.removeEventListener('resize', updateShadowPosition);
168
- window.removeEventListener('scroll', updateShadowPosition);
169
- };
170
- }, [
171
- inputRef,
172
- shadowRef
173
- ]);
174
- useEffect(()=>{
175
- const fetchItems = ()=>{
176
- if (!query) return;
177
- const newItems = opt.onQuery(query);
178
- setItems(newItems);
179
- setCoords(getCaret());
180
- };
181
- const timeoutId = setTimeout(fetchItems, opt.debounce);
182
- return ()=>clearTimeout(timeoutId);
183
- }, [
184
- query,
185
- opt.onQuery,
186
- opt.debounce,
187
- getCaret
188
- ]);
189
- useEffect(()=>{
190
- if (opt.onNavigate) {
191
- opt.onNavigate(1, items, currentIndex);
192
- }
193
- }, [
194
- currentIndex,
195
- items,
196
- opt
197
- ]);
198
- useEffect(()=>{
199
- if (boxRef.current && coords && inputRef && 'current' in inputRef && inputRef.current) {
200
- const box = boxRef.current;
201
- box.style.position = 'fixed';
202
- box.style.left = `${coords.x}px`;
203
- box.style.top = `${coords.y}px`;
204
- box.style.width = window.getComputedStyle(inputRef.current).width;
205
- box.style.display = items.length > 0 ? 'block' : 'none';
206
- }
207
- }, [
208
- coords,
209
- items,
210
- inputRef
211
- ]);
212
- return /*#__PURE__*/ _jsxs("div", {
213
- className: "field-type textarea",
214
- style: {
215
- position: 'relative'
216
- },
217
- children: [
218
- /*#__PURE__*/ _jsx("div", {
219
- className: "textarea-clone",
220
- ref: shadowRef,
221
- style: {
222
- position: 'absolute'
223
- }
224
- }),
225
- items.length > 0 && /*#__PURE__*/ _jsx("div", {
226
- className: styles.floatype,
227
- ref: boxRef,
228
- children: items.map((item, idx)=>/*#__PURE__*/ _jsx("div", {
229
- className: `${styles.floatype_item} ${idx === currentIndex ? styles.floatype_sel : ''}`,
230
- "data-selected": idx === currentIndex,
231
- onMouseDown: ()=>{
232
- if (inputRef && 'current' in inputRef && inputRef.current) {
233
- const newVal = opt.onSelect ? opt.onSelect(item, query) : item;
234
- insertWord(inputRef.current, newVal);
235
- }
236
- destroy();
237
- },
238
- children: opt.onRender ? opt.onRender(item) : item
239
- }, idx))
240
- })
241
- ]
242
- });
243
- });
244
-
245
- //# sourceMappingURL=Floatype.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/ui/Floatype/Floatype.tsx"],"sourcesContent":["/**\n * OG Creator: Kailash Nadh\n * Github: https://github.com/knadh/floatype.js\n *\n * Reacted By: Claude 3.5 Sonnet and Ashbuilds\n */\n\nimport React, { forwardRef, useCallback, useEffect, useRef, useState } from 'react'\n\nimport styles from './floatype.module.css'\n\ntype Options = {\n debounce?: number\n onNavigate?: (direction: number, items: any[], currentIndex: number) => void\n onQuery: (query: string) => any[]\n onRender?: (item: any) => React.ReactNode\n onSelect?: (item: any, query: string) => string\n onUpdate: (value: string) => void\n}\n\ntype FloatypeProps = {\n options: Partial<Options>\n}\n\nexport const Floatype = forwardRef<HTMLTextAreaElement, FloatypeProps>(({ options }, inputRef) => {\n const [items, setItems] = useState<any[]>([])\n const [currentIndex, setCurrentIndex] = useState(0)\n const [query, setQuery] = useState<null | string>(null)\n const [coords, setCoords] = useState<{ x: number; y: number } | null>(null)\n\n const boxRef = useRef<HTMLDivElement>(null)\n const shadowRef = useRef<HTMLDivElement>(null)\n\n const opt: Options = {\n debounce: 100,\n onNavigate: undefined,\n onQuery: () => [],\n onRender: undefined,\n onSelect: undefined,\n onUpdate: () => {},\n ...options,\n }\n\n const destroy = useCallback(() => {\n setItems([])\n setCurrentIndex(0)\n setQuery(null)\n }, [])\n\n const getLastWord = useCallback((el: HTMLTextAreaElement): null | string => {\n const text = el.value.substring(0, el.selectionStart ?? 0)\n const match = text.match(/\\S+\\s*$/)\n return match ? match[0] : null\n }, [])\n\n const insertWord = useCallback(\n (el: HTMLInputElement | HTMLTextAreaElement, val: string): void => {\n const start =\n Math.max(\n el.value.lastIndexOf(' ', (el.selectionStart ?? 0) - 1),\n el.value.lastIndexOf('\\n', (el.selectionStart ?? 0) - 1),\n ) + 1\n el.value =\n el.value.substring(0, start) +\n val +\n (el.value[el.selectionStart ?? 0] !== ' ' ? ' ' : '') +\n el.value.substring(el.selectionStart ?? 0)\n el.setSelectionRange(start + val.length + 1, start + val.length + 1)\n opt.onUpdate(el.value)\n },\n [opt],\n )\n\n const getCaret = useCallback(() => {\n if (!inputRef || !('current' in inputRef) || !inputRef.current || !shadowRef.current)\n return null\n\n const el = inputRef.current\n const shadow = shadowRef.current\n\n const txt = el.value.substring(0, el.selectionStart ?? 0)\n const start = Math.max(txt.lastIndexOf('\\n'), txt.lastIndexOf(' ')) + 1\n\n const cl = 'floatype-caret'\n shadow.innerHTML =\n el.value.substring(0, start) +\n `<span id=\"${cl}\" style=\"display: inline-block;\">${el.value.substring(start)}</span>`\n\n const m = shadow.querySelector(`#${cl}`)\n const elRect = el.getBoundingClientRect()\n const mRect = m?.getBoundingClientRect()\n\n if (!mRect) return null\n\n let top = mRect.top - elRect.top + el.scrollTop\n let left = mRect.left - elRect.left + el.scrollLeft\n\n if (boxRef.current && currentIndex !== null) {\n const box = boxRef.current\n const selected = box.children[currentIndex] as HTMLElement\n if (selected) {\n top -= selected.offsetTop + (selected.clientHeight / 2 - 5)\n }\n }\n\n if (boxRef.current) {\n const box = boxRef.current\n if (box.clientWidth + left + elRect.left + 50 > window.innerWidth) {\n left = left - box.offsetWidth - 50\n }\n }\n\n return {\n x: left + elRect.left,\n y: top + elRect.top,\n }\n }, [inputRef, shadowRef, boxRef, currentIndex])\n\n const handleInput = useCallback(() => {\n if (!inputRef || !('current' in inputRef) || !inputRef.current) return\n const w = getLastWord(inputRef.current)\n if (!w) {\n destroy()\n return\n }\n setQuery(w)\n }, [inputRef, getLastWord, destroy])\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (!boxRef.current) return\n\n switch (e.key) {\n case 'ArrowUp':\n e.preventDefault()\n setCurrentIndex((prev) => (prev - 1 + items.length) % items.length)\n break\n case 'ArrowDown':\n e.preventDefault()\n setCurrentIndex((prev) => (prev + 1) % items.length)\n break\n case 'Enter':\n e.preventDefault()\n if (inputRef && 'current' in inputRef && inputRef.current) {\n const selectedItem = items[currentIndex]\n const newVal = opt.onSelect\n ? opt.onSelect(selectedItem, query)\n : (selectedItem as unknown as string)\n insertWord(inputRef.current, newVal)\n }\n destroy()\n break\n case 'Escape':\n destroy()\n break\n }\n },\n [boxRef, items, currentIndex, inputRef, opt.onSelect, insertWord, destroy, query],\n )\n\n useEffect(() => {\n if (!inputRef || !('current' in inputRef) || !inputRef.current) return\n\n const el = inputRef.current\n el.addEventListener('input', handleInput)\n el.addEventListener('keydown', handleKeyDown as any)\n el.addEventListener('blur', destroy)\n\n return () => {\n el.removeEventListener('input', handleInput)\n el.removeEventListener('keydown', handleKeyDown as any)\n el.removeEventListener('blur', destroy)\n }\n }, [inputRef, handleInput, handleKeyDown])\n\n useEffect(() => {\n if (!shadowRef.current || !inputRef || !('current' in inputRef) || !inputRef.current) return\n\n const shadow = shadowRef.current\n const el = inputRef.current\n\n const stylesCss = window.getComputedStyle(el)\n const { fontFamily, fontSize, fontWeight } = stylesCss\n\n shadow.style.fontFamily = fontFamily\n shadow.style.fontSize = fontSize\n shadow.style.fontWeight = fontWeight\n\n const updateShadowPosition = () => {\n const elRect = el.getBoundingClientRect()\n shadow.style.position = 'fixed'\n shadow.style.top = `${elRect.top}px`\n shadow.style.left = `${elRect.left - 52}px`\n shadow.style.width = `${elRect.width}px`\n shadow.style.height = `${elRect.height}px`\n shadow.style.opacity = '0'\n shadow.style.padding = '0'\n shadow.style.visibility = 'hidden'\n }\n\n setTimeout(updateShadowPosition, 300)\n window.addEventListener('resize', updateShadowPosition)\n window.addEventListener('scroll', updateShadowPosition)\n\n return () => {\n window.removeEventListener('resize', updateShadowPosition)\n window.removeEventListener('scroll', updateShadowPosition)\n }\n }, [inputRef, shadowRef])\n\n useEffect(() => {\n const fetchItems = () => {\n if (!query) return\n const newItems = opt.onQuery(query)\n setItems(newItems)\n setCoords(getCaret())\n }\n\n const timeoutId = setTimeout(fetchItems, opt.debounce)\n return () => clearTimeout(timeoutId)\n }, [query, opt.onQuery, opt.debounce, getCaret])\n\n useEffect(() => {\n if (opt.onNavigate) {\n opt.onNavigate(1, items, currentIndex)\n }\n }, [currentIndex, items, opt])\n\n useEffect(() => {\n if (boxRef.current && coords && inputRef && 'current' in inputRef && inputRef.current) {\n const box = boxRef.current\n box.style.position = 'fixed'\n box.style.left = `${coords.x}px`\n box.style.top = `${coords.y}px`\n box.style.width = window.getComputedStyle(inputRef.current).width\n box.style.display = items.length > 0 ? 'block' : 'none'\n }\n }, [coords, items, inputRef])\n\n return (\n <div className=\"field-type textarea\" style={{ position: 'relative' }}>\n <div className=\"textarea-clone\" ref={shadowRef} style={{ position: 'absolute' }} />\n {items.length > 0 && (\n <div className={styles.floatype} ref={boxRef}>\n {items.map((item, idx) => (\n <div\n className={`${styles.floatype_item} ${idx === currentIndex ? styles.floatype_sel : ''}`}\n data-selected={idx === currentIndex}\n key={idx}\n onMouseDown={() => {\n if (inputRef && 'current' in inputRef && inputRef.current) {\n const newVal = opt.onSelect\n ? opt.onSelect(item, query)\n : (item as unknown as string)\n insertWord(inputRef.current, newVal)\n }\n destroy()\n }}\n >\n {opt.onRender ? opt.onRender(item) : (item as unknown as string)}\n </div>\n ))}\n </div>\n )}\n </div>\n )\n})\n"],"names":["React","forwardRef","useCallback","useEffect","useRef","useState","styles","Floatype","options","inputRef","items","setItems","currentIndex","setCurrentIndex","query","setQuery","coords","setCoords","boxRef","shadowRef","opt","debounce","onNavigate","undefined","onQuery","onRender","onSelect","onUpdate","destroy","getLastWord","el","text","value","substring","selectionStart","match","insertWord","val","start","Math","max","lastIndexOf","setSelectionRange","length","getCaret","current","shadow","txt","cl","innerHTML","m","querySelector","elRect","getBoundingClientRect","mRect","top","scrollTop","left","scrollLeft","box","selected","children","offsetTop","clientHeight","clientWidth","window","innerWidth","offsetWidth","x","y","handleInput","w","handleKeyDown","e","key","preventDefault","prev","selectedItem","newVal","addEventListener","removeEventListener","stylesCss","getComputedStyle","fontFamily","fontSize","fontWeight","style","updateShadowPosition","position","width","height","opacity","padding","visibility","setTimeout","fetchItems","newItems","timeoutId","clearTimeout","display","div","className","ref","floatype","map","item","idx","floatype_item","floatype_sel","data-selected","onMouseDown"],"mappings":"AAAA;;;;;CAKC;AAED,OAAOA,SAASC,UAAU,EAAEC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAEnF,OAAOC,YAAY,wBAAuB;AAe1C,OAAO,MAAMC,yBAAWN,WAA+C,CAAC,EAAEO,OAAO,EAAE,EAAEC;IACnF,MAAM,CAACC,OAAOC,SAAS,GAAGN,SAAgB,EAAE;IAC5C,MAAM,CAACO,cAAcC,gBAAgB,GAAGR,SAAS;IACjD,MAAM,CAACS,OAAOC,SAAS,GAAGV,SAAwB;IAClD,MAAM,CAACW,QAAQC,UAAU,GAAGZ,SAA0C;IAEtE,MAAMa,SAASd,OAAuB;IACtC,MAAMe,YAAYf,OAAuB;IAEzC,MAAMgB,MAAe;QACnBC,UAAU;QACVC,YAAYC;QACZC,SAAS,IAAM,EAAE;QACjBC,UAAUF;QACVG,UAAUH;QACVI,UAAU,KAAO;QACjB,GAAGnB,OAAO;IACZ;IAEA,MAAMoB,UAAU1B,YAAY;QAC1BS,SAAS,EAAE;QACXE,gBAAgB;QAChBE,SAAS;IACX,GAAG,EAAE;IAEL,MAAMc,cAAc3B,YAAY,CAAC4B;QAC/B,MAAMC,OAAOD,GAAGE,KAAK,CAACC,SAAS,CAAC,GAAGH,GAAGI,cAAc,IAAI;QACxD,MAAMC,QAAQJ,KAAKI,KAAK,CAAC;QACzB,OAAOA,QAAQA,KAAK,CAAC,EAAE,GAAG;IAC5B,GAAG,EAAE;IAEL,MAAMC,aAAalC,YACjB,CAAC4B,IAA4CO;QAC3C,MAAMC,QACJC,KAAKC,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FC,iBAAeH,QAAQ9F;wBAEvBkG,aAAa;4BACX,IAAIrG,YAAY,aAAaA,YAAYA,SAASoC,OAAO,EAAE;gCACzD,MAAMiC,SAAS1D,IAAIM,QAAQ,GACvBN,IAAIM,QAAQ,CAAC+E,MAAM3F,SAClB2F;gCACLrE,WAAW3B,SAASoC,OAAO,EAAEiC;4BAC/B;4BACAlD;wBACF;kCAECR,IAAIK,QAAQ,GAAGL,IAAIK,QAAQ,CAACgF,QAASA;uBAXjCC;;;;AAkBnB,GAAE"}
@@ -1,25 +0,0 @@
1
- .floatype {
2
- background: var(--theme-bg);
3
- color: var(--theme-text);
4
- border: 1px solid var(--theme-elevation-250);
5
- box-shadow:
6
- 0px 10px 4px -8px rgba(0, 2, 4, 0.02),
7
- 0px 2px 3px 0px rgba(0, 2, 4, 0.05);
8
- text-align: left;
9
- max-width: 200px;
10
- z-index: 1000;
11
- position: fixed;
12
- }
13
-
14
- .floatype_item {
15
- padding: 5px 10px;
16
- }
17
-
18
- .floatype_item:hover {
19
- background: var(--theme-elevation-100);
20
- }
21
-
22
- .floatype_sel {
23
- background: var(--theme-input-bg);
24
- font-weight: bold;
25
- }
File without changes