@primer/components 31.2.0-rc.0b631515 → 31.2.0-rc.25d7c83f
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 +7 -1
- package/dist/browser.esm.js +473 -471
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +103 -101
- package/dist/browser.umd.js.map +1 -1
- package/docs/content/ActionList2.mdx +354 -0
- package/docs/content/getting-started.md +1 -1
- package/docs/src/@primer/gatsby-theme-doctocat/live-code-scope.js +17 -0
- package/lib/ActionList2/Description.d.ts +12 -0
- package/lib/ActionList2/Description.js +53 -0
- package/lib/ActionList2/Divider.d.ts +5 -0
- package/lib/ActionList2/Divider.js +35 -0
- package/lib/ActionList2/Group.d.ts +11 -0
- package/lib/ActionList2/Group.js +57 -0
- package/lib/ActionList2/Header.d.ts +26 -0
- package/lib/ActionList2/Header.js +55 -0
- package/lib/ActionList2/Item.d.ts +63 -0
- package/lib/ActionList2/Item.js +234 -0
- package/lib/ActionList2/LinkItem.d.ts +17 -0
- package/lib/ActionList2/LinkItem.js +57 -0
- package/lib/ActionList2/List.d.ts +26 -0
- package/lib/ActionList2/List.js +59 -0
- package/lib/ActionList2/Selection.d.ts +5 -0
- package/lib/ActionList2/Selection.js +70 -0
- package/lib/ActionList2/Visuals.d.ts +9 -0
- package/lib/ActionList2/Visuals.js +90 -0
- package/lib/ActionList2/index.d.ts +36 -0
- package/lib/ActionList2/index.js +47 -0
- package/lib/_TextInputWrapper.js +2 -2
- package/lib/__tests__/ActionList2.test.d.ts +1 -0
- package/lib/__tests__/ActionList2.test.js +53 -0
- package/lib/__tests__/AnchoredOverlay.test.js +4 -2
- package/lib/__tests__/utils/createSlots.test.d.ts +1 -0
- package/lib/__tests__/utils/createSlots.test.js +75 -0
- package/lib/stories/ActionList2.stories.js +907 -0
- package/lib/stories/TextInput.stories.js +144 -0
- package/lib/sx.d.ts +2 -0
- package/lib/sx.js +8 -0
- package/lib/theme-preval.js +81 -2
- package/lib/unreleased.d.ts +7 -0
- package/lib/unreleased.js +18 -0
- package/lib/utils/create-slots.d.ts +17 -0
- package/lib/utils/create-slots.js +105 -0
- package/lib/utils/testing.d.ts +14 -1
- package/lib/utils/use-force-update.d.ts +1 -0
- package/lib/utils/use-force-update.js +19 -0
- package/lib-esm/ActionList2/Description.d.ts +12 -0
- package/lib-esm/ActionList2/Description.js +37 -0
- package/lib-esm/ActionList2/Divider.d.ts +5 -0
- package/lib-esm/ActionList2/Divider.js +23 -0
- package/lib-esm/ActionList2/Group.d.ts +11 -0
- package/lib-esm/ActionList2/Group.js +40 -0
- package/lib-esm/ActionList2/Header.d.ts +26 -0
- package/lib-esm/ActionList2/Header.js +44 -0
- package/lib-esm/ActionList2/Item.d.ts +63 -0
- package/lib-esm/ActionList2/Item.js +201 -0
- package/lib-esm/ActionList2/LinkItem.d.ts +17 -0
- package/lib-esm/ActionList2/LinkItem.js +43 -0
- package/lib-esm/ActionList2/List.d.ts +26 -0
- package/lib-esm/ActionList2/List.js +37 -0
- package/lib-esm/ActionList2/Selection.d.ts +5 -0
- package/lib-esm/ActionList2/Selection.js +52 -0
- package/lib-esm/ActionList2/Visuals.d.ts +9 -0
- package/lib-esm/ActionList2/Visuals.js +68 -0
- package/lib-esm/ActionList2/index.d.ts +36 -0
- package/lib-esm/ActionList2/index.js +33 -0
- package/lib-esm/_TextInputWrapper.js +2 -2
- package/lib-esm/__tests__/ActionList2.test.d.ts +1 -0
- package/lib-esm/__tests__/ActionList2.test.js +41 -0
- package/lib-esm/__tests__/AnchoredOverlay.test.js +4 -2
- package/lib-esm/__tests__/utils/createSlots.test.d.ts +1 -0
- package/lib-esm/__tests__/utils/createSlots.test.js +67 -0
- package/lib-esm/stories/ActionList2.stories.js +796 -0
- package/lib-esm/stories/TextInput.stories.js +117 -0
- package/lib-esm/sx.d.ts +2 -0
- package/lib-esm/sx.js +3 -1
- package/lib-esm/theme-preval.js +81 -2
- package/lib-esm/unreleased.d.ts +7 -0
- package/lib-esm/unreleased.js +8 -0
- package/lib-esm/utils/create-slots.d.ts +17 -0
- package/lib-esm/utils/create-slots.js +84 -0
- package/lib-esm/utils/testing.d.ts +14 -1
- package/lib-esm/utils/use-force-update.d.ts +1 -0
- package/lib-esm/utils/use-force-update.js +6 -0
- package/package-lock.json +146 -7
- package/package.json +4 -2
- package/src/ActionList2/Description.tsx +49 -0
- package/src/ActionList2/Divider.tsx +24 -0
- package/src/ActionList2/Group.tsx +34 -0
- package/src/ActionList2/Header.tsx +58 -0
- package/src/ActionList2/Item.tsx +223 -0
- package/src/ActionList2/LinkItem.tsx +49 -0
- package/src/ActionList2/List.tsx +55 -0
- package/src/ActionList2/Selection.tsx +40 -0
- package/src/ActionList2/Visuals.tsx +76 -0
- package/src/ActionList2/index.ts +39 -0
- package/src/_TextInputWrapper.tsx +7 -0
- package/src/__tests__/ActionList2.test.tsx +47 -0
- package/src/__tests__/AnchoredOverlay.test.tsx +2 -2
- package/src/__tests__/__snapshots__/ActionList2.test.tsx.snap +14 -0
- package/src/__tests__/__snapshots__/AnchoredOverlay.test.tsx.snap +35 -135
- package/src/__tests__/utils/__snapshots__/createSlots.test.tsx.snap +55 -0
- package/src/__tests__/utils/createSlots.test.tsx +74 -0
- package/src/stories/ActionList2.stories.tsx +1290 -0
- package/src/stories/TextInput.stories.tsx +113 -0
- package/src/sx.ts +3 -0
- package/src/theme-preval.js +1 -0
- package/src/unreleased.ts +9 -0
- package/src/utils/create-slots.tsx +96 -0
- package/src/utils/use-force-update.ts +7 -0
- package/stats.html +1 -1
@@ -0,0 +1,47 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.ActionList = void 0;
|
7
|
+
|
8
|
+
var _List = require("./List");
|
9
|
+
|
10
|
+
var _Group = require("./Group");
|
11
|
+
|
12
|
+
var _Item = require("./Item");
|
13
|
+
|
14
|
+
var _LinkItem = require("./LinkItem");
|
15
|
+
|
16
|
+
var _Divider = require("./Divider");
|
17
|
+
|
18
|
+
var _Description = require("./Description");
|
19
|
+
|
20
|
+
var _Visuals = require("./Visuals");
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Collection of list-related components.
|
24
|
+
*/
|
25
|
+
const ActionList = Object.assign(_List.List, {
|
26
|
+
/** Collects related `Items` in an `ActionList`. */
|
27
|
+
Group: _Group.Group,
|
28
|
+
|
29
|
+
/** An actionable or selectable `Item` */
|
30
|
+
Item: _Item.Item,
|
31
|
+
|
32
|
+
/** A `Item` that renders a full-size anchor inside ListItem */
|
33
|
+
LinkItem: _LinkItem.LinkItem,
|
34
|
+
|
35
|
+
/** Visually separates `Item`s or `Group`s in an `ActionList`. */
|
36
|
+
Divider: _Divider.Divider,
|
37
|
+
|
38
|
+
/** Secondary text which provides additional information about an `Item`. */
|
39
|
+
Description: _Description.Description,
|
40
|
+
|
41
|
+
/** Icon (or similar) positioned before `Item` text. */
|
42
|
+
LeadingVisual: _Visuals.LeadingVisual,
|
43
|
+
|
44
|
+
/** Icon (or similar) positioned after `Item` text. */
|
45
|
+
TrailingVisual: _Visuals.TrailingVisual
|
46
|
+
});
|
47
|
+
exports.ActionList = ActionList;
|
package/lib/_TextInputWrapper.js
CHANGED
@@ -39,13 +39,13 @@ const sizeVariants = (0, _styledSystem.variant)({
|
|
39
39
|
const TextInputWrapper = _styledComponents.default.span.withConfig({
|
40
40
|
displayName: "_TextInputWrapper__TextInputWrapper",
|
41
41
|
componentId: "sc-5vfcis-0"
|
42
|
-
})(["display:inline-flex;align-items:stretch;min-height:34px;font-size:", ";line-height:20px;color:", ";vertical-align:middle;background-repeat:no-repeat;background-position:right 8px center;border:1px solid ", ";border-radius:", ";outline:none;box-shadow:", ";cursor:text;", " .TextInput-icon{align-self:center;color:", ";margin:0 ", ";flex-shrink:0;}&:focus-within{border-color:", ";box-shadow:", ";}", " ", " ", " @media (min-width:", "){font-size:", ";}", " ", " ", " ", " ", ";"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('colors.fg.default'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('radii.2'), (0, _constants.get)('shadows.primer.shadow.inset'), props => {
|
42
|
+
})(["display:inline-flex;align-items:stretch;min-height:34px;font-size:", ";line-height:20px;color:", ";vertical-align:middle;background-repeat:no-repeat;background-position:right 8px center;border:1px solid ", ";border-radius:", ";outline:none;box-shadow:", ";cursor:text;", " .TextInput-icon{align-self:center;color:", ";margin:0 ", ";flex-shrink:0;}&:focus-within{border-color:", ";box-shadow:", ";}", " ", " ", " ", " @media (min-width:", "){font-size:", ";}", " ", " ", " ", " ", ";"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('colors.fg.default'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('radii.2'), (0, _constants.get)('shadows.primer.shadow.inset'), props => {
|
43
43
|
if (props.hasIcon) {
|
44
44
|
return (0, _styledComponents.css)(["padding:0;"]);
|
45
45
|
} else {
|
46
46
|
return (0, _styledComponents.css)(["padding:6px 12px;"]);
|
47
47
|
}
|
48
|
-
}, (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.accent.emphasis'), (0, _constants.get)('shadows.primer.shadow.focus'), props => props.contrast && (0, _styledComponents.css)(["background-color:", ";"], (0, _constants.get)('colors.canvas.inset')), props => props.disabled && (0, _styledComponents.css)(["color:", ";background-color:", ";border-color:", ";"], (0, _constants.get)('colors.primer.fg.disabled'), (0, _constants.get)('colors.input.disabledBg'), (0, _constants.get)('colors.border.default')), props => props.block && (0, _styledComponents.css)(["display:block;width:100%;"]), (0, _constants.get)('breakpoints.1'), (0, _constants.get)('fontSizes.1'), _styledSystem.width, _styledSystem.minWidth, _styledSystem.maxWidth, sizeVariants, _sx.default);
|
48
|
+
}, (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.accent.emphasis'), (0, _constants.get)('shadows.primer.shadow.focus'), props => props.contrast && (0, _styledComponents.css)(["background-color:", ";"], (0, _constants.get)('colors.canvas.inset')), props => props.disabled && (0, _styledComponents.css)(["color:", ";background-color:", ";border-color:", ";"], (0, _constants.get)('colors.primer.fg.disabled'), (0, _constants.get)('colors.input.disabledBg'), (0, _constants.get)('colors.border.default')), props => props.block && (0, _styledComponents.css)(["display:block;width:100%;"]), props => props.block && props.hasIcon && (0, _styledComponents.css)(["display:flex;"]), (0, _constants.get)('breakpoints.1'), (0, _constants.get)('fontSizes.1'), _styledSystem.width, _styledSystem.minWidth, _styledSystem.maxWidth, sizeVariants, _sx.default);
|
49
49
|
|
50
50
|
var _default = TextInputWrapper;
|
51
51
|
exports.default = _default;
|
@@ -0,0 +1 @@
|
|
1
|
+
import 'babel-polyfill';
|
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _react = require("@testing-library/react");
|
4
|
+
|
5
|
+
require("babel-polyfill");
|
6
|
+
|
7
|
+
var _jestAxe = require("jest-axe");
|
8
|
+
|
9
|
+
var _react2 = _interopRequireDefault(require("react"));
|
10
|
+
|
11
|
+
var _theme = _interopRequireDefault(require("../theme"));
|
12
|
+
|
13
|
+
var _ActionList = require("../ActionList2");
|
14
|
+
|
15
|
+
var _testing = require("../utils/testing");
|
16
|
+
|
17
|
+
var _ = require("..");
|
18
|
+
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
20
|
+
|
21
|
+
expect.extend(_jestAxe.toHaveNoViolations);
|
22
|
+
|
23
|
+
function SimpleActionList() {
|
24
|
+
return /*#__PURE__*/_react2.default.createElement(_.ThemeProvider, {
|
25
|
+
theme: _theme.default
|
26
|
+
}, /*#__PURE__*/_react2.default.createElement(_.SSRProvider, null, /*#__PURE__*/_react2.default.createElement(_.BaseStyles, null, /*#__PURE__*/_react2.default.createElement(_ActionList.ActionList, null, /*#__PURE__*/_react2.default.createElement(_ActionList.ActionList.Item, null, "New file"), /*#__PURE__*/_react2.default.createElement(_ActionList.ActionList.Divider, null), /*#__PURE__*/_react2.default.createElement(_ActionList.ActionList.Item, null, "Copy link"), /*#__PURE__*/_react2.default.createElement(_ActionList.ActionList.Item, null, "Edit file"), /*#__PURE__*/_react2.default.createElement(_ActionList.ActionList.Item, {
|
27
|
+
variant: "danger"
|
28
|
+
}, "Delete file")))));
|
29
|
+
}
|
30
|
+
|
31
|
+
SimpleActionList.displayName = "SimpleActionList";
|
32
|
+
describe('ActionList', () => {
|
33
|
+
(0, _testing.behavesAsComponent)({
|
34
|
+
Component: _ActionList.ActionList,
|
35
|
+
options: {
|
36
|
+
skipAs: true,
|
37
|
+
skipSx: true
|
38
|
+
},
|
39
|
+
toRender: () => /*#__PURE__*/_react2.default.createElement(_ActionList.ActionList, null)
|
40
|
+
});
|
41
|
+
(0, _testing.checkExports)('ActionList2', {
|
42
|
+
default: undefined,
|
43
|
+
ActionList: _ActionList.ActionList
|
44
|
+
});
|
45
|
+
it('should have no axe violations', async () => {
|
46
|
+
const {
|
47
|
+
container
|
48
|
+
} = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(SimpleActionList, null));
|
49
|
+
const results = await (0, _jestAxe.axe)(container);
|
50
|
+
expect(results).toHaveNoViolations();
|
51
|
+
(0, _react.cleanup)();
|
52
|
+
});
|
53
|
+
});
|
@@ -152,9 +152,11 @@ describe('AnchoredOverlay', () => {
|
|
152
152
|
expect(mockCloseCallback).toHaveBeenCalledWith('escape');
|
153
153
|
});
|
154
154
|
it('should render consistently when open', () => {
|
155
|
-
const
|
155
|
+
const {
|
156
|
+
container
|
157
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(AnchoredOverlayTestComponent, {
|
156
158
|
initiallyOpen: true
|
157
159
|
}));
|
158
|
-
expect(
|
160
|
+
expect(container).toMatchSnapshot();
|
159
161
|
});
|
160
162
|
});
|
@@ -0,0 +1 @@
|
|
1
|
+
import 'babel-polyfill';
|
@@ -0,0 +1,75 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
4
|
+
|
5
|
+
require("babel-polyfill");
|
6
|
+
|
7
|
+
var _react2 = require("@testing-library/react");
|
8
|
+
|
9
|
+
var _createSlots = _interopRequireDefault(require("../../utils/create-slots"));
|
10
|
+
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
12
|
+
|
13
|
+
// setup a component with slots
|
14
|
+
const {
|
15
|
+
Slots,
|
16
|
+
Slot
|
17
|
+
} = (0, _createSlots.default)(['One', 'Two', 'Three']);
|
18
|
+
|
19
|
+
const ComponentWithSlots = ({
|
20
|
+
salutation,
|
21
|
+
children
|
22
|
+
}) => {
|
23
|
+
return /*#__PURE__*/_react.default.createElement(Slots, {
|
24
|
+
context: {
|
25
|
+
salutation
|
26
|
+
}
|
27
|
+
}, slots => /*#__PURE__*/_react.default.createElement("div", null, slots.One, /*#__PURE__*/_react.default.createElement("span", null, children, " ", slots.Two, " ", slots.Three)));
|
28
|
+
};
|
29
|
+
|
30
|
+
ComponentWithSlots.displayName = "ComponentWithSlots";
|
31
|
+
|
32
|
+
const SlotItem1 = ({
|
33
|
+
children
|
34
|
+
}) => /*#__PURE__*/_react.default.createElement(Slot, {
|
35
|
+
name: "One"
|
36
|
+
}, children);
|
37
|
+
|
38
|
+
SlotItem1.displayName = "SlotItem1";
|
39
|
+
|
40
|
+
const SlotItem2 = ({
|
41
|
+
children
|
42
|
+
}) => /*#__PURE__*/_react.default.createElement(Slot, {
|
43
|
+
name: "Two"
|
44
|
+
}, children);
|
45
|
+
|
46
|
+
SlotItem2.displayName = "SlotItem2";
|
47
|
+
|
48
|
+
const SlotItem3 = ({
|
49
|
+
children
|
50
|
+
}) => /*#__PURE__*/_react.default.createElement(Slot, {
|
51
|
+
name: "Three"
|
52
|
+
}, context => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, context.salutation, " ", children));
|
53
|
+
|
54
|
+
SlotItem3.displayName = "SlotItem3";
|
55
|
+
describe('ComponentWithSlots', () => {
|
56
|
+
it('renders all slots', async () => {
|
57
|
+
const component = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(ComponentWithSlots, null, /*#__PURE__*/_react.default.createElement(SlotItem1, null, "first"), /*#__PURE__*/_react.default.createElement(SlotItem2, null, "second"), "free form"));
|
58
|
+
await (0, _react2.waitFor)(() => component.getByText('first'));
|
59
|
+
expect(component.container).toMatchSnapshot();
|
60
|
+
});
|
61
|
+
it('renders without any slots', async () => {
|
62
|
+
const component = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(ComponentWithSlots, null, "free form"));
|
63
|
+
expect(component.container).toMatchSnapshot();
|
64
|
+
});
|
65
|
+
it('renders with just one slot', async () => {
|
66
|
+
const component = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(ComponentWithSlots, null, /*#__PURE__*/_react.default.createElement(SlotItem1, null, "first"), "free form"));
|
67
|
+
expect(component.container).toMatchSnapshot();
|
68
|
+
});
|
69
|
+
it('renders with context passed to children', async () => {
|
70
|
+
const component = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(ComponentWithSlots, {
|
71
|
+
salutation: "hi"
|
72
|
+
}, /*#__PURE__*/_react.default.createElement(SlotItem3, null, "third"), "free form"));
|
73
|
+
expect(component.container).toMatchSnapshot();
|
74
|
+
});
|
75
|
+
});
|