@pingux/astro 2.59.0 → 2.60.0-alpha.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.
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { CodeViewProps } from '../../types/codeView';
3
+ declare const CodeView: React.ForwardRefExoticComponent<CodeViewProps & React.RefAttributes<HTMLDivElement>>;
4
+ export default CodeView;
@@ -25,7 +25,6 @@ var _focus = require("@react-aria/focus");
25
25
  var _interactions = require("@react-aria/interactions");
26
26
  var _utils = require("@react-aria/utils");
27
27
  var _prismReactRenderer = _interopRequireWildcard(require("prism-react-renderer"));
28
- var _propTypes = _interopRequireDefault(require("prop-types"));
29
28
  var _ = require("../..");
30
29
  var _hooks = require("../../hooks");
31
30
  var _CodeView = _interopRequireDefault(require("./CodeView.styles"));
@@ -61,9 +60,10 @@ var CodeView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
61
60
  var getLineNoWidth = function getLineNoWidth(tokens) {
62
61
  return tokens.length.toString().length * 12;
63
62
  };
63
+ var code = (children === null || children === void 0 ? void 0 : (0, _trim["default"])(children).call(children)) || '';
64
64
  var content = (0, _react2.jsx)(_prismReactRenderer["default"], (0, _extends2["default"])({}, _prismReactRenderer.defaultProps, {
65
65
  theme: _CodeView["default"].theme,
66
- code: (children === null || children === void 0 ? void 0 : (0, _trim["default"])(children).call(children)) || '',
66
+ code: code,
67
67
  language: language,
68
68
  Prism: customPrism || _prismReactRenderer.Prism
69
69
  }), function (_ref) {
@@ -75,7 +75,8 @@ var CodeView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
75
75
  return (0, _react2.jsx)(_.Box, {
76
76
  as: "pre",
77
77
  className: className,
78
- style: style
78
+ style: style,
79
+ tabIndex: "0"
79
80
  }, (0, _map["default"])(tokens).call(tokens, function (line, i) {
80
81
  return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
81
82
  isRow: true
@@ -100,9 +101,10 @@ var CodeView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
100
101
  return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
101
102
  ref: ref,
102
103
  variant: "codeView.wrapper",
103
- tabIndex: 0,
104
104
  className: classNames
105
- }, (0, _utils.mergeProps)(focusProps, hoverProps, others)), content);
105
+ }, (0, _utils.mergeProps)(focusProps, hoverProps, others), {
106
+ role: "none"
107
+ }), content);
106
108
  }
107
109
  return (0, _react2.jsx)(_.CopyText, {
108
110
  ref: ref,
@@ -117,23 +119,6 @@ var CodeView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
117
119
  }, others)
118
120
  }, content);
119
121
  });
