@pingux/astro 1.13.0-alpha.5 → 1.13.0-alpha.8

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.
@@ -114,14 +114,41 @@ var CopyText = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
114
114
  return undefined;
115
115
  }, [isCopied]);
116
116
  var copyToClipboard = (0, _useCopyToClipboard["default"])(value, setIsCopied);
117
- var content = mode === 'link' || mode === 'nonClickableContent' ? children : (0, _react2.jsx)(_index.Button, (0, _extends2["default"])({
118
- variant: "quiet",
119
- onPress: copyToClipboard,
120
- "aria-label": "copy-content",
121
- tabIndex: -1
122
- }, focusProps), children);
117
+
118
+ var onTextClick = function onTextClick() {
119
+ var selection = window.getSelection();
120
+
121
+ if (selection.toString() === '') {
122
+ copyToClipboard();
123
+ }
124
+ };
125
+ /* Used for text copying */
126
+
127
+
128
+ var contentRef = (0, _react.useRef)();
129
+
130
+ var _usePress = (0, _interactions.usePress)({
131
+ ref: contentRef,
132
+ onClick: onTextClick
133
+ }),
134
+ pressProps = _usePress.pressProps;
135
+
136
+ delete pressProps.onMouseDown;
137
+ delete pressProps.onPointerDown;
138
+ var content = mode === 'link' || mode === 'nonClickableContent' ? children : (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
139
+ ref: contentRef
140
+ }, (0, _utils.mergeProps)(focusProps, pressProps)), children);
123
141
  var tooltip = isCopied ? 'Copied!' : tooltipText;
124
142
  var isTooltipOpen = isFocusVisible || isHovered || isCopied;
143
+ var pressableRef = (0, _react.useRef)();
144
+
145
+ var _usePress2 = (0, _interactions.usePress)({
146
+ ref: pressableRef
147
+ }),
148
+ pressableProps = _usePress2.pressProps;
149
+
150
+ delete pressableProps.onMouseDown;
151
+ delete pressableProps.onPointerDown;
125
152
  var wrapperRef = (0, _react.useRef)();
126
153
 
127
154
  if (mode === 'nonClickableContent') {
@@ -153,12 +180,19 @@ var CopyText = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
153
180
 
154
181
  return (0, _react2.jsx)(TooltipWrapper, {
155
182
  isOpen: isTooltipOpen,
156
- tooltip: tooltip
157
- }, (0, _react2.jsx)(_interactions.Pressable, null, (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
183
+ tooltip: tooltip,
184
+ targetRef: pressableRef
185
+ }, (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
186
+ ref: pressableRef
187
+ }, (0, _utils.mergeProps)(hoverProps, pressableProps), {
188
+ sx: {
189
+ width: 'min-content'
190
+ }
191
+ }), (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
158
192
  ref: ref,
159
193
  isRow: true,
160
194
  variant: "boxes.copy"
161
- }, (0, _utils.mergeProps)(hoverProps, others)), content, (0, _react2.jsx)(_CopyButton["default"], (0, _extends2["default"])({
195
+ }, others), content, (0, _react2.jsx)(_CopyButton["default"], (0, _extends2["default"])({
162
196
  onPress: copyToClipboard
163
197
  }, focusProps)))));
164
198
  });
@@ -49,6 +49,7 @@ var testId = 'test-copy-text';
49
49
  var originalClipboard = _objectSpread({}, global.navigator.clipboard);
50
50
 
51
51
  var originalExecCommand = global.document.execCommand;
52
+ var originalGetSelection = window.getSelection;
52
53
 
