@instructure/ui-source-code-editor 8.25.1-snapshot-19

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 (43) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +48 -0
  3. package/es/SourceCodeEditor/SourceCodeEditorLocator.js +81 -0
  4. package/es/SourceCodeEditor/customKeybinding.js +96 -0
  5. package/es/SourceCodeEditor/index.js +587 -0
  6. package/es/SourceCodeEditor/props.js +55 -0
  7. package/es/SourceCodeEditor/styles.js +204 -0
  8. package/es/SourceCodeEditor/theme.js +52 -0
  9. package/es/index.js +24 -0
  10. package/lib/SourceCodeEditor/SourceCodeEditorLocator.js +92 -0
  11. package/lib/SourceCodeEditor/customKeybinding.js +104 -0
  12. package/lib/SourceCodeEditor/index.js +601 -0
  13. package/lib/SourceCodeEditor/props.js +67 -0
  14. package/lib/SourceCodeEditor/styles.js +213 -0
  15. package/lib/SourceCodeEditor/theme.js +60 -0
  16. package/lib/index.js +13 -0
  17. package/lib/package.json +1 -0
  18. package/package.json +68 -0
  19. package/src/SourceCodeEditor/README.md +794 -0
  20. package/src/SourceCodeEditor/SourceCodeEditorLocator.ts +56 -0
  21. package/src/SourceCodeEditor/customKeybinding.ts +121 -0
  22. package/src/SourceCodeEditor/index.tsx +659 -0
  23. package/src/SourceCodeEditor/props.ts +291 -0
  24. package/src/SourceCodeEditor/styles.ts +200 -0
  25. package/src/SourceCodeEditor/theme.ts +55 -0
  26. package/src/index.ts +25 -0
  27. package/tsconfig.build.json +25 -0
  28. package/tsconfig.build.tsbuildinfo +1 -0
  29. package/tsconfig.json +4 -0
  30. package/types/SourceCodeEditor/SourceCodeEditorLocator.d.ts +607 -0
  31. package/types/SourceCodeEditor/SourceCodeEditorLocator.d.ts.map +1 -0
  32. package/types/SourceCodeEditor/customKeybinding.d.ts +4 -0
  33. package/types/SourceCodeEditor/customKeybinding.d.ts.map +1 -0
  34. package/types/SourceCodeEditor/index.d.ts +126 -0
  35. package/types/SourceCodeEditor/index.d.ts.map +1 -0
  36. package/types/SourceCodeEditor/props.d.ts +130 -0
  37. package/types/SourceCodeEditor/props.d.ts.map +1 -0
  38. package/types/SourceCodeEditor/styles.d.ts +14 -0
  39. package/types/SourceCodeEditor/styles.d.ts.map +1 -0
  40. package/types/SourceCodeEditor/theme.d.ts +10 -0
  41. package/types/SourceCodeEditor/theme.d.ts.map +1 -0
  42. package/types/index.d.ts +3 -0
  43. package/types/index.d.ts.map +1 -0
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _highlight = require("@lezer/highlight");
9
+
10
+ /*
11
+ * The MIT License (MIT)
12
+ *
13
+ * Copyright (c) 2015 - present Instructure, Inc.
14
+ *
15
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ * of this software and associated documentation files (the "Software"), to deal
17
+ * in the Software without restriction, including without limitation the rights
18
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ * copies of the Software, and to permit persons to whom the Software is
20
+ * furnished to do so, subject to the following conditions:
21
+ *
22
+ * The above copyright notice and this permission notice shall be included in all
23
+ * copies or substantial portions of the Software.
24
+ *
25
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ * SOFTWARE.
32
+ */
33
+
34
+ /**
35
+ * ---
36
+ * private: true
37
+ * ---
38
+ * Generates the style object from the theme and provided additional information
39
+ * @param {Object} componentTheme The theme variable object.
40
+ * @param {Object} props the props of the component, the style is applied to
41
+ * @return {Object} The final style object, which will be used in the component
42
+ */
43
+ const generateStyle = (componentTheme, props) => {
44
+ const attachment = props.attachment;
45
+ const attachmentBorderRadius = {
46
+ top: {
47
+ borderBottomLeftRadius: 0,
48
+ borderBottomRightRadius: 0
49
+ },
50
+ bottom: {
51
+ borderTopLeftRadius: 0,
52
+ borderTopRightRadius: 0
53
+ }
54
+ };
55
+ const attachmentVariants = {
56
+ top: {
57
+ marginBottom: 0,
58
+ marginTop: '0.25rem'
59
+ },
60
+ bottom: {
61
+ borderTopLeftRadius: 0,
62
+ borderTopRightRadius: 0,
63
+ marginBottom: '0.25rem'
64
+ }
65
+ };
66
+ return {
67
+ codeEditor: {
68
+ label: 'codeEditor',
69
+ position: 'relative'
70
+ },
71
+ codeEditorContainer: {
72
+ label: 'codeEditorContainer',
73
+ borderColor: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.borderColor,
74
+ borderStyle: 'solid',
75
+ borderWidth: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.borderWidth,
76
+ borderRadius: componentTheme.borderRadius,
77
+ marginBottom: '1rem',
78
+ ...(attachment && { ...attachmentVariants[attachment],
79
+ ...attachmentBorderRadius[attachment]
80
+ })
81
+ },
82
+ theme: {
83
+ '&': {
84
+ overflow: 'hidden',
85
+ background: componentTheme.background,
86
+ height: 'auto',
87
+ fontFamily: componentTheme.fontFamily,
88
+ fontSize: componentTheme.fontSize,
89
+ color: componentTheme.color,
90
+ border: 0,
91
+ lineHeight: 1.4375,
92
+ minHeight: '1.4375rem',
93
+ borderRadius: componentTheme.borderRadius,
94
+ ...(attachment && { ...attachmentBorderRadius[attachment]
95
+ })
96
+ },
97
+ '&.cm-editor.cm-focused': {
98
+ // Provide a simple default outline to make sure a focused
99
+ // editor is visually distinct. Can't leave the default behavior
100
+ // because that will apply to the content element, which is
101
+ // inside the scrollable container and doesn't include the
102
+ // gutters. We also can't use an 'auto' outline, since those
103
+ // are, for some reason, drawn behind the element content, which
104
+ // will cause things like the active line background to cover
105
+ // the outline (#297).
106
+ outline: `${componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.borderWidth} solid ${componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.focusBorderColor}`
107
+ },
108
+ '.cm-content': {
109
+ padding: `${componentTheme.verticalPadding} 0`
110
+ },
111
+ '.cm-scroller': {
112
+ fontFamily: componentTheme.fontFamily,
113
+ lineHeight: 1.4375
114
+ },
115
+ '.cm-gutters': {
116
+ background: componentTheme.gutterBackground,
117
+ borderColor: componentTheme.borderColor
118
+ },
119
+ '.cm-line': {
120
+ padding: `0 ${componentTheme.horizontalPadding}`
121
+ },
122
+ '.cm-selectionBackground': {
123
+ background: 'transparent'
124
+ },
125
+ '.cm-focused .cm-selectionBackground': {
126
+ background: '#d7d4f0'
127
+ },
128
+ '.cm-placeholder': {
129
+ // for better contrast
130
+ color: '#707070'
131
+ }
132
+ },
133
+ highlightStyle: [
134
+ /**
135
+ * Copy of `defaultHighlightStyle` from '@codemirror/language'
136
+ */
137
+ // { tag: tags.meta, color: '#7a757a' },
138
+ {
139
+ tag: _highlight.tags.link,
140
+ textDecoration: 'underline'
141
+ }, {
142
+ tag: _highlight.tags.heading,
143
+ textDecoration: 'underline',
144
+ fontWeight: 'bold'
145
+ }, {
146
+ tag: _highlight.tags.emphasis,
147
+ fontStyle: 'italic'
148
+ }, {
149
+ tag: _highlight.tags.strong,
150
+ fontWeight: 'bold'
151
+ }, {
152
+ tag: _highlight.tags.strikethrough,
153
+ textDecoration: 'line-through'
154
+ }, {
155
+ tag: _highlight.tags.keyword,
156
+ color: '#708'
157
+ }, {
158
+ tag: [_highlight.tags.atom, _highlight.tags.bool, _highlight.tags.url, _highlight.tags.contentSeparator, _highlight.tags.labelName],
159
+ color: '#219'
160
+ }, {
161
+ tag: [_highlight.tags.literal, _highlight.tags.inserted],
162
+ color: '#164'
163
+ }, {
164
+ tag: [_highlight.tags.string, _highlight.tags.deleted],
165
+ color: '#a11'
166
+ }, // {
167
+ // tag: [tags.regexp, tags.escape, tags.special(tags.string)],
168
+ // color: '#e40'
169
+ // },
170
+ {
171
+ tag: _highlight.tags.definition(_highlight.tags.variableName),
172
+ color: '#00f'
173
+ }, {
174
+ tag: _highlight.tags.local(_highlight.tags.variableName),
175
+ color: '#30a'
176
+ }, // { tag: [tags.typeName, tags.namespace], color: '#085' },
177
+ {
178
+ tag: _highlight.tags.className,
179
+ color: '#167'
180
+ }, {
181
+ tag: [_highlight.tags.special(_highlight.tags.variableName), _highlight.tags.macroName],
182
+ color: '#256'
183
+ }, {
184
+ tag: _highlight.tags.definition(_highlight.tags.propertyName),
185
+ color: '#00c'
186
+ }, {
187
+ tag: _highlight.tags.comment,
188
+ color: '#940'
189
+ }, // { tag: tags.invalid, color: '#f00' },
190
+
191
+ /**
192
+ * Custom highlighting overrides
193
+ * (where original colors don't have enough contrast against #fff
194
+ * or active highlight background)
195
+ */
196
+ {
197
+ tag: _highlight.tags.meta,
198
+ color: '#757075'
199
+ }, {
200
+ tag: [_highlight.tags.regexp, _highlight.tags.escape, _highlight.tags.special(_highlight.tags.string)],
201
+ color: '#d13b00'
202
+ }, {
203
+ tag: [_highlight.tags.typeName, _highlight.tags.namespace],
204
+ color: '#008051'
205
+ }, {
206
+ tag: _highlight.tags.invalid,
207
+ color: '#e60000'
208
+ }]
209
+ };
210
+ };
211
+
212
+ var _default = generateStyle;
213
+ exports.default = _default;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ /*
9
+ * The MIT License (MIT)
10
+ *
11
+ * Copyright (c) 2015 - present Instructure, Inc.
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all
21
+ * copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ * SOFTWARE.
30
+ */
31
+
32
+ /**
33
+ * Generates the theme object for the component from the theme and provided additional information
34
+ * @param {Object} theme The actual theme object.
35
+ * @return {Object} The final theme object with the overrides and component variables
36
+ */
37
+ const generateComponentTheme = theme => {
38
+ const colors = theme.colors,
39
+ borders = theme.borders,
40
+ typography = theme.typography,
41
+ spacing = theme.spacing;
42
+ const componentVariables = {
43
+ fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamilyMonospace,
44
+ fontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
45
+ background: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest,
46
+ color: colors === null || colors === void 0 ? void 0 : colors.textDarkest,
47
+ gutterBackground: colors === null || colors === void 0 ? void 0 : colors.backgroundLight,
48
+ borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
49
+ borderColor: colors === null || colors === void 0 ? void 0 : colors.borderMedium,
50
+ borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusMedium,
51
+ focusBorderColor: colors === null || colors === void 0 ? void 0 : colors.borderBrand,
52
+ horizontalPadding: spacing === null || spacing === void 0 ? void 0 : spacing.xSmall,
53
+ verticalPadding: spacing === null || spacing === void 0 ? void 0 : spacing.xxSmall
54
+ };
55
+ return { ...componentVariables
56
+ };
57
+ };
58
+
59
+ var _default = generateComponentTheme;
60
+ exports.default = _default;
package/lib/index.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "SourceCodeEditor", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _SourceCodeEditor.SourceCodeEditor;
10
+ }
11
+ });
12
+
13
+ var _SourceCodeEditor = require("./SourceCodeEditor");
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@instructure/ui-source-code-editor",
3
+ "version": "8.25.1-snapshot-19",
4
+ "description": "A UI component library made by Instructure Inc.",
5
+ "author": "Instructure, Inc. Engineering and Product Design",
6
+ "module": "./es/index.js",
7
+ "main": "./lib/index.js",
8
+ "types": "./types/index.d.ts",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/instructure/instructure-ui.git"
12
+ },
13
+ "homepage": "https://instructure.github.io/instructure-ui/",
14
+ "bugs": "https://github.com/instructure/instructure-ui/issues",
15
+ "scripts": {
16
+ "lint": "run -T ui-test --lint",
17
+ "lint:fix": "run -T ui-test --lint --fix",
18
+ "clean": "run -T ui-build --clean",
19
+ "build": "run -T ui-build --modules es,cjs",
20
+ "build:watch": "yarn ts:check --watch & run -T ui-build --watch",
21
+ "build:types": "run -T tsc -p tsconfig.build.json",
22
+ "ts:check": "run -T tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
23
+ },
24
+ "license": "MIT",
25
+ "devDependencies": {
26
+ "@instructure/ui-babel-preset": "8.25.1-snapshot-19",
27
+ "@instructure/ui-test-queries": "8.25.1-snapshot-19",
28
+ "@instructure/ui-test-utils": "8.25.1-snapshot-19",
29
+ "@types/lodash": "^4"
30
+ },
31
+ "dependencies": {
32
+ "@babel/runtime": "^7.13.10",
33
+ "@codemirror/autocomplete": "^6.0.1",
34
+ "@codemirror/commands": "^6.0.0",
35
+ "@codemirror/lang-css": "^6.0.0",
36
+ "@codemirror/lang-html": "^6.0.0",
37
+ "@codemirror/lang-javascript": "^6.0.0",
38
+ "@codemirror/lang-json": "^6.0.0",
39
+ "@codemirror/lang-markdown": "^6.0.0",
40
+ "@codemirror/language": "^6.0.0",
41
+ "@codemirror/legacy-modes": "^6.0.0",
42
+ "@codemirror/lint": "^6.0.0",
43
+ "@codemirror/search": "^6.0.0",
44
+ "@codemirror/state": "^6.0.0",
45
+ "@codemirror/view": "^6.0.0",
46
+ "@instructure/emotion": "8.25.1-snapshot-19",
47
+ "@instructure/shared-types": "8.25.1-snapshot-19",
48
+ "@instructure/ui-a11y-content": "8.25.1-snapshot-19",
49
+ "@instructure/ui-dom-utils": "8.25.1-snapshot-19",
50
+ "@instructure/ui-i18n": "8.25.1-snapshot-19",
51
+ "@instructure/ui-prop-types": "8.25.1-snapshot-19",
52
+ "@instructure/ui-react-utils": "8.25.1-snapshot-19",
53
+ "@instructure/ui-test-locator": "8.25.1-snapshot-19",
54
+ "@instructure/ui-testable": "8.25.1-snapshot-19",
55
+ "@instructure/ui-themes": "8.25.1-snapshot-19",
56
+ "@instructure/ui-utils": "8.25.1-snapshot-19",
57
+ "@lezer/highlight": "^1.0.0",
58
+ "lodash": "^4",
59
+ "prop-types": "^15"
60
+ },
61
+ "peerDependencies": {
62
+ "react": ">=16.8 <=17"
63
+ },
64
+ "publishConfig": {
65
+ "access": "public"
66
+ },
67
+ "sideEffects": false
68
+ }