@pingux/astro 2.144.0-alpha.0 → 2.144.0-alpha.2

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.
@@ -42,7 +42,8 @@ var Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
42
42
  hasAutoFocus = props.hasAutoFocus,
43
43
  maxValue = props.maxValue,
44
44
  minValue = props.minValue,
45
- value = props.value;
45
+ value = props.value,
46
+ calendarWrapperProps = props.calendarWrapperProps;
46
47
  var _useLocale = (0, _i18n.useLocale)(),
47
48
  locale = _useLocale.locale;
48
49
  var calenderRef = (0, _hooks.useLocalOrForwardRef)(ref);
@@ -115,7 +116,7 @@ var Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
115
116
  fontWeight: 3,
116
117
  flex: 1
117
118
  }, title);
118
- return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({}, calendarProps, {
119
+ return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({}, calendarProps, calendarWrapperProps, {
119
120
  ref: calenderRef,
120
121
  variant: "calendar.calendarContainer",
121
122
  role: "group"
@@ -31,7 +31,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
31
31
  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
32
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
33
33
  var CodeEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
34
- var defaultValue = props.defaultValue,
34
+ var _props$defaultValue = props.defaultValue,
35
+ defaultValue = _props$defaultValue === void 0 ? '\n' : _props$defaultValue,
35
36
  language = props.language,
36
37
  onChange = props.onChange,
37
38
  onValidate = props.onValidate,
@@ -22,6 +22,7 @@ declare const _default: {
22
22
  };
23
23
  };
24
24
  export default _default;
25
+ export declare const Default: StoryFn<CodeEditorProps>;
25
26
  export declare const TypescriptEditor: StoryFn<CodeEditorProps>;
26
27
  export declare const JavascriptEditor: StoryFn<CodeEditorProps>;
27
28
  export declare const JsonEditor: StoryFn<CodeEditorProps>;
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
5
5
  _Object$defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports["default"] = exports.TypescriptEditor = exports.ReadOnly = exports.JsonEditor = exports.JavascriptEditor = void 0;
8
+ exports["default"] = exports.TypescriptEditor = exports.ReadOnly = exports.JsonEditor = exports.JavascriptEditor = exports.Default = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
  var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
@@ -41,6 +41,13 @@ exports["default"] = _default;
41
41
  var jsonCode = "{\n \"name\": \"Luke Skywalker\", \n \"height\": \"172\", \n \"mass\": \"77\", \n \"hair_color\": \"blond\", \n \"skin_color\": \"fair\", \n \"eye_color\": \"blue\", \n \"birth_year\": \"19BBY\", \n \"gender\": \"male\", \n \"homeworld\": \"https://swapi.dev/api/planets/1/\", \n \"films\": [\n \"https://swapi.dev/api/films/1/\", \n \"https://swapi.dev/api/films/2/\", \n \"https://swapi.dev/api/films/3/\", \n \"https://swapi.dev/api/films/6/\"\n ],\n \"starships\": [\n \"https://swapi.dev/api/starships/12/\", \n \"https://swapi.dev/api/starships/22/\"\n ]\n}";
42
42
  var tsCode = "const stringValue: string = 15;\n\nfunction addOne(integer: number) {\n return integer + 1;\n}\n\naddOne('I am a string');\n";
43
43
  var jsCode = "\nfunction factorial(n) {\n if (n === 0 || n === 1) {\n return 1;\n } else {\n return n * factorial(n - 1);\n }\n}\n\nconsole.log(factorial(5));\n\n(a) => {};\n";
44
+ var Default = function Default(args) {
45
+ return (0, _react2.jsx)(_index.CodeEditor, (0, _extends2["default"])({}, args, {
46
+ height: "200px",
47
+ language: "Default"
48
+ }));
49
+ };
50
+ exports.Default = Default;
44
51
  var TypescriptEditor = function TypescriptEditor(args) {
45
52
  return (0, _react2.jsx)(_index.CodeEditor, (0, _extends2["default"])({}, args, {
46
53
  defaultValue: tsCode,
@@ -58,6 +58,11 @@ describe('CodeEditor', function () {
58
58
  expect(_testWrapper.screen.getByTestId('mock-monaco-editor')).toBeInTheDocument();
59
59
  expect(_testWrapper.screen.getByText('Editor Language: javascript, Code:console.log("Hello, World!");')).toBeInTheDocument();
60
60
  });
61
+ it('renders with null/undefined', function () {
62
+ (0, _testWrapper.render)((0, _react2.jsx)(_index.CodeEditor, null));
63
+ expect(_testWrapper.screen.getByTestId('mock-monaco-editor')).toBeInTheDocument();
64
+ expect(_testWrapper.screen.getByText('Editor Language: undefined, Code:')).toBeInTheDocument();
65
+ });
61
66
  it('calls onChange when code changes', function () {
62
67
  var value = 'console.log("Hello, World!");';
63
68
  var mockOnChange = jest.fn();
@@ -82,7 +82,7 @@ var CodeView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
82
82
  console.warn("Prism language module for \"".concat(String(language), "\" not found."));
83
83
  }
84
84
  }, [language]);
85
- var content = (0, _react2.jsx)(_prismReactRenderer["default"], (0, _extends2["default"])({}, _prismReactRenderer.defaultProps, {
85
+ var content = code ? (0, _react2.jsx)(_prismReactRenderer["default"], (0, _extends2["default"])({}, _prismReactRenderer.defaultProps, {
86
86
  theme: codeViewTheme,
87
87
  code: code,
88
88
  language: language,
@@ -117,7 +117,7 @@ var CodeView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
117
117
  }));
118
118
  }));
119
119
  }));
120
- });
120
+ }) : '';
121
121
 
