@primer/components 0.0.0-202192711645 → 0.0.0-2021927173554

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.
Files changed (118) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/browser.esm.js +615 -615
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +176 -176
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/Autocomplete/Autocomplete.d.ts +8 -8
  7. package/lib/Autocomplete/AutocompleteInput.d.ts +8 -8
  8. package/lib/Button/Button.d.ts +6 -6
  9. package/lib/Button/ButtonBase.d.ts +1 -1
  10. package/lib/Button/ButtonClose.d.ts +5 -5
  11. package/lib/Button/ButtonDanger.d.ts +6 -6
  12. package/lib/Button/ButtonInvisible.d.ts +6 -6
  13. package/lib/Button/ButtonOutline.d.ts +6 -6
  14. package/lib/Button/ButtonPrimary.d.ts +6 -6
  15. package/lib/CircleBadge.d.ts +2 -2
  16. package/lib/CircleOcticon.d.ts +4 -4
  17. package/lib/Dialog.d.ts +4 -4
  18. package/lib/Dropdown.d.ts +18 -18
  19. package/lib/DropdownMenu/DropdownButton.d.ts +7 -7
  20. package/lib/FilterList.d.ts +3 -3
  21. package/lib/Flash.d.ts +1 -1
  22. package/lib/Label.d.ts +1 -1
  23. package/lib/Position.d.ts +4 -4
  24. package/lib/ProgressBar.d.ts +1 -1
  25. package/lib/SelectMenu/SelectMenu.d.ts +28 -28
  26. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  27. package/lib/TextInputWithTokens.d.ts +8 -8
  28. package/lib/Timeline.d.ts +4 -4
  29. package/lib/Token/AvatarToken.d.ts +1 -1
  30. package/lib/Token/IssueLabelToken.d.ts +1 -1
  31. package/lib/Token/Token.d.ts +1 -1
  32. package/lib/_TextInputWrapper.d.ts +1 -1
  33. package/lib/index.d.ts +0 -1
  34. package/lib/index.js +0 -8
  35. package/lib/sx.d.ts +8 -4
  36. package/lib/sx.js +0 -8
  37. package/lib/theme.d.ts +100 -0
  38. package/lib-esm/Autocomplete/Autocomplete.d.ts +8 -8
  39. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +8 -8
  40. package/lib-esm/Button/Button.d.ts +6 -6
  41. package/lib-esm/Button/ButtonBase.d.ts +1 -1
  42. package/lib-esm/Button/ButtonClose.d.ts +5 -5
  43. package/lib-esm/Button/ButtonDanger.d.ts +6 -6
  44. package/lib-esm/Button/ButtonInvisible.d.ts +6 -6
  45. package/lib-esm/Button/ButtonOutline.d.ts +6 -6
  46. package/lib-esm/Button/ButtonPrimary.d.ts +6 -6
  47. package/lib-esm/CircleBadge.d.ts +2 -2
  48. package/lib-esm/CircleOcticon.d.ts +4 -4
  49. package/lib-esm/Dialog.d.ts +4 -4
  50. package/lib-esm/Dropdown.d.ts +18 -18
  51. package/lib-esm/DropdownMenu/DropdownButton.d.ts +7 -7
  52. package/lib-esm/FilterList.d.ts +3 -3
  53. package/lib-esm/Flash.d.ts +1 -1
  54. package/lib-esm/Label.d.ts +1 -1
  55. package/lib-esm/Position.d.ts +4 -4
  56. package/lib-esm/ProgressBar.d.ts +1 -1
  57. package/lib-esm/SelectMenu/SelectMenu.d.ts +28 -28
  58. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  59. package/lib-esm/TextInputWithTokens.d.ts +8 -8
  60. package/lib-esm/Timeline.d.ts +4 -4
  61. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  62. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  63. package/lib-esm/Token/Token.d.ts +1 -1
  64. package/lib-esm/_TextInputWrapper.d.ts +1 -1
  65. package/lib-esm/index.d.ts +0 -1
  66. package/lib-esm/index.js +0 -1
  67. package/lib-esm/sx.d.ts +8 -4
  68. package/lib-esm/sx.js +1 -3
  69. package/lib-esm/theme.d.ts +100 -0
  70. package/package.json +1 -1
  71. package/lib/ActionList2/Description.d.ts +0 -6
  72. package/lib/ActionList2/Description.js +0 -53
  73. package/lib/ActionList2/Divider.d.ts +0 -8
  74. package/lib/ActionList2/Divider.js +0 -42
  75. package/lib/ActionList2/Group.d.ts +0 -8
  76. package/lib/ActionList2/Group.js +0 -39
  77. package/lib/ActionList2/Header.d.ts +0 -26
  78. package/lib/ActionList2/Header.js +0 -55
  79. package/lib/ActionList2/Item.d.ts +0 -50
  80. package/lib/ActionList2/Item.js +0 -205
  81. package/lib/ActionList2/List.d.ts +0 -11
  82. package/lib/ActionList2/List.js +0 -53
  83. package/lib/ActionList2/Selection.d.ts +0 -5
  84. package/lib/ActionList2/Selection.js +0 -67
  85. package/lib/ActionList2/Visuals.d.ts +0 -11
  86. package/lib/ActionList2/Visuals.js +0 -90
  87. package/lib/ActionList2/hacks.d.ts +0 -30
  88. package/lib/ActionList2/hacks.js +0 -38
  89. package/lib/ActionList2/index.d.ts +0 -26
  90. package/lib/ActionList2/index.js +0 -36
  91. package/lib/utils/create-slots.d.ts +0 -17
  92. package/lib/utils/create-slots.js +0 -105
  93. package/lib/utils/use-force-update.d.ts +0 -1
  94. package/lib/utils/use-force-update.js +0 -19
  95. package/lib-esm/ActionList2/Description.d.ts +0 -6
  96. package/lib-esm/ActionList2/Description.js +0 -37
  97. package/lib-esm/ActionList2/Divider.d.ts +0 -8
  98. package/lib-esm/ActionList2/Divider.js +0 -30
  99. package/lib-esm/ActionList2/Group.d.ts +0 -8
  100. package/lib-esm/ActionList2/Group.js +0 -29
  101. package/lib-esm/ActionList2/Header.d.ts +0 -26
  102. package/lib-esm/ActionList2/Header.js +0 -45
  103. package/lib-esm/ActionList2/Item.d.ts +0 -50
  104. package/lib-esm/ActionList2/Item.js +0 -199
  105. package/lib-esm/ActionList2/List.d.ts +0 -11
  106. package/lib-esm/ActionList2/List.js +0 -35
  107. package/lib-esm/ActionList2/Selection.d.ts +0 -5
  108. package/lib-esm/ActionList2/Selection.js +0 -50
  109. package/lib-esm/ActionList2/Visuals.d.ts +0 -11
  110. package/lib-esm/ActionList2/Visuals.js +0 -68
  111. package/lib-esm/ActionList2/hacks.d.ts +0 -30
  112. package/lib-esm/ActionList2/hacks.js +0 -30
  113. package/lib-esm/ActionList2/index.d.ts +0 -26
  114. package/lib-esm/ActionList2/index.js +0 -23
  115. package/lib-esm/utils/create-slots.d.ts +0 -17
  116. package/lib-esm/utils/create-slots.js +0 -84
  117. package/lib-esm/utils/use-force-update.d.ts +0 -1
  118. package/lib-esm/utils/use-force-update.js +0 -6
