@pingux/astro 2.97.0 → 2.98.0-alpha.1
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/lib/cjs/components/ListView/ListView.js +15 -2
- package/lib/cjs/components/ListView/ListView.stories.d.ts +1 -0
- package/lib/cjs/components/ListView/ListView.stories.js +157 -33
- package/lib/cjs/components/ListView/ListView.test.js +171 -77
- package/lib/cjs/components/Radio/Radio.d.ts +12 -0
- package/lib/cjs/components/Radio/Radio.js +2 -1
- package/lib/cjs/components/Radio/Radio.styles.d.ts +53 -0
- package/lib/cjs/components/Radio/Radio.styles.js +4 -2
- package/lib/cjs/components/Radio/index.d.ts +1 -0
- package/lib/cjs/components/RadioField/RadioField.d.ts +12 -0
- package/lib/cjs/components/RadioField/RadioField.js +6 -57
- package/lib/cjs/components/RadioField/RadioField.test.d.ts +1 -0
- package/lib/cjs/components/RadioField/RadioField.test.js +7 -4
- package/lib/cjs/components/RadioField/index.d.ts +2 -0
- package/lib/cjs/components/RadioGroupField/RadioGroupField.d.ts +4 -0
- package/lib/cjs/components/RadioGroupField/RadioGroupField.js +2 -47
- package/lib/cjs/components/RadioGroupField/RadioGroupField.stories.d.ts +42 -0
- package/lib/cjs/components/RadioGroupField/RadioGroupField.stories.js +7 -0
- package/lib/cjs/components/RadioGroupField/RadioGroupField.test.d.ts +1 -0
- package/lib/cjs/components/RadioGroupField/RadioGroupField.test.js +4 -4
- package/lib/cjs/components/RadioGroupField/index.d.ts +1 -0
- package/lib/cjs/hooks/useLoadPrev/index.d.ts +1 -0
- package/lib/cjs/hooks/useLoadPrev/index.js +14 -0
- package/lib/cjs/hooks/useLoadPrev/useLoadPrev.d.ts +2 -0
- package/lib/cjs/hooks/useLoadPrev/useLoadPrev.js +35 -0
- package/lib/cjs/hooks/useLoadPrev/useLoadPrev.test.d.ts +1 -0
- package/lib/cjs/hooks/useLoadPrev/useLoadPrev.test.js +87 -0
- package/lib/cjs/types/listView.d.ts +1 -0
- package/lib/cjs/types/radio.d.ts +3 -0
- package/lib/cjs/types/radio.js +6 -0
- package/lib/cjs/types/radioField.d.ts +42 -0
- package/lib/cjs/types/radioField.js +6 -0
- package/lib/cjs/types/radioGroupField.d.ts +15 -0
- package/lib/cjs/types/radioGroupField.js +6 -0
- package/lib/cjs/utils/designUtils/figmaLinks.d.ts +3 -0
- package/lib/cjs/utils/designUtils/figmaLinks.js +3 -0
- package/lib/cjs/utils/devUtils/constants/loadingStates.js +2 -1
- package/lib/components/ListView/ListView.js +15 -2
- package/lib/components/ListView/ListView.stories.js +125 -2
- package/lib/components/ListView/ListView.test.js +168 -77
- package/lib/components/Radio/Radio.js +1 -2
- package/lib/components/Radio/Radio.styles.js +4 -2
- package/lib/components/RadioField/RadioField.js +8 -59
- package/lib/components/RadioField/RadioField.test.js +7 -4
- package/lib/components/RadioGroupField/RadioGroupField.js +0 -47
- package/lib/components/RadioGroupField/RadioGroupField.stories.js +7 -0
- package/lib/components/RadioGroupField/RadioGroupField.test.js +4 -4
- package/lib/hooks/useLoadPrev/index.js +1 -0
- package/lib/hooks/useLoadPrev/useLoadPrev.js +27 -0
- package/lib/hooks/useLoadPrev/useLoadPrev.test.js +78 -0
- package/lib/types/radio.js +1 -0
- package/lib/types/radioField.js +1 -0
- package/lib/types/radioGroupField.js +1 -0
- package/lib/utils/designUtils/figmaLinks.js +3 -0
- package/lib/utils/devUtils/constants/loadingStates.js +2 -1
- package/package.json +1 -1
@@ -16,7 +16,9 @@ var defaultProps = {
|
|
16
16
|
value: testValue
|
17
17
|
};
|
18
18
|
var defaultState = {
|
19
|
-
setLastFocusedValue: function setLastFocusedValue() {
|
19
|
+
setLastFocusedValue: function setLastFocusedValue() {
|
20
|
+
return jest.fn();
|
21
|
+
}
|
20
22
|
};
|
21
23
|
var getComponent = function getComponent() {
|
22
24
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
@@ -69,11 +71,12 @@ test('radio with checked content does not display if not checked', function () {
|
|
69
71
|
});
|
70
72
|
test('radio with checked content displays if checked', function () {
|
71
73
|
var testContent = 'test content';
|
74
|
+
var customState = {
|
75
|
+
selectedValue: testValue
|
76
|
+
};
|
72
77
|
getComponent({
|
73
78
|
checkedContent: ___EmotionJSX("div", null, testContent)
|
74
|
-
},
|
75
|
-
selectedValue: testValue
|
76
|
-
});
|
79
|
+
}, customState);
|
77
80
|
var content = screen.queryByText(testContent);
|
78
81
|
expect(content).toBeInTheDocument();
|
79
82
|
});
|
@@ -1,27 +1,12 @@
|
|
1
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
3
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
4
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
5
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
6
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
7
|
-
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
|
-
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
11
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
12
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
13
2
|
import React, { forwardRef, useMemo } from 'react';
|
14
3
|
import { useRadioGroup } from 'react-aria';
|
15
4
|
import { useRadioGroupState } from 'react-stately';
|
16
|
-
import PropTypes from 'prop-types';
|
17
5
|
import { v4 as uuid } from 'uuid';
|
18
6
|
import { Box, FieldHelperText, Label } from '../..';
|
19
7
|
import { usePropWarning, useStatusClasses } from '../../hooks';
|
20
8
|
import ORIENTATION from '../../utils/devUtils/constants/orientation';
|
21
9
|
import { getPendoID } from '../../utils/devUtils/constants/pendoID';
|
22
|
-
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
23
|
-
import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
|
24
|
-
import { statusPropTypes } from '../../utils/docUtils/statusProp';
|
25
10
|
import { RadioContext } from '../RadioField';
|
26
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
27
12
|
var displayName = 'RadioGroupField';
|
@@ -73,36 +58,4 @@ var RadioGroupField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
73
58
|
id: helperTextId
|
74
59
|
}, helperText));
|
75
60
|
});
|
76
|
-
RadioGroupField.propTypes = _objectSpread(_objectSpread(_objectSpread({
|
77
|
-
/** The name of the RadioGroupField, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name_and_radio_buttons). */
|
78
|
-
name: PropTypes.string,
|
79
|
-
/** The current value (controlled). */
|
80
|
-
value: PropTypes.string,
|
81
|
-
/** The default value (uncontrolled). */
|
82
|
-
defaultValue: PropTypes.string,
|
83
|
-
/** Text to display after the radio group label. Useful for errors or other info. */
|
84
|
-
helperText: PropTypes.node,
|
85
|
-
/** If present this prop will cause a help hint to render in the label of the field. */
|
86
|
-
hintText: PropTypes.string,
|
87
|
-
/** Determines the arrangement of the radios. */
|
88
|
-
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
89
|
-
/**
|
90
|
-
* Handler that is called when the value changes.
|
91
|
-
*
|
92
|
-
* `(newValue) => void`
|
93
|
-
*/
|
94
|
-
onChange: PropTypes.func,
|
95
|
-
/** Whether the radio group is disabled. */
|
96
|
-
isDisabled: PropTypes.bool,
|
97
|
-
/** Whether user input is required on the input before form submission. */
|
98
|
-
isRequired: PropTypes.bool,
|
99
|
-
/**
|
100
|
-
* The content to display as the label. If not set, It is recommended to set an aria-label or
|
101
|
-
* aria-labelledby attribute for accessibility.
|
102
|
-
*/
|
103
|
-
label: PropTypes.node,
|
104
|
-
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
105
|
-
id: PropTypes.string
|
106
|
-
}, statusPropTypes), ariaAttributesBasePropTypes), inputFieldAttributesBasePropTypes);
|
107
|
-
RadioGroupField.displayName = displayName;
|
108
61
|
export default RadioGroupField;
|
@@ -13,6 +13,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
13
13
|
import React, { useState } from 'react';
|
14
14
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
15
15
|
import { RadioField, RadioGroupField } from '../../index';
|
16
|
+
import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks';
|
16
17
|
import { ariaAttributeBaseArgTypes } from '../../utils/docUtils/ariaAttributes';
|
17
18
|
import { statusArgTypes } from '../../utils/docUtils/statusProp';
|
18
19
|
import RadioGroupFieldReadme from './RadioGroupField.mdx';
|
@@ -72,6 +73,12 @@ export var Default = function Default(args) {
|
|
72
73
|
label: "C"
|
73
74
|
}));
|
74
75
|
};
|
76
|
+
Default.parameters = {
|
77
|
+
design: {
|
78
|
+
type: 'figma',
|
79
|
+
url: FIGMA_LINKS.radioGroup["default"]
|
80
|
+
}
|
81
|
+
};
|
75
82
|
export var Controlled = function Controlled() {
|
76
83
|
var _useState = useState('A'),
|
77
84
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -30,16 +30,16 @@ var defaultProps = {
|
|
30
30
|
var getComponent = function getComponent() {
|
31
31
|
var groupProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
32
32
|
var radioProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
33
|
-
return render(___EmotionJSX(RadioGroupField, _extends({}, defaultProps, groupProps), ___EmotionJSX(RadioField,
|
33
|
+
return render(___EmotionJSX(RadioGroupField, _extends({}, defaultProps, groupProps), ___EmotionJSX(RadioField, {
|
34
34
|
value: testValues[0],
|
35
35
|
label: testValues[0]
|
36
|
-
}
|
36
|
+
}), ___EmotionJSX(RadioField, {
|
37
37
|
value: testValues[1],
|
38
38
|
label: testValues[1]
|
39
|
-
}
|
39
|
+
}), ___EmotionJSX(RadioField, {
|
40
40
|
value: testValues[2],
|
41
41
|
label: testValues[2]
|
42
|
-
}
|
42
|
+
})));
|
43
43
|
};
|
44
44
|
|
45
45
|
// Needs to be added to each components test file
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './useLoadPrev';
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { useCallback, useLayoutEffect, useRef } from 'react';
|
2
|
+
import { useEvent } from '@react-aria/utils';
|
3
|
+
var useLoadPrev = function useLoadPrev(props, ref) {
|
4
|
+
var isLoading = props.isLoading,
|
5
|
+
onLoadPrev = props.onLoadPrev,
|
6
|
+
items = props.items;
|
7
|
+
var isLoadingRef = useRef(isLoading);
|
8
|
+
var prevProps = useRef(props);
|
9
|
+
var onScroll = useCallback(function () {
|
10
|
+
if (ref.current && !isLoadingRef.current && onLoadPrev) {
|
11
|
+
var rc = ref.current;
|
12
|
+
var shouldLoadPrev = rc.scrollTop === 0;
|
13
|
+
if (shouldLoadPrev) {
|
14
|
+
isLoadingRef.current = true;
|
15
|
+
onLoadPrev();
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}, [onLoadPrev, ref]);
|
19
|
+
useLayoutEffect(function () {
|
20
|
+
if (props !== prevProps.current) {
|
21
|
+
isLoadingRef.current = isLoading;
|
22
|
+
prevProps.current = props;
|
23
|
+
}
|
24
|
+
}, [isLoading, onLoadPrev, props, ref, items]);
|
25
|
+
useEvent(ref, 'scroll', onScroll);
|
26
|
+
};
|
27
|
+
export default useLoadPrev;
|
@@ -0,0 +1,78 @@
|
|
1
|
+
import React, { useRef } from 'react';
|
2
|
+
import { fireEvent } from '@testing-library/react';
|
3
|
+
import Box from '../../components/Box';
|
4
|
+
import { render, screen } from '../../utils/testUtils/testWrapper';
|
5
|
+
import useLoadPrev from './useLoadPrev';
|
6
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
7
|
+
var onLoadPrev = jest.fn();
|
8
|
+
var TestComponent = function TestComponent(props) {
|
9
|
+
var items = props.items;
|
10
|
+
var ref = useRef(null);
|
11
|
+
useLoadPrev({
|
12
|
+
isLoading: false,
|
13
|
+
onLoadPrev: onLoadPrev,
|
14
|
+
items: items
|
15
|
+
}, ref);
|
16
|
+
return ___EmotionJSX(Box, {
|
17
|
+
sx: {
|
18
|
+
height: '400px',
|
19
|
+
maxHeight: '400px',
|
20
|
+
overflowY: 'scroll'
|
21
|
+
},
|
22
|
+
"data-testid": "outerbox",
|
23
|
+
ref: ref
|
24
|
+
}, "content", ___EmotionJSX(Box, {
|
25
|
+
sx: {
|
26
|
+
height: '800px',
|
27
|
+
minHeight: '800px'
|
28
|
+
},
|
29
|
+
"data-testid": "innerbox"
|
30
|
+
}, "inner content"));
|
31
|
+
};
|
32
|
+
describe('useLoadPrev', function () {
|
33
|
+
it('onLoadPrev is called when scrolling to the top', function () {
|
34
|
+
var _render = render(___EmotionJSX(TestComponent, {
|
35
|
+
items: [1, 2, 3, 4]
|
36
|
+
})),
|
37
|
+
rerender = _render.rerender;
|
38
|
+
var listView = screen.getByTestId('outerbox');
|
39
|
+
fireEvent.scroll(listView, {
|
40
|
+
target: {
|
41
|
+
scrollY: 450
|
42
|
+
}
|
43
|
+
});
|
44
|
+
fireEvent.scroll(listView, {
|
45
|
+
target: {
|
46
|
+
scrollY: 0
|
47
|
+
}
|
48
|
+
});
|
49
|
+
expect(onLoadPrev).toHaveBeenCalledTimes(1);
|
50
|
+
// should not call because props have not changed
|
51
|
+
fireEvent.scroll(listView, {
|
52
|
+
target: {
|
53
|
+
scrollY: 450
|
54
|
+
}
|
55
|
+
});
|
56
|
+
fireEvent.scroll(listView, {
|
57
|
+
target: {
|
58
|
+
scrollY: 0
|
59
|
+
}
|
60
|
+
});
|
61
|
+
expect(onLoadPrev).toHaveBeenCalledTimes(1);
|
62
|
+
// will call becuase props have changed.
|
63
|
+
rerender(___EmotionJSX(TestComponent, {
|
64
|
+
items: [1, 2, 3, 4, 5]
|
65
|
+
}));
|
66
|
+
fireEvent.scroll(listView, {
|
67
|
+
target: {
|
68
|
+
scrollY: 450
|
69
|
+
}
|
70
|
+
});
|
71
|
+
fireEvent.scroll(listView, {
|
72
|
+
target: {
|
73
|
+
scrollY: 0
|
74
|
+
}
|
75
|
+
});
|
76
|
+
expect(onLoadPrev).toHaveBeenCalledTimes(2);
|
77
|
+
});
|
78
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -149,6 +149,9 @@ export var FIGMA_LINKS = {
|
|
149
149
|
popoverMenu: {
|
150
150
|
"default": 'https://www.figma.com/file/Oa6VYtJcUJzEJuuRp0p4ls/Astro?type=design&node-id=0%3A3073&t=We3h7LaaFJQnxdSy-1'
|
151
151
|
},
|
152
|
+
radioGroup: {
|
153
|
+
"default": 'https://embed.figma.com/design/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?m=auto&node-id=3613-12435&embed-host=share'
|
154
|
+
},
|
152
155
|
requirementsList: {
|
153
156
|
"default": 'https://www.figma.com/file/Oa6VYtJcUJzEJuuRp0p4ls/Astro?type=design&node-id=0%3A4039&t=We3h7LaaFJQnxdSy-1'
|
154
157
|
},
|