122
122
  /* istanbul ignore next */
123
123
  if (isOnyx) {
@@ -39,7 +39,7 @@ var defaultProps = {
39
39
  var textValue = "\nexport const Default = args => (\n <>\n <Text sx={{ fontWeight: 2 }}>JSON</Text>\n <CodeView {...args} />\n </>\n);\n";
40
40
  var getComponent = function getComponent() {
41
41
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
42
- return (0, _testWrapper.render)((0, _react2.jsx)(_.CodeView, (0, _extends2["default"])({}, defaultProps, props), textValue));
42
+ return (0, _testWrapper.render)((0, _react2.jsx)(_.CodeView, (0, _extends2["default"])({}, defaultProps, props), 'children' in props ? props.children : textValue));
43
43
  };
44
44
  beforeEach(function () {
45
45
  var mockClipboard = {
@@ -183,7 +183,7 @@ test('after button click, the tooltip renders with the text "Copied!"', /*#__PUR
183
183
  }, _callee4);
184
184
  })));
185
185
  test('renders CodeView component with default language', function () {
186
- var children = ' ';
186
+ var children = '{}';
187
187
  getComponent({
188
188
  children: children
189
189
  });
@@ -191,6 +191,17 @@ test('renders CodeView component with default language', function () {
191
191
  expect(codeViewElement).toBeInTheDocument();
192
192
  expect(codeViewElement).toHaveClass('language-json');
193
193
  });
194
+ test('renders CodeView component with null/undefined', function () {
195
+ var children = undefined;
196
+ getComponent({
197
+ children: children
198
+ });
199
+ _testWrapper.screen.getByRole('button', {
200
+ name: /copy to clipboard/i
201
+ });
202
+ var codeViewElement = _testWrapper.screen.getByTestId(testId).querySelector('pre');
203
+ expect(codeViewElement).not.toBeInTheDocument();
204
+ });
194
205
  test('renders CodeView component with highlighted code', function () {
195
206
  var children = "\n export const Default = args => (\n <>\n <Text sx={{ fontWeight: 2 }}>JSON</Text>\n <CodeView {...args} />\n </>\n );\n ";
196
207
  var language = 'jsx';
@@ -203,14 +214,15 @@ test('renders CodeView component with highlighted code', function () {
203
214
  expect(codeViewElement).toHaveClass("language-".concat(language));
204
215
  });
205
216
  test('isOnyx prop renders CodeView component with next-gen theme', function () {
206
- var children = ' ';
217
+ var children = '{}';
207
218
  getComponent({
208
219
  children: children,
209
220
  isOnyx: true,
210
221
  language: 'json'
211
222
  });
212
- var codeViewElement = _testWrapper.screen.getByTestId(testId);
213
- expect(codeViewElement).toHaveTextContent('JSON');
223
+ var codeViewElement = _testWrapper.screen.getByTestId(testId).querySelector('pre');
224
+ expect(codeViewElement).toBeInTheDocument();
225
+ expect(codeViewElement).toHaveClass('language-json');
214
226
  });
215
227
  test('if textToCopy is provided it\'s copied to clipboard instead of children text data', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
216
228
  var textToCopy, button;
@@ -34,6 +34,7 @@ var TooltipWrapper = function TooltipWrapper(_ref) {
34
34
  }, others), children, (0, _react2.jsx)(_index.Tooltip, null, tooltip));
35
35
  };
36
36
  var CopyText = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
37
+ var _props, _props2;
37
38
  var children = props.children,
38
39
  textToCopy = props.textToCopy,
39
40
  tooltipText = props.tooltipText,
@@ -42,7 +43,7 @@ var CopyText = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
42
43
  wrapperProps = props.wrapperProps,
43
44
  iconButtonProps = props.iconButtonProps,
44
45
  others = (0, _objectWithoutProperties2["default"])(props, _excluded2);
45
- var value = textToCopy || (mode === 'link' ? children.props.href : children.props.children);
46
+ var value = textToCopy || (mode === 'link' ? children === null || children === void 0 || (_props = children.props) === null || _props === void 0 ? void 0 : _props.href : (_props2 = children.props) === null || _props2 === void 0 ? void 0 : _props2.children);
46
47
  var _useState = (0, _react.useState)(false),
47
48
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
48
49
  isCopied = _useState2[0],
@@ -125,7 +126,8 @@ var CopyText = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
125
126
  return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
126
127
  ref: ref,
127
128
  isRow: true,
128
- variant: "copyText.copy"
129
+ variant: "copyText.copy",
130
+ justifyContent: content ? 'start' : 'end'
129
131
  }, wrapperProps, others), content, (0, _react2.jsx)(TooltipWrapper, (0, _extends2["default"])({
130
132
  isOpen: isTooltipOpen,
131
133
  tooltip: tooltip
@@ -39,7 +39,7 @@ var _index = require("../../index");
39
39
  var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
40
40
  var _DateSegment = _interopRequireDefault(require("./DateSegment"));
41
41
  var _react2 = require("@emotion/react");
42
- var _excluded = ["buttonProps", "className", "fieldProps", "groupProps", "groupRef", "hasFormatHelpText", "helperText", "isDisabled", "isOpen", "isReadOnly", "isRequired", "status", "datePickerState", "minValue", "maxValue", "unavailableRanges"],
42
+ var _excluded = ["buttonProps", "className", "fieldProps", "groupProps", "groupRef", "hasFormatHelpText", "helperText", "isDisabled", "isOpen", "isReadOnly", "isRequired", "status", "datePickerState", "minValue", "maxValue", "unavailableRanges", "fieldControlProps"],
43
43
  _excluded2 = ["defaultValue"];
44
44
  /**
45
45
  * DateFields allow users to enter and edit date using a keyboard.
@@ -71,6 +71,7 @@ var DateField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
71
71
  minValue = props.minValue,
72
72
  maxValue = props.maxValue,
73
73
  unavailableRanges = props.unavailableRanges,
74
+ fieldControlProps = props.fieldControlProps,
74
75
  other = (0, _objectWithoutProperties2["default"])(props, _excluded);
75
76
  var _useState = (0, _react.useState)(''),
76
77
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
@@ -234,7 +235,7 @@ var DateField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
234
235
  })))), (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
235
236
  isRow: true,
236
237
  variant: "forms.datePicker.inputField"
237
- }, dateFieldProps, {
238
+ }, dateFieldProps, fieldControlProps, {
238
239
  ref: fieldRef,
239
240
  className: classNames
240
241
  }), (0, _react2.jsx)(_reactAria.FocusScope, null, (0, _map["default"])(_context3 = isLocalEnUS ? enUSSegments : segments).call(_context3, function (segment, index) {
@@ -320,7 +321,9 @@ DateField.propTypes = {
320
321
  /** The ranges of unavailable dates passed */
321
322
  unavailableRanges: _propTypes["default"].arrayOf(_propTypes["default"].arrayOf(_propTypes["default"].string)),
322
323
  /** Props object that is spread directly into the input wrapper element. */
323
- wrapperProps: _propTypes["default"].shape({})
324
+ wrapperProps: _propTypes["default"].shape({}),
325
+ /** Props object that spread into date segment wrapper element. */
326
+ fieldControlProps: _propTypes["default"].shape({})
324
327
  };
325
328
  DateField.defaultProps = {
326
329
  hasAutoFocus: false,
@@ -51,7 +51,9 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
51
51
  minValue = props.minValue,
52
52
  status = props.status,
53
53
  value = props.value,
54
- unavailableRanges = props.unavailableRanges;
54
+ unavailableRanges = props.unavailableRanges,
55
+ fieldControlProps = props.fieldControlProps,
56
+ calendarWrapperProps = props.calendarWrapperProps;
55
57
  var groupRef = (0, _react.useRef)();
56
58
  var popoverRef = (0, _react.useRef)();
57
59
 
@@ -107,12 +109,15 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
107
109
  autoFocus: true,
108
110
  contain: true,
109
111
  restoreFocus: true
110
- }, (0, _react2.jsx)(_index.Calendar, calendarProps)));
112
+ }, (0, _react2.jsx)(_index.Calendar, (0, _extends2["default"])({}, calendarProps, {
113
+ calendarWrapperProps: calendarWrapperProps
114
+ }))));
111
115
  return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_DateField["default"], (0, _extends2["default"])({}, (0, _pendoID.getPendoID)('DatePicker'), props, {
112
116
  ref: ref,
113
117
  buttonProps: buttonProps,
114
118
  fieldProps: fieldProps,
115
119
  groupProps: (0, _object.omit)(groupProps, 'data-pendo-id'),
120
+ fieldControlProps: fieldControlProps,
116
121
  groupRef: groupRef,
117
122
  helperText: helperText,
118
123
  labelProps: labelProps,
@@ -177,7 +182,11 @@ DatePicker.propTypes = {
177
182
  /** Determines the textarea status indicator and helper text styling. */
178
183
  status: _propTypes["default"].oneOf((0, _values["default"])(_statuses["default"])),
179
184
  /** The ranges of unavailable dates passed */
180
- unavailableRanges: _propTypes["default"].arrayOf(_propTypes["default"].arrayOf(_propTypes["default"].string))
185
+ unavailableRanges: _propTypes["default"].arrayOf(_propTypes["default"].arrayOf(_propTypes["default"].string)),
186
+ /** Props object that spread into date segment wrapper element. */
187
+ fieldControlProps: _propTypes["default"].shape({}),
188
+ /** Props object that spread into calendar element. */
189
+ calendarWrapperProps: _propTypes["default"].shape({})
181
190
  };
182
191
  _DateField["default"].defaultProps = {
183
192
  isDisabled: false,
@@ -14,7 +14,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
14
14
  _Object$defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- exports["default"] = exports.UnavailableDates = exports.Required = exports.ReadOnly = exports.MinimumDate = exports.MaximumDate = exports.FormatHelperText = exports.Error = exports.Disabled = exports.DefaultValue = exports.DefaultOpen = exports.Default = exports.Controlled = void 0;
17
+ exports["default"] = exports.UnavailableDates = exports.Required = exports.ReadOnly = exports.MinimumDate = exports.MaximumDate = exports.FormatHelperText = exports.Error = exports.Disabled = exports.DefaultValue = exports.DefaultOpen = exports.Default = exports.CustomWidth = exports.Controlled = void 0;
18
18
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
19
19
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
20
20
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
@@ -276,4 +276,23 @@ Error.parameters = {
276
276
  type: 'figma',
277
277
  url: _figmaLinks.FIGMA_LINKS.datePicker.error
278
278
  }
279
- };
279
+ };
280
+ var CustomWidth = function CustomWidth(args) {
281
+ return (0, _react2.jsx)(_DatePicker["default"], (0, _extends2["default"])({}, args, {
282
+ fieldControlProps: {
283
+ sx: {
284
+ width: '500px'
285
+ }
286
+ },
287
+ calendarWrapperProps: {
288
+ sx: {
289
+ maxWidth: '500px',
290
+ width: '400px',
291
+ '& tr': {
292
+ gap: '20px'
293
+ }
294
+ }
295
+ }
296
+ }));
297
+ };
298
+ exports.CustomWidth = CustomWidth;
@@ -63,6 +63,8 @@ export interface CalendarProps extends Omit<CalendarBaseProps, 'onChange'> {
63
63
  value?: DateValue | string;
64
64
  /** Handler that is called when the value changes. */
65
65
  onChange?: (value: MappedDateValue<DateValue>) => void;
66
+ /** Props object that spread into calendar element. */
67
+ calendarWrapperProps?: BoxProps;
66
68
  }
67
69
  export interface RangeCalendarProps extends Omit<CalendarBaseProps, 'onChange'> {
68
70
  /** Prop to provide a custom default date (uncontrolled) */
@@ -31,7 +31,8 @@ var Calendar = /*#__PURE__*/forwardRef(function (props, ref) {
31
31
  hasAutoFocus = props.hasAutoFocus,
32
32
  maxValue = props.maxValue,
33
33
  minValue = props.minValue,
34
- value = props.value;
34
+ value = props.value,
35
+ calendarWrapperProps = props.calendarWrapperProps;
35
36
  var _useLocale = useLocale(),
36
37
  locale = _useLocale.locale;
37
38
  var calenderRef = useLocalOrForwardRef(ref);
@@ -104,7 +105,7 @@ var Calendar = /*#__PURE__*/forwardRef(function (props, ref) {
104
105
  fontWeight: 3,
105
106
  flex: 1
106
107
  }, title);
107
- return ___EmotionJSX(Box, _extends({}, calendarProps, {
108
+ return ___EmotionJSX(Box, _extends({}, calendarProps, calendarWrapperProps, {
108
109
  ref: calenderRef,
109
110
  variant: "calendar.calendarContainer",
110
111
  role: "group"
@@ -20,7 +20,8 @@ import { Box, CopyText, Text } from '../../index';
20
20
  import languageMapping from '../../utils/devUtils/constants/languageMapping';
21
21
  import { jsx as ___EmotionJSX } from "@emotion/react";
22
22
  var CodeEditor = /*#__PURE__*/forwardRef(function (props, ref) {
23
- var defaultValue = props.defaultValue,
23
+ var _props$defaultValue = props.defaultValue,
24
+ defaultValue = _props$defaultValue === void 0 ? '\n' : _props$defaultValue,
24
25
  language = props.language,
25
26
  onChange = props.onChange,
26
27
  onValidate = props.onValidate,
@@ -32,6 +32,12 @@ export default {
32
32
  var jsonCode = "{\n \"name\": \"Luke Skywalker\", \n \"height\": \"172\", \n \"mass\": \"77\", \n \"hair_color\": \"blond\", \n \"skin_color\": \"fair\", \n \"eye_color\": \"blue\", \n \"birth_year\": \"19BBY\", \n \"gender\": \"male\", \n \"homeworld\": \"https://swapi.dev/api/planets/1/\", \n \"films\": [\n \"https://swapi.dev/api/films/1/\", \n \"https://swapi.dev/api/films/2/\", \n \"https://swapi.dev/api/films/3/\", \n \"https://swapi.dev/api/films/6/\"\n ],\n \"starships\": [\n \"https://swapi.dev/api/starships/12/\", \n \"https://swapi.dev/api/starships/22/\"\n ]\n}";
33
33
  var tsCode = "const stringValue: string = 15;\n\nfunction addOne(integer: number) {\n return integer + 1;\n}\n\naddOne('I am a string');\n";
34
34
  var jsCode = "\nfunction factorial(n) {\n if (n === 0 || n === 1) {\n return 1;\n } else {\n return n * factorial(n - 1);\n }\n}\n\nconsole.log(factorial(5));\n\n(a) => {};\n";
35
+ export var Default = function Default(args) {
36
+ return ___EmotionJSX(CodeEditor, _extends({}, args, {
37
+ height: "200px",
38
+ language: "Default"
39
+ }));
40
+ };
35
41
  export var TypescriptEditor = function TypescriptEditor(args) {
36
42
  return ___EmotionJSX(CodeEditor, _extends({}, args, {
37
43
  defaultValue: tsCode,
@@ -55,6 +55,11 @@ describe('CodeEditor', function () {
55
55
  expect(screen.getByTestId('mock-monaco-editor')).toBeInTheDocument();
56
56
  expect(screen.getByText('Editor Language: javascript, Code:console.log("Hello, World!");')).toBeInTheDocument();
57
57
  });
58
+ it('renders with null/undefined', function () {
59
+ render(___EmotionJSX(CodeEditor, null));
60
+ expect(screen.getByTestId('mock-monaco-editor')).toBeInTheDocument();
61
+ expect(screen.getByText('Editor Language: undefined, Code:')).toBeInTheDocument();
62
+ });
58
63
  it('calls onChange when code changes', function () {
59
64
  var value = 'console.log("Hello, World!");';
60
65
  var mockOnChange = jest.fn();
@@ -72,7 +72,7 @@ var CodeView = /*#__PURE__*/forwardRef(function (props, ref) {
72
72
  console.warn("Prism language module for \"".concat(String(language), "\" not found."));
73
73
  }
74
74
  }, [language]);
75
- var content = ___EmotionJSX(Highlight, _extends({}, defaultProps, {
75
+ var content = code ? ___EmotionJSX(Highlight, _extends({}, defaultProps, {
76
76
  theme: codeViewTheme,
77
77
  code: code,
78
78
  language: language,
@@ -107,7 +107,7 @@ var CodeView = /*#__PURE__*/forwardRef(function (props, ref) {
107
107
  }));
108
108
  }));
109
109
  }));
110
- });
110
+ }) : '';
111
111
 
112
112
  /* istanbul ignore next */
113
113
  if (isOnyx) {
@@ -35,7 +35,7 @@ var defaultProps = {
35
35
  var textValue = "\nexport const Default = args => (\n <>\n <Text sx={{ fontWeight: 2 }}>JSON</Text>\n <CodeView {...args} />\n </>\n);\n";
36
36
  var getComponent = function getComponent() {
37
37
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
38
- return render(___EmotionJSX(CodeView, _extends({}, defaultProps, props), textValue));
38
+ return render(___EmotionJSX(CodeView, _extends({}, defaultProps, props), 'children' in props ? props.children : textValue));
39
39
  };
40
40
  beforeEach(function () {
41
41
  var mockClipboard = {
@@ -179,7 +179,7 @@ test('after button click, the tooltip renders with the text "Copied!"', /*#__PUR
179
179
  }, _callee4);
180
180
  })));
181
181
  test('renders CodeView component with default language', function () {
182
- var children = ' ';
182
+ var children = '{}';
183
183
  getComponent({
184
184
  children: children
185
185
  });
@@ -187,6 +187,17 @@ test('renders CodeView component with default language', function () {
187
187
  expect(codeViewElement).toBeInTheDocument();
188
188
  expect(codeViewElement).toHaveClass('language-json');
189
189
  });
190
+ test('renders CodeView component with null/undefined', function () {
191
+ var children = undefined;
192
+ getComponent({
193
+ children: children
194
+ });
195
+ screen.getByRole('button', {
196
+ name: /copy to clipboard/i
197
+ });
198
+ var codeViewElement = screen.getByTestId(testId).querySelector('pre');
199
+ expect(codeViewElement).not.toBeInTheDocument();
200
+ });
190
201
  test('renders CodeView component with highlighted code', function () {
191
202
  var children = "\n export const Default = args => (\n <>\n <Text sx={{ fontWeight: 2 }}>JSON</Text>\n <CodeView {...args} />\n </>\n );\n ";
192
203
  var language = 'jsx';
@@ -199,14 +210,15 @@ test('renders CodeView component with highlighted code', function () {
199
210
  expect(codeViewElement).toHaveClass("language-".concat(language));
200
211
  });
201
212
  test('isOnyx prop renders CodeView component with next-gen theme', function () {
202
- var children = ' ';
213
+ var children = '{}';
203
214
  getComponent({
204
215
  children: children,
205
216
  isOnyx: true,
206
217
  language: 'json'
207
218
  });
208
- var codeViewElement = screen.getByTestId(testId);
209
- expect(codeViewElement).toHaveTextContent('JSON');
219
+ var codeViewElement = screen.getByTestId(testId).querySelector('pre');
220
+ expect(codeViewElement).toBeInTheDocument();
221
+ expect(codeViewElement).toHaveClass('language-json');
210
222
  });
211
223
  test('if textToCopy is provided it\'s copied to clipboard instead of children text data', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
212
224
  var textToCopy, button;
@@ -21,6 +21,7 @@ var TooltipWrapper = function TooltipWrapper(_ref) {
21
21
  }, others), children, ___EmotionJSX(Tooltip, null, tooltip));
22
22
  };
23
23
  var CopyText = /*#__PURE__*/forwardRef(function (props, ref) {
24
+ var _props, _props2;
24
25
  var children = props.children,
25
26
  textToCopy = props.textToCopy,
26
27
  tooltipText = props.tooltipText,
@@ -29,7 +30,7 @@ var CopyText = /*#__PURE__*/forwardRef(function (props, ref) {
29
30
  wrapperProps = props.wrapperProps,
30
31
  iconButtonProps = props.iconButtonProps,
31
32
  others = _objectWithoutProperties(props, _excluded2);
32
- var value = textToCopy || (mode === 'link' ? children.props.href : children.props.children);
33
+ var value = textToCopy || (mode === 'link' ? children === null || children === void 0 || (_props = children.props) === null || _props === void 0 ? void 0 : _props.href : (_props2 = children.props) === null || _props2 === void 0 ? void 0 : _props2.children);
33
34
  var _useState = useState(false),
34
35
  _useState2 = _slicedToArray(_useState, 2),
35
36
  isCopied = _useState2[0],
@@ -112,7 +113,8 @@ var CopyText = /*#__PURE__*/forwardRef(function (props, ref) {
112
113
  return ___EmotionJSX(Box, _extends({
113
114
  ref: ref,
114
115
  isRow: true,
115
- variant: "copyText.copy"
116
+ variant: "copyText.copy",
117
+ justifyContent: content ? 'start' : 'end'
116
118
  }, wrapperProps, others), content, ___EmotionJSX(TooltipWrapper, _extends({
117
119
  isOpen: isTooltipOpen,
118
120
  tooltip: tooltip
@@ -9,7 +9,7 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
9
9
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
10
10
  import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
11
11
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
12
- var _excluded = ["buttonProps", "className", "fieldProps", "groupProps", "groupRef", "hasFormatHelpText", "helperText", "isDisabled", "isOpen", "isReadOnly", "isRequired", "status", "datePickerState", "minValue", "maxValue", "unavailableRanges"],
12
+ var _excluded = ["buttonProps", "className", "fieldProps", "groupProps", "groupRef", "hasFormatHelpText", "helperText", "isDisabled", "isOpen", "isReadOnly", "isRequired", "status", "datePickerState", "minValue", "maxValue", "unavailableRanges", "fieldControlProps"],
13
13
  _excluded2 = ["defaultValue"];
14
14
  import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
15
15
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
@@ -60,6 +60,7 @@ var DateField = /*#__PURE__*/forwardRef(function (props, ref) {
60
60
  minValue = props.minValue,
61
61
  maxValue = props.maxValue,
62
62
  unavailableRanges = props.unavailableRanges,
63
+ fieldControlProps = props.fieldControlProps,
63
64
  other = _objectWithoutProperties(props, _excluded);
64
65
  var _useState = useState(''),
65
66
  _useState2 = _slicedToArray(_useState, 2),
@@ -223,7 +224,7 @@ var DateField = /*#__PURE__*/forwardRef(function (props, ref) {
223
224
  })))), ___EmotionJSX(Box, _extends({
224
225
  isRow: true,
225
226
  variant: "forms.datePicker.inputField"
226
- }, dateFieldProps, {
227
+ }, dateFieldProps, fieldControlProps, {
227
228
  ref: fieldRef,
228
229
  className: classNames
229
230
  }), ___EmotionJSX(FocusScope, null, _mapInstanceProperty(_context3 = isLocalEnUS ? enUSSegments : segments).call(_context3, function (segment, index) {
@@ -309,7 +310,9 @@ DateField.propTypes = {
309
310
  /** The ranges of unavailable dates passed */
310
311
  unavailableRanges: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)),
311
312
  /** Props object that is spread directly into the input wrapper element. */
312
- wrapperProps: PropTypes.shape({})
313
+ wrapperProps: PropTypes.shape({}),
314
+ /** Props object that spread into date segment wrapper element. */
315
+ fieldControlProps: PropTypes.shape({})
313
316
  };
314
317
  DateField.defaultProps = {
315
318
  hasAutoFocus: false,
@@ -42,7 +42,9 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
42
42
  minValue = props.minValue,
43
43
  status = props.status,
44
44
  value = props.value,
45
- unavailableRanges = props.unavailableRanges;
45
+ unavailableRanges = props.unavailableRanges,
46
+ fieldControlProps = props.fieldControlProps,
47
+ calendarWrapperProps = props.calendarWrapperProps;
46
48
  var groupRef = useRef();
47
49
  var popoverRef = useRef();
48
50
 
@@ -98,12 +100,15 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
98
100
  autoFocus: true,
99
101
  contain: true,
100
102
  restoreFocus: true
101
- }, ___EmotionJSX(Calendar, calendarProps)));
103
+ }, ___EmotionJSX(Calendar, _extends({}, calendarProps, {
104
+ calendarWrapperProps: calendarWrapperProps
105
+ }))));
102
106
  return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(DateField, _extends({}, getPendoID('DatePicker'), props, {
103
107
  ref: ref,
104
108
  buttonProps: buttonProps,
105
109
  fieldProps: fieldProps,
106
110
  groupProps: omit(groupProps, 'data-pendo-id'),
111
+ fieldControlProps: fieldControlProps,
107
112
  groupRef: groupRef,
108
113
  helperText: helperText,
109
114
  labelProps: labelProps,
@@ -168,7 +173,11 @@ DatePicker.propTypes = {
168
173
  /** Determines the textarea status indicator and helper text styling. */
169
174
  status: PropTypes.oneOf(_Object$values(statuses)),
170
175
  /** The ranges of unavailable dates passed */
171
- unavailableRanges: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string))
176
+ unavailableRanges: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)),
177
+ /** Props object that spread into date segment wrapper element. */
178
+ fieldControlProps: PropTypes.shape({}),
179
+ /** Props object that spread into calendar element. */
180
+ calendarWrapperProps: PropTypes.shape({})
172
181
  };
173
182
  DateField.defaultProps = {
174
183
  isDisabled: false,
@@ -252,4 +252,22 @@ Error.parameters = {
252
252
  type: 'figma',
253
253
  url: FIGMA_LINKS.datePicker.error
254
254
  }
255
+ };
256
+ export var CustomWidth = function CustomWidth(args) {
257
+ return ___EmotionJSX(DatePicker, _extends({}, args, {
258
+ fieldControlProps: {
259
+ sx: {
260
+ width: '500px'
261
+ }
262
+ },
263
+ calendarWrapperProps: {
264
+ sx: {
265
+ maxWidth: '500px',
266
+ width: '400px',
267
+ '& tr': {
268
+ gap: '20px'
269
+ }
270
+ }
271
+ }
272
+ }));
255
273
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.144.0-alpha.0",
3
+ "version": "2.144.0-alpha.2",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",