@primer/components 0.0.0-2021112103924 → 0.0.0-2021112133435
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 +5 -5
- package/dist/browser.esm.js +192 -186
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +197 -191
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList2/Item.js +6 -4
- package/lib/ActionList2/List.js +2 -2
- package/lib/ActionList2/{ActionListContainerContext.d.ts → MenuContext.d.ts} +3 -3
- package/lib/ActionList2/{ActionListContainerContext.js → MenuContext.js} +3 -3
- package/lib/ActionList2/Selection.js +4 -4
- package/lib/ActionMenu2.d.ts +9 -13
- package/lib/ActionMenu2.js +29 -63
- package/lib/Checkbox.d.ts +1 -1
- package/lib/Radio.d.ts +38 -0
- package/lib/Radio.js +55 -0
- package/lib/hooks/index.d.ts +0 -1
- package/lib/hooks/index.js +1 -9
- package/lib/index.d.ts +2 -0
- package/lib/index.js +8 -0
- package/lib-esm/ActionList2/Item.js +6 -4
- package/lib-esm/ActionList2/List.js +2 -2
- package/lib-esm/ActionList2/{ActionListContainerContext.d.ts → MenuContext.d.ts} +3 -3
- package/lib-esm/ActionList2/{ActionListContainerContext.js → MenuContext.js} +1 -1
- package/lib-esm/ActionList2/Selection.js +4 -4
- package/lib-esm/ActionMenu2.d.ts +9 -13
- package/lib-esm/ActionMenu2.js +27 -60
- package/lib-esm/Checkbox.d.ts +1 -1
- package/lib-esm/Radio.d.ts +38 -0
- package/lib-esm/Radio.js +40 -0
- package/lib-esm/hooks/index.d.ts +0 -1
- package/lib-esm/hooks/index.js +1 -2
- package/lib-esm/index.d.ts +2 -0
- package/lib-esm/index.js +1 -0
- package/package.json +1 -1
package/lib-esm/ActionMenu2.d.ts
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
import { ButtonProps } from './Button';
|
2
2
|
import React from 'react';
|
3
|
-
import { AnchoredOverlayProps } from './AnchoredOverlay';
|
4
3
|
import { OverlayProps } from './Overlay';
|
5
|
-
|
6
|
-
|
7
|
-
export declare type ActionMenuProps = {
|
4
|
+
import { AnchoredOverlayWrapperAnchorProps } from './AnchoredOverlay/AnchoredOverlay';
|
5
|
+
declare type ActionMenuBaseProps = {
|
8
6
|
/**
|
9
|
-
* Recommended: `ActionMenu.Button` or `ActionMenu.Anchor` with `
|
7
|
+
* Recommended: `ActionMenu.Button` or `ActionMenu.Anchor` with ActionList`
|
10
8
|
*/
|
11
9
|
children: React.ReactElement[] | React.ReactElement;
|
12
10
|
/**
|
@@ -17,18 +15,17 @@ export declare type ActionMenuProps = {
|
|
17
15
|
* If defined, will control the open/closed state of the overlay. Must be used in conjuction with `open`.
|
18
16
|
*/
|
19
17
|
onOpenChange?: (s: boolean) => void;
|
20
|
-
|
18
|
+
/**
|
19
|
+
* Props to be spread on the internal `Overlay` component.
|
20
|
+
*/
|
21
|
+
overlayProps?: Partial<OverlayProps>;
|
22
|
+
};
|
23
|
+
export declare type ActionMenuProps = ActionMenuBaseProps & AnchoredOverlayWrapperAnchorProps;
|
21
24
|
export declare type MenuAnchorProps = {
|
22
25
|
children: React.ReactElement;
|
23
26
|
};
|
24
27
|
/** this component is syntactical sugar 🍭 */
|
25
28
|
export declare type MenuButtonProps = ButtonProps;
|
26
|
-
declare type MenuOverlayProps = Partial<OverlayProps> & {
|
27
|
-
/**
|
28
|
-
* Recommended: `ActionList`
|
29
|
-
*/
|
30
|
-
children: React.ReactElement[] | React.ReactElement;
|
31
|
-
};
|
32
29
|
export declare const ActionMenu: React.FC<ActionMenuProps> & {
|
33
30
|
Button: React.ForwardRefExoticComponent<Pick<{
|
34
31
|
color?: string | undefined;
|
@@ -308,7 +305,6 @@ export declare const ActionMenu: React.FC<ActionMenuProps> & {
|
|
308
305
|
theme?: any;
|
309
306
|
}, "color" | "translate" | "hidden" | "children" | "theme" | "value" | "form" | "slot" | "style" | "title" | "variant" | "role" | "sx" | "type" | "name" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "css" | "as" | "disabled" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget"> & React.RefAttributes<React.RefObject<HTMLElement> | undefined>>;
|
310
307
|
Anchor: React.ForwardRefExoticComponent<MenuAnchorProps & React.RefAttributes<React.RefObject<HTMLElement> | undefined>>;
|
311
|
-
Overlay: React.FC<MenuOverlayProps>;
|
312
308
|
Divider: React.FC<import("./sx").SxProp>;
|
313
309
|
};
|
314
310
|
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 {
|
4
|
+
import { useProvidedStateOrCreate } from './hooks/useProvidedStateOrCreate';
|
5
|
+
import { useProvidedRefOrCreate } from './hooks';
|
5
6
|
import { Divider } from './ActionList2/Divider';
|
6
|
-
import {
|
7
|
-
export const MenuContext = /*#__PURE__*/React.createContext({
|
8
|
-
renderAnchor: null,
|
9
|
-
open: false
|
10
|
-
});
|
7
|
+
import { MenuContext as ActionListMenuContext } from './ActionList2/MenuContext';
|
11
8
|
|
12
|
-
const
|
9
|
+
const ActionMenuBase = ({
|
13
10
|
anchorRef: externalAnchorRef,
|
14
11
|
open,
|
15
12
|
onOpenChange,
|
13
|
+
overlayProps,
|
16
14
|
children
|
17
15
|
}) => {
|
18
16
|
const [combinedOpenState, setCombinedOpenState] = useProvidedStateOrCreate(open, onOpenChange, false);
|
17
|
+
const anchorRef = useProvidedRefOrCreate(externalAnchorRef);
|
19
18
|
const onOpen = React.useCallback(() => setCombinedOpenState(true), [setCombinedOpenState]);
|
20
19
|
const onClose = React.useCallback(() => setCombinedOpenState(false), [setCombinedOpenState]);
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
// with additional props for accessibility
|
25
|
-
|
26
|
-
const contents = React.Children.map(children, child => {
|
20
|
+
let renderAnchor = null;
|
21
|
+
const contents = [];
|
22
|
+
React.Children.map(children, child => {
|
27
23
|
if (child.type === MenuButton || child.type === Anchor) {
|
28
24
|
renderAnchor = anchorProps => /*#__PURE__*/React.cloneElement(child, anchorProps);
|
29
|
-
|
30
|
-
|
25
|
+
} else {
|
26
|
+
contents.push(child);
|
31
27
|
}
|
32
|
-
|
33
|
-
return child;
|
34
28
|
});
|
35
|
-
return /*#__PURE__*/React.createElement(
|
29
|
+
return /*#__PURE__*/React.createElement(AnchoredOverlay, {
|
30
|
+
renderAnchor: renderAnchor,
|
31
|
+
anchorRef: anchorRef,
|
32
|
+
open: combinedOpenState,
|
33
|
+
onOpen: onOpen,
|
34
|
+
onClose: onClose,
|
35
|
+
overlayProps: overlayProps
|
36
|
+
}, /*#__PURE__*/React.createElement(ActionListMenuContext.Provider, {
|
36
37
|
value: {
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
onClose
|
38
|
+
parent: 'ActionMenu',
|
39
|
+
listRole: 'menu',
|
40
|
+
itemRole: 'menuitem',
|
41
|
+
afterSelect: onClose
|
42
42
|
}
|
43
|
-
}, contents);
|
43
|
+
}, contents));
|
44
44
|
};
|
45
45
|
|
46
|
-
|
46
|
+
ActionMenuBase.displayName = "ActionMenuBase";
|
47
47
|
const Anchor = /*#__PURE__*/React.forwardRef(({
|
48
48
|
children,
|
49
49
|
...anchorProps
|
@@ -59,42 +59,9 @@ const MenuButton = /*#__PURE__*/React.forwardRef((props, anchorRef) => {
|
|
59
59
|
ref: anchorRef
|
60
60
|
}, /*#__PURE__*/React.createElement(Button, props));
|
61
61
|
});
|
62
|
-
|
63
|
-
const
|
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, {
|
62
|
+
ActionMenuBase.displayName = 'ActionMenu';
|
63
|
+
export const ActionMenu = Object.assign(ActionMenuBase, {
|
96
64
|
Button: MenuButton,
|
97
65
|
Anchor,
|
98
|
-
Overlay,
|
99
66
|
Divider
|
100
67
|
});
|
package/lib-esm/Checkbox.d.ts
CHANGED
@@ -25,5 +25,5 @@ export declare type CheckboxProps = {
|
|
25
25
|
/**
|
26
26
|
* An accessible, native checkbox component
|
27
27
|
*/
|
28
|
-
declare const Checkbox: React.ForwardRefExoticComponent<Pick<CheckboxProps, "sx" | keyof React.InputHTMLAttributes<HTMLInputElement> | "
|
28
|
+
declare const Checkbox: React.ForwardRefExoticComponent<Pick<CheckboxProps, "sx" | keyof React.InputHTMLAttributes<HTMLInputElement> | "validationStatus" | "indeterminate"> & React.RefAttributes<HTMLInputElement>>;
|
29
29
|
export default Checkbox;
|
@@ -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,4 +9,3 @@ 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,5 +4,4 @@ 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';
|
8
|
-
export { useProvidedStateOrCreate } from './useProvidedStateOrCreate';
|
7
|
+
export { useRenderForcingRef } from './useRenderForcingRef';
|
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';
|
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';
|