120
- CodeView.propTypes = {
121
- /** Whether the CodeView displays line numbers. */
122
- hasLineNumbers: _propTypes["default"].bool,
123
- /** Whether the CodeView hides the copy button. */
124
- hasNoCopyButton: _propTypes["default"].bool,
125
- /**
126
- * Which programming language the CodeView should use for highlighting. A list of default languages is listed [here](https://github.com/FormidableLabs/prism-react-renderer/blob/master/packages/generate-prism-languages/index.ts#L9-L23).
127
- *
128
- *
129
- * Additional languages may be added, see
130
- * [CodeView with additional language](/?path=/docs/components-codeview--with-additional-language)
131
- * for more information.
132
- */
133
- language: _propTypes["default"].string,
134
- /* Prism object for using instead of Prism from "react-prism-renderer" */
135
- Prism: _propTypes["default"].shape({})
136
- };
137
122
  CodeView.defaultProps = {
138
123
  language: 'json',
139
124
  hasLineNumbers: false,
@@ -0,0 +1,9 @@
1
+ import { StoryFn } from '@storybook/react';
2
+ import 'prismjs/components/prism-powershell';
3
+ import { CodeViewProps } from '../../types/codeView';
4
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
5
+ export default _default;
6
+ export declare const Default: StoryFn<CodeViewProps>;
7
+ export declare const WithLineNumbers: StoryFn;
8
+ export declare const WithCustomSize: StoryFn;
9
+ export declare const WithAdditionalLanguage: StoryFn;
@@ -13,7 +13,7 @@ var _storybookAddonDesigns = require("storybook-addon-designs");
13
13
  require("prismjs/components/prism-powershell");
14
14
  var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
15
15
  var _index = require("../../index");
16
- var _figmaLinks = require("../../utils/designUtils/figmaLinks.ts");
16
+ var _figmaLinks = require("../../utils/designUtils/figmaLinks");
17
17
  var _CodeView = _interopRequireDefault(require("./CodeView.mdx"));
18
18
  var _react2 = require("@emotion/react");
19
19
  var code = "{\n \"_links\": {\n \"self\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad\"\n },\n \"password\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/password\"\n },\n \"password.set\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/password\"\n },\n \"password.reset\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/password\"\n },\n \"password.check\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/password\"\n },\n \"password.recover\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/password\"\n },\n \"account.sendVerificationCode\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad\"\n },\n \"linkedAccounts\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/linkedAccounts\"\n }\n },\n \"id\": \"5a5d4c0c-8383-4796-9cdc-16b5a22f45ad\",\n \"environment\": {\n \"id\": \"94e3268d-847d-47aa-a45e-1ef8dd8f4df0\"\n },\n \"account\": {\n \"canAuthenticate\": true,\n \"status\": \"OK\"\n },\n \"createdAt\": \"2021-09-03T15:01:43.555Z\",\n \"email\": \"allegraweldon@pingidentity.com\",\n \"enabled\": true,\n \"identityProvider\": {\n \"type\": \"PING_ONE\"\n },\n \"lifecycle\": {\n \"status\": \"ACCOUNT_OK\"\n },\n \"mfaEnabled\": false,\n \"population\": {\n \"id\": \"c1adbc29-f188-4ea6-a015-49bddd74bc84\"\n },\n \"updatedAt\": \"2021-09-03T15:01:43.555Z\",\n \"username\": \"allegraweldon@pingidentity.com\",\n \"verifyStatus\": \"NOT_INITIATED\"\n}";
@@ -66,6 +66,14 @@ Default.parameters = {
66
66
  design: {
67
67
  type: 'figma',
68
68
  url: _figmaLinks.FIGMA_LINKS.codeView["default"]
69
+ },
70
+ a11y: {
71
+ config: {
72
+ rules: [{
73
+ id: 'color-contrast',
74
+ enabled: false
75
+ }]
76
+ }
69
77
  }
70
78
  };
71
79
  var WithLineNumbers = function WithLineNumbers() {
@@ -77,6 +85,14 @@ exports.WithLineNumbers = WithLineNumbers;
77
85
  WithLineNumbers.parameters = {
78
86
  docs: {
79
87
  storyDescription: 'Please note that with adding line numbers, line wrapping does not work.'
88
+ },
89
+ a11y: {
90
+ config: {
91
+ rules: [{
92
+ id: 'color-contrast',
93
+ enabled: false
94
+ }]
95
+ }
80
96
  }
81
97
  };
82
98
  var WithCustomSize = function WithCustomSize() {
@@ -90,23 +106,38 @@ var WithCustomSize = function WithCustomSize() {
90
106
  }, "\nconst BadgeWithIcon = () => (\n <>\n <Badge label=\"Badge with Icon Button\" bg=\"navy\">\n <IconButton aria-label=\"Clear Badge with Icon Button\" variant=\"inverted\">\n <Icon icon={Clear} ml=\"xs\" size=\"14px\" title={{ name: 'Clear Icon' }} />\n </IconButton>\n </Badge>\n\n <div style={{ padding: '5px' }} />\n\n <Badge label=\"Badge with Icon Button\">\n <IconButton aria-label=\"Clear Badge with Icon Button\" variant=\"inverted\">\n <Icon icon={Earth} ml=\"xs\" size=\"14px\" title={{ name: 'Earth Icon' }} />\n </IconButton>\n </Badge>\n\n <div style={{ padding: '5px' }} />\n\n <Badge label=\"Badge with Icon\" bg=\"green\">\n <Icon icon={ContentCopy} ml=\"xs\" size=\"14px\" color=\"white\" title={{ name: 'Copy Icon' }} />\n </Badge>\n </>\n);\n ");
91
107
  };
92
108
  exports.WithCustomSize = WithCustomSize;
109
+ WithCustomSize.parameters = {
110
+ docs: {
111
+ storyDescription: 'All available languages are listed [here](https://github.com/PrismJS/prism/tree/master/components).'
112
+ },
113
+ a11y: {
114
+ config: {
115
+ rules: [{
116
+ id: 'color-contrast',
117
+ enabled: false
118
+ }]
119
+ }
120
+ }
121
+ };
93
122
  var WithAdditionalLanguage = function WithAdditionalLanguage() {
94
123
  var _context;
95
- /**
96
- * import { CodeView } from "@pingux/astro";
97
- * import Prism from 'prismjs';
98
- * import 'prismjs/components/prism-powershell';
99
- */
100
-
101
- var powershellCode = (0, _trim["default"])(_context = "\n Get-WinEvent -FilterHashtable @{\n LogName='Application'\n ProviderName='*defrag'\n }\n ").call(_context);
124
+ var cssCode = (0, _trim["default"])(_context = "\n body {\n margin: 0;\n font-family: Roboto, sans-serif;\n }\n \n h1 {\n color: red;\n margin-left: 40px;\n } \n ").call(_context);
102
125
  return (0, _react2.jsx)(_index.CodeView, {
103
- language: "powershell",
126
+ language: "css",
104
127
  Prism: _prismjs["default"]
105
- }, powershellCode);
128
+ }, cssCode);
106
129
  };
