@sanity/code-input 2.29.5-get-started-template.13 → 2.29.5-purple-unicorn.779

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 (113) hide show
  1. package/CodeInput.js +7 -0
  2. package/deprecatedSchema.js +7 -0
  3. package/lib/CodeInput.cjs +39 -0
  4. package/lib/CodeInput.cjs.map +1 -0
  5. package/lib/CodeInput.js +33 -333
  6. package/lib/CodeInput.js.map +1 -0
  7. package/lib/_CodeInput-d6f5810b.js +846 -0
  8. package/lib/_CodeInput-d6f5810b.js.map +1 -0
  9. package/lib/_CodeInput-f70e9606.cjs +857 -0
  10. package/lib/_CodeInput-f70e9606.cjs.map +1 -0
  11. package/lib/_reExport.js +19 -0
  12. package/lib/deprecatedSchema.cjs +23 -0
  13. package/lib/deprecatedSchema.cjs.map +1 -0
  14. package/lib/deprecatedSchema.js +19 -24
  15. package/lib/deprecatedSchema.js.map +1 -0
  16. package/lib/dts/src/CodeInput.d.ts +17 -0
  17. package/lib/dts/src/CodeInput.d.ts.map +1 -0
  18. package/lib/dts/src/CodeInput.js +155 -0
  19. package/lib/dts/src/CodeInput.js.map +1 -0
  20. package/{dist/dts → lib/dts/src}/PreviewCode.d.ts +8 -8
  21. package/lib/dts/src/PreviewCode.d.ts.map +1 -0
  22. package/lib/dts/src/PreviewCode.js +50 -0
  23. package/lib/dts/src/PreviewCode.js.map +1 -0
  24. package/lib/dts/src/__workshop__/dev.d.ts +3 -0
  25. package/lib/dts/src/__workshop__/dev.d.ts.map +1 -0
  26. package/lib/dts/src/__workshop__/dev.js +18 -0
  27. package/lib/dts/src/__workshop__/dev.js.map +1 -0
  28. package/lib/dts/src/__workshop__/index.d.ts +3 -0
  29. package/lib/dts/src/__workshop__/index.d.ts.map +1 -0
  30. package/lib/dts/src/__workshop__/index.js +10 -0
  31. package/lib/dts/src/__workshop__/index.js.map +1 -0
  32. package/{dist/dts → lib/dts/src}/config.d.ts +15 -15
  33. package/lib/dts/src/config.d.ts.map +1 -0
  34. package/lib/dts/src/config.js +38 -0
  35. package/lib/dts/src/config.js.map +1 -0
  36. package/{dist/dts → lib/dts/src}/createHighlightMarkers.d.ts +3 -3
  37. package/lib/dts/src/createHighlightMarkers.d.ts.map +1 -0
  38. package/lib/dts/src/createHighlightMarkers.js +22 -0
  39. package/lib/dts/src/createHighlightMarkers.js.map +1 -0
  40. package/{dist/dts → lib/dts/src}/deprecatedSchema.d.ts +11 -11
  41. package/lib/dts/src/deprecatedSchema.d.ts.map +1 -0
  42. package/lib/dts/src/deprecatedSchema.js +19 -0
  43. package/lib/dts/src/deprecatedSchema.js.map +1 -0
  44. package/{dist/dts → lib/dts/src}/editorSupport.d.ts +27 -27
  45. package/lib/dts/src/editorSupport.d.ts.map +1 -0
  46. package/lib/dts/src/editorSupport.js +32 -0
  47. package/lib/dts/src/editorSupport.js.map +1 -0
  48. package/{dist/dts → lib/dts/src}/getMedia.d.ts +2 -2
  49. package/lib/dts/src/getMedia.d.ts.map +1 -0
  50. package/lib/dts/src/getMedia.js +35 -0
  51. package/lib/dts/src/getMedia.js.map +1 -0
  52. package/lib/dts/src/groq.d.ts +2 -0
  53. package/lib/dts/src/groq.d.ts.map +1 -0
  54. package/lib/dts/src/groq.js +612 -0
  55. package/lib/dts/src/groq.js.map +1 -0
  56. package/lib/dts/src/index.d.ts +4 -0
  57. package/lib/dts/src/index.d.ts.map +1 -0
  58. package/lib/dts/src/index.js +7 -0
  59. package/lib/dts/src/index.js.map +1 -0
  60. package/lib/dts/src/schema.d.ts +47 -0
  61. package/lib/dts/src/schema.d.ts.map +1 -0
  62. package/lib/dts/src/schema.js +59 -0
  63. package/lib/dts/src/schema.js.map +1 -0
  64. package/{dist/dts → lib/dts/src}/types.d.ts +28 -28
  65. package/lib/dts/src/types.d.ts.map +1 -0
  66. package/lib/dts/src/types.js +2 -0
  67. package/lib/dts/src/types.js.map +1 -0
  68. package/lib/dts/tsconfig.tsbuildinfo +1 -0
  69. package/lib/index.cjs +45 -0
  70. package/lib/index.cjs.map +1 -0
  71. package/lib/index.js +43 -0
  72. package/lib/index.js.map +1 -0
  73. package/lib/schema.cjs +174 -0
  74. package/lib/schema.cjs.map +1 -0
  75. package/lib/schema.js +159 -62
  76. package/lib/schema.js.map +1 -0
  77. package/package.json +63 -12
  78. package/schema.js +7 -0
  79. package/src/CodeInput.tsx +327 -0
  80. package/src/PreviewCode.tsx +89 -0
  81. package/src/__workshop__/dev.tsx +35 -0
  82. package/src/__workshop__/index.ts +10 -0
  83. package/src/config.ts +45 -0
  84. package/src/createHighlightMarkers.ts +24 -0
  85. package/src/deprecatedSchema.ts +19 -0
  86. package/src/editorSupport.ts +33 -0
  87. package/src/getMedia.tsx +95 -0
  88. package/src/groq.ts +630 -0
  89. package/src/index.ts +11 -0
  90. package/src/schema.tsx +69 -0
  91. package/src/types.ts +26 -0
  92. package/dist/dts/CodeInput.d.ts +0 -23
  93. package/dist/dts/CodeInput.d.ts.map +0 -1
  94. package/dist/dts/PreviewCode.d.ts.map +0 -1
  95. package/dist/dts/config.d.ts.map +0 -1
  96. package/dist/dts/createHighlightMarkers.d.ts.map +0 -1
  97. package/dist/dts/deprecatedSchema.d.ts.map +0 -1
  98. package/dist/dts/editorSupport.d.ts.map +0 -1
  99. package/dist/dts/getMedia.d.ts.map +0 -1
  100. package/dist/dts/groq.d.ts +0 -376
  101. package/dist/dts/groq.d.ts.map +0 -1
  102. package/dist/dts/schema.d.ts +0 -44
  103. package/dist/dts/schema.d.ts.map +0 -1
  104. package/dist/dts/types.d.ts.map +0 -1
  105. package/lib/@types/css.d.js +0 -1
  106. package/lib/PreviewCode.js +0 -79
  107. package/lib/config.js +0 -103
  108. package/lib/createHighlightMarkers.js +0 -31
  109. package/lib/editorSupport.js +0 -55
  110. package/lib/getMedia.js +0 -110
  111. package/lib/groq.js +0 -414
  112. package/lib/types.js +0 -5
  113. package/tsconfig.json +0 -26
