@pingux/astro 2.25.0 → 2.26.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/AccordionGroup/Accordion.styles.js +8 -5
- package/lib/cjs/components/AccordionGroup/AccordionGroup.js +8 -4
- package/lib/cjs/components/AccordionGroup/AccordionGroup.stories.js +44 -7
- package/lib/cjs/components/AccordionGroup/AccordionGroup.test.js +52 -0
- package/lib/cjs/components/AccordionItem/AccordionItem.js +18 -3
- package/lib/cjs/components/ColorField/ColorField.js +1 -1
- package/lib/cjs/components/ColorField/ColorField.mdx +3 -2
- package/lib/cjs/components/Text/Text.styles.d.ts +138 -94
- package/lib/cjs/components/Text/Text.styles.js +35 -22
- package/lib/cjs/utils/designUtils/figmaLinks.js +2 -1
- package/lib/components/AccordionGroup/Accordion.styles.js +6 -4
- package/lib/components/AccordionGroup/AccordionGroup.js +8 -4
- package/lib/components/AccordionGroup/AccordionGroup.stories.js +42 -6
- package/lib/components/AccordionGroup/AccordionGroup.test.js +52 -0
- package/lib/components/AccordionItem/AccordionItem.js +16 -2
- package/lib/components/ColorField/ColorField.js +2 -2
- package/lib/components/ColorField/ColorField.mdx +3 -2
- package/lib/components/Text/Text.styles.js +35 -22
- package/lib/utils/designUtils/figmaLinks.js +2 -1
- package/package.json +1 -1
@@ -1,10 +1,12 @@
|
|
1
1
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
3
|
import React, { useState } from 'react';
|
3
4
|
import { Item } from 'react-stately';
|
4
5
|
import { withDesign } from 'storybook-addon-designs';
|
5
6
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
6
7
|
import { AccordionGroup, Button, Text, TextField } from '../../index';
|
7
8
|
import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks.js';
|
9
|
+
import { validHeadingTags } from '../AccordionItem/AccordionItem';
|
8
10
|
import AccordionReadme from './AccordionGroup.mdx';
|
9
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
10
12
|
var itemArray = [{
|
@@ -73,11 +75,17 @@ export default {
|
|
73
75
|
control: {
|
74
76
|
type: 'none'
|
75
77
|
}
|
78
|
+
},
|
79
|
+
labelHeadingTag: {
|
80
|
+
control: 'radio',
|
81
|
+
options: validHeadingTags
|
76
82
|
}
|
77
83
|
}
|
78
84
|
};
|
79
85
|
export var Default = function Default(args) {
|
80
|
-
return ___EmotionJSX(AccordionGroup,
|
86
|
+
return ___EmotionJSX(AccordionGroup, _extends({
|
87
|
+
labelHeadingTag: "h3"
|
88
|
+
}, args), ___EmotionJSX(Item, {
|
81
89
|
key: "accordionKey",
|
82
90
|
textValue: "accordionKey",
|
83
91
|
label: "Accordion Label",
|
@@ -90,6 +98,29 @@ Default.parameters = {
|
|
90
98
|
url: FIGMA_LINKS.accordionGroup["default"]
|
91
99
|
}
|
92
100
|
};
|
101
|
+
export var DifferentLevels = function DifferentLevels() {
|
102
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(AccordionGroup, {
|
103
|
+
labelHeadingTag: "h3"
|
104
|
+
}, ___EmotionJSX(Item, {
|
105
|
+
key: "accordionLabelH3Key",
|
106
|
+
textValue: "accordionLabelH3Key",
|
107
|
+
label: "Accordion Label H3",
|
108
|
+
"data-id": "accordionItem"
|
109
|
+
}, ___EmotionJSX(Text, null, "Render me!"))), ___EmotionJSX(AccordionGroup, {
|
110
|
+
labelHeadingTag: "h2"
|
111
|
+
}, ___EmotionJSX(Item, {
|
112
|
+
key: "accordionLabelH2Key",
|
113
|
+
textValue: "accordionLabelH2Key",
|
114
|
+
label: "Accordion Label H2",
|
115
|
+
"data-id": "accordionItem"
|
116
|
+
}, ___EmotionJSX(Text, null, "Render me!"))));
|
117
|
+
};
|
118
|
+
DifferentLevels.parameters = {
|
119
|
+
design: {
|
120
|
+
type: 'figma',
|
121
|
+
url: FIGMA_LINKS.accordionGroup.differentLevels
|
122
|
+
}
|
123
|
+
};
|
93
124
|
export var Multiple = function Multiple() {
|
94
125
|
return (
|
95
126
|
/*
|
@@ -100,7 +131,8 @@ export var Multiple = function Multiple() {
|
|
100
131
|
* ];
|
101
132
|
*/
|
102
133
|
___EmotionJSX(AccordionGroup, {
|
103
|
-
items: itemArray
|
134
|
+
items: itemArray,
|
135
|
+
labelHeadingTag: "h3"
|
104
136
|
}, function (item) {
|
105
137
|
return ___EmotionJSX(Item, {
|
106
138
|
key: item.key,
|
@@ -130,7 +162,8 @@ export var ControlledExpanded = function ControlledExpanded() {
|
|
130
162
|
___EmotionJSX(AccordionGroup, {
|
131
163
|
onExpandedChange: setExpandedKeys,
|
132
164
|
expandedKeys: expandedKeys,
|
133
|
-
items: itemArray
|
165
|
+
items: itemArray,
|
166
|
+
labelHeadingTag: "h3"
|
134
167
|
}, function (item) {
|
135
168
|
return ___EmotionJSX(Item, {
|
136
169
|
key: item.key,
|
@@ -151,7 +184,8 @@ export var UncontrolledExpanded = function UncontrolledExpanded() {
|
|
151
184
|
*/
|
152
185
|
___EmotionJSX(AccordionGroup, {
|
153
186
|
defaultExpandedKeys: ['t1'],
|
154
|
-
items: itemArray
|
187
|
+
items: itemArray,
|
188
|
+
labelHeadingTag: "h3"
|
155
189
|
}, function (item) {
|
156
190
|
return ___EmotionJSX(Item, {
|
157
191
|
key: item.key,
|
@@ -172,7 +206,8 @@ export var DisabledItems = function DisabledItems() {
|
|
172
206
|
*/
|
173
207
|
___EmotionJSX(AccordionGroup, {
|
174
208
|
disabledKeys: ['t1', 't3'],
|
175
|
-
items: itemArrayDisabled
|
209
|
+
items: itemArrayDisabled,
|
210
|
+
labelHeadingTag: "h3"
|
176
211
|
}, function (item) {
|
177
212
|
return ___EmotionJSX(Item, {
|
178
213
|
key: item.key,
|
@@ -192,7 +227,8 @@ export var CustomPresentation = function CustomPresentation() {
|
|
192
227
|
];
|
193
228
|
*/
|
194
229
|
___EmotionJSX(AccordionGroup, {
|
195
|
-
items: itemArrayDisabled
|
230
|
+
items: itemArrayDisabled,
|
231
|
+
labelHeadingTag: "h3"
|
196
232
|
}, function (item) {
|
197
233
|
return ___EmotionJSX(Item, {
|
198
234
|
key: item.key,
|
@@ -1,11 +1,13 @@
|
|
1
1
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
2
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
3
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
3
4
|
import React from 'react';
|
4
5
|
import { Item } from 'react-stately';
|
5
6
|
import userEvent from '@testing-library/user-event';
|
6
7
|
import { Box, Button, Menu, OverlayPanel, PopoverMenu, TextField } from '../../index';
|
7
8
|
import axeTest from '../../utils/testUtils/testAxe';
|
8
9
|
import { act, fireEvent, render, screen } from '../../utils/testUtils/testWrapper';
|
10
|
+
import { validHeadingTags } from '../AccordionItem/AccordionItem';
|
9
11
|
import Text from '../Text';
|
10
12
|
import AccordionGroup from '.';
|
11
13
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -350,4 +352,54 @@ test('accordion works if there are multiple, controlled on the same implementati
|
|
350
352
|
expect(secondSelectedItem).toHaveAttribute('aria-expanded', 'true');
|
351
353
|
userEvent.click(secondSelectedItem);
|
352
354
|
expect(secondSelectedItem).toHaveAttribute('aria-expanded', 'false');
|
355
|
+
});
|
356
|
+
|
357
|
+
// get the last char of heading tag and convert to number, 'h1' => 1
|
358
|
+
var getLabelHeadingLevel = function getLabelHeadingLevel(labelHeading) {
|
359
|
+
return Number(_sliceInstanceProperty(labelHeading).call(labelHeading, -1));
|
360
|
+
};
|
361
|
+
test('when labelHeadingTag is h1, the label is rendered as an h1 tag', function () {
|
362
|
+
var h1Tag = validHeadingTags[0];
|
363
|
+
getComponent({
|
364
|
+
labelHeadingTag: h1Tag
|
365
|
+
});
|
366
|
+
screen.getAllByRole('heading', {
|
367
|
+
level: getLabelHeadingLevel(h1Tag)
|
368
|
+
});
|
369
|
+
});
|
370
|
+
test('when labelHeadingTag is h2, the label is rendered as an h2 tag', function () {
|
371
|
+
var h2Tag = validHeadingTags[1];
|
372
|
+
getComponent({
|
373
|
+
labelHeadingTag: h2Tag
|
374
|
+
});
|
375
|
+
screen.getAllByRole('heading', {
|
376
|
+
level: getLabelHeadingLevel(h2Tag)
|
377
|
+
});
|
378
|
+
});
|
379
|
+
test('when labelHeadingTag is h3, the label is rendered as an h3 tag', function () {
|
380
|
+
var h3Tag = validHeadingTags[2];
|
381
|
+
getComponent({
|
382
|
+
labelHeadingTag: h3Tag
|
383
|
+
});
|
384
|
+
screen.getAllByRole('heading', {
|
385
|
+
level: getLabelHeadingLevel(h3Tag)
|
386
|
+
});
|
387
|
+
});
|
388
|
+
test('when labelHeadingTag is h4, the label is rendered as an h4 tag', function () {
|
389
|
+
var h4Tag = validHeadingTags[3];
|
390
|
+
getComponent({
|
391
|
+
labelHeadingTag: h4Tag
|
392
|
+
});
|
393
|
+
screen.getAllByRole('heading', {
|
394
|
+
level: getLabelHeadingLevel(h4Tag)
|
395
|
+
});
|
396
|
+
});
|
397
|
+
test('when labelHeadingTag is uppercase, the label is rendered', function () {
|
398
|
+
var h4Tag = validHeadingTags[3].toUpperCase();
|
399
|
+
getComponent({
|
400
|
+
labelHeadingTag: h4Tag
|
401
|
+
});
|
402
|
+
screen.getAllByRole('heading', {
|
403
|
+
level: getLabelHeadingLevel(h4Tag)
|
404
|
+
});
|
353
405
|
});
|
@@ -1,6 +1,10 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
3
|
+
var _context;
|
3
4
|
var _excluded = ["label", "children", "textValue", "containerProps", "buttonProps", "regionProps"];
|
5
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
6
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
7
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
4
8
|
import React, { forwardRef, useContext, useImperativeHandle, useRef } from 'react';
|
5
9
|
import { mergeProps, useButton } from 'react-aria';
|
6
10
|
import MenuDown from '@pingux/mdi-react/MenuDownIcon';
|
@@ -13,10 +17,13 @@ import { Button as ThemeUIButton } from 'theme-ui';
|
|
13
17
|
import { AccordionContext } from '../../context/AccordionContext';
|
14
18
|
import { useStatusClasses } from '../../hooks';
|
15
19
|
import { Box, Icon, Text } from '../../index';
|
20
|
+
import { hoveredState } from '../AccordionGroup/Accordion.styles';
|
16
21
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
22
|
+
export var validHeadingTags = ['h1', 'h2', 'h3', 'h4'];
|
17
23
|
var AccordionItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
18
24
|
var className = props.className,
|
19
|
-
item = props.item
|
25
|
+
item = props.item,
|
26
|
+
labelHeadingTag = props.labelHeadingTag;
|
20
27
|
var _item$props = item.props,
|
21
28
|
label = _item$props.label,
|
22
29
|
children = _item$props.children,
|
@@ -62,6 +69,8 @@ var AccordionItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
62
69
|
}),
|
63
70
|
buttonClasses = _useStatusClasses2.classNames;
|
64
71
|
var ariaLabel = props['aria-label'] || item.props.label;
|
72
|
+
var isValidHeadingTag = _includesInstanceProperty(validHeadingTags).call(validHeadingTags, labelHeadingTag === null || labelHeadingTag === void 0 ? void 0 : labelHeadingTag.toLowerCase());
|
73
|
+
var validLabelHeadingTag = isValidHeadingTag ? labelHeadingTag === null || labelHeadingTag === void 0 ? void 0 : labelHeadingTag.toLowerCase() : 'span';
|
65
74
|
return ___EmotionJSX(Box, _extends({
|
66
75
|
variant: "accordion.accordion",
|
67
76
|
className: itemClasses
|
@@ -76,8 +85,10 @@ var AccordionItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
76
85
|
variant: "variants.accordion.header",
|
77
86
|
className: buttonClasses
|
78
87
|
}, mergeProps(hoverProps, accordionButtonProps, raButtonProps, buttonProps, focusProps)), ___EmotionJSX(Text, {
|
88
|
+
as: validLabelHeadingTag,
|
79
89
|
className: buttonClasses,
|
80
|
-
variant:
|
90
|
+
variant: validLabelHeadingTag,
|
91
|
+
sx: hoveredState
|
81
92
|
}, item.props.label), ___EmotionJSX(Box, {
|
82
93
|
as: "span",
|
83
94
|
ml: "5px"
|
@@ -94,6 +105,9 @@ var AccordionItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
94
105
|
});
|
95
106
|
AccordionItem.propTypes = {
|
96
107
|
'aria-label': PropTypes.string,
|
108
|
+
labelHeadingTag: PropTypes.oneOf(_concatInstanceProperty(_context = []).call(_context, validHeadingTags, _mapInstanceProperty(validHeadingTags).call(validHeadingTags, function (heading) {
|
109
|
+
return heading.toUpperCase();
|
110
|
+
}))),
|
97
111
|
item: PropTypes.shape({
|
98
112
|
key: PropTypes.string,
|
99
113
|
rendered: PropTypes.node,
|
@@ -13,7 +13,7 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
|
|
13
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context6 = ownKeys(Object(source))).call(_context6, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
14
14
|
import React, { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
|
15
15
|
import { FocusScope, mergeProps, useOverlayPosition, useOverlayTrigger, useVisuallyHidden } from 'react-aria';
|
16
|
-
import {
|
16
|
+
import { SketchPicker } from 'react-color';
|
17
17
|
import { useOverlayTriggerState } from 'react-stately';
|
18
18
|
import { useColorField } from '@react-aria/color';
|
19
19
|
import { useColorFieldState } from '@react-stately/color';
|
@@ -116,7 +116,7 @@ var ColorField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
116
116
|
restoreFocus: true,
|
117
117
|
contain: true,
|
118
118
|
autoFocus: true
|
119
|
-
}, ___EmotionJSX(
|
119
|
+
}, ___EmotionJSX(SketchPicker, {
|
120
120
|
color: getRgbaFromState(state),
|
121
121
|
onChange: handleColorChange
|
122
122
|
}))));
|
@@ -29,10 +29,11 @@ These keys provide additional functionality to the component.
|
|
29
29
|
| Shift + Tab | Moves focus to the previous focusable component. |
|
30
30
|
| Space or Enter | Opens the color swatch when it is focused. Once opened, the focus moves to the input field and is locked inside the ColorPicker Overlay. |
|
31
31
|
| Esc | When the picker is open, pressing the escape key closes the overlay and focuses on the previously focused component. |
|
32
|
+
| Up and Down Arrows | Using the up and down arrows on any of the RGBA inputs adjusts the value of the input in focus.
|
32
33
|
|
33
34
|
#### Screen Readers
|
34
35
|
|
35
36
|
This component uses the following attributes to assist screen readers:
|
36
|
-
- The trigger button uses the **`aria-expanded`** attribute to indicate the expansion and collapse of
|
37
|
-
- When expanded, **`aria-controls`** is added to the button pointing to the
|
37
|
+
- The trigger button uses the **`aria-expanded`** attribute to indicate the expansion and collapse of Sketch Picker.
|
38
|
+
- When expanded, **`aria-controls`** is added to the button pointing to the Sketch Picker.
|
38
39
|
- The visibly hidden input uses the **`aria-labelledby`** attribute supplied with label ID.
|
@@ -89,7 +89,38 @@ var listViewItemSubtext = _objectSpread(_objectSpread({}, subtitle), {}, {
|
|
89
89
|
fontSize: 'sm',
|
90
90
|
mt: '1px'
|
91
91
|
});
|
92
|
-
|
92
|
+
var hTags = {
|
93
|
+
h1: _objectSpread(_objectSpread({}, title), {}, {
|
94
|
+
fontWeight: 3
|
95
|
+
}),
|
96
|
+
h2: _objectSpread(_objectSpread({}, sectionTitle), {}, {
|
97
|
+
fontWeight: 3
|
98
|
+
}),
|
99
|
+
h3: _objectSpread(_objectSpread({}, itemTitle), {}, {
|
100
|
+
fontWeight: 3
|
101
|
+
}),
|
102
|
+
h4: _objectSpread(_objectSpread({}, wordWrap), {}, {
|
103
|
+
fontSize: 'sm',
|
104
|
+
fontWeight: 3,
|
105
|
+
color: 'text.primary',
|
106
|
+
fontFamily: 'standard'
|
107
|
+
})
|
108
|
+
};
|
109
|
+
var HTags = {
|
110
|
+
H1: _objectSpread(_objectSpread({}, hTags.h1), {}, {
|
111
|
+
lineHeight: '28px'
|
112
|
+
}),
|
113
|
+
H2: _objectSpread(_objectSpread({}, hTags.h2), {}, {
|
114
|
+
lineHeight: '21px'
|
115
|
+
}),
|
116
|
+
H3: _objectSpread(_objectSpread({}, hTags.h3), {}, {
|
117
|
+
lineHeight: '18px'
|
118
|
+
}),
|
119
|
+
H4: _objectSpread(_objectSpread({}, hTags.h4), {}, {
|
120
|
+
lineHeight: '16px'
|
121
|
+
})
|
122
|
+
};
|
123
|
+
export var text = _objectSpread(_objectSpread(_objectSpread({
|
93
124
|
base: base,
|
94
125
|
bodyStrong: bodyStrong,
|
95
126
|
bodyWeak: _objectSpread(_objectSpread({}, wordWrap), {}, {
|
@@ -122,26 +153,8 @@ export var text = {
|
|
122
153
|
textTransform: 'uppercase',
|
123
154
|
fontFamily: 'standard'
|
124
155
|
}),
|
125
|
-
environmentBreadcrumb: environmentBreadcrumb
|
126
|
-
|
127
|
-
fontWeight: 3,
|
128
|
-
lineHeight: '28px'
|
129
|
-
}),
|
130
|
-
H2: _objectSpread(_objectSpread({}, sectionTitle), {}, {
|
131
|
-
fontWeight: 3,
|
132
|
-
lineHeight: '21px'
|
133
|
-
}),
|
134
|
-
H3: _objectSpread(_objectSpread({}, itemTitle), {}, {
|
135
|
-
fontWeight: 3,
|
136
|
-
lineHeight: '18px'
|
137
|
-
}),
|
138
|
-
H4: _objectSpread(_objectSpread({}, wordWrap), {}, {
|
139
|
-
fontSize: 'sm',
|
140
|
-
fontWeight: 3,
|
141
|
-
color: 'text.primary',
|
142
|
-
fontFamily: 'standard',
|
143
|
-
lineHeight: '16px'
|
144
|
-
}),
|
156
|
+
environmentBreadcrumb: environmentBreadcrumb
|
157
|
+
}, hTags), HTags), {}, {
|
145
158
|
inputValue: {
|
146
159
|
fontWeight: 1,
|
147
160
|
color: 'text.primary',
|
@@ -196,4 +209,4 @@ export var text = {
|
|
196
209
|
}),
|
197
210
|
textEllipsis: textEllipsis,
|
198
211
|
title: title
|
199
|
-
};
|
212
|
+
});
|
@@ -1,6 +1,7 @@
|
|
1
1
|
export var FIGMA_LINKS = {
|
2
2
|
accordionGroup: {
|
3
|
-
"default": 'https://www.figma.com/file/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?type=design&node-id=446-1808&t=8Wwd3tIBh3GEjCJB-0'
|
3
|
+
"default": 'https://www.figma.com/file/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?type=design&node-id=446-1808&t=8Wwd3tIBh3GEjCJB-0',
|
4
|
+
differentLevels: 'https://www.figma.com/file/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?node-id=446%3A1949&mode=dev'
|
4
5
|
},
|
5
6
|
attributeMappings: {
|
6
7
|
"default": 'https://www.figma.com/file/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?node-id=15076%3A33905&mode=dev',
|