107
130
  exports.WithAdditionalLanguage = WithAdditionalLanguage;
108
131
  WithAdditionalLanguage.parameters = {
109
132
  docs: {
110
133
  storyDescription: 'All available languages are listed [here](https://github.com/PrismJS/prism/tree/master/components).'
134
+ },
135
+ a11y: {
136
+ config: {
137
+ rules: [{
138
+ id: 'color-contrast',
139
+ enabled: false
140
+ }]
141
+ }
111
142
  }
112
143
  };
@@ -0,0 +1,95 @@
1
+ declare const _default: {
2
+ theme: {
3
+ plain: {
4
+ color: string;
5
+ background: string;
6
+ lineHeight: number;
7
+ tabSize: number;
8
+ fontFamily: string;
9
+ };
10
+ styles: ({
11
+ types: string[];
12
+ style: {
13
+ color: string;
14
+ fontStyle?: undefined;
15
+ };
16
+ } | {
17
+ types: string[];
18
+ style: {
19
+ color: string;
20
+ fontStyle: string;
21
+ };
22
+ } | {
23
+ types: string[];
24
+ style: {
25
+ fontStyle: string;
26
+ color?: undefined;
27
+ };
28
+ })[];
29
+ };
30
+ wrapper: {
31
+ bg: string;
32
+ border: string;
33
+ borderColor: string;
34
+ width: number;
35
+ height: number;
36
+ my: number;
37
+ overflow: string;
38
+ alignItems: string;
39
+ '&.is-focused, &:focus': {
40
+ boxShadow: string;
41
+ outline: string;
42
+ };
43
+ pre: {
44
+ backgroundColor: string;
45
+ m: number;
46
+ p: number;
47
+ pr: number;
48
+ height: string;
49
+ width: string;
50
+ overflowX: string;
51
+ overflowY: string;
52
+ fontFamily: string;
53
+ fontSize: string;
54
+ '& .token-line': {
55
+ display: string;
56
+ alignItems: string;
57
+ '& .token': {
58
+ whiteSpace: string;
59
+ wordBreak: string;
60
+ };
61
+ };
62
+ };
63
+ '&.has-no-copy-button': {
64
+ pre: {
65
+ p: number;
66
+ };
67
+ };
68
+ '&.has-line-numbers': {
69
+ pre: {
70
+ p: string;
71
+ overflow: string;
72
+ '& .token-line:first-of-type *': {
73
+ pt: number;
74
+ };
75
+ '& .token-line': {
76
+ display: string;
77
+ '& .token': {
78
+ whiteSpace: string;
79
+ };
80
+ };
81
+ };
82
+ };
83
+ };
84
+ lineNo: {
85
+ display: string;
86
+ userSelect: string;
87
+ px: number;
88
+ m: string;
89
+ bg: string;
90
+ minWidth: number;
91
+ color: string;
92
+ lineHeight: string;
93
+ };
94
+ };
95
+ export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -8,7 +8,7 @@ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-s
8
8
  var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
