@pingux/astro 1.0.0-alpha.2 → 1.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +192 -0
- package/README.md +5 -0
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.stories.js +4 -11
- package/lib/cjs/components/AccordionItem/AccordionItem.js +3 -1
- package/lib/cjs/components/Button/Button.js +5 -24
- package/lib/cjs/components/Button/Button.stories.js +5 -11
- package/lib/cjs/components/Button/Button.test.js +0 -24
- package/lib/cjs/components/Chip/Chip.js +26 -10
- package/lib/cjs/components/Chip/Chip.stories.js +44 -5
- package/lib/cjs/components/Chip/Chip.test.js +9 -0
- package/lib/cjs/components/{Dropdown/index.js → Chip/ChipContext.js} +8 -7
- package/lib/cjs/components/CopyText/CopyText.js +3 -73
- package/lib/cjs/components/FileInputField/FileInputField.js +324 -0
- package/lib/cjs/components/FileInputField/FileInputField.stories.js +250 -0
- package/lib/cjs/components/FileInputField/FileInputField.test.js +227 -0
- package/lib/cjs/components/FileInputField/FileItem.js +125 -0
- package/lib/cjs/components/FileInputField/FileSelect.js +48 -0
- package/lib/cjs/components/{DropdownField → FileInputField}/index.js +2 -2
- package/lib/cjs/components/IconButton/IconButton.js +17 -7
- package/lib/cjs/components/IconButton/IconButton.test.js +0 -1
- package/lib/cjs/components/ListItem/ListItem.stories.js +0 -2
- package/lib/cjs/components/ListView/ListView.js +4 -3
- package/lib/cjs/components/ListViewItem/ListViewItem.js +3 -6
- package/lib/cjs/components/Stepper/Stepper.js +1 -0
- package/lib/cjs/components/Tab/Tab.js +15 -6
- package/lib/cjs/components/Tabs/Tabs.js +7 -1
- package/lib/cjs/components/Tabs/Tabs.stories.js +60 -6
- package/lib/cjs/components/Tabs/Tabs.test.js +78 -15
- package/lib/cjs/components/TextAreaField/TextAreaField.test.js +10 -0
- package/lib/cjs/{components/Panel → hooks/useCopyToClipboard}/index.js +2 -2
- package/lib/cjs/hooks/useCopyToClipboard/useCopyToClipboard.js +83 -0
- package/lib/cjs/hooks/useCopyToClipboard/useCopyToClipboard.test.js +79 -0
- package/lib/cjs/index.js +55 -133
- package/lib/cjs/layouts/ListLayout.stories.js +2 -1
- package/lib/cjs/layouts/SchemaFormLayout.stories.js +2 -21
- package/lib/cjs/recipes/ArrayField.stories.js +3 -3
- package/lib/cjs/recipes/CopyToClipboard.stories.js +45 -0
- package/lib/cjs/recipes/RadioButtonsWithLinks.stories.js +146 -0
- package/lib/cjs/styles/forms/input.js +15 -0
- package/lib/cjs/styles/theme.js +0 -3
- package/lib/cjs/styles/variants/accordion.js +7 -9
- package/lib/cjs/styles/variants/boxes.js +43 -18
- package/lib/cjs/styles/variants/buttons.js +22 -28
- package/lib/cjs/styles/variants/tabs.js +1 -0
- package/lib/cjs/styles/variants/variants.js +0 -3
- package/lib/components/AccordionGridGroup/AccordionGridGroup.stories.js +4 -11
- package/lib/components/AccordionItem/AccordionItem.js +3 -1
- package/lib/components/Button/Button.js +7 -24
- package/lib/components/Button/Button.stories.js +5 -10
- package/lib/components/Button/Button.test.js +0 -20
- package/lib/components/Chip/Chip.js +25 -10
- package/lib/components/Chip/Chip.stories.js +41 -5
- package/lib/components/Chip/Chip.test.js +9 -0
- package/lib/components/Chip/ChipContext.js +3 -0
- package/lib/components/CopyText/CopyText.js +2 -71
- package/lib/components/FileInputField/FileInputField.js +280 -0
- package/lib/components/FileInputField/FileInputField.stories.js +206 -0
- package/lib/components/FileInputField/FileInputField.test.js +187 -0
- package/lib/components/FileInputField/FileItem.js +100 -0
- package/lib/components/FileInputField/FileSelect.js +31 -0
- package/lib/components/FileInputField/index.js +1 -0
- package/lib/components/IconButton/IconButton.js +17 -9
- package/lib/components/IconButton/IconButton.test.js +0 -1
- package/lib/components/ListItem/ListItem.stories.js +0 -2
- package/lib/components/ListView/ListView.js +4 -3
- package/lib/components/ListViewItem/ListViewItem.js +3 -5
- package/lib/components/Stepper/Stepper.js +1 -0
- package/lib/components/Tab/Tab.js +15 -6
- package/lib/components/Tabs/Tabs.js +7 -1
- package/lib/components/Tabs/Tabs.stories.js +56 -4
- package/lib/components/Tabs/Tabs.test.js +78 -15
- package/lib/components/TextAreaField/TextAreaField.test.js +8 -0
- package/lib/hooks/useCopyToClipboard/index.js +1 -0
- package/lib/hooks/useCopyToClipboard/useCopyToClipboard.js +69 -0
- package/lib/hooks/useCopyToClipboard/useCopyToClipboard.test.js +64 -0
- package/lib/index.js +1 -8
- package/lib/layouts/ListLayout.stories.js +2 -1
- package/lib/layouts/SchemaFormLayout.stories.js +2 -19
- package/lib/recipes/ArrayField.stories.js +3 -3
- package/lib/recipes/CopyToClipboard.stories.js +25 -0
- package/lib/recipes/RadioButtonsWithLinks.stories.js +120 -0
- package/lib/styles/forms/input.js +15 -0
- package/lib/styles/theme.js +0 -3
- package/lib/styles/variants/accordion.js +7 -9
- package/lib/styles/variants/boxes.js +43 -18
- package/lib/styles/variants/buttons.js +22 -28
- package/lib/styles/variants/tabs.js +1 -0
- package/lib/styles/variants/variants.js +0 -2
- package/package.json +3 -2
- package/lib/cjs/components/Dropdown/Dropdown.js +0 -112
- package/lib/cjs/components/Dropdown/Dropdown.test.js +0 -80
- package/lib/cjs/components/DropdownField/DropdownField.js +0 -187
- package/lib/cjs/components/DropdownField/DropdownField.stories.js +0 -278
- package/lib/cjs/components/DropdownField/DropdownField.test.js +0 -80
- package/lib/cjs/components/Panel/Panel.js +0 -101
- package/lib/cjs/components/Panel/Panel.stories.js +0 -57
- package/lib/cjs/components/Panel/Panel.test.js +0 -72
- package/lib/cjs/components/Popover/Popover.js +0 -87
- package/lib/cjs/components/Popover/Popover.stories.js +0 -80
- package/lib/cjs/components/Popover/Popover.test.js +0 -91
- package/lib/cjs/components/Popover/index.js +0 -18
- package/lib/cjs/recipes/InputBoxWithLinkedChip.stories.js +0 -67
- package/lib/cjs/styles/variants/popover.js +0 -86
- package/lib/components/Dropdown/Dropdown.js +0 -90
- package/lib/components/Dropdown/Dropdown.test.js +0 -62
- package/lib/components/Dropdown/index.js +0 -1
- package/lib/components/DropdownField/DropdownField.js +0 -155
- package/lib/components/DropdownField/DropdownField.stories.js +0 -222
- package/lib/components/DropdownField/DropdownField.test.js +0 -60
- package/lib/components/DropdownField/index.js +0 -1
- package/lib/components/Panel/Panel.js +0 -71
- package/lib/components/Panel/Panel.stories.js +0 -35
- package/lib/components/Panel/Panel.test.js +0 -52
- package/lib/components/Panel/index.js +0 -1
- package/lib/components/Popover/Popover.js +0 -65
- package/lib/components/Popover/Popover.stories.js +0 -52
- package/lib/components/Popover/Popover.test.js +0 -75
- package/lib/components/Popover/index.js +0 -2
- package/lib/recipes/InputBoxWithLinkedChip.stories.js +0 -43
- package/lib/styles/variants/popover.js +0 -76
@@ -21,6 +21,7 @@ export var CollectionTab = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
21
21
|
tabsDisabled = props.isDisabled,
|
22
22
|
orientation = props.orientation,
|
23
23
|
mode = props.mode,
|
24
|
+
slots = props.slots,
|
24
25
|
tooltipTriggerProps = props.tooltipTriggerProps;
|
25
26
|
var key = item.key,
|
26
27
|
rendered = item.rendered,
|
@@ -32,10 +33,11 @@ export var CollectionTab = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
32
33
|
tabLabelProps = itemProps.tabLabelProps,
|
33
34
|
tabLineProps = itemProps.tabLineProps,
|
34
35
|
content = itemProps.content,
|
35
|
-
|
36
|
+
titleAttr = itemProps.titleAttr,
|
37
|
+
otherItemProps = _objectWithoutProperties(itemProps, ["icon", "isDisabled", "separator", "tabLabelProps", "tabLineProps", "content", "titleAttr"]);
|
36
38
|
|
37
|
-
var isDisabled = tabsDisabled || tabDisabled;
|
38
39
|
var state = useContext(TabsContext);
|
40
|
+
var isDisabled = tabsDisabled || tabDisabled || state.disabledKeys.has(key);
|
39
41
|
var isSelected = state.selectedKey === key;
|
40
42
|
|
41
43
|
var _useFocusRing = useFocusRing(),
|
@@ -70,14 +72,17 @@ export var CollectionTab = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
70
72
|
}, state, tabRef),
|
71
73
|
tabProps = _useTab.tabProps;
|
72
74
|
|
73
|
-
var tab = ___EmotionJSX(Box,
|
75
|
+
var tab = ___EmotionJSX(Box, {
|
76
|
+
isRow: true
|
77
|
+
}, slots === null || slots === void 0 ? void 0 : slots.beforeTab, ___EmotionJSX(Box, _extends({
|
74
78
|
className: classNames,
|
75
79
|
variant: "tab"
|
76
80
|
}, mergeProps(focusProps, hoverProps, tabProps), otherItemProps, {
|
77
|
-
ref: tabRef
|
81
|
+
ref: tabRef,
|
82
|
+
title: titleAttr || undefined
|
78
83
|
}), icon, ___EmotionJSX(Text, _extends({
|
79
84
|
variant: "tabLabel"
|
80
|
-
}, tabLabelProps), rendered), isSelected && !isDisabled && ___EmotionJSX(TabLine, tabLineProps));
|
85
|
+
}, tabLabelProps), rendered), isSelected && !isDisabled && ___EmotionJSX(TabLine, tabLineProps)), slots === null || slots === void 0 ? void 0 : slots.afterTab);
|
81
86
|
|
82
87
|
if (mode === 'tooltip') {
|
83
88
|
return ___EmotionJSX(React.Fragment, null, separator, ___EmotionJSX(TooltipTrigger, _extends({}, tooltipTriggerProps, {
|
@@ -100,7 +105,11 @@ CollectionTab.propTypes = {
|
|
100
105
|
}),
|
101
106
|
mode: PropTypes.oneOf(['default', 'tooltip']),
|
102
107
|
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
103
|
-
tooltipTriggerProps: PropTypes.shape({})
|
108
|
+
tooltipTriggerProps: PropTypes.shape({}),
|
109
|
+
slots: PropTypes.shape({
|
110
|
+
beforeTab: PropTypes.node,
|
111
|
+
afterTab: PropTypes.node
|
112
|
+
})
|
104
113
|
};
|
105
114
|
|
106
115
|
var TabLine = function TabLine(props) {
|
@@ -71,12 +71,15 @@ var Tabs = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
71
71
|
}, tabListProps, raTabListProps, {
|
72
72
|
ref: tabListRef
|
73
73
|
}), _mapInstanceProperty(_context = _Array$from(state.collection)).call(_context, function (item) {
|
74
|
+
var _item$props;
|
75
|
+
|
74
76
|
return ___EmotionJSX(CollectionTab, {
|
75
77
|
key: item.key,
|
76
78
|
item: item,
|
77
79
|
isDisabled: isDisabled,
|
78
80
|
orientation: orientation,
|
79
|
-
mode: mode
|
81
|
+
mode: mode,
|
82
|
+
slots: item === null || item === void 0 ? void 0 : (_item$props = item.props) === null || _item$props === void 0 ? void 0 : _item$props.slots
|
80
83
|
});
|
81
84
|
})), ___EmotionJSX(Box, _extends({
|
82
85
|
variant: "tabPanel",
|
@@ -87,6 +90,9 @@ Tabs.propTypes = {
|
|
87
90
|
/** The default tab key to be selected. (uncontrolled) */
|
88
91
|
defaultSelectedKey: PropTypes.string,
|
89
92
|
|
93
|
+
/** Array of keys to disable within the tab list. */
|
94
|
+
disabledKeys: PropTypes.arrayOf(PropTypes.string),
|
95
|
+
|
90
96
|
/** The tab key that is currently selected. (controlled) */
|
91
97
|
selectedKey: PropTypes.string,
|
92
98
|
|
@@ -2,10 +2,12 @@ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
2
2
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
3
3
|
import React, { useState } from 'react';
|
4
4
|
import Earth from 'mdi-react/GlobeModelIcon';
|
5
|
+
import LockIcon from 'mdi-react/LockIcon';
|
5
6
|
import Tabs from './Tabs';
|
6
7
|
import Tab from '../Tab';
|
7
8
|
import Icon from '../Icon';
|
8
9
|
import Text from '../Text';
|
10
|
+
import { Chip } from '../../index';
|
9
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
10
12
|
export default {
|
11
13
|
title: 'Tabs',
|
@@ -126,13 +128,12 @@ export var Centered = function Centered() {
|
|
126
128
|
};
|
127
129
|
export var DisabledSingleTab = function DisabledSingleTab() {
|
128
130
|
return ___EmotionJSX(Tabs, {
|
129
|
-
|
130
|
-
|
131
|
+
items: tabs,
|
132
|
+
disabledKeys: ['Tab 2']
|
131
133
|
}, function (item) {
|
132
134
|
return ___EmotionJSX(Tab, {
|
133
135
|
key: item.name,
|
134
|
-
title: item.name
|
135
|
-
isDisabled: item.name === 'Tab 1'
|
136
|
+
title: item.name
|
136
137
|
}, item.children);
|
137
138
|
});
|
138
139
|
};
|
@@ -184,4 +185,55 @@ export var TabPanelProps = function TabPanelProps() {
|
|
184
185
|
title: item.name
|
185
186
|
}, item.children);
|
186
187
|
});
|
188
|
+
};
|
189
|
+
export var ContentSlots = function ContentSlots() {
|
190
|
+
var beforeTabNode = ___EmotionJSX(Icon, {
|
191
|
+
icon: LockIcon,
|
192
|
+
sx: {
|
193
|
+
marginTop: 10,
|
194
|
+
marginRight: 5
|
195
|
+
}
|
196
|
+
});
|
197
|
+
|
198
|
+
var nodeSx = {
|
199
|
+
alignItems: 'center',
|
200
|
+
backgroundColor: 'neutral.95',
|
201
|
+
borderRadius: '50%',
|
202
|
+
color: 'neutral.30',
|
203
|
+
fontSize: 'sm',
|
204
|
+
height: 20,
|
205
|
+
justifyContent: 'center',
|
206
|
+
marginLeft: 6,
|
207
|
+
marginTop: 10,
|
208
|
+
minWidth: 20
|
209
|
+
};
|
210
|
+
|
211
|
+
var afterTabNode = ___EmotionJSX(Chip, {
|
212
|
+
sx: nodeSx
|
213
|
+
}, "14");
|
214
|
+
|
215
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Tabs, {
|
216
|
+
items: tabs,
|
217
|
+
mb: 50
|
218
|
+
}, ___EmotionJSX(Tab, {
|
219
|
+
key: "tab1",
|
220
|
+
title: "Tab 1",
|
221
|
+
slots: {
|
222
|
+
beforeTab: beforeTabNode
|
223
|
+
}
|
224
|
+
}, ___EmotionJSX(Text, null, "This is content for Tab 1")), ___EmotionJSX(Tab, {
|
225
|
+
key: "tab2",
|
226
|
+
title: "Tab 2"
|
227
|
+
}, ___EmotionJSX(Text, null, "This is content for Tab 2"))), ___EmotionJSX(Tabs, {
|
228
|
+
items: tabs
|
229
|
+
}, ___EmotionJSX(Tab, {
|
230
|
+
key: "tab1",
|
231
|
+
title: "Tab 1"
|
232
|
+
}, ___EmotionJSX(Text, null, "Compose Filter")), ___EmotionJSX(Tab, {
|
233
|
+
key: "tab2",
|
234
|
+
title: "Tab 2",
|
235
|
+
slots: {
|
236
|
+
afterTab: afterTabNode
|
237
|
+
}
|
238
|
+
}, ___EmotionJSX(Text, null, "Users Matched"))));
|
187
239
|
};
|
@@ -220,6 +220,31 @@ test('disabled all tabs', function () {
|
|
220
220
|
expect(tab1).not.toContainElement(screen.queryByRole('presentation'));
|
221
221
|
testTabPanel(0);
|
222
222
|
});
|
223
|
+
test('disabled tab is not accessible on click or focus', function () {
|
224
|
+
getComponent({
|
225
|
+
disabledKeys: [defaultTabs[1].name]
|
226
|
+
});
|
227
|
+
testTabPanel(0);
|
228
|
+
|
229
|
+
var _getTabs5 = getTabs(),
|
230
|
+
tabs = _getTabs5.tabs,
|
231
|
+
tab0 = _getTabs5.tab0,
|
232
|
+
tab1 = _getTabs5.tab1,
|
233
|
+
tab2 = _getTabs5.tab2; // Ensure that clicking a disabled tab does nothing
|
234
|
+
|
235
|
+
|
236
|
+
userEvent.click(tab1);
|
237
|
+
testTabPanel(0); // Ensure that disabled tab is not accessible via focus
|
238
|
+
|
239
|
+
userEvent.tab();
|
240
|
+
testSingleTab(tabs, tab0, 'toHaveFocus');
|
241
|
+
fireEvent.keyDown(tab0, {
|
242
|
+
key: 'ArrowRight',
|
243
|
+
code: 'ArrowRight'
|
244
|
+
});
|
245
|
+
testSingleTab(tabs, tab2, 'toHaveFocus');
|
246
|
+
testTabPanel(2);
|
247
|
+
});
|
223
248
|
test('controlled tabs', function () {
|
224
249
|
var selectedKey = defaultTabs[1].name;
|
225
250
|
var onSelectionChange = jest.fn();
|
@@ -230,11 +255,11 @@ test('controlled tabs', function () {
|
|
230
255
|
}),
|
231
256
|
rerender = _getComponent.rerender;
|
232
257
|
|
233
|
-
var
|
234
|
-
tabs =
|
235
|
-
tab0 =
|
236
|
-
tab1 =
|
237
|
-
tab2 =
|
258
|
+
var _getTabs6 = getTabs(),
|
259
|
+
tabs = _getTabs6.tabs,
|
260
|
+
tab0 = _getTabs6.tab0,
|
261
|
+
tab1 = _getTabs6.tab1,
|
262
|
+
tab2 = _getTabs6.tab2; // Expect the second tab to be selected
|
238
263
|
|
239
264
|
|
240
265
|
expect(onSelectionChange).not.toHaveBeenCalled();
|
@@ -271,9 +296,9 @@ test('tab line props', function () {
|
|
271
296
|
}),
|
272
297
|
rerender = _getComponent2.rerender;
|
273
298
|
|
274
|
-
var
|
275
|
-
tabs =
|
276
|
-
tab0 =
|
299
|
+
var _getTabs7 = getTabs(),
|
300
|
+
tabs = _getTabs7.tabs,
|
301
|
+
tab0 = _getTabs7.tab0;
|
277
302
|
|
278
303
|
var tabLine = screen.getByRole('presentation'); // Expect the tab line to have a red background
|
279
304
|
|
@@ -302,16 +327,16 @@ test('tab with icon', function () {
|
|
302
327
|
tabs: newTabs
|
303
328
|
});
|
304
329
|
|
305
|
-
var
|
306
|
-
tabs =
|
307
|
-
tab0 =
|
330
|
+
var _getTabs8 = getTabs(),
|
331
|
+
tabs = _getTabs8.tabs,
|
332
|
+
tab0 = _getTabs8.tab0;
|
308
333
|
|
309
334
|
var icon = screen.getByTestId('icon'); // Expect the tab to have the given icon element
|
310
335
|
|
311
336
|
testSingleTab(tabs, tab0, 'toContainElement', [icon]);
|
312
337
|
});
|
313
338
|
test('tooltip renders on tab\'s hover in `tooltip` mode', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
314
|
-
var
|
339
|
+
var _getTabs9, tab0;
|
315
340
|
|
316
341
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
317
342
|
while (1) {
|
@@ -321,7 +346,7 @@ test('tooltip renders on tab\'s hover in `tooltip` mode', /*#__PURE__*/_asyncToG
|
|
321
346
|
mode: 'tooltip'
|
322
347
|
});
|
323
348
|
expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
|
324
|
-
|
349
|
+
_getTabs9 = getTabs(), tab0 = _getTabs9.tab0;
|
325
350
|
fireEvent.mouseMove(tab0);
|
326
351
|
fireEvent.mouseEnter(tab0);
|
327
352
|
|
@@ -345,10 +370,48 @@ test('tabs without selected keys show null tab panel content', function () {
|
|
345
370
|
test('hover tab style', function () {
|
346
371
|
getComponent();
|
347
372
|
|
348
|
-
var
|
349
|
-
tab0 =
|
373
|
+
var _getTabs10 = getTabs(),
|
374
|
+
tab0 = _getTabs10.tab0;
|
350
375
|
|
351
376
|
expect(tab0).not.toHaveClass('is-hovered');
|
352
377
|
userEvent.hover(tab0);
|
353
378
|
expect(tab0).toHaveClass('is-hovered');
|
379
|
+
});
|
380
|
+
test('will render slots.beforeTab if provided', function () {
|
381
|
+
var testText = 'test-text';
|
382
|
+
|
383
|
+
var testComponent = ___EmotionJSX("div", null, testText);
|
384
|
+
|
385
|
+
var tabs = [{
|
386
|
+
name: 'Tab 1',
|
387
|
+
children: 'Tab 1 body',
|
388
|
+
props: {
|
389
|
+
slots: {
|
390
|
+
beforeTab: testComponent
|
391
|
+
}
|
392
|
+
}
|
393
|
+
}];
|
394
|
+
getComponent({}, {
|
395
|
+
tabs: tabs
|
396
|
+
});
|
397
|
+
expect(screen.getByText(testText)).toBeInTheDocument();
|
398
|
+
});
|
399
|
+
test('will render slots.afterTab if provided', function () {
|
400
|
+
var testText = 'test-text';
|
401
|
+
|
402
|
+
var testComponent = ___EmotionJSX("div", null, testText);
|
403
|
+
|
404
|
+
var tabs = [{
|
405
|
+
name: 'Tab 1',
|
406
|
+
children: 'Tab 1 body',
|
407
|
+
props: {
|
408
|
+
slots: {
|
409
|
+
afterTab: testComponent
|
410
|
+
}
|
411
|
+
}
|
412
|
+
}];
|
413
|
+
getComponent({}, {
|
414
|
+
tabs: tabs
|
415
|
+
});
|
416
|
+
expect(screen.getByText(testText)).toBeInTheDocument();
|
354
417
|
});
|
@@ -99,6 +99,14 @@ test('form wrapper will have default max label column width when no custom width
|
|
99
99
|
var textAreaContainer = screen.getByTestId(testId);
|
100
100
|
expect(textAreaContainer).toHaveStyle('grid-template-columns: 40% auto');
|
101
101
|
});
|
102
|
+
test('passing read only prop applys the is-read-only class to the textarea', function () {
|
103
|
+
var isReadOnly = true;
|
104
|
+
getComponent({
|
105
|
+
isReadOnly: isReadOnly
|
106
|
+
});
|
107
|
+
var textArea = screen.getByLabelText(defaultProps.label);
|
108
|
+
expect(textArea).toHaveClass('is-read-only');
|
109
|
+
});
|
102
110
|
test('form wrapper will have a max label column width when custom width set', function () {
|
103
111
|
var labelMode = 'left';
|
104
112
|
var containerProps = {
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './useCopyToClipboard';
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
2
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
3
|
+
|
4
|
+
var useCopyToClipboard = function useCopyToClipboard(value) {
|
5
|
+
var setIsCopied = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
|
6
|
+
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
7
|
+
var textArea, isSuccessful;
|
8
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
9
|
+
while (1) {
|
10
|
+
switch (_context.prev = _context.next) {
|
11
|
+
case 0:
|
12
|
+
_context.prev = 0;
|
13
|
+
|
14
|
+
if (!navigator.clipboard) {
|
15
|
+
_context.next = 7;
|
16
|
+
break;
|
17
|
+
}
|
18
|
+
|
19
|
+
_context.next = 4;
|
20
|
+
return navigator.clipboard.writeText(value);
|
21
|
+
|
22
|
+
case 4:
|
23
|
+
setIsCopied(true);
|
24
|
+
_context.next = 20;
|
25
|
+
break;
|
26
|
+
|
27
|
+
case 7:
|
28
|
+
// Workaround for copying in insecure origin
|
29
|
+
textArea = document.createElement('textarea');
|
30
|
+
textArea.value = value;
|
31
|
+
textArea.style.position = 'fixed';
|
32
|
+
document.body.appendChild(textArea);
|
33
|
+
textArea.focus();
|
34
|
+
textArea.select();
|
35
|
+
isSuccessful = document.execCommand('copy');
|
36
|
+
textArea.remove();
|
37
|
+
|
38
|
+
if (!isSuccessful) {
|
39
|
+
_context.next = 19;
|
40
|
+
break;
|
41
|
+
}
|
42
|
+
|
43
|
+
setIsCopied(isSuccessful);
|
44
|
+
_context.next = 20;
|
45
|
+
break;
|
46
|
+
|
47
|
+
case 19:
|
48
|
+
throw new Error('Unable to copy message');
|
49
|
+
|
50
|
+
case 20:
|
51
|
+
_context.next = 25;
|
52
|
+
break;
|
53
|
+
|
54
|
+
case 22:
|
55
|
+
_context.prev = 22;
|
56
|
+
_context.t0 = _context["catch"](0);
|
57
|
+
// eslint-disable-next-line no-console
|
58
|
+
console.error('Failed to copy: ', _context.t0);
|
59
|
+
|
60
|
+
case 25:
|
61
|
+
case "end":
|
62
|
+
return _context.stop();
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}, _callee, null, [[0, 22]]);
|
66
|
+
}));
|
67
|
+
};
|
68
|
+
|
69
|
+
export default useCopyToClipboard;
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
2
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
3
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
4
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
5
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
6
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
7
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
8
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
9
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
10
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
11
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
12
|
+
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
14
|
+
|
15
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source), true)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context3; _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
16
|
+
|
17
|
+
import useCopyToClipboard from './useCopyToClipboard';
|
18
|
+
var mockCopyText = 'test';
|
19
|
+
|
20
|
+
var originalClipboard = _objectSpread({}, global.navigator.clipboard);
|
21
|
+
|
22
|
+
var originalExecCommand = global.document.execCommand;
|
23
|
+
beforeEach(function () {
|
24
|
+
global.navigator.clipboard = {
|
25
|
+
writeText: jest.fn()
|
26
|
+
};
|
27
|
+
global.document.execCommand = jest.fn();
|
28
|
+
global.document.execCommand.mockReturnValue(true);
|
29
|
+
});
|
30
|
+
afterEach(function () {
|
31
|
+
jest.resetAllMocks();
|
32
|
+
global.navigator.clipboard = originalClipboard;
|
33
|
+
global.document.execCommand = originalExecCommand;
|
34
|
+
});
|
35
|
+
test('default return', function () {
|
36
|
+
var copyToClipboard = useCopyToClipboard();
|
37
|
+
expect(copyToClipboard).toEqual(expect.any(Function));
|
38
|
+
});
|
39
|
+
test('should copy text that passed in props', function () {
|
40
|
+
var copyToClipboard = useCopyToClipboard(mockCopyText);
|
41
|
+
copyToClipboard();
|
42
|
+
expect(navigator.clipboard.writeText).toHaveBeenCalledWith(mockCopyText);
|
43
|
+
});
|
44
|
+
test('should call setIsCopied once function will be called', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
45
|
+
var mockSetIsCopied, copyToClipboard;
|
46
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
47
|
+
while (1) {
|
48
|
+
switch (_context.prev = _context.next) {
|
49
|
+
case 0:
|
50
|
+
mockSetIsCopied = jest.fn();
|
51
|
+
copyToClipboard = useCopyToClipboard(mockCopyText, mockSetIsCopied);
|
52
|
+
_context.next = 4;
|
53
|
+
return copyToClipboard();
|
54
|
+
|
55
|
+
case 4:
|
56
|
+
expect(mockSetIsCopied).toHaveBeenCalledWith(true);
|
57
|
+
|
58
|
+
case 5:
|
59
|
+
case "end":
|
60
|
+
return _context.stop();
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}, _callee);
|
64
|
+
})));
|
package/lib/index.js
CHANGED
@@ -30,12 +30,9 @@ export * from './components/Chip';
|
|
30
30
|
export { default as ComboBoxField } from './components/ComboBoxField';
|
31
31
|
export { default as CopyText } from './components/CopyText';
|
32
32
|
export { default as ColorField } from './components/ColorField';
|
33
|
-
export { default as Dropdown } from './components/Dropdown';
|
34
|
-
export * from './components/Dropdown';
|
35
|
-
export { default as DropdownField } from './components/DropdownField';
|
36
|
-
export * from './components/DropdownField';
|
37
33
|
export { default as FieldHelperText } from './components/FieldHelperText';
|
38
34
|
export * from './components/FieldHelperText';
|
35
|
+
export { default as FileInputField } from './components/FileInputField';
|
39
36
|
export { default as HelpHint } from './components/HelpHint';
|
40
37
|
export * from './components/HelpHint';
|
41
38
|
export { default as Icon } from './components/Icon';
|
@@ -76,12 +73,8 @@ export { default as OverlayPanel } from './components/OverlayPanel';
|
|
76
73
|
export * from './components/OverlayPanel';
|
77
74
|
export { default as PageHeader } from './components/PageHeader';
|
78
75
|
export * from './components/PageHeader';
|
79
|
-
export { default as Panel } from './components/Panel';
|
80
|
-
export * from './components/Panel';
|
81
76
|
export { default as PasswordField } from './components/PasswordField';
|
82
77
|
export * from './components/PasswordField';
|
83
|
-
export { default as Popover } from './components/Popover';
|
84
|
-
export * from './components/Popover';
|
85
78
|
export { default as PopoverContainer } from './components/PopoverContainer';
|
86
79
|
export * from './components/PopoverContainer';
|
87
80
|
export { default as PopoverMenu } from './components/PopoverMenu';
|
@@ -274,7 +274,8 @@ export var Default = function Default() {
|
|
274
274
|
}, ___EmotionJSX(Chip, {
|
275
275
|
bg: "success.light",
|
276
276
|
textColor: "success.dark",
|
277
|
-
label: "New"
|
277
|
+
label: "New",
|
278
|
+
isUppercase: true
|
278
279
|
})) : null)), ___EmotionJSX(Box, {
|
279
280
|
isRow: true,
|
280
281
|
alignSelf: "center"
|
@@ -3,14 +3,12 @@ import React from 'react';
|
|
3
3
|
import Earth from 'mdi-react/EarthIcon';
|
4
4
|
import Cog from 'mdi-react/CogOutlineIcon';
|
5
5
|
import Button from '../components/Button/Button';
|
6
|
-
import Panel from '../components/Panel/Panel';
|
7
6
|
import Box from '../components/Box/Box';
|
8
7
|
import Icon from '../components/Icon/Icon';
|
9
8
|
import Text from '../components/Text/Text';
|
10
9
|
import Separator from '../components/Separator/Separator';
|
11
10
|
import TextField from '../components/TextField/TextField';
|
12
11
|
import TextAreaField from '../components/TextAreaField/TextAreaField';
|
13
|
-
import DropdownField from '../components/DropdownField/DropdownField';
|
14
12
|
import RadioGroupField from '../components/RadioGroupField/RadioGroupField';
|
15
13
|
import RadioField from '../components/RadioField/RadioField';
|
16
14
|
import Tabs from '../components/Tabs/Tabs';
|
@@ -96,10 +94,7 @@ export var Default = function Default() {
|
|
96
94
|
}), ___EmotionJSX(TextAreaField, {
|
97
95
|
mb: "lg",
|
98
96
|
label: "Description"
|
99
|
-
}), ___EmotionJSX(
|
100
|
-
label: "Category",
|
101
|
-
mb: "lg"
|
102
|
-
}, ___EmotionJSX("option", null, "Option 1"), ___EmotionJSX("option", null, "Option 2"), ___EmotionJSX("option", null, "Option 3")), ___EmotionJSX(RadioGroupField, {
|
97
|
+
}), ___EmotionJSX(RadioGroupField, {
|
103
98
|
label: "Required Fields",
|
104
99
|
variant: "radioGroupBasic"
|
105
100
|
}, ___EmotionJSX(RadioField, {
|
@@ -108,17 +103,5 @@ export var Default = function Default() {
|
|
108
103
|
}), ___EmotionJSX(RadioField, {
|
109
104
|
value: "B",
|
110
105
|
label: "Option B"
|
111
|
-
}))))
|
112
|
-
isVisible: visible,
|
113
|
-
width: "70%",
|
114
|
-
bg: "accent.99"
|
115
|
-
}, ___EmotionJSX(Box, {
|
116
|
-
p: "lg",
|
117
|
-
onClick: function onClick() {
|
118
|
-
return setVisible(!visible);
|
119
|
-
}
|
120
|
-
}, ___EmotionJSX(Box, {
|
121
|
-
p: "lg",
|
122
|
-
bg: "white"
|
123
|
-
}, ___EmotionJSX(Text, null, "Your content here."))))));
|
106
|
+
}))))));
|
124
107
|
};
|
@@ -82,11 +82,11 @@ export var Default = function Default() {
|
|
82
82
|
sx: {
|
83
83
|
position: 'absolute',
|
84
84
|
right: -30,
|
85
|
-
top: 5
|
85
|
+
top: 5,
|
86
|
+
width: 'auto'
|
86
87
|
},
|
87
88
|
type: "delete",
|
88
|
-
title: "Delete Field"
|
89
|
-
variant: "icon"
|
89
|
+
title: "Delete Field"
|
90
90
|
}, ___EmotionJSX(Icon, {
|
91
91
|
icon: TrashIcon,
|
92
92
|
size: 20,
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Box, Button, Text } from '../index';
|
3
|
+
import useCopyToClipboard from '../hooks/useCopyToClipboard';
|
4
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
5
|
+
export default {
|
6
|
+
title: 'Recipes/CopyToClipboard'
|
7
|
+
};
|
8
|
+
export var Default = function Default() {
|
9
|
+
var textToCopy = 'eyJraWQiOiI4YTg5MmY3ZS1iNTk1LTRkYWQtODBlNC0yMzA4ODkyZTczZDQiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJodHRwczovL2FwaS5waW5nb25lLmNvbSIsImF1dGhVcmwiOiJodHRwczovL2F1dGgucGluZ29uZS5jb20iLCJjb25zb2xlVXJsIjoiaHR0cHM6Ly9jb25zb2xlLnBpbmdvbmUuY29tIiwiZW52aXJvbm1lbnROYW1lIjoiTW9udGFuYSIsImVudmlyb25tZW50SWQiOiJhYzc2NWQ0Ny1kMDM2LTQ1MGUtODFjMS1mYjQ1NDMxMjM1NjYiLCJvcmdhbml6YXRpb25OYW1lIjoiaW50ZXJuYWxfZXJpa2FhbGRlYm9yZ2hfMjUyMDc1MDMxIiwib3JnYW5pemF0aW9uSWQiOiJkMDYzMmYwZi03YjQ2LTQ5ZjUtYjgyYS1kZWU5MWQ3MDY3ODYiLCJnYXRld2F5TmFtZSI6ImRzZHMiLCJnYXRld2F5SWQiOiJiMDVmNGU5Yy1jMzRiLTRlZTMtYTYyNS01ZGFiNjlkYTE1YTEiLCJnYXRld2F5VHlwZSI6IlBJTkdfRkVERVJBVEUiLCJ0YXJnZXRDbHVzdGVyRW52aXJvbm1lbnQiOiJQUk9EIiwidGFyZ2V0R2VvZ3JhcGh5IjoiTkEiLCJyZWdpb24iOiJOb3J0aCBBbWVyaWNhIiwianRpIjoiMTUwYTQ0OTktZjIyYi00YWVhLWIzY2UtYWM2YWY1NjVjNjk5IiwiaXNzIjoid3NzOi8vZ2F0ZXdheXMucGluZ29uZS5jb20iLCJpYXQiOjE2MjYyODEyMTZ9.JJ9wwqTxQWUwz2vmU0yE54xuYff51xbirzZuEUxd8GDzV45bnpbmx460CY8g9ccdmOjvfVF4RPPsawpKuMZH271tDlLZl67iknxDVWBZSih9K6v0RAmsmNriR4OyOFOkGrULCIz3ISyPWeItp1AVuue_8guWR63KzYg32aPC4SgmOrc2myq9N6XNU2H1KybETbG_s5-VU_cUqaXn7GUzhL2_W6CSVrrlE1cYfjC7pxMKFm4vvIw_KcNYVGO1K6oYgzRZ4A8toQHIdlGB8L-wkCt442LdC93OjoQdkLuGzmXnO8BUohWea-Dn35gGHoH-H1BRQTya_H9AKyWMxCw-vg';
|
10
|
+
var copyToClipboard = useCopyToClipboard(textToCopy);
|
11
|
+
return ___EmotionJSX(Box, {
|
12
|
+
bg: "accent.99",
|
13
|
+
py: "md",
|
14
|
+
px: "xl"
|
15
|
+
}, ___EmotionJSX(Text, {
|
16
|
+
sx: {
|
17
|
+
wordBreak: 'break-all'
|
18
|
+
}
|
19
|
+
}, textToCopy), ___EmotionJSX(Button, {
|
20
|
+
variant: "inline",
|
21
|
+
my: "lg",
|
22
|
+
onPress: copyToClipboard,
|
23
|
+
"aria-label": "Copy Text To Clipboard"
|
24
|
+
}, "Copy To Clipboard"));
|
25
|
+
};
|