@pingux/astro 2.33.0-alpha.0 → 2.33.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/lib/cjs/components/ButtonBar/ButtonBar.stories.js +61 -5
- package/lib/cjs/components/Tabs/Tabs.stories.js +2 -2
- package/lib/cjs/components/Tabs/Tabs.style.js +0 -1
- package/lib/cjs/hooks/useComponentToggle/useComponentToggle.js +1 -3
- package/lib/cjs/hooks/useField/useField.d.ts +33 -35
- package/lib/cjs/hooks/useField/useField.js +1 -1
- package/lib/cjs/hooks/useOverlayPanelState/index.d.ts +1 -0
- package/lib/cjs/hooks/useOverlayPanelState/useOverlayPanelState.d.ts +32 -0
- package/lib/cjs/hooks/useOverlayPanelState/useOverlayPanelState.js +0 -10
- package/lib/cjs/hooks/useOverlayPanelState/useOverlayPanelState.test.d.ts +1 -0
- package/lib/cjs/hooks/useProgressiveState/index.d.ts +1 -0
- package/lib/cjs/hooks/useProgressiveState/useProgressiveState.d.ts +11 -0
- package/lib/cjs/hooks/useProgressiveState/useProgressiveState.js +3 -6
- package/lib/cjs/hooks/useProgressiveState/useProgressiveState.test.d.ts +1 -0
- package/lib/cjs/hooks/useProgressiveState/useProgressiveState.test.js +7 -16
- package/lib/cjs/hooks/usePropWarning/index.d.ts +1 -0
- package/lib/cjs/hooks/usePropWarning/usePropWarning.d.ts +13 -0
- package/lib/cjs/hooks/usePropWarning/usePropWarning.js +0 -8
- package/lib/cjs/hooks/usePropWarning/usePropWarning.test.d.ts +1 -0
- package/lib/cjs/hooks/usePropWarning/usePropWarning.test.js +13 -9
- package/lib/cjs/hooks/useRockerButton/index.d.ts +1 -0
- package/lib/cjs/hooks/useRockerButton/useRockerButton.d.ts +241 -0
- package/lib/cjs/hooks/useSelectField/index.d.ts +1 -0
- package/lib/cjs/hooks/useSelectField/useSelectField.d.ts +55 -0
- package/lib/cjs/hooks/useSelectField/useSelectField.js +10 -10
- package/lib/cjs/types/item.d.ts +4 -7
- package/lib/cjs/types/popoverContainer.d.ts +1 -0
- package/lib/cjs/types/shared/style.d.ts +6 -0
- package/lib/cjs/utils/designUtils/figmaLinks.js +4 -2
- package/lib/components/ButtonBar/ButtonBar.stories.js +57 -3
- package/lib/components/Tabs/Tabs.stories.js +3 -3
- package/lib/components/Tabs/Tabs.style.js +0 -1
- package/lib/hooks/useComponentToggle/useComponentToggle.js +1 -3
- package/lib/hooks/useField/useField.js +2 -0
- package/lib/hooks/useOverlayPanelState/useOverlayPanelState.js +0 -11
- package/lib/hooks/useProgressiveState/useProgressiveState.js +3 -7
- package/lib/hooks/useProgressiveState/useProgressiveState.test.js +7 -16
- package/lib/hooks/usePropWarning/usePropWarning.js +0 -8
- package/lib/hooks/usePropWarning/usePropWarning.test.js +13 -9
- package/lib/hooks/useSelectField/useSelectField.js +11 -9
- package/lib/utils/designUtils/figmaLinks.js +4 -2
- package/package.json +1 -1
@@ -1,26 +1,16 @@
|
|
1
|
-
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
1
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
3
|
-
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
4
|
-
var _excluded = ["count"];
|
5
2
|
import React from 'react';
|
6
3
|
import { render, screen } from '@testing-library/react';
|
7
4
|
import { renderHook } from '@testing-library/react-hooks';
|
8
5
|
import userEvent from '@testing-library/user-event';
|
9
6
|
import useProgressiveState from './useProgressiveState';
|
10
7
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
11
|
-
var testId = 'test';
|
12
|
-
var defaultProps = {
|
13
|
-
'data-testid': testId
|
14
|
-
};
|
15
8
|
var hookProps = {
|
16
9
|
prop: 'count',
|
17
10
|
initial: 0
|
18
11
|
};
|
19
|
-
|
20
|
-
/* eslint-disable react/prop-types */
|
21
12
|
var TestComponent = function TestComponent(_ref) {
|
22
|
-
var count = _ref.count
|
23
|
-
others = _objectWithoutProperties(_ref, _excluded);
|
13
|
+
var count = _ref.count;
|
24
14
|
var _useProgressiveState = useProgressiveState(count, 0),
|
25
15
|
_useProgressiveState2 = _slicedToArray(_useProgressiveState, 2),
|
26
16
|
countVal = _useProgressiveState2[0],
|
@@ -28,18 +18,19 @@ var TestComponent = function TestComponent(_ref) {
|
|
28
18
|
var handleClick = function handleClick() {
|
29
19
|
return setCountVal(countVal + 1);
|
30
20
|
};
|
31
|
-
return ___EmotionJSX("button",
|
21
|
+
return ___EmotionJSX("button", {
|
22
|
+
type: "button",
|
32
23
|
onClick: handleClick
|
33
|
-
}
|
24
|
+
}, countVal);
|
34
25
|
};
|
35
26
|
var getComponent = function getComponent() {
|
36
27
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
37
|
-
return render(___EmotionJSX(TestComponent,
|
28
|
+
return render(___EmotionJSX(TestComponent, props));
|
38
29
|
};
|
39
30
|
describe('State Utils', function () {
|
40
31
|
it('should update the state when no prop is provided', function () {
|
41
32
|
getComponent();
|
42
|
-
var component = screen.
|
33
|
+
var component = screen.getByRole('button');
|
43
34
|
expect(component).toHaveTextContent('0');
|
44
35
|
userEvent.click(component);
|
45
36
|
expect(component).toHaveTextContent('1');
|
@@ -50,7 +41,7 @@ describe('State Utils', function () {
|
|
50
41
|
getComponent({
|
51
42
|
count: 5
|
52
43
|
});
|
53
|
-
var component = screen.
|
44
|
+
var component = screen.getByRole('button');
|
54
45
|
expect(component).toHaveTextContent('5');
|
55
46
|
userEvent.click(component);
|
56
47
|
expect(component).toHaveTextContent('5');
|
@@ -2,14 +2,6 @@ import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
2
2
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
3
3
|
import { useEffect } from 'react';
|
4
4
|
var alreadyShown = new _Set();
|
5
|
-
|
6
|
-
/**
|
7
|
-
* Provides a development-only console warning for props that we don't want consumers to use
|
8
|
-
* @param {Object} props - The whole props object
|
9
|
-
* @param {String} propToWarn - Specify prop to warn not to use
|
10
|
-
* @param {String} propToUse - Specify prop that should be used instead
|
11
|
-
* @param {Boolean} [allowDuplicates] - If allow duplicate warning messages
|
12
|
-
*/
|
13
5
|
var usePropWarning = function usePropWarning(props, propToWarn, propToUse, allowDuplicates) {
|
14
6
|
useEffect(function () {
|
15
7
|
if (!allowDuplicates && alreadyShown.has(propToWarn)) {
|
@@ -4,7 +4,7 @@ describe('usePropWarning', function () {
|
|
4
4
|
beforeEach(function () {
|
5
5
|
process.env.NODE_ENV = 'development';
|
6
6
|
global.console.warn = function () {
|
7
|
-
return jest.
|
7
|
+
return jest.fn();
|
8
8
|
}; // eslint-disable-line no-console
|
9
9
|
});
|
10
10
|
|
@@ -13,8 +13,9 @@ describe('usePropWarning', function () {
|
|
13
13
|
jest.clearAllMocks();
|
14
14
|
});
|
15
15
|
test('default', function () {
|
16
|
-
var props = {
|
17
|
-
|
16
|
+
var props = {
|
17
|
+
disabled: true
|
18
|
+
};
|
18
19
|
var spy = jest.spyOn(console, 'warn');
|
19
20
|
expect(spy).not.toHaveBeenCalled();
|
20
21
|
renderHook(function () {
|
@@ -23,8 +24,9 @@ describe('usePropWarning', function () {
|
|
23
24
|
expect(spy).toHaveBeenCalledTimes(1);
|
24
25
|
});
|
25
26
|
test('does not warn if prop does not exist', function () {
|
26
|
-
var props = {
|
27
|
-
|
27
|
+
var props = {
|
28
|
+
isDisabled: true
|
29
|
+
};
|
28
30
|
var spy = jest.spyOn(console, 'warn');
|
29
31
|
expect(spy).not.toHaveBeenCalled();
|
30
32
|
renderHook(function () {
|
@@ -33,8 +35,9 @@ describe('usePropWarning', function () {
|
|
33
35
|
expect(spy).not.toHaveBeenCalled();
|
34
36
|
});
|
35
37
|
test('showns duplicated messages if explicitly allowed', function () {
|
36
|
-
var props = {
|
37
|
-
|
38
|
+
var props = {
|
39
|
+
disabled: true
|
40
|
+
};
|
38
41
|
var spy = jest.spyOn(console, 'warn');
|
39
42
|
renderHook(function () {
|
40
43
|
return usePropWarning(props, 'disabled', 'isDisabled', true);
|
@@ -46,8 +49,9 @@ describe('usePropWarning', function () {
|
|
46
49
|
});
|
47
50
|
test('does not warn if it is in production environment', function () {
|
48
51
|
process.env.NODE_ENV = 'production';
|
49
|
-
var props = {
|
50
|
-
|
52
|
+
var props = {
|
53
|
+
disabled: true
|
54
|
+
};
|
51
55
|
var spy = jest.spyOn(console, 'warn');
|
52
56
|
expect(spy).not.toHaveBeenCalled();
|
53
57
|
renderHook(function () {
|
@@ -16,8 +16,10 @@ import React, { useCallback, useImperativeHandle, useLayoutEffect, useRef, useSt
|
|
16
16
|
import { DismissButton, FocusScope, useOverlayPosition, useSelect } from 'react-aria';
|
17
17
|
import { useSelectState } from 'react-stately';
|
18
18
|
import { useResizeObserver } from '@react-aria/utils';
|
19
|
+
// eslint-disable-next-line import/no-unresolved
|
20
|
+
|
19
21
|
import { modes } from '../../components/Label/constants';
|
20
|
-
import ListBox from '../../components/ListBox';
|
22
|
+
import ListBox from '../../components/ListBox/ListBox';
|
21
23
|
import PopoverContainer from '../../components/PopoverContainer';
|
22
24
|
import ScrollBox from '../../components/ScrollBox';
|
23
25
|
import { useColumnStyles, useDeprecationWarning, useField } from '..';
|
@@ -53,8 +55,7 @@ var useSelectField = function useSelectField(props, ref) {
|
|
53
55
|
// We use falsy booleans as defaults, but React Aria has this as true by default so we need to
|
54
56
|
// negate this.
|
55
57
|
var shouldFlip = !isNotFlippable;
|
56
|
-
var selectProps = _objectSpread({
|
57
|
-
children: children,
|
58
|
+
var selectProps = _objectSpread(_objectSpread({
|
58
59
|
defaultSelectedKey: defaultSelectedKey,
|
59
60
|
defaultText: defaultText,
|
60
61
|
disabledKeys: disabledKeys,
|
@@ -76,13 +77,14 @@ var useSelectField = function useSelectField(props, ref) {
|
|
76
77
|
disallowEmptySelection: disallowEmptySelection,
|
77
78
|
// must match React Aria API
|
78
79
|
shouldFlip: shouldFlip
|
79
|
-
}, controlProps)
|
80
|
+
}, controlProps), {}, {
|
81
|
+
children: children
|
82
|
+
});
|
80
83
|
// Create state based on the incoming props
|
81
84
|
var state = useSelectState(selectProps);
|
82
85
|
var popoverRef = useRef();
|
83
|
-
var triggerRef = useRef();
|
84
86
|
var listBoxRef = useRef();
|
85
|
-
|
87
|
+
var triggerRef = useRef();
|
86
88
|
/* istanbul ignore next */
|
87
89
|
useImperativeHandle(ref, function () {
|
88
90
|
return triggerRef.current;
|
@@ -109,7 +111,7 @@ var useSelectField = function useSelectField(props, ref) {
|
|
109
111
|
placeholder: props.labelMode === modes.FLOAT ? '' : placeholder,
|
110
112
|
labelProps: _objectSpread(_objectSpread({}, props.labelProps), labelProps),
|
111
113
|
containerProps: _objectSpread({
|
112
|
-
isFloatLabelActive: state.selectedItem
|
114
|
+
isFloatLabelActive: !!state.selectedItem
|
113
115
|
}, props.containerProps)
|
114
116
|
})),
|
115
117
|
fieldContainerProps = _useField.fieldContainerProps,
|
@@ -141,7 +143,7 @@ var useSelectField = function useSelectField(props, ref) {
|
|
141
143
|
}, [state.isOpen, updatePosition]);
|
142
144
|
|
143
145
|
// Measure the width of the input to inform the width of the listbox (below).
|
144
|
-
var _useState = useState(
|
146
|
+
var _useState = useState(0),
|
145
147
|
_useState2 = _slicedToArray(_useState, 2),
|
146
148
|
buttonWidth = _useState2[0],
|
147
149
|
setButtonWidth = _useState2[1];
|
@@ -150,7 +152,7 @@ var useSelectField = function useSelectField(props, ref) {
|
|
150
152
|
if (triggerRef.current) {
|
151
153
|
setButtonWidth(triggerRef.current.offsetWidth);
|
152
154
|
}
|
153
|
-
}, [triggerRef, setButtonWidth
|
155
|
+
}, [triggerRef, setButtonWidth]);
|
154
156
|
useResizeObserver({
|
155
157
|
ref: triggerRef,
|
156
158
|
onResize: onResize
|
@@ -29,8 +29,10 @@ export var FIGMA_LINKS = {
|
|
29
29
|
"default": 'https://www.figma.com/file/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?type=design&node-id=0-1&t=8Wwd3tIBh3GEjCJB-0'
|
30
30
|
},
|
31
31
|
buttonBar: {
|
32
|
-
"default": 'https://www.figma.com/file/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?node-id=
|
33
|
-
rightAligned: 'https://www.figma.com/file/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?node-id=
|
32
|
+
"default": 'https://www.figma.com/file/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?node-id=46080%3A753&mode=dev',
|
33
|
+
rightAligned: 'https://www.figma.com/file/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?node-id=46080%3A770&mode=dev',
|
34
|
+
secondary: 'https://www.figma.com/file/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?node-id=46080%3A778&mode=dev',
|
35
|
+
secondaryRightAligned: 'https://www.figma.com/file/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?node-id=46080%3A788&mode=dev'
|
34
36
|
},
|
35
37
|
calendar: {
|
36
38
|
"default": 'https://www.figma.com/file/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?type=design&node-id=6373%3A25490&t=BoHXzVpQq9Lf7MaU-1'
|