9
9
  var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
10
10
  var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
11
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
11
+ var _Object$defineProperty2 = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
12
12
  var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
13
13
  var _Object$create = require("@babel/runtime-corejs3/core-js-stable/object/create");
14
14
  var _Object$getPrototypeOf = require("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of");
@@ -17,22 +17,22 @@ var _Promise = require("@babel/runtime-corejs3/core-js-stable/promise");
17
17
  var _reverseInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/reverse");
18
18
  var _sliceInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
19
19
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
20
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property"));
20
21
  var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
21
22
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
22
23
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
23
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
24
+ var _defineProperty3 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
24
25
  var _react = _interopRequireDefault(require("react"));
25
26
  var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
26
27
  var _ = require("../..");
27
28
  var _testWrapper = require("../../utils/testUtils/testWrapper");
28
29
  var _universalComponentTest = require("../../utils/testUtils/universalComponentTest");
29
30
  var _react2 = require("@emotion/react");
30
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = _Object$defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context7; _forEachInstanceProperty(_context7 = ["next", "throw", "return"]).call(_context7, function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = _Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return _reverseInstanceProperty(keys).call(keys), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { var _context8; if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context8 = this.tryEntries).call(_context8, resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
31
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = _Object$defineProperty2 || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty2(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context7; _forEachInstanceProperty(_context7 = ["next", "throw", "return"]).call(_context7, function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = _Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return _reverseInstanceProperty(keys).call(keys), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { var _context8; if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context8 = this.tryEntries).call(_context8, resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
31
32
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
32
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context6 = ownKeys(Object(source))).call(_context6, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
33
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) { (0, _defineProperty3["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context6 = ownKeys(Object(source))).call(_context6, function (key) { _Object$defineProperty2(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
33
34
  var testId = 'test-code-sample';
34
35
  var originalClipboard = _objectSpread({}, global.navigator.clipboard);
35
- var originalExecCommand = global.document.execCommand;
36
36
  var defaultProps = {
37
37
  'data-testid': testId
38
38
  };
@@ -45,14 +45,20 @@ beforeEach(function () {
45
45
  var mockClipboard = {
46
46
  writeText: jest.fn()
47
47
  };
48
- global.navigator.clipboard = mockClipboard;
48
+ (0, _defineProperty2["default"])(global.navigator, 'clipboard', {
49
+ writable: true,
50
+ value: mockClipboard
51
+ });
49
52
  global.document.execCommand = jest.fn();
50
- global.document.execCommand.mockReturnValue(true);
53
+ jest.spyOn(document, 'execCommand').mockReturnValue(true);
51
54
  });
52
55
  afterEach(function () {
53
56
  jest.resetAllMocks();
54
- global.navigator.clipboard = originalClipboard;
55
- global.document.execCommand = originalExecCommand;
57
+ (0, _defineProperty2["default"])(global.navigator, 'clipboard', {
58
+ writable: true,
59
+ value: originalClipboard
60
+ });
61
+ jest.spyOn(document, 'execCommand').mockReturnValue(true);
56
62
  });
57
63
 
58
64
  // Needs to be added to each components test file
@@ -81,6 +87,7 @@ test('copy button is focused and renders tooltip via keyboard', function () {
81
87
  var copyBtn = _testWrapper.screen.getByLabelText('copy to clipboard');
82
88
  expect(copyBtn).not.toHaveFocus();
83
89
  _userEvent["default"].tab();
90
+ _userEvent["default"].tab();
84
91
  expect(copyBtn).toHaveFocus();
85
92
  expect(copyBtn).toHaveClass('is-focused');
86
93
  expect(_testWrapper.screen.queryByRole('tooltip')).toBeInTheDocument();
@@ -162,4 +169,24 @@ test('after button click, the tooltip renders with the text "Copied!"', /*#__PUR
162
169
  return _context4.stop();
163
170
  }
164
171
  }, _callee4);
165
- })));
172
+ })));
173
+ test('renders CodeView component with default language', function () {
174
+ var children = ' ';
175
+ getComponent({
176
+ children: children
177
+ });
178
+ var codeViewElement = _testWrapper.screen.getByTestId(testId).querySelector('pre');
179
+ expect(codeViewElement).toBeInTheDocument();
180
+ expect(codeViewElement).toHaveClass('language-json');
181
+ });
182
+ test('renders CodeView component with highlighted code', function () {
183
+ var children = "\n export const Default = args => (\n <>\n <Text sx={{ fontWeight: 2 }}>JSON</Text>\n <CodeView {...args} />\n </>\n );\n ";
184
+ var language = 'jsx';
185
+ getComponent({
186
+ children: children,
187
+ language: language
188
+ });
189
+ var codeViewElement = _testWrapper.screen.getByTestId(testId).querySelector('pre');
190
+ expect(codeViewElement).toBeInTheDocument();
191
+ expect(codeViewElement).toHaveClass("language-".concat(language));
192
+ });
@@ -0,0 +1 @@
1
+ export { default } from './CodeView';
@@ -0,0 +1,16 @@
1
+ import type { PrismTheme } from 'prism-react-renderer';
2
+ import { Language, Prism as PrismRR } from 'prism-react-renderer';
3
+ import Prism from 'prismjs';
4
+ import { ThemeUICSSObject } from 'theme-ui';
5
+ import { HoverProps } from './shared';
6
+ export type PrismProps = typeof PrismRR & typeof Prism;
7
+ export type PrismThemeProps = PrismTheme;
8
+ export interface CodeViewProps extends HoverProps {
9
+ children?: string;
10
+ className?: string;
11
+ hasLineNumbers?: boolean;
12
+ hasNoCopyButton?: boolean;
13
+ language?: Language;
14
+ Prism?: PrismProps;
15
+ sx?: ThemeUICSSObject;
16
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+ _Object$defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
@@ -7,6 +7,8 @@ import { TooltipTriggerProps } from './tooltipTrigger';
7
7
  export interface TooltipWrapperProps {
8
8
  children?: React.ReactNode;
9
9
  isOpen?: boolean;
10
+ className?: string;
11
+ variant?: string;
10
12
  tooltip?: string;
11
13
  targetRef?: RefObject<HTMLDivElement | FocusableElement>;
12
14
  }
@@ -19,7 +19,6 @@ import { useFocusRing } from '@react-aria/focus';
19
19
  import { useHover } from '@react-aria/interactions';
20
20
  import { mergeProps } from '@react-aria/utils';
21
21
  import Highlight, { defaultProps, Prism } from 'prism-react-renderer';
22
- import PropTypes from 'prop-types';
23
22
  import { Box, CopyText } from '../..';
24
23
  import { useStatusClasses } from '../../hooks';
25
24
  import styles from './CodeView.styles';
@@ -50,9 +49,10 @@ var CodeView = /*#__PURE__*/forwardRef(function (props, ref) {
50
49
  var getLineNoWidth = function getLineNoWidth(tokens) {
51
50
  return tokens.length.toString().length * 12;
52
51
  };
52
+ var code = (children === null || children === void 0 ? void 0 : _trimInstanceProperty(children).call(children)) || '';
53
53
  var content = ___EmotionJSX(Highlight, _extends({}, defaultProps, {
54
54
  theme: styles.theme,
55
- code: (children === null || children === void 0 ? void 0 : _trimInstanceProperty(children).call(children)) || '',
55
+ code: code,
56
56
  language: language,
57
57
  Prism: customPrism || Prism
58
58
  }), function (_ref) {
@@ -64,7 +64,8 @@ var CodeView = /*#__PURE__*/forwardRef(function (props, ref) {
64
64
  return ___EmotionJSX(Box, {
65
65
  as: "pre",
66
66
  className: className,
67
- style: style
67
+ style: style,
68
+ tabIndex: "0"
68
69
  }, _mapInstanceProperty(tokens).call(tokens, function (line, i) {
69
70
  return ___EmotionJSX(Box, _extends({
70
71
  isRow: true
@@ -89,9 +90,10 @@ var CodeView = /*#__PURE__*/forwardRef(function (props, ref) {
89
90
  return ___EmotionJSX(Box, _extends({
90
91
  ref: ref,
91
92
  variant: "codeView.wrapper",
92
- tabIndex: 0,
93
93
  className: classNames
94
- }, mergeProps(focusProps, hoverProps, others)), content);
94
+ }, mergeProps(focusProps, hoverProps, others), {
95
+ role: "none"
96
+ }), content);
95
97
  }
96
98
  return ___EmotionJSX(CopyText, {
97
99
  ref: ref,
@@ -106,23 +108,6 @@ var CodeView = /*#__PURE__*/forwardRef(function (props, ref) {
106
108
  }, others)
107
109
  }, content);
108
110
  });
109
- CodeView.propTypes = {
110
- /** Whether the CodeView displays line numbers. */
111
- hasLineNumbers: PropTypes.bool,
112
- /** Whether the CodeView hides the copy button. */
113
- hasNoCopyButton: PropTypes.bool,
114
- /**
115
- * Which programming language the CodeView should use for highlighting. A list of default languages is listed [here](https://github.com/FormidableLabs/prism-react-renderer/blob/master/packages/generate-prism-languages/index.ts#L9-L23).
116
- *
117
- *
118
- * Additional languages may be added, see
119
- * [CodeView with additional language](/?path=/docs/components-codeview--with-additional-language)
120
- * for more information.
121
- */
122
- language: PropTypes.string,
123
- /* Prism object for using instead of Prism from "react-prism-renderer" */
124
- Prism: PropTypes.shape({})
125
- };
126
111
  CodeView.defaultProps = {
127
112
  language: 'json',
128
113
  hasLineNumbers: false,
@@ -5,7 +5,7 @@ import { withDesign } from 'storybook-addon-designs';
5
5
  import 'prismjs/components/prism-powershell';
6
6
  import DocsLayout from '../../../.storybook/storybookDocsLayout';
7
7
  import { CodeView } from '../../index';
8
- import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks.ts';
8
+ import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks';
9
9
  import CodeViewReadme from './CodeView.mdx';
10
10
  import { jsx as ___EmotionJSX } from "@emotion/react";
11
11
  var code = "{\n \"_links\": {\n \"self\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad\"\n },\n \"password\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/password\"\n },\n \"password.set\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/password\"\n },\n \"password.reset\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/password\"\n },\n \"password.check\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/password\"\n },\n \"password.recover\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/password\"\n },\n \"account.sendVerificationCode\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad\"\n },\n \"linkedAccounts\": {\n \"href\": \"https://api.pingone.com/v1/environments/94e3268d-847d-47aa-a45e-1ef8dd8f4df0/users/5a5d4c0c-8383-4796-9cdc-16b5a22f45ad/linkedAccounts\"\n }\n },\n \"id\": \"5a5d4c0c-8383-4796-9cdc-16b5a22f45ad\",\n \"environment\": {\n \"id\": \"94e3268d-847d-47aa-a45e-1ef8dd8f4df0\"\n },\n \"account\": {\n \"canAuthenticate\": true,\n \"status\": \"OK\"\n },\n \"createdAt\": \"2021-09-03T15:01:43.555Z\",\n \"email\": \"allegraweldon@pingidentity.com\",\n \"enabled\": true,\n \"identityProvider\": {\n \"type\": \"PING_ONE\"\n },\n \"lifecycle\": {\n \"status\": \"ACCOUNT_OK\"\n },\n \"mfaEnabled\": false,\n \"population\": {\n \"id\": \"c1adbc29-f188-4ea6-a015-49bddd74bc84\"\n },\n \"updatedAt\": \"2021-09-03T15:01:43.555Z\",\n \"username\": \"allegraweldon@pingidentity.com\",\n \"verifyStatus\": \"NOT_INITIATED\"\n}";
@@ -56,6 +56,14 @@ Default.parameters = {
56
56
  design: {
57
57
  type: 'figma',
58
58
  url: FIGMA_LINKS.codeView["default"]
59
+ },
60
+ a11y: {
61
+ config: {
62
+ rules: [{
63
+ id: 'color-contrast',
64
+ enabled: false
65
+ }]
66
+ }
59
67
  }
60
68
  };
61
69
  export var WithLineNumbers = function WithLineNumbers() {
@@ -66,6 +74,14 @@ export var WithLineNumbers = function WithLineNumbers() {
66
74
  WithLineNumbers.parameters = {
67
75
  docs: {
68
76
  storyDescription: 'Please note that with adding line numbers, line wrapping does not work.'
77
+ },
78
+ a11y: {
79
+ config: {
80
+ rules: [{
81
+ id: 'color-contrast',
82
+ enabled: false
83
+ }]
84
+ }
69
85
  }
70
86
  };
71
87
  export var WithCustomSize = function WithCustomSize() {
@@ -78,22 +94,37 @@ export var WithCustomSize = function WithCustomSize() {
78
94
  hasNoCopyButton: true
79
95
  }, "\nconst BadgeWithIcon = () => (\n <>\n <Badge label=\"Badge with Icon Button\" bg=\"navy\">\n <IconButton aria-label=\"Clear Badge with Icon Button\" variant=\"inverted\">\n <Icon icon={Clear} ml=\"xs\" size=\"14px\" title={{ name: 'Clear Icon' }} />\n </IconButton>\n </Badge>\n\n <div style={{ padding: '5px' }} />\n\n <Badge label=\"Badge with Icon Button\">\n <IconButton aria-label=\"Clear Badge with Icon Button\" variant=\"inverted\">\n <Icon icon={Earth} ml=\"xs\" size=\"14px\" title={{ name: 'Earth Icon' }} />\n </IconButton>\n </Badge>\n\n <div style={{ padding: '5px' }} />\n\n <Badge label=\"Badge with Icon\" bg=\"green\">\n <Icon icon={ContentCopy} ml=\"xs\" size=\"14px\" color=\"white\" title={{ name: 'Copy Icon' }} />\n </Badge>\n </>\n);\n ");
80
96
  };
97
+ WithCustomSize.parameters = {
98
+ docs: {
99
+ storyDescription: 'All available languages are listed [here](https://github.com/PrismJS/prism/tree/master/components).'
100
+ },
101
+ a11y: {
102
+ config: {
103
+ rules: [{
104
+ id: 'color-contrast',
105
+ enabled: false
106
+ }]
107
+ }
108
+ }
109
+ };
81
110
  export var WithAdditionalLanguage = function WithAdditionalLanguage() {
82
111
  var _context;
83
- /**
84
- * import { CodeView } from "@pingux/astro";
85
- * import Prism from 'prismjs';
86
- * import 'prismjs/components/prism-powershell';
87
- */
88
-
89
- var powershellCode = _trimInstanceProperty(_context = "\n Get-WinEvent -FilterHashtable @{\n LogName='Application'\n ProviderName='*defrag'\n }\n ").call(_context);
112
+ var cssCode = _trimInstanceProperty(_context = "\n body {\n margin: 0;\n font-family: Roboto, sans-serif;\n }\n \n h1 {\n color: red;\n margin-left: 40px;\n } \n ").call(_context);
90
113
  return ___EmotionJSX(CodeView, {
91
- language: "powershell",
114
+ language: "css",
92
115
  Prism: Prism
93
- }, powershellCode);
116
+ }, cssCode);
94
117
  };
95
118
  WithAdditionalLanguage.parameters = {
96
119
  docs: {
97
120
  storyDescription: 'All available languages are listed [here](https://github.com/PrismJS/prism/tree/master/components).'
121
+ },
122
+ a11y: {
123
+ config: {
124
+ rules: [{
125
+ id: 'color-contrast',
126
+ enabled: false
127
+ }]
128
+ }
98
129
  }
99
130
  };
@@ -5,7 +5,6 @@ import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-sta
5
5
  import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
6
  import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
7
7
  import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
8
- import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
9
8
  import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
10
9
  import _Object$create from "@babel/runtime-corejs3/core-js-stable/object/create";
11
10
  import _Object$getPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/get-prototype-of";
@@ -18,6 +17,7 @@ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerat
18
17
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
19
18
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
20
19
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = _Object$defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context7; _forEachInstanceProperty(_context7 = ["next", "throw", "return"]).call(_context7, function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = _Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return _reverseInstanceProperty(keys).call(keys), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { var _context8; if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context8 = this.tryEntries).call(_context8, resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
20
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
21
21
  import _trimInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/trim";
22
22
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
23
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context6 = ownKeys(Object(source))).call(_context6, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -29,7 +29,6 @@ import { universalComponentTests } from '../../utils/testUtils/universalComponen
29
29
  import { jsx as ___EmotionJSX } from "@emotion/react";
30
30
  var testId = 'test-code-sample';
31
31
  var originalClipboard = _objectSpread({}, global.navigator.clipboard);
32
- var originalExecCommand = global.document.execCommand;
33
32
  var defaultProps = {
34
33
  'data-testid': testId
35
34
  };
@@ -42,14 +41,20 @@ beforeEach(function () {
42
41
  var mockClipboard = {
43
42
  writeText: jest.fn()
44
43
  };
45
- global.navigator.clipboard = mockClipboard;
44
+ _Object$defineProperty(global.navigator, 'clipboard', {
45
+ writable: true,
46
+ value: mockClipboard
47
+ });
46
48
  global.document.execCommand = jest.fn();
47
- global.document.execCommand.mockReturnValue(true);
49
+ jest.spyOn(document, 'execCommand').mockReturnValue(true);
48
50
  });
49
51
  afterEach(function () {
50
52
  jest.resetAllMocks();
51
- global.navigator.clipboard = originalClipboard;
52
- global.document.execCommand = originalExecCommand;
53
+ _Object$defineProperty(global.navigator, 'clipboard', {
54
+ writable: true,
55
+ value: originalClipboard
56
+ });
57
+ jest.spyOn(document, 'execCommand').mockReturnValue(true);
53
58
  });
54
59
 
55
60
  // Needs to be added to each components test file
@@ -78,6 +83,7 @@ test('copy button is focused and renders tooltip via keyboard', function () {
78
83
  var copyBtn = screen.getByLabelText('copy to clipboard');
79
84
  expect(copyBtn).not.toHaveFocus();
80
85
  userEvent.tab();
86
+ userEvent.tab();
81
87
  expect(copyBtn).toHaveFocus();
82
88
  expect(copyBtn).toHaveClass('is-focused');
83
89
  expect(screen.queryByRole('tooltip')).toBeInTheDocument();
@@ -159,4 +165,24 @@ test('after button click, the tooltip renders with the text "Copied!"', /*#__PUR
159
165
  return _context4.stop();
160
166
  }
161
167
  }, _callee4);
162
- })));
168
+ })));
169
+ test('renders CodeView component with default language', function () {
170
+ var children = ' ';
171
+ getComponent({
172
+ children: children
173
+ });
174
+ var codeViewElement = screen.getByTestId(testId).querySelector('pre');
175
+ expect(codeViewElement).toBeInTheDocument();
176
+ expect(codeViewElement).toHaveClass('language-json');
177
+ });
178
+ test('renders CodeView component with highlighted code', function () {
179
+ var children = "\n export const Default = args => (\n <>\n <Text sx={{ fontWeight: 2 }}>JSON</Text>\n <CodeView {...args} />\n </>\n );\n ";
180
+ var language = 'jsx';
181
+ getComponent({
182
+ children: children,
183
+ language: language
184
+ });
185
+ var codeViewElement = screen.getByTestId(testId).querySelector('pre');
186
+ expect(codeViewElement).toBeInTheDocument();
187
+ expect(codeViewElement).toHaveClass("language-".concat(language));
188
+ });
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.59.0",
3
+ "version": "2.60.0-alpha.0",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",
@@ -56,7 +56,7 @@
56
56
  "@react-aria/dnd": "^3.5.0",
57
57
  "@react-aria/focus": "~3.8.0",
58
58
  "@react-aria/grid": "~3.4.1",
59
- "@react-aria/gridlist": "^3.7.4",
59
+ "@react-aria/gridlist": "~3.7.4",
60
60
  "@react-aria/i18n": "~3.6.0",
61
61
  "@react-aria/interactions": "~3.11.0",
62
62
  "@react-aria/label": "^3.1.0",