@primer/components 0.0.0-202111321290 → 0.0.0-2021116132249
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/dist/browser.esm.js +2 -2
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +2 -2
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList2/{MenuContext.d.ts → ActionListContainerContext.d.ts} +3 -3
- package/lib/ActionList2/{MenuContext.js → ActionListContainerContext.js} +3 -3
- package/lib/ActionList2/Item.js +4 -6
- package/lib/ActionList2/List.js +2 -2
- package/lib/ActionList2/Selection.js +4 -4
- package/lib/ActionMenu2.d.ts +13 -9
- package/lib/ActionMenu2.js +63 -29
- package/lib/Autocomplete/AutocompleteMenu.js +13 -6
- package/lib/Radio.d.ts +38 -0
- package/lib/Radio.js +55 -0
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/index.js +9 -1
- package/lib/index.d.ts +2 -3
- package/lib/index.js +8 -24
- package/lib-esm/ActionList2/{MenuContext.d.ts → ActionListContainerContext.d.ts} +3 -3
- package/lib-esm/ActionList2/{MenuContext.js → ActionListContainerContext.js} +1 -1
- package/lib-esm/ActionList2/Item.js +4 -6
- package/lib-esm/ActionList2/List.js +2 -2
- package/lib-esm/ActionList2/Selection.js +4 -4
- package/lib-esm/ActionMenu2.d.ts +13 -9
- package/lib-esm/ActionMenu2.js +60 -27
- package/lib-esm/Autocomplete/AutocompleteMenu.js +13 -3
- package/lib-esm/Radio.d.ts +38 -0
- package/lib-esm/Radio.js +40 -0
- package/lib-esm/hooks/index.d.ts +1 -0
- package/lib-esm/hooks/index.js +2 -1
- package/lib-esm/index.d.ts +2 -3
- package/lib-esm/index.js +1 -3
- package/package.json +2 -2
- package/lib/CheckboxInputField.d.ts +0 -10
- package/lib/CheckboxInputField.js +0 -73
- package/lib/RadioInputField.d.ts +0 -8
- package/lib/RadioInputField.js +0 -82
- package/lib/TextInputField.d.ts +0 -583
- package/lib/TextInputField.js +0 -66
- package/lib/_InputCaption.d.ts +0 -13
- package/lib/_InputCaption.js +0 -26
- package/lib/_InputField/InputField.d.ts +0 -39
- package/lib/_InputField/InputField.js +0 -90
- package/lib/_InputField/InputFieldCaption.d.ts +0 -3
- package/lib/_InputField/InputFieldCaption.js +0 -30
- package/lib/_InputField/InputFieldLabel.d.ts +0 -9
- package/lib/_InputField/InputFieldLabel.js +0 -34
- package/lib/_InputField/InputFieldValidation.d.ts +0 -6
- package/lib/_InputField/InputFieldValidation.js +0 -17
- package/lib/_InputField/ToggleInputField.d.ts +0 -13
- package/lib/_InputField/ToggleInputField.js +0 -71
- package/lib/_InputField/ToggleInputLeadingVisual.d.ts +0 -3
- package/lib/_InputField/ToggleInputLeadingVisual.js +0 -22
- package/lib/_InputField/ValidationAnimationContainer.d.ts +0 -6
- package/lib/_InputField/ValidationAnimationContainer.js +0 -48
- package/lib/_InputField/index.d.ts +0 -1
- package/lib/_InputField/index.js +0 -15
- package/lib/_InputField/slots.d.ts +0 -13
- package/lib/_InputField/slots.js +0 -17
- package/lib/_InputLabel.d.ts +0 -8
- package/lib/_InputLabel.js +0 -44
- package/lib/_InputValidation.d.ts +0 -8
- package/lib/_InputValidation.js +0 -56
- package/lib/_VisuallyHidden.d.ts +0 -6
- package/lib/_VisuallyHidden.js +0 -39
- package/lib/utils/types/FormValidationStatus.d.ts +0 -1
- package/lib/utils/types/FormValidationStatus.js +0 -1
- package/lib-esm/CheckboxInputField.d.ts +0 -10
- package/lib-esm/CheckboxInputField.js +0 -56
- package/lib-esm/RadioInputField.d.ts +0 -8
- package/lib-esm/RadioInputField.js +0 -65
- package/lib-esm/TextInputField.d.ts +0 -583
- package/lib-esm/TextInputField.js +0 -50
- package/lib-esm/_InputCaption.d.ts +0 -13
- package/lib-esm/_InputCaption.js +0 -15
- package/lib-esm/_InputField/InputField.d.ts +0 -39
- package/lib-esm/_InputField/InputField.js +0 -70
- package/lib-esm/_InputField/InputFieldCaption.d.ts +0 -3
- package/lib-esm/_InputField/InputFieldCaption.js +0 -18
- package/lib-esm/_InputField/InputFieldLabel.d.ts +0 -9
- package/lib-esm/_InputField/InputFieldLabel.js +0 -22
- package/lib-esm/_InputField/InputFieldValidation.d.ts +0 -6
- package/lib-esm/_InputField/InputFieldValidation.js +0 -7
- package/lib-esm/_InputField/ToggleInputField.d.ts +0 -13
- package/lib-esm/_InputField/ToggleInputField.js +0 -54
- package/lib-esm/_InputField/ToggleInputLeadingVisual.d.ts +0 -3
- package/lib-esm/_InputField/ToggleInputLeadingVisual.js +0 -11
- package/lib-esm/_InputField/ValidationAnimationContainer.d.ts +0 -6
- package/lib-esm/_InputField/ValidationAnimationContainer.js +0 -33
- package/lib-esm/_InputField/index.d.ts +0 -1
- package/lib-esm/_InputField/index.js +0 -1
- package/lib-esm/_InputField/slots.d.ts +0 -13
- package/lib-esm/_InputField/slots.js +0 -5
- package/lib-esm/_InputLabel.d.ts +0 -8
- package/lib-esm/_InputLabel.js +0 -32
- package/lib-esm/_InputValidation.d.ts +0 -8
- package/lib-esm/_InputValidation.js +0 -43
- package/lib-esm/_VisuallyHidden.d.ts +0 -6
- package/lib-esm/_VisuallyHidden.js +0 -26
- package/lib-esm/utils/types/FormValidationStatus.d.ts +0 -1
- package/lib-esm/utils/types/FormValidationStatus.js +0 -1
@@ -3,7 +3,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
3
3
|
import React from 'react';
|
4
4
|
import styled from 'styled-components';
|
5
5
|
import sx, { merge } from '../sx';
|
6
|
-
import {
|
6
|
+
import { ActionListContainerContext } from './ActionListContainerContext';
|
7
7
|
export const ListContext = /*#__PURE__*/React.createContext({});
|
8
8
|
const ListBox = styled.ul.withConfig({
|
9
9
|
displayName: "List__ListBox",
|
@@ -27,7 +27,7 @@ export const List = /*#__PURE__*/React.forwardRef(({
|
|
27
27
|
|
28
28
|
const {
|
29
29
|
listRole
|
30
|
-
} = React.useContext(
|
30
|
+
} = React.useContext(ActionListContainerContext);
|
31
31
|
return /*#__PURE__*/React.createElement(ListBox, _extends({
|
32
32
|
sx: merge(styles, sxProp),
|
33
33
|
role: role || listRole
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
2
2
|
import { CheckIcon } from '@primer/octicons-react';
|
3
3
|
import { ListContext } from './List';
|
4
4
|
import { GroupContext } from './Group';
|
5
|
-
import {
|
5
|
+
import { ActionListContainerContext } from './ActionListContainerContext';
|
6
6
|
import { LeadingVisualContainer } from './Visuals';
|
7
7
|
export const Selection = ({
|
8
8
|
selected
|
@@ -14,8 +14,8 @@ export const Selection = ({
|
|
14
14
|
selectionVariant: groupSelectionVariant
|
15
15
|
} = React.useContext(GroupContext);
|
16
16
|
const {
|
17
|
-
|
18
|
-
} = React.useContext(
|
17
|
+
container
|
18
|
+
} = React.useContext(ActionListContainerContext);
|
19
19
|
/** selectionVariant in Group can override the selectionVariant in List root */
|
20
20
|
|
21
21
|
const selectionVariant = typeof groupSelectionVariant !== 'undefined' ? groupSelectionVariant : listSelectionVariant; // if selectionVariant is not set on List, don't show selection
|
@@ -26,7 +26,7 @@ export const Selection = ({
|
|
26
26
|
return null;
|
27
27
|
}
|
28
28
|
|
29
|
-
if (
|
29
|
+
if (container === 'ActionMenu') {
|
30
30
|
throw new Error('ActionList cannot have a selectionVariant inside ActionMenu, please use DropdownMenu or SelectPanel instead. More information: https://primer.style/design/components/action-list#application');
|
31
31
|
return null;
|
32
32
|
}
|
package/lib-esm/ActionMenu2.d.ts
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
import { ButtonProps } from './Button';
|
2
2
|
import React from 'react';
|
3
|
+
import { AnchoredOverlayProps } from './AnchoredOverlay';
|
3
4
|
import { OverlayProps } from './Overlay';
|
4
|
-
|
5
|
-
declare
|
5
|
+
declare type MenuContextProps = Pick<AnchoredOverlayProps, 'anchorRef' | 'renderAnchor' | 'open' | 'onOpen' | 'onClose'>;
|
6
|
+
export declare const MenuContext: React.Context<MenuContextProps>;
|
7
|
+
export declare type ActionMenuProps = {
|
6
8
|
/**
|
7
|
-
* Recommended: `ActionMenu.Button` or `ActionMenu.Anchor` with
|
9
|
+
* Recommended: `ActionMenu.Button` or `ActionMenu.Anchor` with `ActionMenu.Overlay`
|
8
10
|
*/
|
9
11
|
children: React.ReactElement[] | React.ReactElement;
|
10
12
|
/**
|
@@ -15,17 +17,18 @@ declare type ActionMenuBaseProps = {
|
|
15
17
|
* If defined, will control the open/closed state of the overlay. Must be used in conjuction with `open`.
|
16
18
|
*/
|
17
19
|
onOpenChange?: (s: boolean) => void;
|
18
|
-
|
19
|
-
* Props to be spread on the internal `Overlay` component.
|
20
|
-
*/
|
21
|
-
overlayProps?: Partial<OverlayProps>;
|
22
|
-
};
|
23
|
-
export declare type ActionMenuProps = ActionMenuBaseProps & AnchoredOverlayWrapperAnchorProps;
|
20
|
+
} & Pick<AnchoredOverlayProps, 'anchorRef'>;
|
24
21
|
export declare type MenuAnchorProps = {
|
25
22
|
children: React.ReactElement;
|
26
23
|
};
|
27
24
|
/** this component is syntactical sugar 🍭 */
|
28
25
|
export declare type MenuButtonProps = ButtonProps;
|
26
|
+
declare type MenuOverlayProps = Partial<OverlayProps> & {
|
27
|
+
/**
|
28
|
+
* Recommended: `ActionList`
|
29
|
+
*/
|
30
|
+
children: React.ReactElement[] | React.ReactElement;
|
31
|
+
};
|
29
32
|
export declare const ActionMenu: React.FC<ActionMenuProps> & {
|
30
33
|
Button: React.ForwardRefExoticComponent<Pick<{
|
31
34
|
color?: string | undefined;
|
@@ -308,6 +311,7 @@ export declare const ActionMenu: React.FC<ActionMenuProps> & {
|
|
308
311
|
variant?: "small" | "medium" | "large" | undefined;
|
309
312
|
}> & React.RefAttributes<React.RefObject<HTMLElement> | undefined>>;
|
310
313
|
Anchor: React.ForwardRefExoticComponent<MenuAnchorProps & React.RefAttributes<React.RefObject<HTMLElement> | undefined>>;
|
314
|
+
Overlay: React.FC<MenuOverlayProps>;
|
311
315
|
Divider: React.FC<import("./sx").SxProp>;
|
312
316
|
};
|
313
317
|
export {};
|
package/lib-esm/ActionMenu2.js
CHANGED
@@ -1,49 +1,49 @@
|
|
1
1
|
import Button from './Button';
|
2
2
|
import React from 'react';
|
3
3
|
import { AnchoredOverlay } from './AnchoredOverlay';
|
4
|
-
import { useProvidedStateOrCreate } from './hooks
|
5
|
-
import { useProvidedRefOrCreate } from './hooks';
|
4
|
+
import { useProvidedRefOrCreate, useProvidedStateOrCreate } from './hooks';
|
6
5
|
import { Divider } from './ActionList2/Divider';
|
7
|
-
import {
|
6
|
+
import { ActionListContainerContext } from './ActionList2/ActionListContainerContext';
|
7
|
+
export const MenuContext = /*#__PURE__*/React.createContext({
|
8
|
+
renderAnchor: null,
|
9
|
+
open: false
|
10
|
+
});
|
8
11
|
|
9
|
-
const
|
12
|
+
const Menu = ({
|
10
13
|
anchorRef: externalAnchorRef,
|
11
14
|
open,
|
12
15
|
onOpenChange,
|
13
|
-
overlayProps,
|
14
16
|
children
|
15
17
|
}) => {
|
16
18
|
const [combinedOpenState, setCombinedOpenState] = useProvidedStateOrCreate(open, onOpenChange, false);
|
17
|
-
const anchorRef = useProvidedRefOrCreate(externalAnchorRef);
|
18
19
|
const onOpen = React.useCallback(() => setCombinedOpenState(true), [setCombinedOpenState]);
|
19
20
|
const onClose = React.useCallback(() => setCombinedOpenState(false), [setCombinedOpenState]);
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
const anchorRef = useProvidedRefOrCreate(externalAnchorRef);
|
22
|
+
let renderAnchor = null; // 🚨 Hack for good API!
|
23
|
+
// we strip out Anchor from children and pass it to AnchoredOverlay to render
|
24
|
+
// with additional props for accessibility
|
25
|
+
|
26
|
+
const contents = React.Children.map(children, child => {
|
23
27
|
if (child.type === MenuButton || child.type === Anchor) {
|
24
28
|
renderAnchor = anchorProps => /*#__PURE__*/React.cloneElement(child, anchorProps);
|
25
|
-
|
26
|
-
|
29
|
+
|
30
|
+
return null;
|
27
31
|
}
|
32
|
+
|
33
|
+
return child;
|
28
34
|
});
|
29
|
-
return /*#__PURE__*/React.createElement(
|
30
|
-
renderAnchor: renderAnchor,
|
31
|
-
anchorRef: anchorRef,
|
32
|
-
open: combinedOpenState,
|
33
|
-
onOpen: onOpen,
|
34
|
-
onClose: onClose,
|
35
|
-
overlayProps: overlayProps
|
36
|
-
}, /*#__PURE__*/React.createElement(ActionListMenuContext.Provider, {
|
35
|
+
return /*#__PURE__*/React.createElement(MenuContext.Provider, {
|
37
36
|
value: {
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
anchorRef,
|
38
|
+
renderAnchor,
|
39
|
+
open: combinedOpenState,
|
40
|
+
onOpen,
|
41
|
+
onClose
|
42
42
|
}
|
43
|
-
}, contents)
|
43
|
+
}, contents);
|
44
44
|
};
|
45
45
|
|
46
|
-
|
46
|
+
Menu.displayName = "Menu";
|
47
47
|
const Anchor = /*#__PURE__*/React.forwardRef(({
|
48
48
|
children,
|
49
49
|
...anchorProps
|
@@ -59,9 +59,42 @@ const MenuButton = /*#__PURE__*/React.forwardRef((props, anchorRef) => {
|
|
59
59
|
ref: anchorRef
|
60
60
|
}, /*#__PURE__*/React.createElement(Button, props));
|
61
61
|
});
|
62
|
-
|
63
|
-
|
62
|
+
|
63
|
+
const Overlay = ({
|
64
|
+
children,
|
65
|
+
...overlayProps
|
66
|
+
}) => {
|
67
|
+
// we typecast anchorRef as required instead of optional
|
68
|
+
// because we know that we're setting it in context in Menu
|
69
|
+
const {
|
70
|
+
anchorRef,
|
71
|
+
renderAnchor,
|
72
|
+
open,
|
73
|
+
onOpen,
|
74
|
+
onClose
|
75
|
+
} = React.useContext(MenuContext);
|
76
|
+
return /*#__PURE__*/React.createElement(AnchoredOverlay, {
|
77
|
+
anchorRef: anchorRef,
|
78
|
+
renderAnchor: renderAnchor,
|
79
|
+
open: open,
|
80
|
+
onOpen: onOpen,
|
81
|
+
onClose: onClose,
|
82
|
+
overlayProps: overlayProps
|
83
|
+
}, /*#__PURE__*/React.createElement(ActionListContainerContext.Provider, {
|
84
|
+
value: {
|
85
|
+
container: 'ActionMenu',
|
86
|
+
listRole: 'menu',
|
87
|
+
itemRole: 'menuitem',
|
88
|
+
afterSelect: onClose
|
89
|
+
}
|
90
|
+
}, children));
|
91
|
+
};
|
92
|
+
|
93
|
+
Overlay.displayName = "Overlay";
|
94
|
+
Menu.displayName = 'ActionMenu';
|
95
|
+
export const ActionMenu = Object.assign(Menu, {
|
64
96
|
Button: MenuButton,
|
65
97
|
Anchor,
|
98
|
+
Overlay,
|
66
99
|
Divider
|
67
100
|
});
|
@@ -6,7 +6,6 @@ import { AutocompleteContext } from './AutocompleteContext';
|
|
6
6
|
import { PlusIcon } from '@primer/octicons-react';
|
7
7
|
import { uniqueId } from '../utils/uniqueId';
|
8
8
|
import { scrollIntoViewingArea } from '../behaviors/scrollIntoViewingArea';
|
9
|
-
import VisuallyHidden from '../_VisuallyHidden';
|
10
9
|
|
11
10
|
const getDefaultSortFn = isItemSelectedFn => (itemIdA, itemIdB) => isItemSelectedFn(itemIdA) === isItemSelectedFn(itemIdB) ? 0 : isItemSelectedFn(itemIdA) ? -1 : 1;
|
12
11
|
|
@@ -165,8 +164,19 @@ function AutocompleteMenu(props) {
|
|
165
164
|
setSelectedItemLength(selectedItemIds.length);
|
166
165
|
}
|
167
166
|
}, [selectedItemIds, setSelectedItemLength]);
|
168
|
-
return /*#__PURE__*/React.createElement(
|
169
|
-
|
167
|
+
return /*#__PURE__*/React.createElement(Box, {
|
168
|
+
sx: !showMenu ? {
|
169
|
+
// visually hides this label for sighted users
|
170
|
+
position: 'absolute',
|
171
|
+
width: '1px',
|
172
|
+
height: '1px',
|
173
|
+
padding: '0',
|
174
|
+
margin: '-1px',
|
175
|
+
overflow: 'hidden',
|
176
|
+
clip: 'rect(0, 0, 0, 0)',
|
177
|
+
whiteSpace: 'nowrap',
|
178
|
+
borderWidth: '0'
|
179
|
+
} : {}
|
170
180
|
}, loading ? /*#__PURE__*/React.createElement(Box, {
|
171
181
|
p: 3,
|
172
182
|
display: "flex",
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import React, { InputHTMLAttributes } from 'react';
|
2
|
+
import { SxProp } from './sx';
|
3
|
+
export declare type RadioProps = {
|
4
|
+
/**
|
5
|
+
* A unique value that is never shown to the user.
|
6
|
+
* Used during form submission and to identify which radio button in a group is selected
|
7
|
+
*/
|
8
|
+
value: string;
|
9
|
+
/**
|
10
|
+
* Name attribute of the input element. Required for grouping radio inputs
|
11
|
+
*/
|
12
|
+
name: string;
|
13
|
+
/**
|
14
|
+
* Apply inactive visual appearance to the radio button
|
15
|
+
*/
|
16
|
+
disabled?: boolean;
|
17
|
+
/**
|
18
|
+
* Indicates whether the radio button is selected
|
19
|
+
*/
|
20
|
+
checked?: boolean;
|
21
|
+
/**
|
22
|
+
* Forward a ref to the underlying input element
|
23
|
+
*/
|
24
|
+
ref?: React.RefObject<HTMLInputElement>;
|
25
|
+
/**
|
26
|
+
* Indicates whether the radio button must be checked before the form can be submitted
|
27
|
+
*/
|
28
|
+
required?: boolean;
|
29
|
+
/**
|
30
|
+
* Indicates whether the radio button validation state is non-standard
|
31
|
+
*/
|
32
|
+
validationStatus?: 'error' | 'success';
|
33
|
+
} & InputHTMLAttributes<HTMLInputElement> & SxProp;
|
34
|
+
/**
|
35
|
+
* An accessible, native radio component for selecting one option from a list.
|
36
|
+
*/
|
37
|
+
declare const Radio: React.ForwardRefExoticComponent<Pick<RadioProps, "sx" | keyof React.InputHTMLAttributes<HTMLInputElement> | "validationStatus"> & React.RefAttributes<HTMLInputElement>>;
|
38
|
+
export default Radio;
|
package/lib-esm/Radio.js
ADDED
@@ -0,0 +1,40 @@
|
|
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 styled from 'styled-components';
|
4
|
+
import React from 'react';
|
5
|
+
import sx from './sx';
|
6
|
+
const StyledRadio = styled.input.withConfig({
|
7
|
+
displayName: "Radio__StyledRadio",
|
8
|
+
componentId: "sc-1ak1fjg-0"
|
9
|
+
})(["cursor:pointer;", " ", ""], props => props.disabled && `cursor: not-allowed;`, sx);
|
10
|
+
/**
|
11
|
+
* An accessible, native radio component for selecting one option from a list.
|
12
|
+
*/
|
13
|
+
|
14
|
+
const Radio = /*#__PURE__*/React.forwardRef(({
|
15
|
+
checked,
|
16
|
+
disabled,
|
17
|
+
sx: sxProp,
|
18
|
+
required,
|
19
|
+
validationStatus,
|
20
|
+
value,
|
21
|
+
name,
|
22
|
+
...rest
|
23
|
+
}, ref) => {
|
24
|
+
return /*#__PURE__*/React.createElement(StyledRadio, _extends({
|
25
|
+
type: "radio",
|
26
|
+
value: value,
|
27
|
+
name: name,
|
28
|
+
ref: ref,
|
29
|
+
disabled: disabled,
|
30
|
+
"aria-disabled": disabled ? 'true' : 'false',
|
31
|
+
checked: checked,
|
32
|
+
"aria-checked": checked ? 'true' : 'false',
|
33
|
+
required: required,
|
34
|
+
"aria-required": required ? 'true' : 'false',
|
35
|
+
"aria-invalid": validationStatus === 'error' ? 'true' : 'false',
|
36
|
+
sx: sxProp
|
37
|
+
}, rest));
|
38
|
+
});
|
39
|
+
Radio.displayName = 'Radio';
|
40
|
+
export default Radio;
|
package/lib-esm/hooks/index.d.ts
CHANGED
@@ -9,3 +9,4 @@ export { useAnchoredPosition } from './useAnchoredPosition';
|
|
9
9
|
export { useOverlay } from './useOverlay';
|
10
10
|
export type { UseOverlaySettings } from './useOverlay';
|
11
11
|
export { useRenderForcingRef } from './useRenderForcingRef';
|
12
|
+
export { useProvidedStateOrCreate } from './useProvidedStateOrCreate';
|
package/lib-esm/hooks/index.js
CHANGED
@@ -4,4 +4,5 @@ export { useOnEscapePress } from './useOnEscapePress';
|
|
4
4
|
export { useOpenAndCloseFocus } from './useOpenAndCloseFocus';
|
5
5
|
export { useAnchoredPosition } from './useAnchoredPosition';
|
6
6
|
export { useOverlay } from './useOverlay';
|
7
|
-
export { useRenderForcingRef } from './useRenderForcingRef';
|
7
|
+
export { useRenderForcingRef } from './useRenderForcingRef';
|
8
|
+
export { useProvidedStateOrCreate } from './useProvidedStateOrCreate';
|
package/lib-esm/index.d.ts
CHANGED
@@ -21,6 +21,8 @@ export { useOpenAndCloseFocus } from './hooks/useOpenAndCloseFocus';
|
|
21
21
|
export { useOnEscapePress } from './hooks/useOnEscapePress';
|
22
22
|
export { useOverlay } from './hooks/useOverlay';
|
23
23
|
export { useConfirm } from './Dialog/ConfirmationDialog';
|
24
|
+
export { default as Radio } from './Radio';
|
25
|
+
export type { RadioProps } from './Radio';
|
24
26
|
export { ActionList } from './ActionList';
|
25
27
|
export { ActionMenu } from './ActionMenu';
|
26
28
|
export type { ActionMenuProps } from './ActionMenu';
|
@@ -46,7 +48,6 @@ export { default as CircleBadge } from './CircleBadge';
|
|
46
48
|
export type { CircleBadgeProps, CircleBadgeIconProps } from './CircleBadge';
|
47
49
|
export { default as CircleOcticon } from './CircleOcticon';
|
48
50
|
export type { CircleOcticonProps } from './CircleOcticon';
|
49
|
-
export { default as CheckboxInputField } from './CheckboxInputField';
|
50
51
|
export { default as CounterLabel } from './CounterLabel';
|
51
52
|
export type { CounterLabelProps } from './CounterLabel';
|
52
53
|
export { default as Details } from './Details';
|
@@ -87,7 +88,6 @@ export { default as Popover } from './Popover';
|
|
87
88
|
export type { PopoverProps, PopoverContentProps } from './Popover';
|
88
89
|
export { default as ProgressBar } from './ProgressBar';
|
89
90
|
export type { ProgressBarProps } from './ProgressBar';
|
90
|
-
export { default as RadioInputField } from './RadioInputField';
|
91
91
|
export { default as SelectMenu } from './SelectMenu';
|
92
92
|
export type { SelectMenuProps, SelectMenuDividerProps, SelectMenuFilterProps, SelectMenuFooterProps, SelectMenuItemProps, SelectMenuListProps, SelectMenuModalProps, SelectMenuTabsProps, SelectMenuHeaderProps, SelectMenuTabProps, SelectMenuTabPanelProps, SelectMenuLoadingAnimationProps } from './SelectMenu';
|
93
93
|
export { default as SideNav } from './SideNav';
|
@@ -104,7 +104,6 @@ export { default as TabNav } from './TabNav';
|
|
104
104
|
export type { TabNavProps, TabNavLinkProps } from './TabNav';
|
105
105
|
export { default as TextInput } from './TextInput';
|
106
106
|
export type { TextInputProps } from './TextInput';
|
107
|
-
export { default as TextInputField } from './TextInputField';
|
108
107
|
export { default as TextInputWithTokens } from './TextInputWithTokens';
|
109
108
|
export type { TextInputWithTokensProps } from './TextInputWithTokens';
|
110
109
|
export { default as Text } from './Text';
|
package/lib-esm/index.js
CHANGED
@@ -17,6 +17,7 @@ export { useOnEscapePress } from './hooks/useOnEscapePress';
|
|
17
17
|
export { useOverlay } from './hooks/useOverlay';
|
18
18
|
export { useConfirm } from './Dialog/ConfirmationDialog'; // Components
|
19
19
|
|
20
|
+
export { default as Radio } from './Radio';
|
20
21
|
export { ActionList } from './ActionList';
|
21
22
|
export { ActionMenu } from './ActionMenu';
|
22
23
|
export { default as Autocomplete } from './Autocomplete';
|
@@ -30,7 +31,6 @@ export { NewButton } from './NewButton';
|
|
30
31
|
export { default as Caret } from './Caret';
|
31
32
|
export { default as CircleBadge } from './CircleBadge';
|
32
33
|
export { default as CircleOcticon } from './CircleOcticon';
|
33
|
-
export { default as CheckboxInputField } from './CheckboxInputField';
|
34
34
|
export { default as CounterLabel } from './CounterLabel';
|
35
35
|
export { default as Details } from './Details';
|
36
36
|
export { default as Dialog } from './Dialog';
|
@@ -56,7 +56,6 @@ export { default as Popover } from './Popover';
|
|
56
56
|
// export {default as Portal, registerPortalRoot} from './Portal'
|
57
57
|
// export type {PortalProps} from './Portal'
|
58
58
|
export { default as ProgressBar } from './ProgressBar';
|
59
|
-
export { default as RadioInputField } from './RadioInputField';
|
60
59
|
export { default as SelectMenu } from './SelectMenu';
|
61
60
|
export { default as SideNav } from './SideNav';
|
62
61
|
export { default as Spinner } from './Spinner';
|
@@ -65,7 +64,6 @@ export { default as StyledOcticon } from './StyledOcticon';
|
|
65
64
|
export { default as SubNav } from './SubNav';
|
66
65
|
export { default as TabNav } from './TabNav';
|
67
66
|
export { default as TextInput } from './TextInput';
|
68
|
-
export { default as TextInputField } from './TextInputField';
|
69
67
|
export { default as TextInputWithTokens } from './TextInputWithTokens';
|
70
68
|
export { default as Text } from './Text';
|
71
69
|
export { default as Timeline } from './Timeline';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@primer/components",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-2021116132249",
|
4
4
|
"description": "Primer react components",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"module": "lib-esm/index.js",
|
@@ -43,7 +43,7 @@
|
|
43
43
|
"author": "GitHub, Inc.",
|
44
44
|
"license": "MIT",
|
45
45
|
"dependencies": {
|
46
|
-
"@primer/octicons-react": "16.1.
|
46
|
+
"@primer/octicons-react": "^16.1.0",
|
47
47
|
"@primer/primitives": "7.1.1",
|
48
48
|
"@radix-ui/react-polymorphic": "0.0.14",
|
49
49
|
"@react-aria/ssr": "3.1.0",
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
declare const _default: React.FC<import("./_InputField/ToggleInputField").Props> & {
|
3
|
-
Input: React.FC<Omit<React.HTMLProps<HTMLInputElement>, "ref"> & {
|
4
|
-
ref?: React.Ref<HTMLInputElement> | undefined;
|
5
|
-
}>;
|
6
|
-
Caption: React.FC<{}>;
|
7
|
-
Label: React.FC<import("./_InputField/InputFieldLabel").Props>;
|
8
|
-
LeadingVisual: React.FC<{}>;
|
9
|
-
};
|
10
|
-
export default _default;
|
@@ -1,73 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
9
|
-
|
10
|
-
var _ = require(".");
|
11
|
-
|
12
|
-
var _InputField = _interopRequireDefault(require("./_InputField/InputField"));
|
13
|
-
|
14
|
-
var _slots = require("./_InputField/slots");
|
15
|
-
|
16
|
-
var _ToggleInputField = _interopRequireDefault(require("./_InputField/ToggleInputField"));
|
17
|
-
|
18
|
-
var _ToggleInputLeadingVisual = _interopRequireDefault(require("./_InputField/ToggleInputLeadingVisual"));
|
19
|
-
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
|
-
|
22
|
-
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); }
|
23
|
-
|
24
|
-
const Input = ({
|
25
|
-
id: idProp,
|
26
|
-
required: requiredProp,
|
27
|
-
disabled: disabledProp,
|
28
|
-
...rest
|
29
|
-
}) => {
|
30
|
-
if (idProp) {
|
31
|
-
// eslint-disable-next-line no-console
|
32
|
-
console.warn("instead of passing the 'id' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
|
33
|
-
}
|
34
|
-
|
35
|
-
if (disabledProp) {
|
36
|
-
// eslint-disable-next-line no-console
|
37
|
-
console.warn("instead of passing the 'disabled' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
|
38
|
-
}
|
39
|
-
|
40
|
-
if (requiredProp) {
|
41
|
-
// eslint-disable-next-line no-console
|
42
|
-
console.warn("instead of passing the 'required' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
|
43
|
-
}
|
44
|
-
|
45
|
-
return /*#__PURE__*/_react.default.createElement(_slots.Slot, {
|
46
|
-
name: "Input"
|
47
|
-
}, ({
|
48
|
-
disabled,
|
49
|
-
id,
|
50
|
-
required,
|
51
|
-
captionId
|
52
|
-
}) => /*#__PURE__*/_react.default.createElement(_.Checkbox, _extends({
|
53
|
-
"aria-describedby": captionId,
|
54
|
-
id: id,
|
55
|
-
required: required,
|
56
|
-
disabled: disabled
|
57
|
-
}, rest)));
|
58
|
-
};
|
59
|
-
|
60
|
-
Input.displayName = "Input";
|
61
|
-
|
62
|
-
const CheckboxInputField = props => /*#__PURE__*/_react.default.createElement(_ToggleInputField.default, props);
|
63
|
-
|
64
|
-
CheckboxInputField.displayName = "CheckboxInputField";
|
65
|
-
|
66
|
-
var _default = Object.assign(CheckboxInputField, {
|
67
|
-
Input,
|
68
|
-
Caption: _InputField.default.Caption,
|
69
|
-
Label: _InputField.default.Label,
|
70
|
-
LeadingVisual: _ToggleInputLeadingVisual.default
|
71
|
-
});
|
72
|
-
|
73
|
-
exports.default = _default;
|
package/lib/RadioInputField.d.ts
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
declare const _default: React.FC<import("./_InputField/ToggleInputField").Props> & {
|
3
|
-
Input: React.FC<React.HTMLProps<HTMLInputElement>>;
|
4
|
-
Caption: React.FC<{}>;
|
5
|
-
Label: React.FC<import("./_InputField/InputFieldLabel").Props>;
|
6
|
-
LeadingVisual: React.FC<{}>;
|
7
|
-
};
|
8
|
-
export default _default;
|
package/lib/RadioInputField.js
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
9
|
-
|
10
|
-
var _InputField = _interopRequireDefault(require("./_InputField/InputField"));
|
11
|
-
|
12
|
-
var _slots = require("./_InputField/slots");
|
13
|
-
|
14
|
-
var _ToggleInputField = _interopRequireDefault(require("./_InputField/ToggleInputField"));
|
15
|
-
|
16
|
-
var _ToggleInputLeadingVisual = _interopRequireDefault(require("./_InputField/ToggleInputLeadingVisual"));
|
17
|
-
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
|
-
|
20
|
-
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); }
|
21
|
-
|
22
|
-
// TODO: use Primer's checkbox input once it's available
|
23
|
-
// https://github.com/github/primer/issues/489
|
24
|
-
const RadioInput = props => {
|
25
|
-
return /*#__PURE__*/_react.default.createElement("input", _extends({
|
26
|
-
type: "radio"
|
27
|
-
}, props));
|
28
|
-
};
|
29
|
-
|
30
|
-
RadioInput.displayName = "RadioInput";
|
31
|
-
|
32
|
-
// pulling out `id`, `disabled`, and `required` because those should come from the parent TextInputField component
|
33
|
-
const Input = ({
|
34
|
-
id: idProp,
|
35
|
-
required: requiredProp,
|
36
|
-
disabled: disabledProp,
|
37
|
-
...rest
|
38
|
-
}) => {
|
39
|
-
if (idProp) {
|
40
|
-
// eslint-disable-next-line no-console
|
41
|
-
console.warn("instead of passing the 'id' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
|
42
|
-
}
|
43
|
-
|
44
|
-
if (disabledProp) {
|
45
|
-
// eslint-disable-next-line no-console
|
46
|
-
console.warn("instead of passing the 'disabled' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
|
47
|
-
}
|
48
|
-
|
49
|
-
if (requiredProp) {
|
50
|
-
// eslint-disable-next-line no-console
|
51
|
-
console.warn("instead of passing the 'required' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
|
52
|
-
}
|
53
|
-
|
54
|
-
return /*#__PURE__*/_react.default.createElement(_slots.Slot, {
|
55
|
-
name: "Input"
|
56
|
-
}, ({
|
57
|
-
disabled,
|
58
|
-
id,
|
59
|
-
required,
|
60
|
-
captionId
|
61
|
-
}) => /*#__PURE__*/_react.default.createElement(RadioInput, _extends({
|
62
|
-
"aria-describedby": captionId,
|
63
|
-
id: id,
|
64
|
-
required: required,
|
65
|
-
disabled: disabled
|
66
|
-
}, rest)));
|
67
|
-
};
|
68
|
-
|
69
|
-
Input.displayName = "Input";
|
70
|
-
|
71
|
-
const RadioInputField = props => /*#__PURE__*/_react.default.createElement(_ToggleInputField.default, props);
|
72
|
-
|
73
|
-
RadioInputField.displayName = "RadioInputField";
|
74
|
-
|
75
|
-
var _default = Object.assign(RadioInputField, {
|
76
|
-
Input,
|
77
|
-
Caption: _InputField.default.Caption,
|
78
|
-
Label: _InputField.default.Label,
|
79
|
-
LeadingVisual: _ToggleInputLeadingVisual.default
|
80
|
-
});
|
81
|
-
|
82
|
-
exports.default = _default;
|