package/CodeInput.js ADDED
@@ -0,0 +1,7 @@
1
+ /* eslint-disable prettier/prettier, strict */
2
+ 'use strict'
3
+
4
+ // AUTO-GENERATED – DO NOT EDIT
5
+ // This is a legacy package export
6
+ // prettier-ignore
7
+ require('./lib/_reExport')(module.exports, require('./lib/CodeInput.cjs'))
@@ -0,0 +1,7 @@
1
+ /* eslint-disable prettier/prettier, strict */
2
+ 'use strict'
3
+
4
+ // AUTO-GENERATED – DO NOT EDIT
5
+ // This is a legacy package export
6
+ // prettier-ignore
7
+ require('./lib/_reExport')(module.exports, require('./lib/deprecatedSchema.cjs'))
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ require('react');
4
+ require('@sanity/base/form');
5
+ require('@sanity/ui');
6
+ require('react-ace');
7
+ require('styled-components');
8
+ var CodeInput = require('./_CodeInput-f70e9606.cjs');
9
+ require('ace-builds/src-noconflict/mode-batchfile');
10
+ require('ace-builds/src-noconflict/mode-csharp');
11
+ require('ace-builds/src-noconflict/mode-css');
12
+ require('ace-builds/src-noconflict/mode-golang');
13
+ require('ace-builds/src-noconflict/mode-html');
14
+ require('ace-builds/src-noconflict/mode-java');
15
+ require('ace-builds/src-noconflict/mode-javascript');
16
+ require('ace-builds/src-noconflict/mode-json');
17
+ require('ace-builds/src-noconflict/mode-jsx');
18
+ require('ace-builds/src-noconflict/mode-markdown');
19
+ require('ace-builds/src-noconflict/mode-mysql');
20
+ require('ace-builds/src-noconflict/mode-php');
21
+ require('ace-builds/src-noconflict/mode-python');
22
+ require('ace-builds/src-noconflict/mode-ruby');
23
+ require('ace-builds/src-noconflict/mode-sass');
24
+ require('ace-builds/src-noconflict/mode-scss');
25
+ require('ace-builds/src-noconflict/mode-sh');
26
+ require('ace-builds/src-noconflict/mode-text');
27
+ require('ace-builds/src-noconflict/mode-tsx');
28
+ require('ace-builds/src-noconflict/mode-typescript');
29
+ require('ace-builds/src-noconflict/mode-xml');
30
+ require('ace-builds/src-noconflict/mode-yaml');
31
+ require('ace-builds/src-noconflict/theme-github');
32
+ require('ace-builds/src-noconflict/theme-monokai');
33
+ require('ace-builds/src-noconflict/theme-terminal');
34
+ require('ace-builds/src-noconflict/theme-tomorrow');
35
+
36
+
37
+
38
+ exports.CodeInput = CodeInput.CodeInput;
39
+ //# sourceMappingURL=CodeInput.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeInput.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/lib/CodeInput.js CHANGED
@@ -1,333 +1,33 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- var _components = require("@sanity/base/components");
11
-
12
- var _ui = require("@sanity/ui");
13
-
14
- var PathUtils = _interopRequireWildcard(require("@sanity/util/paths"));
15
-
16
- var _changeIndicators = require("@sanity/base/change-indicators");
17
-
18
- var _patchEvent = require("part:@sanity/form-builder/patch-event");
19
-
20
- var _reactAce = _interopRequireDefault(require("react-ace"));
21
-
22
- var _styledComponents = _interopRequireDefault(require("styled-components"));
23
-
24
- var _autoId = require("@reach/auto-id");
25
-
26
- var _createHighlightMarkers = _interopRequireWildcard(require("./createHighlightMarkers"));
27
-
28
- require("./editorSupport");
29
-
30
- var _config = require("./config");
31
-
32
- var _templateObject;
33
-
34
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
-
36
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
37
-
38
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
39
-
40
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
41
-
42
- var EditorContainer = (0, _styledComponents.default)(_ui.Card)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n box-sizing: border-box;\n overflow: hidden;\n z-index: 0;\n\n .ace_editor {\n font-family: ", ";\n font-size: ", ";\n line-height: inherit;\n }\n\n ", "\n\n &:not([disabled]):not([readonly]) {\n &:focus,\n &:focus-within {\n box-shadow: 0 0 0 2px ", ";\n background-color: ", ";\n border-color: ", ";\n }\n }\n"])), _ref => {
43
- var theme = _ref.theme;
44
- return theme.sanity.fonts.code.family;
45
- }, _ref2 => {
46
- var theme = _ref2.theme;
47
- return theme.sanity.fonts.code.sizes[1];
48
- }, _createHighlightMarkers.highlightMarkersCSS, _ref3 => {
49
- var theme = _ref3.theme;
50
- return theme.sanity.color.base.focusRing;
51
- }, _ref4 => {
52
- var theme = _ref4.theme;
53
- return theme.sanity.color.base.bg;
54
- }, _ref5 => {
55
- var theme = _ref5.theme;
56
- return theme.sanity.color.base.focusRing;
57
- });
58
-
59
- // Returns a string with the mode name if supported (because aliases), otherwise false
60
- function isSupportedLanguage(mode) {
61
- var alias = _config.LANGUAGE_ALIASES[mode];
62
-
63
- if (alias) {
64
- return alias;
65
- }
66
-
67
- var isSupported = _config.SUPPORTED_LANGUAGES.find(lang => lang.value === mode);
68
-
69
- if (isSupported) {
70
- return mode;
71
- }
72
-
73
- return false;
74
- }
75
-
76
- var CodeInput = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
77
- var _props$value, _type$options5, _type$options6;
78
-
79
- var aceEditorRef = (0, _react.useRef)();
80
- var aceEditorId = (0, _autoId.useId)();
81
- var onFocus = props.onFocus,
82
- onChange = props.onChange,
83
- onBlur = props.onBlur,
84
- compareValue = props.compareValue,
85
- value = props.value,
86
- presence = props.presence,
87
- type = props.type,
88
- level = props.level,
89
- readOnly = props.readOnly,
90
- focusPath = props.focusPath;
91
- (0, _react.useImperativeHandle)(ref, () => ({
92
- focus: () => {
93
- var _aceEditorRef$current, _aceEditorRef$current2;
94
-
95
- aceEditorRef === null || aceEditorRef === void 0 ? void 0 : (_aceEditorRef$current = aceEditorRef.current) === null || _aceEditorRef$current === void 0 ? void 0 : (_aceEditorRef$current2 = _aceEditorRef$current.editor) === null || _aceEditorRef$current2 === void 0 ? void 0 : _aceEditorRef$current2.focus();
96
- }
97
- }));
98
- var handleLanguageFocus = (0, _react.useCallback)(() => {
99
- onFocus(_config.PATH_LANGUAGE);
100
- }, [onFocus]);
101
- var handleCodeFocus = (0, _react.useCallback)(() => {
102
- onFocus(_config.PATH_CODE);
103
- }, [onFocus]);
104
- var handleFilenameFocus = (0, _react.useCallback)(() => {
105
- onFocus(_config.PATH_FILENAME);
106
- }, [onFocus]);
107
- var handleFilenameChange = (0, _react.useCallback)(event => {
108
- var val = event.target.value;
109
- var path = _config.PATH_FILENAME;
110
- onChange(_patchEvent.PatchEvent.from([(0, _patchEvent.setIfMissing)({
111
- _type: type.name
112
- }), val ? (0, _patchEvent.set)(val, path) : (0, _patchEvent.unset)(path)]));
113
- }, [onChange, type.name]);
114
- var getTheme = (0, _react.useCallback)(() => {
115
- var _type$options;
116
-
117
- var preferredTheme = (_type$options = type.options) === null || _type$options === void 0 ? void 0 : _type$options.theme;
118
- return preferredTheme && _config.SUPPORTED_THEMES.find(theme => theme === preferredTheme) ? preferredTheme : _config.DEFAULT_THEME;
119
- }, [type]);
120
- var handleToggleSelectLine = (0, _react.useCallback)(lineNumber => {
121
- var _aceEditorRef$current3, _aceEditorRef$current4;
122
-
123
- var editorSession = (_aceEditorRef$current3 = aceEditorRef.current) === null || _aceEditorRef$current3 === void 0 ? void 0 : (_aceEditorRef$current4 = _aceEditorRef$current3.editor) === null || _aceEditorRef$current4 === void 0 ? void 0 : _aceEditorRef$current4.getSession();
124
- var backgroundMarkers = editorSession === null || editorSession === void 0 ? void 0 : editorSession.getMarkers(true);
125
- var currentHighlightedLines = Object.keys(backgroundMarkers).filter(key => backgroundMarkers[key].type === 'screenLine').map(key => backgroundMarkers[key].range.start.row);
126
- var currentIndex = currentHighlightedLines.indexOf(lineNumber);
127
-
128
- if (currentIndex > -1) {
129
- // toggle remove
130
- currentHighlightedLines.splice(currentIndex, 1);
131
- } else {
132
- // toggle add
133
- currentHighlightedLines.push(lineNumber);
134
- currentHighlightedLines.sort();
135
- }
136
-
137
- onChange(_patchEvent.PatchEvent.from((0, _patchEvent.set)(currentHighlightedLines.map(line => // ace starts at line (row) 0, but we store it starting at line 1
138
- line + 1), ['highlightedLines'])));
139
- }, [aceEditorRef, onChange]);
140
- var handleGutterMouseDown = (0, _react.useCallback)(event => {
141
- var target = event.domEvent.target;
142
-
143
- if (target.classList.contains('ace_gutter-cell')) {
144
- var row = event.getDocumentPosition().row;
145
- handleToggleSelectLine(row);
146
- }
147
- }, [handleToggleSelectLine]);
148
- (0, _react.useEffect)(() => {
149
- var _aceEditorRef$current5;
150
-
151
- var editor = aceEditorRef === null || aceEditorRef === void 0 ? void 0 : (_aceEditorRef$current5 = aceEditorRef.current) === null || _aceEditorRef$current5 === void 0 ? void 0 : _aceEditorRef$current5.editor;
152
- return () => {
153
- var _editor$session;
154
-
155
- editor === null || editor === void 0 ? void 0 : (_editor$session = editor.session) === null || _editor$session === void 0 ? void 0 : _editor$session.removeListener('guttermousedown', handleGutterMouseDown);
156
- };
157
- }, [aceEditorRef, handleGutterMouseDown]);
158
- var handleEditorLoad = (0, _react.useCallback)(editor => {
159
- editor === null || editor === void 0 ? void 0 : editor.on('guttermousedown', handleGutterMouseDown);
160
- }, [handleGutterMouseDown]);
161
- var getLanguageAlternatives = (0, _react.useCallback)(() => {
162
- var _type$options2;
163
-
164
- var languageAlternatives = (_type$options2 = type.options) === null || _type$options2 === void 0 ? void 0 : _type$options2.languageAlternatives;
165
-
166
- if (!languageAlternatives) {
167
- return _config.SUPPORTED_LANGUAGES;
168
- }
169
-
170
- if (!Array.isArray(languageAlternatives)) {
171
- throw new Error("'options.languageAlternatives' should be an array, got ".concat(typeof languageAlternatives));
172
- }
173
-
174
- return languageAlternatives.reduce((acc, _ref6) => {
175
- var title = _ref6.title,
176
- val = _ref6.value,
177
- mode = _ref6.mode;
178
- var alias = _config.LANGUAGE_ALIASES[val];
179
-
180
- if (alias) {
181
- // eslint-disable-next-line no-console
182
- console.warn("'options.languageAlternatives' lists a language with value \"%s\", which is an alias of \"%s\" - please replace the value to read \"%s\"", val, alias, alias);
183
- return acc.concat({
184
- title,
185
- value: alias,
186
- mode: mode
187
- });
188
- }
189
-
190
- if (!mode && !_config.SUPPORTED_LANGUAGES.find(lang => lang.value === val)) {
191
- // eslint-disable-next-line no-console
192
- console.warn("'options.languageAlternatives' lists a language which is not supported: \"%s\", syntax highlighting will be disabled.", val);
193
- }
194
-
195
- return acc.concat({
196
- title,
197
- value: val,
198
- mode
199
- });
200
- }, []);
201
- }, [type]);
202
- var handleCodeChange = (0, _react.useCallback)(code => {
203
- var _type$options3;
204
-
205
- var path = _config.PATH_CODE;
206
- var fixedLanguage = (_type$options3 = type.options) === null || _type$options3 === void 0 ? void 0 : _type$options3.language;
207
- onChange(_patchEvent.PatchEvent.from([(0, _patchEvent.setIfMissing)({
208
- _type: type.name,
209
- language: fixedLanguage
210
- }), code ? (0, _patchEvent.set)(code, path) : (0, _patchEvent.unset)(path)]));
211
- }, [onChange, type]);
212
- var handleLanguageChange = (0, _react.useCallback)(event => {
213
- var val = event.currentTarget.value;
214
- var path = _config.PATH_LANGUAGE;
215
- onChange(_patchEvent.PatchEvent.from([(0, _patchEvent.setIfMissing)({
216
- _type: type.name
217
- }), val ? (0, _patchEvent.set)(val, path) : (0, _patchEvent.unset)(path)]));
218
- }, [onChange, type.name]);
219
- var languages = getLanguageAlternatives().slice();
220
- var selectedLanguage = props !== null && props !== void 0 && (_props$value = props.value) !== null && _props$value !== void 0 && _props$value.language ? languages.find(item => {
221
- var _props$value2;
222
-
223
- return item.value === (props === null || props === void 0 ? void 0 : (_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2.language);
224
- }) : undefined;
225
- var languageField = type.fields.find(field => field.name === 'language');
226
- var filenameField = type.fields.find(field => field.name === 'filename');
227
- var languageCompareValue = PathUtils.get(compareValue, _config.PATH_LANGUAGE);
228
- var codeCompareValue = PathUtils.get(compareValue, _config.PATH_CODE);
229
- var filenameCompareValue = PathUtils.get(compareValue, _config.PATH_FILENAME);
230
- var languagePresence = presence.filter(presenceItem => PathUtils.startsWith(_config.PATH_LANGUAGE, presenceItem.path));
231
- var codePresence = presence.filter(presenceItem => PathUtils.startsWith(_config.PATH_CODE, presenceItem.path));
232
- var filenamePresence = presence.filter(presenceItem => PathUtils.startsWith(_config.PATH_FILENAME, presenceItem.path));
233
- var renderEditor = (0, _react.useCallback)(() => {
234
- var _type$options4;
235
-
236
- var fixedLanguage = (_type$options4 = type.options) === null || _type$options4 === void 0 ? void 0 : _type$options4.language;
237
- var language = (value === null || value === void 0 ? void 0 : value.language) || fixedLanguage; // the language config from the schema
238
-
239
- var configured = languages.find(entry => entry.value === language); // is the language officially supported (e.g. we import the mode by default)
240
-
241
- var supported = language && isSupportedLanguage(language);
242
- var mode = (configured === null || configured === void 0 ? void 0 : configured.mode) || (supported ? language : 'text');
243
- return /*#__PURE__*/_react.default.createElement(EditorContainer, {
244
- radius: 1,
245
- shadow: 1,
246
- readOnly: readOnly
247
- }, /*#__PURE__*/_react.default.createElement(_reactAce.default, {
248
- ref: aceEditorRef,
249
- mode: mode,
250
- theme: getTheme(),
251
- width: "100%",
252
- onChange: handleCodeChange,
253
- name: "editor-".concat(aceEditorId),
254
- value: value && value.code || '',
255
- markers: value && value.highlightedLines ? (0, _createHighlightMarkers.default)(value.highlightedLines) : undefined,
256
- onLoad: handleEditorLoad,
257
- readOnly: readOnly,
258
- tabSize: 2,
259
- wrapEnabled: true,
260
- setOptions: _config.ACE_SET_OPTIONS,
261
- editorProps: _config.ACE_EDITOR_PROPS,
262
- onFocus: handleCodeFocus,
263
- onBlur: onBlur
264
- }));
265
- }, [type, value, readOnly, getTheme, handleCodeChange, aceEditorId, handleEditorLoad, handleCodeFocus, onBlur]);
266
-
267
- if ((_type$options5 = type.options) !== null && _type$options5 !== void 0 && _type$options5.language) {
268
- return /*#__PURE__*/_react.default.createElement(_changeIndicators.ChangeIndicatorProvider, {
269
- path: _config.PATH_CODE,
270
- focusPath: focusPath,
271
- value: value === null || value === void 0 ? void 0 : value.code,
272
- compareValue: codeCompareValue
273
- }, /*#__PURE__*/_react.default.createElement(_components.FormFieldSet, {
274
- title: type.title,
275
- description: type.description,
276
- level: level
277
- }, renderEditor()));
278
- }
279
-
280
- return /*#__PURE__*/_react.default.createElement(_components.FormFieldSet, {
281
- title: type.title,
282
- description: type.description,
283
- level: level,
284
- __unstable_changeIndicator: false
285
- }, /*#__PURE__*/_react.default.createElement(_changeIndicators.ChangeIndicatorProvider, {
286
- path: _config.PATH_LANGUAGE,
287
- focusPath: focusPath,
288
- value: selectedLanguage === null || selectedLanguage === void 0 ? void 0 : selectedLanguage.value,
289
- compareValue: languageCompareValue
290
- }, /*#__PURE__*/_react.default.createElement(_components.FormField, {
291
- level: level + 1,
292
- label: (languageField === null || languageField === void 0 ? void 0 : languageField.title) || 'Language',
293
- __unstable_presence: languagePresence
294
- }, /*#__PURE__*/_react.default.createElement(_ui.Select, {
295
- onChange: handleLanguageChange,
296
- readOnly: readOnly,
297
- value: (selectedLanguage === null || selectedLanguage === void 0 ? void 0 : selectedLanguage.value) || '',
298
- onFocus: handleLanguageFocus,
299
- onBlur: onBlur
300
- }, languages.map(lang => /*#__PURE__*/_react.default.createElement("option", {
301
- key: lang.value,
302
- value: lang.value
303
- }, lang.title))))), ((_type$options6 = type.options) === null || _type$options6 === void 0 ? void 0 : _type$options6.withFilename) && /*#__PURE__*/_react.default.createElement(_changeIndicators.ChangeIndicatorProvider, {
304
- path: _config.PATH_FILENAME,
305
- focusPath: focusPath,
306
- value: value === null || value === void 0 ? void 0 : value.filename,
307
- compareValue: filenameCompareValue
308
- }, /*#__PURE__*/_react.default.createElement(_components.FormField, {
309
- label: (filenameField === null || filenameField === void 0 ? void 0 : filenameField.title) || 'Filename',
310
- level: level + 1,
311
- __unstable_presence: filenamePresence
312
- }, /*#__PURE__*/_react.default.createElement(_ui.TextInput, {
313
- name: "filename",
314
- value: (value === null || value === void 0 ? void 0 : value.filename) || '',
315
- placeholder: filenameField === null || filenameField === void 0 ? void 0 : filenameField.placeholder,
316
- onChange: handleFilenameChange,
317
- onFocus: handleFilenameFocus,
318
- onBlur: onBlur
319
- }))), /*#__PURE__*/_react.default.createElement(_changeIndicators.ChangeIndicatorProvider, {
320
- path: _config.PATH_CODE,
321
- focusPath: focusPath,
322
- value: value === null || value === void 0 ? void 0 : value.code,
323
- compareValue: codeCompareValue
324
- }, /*#__PURE__*/_react.default.createElement(_components.FormField, {
325
- label: "Code",
326
- level: level + 1,
327
- __unstable_presence: codePresence
328
- }, renderEditor())));
329
- });
330
-
331
- CodeInput.displayName = 'CodeInput';
332
- var _default = CodeInput;
333
- exports.default = _default;
1
+ import 'react';
2
+ import '@sanity/base/form';
3
+ import '@sanity/ui';
4
+ import 'react-ace';
5
+ import 'styled-components';
6
+ export { C as CodeInput } from './_CodeInput-d6f5810b.js';
7
+ import 'ace-builds/src-noconflict/mode-batchfile';
8
+ import 'ace-builds/src-noconflict/mode-csharp';
9
+ import 'ace-builds/src-noconflict/mode-css';
10
+ import 'ace-builds/src-noconflict/mode-golang';
11
+ import 'ace-builds/src-noconflict/mode-html';
12
+ import 'ace-builds/src-noconflict/mode-java';
13
+ import 'ace-builds/src-noconflict/mode-javascript';
14
+ import 'ace-builds/src-noconflict/mode-json';
15
+ import 'ace-builds/src-noconflict/mode-jsx';
16
+ import 'ace-builds/src-noconflict/mode-markdown';
17
+ import 'ace-builds/src-noconflict/mode-mysql';
18
+ import 'ace-builds/src-noconflict/mode-php';
19
+ import 'ace-builds/src-noconflict/mode-python';
20
+ import 'ace-builds/src-noconflict/mode-ruby';
21
+ import 'ace-builds/src-noconflict/mode-sass';
22
+ import 'ace-builds/src-noconflict/mode-scss';
23
+ import 'ace-builds/src-noconflict/mode-sh';
24
+ import 'ace-builds/src-noconflict/mode-text';
25
+ import 'ace-builds/src-noconflict/mode-tsx';
26
+ import 'ace-builds/src-noconflict/mode-typescript';
27
+ import 'ace-builds/src-noconflict/mode-xml';
28
+ import 'ace-builds/src-noconflict/mode-yaml';
29
+ import 'ace-builds/src-noconflict/theme-github';
30
+ import 'ace-builds/src-noconflict/theme-monokai';
31
+ import 'ace-builds/src-noconflict/theme-terminal';
32
+ import 'ace-builds/src-noconflict/theme-tomorrow';
33
+ //# sourceMappingURL=CodeInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeInput.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}