@@ -1,50 +0,0 @@
1
- import React from 'react';
2
- import { CheckIcon } from '@primer/octicons-react';
3
- import { useTheme } from '../ThemeProvider';
4
- import { ListContext } from './List';
5
- import { LeadingVisualContainer } from './Visuals';
6
- export const Selection = ({
7
- selected,
8
- disabled
9
- }) => {
10
- const {
11
- selectionVariant
12
- } = React.useContext(ListContext);
13
- const {
14
- theme
15
- } = useTheme();
16
- if (typeof selected === 'undefined') return null;
17
-
18
- if (selectionVariant === 'single') {
19
- return /*#__PURE__*/React.createElement(LeadingVisualContainer, null, selected && /*#__PURE__*/React.createElement(CheckIcon, {
20
- fill: "fg.muted"
21
- }));
22
- }
23
-
24
- if (selectionVariant === 'multiple') {
25
- /**
26
- * readOnly is required because we are doing a one-way bind to `checked`
27
- * aria-readonly="false" tells screen that they can still interact with the checkbox
28
- * TODO: not sure if disabled & aria-label be here or should we apply it on the instance as props
29
- * TODO: aria-label should come from the text part of the slot
30
- */
31
- return /*#__PURE__*/React.createElement(LeadingVisualContainer, {
32
- sx: {
33
- input: {
34
- margin: 0,
35
- pointerEvents: 'none'
36
- }
37
- }
38
- }, /*#__PURE__*/React.createElement("input", {
39
- type: "checkbox",
40
- checked: selected,
41
- disabled: disabled,
42
- "aria-label": "TODO",
43
- tabIndex: -1,
44
- readOnly: true,
45
- "aria-readonly": "false"
46
- }));
47
- }
48
-
49
- return null;
50
- };
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { SxProp } from '../sx';
3
- declare type VisualProps = SxProp & {
4
- children: React.ReactNode;
5
- };
6
- export declare const LeadingVisualContainer: React.FC<SxProp>;
7
- export declare type LeadingVisualProps = VisualProps;
8
- export declare const LeadingVisual: React.FC<VisualProps>;
9
- export declare type TrailingVisualProps = VisualProps;
10
- export declare const TrailingVisual: React.FC<VisualProps>;
11
- export {};
@@ -1,68 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import React from 'react';
4
- import Box from '../Box';
5
- import { merge } from '../sx';
6
- import { get } from '../constants';
7
- import { getVariantStyles, Slot } from './Item';
8
- export const LeadingVisualContainer = ({
9
- sx = {},
10
- ...props
11
- }) => {
12
- return /*#__PURE__*/React.createElement(Box, _extends({
13
- as: "span",
14
- sx: merge({
15
- height: '20px',
16
- // match height of text row
17
- minWidth: get('space.3'),
18
- maxWidth: '20px',
19
- // square (same as height)
20
- display: 'flex',
21
- justifyContent: 'center',
22
- alignItems: 'center',
23
- flexShrink: 0,
24
- marginRight: 2
25
- }, sx)
26
- }, props));
27
- };
28
- LeadingVisualContainer.displayName = "LeadingVisualContainer";
29
- export const LeadingVisual = ({
30
- sx = {},
31
- ...props
32
- }) => {
33
- return /*#__PURE__*/React.createElement(Slot, {
34
- name: "LeadingVisual"
35
- }, ({
36
- variant,
37
- disabled
38
- }) => /*#__PURE__*/React.createElement(LeadingVisualContainer, _extends({
39
- sx: merge({
40
- color: getVariantStyles(variant, disabled).iconColor,
41
- svg: {
42
- fontSize: 0
43
- }
44
- }, sx)
45
- }, props), props.children));
46
- };
47
- LeadingVisual.displayName = "LeadingVisual";
48
- export const TrailingVisual = ({
49
- sx = {},
50
- ...props
51
- }) => {
52
- return /*#__PURE__*/React.createElement(Slot, {
53
- name: "TrailingVisual"
54
- }, ({
55
- variant,
56
- disabled
57
- }) => /*#__PURE__*/React.createElement(Box, _extends({
58
- as: "span",
59
- sx: merge({
60
- height: '20px',
61
- // match height of text row
62
- flexShrink: 0,
63
- color: getVariantStyles(variant, disabled).annotationColor,
64
- marginLeft: 2
65
- }, sx)
66
- }, props), props.children));
67
- };
68
- TrailingVisual.displayName = "TrailingVisual";
@@ -1,30 +0,0 @@
1
- /**
2
- * These colors are not yet in our default theme.
3
- * TODO: Need to remove this once they are added.
4
- */
5
- export declare const customItemThemes: {
6
- default: {
7
- hover: {
8
- light: string;
9
- dark: string;
10
- dark_dimmed: string;
11
- };
12
- focus: {
13
- light: string;
14
- dark: string;
15
- dark_dimmed: string;
16
- };
17
- };
18
- danger: {
19
- hover: {
20
- light: string;
21
- dark: string;
22
- dark_dimmed: string;
23
- };
24
- focus: {
25
- light: string;
26
- dark: string;
27
- dark_dimmed: string;
28
- };
29
- };
30
- };
@@ -1,30 +0,0 @@
1
- /**
2
- * These colors are not yet in our default theme.
3
- * TODO: Need to remove this once they are added.
4
- */
5
- export const customItemThemes = {
6
- default: {
7
- hover: {
8
- light: 'rgba(46, 77, 108, 0.06)',
9
- dark: 'rgba(201, 206, 212, 0.12)',
10
- dark_dimmed: 'rgba(201, 206, 212, 0.12)'
11
- },
12
- focus: {
13
- light: 'rgba(54, 77, 100, 0.16)',
14
- dark: 'rgba(201, 206, 212, 0.24)',
15
- dark_dimmed: 'rgba(201, 206, 212, 0.24)'
16
- }
17
- },
18
- danger: {
19
- hover: {
20
- light: 'rgba(234, 74, 90, 0.08)',
21
- dark: 'rgba(248, 81, 73, 0.16)',
22
- dark_dimmed: 'rgba(248, 81, 73, 0.16)'
23
- },
24
- focus: {
25
- light: 'rgba(234, 74, 90, 0.14)',
26
- dark: 'rgba(248, 81, 73, 0.24)',
27
- dark_dimmed: 'rgba(248, 81, 73, 0.24)'
28
- }
29
- }
30
- };
@@ -1,26 +0,0 @@
1
- /// <reference types="react" />
2
- import { Group } from './Group';
3
- import { Divider } from './Divider';
4
- export type { ListProps as ActionListProps } from './List';
5
- export type { GroupProps } from './Group';
6
- export type { ItemProps } from './Item';
7
- export type { DescriptionProps } from './Description';
8
- export type { LeadingVisualProps, TrailingVisualProps } from './Visuals';
9
- /**
10
- * Collection of list-related components.
11
- */
12
- export declare const ActionList: import("@radix-ui/react-polymorphic").ForwardRefComponent<"ul", import("./List").ListProps> & {
13
- /** Collects related `Items` in an `ActionList`. */
14
- Group: typeof Group;
15
- /** An actionable or selectable `Item` with an optional icon and description. */
16
- Item: import("@radix-ui/react-polymorphic").ForwardRefComponent<"li", import("./Item").ItemProps>;
17
- /** Visually separates `Item`s or `Group`s in an `ActionList`. */
18
- Divider: typeof Divider;
19
- Description: import("react").FC<import("./Description").DescriptionProps>;
20
- LeadingVisual: import("react").FC<import("../sx").SxProp & {
21
- children: import("react").ReactNode;
22
- }>;
23
- TrailingVisual: import("react").FC<import("../sx").SxProp & {
24
- children: import("react").ReactNode;
25
- }>;
26
- };
@@ -1,23 +0,0 @@
1
- import { List } from './List';
2
- import { Group } from './Group';
3
- import { Item } from './Item';
4
- import { Divider } from './Divider';
5
- import { Description } from './Description';
6
- import { LeadingVisual, TrailingVisual } from './Visuals';
7
-
8
- /**
9
- * Collection of list-related components.
10
- */
11
- export const ActionList = Object.assign(List, {
12
- /** Collects related `Items` in an `ActionList`. */
13
- Group,
14
-
15
- /** An actionable or selectable `Item` with an optional icon and description. */
16
- Item,
17
-
18
- /** Visually separates `Item`s or `Group`s in an `ActionList`. */
19
- Divider,
20
- Description,
21
- LeadingVisual,
22
- TrailingVisual
23
- });
@@ -1,17 +0,0 @@
1
- import React from 'react';
2
- /** createSlots is a factory that can create a
3
- * typesafe Slots + Slot pair to use in a component definition
4
- * For example: ActionList.Item uses createSlots to get a Slots wrapper
5
- * + Slot component that is used by LeadingVisual, Description
6
- */
7
- declare const createSlots: <SlotNames extends string>(slotNames: SlotNames[]) => {
8
- Slots: React.FC<{
9
- context: Record<string, unknown>;
10
- children: (slots: { [key in SlotNames]?: React.ReactNode; }) => React.ReactNode;
11
- }>;
12
- Slot: React.FC<{
13
- name: SlotNames;
14
- children: React.ReactNode | ((context: Record<string, unknown>) => React.ReactNode);
15
- }>;
16
- };
17
- export default createSlots;
@@ -1,84 +0,0 @@
1
- import React from 'react';
2
- import { useForceUpdate } from './use-force-update';
3
- /** createSlots is a factory that can create a
4
- * typesafe Slots + Slot pair to use in a component definition
5
- * For example: ActionList.Item uses createSlots to get a Slots wrapper
6
- * + Slot component that is used by LeadingVisual, Description
7
- */
8
-
9
- const createSlots = slotNames => {
10
- const SlotsContext = /*#__PURE__*/React.createContext({
11
- registerSlot: () => null,
12
- unregisterSlot: () => null,
13
- context: {}
14
- });
15
- /** Slots uses a Double render strategy inspired by [reach-ui/descendants](https://github.com/reach/reach-ui/tree/develop/packages/descendants)
16
- * Slot registers themself with the Slots parent.
17
- * When all the children have mounted = registered themselves in slot,
18
- * we re-render the parent component to render with slots
19
- */
20
-
21
- const Slots = ({
22
- context,
23
- children
24
- }) => {
25
- // initialise slots
26
- const slotsDefinition = {};
27
- slotNames.map(name => slotsDefinition[name] = null);
28
- const slotsRef = React.useRef(slotsDefinition);
29
- const rerenderWithSlots = useForceUpdate();
30
- const [isMounted, setIsMounted] = React.useState(false); // fires after all the effects in children
31
-
32
- React.useEffect(() => {
33
- rerenderWithSlots();
34
- setIsMounted(true);
35
- }, [rerenderWithSlots]);
36
- const registerSlot = React.useCallback((name, contents) => {
37
- slotsRef.current[name] = contents; // don't render until the component mounts = all slots are registered
38
-
39
- if (isMounted) rerenderWithSlots();
40
- }, [isMounted, rerenderWithSlots]); // Slot can be removed from the tree as well,
41
- // we need to unregister them from the slot
42
-
43
- const unregisterSlot = React.useCallback(name => {
44
- slotsRef.current[name] = null;
45
- rerenderWithSlots();
46
- }, [rerenderWithSlots]);
47
- /**
48
- * Slots uses a render prop API so abstract the
49
- * implementation detail of using a context provider.
50
- */
51
-
52
- const slots = slotsRef.current;
53
- return /*#__PURE__*/React.createElement(SlotsContext.Provider, {
54
- value: {
55
- registerSlot,
56
- unregisterSlot,
57
- context
58
- }
59
- }, children(slots));
60
- };
61
-
62
- const Slot = ({
63
- name,
64
- children
65
- }) => {
66
- const {
67
- registerSlot,
68
- unregisterSlot,
69
- context
70
- } = React.useContext(SlotsContext);
71
- React.useEffect(() => {
72
- registerSlot(name, typeof children === 'function' ? children(context) : children);
73
- return () => unregisterSlot(name);
74
- }, [name, children, registerSlot, unregisterSlot, context]);
75
- return null;
76
- };
77
-
78
- return {
79
- Slots,
80
- Slot
81
- };
82
- };
83
-
84
- export default createSlots;
@@ -1 +0,0 @@
1
- export declare const useForceUpdate: () => () => void;
@@ -1,6 +0,0 @@
1
- // Inspired from reach-ui: https://github.com/reach/reach-ui/blob/develop/packages/utils/src/use-force-update.ts
2
- import React from 'react';
3
- export const useForceUpdate = () => {
4
- const [, rerender] = React.useState({});
5
- return React.useCallback(() => rerender({}), []);
6
- };