@pingux/astro 0.41.0 → 1.0.0-alpha.10
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 +132 -0
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.js +1 -1
- package/lib/cjs/components/AccordionItem/AccordionItem.js +3 -1
- 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/FileInputField/index.js +18 -0
- package/lib/cjs/components/ListView/ListView.js +2 -1
- package/lib/cjs/components/ListViewItem/ListViewItem.js +14 -6
- package/lib/cjs/components/NumberField/NumberField.js +4 -2
- package/lib/cjs/components/NumberField/NumberField.test.js +15 -0
- package/lib/cjs/components/Tab/Tab.js +11 -4
- 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/hooks/useCopyToClipboard/index.js +18 -0
- package/lib/cjs/hooks/useCopyToClipboard/useCopyToClipboard.js +83 -0
- package/lib/cjs/hooks/useCopyToClipboard/useCopyToClipboard.test.js +79 -0
- package/lib/cjs/index.js +10 -0
- package/lib/cjs/recipes/ApplicationSearchDropdown.stories.js +310 -0
- package/lib/cjs/recipes/CopyToClipboard.stories.js +45 -0
- package/lib/cjs/recipes/RadioButtonsWithLinks.stories.js +146 -0
- package/lib/cjs/recipes/RowLineChart.stories.js +6 -1
- package/lib/cjs/recipes/ScrollableListView.stories.js +1 -1
- package/lib/cjs/styles/forms/input.js +11 -0
- package/lib/cjs/styles/variants/accordion.js +2 -2
- package/lib/cjs/styles/variants/boxes.js +23 -0
- package/lib/cjs/styles/variants/buttons.js +56 -1
- package/lib/cjs/styles/variants/tabs.js +1 -0
- package/lib/components/AccordionGridGroup/AccordionGridGroup.js +1 -1
- package/lib/components/AccordionItem/AccordionItem.js +3 -1
- 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/ListView/ListView.js +2 -1
- package/lib/components/ListViewItem/ListViewItem.js +14 -6
- package/lib/components/NumberField/NumberField.js +4 -2
- package/lib/components/NumberField/NumberField.test.js +9 -0
- package/lib/components/Tab/Tab.js +11 -4
- 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/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 -0
- package/lib/recipes/ApplicationSearchDropdown.stories.js +272 -0
- package/lib/recipes/CopyToClipboard.stories.js +25 -0
- package/lib/recipes/RadioButtonsWithLinks.stories.js +120 -0
- package/lib/recipes/RowLineChart.stories.js +6 -1
- package/lib/recipes/ScrollableListView.stories.js +1 -1
- package/lib/styles/forms/input.js +11 -0
- package/lib/styles/variants/accordion.js +2 -2
- package/lib/styles/variants/boxes.js +23 -0
- package/lib/styles/variants/buttons.js +56 -1
- package/lib/styles/variants/tabs.js +1 -0
- package/package.json +3 -2
@@ -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
|
});
|
@@ -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
@@ -36,6 +36,7 @@ export { default as DropdownField } from './components/DropdownField';
|
|
36
36
|
export * from './components/DropdownField';
|
37
37
|
export { default as FieldHelperText } from './components/FieldHelperText';
|
38
38
|
export * from './components/FieldHelperText';
|
39
|
+
export { default as FileInputField } from './components/FileInputField';
|
39
40
|
export { default as HelpHint } from './components/HelpHint';
|
40
41
|
export * from './components/HelpHint';
|
41
42
|
export { default as Icon } from './components/Icon';
|
@@ -0,0 +1,272 @@
|
|
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 _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
7
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
8
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
9
|
+
import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
|
10
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
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 _context; _forEachInstanceProperty(_context = ownKeys(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
16
|
+
|
17
|
+
import React, { useState, useRef, useMemo } from 'react';
|
18
|
+
import { useOverlayPosition } from '@react-aria/overlays';
|
19
|
+
import { useLayoutEffect } from '@react-aria/utils';
|
20
|
+
import SearchIcon from 'mdi-react/SearchIcon';
|
21
|
+
import Email from 'mdi-react/EmailIcon';
|
22
|
+
import Pin from 'mdi-react/PinIcon';
|
23
|
+
import { useFilter } from '@react-aria/i18n';
|
24
|
+
import { FocusScope, createFocusManager } from '@react-aria/focus';
|
25
|
+
import { ListView, Item, IconButton, Text, PopoverContainer, Box, Icon, SearchField } from '../index';
|
26
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
27
|
+
export default {
|
28
|
+
title: 'Recipes/ApplicationSearchDropdown'
|
29
|
+
};
|
30
|
+
var items = [{
|
31
|
+
key: 'Gmail',
|
32
|
+
application: 'Gmail',
|
33
|
+
description: 'Googles most finest email app used by bazillions of people',
|
34
|
+
logo: Email,
|
35
|
+
id: '1'
|
36
|
+
}, {
|
37
|
+
key: 'GAPG',
|
38
|
+
application: 'Google Apps Password Generator',
|
39
|
+
description: 'Generate passwords for all your Google Apps',
|
40
|
+
logo: Email,
|
41
|
+
id: '2'
|
42
|
+
}, {
|
43
|
+
key: 'GCalendar',
|
44
|
+
application: 'Google Calendar',
|
45
|
+
description: 'Get your life organized and never miss an appointment again',
|
46
|
+
logo: Email,
|
47
|
+
id: '3'
|
48
|
+
}, {
|
49
|
+
key: 'GDrive',
|
50
|
+
application: 'Google Drive',
|
51
|
+
description: 'Store all of your precious files up in the clouds',
|
52
|
+
logo: Email,
|
53
|
+
id: '4'
|
54
|
+
}, {
|
55
|
+
key: 'Gmail2',
|
56
|
+
application: 'Gmail2',
|
57
|
+
description: 'Googles most finest email app used by bazillions of people',
|
58
|
+
logo: Email,
|
59
|
+
id: '5'
|
60
|
+
}, {
|
61
|
+
key: 'GAPG2',
|
62
|
+
application: 'Google Apps Password Generator2',
|
63
|
+
description: 'Generate passwords for all your Google Apps',
|
64
|
+
logo: Email,
|
65
|
+
id: '6'
|
66
|
+
}, {
|
67
|
+
key: 'GCalendar2',
|
68
|
+
application: 'Google Calendar2',
|
69
|
+
description: 'Get your life organized and never miss an appointment again',
|
70
|
+
logo: Email,
|
71
|
+
id: '7'
|
72
|
+
}, {
|
73
|
+
key: 'GDrive2',
|
74
|
+
application: 'Google Drive2',
|
75
|
+
description: 'Store all of your precious files up in the clouds',
|
76
|
+
logo: Email,
|
77
|
+
id: '8'
|
78
|
+
}];
|
79
|
+
export var Default = function Default() {
|
80
|
+
var buttonRef = useRef();
|
81
|
+
var popoverRef = useRef();
|
82
|
+
|
83
|
+
var _useState = useState(false),
|
84
|
+
_useState2 = _slicedToArray(_useState, 2),
|
85
|
+
isOpen = _useState2[0],
|
86
|
+
setIsOpen = _useState2[1];
|
87
|
+
|
88
|
+
var focusManager = createFocusManager(popoverRef);
|
89
|
+
|
90
|
+
var _useOverlayPosition = useOverlayPosition({
|
91
|
+
targetRef: buttonRef,
|
92
|
+
overlayRef: popoverRef,
|
93
|
+
placement: 'bottom left',
|
94
|
+
isOpen: true
|
95
|
+
}),
|
96
|
+
overlayProps = _useOverlayPosition.overlayProps,
|
97
|
+
placement = _useOverlayPosition.placement,
|
98
|
+
updatePosition = _useOverlayPosition.updatePosition;
|
99
|
+
|
100
|
+
useLayoutEffect(function () {
|
101
|
+
requestAnimationFrame(function () {
|
102
|
+
updatePosition();
|
103
|
+
});
|
104
|
+
}, [updatePosition]);
|
105
|
+
|
106
|
+
var style = _objectSpread(_objectSpread({}, overlayProps.style), {}, {
|
107
|
+
minWidth: '380px',
|
108
|
+
maxHeight: '320px',
|
109
|
+
// shows 4 options
|
110
|
+
'& > div': {}
|
111
|
+
});
|
112
|
+
|
113
|
+
var _useFilter = useFilter({
|
114
|
+
sensitivity: 'base'
|
115
|
+
}),
|
116
|
+
startsWith = _startsWithInstanceProperty(_useFilter);
|
117
|
+
|
118
|
+
var _useState3 = useState(''),
|
119
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
120
|
+
filterValue = _useState4[0],
|
121
|
+
setFilterValue = _useState4[1];
|
122
|
+
|
123
|
+
var filteredItems = useMemo(function () {
|
124
|
+
return _filterInstanceProperty(items).call(items, function (item) {
|
125
|
+
return startsWith(item.application, filterValue);
|
126
|
+
});
|
127
|
+
}, [items, filterValue]);
|
128
|
+
|
129
|
+
var onKeyDown = function onKeyDown(e) {
|
130
|
+
if (e.key === 'ArrowDown') {
|
131
|
+
focusManager.focusNext();
|
132
|
+
}
|
133
|
+
};
|
134
|
+
|
135
|
+
var InnerHtml = function InnerHtml(props) {
|
136
|
+
var _useState5 = useState(false),
|
137
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
138
|
+
isPinned = _useState6[0],
|
139
|
+
setIsPinned = _useState6[1];
|
140
|
+
|
141
|
+
var item = props.item;
|
142
|
+
|
143
|
+
var onPinPress = function onPinPress() {
|
144
|
+
setIsPinned(!isPinned);
|
145
|
+
};
|
146
|
+
|
147
|
+
return ___EmotionJSX(Box, {
|
148
|
+
isRow: true
|
149
|
+
}, ___EmotionJSX(Icon, {
|
150
|
+
icon: item.logo,
|
151
|
+
mr: "md",
|
152
|
+
color: "text.primary",
|
153
|
+
size: 40,
|
154
|
+
alignSelf: "center",
|
155
|
+
ml: "-10px"
|
156
|
+
}), ___EmotionJSX(Box, {
|
157
|
+
alignSelf: "center",
|
158
|
+
sx: {
|
159
|
+
maxWidth: '260px'
|
160
|
+
}
|
161
|
+
}, ___EmotionJSX(Text, {
|
162
|
+
variant: "itemTitle",
|
163
|
+
alignSelf: "center",
|
164
|
+
mr: "auto",
|
165
|
+
sx: {
|
166
|
+
fontWeight: '700'
|
167
|
+
}
|
168
|
+
}, item.application), ___EmotionJSX(Text, {
|
169
|
+
variant: "itemSubtitle",
|
170
|
+
alignSelf: "center",
|
171
|
+
mr: "auto",
|
172
|
+
sx: {
|
173
|
+
fontSize: '15px'
|
174
|
+
}
|
175
|
+
}, item.description)), ___EmotionJSX(Box, {
|
176
|
+
alignSelf: "center"
|
177
|
+
}, ___EmotionJSX(IconButton, {
|
178
|
+
"aria-label": "Pin ".concat(item.application),
|
179
|
+
ml: "md",
|
180
|
+
alignSelf: "center",
|
181
|
+
onPress: function onPress() {
|
182
|
+
return onPinPress();
|
183
|
+
},
|
184
|
+
sx: {
|
185
|
+
'&.is-hovered': {
|
186
|
+
bg: 'transparent'
|
187
|
+
},
|
188
|
+
'&.is-pressed': {
|
189
|
+
'path': {
|
190
|
+
fill: 'active'
|
191
|
+
}
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}, ___EmotionJSX(Icon, {
|
195
|
+
icon: Pin,
|
196
|
+
sx: {
|
197
|
+
transform: 'rotate(45deg)',
|
198
|
+
'& > path': {
|
199
|
+
fill: isPinned ? 'success.bright' : 'neutral.50'
|
200
|
+
}
|
201
|
+
}
|
202
|
+
}))));
|
203
|
+
};
|
204
|
+
|
205
|
+
return ___EmotionJSX(Box, {
|
206
|
+
isRow: true
|
207
|
+
}, ___EmotionJSX(FocusScope, null, ___EmotionJSX(SearchField, {
|
208
|
+
ref: buttonRef,
|
209
|
+
icon: SearchIcon,
|
210
|
+
"aria-label": "Search Groups",
|
211
|
+
width: "380px",
|
212
|
+
controlProps: {
|
213
|
+
sx: {
|
214
|
+
borderRadius: '20px'
|
215
|
+
}
|
216
|
+
},
|
217
|
+
inputValue: filterValue,
|
218
|
+
onChange: setFilterValue,
|
219
|
+
onKeyUp: onKeyDown,
|
220
|
+
mr: "lg",
|
221
|
+
onFocus: function onFocus() {
|
222
|
+
return setIsOpen(true);
|
223
|
+
},
|
224
|
+
onBlur: function onBlur() {
|
225
|
+
return setIsOpen(false);
|
226
|
+
}
|
227
|
+
}), ___EmotionJSX(PopoverContainer, {
|
228
|
+
isOpen: isOpen && filteredItems.length > 0,
|
229
|
+
hasNoArrow: true,
|
230
|
+
isNonModal: true,
|
231
|
+
isDismissable: false,
|
232
|
+
ref: popoverRef,
|
233
|
+
placement: placement,
|
234
|
+
style: style,
|
235
|
+
type: "grid",
|
236
|
+
onFocus: function onFocus() {
|
237
|
+
return setIsOpen(true);
|
238
|
+
},
|
239
|
+
onBlur: function onBlur() {
|
240
|
+
return setIsOpen(false);
|
241
|
+
}
|
242
|
+
}, ___EmotionJSX(ListView, {
|
243
|
+
items: filteredItems,
|
244
|
+
onSelectionChange: function onSelectionChange() {
|
245
|
+
return setIsOpen(!isOpen);
|
246
|
+
},
|
247
|
+
rowProps: {
|
248
|
+
sx: {
|
249
|
+
bg: 'red',
|
250
|
+
padding: '-4px'
|
251
|
+
}
|
252
|
+
},
|
253
|
+
padding: "-4px"
|
254
|
+
}, function (item) {
|
255
|
+
return ___EmotionJSX(Item, {
|
256
|
+
key: item.name,
|
257
|
+
textValue: item.name,
|
258
|
+
"data-id": item.key,
|
259
|
+
hasSeparator: false,
|
260
|
+
listItemProps: {
|
261
|
+
sx: {
|
262
|
+
bg: 'white',
|
263
|
+
'&.is-hovered': {
|
264
|
+
bg: 'accent.99'
|
265
|
+
}
|
266
|
+
}
|
267
|
+
}
|
268
|
+
}, ___EmotionJSX(InnerHtml, {
|
269
|
+
item: item
|
270
|
+
}));
|
271
|
+
}))));
|
272
|
+
};
|
@@ -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
|
+
};
|