53
54
  var defaultTest = function defaultTest() {
54
55
  var getComponent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -107,11 +108,15 @@ describe('Text mode', function () {
107
108
  global.navigator.clipboard = mockClipboard;
108
109
  global.document.execCommand = jest.fn();
109
110
  global.document.execCommand.mockReturnValue(true);
111
+ var mockGetSelection = jest.fn();
112
+ mockGetSelection.mockReturnValue('');
113
+ window.getSelection = mockGetSelection;
110
114
  });
111
115
  afterEach(function () {
112
116
  jest.resetAllMocks();
113
117
  global.navigator.clipboard = originalClipboard;
114
118
  global.document.execCommand = originalExecCommand;
119
+ window.getSelection = originalGetSelection;
115
120
  });
116
121
  test('click on text copies data to the clipboard', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
117
122
  var button;
@@ -433,10 +438,14 @@ describe('Link mode', function () {
433
438
  writeText: jest.fn()
434
439
  };
435
440
  global.navigator.clipboard = mockClipboard;
441
+ var mockGetSelection = jest.fn();
442
+ mockGetSelection.mockReturnValue('');
443
+ window.getSelection = mockGetSelection;
436
444
  });
437
445
  afterEach(function () {
438
446
  jest.resetAllMocks();
439
447
  global.navigator.clipboard = originalClipboard;
448
+ window.getSelection = originalGetSelection;
440
449
  });
441
450
  test('click on copy button copies data to the clipboard', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee16() {
442
451
  var button;
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
+
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+
11
+ exports["default"] = exports.Default = void 0;
12
+
13
+ var _react = _interopRequireDefault(require("react"));
14
+
15
+ var _CreateIcon = _interopRequireDefault(require("mdi-react/CreateIcon"));
16
+
17
+ var _index = require("../index");
18
+
19
+ var _react2 = require("@emotion/react");
20
+
21
+ var _default = {
22
+ title: 'Recipes/AttributeMappingReadOnlyField'
23
+ };
24
+ exports["default"] = _default;
25
+
26
+ var Default = function Default() {
27
+ var Row = function Row(props) {
28
+ var withChip = props.withChip,
29
+ withTooltip = props.withTooltip,
30
+ leftValue = props.leftValue,
31
+ rightValue = props.rightValue;
32
+ return (0, _react2.jsx)(_index.Box, {
33
+ isRow: true,
34
+ alignItems: "center",
35
+ mt: "10px"
36
+ }, (0, _react2.jsx)(_index.TextField, {
37
+ isReadOnly: true,
38
+ value: leftValue,
39
+ labelProps: {
40
+ mb: 0
41
+ },
42
+ controlProps: {
43
+ variant: 'input.small',
44
+ 'aria-label': "input ".concat(leftValue),
45
+ sx: {
46
+ width: '165px'
47
+ }
48
+ }
49
+ }), (0, _react2.jsx)(_index.Separator, {
50
+ sx: {
51
+ width: '21px',
52
+ ml: '2px',
53
+ mr: '2px'
54
+ }
55
+ }), (0, _react2.jsx)(_index.TextField, {
56
+ isReadOnly: true,
57
+ value: rightValue,
58
+ labelProps: {
59
+ mb: 0
60
+ },
61
+ controlProps: {
62
+ variant: 'input.small',
63
+ 'aria-label': "input ".concat(rightValue),
64
+ sx: {
65
+ width: '165px'
66
+ }
67
+ }
68
+ }), withChip && (0, _react2.jsx)(_index.Chip, {
69
+ label: "Required",
70
+ sx: {
71
+ width: '65px',
72
+ height: '22px',
73
+ alignSelf: 'center',
74
+ minWidth: 'fit-content',
75
+ border: '1px solid',
76
+ borderColor: 'neutral.80',
77
+ backgroundColor: 'white !important',
78
+ ml: 8,
79
+ '& span': {
80
+ fontSize: 'sm',
81
+ lineHeight: 1,
82
+ color: '#253746'
83
+ }
84
+ }
85
+ }), withTooltip && (0, _react2.jsx)(_index.Box, {
86
+ ml: "5px",
87
+ height: "15px",
88
+ width: "15px"
89
+ }, (0, _react2.jsx)(_index.HelpHint, {
90
+ tooltipProps: {
91
+ direction: 'bottom'
92
+ }
93
+ }, "Population set to default")));
94
+ };
95
+
96
+ return (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Box, {
97
+ isRow: true,
98
+ alignItems: "center",
99
+ mb: "15px"
100
+ }, (0, _react2.jsx)(_index.Text, {
101
+ sx: {
102
+ fontSize: 'lg',
103
+ lineHeight: '21px',
104
+ fontWeight: 3,
105
+ color: 'text.primary'
106
+ }
107
+ }, "Attribute Mapping"), (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.IconButton, {
108
+ ml: "5px",
109
+ variant: "inverted",
110
+ "aria-label": "edit header button"
111
+ }, (0, _react2.jsx)(_index.Icon, {
112
+ icon: _CreateIcon["default"],
113
+ size: 18
114
+ })))), (0, _react2.jsx)(_index.Box, {
115
+ backgroundColor: "accent.99",
116
+ width: "450px",
117
+ padding: "10px 10px 25px 10px"
118
+ }, (0, _react2.jsx)(_index.Box, {
119
+ isRow: true,
120
+ sx: {
121
+ width: '100%'
122
+ }
123
+ }, (0, _react2.jsx)(_index.Box, {
124
+ sx: {
125
+ width: 'calc(50% - 22px)'
126
+ }
127
+ }, (0, _react2.jsx)(_index.Text, {
128
+ sx: {
129
+ fontWeight: 3,
130
+ fontSize: 'md',
131
+ lineHeight: '18px',
132
+ mb: '5px'
133
+ }
134
+ }, "PingOne")), (0, _react2.jsx)(_index.Box, {
135
+ sx: {
136
+ width: 'calc(50% - 22px)'
137
+ }
138
+ }, (0, _react2.jsx)(_index.Text, {
139
+ sx: {
140
+ fontWeight: 3,
141
+ fontSize: 'md',
142
+ lineHeight: '18px',
143
+ mb: '5px'
144
+ }
145
+ }, "Google Suites"))), (0, _react2.jsx)(_index.Separator, null), (0, _react2.jsx)(Row, {
146
+ withChip: true,
147
+ leftValue: "UserId",
148
+ rightValue: "mdorey"
149
+ }), (0, _react2.jsx)(Row, {
150
+ leftValue: "givenName",
151
+ rightValue: "firstName"
152
+ }), (0, _react2.jsx)(Row, {
153
+ leftValue: "familyName",
154
+ rightValue: "lastName"
155
+ }), (0, _react2.jsx)(Row, {
156
+ withTooltip: true,
157
+ leftValue: "population",
158
+ rightValue: "population"
159
+ }), (0, _react2.jsx)(Row, {
160
+ leftValue: "password",
161
+ rightValue: "password"
162
+ })));
163
+ };
164
+
165
+ exports.Default = Default;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
+
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+
11
+ exports["default"] = exports.Spacing = void 0;
12
+
13
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
14
+
15
+ var _entries = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/entries"));
16
+
17
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
18
+
19
+ var _react = _interopRequireDefault(require("react"));
20
+
21
+ var _Text = _interopRequireDefault(require("../components/Text"));
22
+
23
+ var _spacing = _interopRequireDefault(require("./spacing"));
24
+
25
+ var _ = require("..");
26
+
27
+ var _react2 = require("@emotion/react");
28
+
29
+ var _default = {
30
+ title: 'Design/Spacing'
31
+ };
32
+ exports["default"] = _default;
33
+ var tableBodyStyles = {
34
+ border: 'unset'
35
+ };
36
+ var tableRowStyles = {
37
+ backgroundColor: 'transparent !important'
38
+ };
39
+
40
+ var Spacing = function Spacing() {
41
+ var _context;
42
+
43
+ return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_Text["default"], {
44
+ variant: "sectionTitle"
45
+ }, "Spacing"), (0, _react2.jsx)(_.Separator, {
46
+ mb: "sm"
47
+ }), (0, _react2.jsx)(_.Table, {
48
+ width: "75%"
49
+ }, (0, _react2.jsx)(_.TableHead, null, (0, _react2.jsx)(_.TableRow, {
50
+ sx: tableRowStyles,
51
+ key: "head"
52
+ }, (0, _react2.jsx)(_.TableCell, {
53
+ isHeading: true,
54
+ key: "name"
55
+ }, "Token"), (0, _react2.jsx)(_.TableCell, {
56
+ isHeading: true,
57
+ key: "value"
58
+ }, "Size"))), (0, _map["default"])(_context = (0, _entries["default"])(_spacing["default"])).call(_context, function (_ref) {
59
+ var _ref2 = (0, _slicedToArray2["default"])(_ref, 2),
60
+ key = _ref2[0],
61
+ value = _ref2[1];
62
+
63
+ return (0, _react2.jsx)(_.TableBody, {
64
+ sx: tableBodyStyles,
65
+ key: key
66
+ }, (0, _react2.jsx)(_.TableRow, {
67
+ sx: tableRowStyles
68
+ }, (0, _react2.jsx)(_.TableCell, {
69
+ bg: "white"
70
+ }, key), (0, _react2.jsx)(_.TableCell, {
71
+ bg: "white"
72
+ }, value, "px")));
73
+ })));
74
+ };
75
+
76
+ exports.Spacing = Spacing;
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
+
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+
11
+ exports["default"] = exports.TypographyTokens = void 0;
12
+
13
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
14
+
15
+ var _entries = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/entries"));
16
+
17
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
18
+
19
+ var _react = _interopRequireDefault(require("react"));
20
+
21
+ var _Text = _interopRequireDefault(require("../components/Text"));
22
+
23
+ var _ = require("..");
24
+
25
+ var _text = require("./text");
26
+
27
+ var _react2 = require("@emotion/react");
28
+
29
+ var _default = {
30
+ title: 'Design/Typography'
31
+ };
32
+ exports["default"] = _default;
33
+ var tableBodyStyles = {
34
+ border: 'unset'
35
+ };
36
+ var tableRowStyles = {
37
+ backgroundColor: 'transparent !important'
38
+ };
39
+
40
+ var TypographyTokens = function TypographyTokens() {
41
+ var _context, _context2;
42
+
43
+ return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_Text["default"], {
44
+ variant: "sectionTitle"
45
+ }, "Font Sizes"), (0, _react2.jsx)(_.Separator, {
46
+ mb: "sm"
47
+ }), (0, _react2.jsx)(_.Table, {
48
+ width: "75%"
49
+ }, (0, _react2.jsx)(_.TableHead, null, (0, _react2.jsx)(_.TableRow, {
50
+ key: "head"
51
+ }, (0, _react2.jsx)(_.TableCell, {
52
+ isHeading: true
53
+ }, "Token"), (0, _react2.jsx)(_.TableCell, {
54
+ isHeading: true
55
+ }, "Size"), (0, _react2.jsx)(_.TableCell, {
56
+ isHeading: true
57
+ }, "Example"))), (0, _map["default"])(_context = (0, _entries["default"])(_text.fontSizes)).call(_context, function (_ref) {
58
+ var _ref2 = (0, _slicedToArray2["default"])(_ref, 2),
59
+ key = _ref2[0],
60
+ value = _ref2[1];
61
+
62
+ return (0, _react2.jsx)(_.TableBody, {
63
+ sx: tableBodyStyles,
64
+ key: key
65
+ }, (0, _react2.jsx)(_.TableRow, {
66
+ sx: tableRowStyles
67
+ }, (0, _react2.jsx)(_.TableCell, null, (0, _react2.jsx)(_Text["default"], {
68
+ fontSize: value
69
+ }, key)), (0, _react2.jsx)(_.TableCell, null, (0, _react2.jsx)(_Text["default"], {
70
+ fontSize: value
71
+ }, value)), (0, _react2.jsx)(_.TableCell, null, (0, _react2.jsx)(_Text["default"], {
72
+ fontSize: value
73
+ }, "<Text fontSize={", key, "} />"))));
74
+ }))), (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_Text["default"], {
75
+ variant: "sectionTitle",
76
+ mt: "xx"
77
+ }, "Font Weights"), (0, _react2.jsx)(_.Separator, {
78
+ mb: "sm"
79
+ }), (0, _react2.jsx)(_.Table, {
80
+ width: "75%"
81
+ }, (0, _react2.jsx)(_.TableHead, null, (0, _react2.jsx)(_.TableRow, {
82
+ key: "head"
83
+ }, (0, _react2.jsx)(_.TableCell, {
84
+ isHeading: true
85
+ }, "Token"), (0, _react2.jsx)(_.TableCell, {
86
+ isHeading: true
87
+ }, "Size"), (0, _react2.jsx)(_.TableCell, {
88
+ isHeading: true
89
+ }, "Example"))), (0, _map["default"])(_context2 = (0, _entries["default"])(_text.fontWeights)).call(_context2, function (_ref3) {
90
+ var _ref4 = (0, _slicedToArray2["default"])(_ref3, 2),
91
+ key = _ref4[0],
92
+ value = _ref4[1];
93
+
94
+ return (0, _react2.jsx)(_.TableBody, {
95
+ sx: tableBodyStyles,
96
+ key: key
97
+ }, (0, _react2.jsx)(_.TableRow, {
98
+ sx: tableRowStyles
99
+ }, (0, _react2.jsx)(_.TableCell, null, (0, _react2.jsx)(_Text["default"], {
100
+ fontWeight: value
101
+ }, key)), (0, _react2.jsx)(_.TableCell, null, (0, _react2.jsx)(_Text["default"], {
102
+ fontWeight: value
103
+ }, value)), (0, _react2.jsx)(_.TableCell, null, (0, _react2.jsx)(_Text["default"], {
104
+ fontWeight: value
105
+ }, "<Text fontWeight={", key, "} />"))));
106
+ }))), (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_Text["default"], {
107
+ variant: "sectionTitle",
108
+ mt: "xx"
109
+ }, "Text Colors"), (0, _react2.jsx)(_.Separator, {
110
+ mb: "sm"
111
+ }), (0, _react2.jsx)(_.Table, {
112
+ width: "75%"
113
+ }, (0, _react2.jsx)(_.TableHead, null, (0, _react2.jsx)(_.TableRow, {
114
+ key: "head"
115
+ }, (0, _react2.jsx)(_.TableCell, {
116
+ isHeading: true
117
+ }, "Token"), (0, _react2.jsx)(_.TableCell, {
118
+ isHeading: true
119
+ }, "Color"), (0, _react2.jsx)(_.TableCell, {
120
+ isHeading: true
121
+ }, "Example"))), (0, _react2.jsx)(_.TableBody, {
122
+ sx: tableBodyStyles
123
+ }, (0, _react2.jsx)(_.TableRow, {
124
+ sx: tableRowStyles
125
+ }, (0, _react2.jsx)(_.TableCell, null, (0, _react2.jsx)(_.Box, {
126
+ isRow: true
127
+ }, (0, _react2.jsx)(_.Box, {
128
+ width: "30px",
129
+ height: "30px",
130
+ bg: "text.primary",
131
+ mr: "xs"
132
+ }), (0, _react2.jsx)(_Text["default"], {
133
+ alignSelf: "center"
134
+ }, "text.primary"))), (0, _react2.jsx)(_.TableCell, {
135
+ alignSelf: "center"
136
+ }, (0, _react2.jsx)(_Text["default"], null, "neutral.10")), (0, _react2.jsx)(_.TableCell, {
137
+ alignSelf: "center"
138
+ }, (0, _react2.jsx)(_Text["default"], {
139
+ color: "text.primary"
140
+ }, "<Text textColor={text.primary} />"))), (0, _react2.jsx)(_.TableRow, {
141
+ sx: tableRowStyles
142
+ }, (0, _react2.jsx)(_.TableCell, null, (0, _react2.jsx)(_.Box, {
143
+ isRow: true
144
+ }, (0, _react2.jsx)(_.Box, {
145
+ width: "30px",
146
+ height: "30px",
147
+ bg: "text.secondary",
148
+ mr: "xs"
149
+ }), (0, _react2.jsx)(_Text["default"], {
150
+ alignSelf: "center"
151
+ }, "text.secondary"))), (0, _react2.jsx)(_.TableCell, {
152
+ alignSelf: "center"
153
+ }, (0, _react2.jsx)(_Text["default"], null, "neutral.40")), (0, _react2.jsx)(_.TableCell, {
154
+ alignSelf: "center"
155
+ }, (0, _react2.jsx)(_Text["default"], {
156
+ color: "text.secondary"
157
+ }, "<Text color={text.secondary} />")))))));
158
+ };
159
+
160
+ exports.TypographyTokens = TypographyTokens;
@@ -172,12 +172,14 @@ var textFieldInContainerSlot = {
172
172
  var copy = {
173
173
  alignItems: 'center',
174
174
  width: 'max-content',
175
- cursor: 'pointer',
176
175
  '& .is-focused': {
177
176
  outline: '1px solid',
178
177
  outlineColor: 'active',
179
178
  outlineOffset: '4px',
180
179
  borderRadius: '4px'
180
+ },
181
+ '& span': {
182
+ cursor: 'text'
181
183
  }
182
184
  };
183
185
  var topShadowScrollbox = {
@@ -7,10 +7,10 @@ var _excluded = ["children", "tooltip"],
7
7
  import React, { forwardRef, useEffect, useRef, useState } from 'react';
8
8
  import PropTypes from 'prop-types';
9
9
  import { useFocusRing } from '@react-aria/focus';
10
- import { Pressable, useHover } from '@react-aria/interactions';
10
+ import { useHover, usePress } from '@react-aria/interactions';
11
11
  import { mergeProps } from '@react-aria/utils';
12
12
  import { announce } from '@react-aria/live-announcer';
13
- import { Box, Button, Tooltip, TooltipTrigger } from '../../index';
13
+ import { Box, Tooltip, TooltipTrigger } from '../../index';
14
14
  import CopyButton from './CopyButton';
15
15
  import useCopyToClipboard from '../../hooks/useCopyToClipboard';
16
16
  import { jsx as ___EmotionJSX } from "@emotion/react";
@@ -82,14 +82,41 @@ var CopyText = /*#__PURE__*/forwardRef(function (props, ref) {
82
82
  return undefined;
83
83
  }, [isCopied]);
84
84
  var copyToClipboard = useCopyToClipboard(value, setIsCopied);
85
- var content = mode === 'link' || mode === 'nonClickableContent' ? children : ___EmotionJSX(Button, _extends({
86
- variant: "quiet",
87
- onPress: copyToClipboard,
88
- "aria-label": "copy-content",
89
- tabIndex: -1
90
- }, focusProps), children);
85
+
86
+ var onTextClick = function onTextClick() {
87
+ var selection = window.getSelection();
88
+
89
+ if (selection.toString() === '') {
90
+ copyToClipboard();
91
+ }
92
+ };
93
+ /* Used for text copying */
94
+
95
+
96
+ var contentRef = useRef();
97
+
98
+ var _usePress = usePress({
99
+ ref: contentRef,
100
+ onClick: onTextClick
101
+ }),
102
+ pressProps = _usePress.pressProps;
103
+
104
+ delete pressProps.onMouseDown;
105
+ delete pressProps.onPointerDown;
106
+ var content = mode === 'link' || mode === 'nonClickableContent' ? children : ___EmotionJSX(Box, _extends({
107
+ ref: contentRef
108
+ }, mergeProps(focusProps, pressProps)), children);
91
109
  var tooltip = isCopied ? 'Copied!' : tooltipText;
92
110
  var isTooltipOpen = isFocusVisible || isHovered || isCopied;
111
+ var pressableRef = useRef();
112
+
113
+ var _usePress2 = usePress({
114
+ ref: pressableRef
115
+ }),
116
+ pressableProps = _usePress2.pressProps;
117
+
118
+ delete pressableProps.onMouseDown;
119
+ delete pressableProps.onPointerDown;
93
120
  var wrapperRef = useRef();
94
121
 
95
122
  if (mode === 'nonClickableContent') {
@@ -121,12 +148,19 @@ var CopyText = /*#__PURE__*/forwardRef(function (props, ref) {
121
148
 
122
149
  return ___EmotionJSX(TooltipWrapper, {
123
150
  isOpen: isTooltipOpen,
124
- tooltip: tooltip
125
- }, ___EmotionJSX(Pressable, null, ___EmotionJSX(Box, _extends({
151
+ tooltip: tooltip,
152
+ targetRef: pressableRef
153
+ }, ___EmotionJSX(Box, _extends({
154
+ ref: pressableRef
155
+ }, mergeProps(hoverProps, pressableProps), {
156
+ sx: {
157
+ width: 'min-content'
158
+ }
159
+ }), ___EmotionJSX(Box, _extends({
126
160
  ref: ref,
127
161
  isRow: true,
128
162
  variant: "boxes.copy"
129
- }, mergeProps(hoverProps, others)), content, ___EmotionJSX(CopyButton, _extends({
163
+ }, others), content, ___EmotionJSX(CopyButton, _extends({
130
164
  onPress: copyToClipboard
131
165
  }, focusProps)))));
132
166
  });
@@ -27,6 +27,7 @@ var testId = 'test-copy-text';
27
27
  var originalClipboard = _objectSpread({}, global.navigator.clipboard);
28
28
 
29
29
  var originalExecCommand = global.document.execCommand;
30
+ var originalGetSelection = window.getSelection;
30
31
 
31
32
  var defaultTest = function defaultTest() {
32
33
  var getComponent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -75,11 +76,15 @@ describe('Text mode', function () {
75
76
  global.navigator.clipboard = mockClipboard;
76
77
  global.document.execCommand = jest.fn();
77
78
  global.document.execCommand.mockReturnValue(true);
79
+ var mockGetSelection = jest.fn();
80
+ mockGetSelection.mockReturnValue('');
81
+ window.getSelection = mockGetSelection;
78
82
  });
79
83
  afterEach(function () {
80
84
  jest.resetAllMocks();
81
85
  global.navigator.clipboard = originalClipboard;
82
86
  global.document.execCommand = originalExecCommand;
87
+ window.getSelection = originalGetSelection;
83
88
  });
84
89
  test('click on text copies data to the clipboard', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
85
90
  var button;
@@ -388,10 +393,14 @@ describe('Link mode', function () {
388
393
  writeText: jest.fn()
389
394
  };
390
395
  global.navigator.clipboard = mockClipboard;
396
+ var mockGetSelection = jest.fn();
397
+ mockGetSelection.mockReturnValue('');
398
+ window.getSelection = mockGetSelection;
391
399
  });
392
400
  afterEach(function () {
393
401
  jest.resetAllMocks();
394
402
  global.navigator.clipboard = originalClipboard;
403
+ window.getSelection = originalGetSelection;
395
404
  });
396
405
  test('click on copy button copies data to the clipboard', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
397
406
  var button;
@@ -0,0 +1,145 @@
1
+ import React from 'react';
2
+ import CreateIcon from 'mdi-react/CreateIcon';
3
+ import { Box, Chip, IconButton, Text, Icon, Separator, TextField, HelpHint } from '../index';
4
+ import { jsx as ___EmotionJSX } from "@emotion/react";
5
+ export default {
6
+ title: 'Recipes/AttributeMappingReadOnlyField'
7
+ };
8
+ export var Default = function Default() {
9
+ var Row = function Row(props) {
10
+ var withChip = props.withChip,
11
+ withTooltip = props.withTooltip,
12
+ leftValue = props.leftValue,
13
+ rightValue = props.rightValue;
14
+ return ___EmotionJSX(Box, {
15
+ isRow: true,
16
+ alignItems: "center",
17
+ mt: "10px"
18
+ }, ___EmotionJSX(TextField, {
19
+ isReadOnly: true,
20
+ value: leftValue,
21
+ labelProps: {
22
+ mb: 0
23
+ },
24
+ controlProps: {
25
+ variant: 'input.small',
26
+ 'aria-label': "input ".concat(leftValue),
27
+ sx: {
28
+ width: '165px'
29
+ }
30
+ }
31
+ }), ___EmotionJSX(Separator, {
32
+ sx: {
33
+ width: '21px',
34
+ ml: '2px',
35
+ mr: '2px'
36
+ }
37
+ }), ___EmotionJSX(TextField, {
38
+ isReadOnly: true,
39
+ value: rightValue,
40
+ labelProps: {
41
+ mb: 0
42
+ },
43
+ controlProps: {
44
+ variant: 'input.small',
45
+ 'aria-label': "input ".concat(rightValue),
46
+ sx: {
47
+ width: '165px'
48
+ }
49
+ }
50
+ }), withChip && ___EmotionJSX(Chip, {
51
+ label: "Required",
52
+ sx: {
53
+ width: '65px',
54
+ height: '22px',
55
+ alignSelf: 'center',
56
+ minWidth: 'fit-content',
57
+ border: '1px solid',
58
+ borderColor: 'neutral.80',
59
+ backgroundColor: 'white !important',
60
+ ml: 8,
61
+ '& span': {
62
+ fontSize: 'sm',
63
+ lineHeight: 1,
64
+ color: '#253746'
65
+ }
66
+ }
67
+ }), withTooltip && ___EmotionJSX(Box, {
68
+ ml: "5px",
69
+ height: "15px",
70
+ width: "15px"
71
+ }, ___EmotionJSX(HelpHint, {
72
+ tooltipProps: {
73
+ direction: 'bottom'
74
+ }
75
+ }, "Population set to default")));
76
+ };
77
+
78
+ return ___EmotionJSX(Box, null, ___EmotionJSX(Box, {
79
+ isRow: true,
80
+ alignItems: "center",
81
+ mb: "15px"
82
+ }, ___EmotionJSX(Text, {
83
+ sx: {
84
+ fontSize: 'lg',
85
+ lineHeight: '21px',
86
+ fontWeight: 3,
87
+ color: 'text.primary'
88
+ }
89
+ }, "Attribute Mapping"), ___EmotionJSX(Box, null, ___EmotionJSX(IconButton, {
90
+ ml: "5px",
91
+ variant: "inverted",
92
+ "aria-label": "edit header button"
93
+ }, ___EmotionJSX(Icon, {
94
+ icon: CreateIcon,
95
+ size: 18
96
+ })))), ___EmotionJSX(Box, {
97
+ backgroundColor: "accent.99",
98
+ width: "450px",
99
+ padding: "10px 10px 25px 10px"
100
+ }, ___EmotionJSX(Box, {
101
+ isRow: true,
102
+ sx: {
103
+ width: '100%'
104
+ }
105
+ }, ___EmotionJSX(Box, {
106
+ sx: {
107
+ width: 'calc(50% - 22px)'
108
+ }
109
+ }, ___EmotionJSX(Text, {
110
+ sx: {
111
+ fontWeight: 3,
112
+ fontSize: 'md',
113
+ lineHeight: '18px',
114
+ mb: '5px'
115
+ }
116
+ }, "PingOne")), ___EmotionJSX(Box, {
117
+ sx: {
118
+ width: 'calc(50% - 22px)'
119
+ }
120
+ }, ___EmotionJSX(Text, {
121
+ sx: {
122
+ fontWeight: 3,
123
+ fontSize: 'md',
124
+ lineHeight: '18px',
125
+ mb: '5px'
126
+ }
127
+ }, "Google Suites"))), ___EmotionJSX(Separator, null), ___EmotionJSX(Row, {
128
+ withChip: true,
129
+ leftValue: "UserId",
130
+ rightValue: "mdorey"
131
+ }), ___EmotionJSX(Row, {
132
+ leftValue: "givenName",
133
+ rightValue: "firstName"
134
+ }), ___EmotionJSX(Row, {
135
+ leftValue: "familyName",
136
+ rightValue: "lastName"
137
+ }), ___EmotionJSX(Row, {
138
+ withTooltip: true,
139
+ leftValue: "population",
140
+ rightValue: "population"
141
+ }), ___EmotionJSX(Row, {
142
+ leftValue: "password",
143
+ rightValue: "password"
144
+ })));
145
+ };
@@ -0,0 +1,52 @@
1
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
2
+ import _Object$entries from "@babel/runtime-corejs3/core-js-stable/object/entries";
3
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
4
+ import React from 'react';
5
+ import Text from '../components/Text';
6
+ import scale from './spacing';
7
+ import { Table, TableHead, TableRow, TableBody, TableCell, Separator } from '..';
8
+ import { jsx as ___EmotionJSX } from "@emotion/react";
9
+ export default {
10
+ title: 'Design/Spacing'
11
+ };
12
+ var tableBodyStyles = {
13
+ border: 'unset'
14
+ };
15
+ var tableRowStyles = {
16
+ backgroundColor: 'transparent !important'
17
+ };
18
+ export var Spacing = function Spacing() {
19
+ var _context;
20
+
21
+ return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Text, {
22
+ variant: "sectionTitle"
23
+ }, "Spacing"), ___EmotionJSX(Separator, {
24
+ mb: "sm"
25
+ }), ___EmotionJSX(Table, {
26
+ width: "75%"
27
+ }, ___EmotionJSX(TableHead, null, ___EmotionJSX(TableRow, {
28
+ sx: tableRowStyles,
29
+ key: "head"
30
+ }, ___EmotionJSX(TableCell, {
31
+ isHeading: true,
32
+ key: "name"
33
+ }, "Token"), ___EmotionJSX(TableCell, {
34
+ isHeading: true,
35
+ key: "value"
36
+ }, "Size"))), _mapInstanceProperty(_context = _Object$entries(scale)).call(_context, function (_ref) {
37
+ var _ref2 = _slicedToArray(_ref, 2),
38
+ key = _ref2[0],
39
+ value = _ref2[1];
40
+
41
+ return ___EmotionJSX(TableBody, {
42
+ sx: tableBodyStyles,
43
+ key: key
44
+ }, ___EmotionJSX(TableRow, {
45
+ sx: tableRowStyles
46
+ }, ___EmotionJSX(TableCell, {
47
+ bg: "white"
48
+ }, key), ___EmotionJSX(TableCell, {
49
+ bg: "white"
50
+ }, value, "px")));
51
+ })));
52
+ };
@@ -0,0 +1,136 @@
1
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
2
+ import _Object$entries from "@babel/runtime-corejs3/core-js-stable/object/entries";
3
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
4
+ import React from 'react';
5
+ import Text from '../components/Text';
6
+ import { Table, TableRow, TableBody, TableHead, TableCell, Box, Separator } from '..';
7
+ import { fontWeights, fontSizes } from './text';
8
+ import { jsx as ___EmotionJSX } from "@emotion/react";
9
+ export default {
10
+ title: 'Design/Typography'
11
+ };
12
+ var tableBodyStyles = {
13
+ border: 'unset'
14
+ };
15
+ var tableRowStyles = {
16
+ backgroundColor: 'transparent !important'
17
+ };
18
+ export var TypographyTokens = function TypographyTokens() {
19
+ var _context, _context2;
20
+
21
+ return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Text, {
22
+ variant: "sectionTitle"
23
+ }, "Font Sizes"), ___EmotionJSX(Separator, {
24
+ mb: "sm"
25
+ }), ___EmotionJSX(Table, {
26
+ width: "75%"
27
+ }, ___EmotionJSX(TableHead, null, ___EmotionJSX(TableRow, {
28
+ key: "head"
29
+ }, ___EmotionJSX(TableCell, {
30
+ isHeading: true
31
+ }, "Token"), ___EmotionJSX(TableCell, {
32
+ isHeading: true
33
+ }, "Size"), ___EmotionJSX(TableCell, {
34
+ isHeading: true
35
+ }, "Example"))), _mapInstanceProperty(_context = _Object$entries(fontSizes)).call(_context, function (_ref) {
36
+ var _ref2 = _slicedToArray(_ref, 2),
37
+ key = _ref2[0],
38
+ value = _ref2[1];
39
+
40
+ return ___EmotionJSX(TableBody, {
41
+ sx: tableBodyStyles,
42
+ key: key
43
+ }, ___EmotionJSX(TableRow, {
44
+ sx: tableRowStyles
45
+ }, ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, {
46
+ fontSize: value
47
+ }, key)), ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, {
48
+ fontSize: value
49
+ }, value)), ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, {
50
+ fontSize: value
51
+ }, "<Text fontSize={", key, "} />"))));
52
+ }))), ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Text, {
53
+ variant: "sectionTitle",
54
+ mt: "xx"
55
+ }, "Font Weights"), ___EmotionJSX(Separator, {
56
+ mb: "sm"
57
+ }), ___EmotionJSX(Table, {
58
+ width: "75%"
59
+ }, ___EmotionJSX(TableHead, null, ___EmotionJSX(TableRow, {
60
+ key: "head"
61
+ }, ___EmotionJSX(TableCell, {
62
+ isHeading: true
63
+ }, "Token"), ___EmotionJSX(TableCell, {
64
+ isHeading: true
65
+ }, "Size"), ___EmotionJSX(TableCell, {
66
+ isHeading: true
67
+ }, "Example"))), _mapInstanceProperty(_context2 = _Object$entries(fontWeights)).call(_context2, function (_ref3) {
68
+ var _ref4 = _slicedToArray(_ref3, 2),
69
+ key = _ref4[0],
70
+ value = _ref4[1];
71
+
72
+ return ___EmotionJSX(TableBody, {
73
+ sx: tableBodyStyles,
74
+ key: key
75
+ }, ___EmotionJSX(TableRow, {
76
+ sx: tableRowStyles
77
+ }, ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, {
78
+ fontWeight: value
79
+ }, key)), ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, {
80
+ fontWeight: value
81
+ }, value)), ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, {
82
+ fontWeight: value
83
+ }, "<Text fontWeight={", key, "} />"))));
84
+ }))), ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Text, {
85
+ variant: "sectionTitle",
86
+ mt: "xx"
87
+ }, "Text Colors"), ___EmotionJSX(Separator, {
88
+ mb: "sm"
89
+ }), ___EmotionJSX(Table, {
90
+ width: "75%"
91
+ }, ___EmotionJSX(TableHead, null, ___EmotionJSX(TableRow, {
92
+ key: "head"
93
+ }, ___EmotionJSX(TableCell, {
94
+ isHeading: true
95
+ }, "Token"), ___EmotionJSX(TableCell, {
96
+ isHeading: true
97
+ }, "Color"), ___EmotionJSX(TableCell, {
98
+ isHeading: true
99
+ }, "Example"))), ___EmotionJSX(TableBody, {
100
+ sx: tableBodyStyles
101
+ }, ___EmotionJSX(TableRow, {
102
+ sx: tableRowStyles
103
+ }, ___EmotionJSX(TableCell, null, ___EmotionJSX(Box, {
104
+ isRow: true
105
+ }, ___EmotionJSX(Box, {
106
+ width: "30px",
107
+ height: "30px",
108
+ bg: "text.primary",
109
+ mr: "xs"
110
+ }), ___EmotionJSX(Text, {
111
+ alignSelf: "center"
112
+ }, "text.primary"))), ___EmotionJSX(TableCell, {
113
+ alignSelf: "center"
114
+ }, ___EmotionJSX(Text, null, "neutral.10")), ___EmotionJSX(TableCell, {
115
+ alignSelf: "center"
116
+ }, ___EmotionJSX(Text, {
117
+ color: "text.primary"
118
+ }, "<Text textColor={text.primary} />"))), ___EmotionJSX(TableRow, {
119
+ sx: tableRowStyles
120
+ }, ___EmotionJSX(TableCell, null, ___EmotionJSX(Box, {
121
+ isRow: true
122
+ }, ___EmotionJSX(Box, {
123
+ width: "30px",
124
+ height: "30px",
125
+ bg: "text.secondary",
126
+ mr: "xs"
127
+ }), ___EmotionJSX(Text, {
128
+ alignSelf: "center"
129
+ }, "text.secondary"))), ___EmotionJSX(TableCell, {
130
+ alignSelf: "center"
131
+ }, ___EmotionJSX(Text, null, "neutral.40")), ___EmotionJSX(TableCell, {
132
+ alignSelf: "center"
133
+ }, ___EmotionJSX(Text, {
134
+ color: "text.secondary"
135
+ }, "<Text color={text.secondary} />")))))));
136
+ };
@@ -152,12 +152,14 @@ var textFieldInContainerSlot = {
152
152
  var copy = {
153
153
  alignItems: 'center',
154
154
  width: 'max-content',
155
- cursor: 'pointer',
156
155
  '& .is-focused': {
157
156
  outline: '1px solid',
158
157
  outlineColor: 'active',
159
158
  outlineOffset: '4px',
160
159
  borderRadius: '4px'
160
+ },
161
+ '& span': {
162
+ cursor: 'text'
161
163
  }
162
164
  };
163
165
  var topShadowScrollbox = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "1.13.0-alpha.5",
3
+ "version": "1.13.0-alpha.8",
4
4
  "description": "PingUX themeable React component library",
5
5
  "author": "ux-development@pingidentity.com",
6
6
  "license": "Apache-2.0",