@splunk/react-ui 4.14.0 → 4.15.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.
- package/.dockerignore +2 -0
- package/Accordion.js +41 -16
- package/Anchor.js +9 -9
- package/Animation.js +6 -6
- package/AnimationToggle.js +2 -2
- package/Box.js +9 -9
- package/Button.js +35 -34
- package/ButtonGroup.js +9 -9
- package/ButtonSimple.js +14 -14
- package/CHANGELOG.md +30 -0
- package/Calendar.js +124 -106
- package/Card.js +68 -68
- package/CardLayout.js +9 -9
- package/Chip.js +23 -23
- package/Clickable.js +38 -14
- package/CloseButton.js +23 -23
- package/Code.js +484 -436
- package/CollapsiblePanel.js +59 -34
- package/Color.js +297 -187
- package/ColumnLayout.js +18 -17
- package/ComboBox.js +81 -32
- package/Concertina.js +88 -27
- package/ControlGroup.js +81 -24
- package/Date.js +44 -31
- package/DefinitionList.js +14 -8
- package/Divider.d.ts +2 -0
- package/Divider.js +9 -9
- package/Dockerfile.enterprise.storybook +7 -0
- package/Dockerfile.prisma.storybook +7 -0
- package/Dockerfile.visual +10 -0
- package/Dropdown.js +78 -18
- package/EventListener.js +17 -17
- package/File.js +96 -43
- package/FormRows.js +38 -37
- package/Heading.js +83 -55
- package/Image.js +67 -42
- package/JSONTree.js +106 -21
- package/Layer.js +59 -34
- package/Link.js +17 -17
- package/List.js +3 -3
- package/Markdown.js +71 -65
- package/Menu.js +155 -121
- package/Message.js +129 -129
- package/MessageBar.js +136 -136
- package/Modal.js +57 -32
- package/ModalLayer.js +15 -15
- package/Monogram.js +18 -17
- package/Multiselect.js +2793 -2315
- package/Number.js +74 -37
- package/Paginator.js +99 -86
- package/Paragraph.js +10 -10
- package/Popover.js +191 -54
- package/Progress.js +23 -22
- package/RadioBar.js +32 -14
- package/RadioList.js +17 -11
- package/Resize.js +33 -20
- package/ResultsMenu.js +36 -23
- package/ScreenReaderContent.js +9 -9
- package/Scroll.js +50 -25
- package/ScrollContainerContext.js +48 -48
- package/Search.js +68 -31
- package/Select.js +347 -69
- package/SidePanel.js +37 -24
- package/Slider.js +54 -24
- package/SlidingPanels.js +52 -14
- package/SplitButton.js +23 -22
- package/StaticContent.js +9 -9
- package/StepBar.js +22 -22
- package/Switch.js +18 -13
- package/TabBar.js +22 -22
- package/TabLayout.js +43 -18
- package/Table.js +371 -162
- package/Text.js +91 -49
- package/TextArea.d.ts +2 -0
- package/TextArea.js +127 -49
- package/Tooltip.js +236 -59
- package/TransitionOpen.js +39 -26
- package/Typography.d.ts +2 -0
- package/Typography.js +17 -16
- package/WaitSpinner.js +15 -15
- package/docker-compose.yml +42 -0
- package/package.json +12 -10
- package/test-runner-jest.config.js +11 -6
- package/types/src/Accordion/AccordionContext.d.ts +1 -0
- package/types/src/Button/docs/examples/Selected.d.ts +2 -2
- package/types/src/ButtonGroup/ButtonGroupContext.d.ts +1 -0
- package/types/src/Calendar/Calendar.d.ts +2 -0
- package/types/src/CardLayout/CardLayoutContext.d.ts +1 -0
- package/types/src/Concertina/ConcertinaContext.d.ts +1 -0
- package/types/src/ControlGroup/ControlGroup.d.ts +15 -8
- package/types/src/ControlGroup/docs/examples/HelpWithErrorText.d.ts +2 -0
- package/types/src/ControlGroup/docs/examples/Required.d.ts +2 -0
- package/types/src/File/File.d.ts +4 -2
- package/types/src/File/FileContext.d.ts +1 -0
- package/types/src/FormRows/FormRowsContext.d.ts +1 -0
- package/types/src/Markdown/renderers/MarkdownLink.d.ts +1 -1
- package/types/src/Menu/MenuContext.d.ts +1 -0
- package/types/src/Modal/ModalContext.d.ts +1 -0
- package/types/src/Multiselect/Compact.d.ts +10 -1
- package/types/src/Multiselect/Multiselect.d.ts +12 -1
- package/types/src/Multiselect/Normal.d.ts +2 -0
- package/types/src/Popover/Popover.d.ts +25 -5
- package/types/src/Popover/PopoverContext.d.ts +1 -0
- package/types/src/RadioBar/RadioBar.d.ts +5 -3
- package/types/src/RadioBar/RadioBarContext.d.ts +1 -0
- package/types/src/RadioList/RadioList.d.ts +5 -1
- package/types/src/RadioList/RadioListContext.d.ts +1 -0
- package/types/src/Select/SelectBase.d.ts +2 -0
- package/types/src/Slider/Slider.d.ts +5 -3
- package/types/src/StepBar/StepBarContext.d.ts +1 -0
- package/types/src/Switch/Switch.d.ts +2 -0
- package/types/src/TabBar/TabBarContext.d.ts +1 -0
- package/types/src/Table/Head.d.ts +2 -0
- package/types/src/Table/TableContext.d.ts +1 -0
- package/types/src/Text/Text.d.ts +5 -3
- package/types/src/TextArea/TextArea.d.ts +5 -3
- package/types/src/Tooltip/Tooltip.d.ts +16 -4
- package/types/src/useForceUpdate/useForceUpdate.d.ts +1 -0
- package/useForceUpdate.js +9 -9
- package/useKeyPress.js +2 -2
- package/usePrevious.js +9 -9
- package/.storybook-visual/config/snapshotResolver.js +0 -29
- package/.storybook-visual/main.js +0 -22
- package/.storybook-visual/preview.jsx +0 -31
- package/.storybook-visual/scripts/test.sh +0 -108
- package/.storybook-visual/test-runner.js +0 -108
package/Code.js
CHANGED
|
@@ -82,7 +82,7 @@ module.exports =
|
|
|
82
82
|
/******/
|
|
83
83
|
/******/
|
|
84
84
|
/******/ // Load entry module and return exports
|
|
85
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
85
|
+
/******/ return __webpack_require__(__webpack_require__.s = 208);
|
|
86
86
|
/******/ })
|
|
87
87
|
/************************************************************************/
|
|
88
88
|
/******/ ({
|
|
@@ -101,473 +101,193 @@ module.exports = require("prop-types");
|
|
|
101
101
|
|
|
102
102
|
/***/ }),
|
|
103
103
|
|
|
104
|
-
/***/
|
|
105
|
-
/***/ (function(module,
|
|
106
|
-
|
|
107
|
-
"use strict";
|
|
108
|
-
// ESM COMPAT FLAG
|
|
109
|
-
__webpack_require__.r(__webpack_exports__);
|
|
104
|
+
/***/ 114:
|
|
105
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
110
106
|
|
|
111
|
-
// EXPORTS
|
|
112
|
-
__webpack_require__.d(__webpack_exports__, "default", function() { return /* reexport */ Code_Code; });
|
|
113
107
|
|
|
114
|
-
|
|
115
|
-
var
|
|
116
|
-
var
|
|
108
|
+
(function() {
|
|
109
|
+
var window = undefined;
|
|
110
|
+
var global = undefined;
|
|
111
|
+
/// <reference lib="WebWorker"/>
|
|
117
112
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
113
|
+
var _self = (typeof window !== 'undefined')
|
|
114
|
+
? window // if in browser
|
|
115
|
+
: (
|
|
116
|
+
(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
|
|
117
|
+
? self // if in worker
|
|
118
|
+
: {} // if in node js
|
|
119
|
+
);
|
|
121
120
|
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
123
|
+
*
|
|
124
|
+
* @license MIT <https://opensource.org/licenses/MIT>
|
|
125
|
+
* @author Lea Verou <https://lea.verou.me>
|
|
126
|
+
* @namespace
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
var Prism = (function (_self) {
|
|
124
130
|
|
|
125
|
-
//
|
|
126
|
-
var
|
|
127
|
-
var
|
|
131
|
+
// Private helper vars
|
|
132
|
+
var lang = /\blang(?:uage)?-([\w-]+)\b/i;
|
|
133
|
+
var uniqueId = 0;
|
|
128
134
|
|
|
129
|
-
//
|
|
130
|
-
var
|
|
131
|
-
var external_styled_components_default = /*#__PURE__*/__webpack_require__.n(external_styled_components_);
|
|
135
|
+
// The grammar object for plaintext
|
|
136
|
+
var plainTextGrammar = {};
|
|
132
137
|
|
|
133
|
-
// EXTERNAL MODULE: external "@splunk/themes"
|
|
134
|
-
var themes_ = __webpack_require__(0);
|
|
135
138
|
|
|
136
|
-
|
|
139
|
+
var _ = {
|
|
140
|
+
/**
|
|
141
|
+
* By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
|
|
142
|
+
* current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
|
|
143
|
+
* additional languages or plugins yourself.
|
|
144
|
+
*
|
|
145
|
+
* By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
|
|
146
|
+
*
|
|
147
|
+
* You obviously have to change this value before the automatic highlighting started. To do this, you can add an
|
|
148
|
+
* empty Prism object into the global scope before loading the Prism script like this:
|
|
149
|
+
*
|
|
150
|
+
* ```js
|
|
151
|
+
* window.Prism = window.Prism || {};
|
|
152
|
+
* Prism.manual = true;
|
|
153
|
+
* // add a new <script> to load Prism's script
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @default false
|
|
157
|
+
* @type {boolean}
|
|
158
|
+
* @memberof Prism
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
161
|
+
manual: _self.Prism && _self.Prism.manual,
|
|
162
|
+
disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
|
|
137
163
|
|
|
164
|
+
/**
|
|
165
|
+
* A namespace for utility methods.
|
|
166
|
+
*
|
|
167
|
+
* All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
|
|
168
|
+
* change or disappear at any time.
|
|
169
|
+
*
|
|
170
|
+
* @namespace
|
|
171
|
+
* @memberof Prism
|
|
172
|
+
*/
|
|
173
|
+
util: {
|
|
174
|
+
encode: function encode(tokens) {
|
|
175
|
+
if (tokens instanceof Token) {
|
|
176
|
+
return new Token(tokens.type, encode(tokens.content), tokens.alias);
|
|
177
|
+
} else if (Array.isArray(tokens)) {
|
|
178
|
+
return tokens.map(encode);
|
|
179
|
+
} else {
|
|
180
|
+
return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' ');
|
|
181
|
+
}
|
|
182
|
+
},
|
|
138
183
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
var gray = Object(themes_["pick"])({
|
|
159
|
-
prisma: themes_["variables"].syntaxGray,
|
|
160
|
-
enterprise: {
|
|
161
|
-
dark: themes_["variables"].gray60,
|
|
162
|
-
light: themes_["variables"].syntaxGray
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
var purple = Object(themes_["pick"])({
|
|
166
|
-
prisma: themes_["variables"].syntaxPurple,
|
|
167
|
-
enterprise: {
|
|
168
|
-
dark: themes_["variables"].syntaxPurpleLight,
|
|
169
|
-
light: themes_["variables"].syntaxPurple
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
var green = Object(themes_["pick"])({
|
|
173
|
-
prisma: themes_["variables"].syntaxGreen,
|
|
174
|
-
enterprise: {
|
|
175
|
-
dark: themes_["variables"].syntaxGreenLight,
|
|
176
|
-
light: themes_["variables"].syntaxGreen
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
var blue = Object(themes_["pick"])({
|
|
180
|
-
prisma: themes_["variables"].syntaxBlue,
|
|
181
|
-
enterprise: {
|
|
182
|
-
dark: themes_["variables"].syntaxBlueLight,
|
|
183
|
-
light: themes_["variables"].syntaxBlue
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
var red = Object(themes_["pick"])({
|
|
187
|
-
prisma: themes_["variables"].syntaxRed,
|
|
188
|
-
enterprise: {
|
|
189
|
-
dark: themes_["variables"].syntaxRedLight,
|
|
190
|
-
light: themes_["variables"].syntaxRed
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
var TokenColors = {
|
|
194
|
-
comment: gray,
|
|
195
|
-
prolog: gray,
|
|
196
|
-
doctype: gray,
|
|
197
|
-
cdata: gray,
|
|
198
|
-
punctuation: gray,
|
|
199
|
-
property: purple,
|
|
200
|
-
tag: purple,
|
|
201
|
-
"boolean": purple,
|
|
202
|
-
number: purple,
|
|
203
|
-
constant: purple,
|
|
204
|
-
symbol: purple,
|
|
205
|
-
deleted: purple,
|
|
206
|
-
key: purple,
|
|
207
|
-
selector: green,
|
|
208
|
-
'attr-name': green,
|
|
209
|
-
string: green,
|
|
210
|
-
"char": green,
|
|
211
|
-
builtin: green,
|
|
212
|
-
inserted: green,
|
|
213
|
-
operator: themes_["variables"].syntaxBrown,
|
|
214
|
-
entity: themes_["variables"].syntaxBrown,
|
|
215
|
-
url: themes_["variables"].syntaxBrown,
|
|
216
|
-
atrule: blue,
|
|
217
|
-
'attr-value': blue,
|
|
218
|
-
keyword: blue,
|
|
219
|
-
"function": red,
|
|
220
|
-
regex: themes_["variables"].syntaxOrange,
|
|
221
|
-
important: themes_["variables"].syntaxOrange,
|
|
222
|
-
variable: themes_["variables"].syntaxOrange
|
|
223
|
-
};
|
|
224
|
-
var StyledToken = external_styled_components_default.a.span.withConfig({
|
|
225
|
-
displayName: "CodeStyles__StyledToken",
|
|
226
|
-
componentId: "sc-1eq4k68-3"
|
|
227
|
-
})(["color:", ";cursor:", ";opacity:", ";font-style:", ";font-weight:", ";"], function (_ref) {
|
|
228
|
-
var partType = _ref.partType;
|
|
229
|
-
return TokenColors[partType];
|
|
230
|
-
}, function (_ref2) {
|
|
231
|
-
var partType = _ref2.partType;
|
|
232
|
-
return partType === 'entity' ? 'help' : null;
|
|
233
|
-
}, function (_ref3) {
|
|
234
|
-
var partType = _ref3.partType;
|
|
235
|
-
return partType === 'namespace' ? 0.7 : null;
|
|
236
|
-
}, function (_ref4) {
|
|
237
|
-
var partType = _ref4.partType;
|
|
238
|
-
return partType === 'italic' ? 'italic' : null;
|
|
239
|
-
}, function (_ref5) {
|
|
240
|
-
var partType = _ref5.partType;
|
|
241
|
-
return partType === 'important' || partType === 'bold' ? 'bold' : null;
|
|
242
|
-
});
|
|
184
|
+
/**
|
|
185
|
+
* Returns the name of the type of the given value.
|
|
186
|
+
*
|
|
187
|
+
* @param {any} o
|
|
188
|
+
* @returns {string}
|
|
189
|
+
* @example
|
|
190
|
+
* type(null) === 'Null'
|
|
191
|
+
* type(undefined) === 'Undefined'
|
|
192
|
+
* type(123) === 'Number'
|
|
193
|
+
* type('foo') === 'String'
|
|
194
|
+
* type(true) === 'Boolean'
|
|
195
|
+
* type([1, 2]) === 'Array'
|
|
196
|
+
* type({}) === 'Object'
|
|
197
|
+
* type(String) === 'Function'
|
|
198
|
+
* type(/abc+/) === 'RegExp'
|
|
199
|
+
*/
|
|
200
|
+
type: function (o) {
|
|
201
|
+
return Object.prototype.toString.call(o).slice(8, -1);
|
|
202
|
+
},
|
|
243
203
|
|
|
244
|
-
|
|
245
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Returns a unique number for the given object. Later calls will still return the same number.
|
|
206
|
+
*
|
|
207
|
+
* @param {Object} obj
|
|
208
|
+
* @returns {number}
|
|
209
|
+
*/
|
|
210
|
+
objId: function (obj) {
|
|
211
|
+
if (!obj['__id']) {
|
|
212
|
+
Object.defineProperty(obj, '__id', { value: ++uniqueId });
|
|
213
|
+
}
|
|
214
|
+
return obj['__id'];
|
|
215
|
+
},
|
|
246
216
|
|
|
247
|
-
|
|
217
|
+
/**
|
|
218
|
+
* Creates a deep clone of the given object.
|
|
219
|
+
*
|
|
220
|
+
* The main intended use of this function is to clone language definitions.
|
|
221
|
+
*
|
|
222
|
+
* @param {T} o
|
|
223
|
+
* @param {Record<number, any>} [visited]
|
|
224
|
+
* @returns {T}
|
|
225
|
+
* @template T
|
|
226
|
+
*/
|
|
227
|
+
clone: function deepClone(o, visited) {
|
|
228
|
+
visited = visited || {};
|
|
248
229
|
|
|
249
|
-
|
|
230
|
+
var clone; var id;
|
|
231
|
+
switch (_.util.type(o)) {
|
|
232
|
+
case 'Object':
|
|
233
|
+
id = _.util.objId(o);
|
|
234
|
+
if (visited[id]) {
|
|
235
|
+
return visited[id];
|
|
236
|
+
}
|
|
237
|
+
clone = /** @type {Record<string, any>} */ ({});
|
|
238
|
+
visited[id] = clone;
|
|
250
239
|
|
|
240
|
+
for (var key in o) {
|
|
241
|
+
if (o.hasOwnProperty(key)) {
|
|
242
|
+
clone[key] = deepClone(o[key], visited);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
251
245
|
|
|
246
|
+
return /** @type {any} */ (clone);
|
|
252
247
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
var supportedLanguages = ['bash', 'clike', 'css', 'html', 'json', 'javascript', 'js', 'jsx', 'typescript', 'ts', 'tsx', 'markup', 'mathml', 'svg', 'xml', 'yaml', 'yml'];
|
|
261
|
-
|
|
262
|
-
function tokenize(text, language) {
|
|
263
|
-
if (false) {}
|
|
264
|
-
|
|
265
|
-
return prism_empty_default.a.tokenize(text, prism_empty_default.a.languages[language]);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
var propTypes = {
|
|
269
|
-
elementRef: external_prop_types_default.a.oneOfType([external_prop_types_default.a.func, external_prop_types_default.a.object]),
|
|
270
|
-
indentChars: external_prop_types_default.a.number,
|
|
271
|
-
language: external_prop_types_default.a.oneOf(supportedLanguages),
|
|
272
|
-
showIndentGuide: external_prop_types_default.a.bool,
|
|
273
|
-
value: external_prop_types_default.a.string
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
function Code(_ref) {
|
|
277
|
-
var elementRef = _ref.elementRef,
|
|
278
|
-
_ref$indentChars = _ref.indentChars,
|
|
279
|
-
indentChars = _ref$indentChars === void 0 ? 4 : _ref$indentChars,
|
|
280
|
-
_ref$language = _ref.language,
|
|
281
|
-
language = _ref$language === void 0 ? 'javascript' : _ref$language,
|
|
282
|
-
_ref$showIndentGuide = _ref.showIndentGuide,
|
|
283
|
-
showIndentGuide = _ref$showIndentGuide === void 0 ? true : _ref$showIndentGuide,
|
|
284
|
-
_ref$value = _ref.value,
|
|
285
|
-
value = _ref$value === void 0 ? '' : _ref$value,
|
|
286
|
-
otherProps = _objectWithoutProperties(_ref, ["elementRef", "indentChars", "language", "showIndentGuide", "value"]);
|
|
287
|
-
|
|
288
|
-
// @docs-props-type CodePropsBase
|
|
289
|
-
var indentBlock = Object(external_lodash_["repeat"])(' ', indentChars);
|
|
290
|
-
|
|
291
|
-
var makeIndentGuide = function makeIndentGuide(spaces) {
|
|
292
|
-
var level = Math.floor(spaces / indentChars);
|
|
293
|
-
var rest = spaces % indentChars;
|
|
294
|
-
var spans = Object(external_lodash_["times"])(level, function (idx) {
|
|
295
|
-
return /*#__PURE__*/external_react_default.a.createElement(StyledIndent, {
|
|
296
|
-
key: idx.toString()
|
|
297
|
-
}, indentBlock);
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
if (rest) {
|
|
301
|
-
spans.push(Object(external_lodash_["repeat"])(' ', rest));
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
return spans;
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
var tokens = tokenize(value, language);
|
|
308
|
-
|
|
309
|
-
var render = function render(tks) {
|
|
310
|
-
return Object(external_lodash_["castArray"])(tks).map(function (part, idx) {
|
|
311
|
-
if (typeof part === 'string') {
|
|
312
|
-
if (!showIndentGuide) {
|
|
313
|
-
return part;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
var lines = part.split('\n');
|
|
317
|
-
|
|
318
|
-
if (lines.length === 1) {
|
|
319
|
-
return part;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
return Object(external_lodash_["flatten"])(lines.map(function (line, lineNo) {
|
|
323
|
-
var res = lineNo === 0 ? [] : ['\n'];
|
|
324
|
-
var indentMatch = line.match(/^(\s+)(.*)/);
|
|
325
|
-
|
|
326
|
-
if (!indentMatch) {
|
|
327
|
-
res.push(line);
|
|
328
|
-
} else {
|
|
329
|
-
res.push( /*#__PURE__*/external_react_default.a.createElement("span", {
|
|
330
|
-
key: "".concat(idx.toString(), ":").concat(lineNo.toString())
|
|
331
|
-
}, makeIndentGuide(indentMatch[1].length)), indentMatch[2]);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
return res;
|
|
335
|
-
}));
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
var content = typeof part.content === 'string' ? part.content : render(part.content);
|
|
339
|
-
return /*#__PURE__*/external_react_default.a.createElement(StyledToken, {
|
|
340
|
-
partType: part.type,
|
|
341
|
-
key: idx.toString()
|
|
342
|
-
}, content);
|
|
343
|
-
});
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
var codeContent = render(tokens);
|
|
347
|
-
return /*#__PURE__*/external_react_default.a.createElement(Styled, _extends({
|
|
348
|
-
"data-test": "code",
|
|
349
|
-
ref: elementRef,
|
|
350
|
-
tabIndex: 0
|
|
351
|
-
}, otherProps), /*#__PURE__*/external_react_default.a.createElement(StyledCode, {
|
|
352
|
-
className: "language-".concat(language)
|
|
353
|
-
}, codeContent));
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
Code.propTypes = propTypes;
|
|
357
|
-
/* harmony default export */ var Code_Code = (Code);
|
|
358
|
-
// CONCATENATED MODULE: ./src/Code/index.ts
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
/***/ }),
|
|
362
|
-
|
|
363
|
-
/***/ 2:
|
|
364
|
-
/***/ (function(module, exports) {
|
|
365
|
-
|
|
366
|
-
module.exports = require("react");
|
|
367
|
-
|
|
368
|
-
/***/ }),
|
|
369
|
-
|
|
370
|
-
/***/ 3:
|
|
371
|
-
/***/ (function(module, exports) {
|
|
372
|
-
|
|
373
|
-
module.exports = require("styled-components");
|
|
374
|
-
|
|
375
|
-
/***/ }),
|
|
376
|
-
|
|
377
|
-
/***/ 4:
|
|
378
|
-
/***/ (function(module, exports) {
|
|
379
|
-
|
|
380
|
-
module.exports = require("lodash");
|
|
381
|
-
|
|
382
|
-
/***/ }),
|
|
383
|
-
|
|
384
|
-
/***/ 84:
|
|
385
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
(function() {
|
|
389
|
-
var window = undefined;
|
|
390
|
-
var global = undefined;
|
|
391
|
-
/// <reference lib="WebWorker"/>
|
|
392
|
-
|
|
393
|
-
var _self = (typeof window !== 'undefined')
|
|
394
|
-
? window // if in browser
|
|
395
|
-
: (
|
|
396
|
-
(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
|
|
397
|
-
? self // if in worker
|
|
398
|
-
: {} // if in node js
|
|
399
|
-
);
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
403
|
-
*
|
|
404
|
-
* @license MIT <https://opensource.org/licenses/MIT>
|
|
405
|
-
* @author Lea Verou <https://lea.verou.me>
|
|
406
|
-
* @namespace
|
|
407
|
-
* @public
|
|
408
|
-
*/
|
|
409
|
-
var Prism = (function (_self) {
|
|
410
|
-
|
|
411
|
-
// Private helper vars
|
|
412
|
-
var lang = /\blang(?:uage)?-([\w-]+)\b/i;
|
|
413
|
-
var uniqueId = 0;
|
|
414
|
-
|
|
415
|
-
// The grammar object for plaintext
|
|
416
|
-
var plainTextGrammar = {};
|
|
248
|
+
case 'Array':
|
|
249
|
+
id = _.util.objId(o);
|
|
250
|
+
if (visited[id]) {
|
|
251
|
+
return visited[id];
|
|
252
|
+
}
|
|
253
|
+
clone = [];
|
|
254
|
+
visited[id] = clone;
|
|
417
255
|
|
|
256
|
+
(/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
|
|
257
|
+
clone[i] = deepClone(v, visited);
|
|
258
|
+
});
|
|
418
259
|
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
|
|
422
|
-
* current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
|
|
423
|
-
* additional languages or plugins yourself.
|
|
424
|
-
*
|
|
425
|
-
* By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
|
|
426
|
-
*
|
|
427
|
-
* You obviously have to change this value before the automatic highlighting started. To do this, you can add an
|
|
428
|
-
* empty Prism object into the global scope before loading the Prism script like this:
|
|
429
|
-
*
|
|
430
|
-
* ```js
|
|
431
|
-
* window.Prism = window.Prism || {};
|
|
432
|
-
* Prism.manual = true;
|
|
433
|
-
* // add a new <script> to load Prism's script
|
|
434
|
-
* ```
|
|
435
|
-
*
|
|
436
|
-
* @default false
|
|
437
|
-
* @type {boolean}
|
|
438
|
-
* @memberof Prism
|
|
439
|
-
* @public
|
|
440
|
-
*/
|
|
441
|
-
manual: _self.Prism && _self.Prism.manual,
|
|
442
|
-
disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
|
|
260
|
+
return /** @type {any} */ (clone);
|
|
443
261
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
*
|
|
447
|
-
* All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
|
|
448
|
-
* change or disappear at any time.
|
|
449
|
-
*
|
|
450
|
-
* @namespace
|
|
451
|
-
* @memberof Prism
|
|
452
|
-
*/
|
|
453
|
-
util: {
|
|
454
|
-
encode: function encode(tokens) {
|
|
455
|
-
if (tokens instanceof Token) {
|
|
456
|
-
return new Token(tokens.type, encode(tokens.content), tokens.alias);
|
|
457
|
-
} else if (Array.isArray(tokens)) {
|
|
458
|
-
return tokens.map(encode);
|
|
459
|
-
} else {
|
|
460
|
-
return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' ');
|
|
262
|
+
default:
|
|
263
|
+
return o;
|
|
461
264
|
}
|
|
462
265
|
},
|
|
463
266
|
|
|
464
267
|
/**
|
|
465
|
-
* Returns the
|
|
268
|
+
* Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
|
|
466
269
|
*
|
|
467
|
-
*
|
|
468
|
-
* @returns {string}
|
|
469
|
-
* @example
|
|
470
|
-
* type(null) === 'Null'
|
|
471
|
-
* type(undefined) === 'Undefined'
|
|
472
|
-
* type(123) === 'Number'
|
|
473
|
-
* type('foo') === 'String'
|
|
474
|
-
* type(true) === 'Boolean'
|
|
475
|
-
* type([1, 2]) === 'Array'
|
|
476
|
-
* type({}) === 'Object'
|
|
477
|
-
* type(String) === 'Function'
|
|
478
|
-
* type(/abc+/) === 'RegExp'
|
|
479
|
-
*/
|
|
480
|
-
type: function (o) {
|
|
481
|
-
return Object.prototype.toString.call(o).slice(8, -1);
|
|
482
|
-
},
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Returns a unique number for the given object. Later calls will still return the same number.
|
|
270
|
+
* If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
|
|
486
271
|
*
|
|
487
|
-
* @param {
|
|
488
|
-
* @returns {
|
|
272
|
+
* @param {Element} element
|
|
273
|
+
* @returns {string}
|
|
489
274
|
*/
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
275
|
+
getLanguage: function (element) {
|
|
276
|
+
while (element && !lang.test(element.className)) {
|
|
277
|
+
element = element.parentElement;
|
|
493
278
|
}
|
|
494
|
-
|
|
279
|
+
if (element) {
|
|
280
|
+
return (element.className.match(lang) || [, 'none'])[1].toLowerCase();
|
|
281
|
+
}
|
|
282
|
+
return 'none';
|
|
495
283
|
},
|
|
496
284
|
|
|
497
285
|
/**
|
|
498
|
-
*
|
|
286
|
+
* Returns the script element that is currently executing.
|
|
499
287
|
*
|
|
500
|
-
*
|
|
288
|
+
* This does __not__ work for line script element.
|
|
501
289
|
*
|
|
502
|
-
* @
|
|
503
|
-
* @param {Record<number, any>} [visited]
|
|
504
|
-
* @returns {T}
|
|
505
|
-
* @template T
|
|
506
|
-
*/
|
|
507
|
-
clone: function deepClone(o, visited) {
|
|
508
|
-
visited = visited || {};
|
|
509
|
-
|
|
510
|
-
var clone; var id;
|
|
511
|
-
switch (_.util.type(o)) {
|
|
512
|
-
case 'Object':
|
|
513
|
-
id = _.util.objId(o);
|
|
514
|
-
if (visited[id]) {
|
|
515
|
-
return visited[id];
|
|
516
|
-
}
|
|
517
|
-
clone = /** @type {Record<string, any>} */ ({});
|
|
518
|
-
visited[id] = clone;
|
|
519
|
-
|
|
520
|
-
for (var key in o) {
|
|
521
|
-
if (o.hasOwnProperty(key)) {
|
|
522
|
-
clone[key] = deepClone(o[key], visited);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
return /** @type {any} */ (clone);
|
|
527
|
-
|
|
528
|
-
case 'Array':
|
|
529
|
-
id = _.util.objId(o);
|
|
530
|
-
if (visited[id]) {
|
|
531
|
-
return visited[id];
|
|
532
|
-
}
|
|
533
|
-
clone = [];
|
|
534
|
-
visited[id] = clone;
|
|
535
|
-
|
|
536
|
-
(/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
|
|
537
|
-
clone[i] = deepClone(v, visited);
|
|
538
|
-
});
|
|
539
|
-
|
|
540
|
-
return /** @type {any} */ (clone);
|
|
541
|
-
|
|
542
|
-
default:
|
|
543
|
-
return o;
|
|
544
|
-
}
|
|
545
|
-
},
|
|
546
|
-
|
|
547
|
-
/**
|
|
548
|
-
* Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
|
|
549
|
-
*
|
|
550
|
-
* If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
|
|
551
|
-
*
|
|
552
|
-
* @param {Element} element
|
|
553
|
-
* @returns {string}
|
|
554
|
-
*/
|
|
555
|
-
getLanguage: function (element) {
|
|
556
|
-
while (element && !lang.test(element.className)) {
|
|
557
|
-
element = element.parentElement;
|
|
558
|
-
}
|
|
559
|
-
if (element) {
|
|
560
|
-
return (element.className.match(lang) || [, 'none'])[1].toLowerCase();
|
|
561
|
-
}
|
|
562
|
-
return 'none';
|
|
563
|
-
},
|
|
564
|
-
|
|
565
|
-
/**
|
|
566
|
-
* Returns the script element that is currently executing.
|
|
567
|
-
*
|
|
568
|
-
* This does __not__ work for line script element.
|
|
569
|
-
*
|
|
570
|
-
* @returns {HTMLScriptElement | null}
|
|
290
|
+
* @returns {HTMLScriptElement | null}
|
|
571
291
|
*/
|
|
572
292
|
currentScript: function () {
|
|
573
293
|
if (typeof document === 'undefined') {
|
|
@@ -2568,6 +2288,334 @@ Prism.languages.js = Prism.languages.javascript;
|
|
|
2568
2288
|
})();
|
|
2569
2289
|
|
|
2570
2290
|
|
|
2291
|
+
/***/ }),
|
|
2292
|
+
|
|
2293
|
+
/***/ 122:
|
|
2294
|
+
/***/ (function(module, exports) {
|
|
2295
|
+
|
|
2296
|
+
module.exports = require("lodash/flatten");
|
|
2297
|
+
|
|
2298
|
+
/***/ }),
|
|
2299
|
+
|
|
2300
|
+
/***/ 2:
|
|
2301
|
+
/***/ (function(module, exports) {
|
|
2302
|
+
|
|
2303
|
+
module.exports = require("react");
|
|
2304
|
+
|
|
2305
|
+
/***/ }),
|
|
2306
|
+
|
|
2307
|
+
/***/ 208:
|
|
2308
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
2309
|
+
|
|
2310
|
+
"use strict";
|
|
2311
|
+
// ESM COMPAT FLAG
|
|
2312
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2313
|
+
|
|
2314
|
+
// EXPORTS
|
|
2315
|
+
__webpack_require__.d(__webpack_exports__, "default", function() { return /* reexport */ Code_Code; });
|
|
2316
|
+
|
|
2317
|
+
// EXTERNAL MODULE: external "react"
|
|
2318
|
+
var external_react_ = __webpack_require__(2);
|
|
2319
|
+
var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
|
|
2320
|
+
|
|
2321
|
+
// EXTERNAL MODULE: external "prop-types"
|
|
2322
|
+
var external_prop_types_ = __webpack_require__(1);
|
|
2323
|
+
var external_prop_types_default = /*#__PURE__*/__webpack_require__.n(external_prop_types_);
|
|
2324
|
+
|
|
2325
|
+
// EXTERNAL MODULE: external "lodash/castArray"
|
|
2326
|
+
var castArray_ = __webpack_require__(62);
|
|
2327
|
+
var castArray_default = /*#__PURE__*/__webpack_require__.n(castArray_);
|
|
2328
|
+
|
|
2329
|
+
// EXTERNAL MODULE: external "lodash/flatten"
|
|
2330
|
+
var flatten_ = __webpack_require__(122);
|
|
2331
|
+
var flatten_default = /*#__PURE__*/__webpack_require__.n(flatten_);
|
|
2332
|
+
|
|
2333
|
+
// EXTERNAL MODULE: external "lodash/indexOf"
|
|
2334
|
+
var indexOf_ = __webpack_require__(88);
|
|
2335
|
+
|
|
2336
|
+
// EXTERNAL MODULE: external "lodash/repeat"
|
|
2337
|
+
var repeat_ = __webpack_require__(79);
|
|
2338
|
+
var repeat_default = /*#__PURE__*/__webpack_require__.n(repeat_);
|
|
2339
|
+
|
|
2340
|
+
// EXTERNAL MODULE: external "lodash/times"
|
|
2341
|
+
var times_ = __webpack_require__(78);
|
|
2342
|
+
var times_default = /*#__PURE__*/__webpack_require__.n(times_);
|
|
2343
|
+
|
|
2344
|
+
// EXTERNAL MODULE: ./src/Code/prism/prism.empty
|
|
2345
|
+
var prism_empty = __webpack_require__(114);
|
|
2346
|
+
var prism_empty_default = /*#__PURE__*/__webpack_require__.n(prism_empty);
|
|
2347
|
+
|
|
2348
|
+
// EXTERNAL MODULE: external "styled-components"
|
|
2349
|
+
var external_styled_components_ = __webpack_require__(3);
|
|
2350
|
+
var external_styled_components_default = /*#__PURE__*/__webpack_require__.n(external_styled_components_);
|
|
2351
|
+
|
|
2352
|
+
// EXTERNAL MODULE: external "@splunk/themes"
|
|
2353
|
+
var themes_ = __webpack_require__(0);
|
|
2354
|
+
|
|
2355
|
+
// CONCATENATED MODULE: ./src/Code/CodeStyles.ts
|
|
2356
|
+
|
|
2357
|
+
|
|
2358
|
+
var Styled = external_styled_components_default.a.pre.withConfig({
|
|
2359
|
+
displayName: "CodeStyles__Styled",
|
|
2360
|
+
componentId: "sc-1eq4k68-0"
|
|
2361
|
+
})(["", ";", " line-height:", ";text-align:left;tab-size:4;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;hyphens:none;overflow-x:auto;margin-bottom:1.3em;&:focus-visible{outline:solid ", ";}"], themes_["mixins"].reset('block'), Object(themes_["pick"])({
|
|
2362
|
+
enterprise: {
|
|
2363
|
+
dark: Object(external_styled_components_["css"])(["color:", ";"], themes_["variables"].gray92)
|
|
2364
|
+
}
|
|
2365
|
+
}), Object(themes_["pick"])({
|
|
2366
|
+
enterprise: '17px',
|
|
2367
|
+
prisma: themes_["variables"].lineHeight
|
|
2368
|
+
}), themes_["variables"].focusColor);
|
|
2369
|
+
var StyledCode = external_styled_components_default.a.code.withConfig({
|
|
2370
|
+
displayName: "CodeStyles__StyledCode",
|
|
2371
|
+
componentId: "sc-1eq4k68-1"
|
|
2372
|
+
})(["font-family:", ";"], themes_["variables"].monoFontFamily);
|
|
2373
|
+
var StyledIndent = external_styled_components_default.a.span.withConfig({
|
|
2374
|
+
displayName: "CodeStyles__StyledIndent",
|
|
2375
|
+
componentId: "sc-1eq4k68-2"
|
|
2376
|
+
})(["&:not(:last-child){background-image:linear-gradient( to left,rgba(0,0,0,0.15) 1px,transparent 1px,transparent );}"]);
|
|
2377
|
+
var gray = Object(themes_["pick"])({
|
|
2378
|
+
prisma: themes_["variables"].syntaxGray,
|
|
2379
|
+
enterprise: {
|
|
2380
|
+
dark: themes_["variables"].gray60,
|
|
2381
|
+
light: themes_["variables"].syntaxGray
|
|
2382
|
+
}
|
|
2383
|
+
});
|
|
2384
|
+
var purple = Object(themes_["pick"])({
|
|
2385
|
+
prisma: themes_["variables"].syntaxPurple,
|
|
2386
|
+
enterprise: {
|
|
2387
|
+
dark: themes_["variables"].syntaxPurpleLight,
|
|
2388
|
+
light: themes_["variables"].syntaxPurple
|
|
2389
|
+
}
|
|
2390
|
+
});
|
|
2391
|
+
var green = Object(themes_["pick"])({
|
|
2392
|
+
prisma: themes_["variables"].syntaxGreen,
|
|
2393
|
+
enterprise: {
|
|
2394
|
+
dark: themes_["variables"].syntaxGreenLight,
|
|
2395
|
+
light: themes_["variables"].syntaxGreen
|
|
2396
|
+
}
|
|
2397
|
+
});
|
|
2398
|
+
var blue = Object(themes_["pick"])({
|
|
2399
|
+
prisma: themes_["variables"].syntaxBlue,
|
|
2400
|
+
enterprise: {
|
|
2401
|
+
dark: themes_["variables"].syntaxBlueLight,
|
|
2402
|
+
light: themes_["variables"].syntaxBlue
|
|
2403
|
+
}
|
|
2404
|
+
});
|
|
2405
|
+
var red = Object(themes_["pick"])({
|
|
2406
|
+
prisma: themes_["variables"].syntaxRed,
|
|
2407
|
+
enterprise: {
|
|
2408
|
+
dark: themes_["variables"].syntaxRedLight,
|
|
2409
|
+
light: themes_["variables"].syntaxRed
|
|
2410
|
+
}
|
|
2411
|
+
});
|
|
2412
|
+
var TokenColors = {
|
|
2413
|
+
comment: gray,
|
|
2414
|
+
prolog: gray,
|
|
2415
|
+
doctype: gray,
|
|
2416
|
+
cdata: gray,
|
|
2417
|
+
punctuation: gray,
|
|
2418
|
+
property: purple,
|
|
2419
|
+
tag: purple,
|
|
2420
|
+
"boolean": purple,
|
|
2421
|
+
number: purple,
|
|
2422
|
+
constant: purple,
|
|
2423
|
+
symbol: purple,
|
|
2424
|
+
deleted: purple,
|
|
2425
|
+
key: purple,
|
|
2426
|
+
selector: green,
|
|
2427
|
+
'attr-name': green,
|
|
2428
|
+
string: green,
|
|
2429
|
+
"char": green,
|
|
2430
|
+
builtin: green,
|
|
2431
|
+
inserted: green,
|
|
2432
|
+
operator: themes_["variables"].syntaxBrown,
|
|
2433
|
+
entity: themes_["variables"].syntaxBrown,
|
|
2434
|
+
url: themes_["variables"].syntaxBrown,
|
|
2435
|
+
atrule: blue,
|
|
2436
|
+
'attr-value': blue,
|
|
2437
|
+
keyword: blue,
|
|
2438
|
+
"function": red,
|
|
2439
|
+
regex: themes_["variables"].syntaxOrange,
|
|
2440
|
+
important: themes_["variables"].syntaxOrange,
|
|
2441
|
+
variable: themes_["variables"].syntaxOrange
|
|
2442
|
+
};
|
|
2443
|
+
var StyledToken = external_styled_components_default.a.span.withConfig({
|
|
2444
|
+
displayName: "CodeStyles__StyledToken",
|
|
2445
|
+
componentId: "sc-1eq4k68-3"
|
|
2446
|
+
})(["color:", ";cursor:", ";opacity:", ";font-style:", ";font-weight:", ";"], function (_ref) {
|
|
2447
|
+
var partType = _ref.partType;
|
|
2448
|
+
return TokenColors[partType];
|
|
2449
|
+
}, function (_ref2) {
|
|
2450
|
+
var partType = _ref2.partType;
|
|
2451
|
+
return partType === 'entity' ? 'help' : null;
|
|
2452
|
+
}, function (_ref3) {
|
|
2453
|
+
var partType = _ref3.partType;
|
|
2454
|
+
return partType === 'namespace' ? 0.7 : null;
|
|
2455
|
+
}, function (_ref4) {
|
|
2456
|
+
var partType = _ref4.partType;
|
|
2457
|
+
return partType === 'italic' ? 'italic' : null;
|
|
2458
|
+
}, function (_ref5) {
|
|
2459
|
+
var partType = _ref5.partType;
|
|
2460
|
+
return partType === 'important' || partType === 'bold' ? 'bold' : null;
|
|
2461
|
+
});
|
|
2462
|
+
|
|
2463
|
+
// CONCATENATED MODULE: ./src/Code/Code.tsx
|
|
2464
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2465
|
+
|
|
2466
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
2467
|
+
|
|
2468
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
2469
|
+
|
|
2470
|
+
|
|
2471
|
+
|
|
2472
|
+
|
|
2473
|
+
|
|
2474
|
+
|
|
2475
|
+
|
|
2476
|
+
// Prism requires special handling to work around issues related to global scope and
|
|
2477
|
+
// auto formatting. The import below points to an empty file which is replaced at build
|
|
2478
|
+
// time, see ./prism/build-isolated-prism.js for details.
|
|
2479
|
+
|
|
2480
|
+
// typed as 'prismjs'
|
|
2481
|
+
|
|
2482
|
+
|
|
2483
|
+
var supportedLanguages = ['bash', 'clike', 'css', 'html', 'json', 'javascript', 'js', 'jsx', 'typescript', 'ts', 'tsx', 'markup', 'mathml', 'svg', 'xml', 'yaml', 'yml'];
|
|
2484
|
+
|
|
2485
|
+
function tokenize(text, language) {
|
|
2486
|
+
if (false) {}
|
|
2487
|
+
|
|
2488
|
+
return prism_empty_default.a.tokenize(text, prism_empty_default.a.languages[language]);
|
|
2489
|
+
}
|
|
2490
|
+
|
|
2491
|
+
var propTypes = {
|
|
2492
|
+
elementRef: external_prop_types_default.a.oneOfType([external_prop_types_default.a.func, external_prop_types_default.a.object]),
|
|
2493
|
+
indentChars: external_prop_types_default.a.number,
|
|
2494
|
+
language: external_prop_types_default.a.oneOf(supportedLanguages),
|
|
2495
|
+
showIndentGuide: external_prop_types_default.a.bool,
|
|
2496
|
+
value: external_prop_types_default.a.string
|
|
2497
|
+
};
|
|
2498
|
+
|
|
2499
|
+
function Code(_ref) {
|
|
2500
|
+
var elementRef = _ref.elementRef,
|
|
2501
|
+
_ref$indentChars = _ref.indentChars,
|
|
2502
|
+
indentChars = _ref$indentChars === void 0 ? 4 : _ref$indentChars,
|
|
2503
|
+
_ref$language = _ref.language,
|
|
2504
|
+
language = _ref$language === void 0 ? 'javascript' : _ref$language,
|
|
2505
|
+
_ref$showIndentGuide = _ref.showIndentGuide,
|
|
2506
|
+
showIndentGuide = _ref$showIndentGuide === void 0 ? true : _ref$showIndentGuide,
|
|
2507
|
+
_ref$value = _ref.value,
|
|
2508
|
+
value = _ref$value === void 0 ? '' : _ref$value,
|
|
2509
|
+
otherProps = _objectWithoutProperties(_ref, ["elementRef", "indentChars", "language", "showIndentGuide", "value"]);
|
|
2510
|
+
|
|
2511
|
+
// @docs-props-type CodePropsBase
|
|
2512
|
+
var indentBlock = repeat_default()(' ', indentChars);
|
|
2513
|
+
|
|
2514
|
+
var makeIndentGuide = function makeIndentGuide(spaces) {
|
|
2515
|
+
var level = Math.floor(spaces / indentChars);
|
|
2516
|
+
var rest = spaces % indentChars;
|
|
2517
|
+
var spans = times_default()(level, function (idx) {
|
|
2518
|
+
return /*#__PURE__*/external_react_default.a.createElement(StyledIndent, {
|
|
2519
|
+
key: idx.toString()
|
|
2520
|
+
}, indentBlock);
|
|
2521
|
+
});
|
|
2522
|
+
|
|
2523
|
+
if (rest) {
|
|
2524
|
+
spans.push(repeat_default()(' ', rest));
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
return spans;
|
|
2528
|
+
};
|
|
2529
|
+
|
|
2530
|
+
var tokens = tokenize(value, language);
|
|
2531
|
+
|
|
2532
|
+
var render = function render(tks) {
|
|
2533
|
+
return castArray_default()(tks).map(function (part, idx) {
|
|
2534
|
+
if (typeof part === 'string') {
|
|
2535
|
+
if (!showIndentGuide) {
|
|
2536
|
+
return part;
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
var lines = part.split('\n');
|
|
2540
|
+
|
|
2541
|
+
if (lines.length === 1) {
|
|
2542
|
+
return part;
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
return flatten_default()(lines.map(function (line, lineNo) {
|
|
2546
|
+
var res = lineNo === 0 ? [] : ['\n'];
|
|
2547
|
+
var indentMatch = line.match(/^(\s+)(.*)/);
|
|
2548
|
+
|
|
2549
|
+
if (!indentMatch) {
|
|
2550
|
+
res.push(line);
|
|
2551
|
+
} else {
|
|
2552
|
+
res.push( /*#__PURE__*/external_react_default.a.createElement("span", {
|
|
2553
|
+
key: "".concat(idx.toString(), ":").concat(lineNo.toString())
|
|
2554
|
+
}, makeIndentGuide(indentMatch[1].length)), indentMatch[2]);
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2557
|
+
return res;
|
|
2558
|
+
}));
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2561
|
+
var content = typeof part.content === 'string' ? part.content : render(part.content);
|
|
2562
|
+
return /*#__PURE__*/external_react_default.a.createElement(StyledToken, {
|
|
2563
|
+
partType: part.type,
|
|
2564
|
+
key: idx.toString()
|
|
2565
|
+
}, content);
|
|
2566
|
+
});
|
|
2567
|
+
};
|
|
2568
|
+
|
|
2569
|
+
var codeContent = render(tokens);
|
|
2570
|
+
return /*#__PURE__*/external_react_default.a.createElement(Styled, _extends({
|
|
2571
|
+
"data-test": "code",
|
|
2572
|
+
ref: elementRef,
|
|
2573
|
+
tabIndex: 0
|
|
2574
|
+
}, otherProps), /*#__PURE__*/external_react_default.a.createElement(StyledCode, {
|
|
2575
|
+
className: "language-".concat(language)
|
|
2576
|
+
}, codeContent));
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
Code.propTypes = propTypes;
|
|
2580
|
+
/* harmony default export */ var Code_Code = (Code);
|
|
2581
|
+
// CONCATENATED MODULE: ./src/Code/index.ts
|
|
2582
|
+
|
|
2583
|
+
|
|
2584
|
+
/***/ }),
|
|
2585
|
+
|
|
2586
|
+
/***/ 3:
|
|
2587
|
+
/***/ (function(module, exports) {
|
|
2588
|
+
|
|
2589
|
+
module.exports = require("styled-components");
|
|
2590
|
+
|
|
2591
|
+
/***/ }),
|
|
2592
|
+
|
|
2593
|
+
/***/ 62:
|
|
2594
|
+
/***/ (function(module, exports) {
|
|
2595
|
+
|
|
2596
|
+
module.exports = require("lodash/castArray");
|
|
2597
|
+
|
|
2598
|
+
/***/ }),
|
|
2599
|
+
|
|
2600
|
+
/***/ 78:
|
|
2601
|
+
/***/ (function(module, exports) {
|
|
2602
|
+
|
|
2603
|
+
module.exports = require("lodash/times");
|
|
2604
|
+
|
|
2605
|
+
/***/ }),
|
|
2606
|
+
|
|
2607
|
+
/***/ 79:
|
|
2608
|
+
/***/ (function(module, exports) {
|
|
2609
|
+
|
|
2610
|
+
module.exports = require("lodash/repeat");
|
|
2611
|
+
|
|
2612
|
+
/***/ }),
|
|
2613
|
+
|
|
2614
|
+
/***/ 88:
|
|
2615
|
+
/***/ (function(module, exports) {
|
|
2616
|
+
|
|
2617
|
+
module.exports = require("lodash/indexOf");
|
|
2618
|
+
|
|
2571
2619
|
/***/ })
|
|
2572
2620
|
|
|
2573
2621
|
/******/ });
|