@primer/components 0.0.0-202111194229 → 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 +7 -1
- package/dist/browser.esm.js +191 -203
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +190 -202
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList2/Divider.d.ts +3 -2
- package/lib/ActionList2/Divider.js +10 -5
- package/lib/ActionList2/Item.js +21 -5
- package/lib/ActionList2/List.js +11 -1
- package/lib/ActionList2/MenuContext.d.ts +10 -0
- package/lib/ActionList2/MenuContext.js +15 -0
- package/lib/ActionList2/Selection.js +11 -0
- package/lib/ActionList2/index.d.ts +1 -2
- package/lib/ActionMenu2.d.ts +310 -0
- package/lib/ActionMenu2.js +91 -0
- package/lib/Autocomplete/Autocomplete.d.ts +2 -10
- package/lib/Autocomplete/AutocompleteInput.d.ts +2 -10
- package/lib/Radio.d.ts +38 -0
- package/lib/Radio.js +55 -0
- package/lib/SelectMenu/SelectMenu.d.ts +2 -10
- package/lib/TextInput.d.ts +1 -8
- package/lib/TextInput.js +5 -16
- package/lib/TextInputWithTokens.d.ts +2 -10
- package/lib/_TextInputWrapper.d.ts +0 -3
- package/lib/_TextInputWrapper.js +7 -18
- package/lib/drafts.d.ts +1 -0
- package/lib/drafts.js +13 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +8 -0
- package/lib-esm/ActionList2/Divider.d.ts +3 -2
- package/lib-esm/ActionList2/Divider.js +8 -5
- package/lib-esm/ActionList2/Item.js +19 -5
- package/lib-esm/ActionList2/List.js +9 -1
- package/lib-esm/ActionList2/MenuContext.d.ts +10 -0
- package/lib-esm/ActionList2/MenuContext.js +3 -0
- package/lib-esm/ActionList2/Selection.js +9 -0
- package/lib-esm/ActionList2/index.d.ts +1 -2
- package/lib-esm/ActionMenu2.d.ts +310 -0
- package/lib-esm/ActionMenu2.js +67 -0
- package/lib-esm/Autocomplete/Autocomplete.d.ts +2 -10
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +2 -10
- package/lib-esm/Radio.d.ts +38 -0
- package/lib-esm/Radio.js +40 -0
- package/lib-esm/SelectMenu/SelectMenu.d.ts +2 -10
- package/lib-esm/TextInput.d.ts +1 -8
- package/lib-esm/TextInput.js +5 -16
- package/lib-esm/TextInputWithTokens.d.ts +2 -10
- package/lib-esm/_TextInputWrapper.d.ts +0 -3
- package/lib-esm/_TextInputWrapper.js +7 -18
- package/lib-esm/drafts.d.ts +1 -0
- package/lib-esm/drafts.js +2 -1
- package/lib-esm/index.d.ts +2 -0
- package/lib-esm/index.js +1 -0
- package/package.json +3 -1
@@ -20,17 +20,11 @@ declare const _default: React.FC<{
|
|
20
20
|
} & {
|
21
21
|
as?: string | React.ComponentType<any> | undefined;
|
22
22
|
forwardedAs?: string | React.ComponentType<any> | undefined;
|
23
|
-
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "
|
23
|
+
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "contrast"> & {
|
24
24
|
className?: string | undefined;
|
25
25
|
icon?: React.ComponentType<{
|
26
26
|
className?: string | undefined;
|
27
27
|
}> | undefined;
|
28
|
-
leadingVisual?: string | React.ComponentType<{
|
29
|
-
className?: string | undefined;
|
30
|
-
}> | undefined;
|
31
|
-
trailingVisual?: string | React.ComponentType<{
|
32
|
-
className?: string | undefined;
|
33
|
-
}> | undefined;
|
34
28
|
} & Pick<{
|
35
29
|
color?: string | undefined;
|
36
30
|
maxWidth?: import("styled-system").ResponsiveValue<import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
@@ -43,7 +37,6 @@ declare const _default: React.FC<{
|
|
43
37
|
slot?: string | undefined;
|
44
38
|
style?: React.CSSProperties | undefined;
|
45
39
|
title?: string | undefined;
|
46
|
-
size?: "small" | "large" | undefined;
|
47
40
|
block?: boolean | undefined;
|
48
41
|
variant?: "small" | "large" | undefined;
|
49
42
|
role?: React.AriaRole | undefined;
|
@@ -301,10 +294,9 @@ declare const _default: React.FC<{
|
|
301
294
|
disabled?: boolean | undefined;
|
302
295
|
hasIcon?: boolean | undefined;
|
303
296
|
contrast?: boolean | undefined;
|
304
|
-
validationStatus?: "error" | "warning" | undefined;
|
305
297
|
} & {
|
306
298
|
theme?: any;
|
307
|
-
}, "maxWidth" | "minWidth" | "width" | "
|
299
|
+
}, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>>, {
|
308
300
|
as?: React.ComponentType<any> | undefined;
|
309
301
|
}>;
|
310
302
|
Menu: typeof AutocompleteMenu;
|
@@ -12,17 +12,11 @@ declare const AutocompleteInput: PolymorphicForwardRefComponent<React.ForwardRef
|
|
12
12
|
} & {
|
13
13
|
as?: string | React.ComponentType<any> | undefined;
|
14
14
|
forwardedAs?: string | React.ComponentType<any> | undefined;
|
15
|
-
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "
|
15
|
+
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "contrast"> & {
|
16
16
|
className?: string | undefined;
|
17
17
|
icon?: React.ComponentType<{
|
18
18
|
className?: string | undefined;
|
19
19
|
}> | undefined;
|
20
|
-
leadingVisual?: string | React.ComponentType<{
|
21
|
-
className?: string | undefined;
|
22
|
-
}> | undefined;
|
23
|
-
trailingVisual?: string | React.ComponentType<{
|
24
|
-
className?: string | undefined;
|
25
|
-
}> | undefined;
|
26
20
|
} & Pick<{
|
27
21
|
color?: string | undefined;
|
28
22
|
maxWidth?: import("styled-system").ResponsiveValue<import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
@@ -35,7 +29,6 @@ declare const AutocompleteInput: PolymorphicForwardRefComponent<React.ForwardRef
|
|
35
29
|
slot?: string | undefined;
|
36
30
|
style?: React.CSSProperties | undefined;
|
37
31
|
title?: string | undefined;
|
38
|
-
size?: "small" | "large" | undefined;
|
39
32
|
block?: boolean | undefined;
|
40
33
|
variant?: "small" | "large" | undefined;
|
41
34
|
role?: React.AriaRole | undefined;
|
@@ -293,9 +286,8 @@ declare const AutocompleteInput: PolymorphicForwardRefComponent<React.ForwardRef
|
|
293
286
|
disabled?: boolean | undefined;
|
294
287
|
hasIcon?: boolean | undefined;
|
295
288
|
contrast?: boolean | undefined;
|
296
|
-
validationStatus?: "error" | "warning" | undefined;
|
297
289
|
} & {
|
298
290
|
theme?: any;
|
299
|
-
}, "maxWidth" | "minWidth" | "width" | "
|
291
|
+
}, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>>, InternalAutocompleteInputProps>;
|
300
292
|
export declare type AutocompleteInputProps = ComponentProps<typeof AutocompleteInput>;
|
301
293
|
export default AutocompleteInput;
|
package/lib/Radio.d.ts
ADDED
@@ -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/Radio.js
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
9
|
+
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
11
|
+
|
12
|
+
var _sx = _interopRequireDefault(require("./sx"));
|
13
|
+
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
+
|
16
|
+
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); }
|
17
|
+
|
18
|
+
const StyledRadio = _styledComponents.default.input.withConfig({
|
19
|
+
displayName: "Radio__StyledRadio",
|
20
|
+
componentId: "sc-1ak1fjg-0"
|
21
|
+
})(["cursor:pointer;", " ", ""], props => props.disabled && `cursor: not-allowed;`, _sx.default);
|
22
|
+
/**
|
23
|
+
* An accessible, native radio component for selecting one option from a list.
|
24
|
+
*/
|
25
|
+
|
26
|
+
|
27
|
+
const Radio = /*#__PURE__*/_react.default.forwardRef(({
|
28
|
+
checked,
|
29
|
+
disabled,
|
30
|
+
sx: sxProp,
|
31
|
+
required,
|
32
|
+
validationStatus,
|
33
|
+
value,
|
34
|
+
name,
|
35
|
+
...rest
|
36
|
+
}, ref) => {
|
37
|
+
return /*#__PURE__*/_react.default.createElement(StyledRadio, _extends({
|
38
|
+
type: "radio",
|
39
|
+
value: value,
|
40
|
+
name: name,
|
41
|
+
ref: ref,
|
42
|
+
disabled: disabled,
|
43
|
+
"aria-disabled": disabled ? 'true' : 'false',
|
44
|
+
checked: checked,
|
45
|
+
"aria-checked": checked ? 'true' : 'false',
|
46
|
+
required: required,
|
47
|
+
"aria-required": required ? 'true' : 'false',
|
48
|
+
"aria-invalid": validationStatus === 'error' ? 'true' : 'false',
|
49
|
+
sx: sxProp
|
50
|
+
}, rest));
|
51
|
+
});
|
52
|
+
|
53
|
+
Radio.displayName = 'Radio';
|
54
|
+
var _default = Radio;
|
55
|
+
exports.default = _default;
|
@@ -39,17 +39,11 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
|
|
39
39
|
} & {
|
40
40
|
as?: string | React.ComponentType<any> | undefined;
|
41
41
|
forwardedAs?: string | React.ComponentType<any> | undefined;
|
42
|
-
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "
|
42
|
+
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "contrast"> & {
|
43
43
|
className?: string | undefined;
|
44
44
|
icon?: React.ComponentType<{
|
45
45
|
className?: string | undefined;
|
46
46
|
}> | undefined;
|
47
|
-
leadingVisual?: string | React.ComponentType<{
|
48
|
-
className?: string | undefined;
|
49
|
-
}> | undefined;
|
50
|
-
trailingVisual?: string | React.ComponentType<{
|
51
|
-
className?: string | undefined;
|
52
|
-
}> | undefined;
|
53
47
|
} & Pick<{
|
54
48
|
color?: string | undefined;
|
55
49
|
maxWidth?: import("styled-system").ResponsiveValue<import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
@@ -62,7 +56,6 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
|
|
62
56
|
slot?: string | undefined;
|
63
57
|
style?: React.CSSProperties | undefined;
|
64
58
|
title?: string | undefined;
|
65
|
-
size?: "small" | "large" | undefined;
|
66
59
|
block?: boolean | undefined;
|
67
60
|
variant?: "small" | "large" | undefined;
|
68
61
|
role?: React.AriaRole | undefined;
|
@@ -320,10 +313,9 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
|
|
320
313
|
disabled?: boolean | undefined;
|
321
314
|
hasIcon?: boolean | undefined;
|
322
315
|
contrast?: boolean | undefined;
|
323
|
-
validationStatus?: "error" | "warning" | undefined;
|
324
316
|
} & {
|
325
317
|
theme?: any;
|
326
|
-
}, "maxWidth" | "minWidth" | "width" | "
|
318
|
+
}, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
327
319
|
Footer: import("styled-components").StyledComponent<"footer", any, SxProp, never>;
|
328
320
|
Item: React.ForwardRefExoticComponent<Pick<{
|
329
321
|
as?: React.ElementType<any> | undefined;
|
package/lib/TextInput.d.ts
CHANGED
@@ -4,17 +4,10 @@ import UnstyledTextInput from './_UnstyledTextInput';
|
|
4
4
|
import TextInputWrapper from './_TextInputWrapper';
|
5
5
|
declare type NonPassthroughProps = {
|
6
6
|
className?: string;
|
7
|
-
/** @deprecated Use `leadingVisual` or `trailingVisual` prop instead */
|
8
7
|
icon?: React.ComponentType<{
|
9
8
|
className?: string;
|
10
9
|
}>;
|
11
|
-
|
12
|
-
className?: string;
|
13
|
-
}>;
|
14
|
-
trailingVisual?: string | React.ComponentType<{
|
15
|
-
className?: string;
|
16
|
-
}>;
|
17
|
-
} & Pick<ComponentProps<typeof TextInputWrapper>, 'block' | 'contrast' | 'disabled' | 'sx' | 'width' | 'maxWidth' | 'minWidth' | 'variant' | 'size'>;
|
10
|
+
} & Pick<ComponentProps<typeof TextInputWrapper>, 'block' | 'contrast' | 'disabled' | 'sx' | 'theme' | 'width' | 'maxWidth' | 'minWidth' | 'variant'>;
|
18
11
|
declare type TextInputInternalProps = Merge<React.ComponentPropsWithoutRef<typeof UnstyledTextInput>, NonPassthroughProps>;
|
19
12
|
declare const TextInput: React.ForwardRefExoticComponent<Pick<TextInputInternalProps, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
20
13
|
export declare type TextInputProps = ComponentProps<typeof TextInput>;
|
package/lib/TextInput.js
CHANGED
@@ -20,21 +20,16 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
20
20
|
// using forwardRef is important so that other components (ex. SelectMenu) can autofocus the input
|
21
21
|
const TextInput = /*#__PURE__*/_react.default.forwardRef(({
|
22
22
|
icon: IconComponent,
|
23
|
-
leadingVisual: LeadingVisual,
|
24
|
-
trailingVisual: TrailingVisual,
|
25
23
|
block,
|
26
24
|
className,
|
27
25
|
contrast,
|
28
26
|
disabled,
|
29
|
-
validationStatus,
|
30
27
|
sx: sxProp,
|
31
|
-
|
32
|
-
// start deprecated props
|
28
|
+
theme,
|
33
29
|
width: widthProp,
|
34
30
|
minWidth: minWidthProp,
|
35
31
|
maxWidth: maxWidthProp,
|
36
32
|
variant: variantProp,
|
37
|
-
// end deprecated props
|
38
33
|
...inputProps
|
39
34
|
}, ref) => {
|
40
35
|
// this class is necessary to style FilterSearch, plz no touchy!
|
@@ -42,27 +37,21 @@ const TextInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
42
37
|
return /*#__PURE__*/_react.default.createElement(_TextInputWrapper.default, {
|
43
38
|
block: block,
|
44
39
|
className: wrapperClasses,
|
45
|
-
validationStatus: validationStatus,
|
46
40
|
contrast: contrast,
|
47
41
|
disabled: disabled,
|
42
|
+
hasIcon: !!IconComponent,
|
48
43
|
sx: sxProp,
|
49
|
-
|
44
|
+
theme: theme,
|
50
45
|
width: widthProp,
|
51
46
|
minWidth: minWidthProp,
|
52
47
|
maxWidth: maxWidthProp,
|
53
48
|
variant: variantProp
|
54
49
|
}, IconComponent && /*#__PURE__*/_react.default.createElement(IconComponent, {
|
55
50
|
className: "TextInput-icon"
|
56
|
-
}),
|
57
|
-
"data-component": "leadingVisual"
|
58
|
-
}, typeof LeadingVisual === 'function' ? /*#__PURE__*/_react.default.createElement(LeadingVisual, null) : LeadingVisual), /*#__PURE__*/_react.default.createElement(_UnstyledTextInput.default, _extends({
|
51
|
+
}), /*#__PURE__*/_react.default.createElement(_UnstyledTextInput.default, _extends({
|
59
52
|
ref: ref,
|
60
53
|
disabled: disabled
|
61
|
-
}, inputProps
|
62
|
-
"data-component": "input"
|
63
|
-
})), TrailingVisual && /*#__PURE__*/_react.default.createElement("span", {
|
64
|
-
"data-component": "leadingVisual"
|
65
|
-
}, typeof TrailingVisual === 'function' ? /*#__PURE__*/_react.default.createElement(TrailingVisual, null) : TrailingVisual));
|
54
|
+
}, inputProps)));
|
66
55
|
});
|
67
56
|
|
68
57
|
TextInput.defaultProps = {
|
@@ -44,17 +44,11 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
44
44
|
} & {
|
45
45
|
as?: string | React.ComponentType<any> | undefined;
|
46
46
|
forwardedAs?: string | React.ComponentType<any> | undefined;
|
47
|
-
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "
|
47
|
+
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "contrast"> & {
|
48
48
|
className?: string | undefined;
|
49
49
|
icon?: React.ComponentType<{
|
50
50
|
className?: string | undefined;
|
51
51
|
}> | undefined;
|
52
|
-
leadingVisual?: string | React.ComponentType<{
|
53
|
-
className?: string | undefined;
|
54
|
-
}> | undefined;
|
55
|
-
trailingVisual?: string | React.ComponentType<{
|
56
|
-
className?: string | undefined;
|
57
|
-
}> | undefined;
|
58
52
|
} & Pick<{
|
59
53
|
color?: string | undefined;
|
60
54
|
maxWidth?: import("styled-system").ResponsiveValue<import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
@@ -67,7 +61,6 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
67
61
|
slot?: string | undefined;
|
68
62
|
style?: React.CSSProperties | undefined;
|
69
63
|
title?: string | undefined;
|
70
|
-
size?: "small" | "large" | undefined;
|
71
64
|
block?: boolean | undefined;
|
72
65
|
variant?: "small" | "large" | undefined;
|
73
66
|
role?: React.AriaRole | undefined;
|
@@ -325,10 +318,9 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
325
318
|
disabled?: boolean | undefined;
|
326
319
|
hasIcon?: boolean | undefined;
|
327
320
|
contrast?: boolean | undefined;
|
328
|
-
validationStatus?: "error" | "warning" | undefined;
|
329
321
|
} & {
|
330
322
|
theme?: any;
|
331
|
-
}, "maxWidth" | "minWidth" | "width" | "
|
323
|
+
}, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement> & {
|
332
324
|
selectedTokenIndex: number | undefined;
|
333
325
|
setSelectedTokenIndex: React.Dispatch<React.SetStateAction<number | undefined>>;
|
334
326
|
}, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
@@ -5,9 +5,6 @@ declare const TextInputWrapper: import("styled-components").StyledComponent<"spa
|
|
5
5
|
hasIcon?: boolean | undefined;
|
6
6
|
block?: boolean | undefined;
|
7
7
|
contrast?: boolean | undefined;
|
8
|
-
validationStatus?: "error" | "warning" | undefined;
|
9
|
-
/** @deprecated Use `size` prop instead */
|
10
8
|
variant?: "small" | "large" | undefined;
|
11
|
-
size?: "small" | "large" | undefined;
|
12
9
|
} & WidthProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Width<import("styled-system").TLengthStyledSystem>> & MinWidthProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.MinWidth<import("styled-system").TLengthStyledSystem>> & MaxWidthProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>> & SxProp, never>;
|
13
10
|
export default TextInputWrapper;
|
package/lib/_TextInputWrapper.js
CHANGED
@@ -19,24 +19,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
19
19
|
|
20
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
21
21
|
|
22
|
-
const sizeDeprecatedVariants = (0, _styledSystem.variant)({
|
23
|
-
variants: {
|
24
|
-
small: {
|
25
|
-
minHeight: '28px',
|
26
|
-
px: 2,
|
27
|
-
py: '3px',
|
28
|
-
fontSize: 0,
|
29
|
-
lineHeight: '20px'
|
30
|
-
},
|
31
|
-
large: {
|
32
|
-
px: 2,
|
33
|
-
py: '10px',
|
34
|
-
fontSize: 3
|
35
|
-
}
|
36
|
-
}
|
37
|
-
});
|
38
22
|
const sizeVariants = (0, _styledSystem.variant)({
|
39
|
-
prop: 'size',
|
40
23
|
variants: {
|
41
24
|
small: {
|
42
25
|
minHeight: '28px',
|
@@ -56,7 +39,13 @@ const sizeVariants = (0, _styledSystem.variant)({
|
|
56
39
|
const TextInputWrapper = _styledComponents.default.span.withConfig({
|
57
40
|
displayName: "_TextInputWrapper__TextInputWrapper",
|
58
41
|
componentId: "sc-5vfcis-0"
|
59
|
-
})(["
|
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
|
+
if (props.hasIcon) {
|
44
|
+
return (0, _styledComponents.css)(["padding:0;"]);
|
45
|
+
} else {
|
46
|
+
return (0, _styledComponents.css)(["padding:6px 12px;"]);
|
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%;"]), 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);
|
60
49
|
|
61
50
|
var _default = TextInputWrapper;
|
62
51
|
exports.default = _default;
|
package/lib/drafts.d.ts
CHANGED
package/lib/drafts.js
CHANGED
@@ -28,4 +28,17 @@ Object.keys(_NewButton).forEach(function (key) {
|
|
28
28
|
return _NewButton[key];
|
29
29
|
}
|
30
30
|
});
|
31
|
+
});
|
32
|
+
|
33
|
+
var _ActionMenu = require("./ActionMenu2");
|
34
|
+
|
35
|
+
Object.keys(_ActionMenu).forEach(function (key) {
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
37
|
+
if (key in exports && exports[key] === _ActionMenu[key]) return;
|
38
|
+
Object.defineProperty(exports, key, {
|
39
|
+
enumerable: true,
|
40
|
+
get: function () {
|
41
|
+
return _ActionMenu[key];
|
42
|
+
}
|
43
|
+
});
|
31
44
|
});
|
package/lib/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/index.js
CHANGED
@@ -141,6 +141,12 @@ Object.defineProperty(exports, "ConfirmationDialog", {
|
|
141
141
|
return _ConfirmationDialog.ConfirmationDialog;
|
142
142
|
}
|
143
143
|
});
|
144
|
+
Object.defineProperty(exports, "Radio", {
|
145
|
+
enumerable: true,
|
146
|
+
get: function () {
|
147
|
+
return _Radio.default;
|
148
|
+
}
|
149
|
+
});
|
144
150
|
Object.defineProperty(exports, "ActionList", {
|
145
151
|
enumerable: true,
|
146
152
|
get: function () {
|
@@ -546,6 +552,8 @@ var _useOverlay = require("./hooks/useOverlay");
|
|
546
552
|
|
547
553
|
var _ConfirmationDialog = require("./Dialog/ConfirmationDialog");
|
548
554
|
|
555
|
+
var _Radio = _interopRequireDefault(require("./Radio"));
|
556
|
+
|
549
557
|
var _ActionList = require("./ActionList");
|
550
558
|
|
551
559
|
var _ActionMenu = require("./ActionMenu");
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
import React from 'react';
|
2
|
+
import { SxProp } from '../sx';
|
2
3
|
/**
|
3
4
|
* Visually separates `Item`s or `Group`s in an `ActionList`.
|
4
5
|
*/
|
5
|
-
export declare
|
6
|
+
export declare const Divider: React.FC<SxProp>;
|
@@ -1,23 +1,26 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import Box from '../Box';
|
3
3
|
import { get } from '../constants';
|
4
|
-
|
4
|
+
import { merge } from '../sx';
|
5
5
|
/**
|
6
6
|
* Visually separates `Item`s or `Group`s in an `ActionList`.
|
7
7
|
*/
|
8
|
-
|
8
|
+
|
9
|
+
export const Divider = ({
|
10
|
+
sx = {}
|
11
|
+
}) => {
|
9
12
|
return /*#__PURE__*/React.createElement(Box, {
|
10
13
|
as: "li",
|
11
14
|
role: "separator",
|
12
|
-
sx: {
|
15
|
+
sx: merge({
|
13
16
|
height: 1,
|
14
17
|
backgroundColor: 'actionListItem.inlineDivider',
|
15
18
|
marginTop: theme => `calc(${get('space.2')(theme)} - 1px)`,
|
16
19
|
marginBottom: 2,
|
17
20
|
listStyle: 'none' // hide the ::marker inserted by browser's stylesheet
|
18
21
|
|
19
|
-
},
|
22
|
+
}, sx),
|
20
23
|
"data-component": "ActionList.Divider"
|
21
24
|
});
|
22
|
-
}
|
25
|
+
};
|
23
26
|
Divider.displayName = "Divider";
|
@@ -8,6 +8,7 @@ import Box from '../Box';
|
|
8
8
|
import sx, { merge } from '../sx';
|
9
9
|
import createSlots from '../utils/create-slots';
|
10
10
|
import { ListContext } from './List';
|
11
|
+
import { MenuContext } from './MenuContext';
|
11
12
|
import { Selection } from './Selection';
|
12
13
|
export const getVariantStyles = (variant, disabled) => {
|
13
14
|
if (disabled) {
|
@@ -54,6 +55,7 @@ export const Item = /*#__PURE__*/React.forwardRef(({
|
|
54
55
|
onSelect,
|
55
56
|
sx: sxProp = {},
|
56
57
|
id,
|
58
|
+
role,
|
57
59
|
_PrivateItemWrapper,
|
58
60
|
...props
|
59
61
|
}, forwardedRef) => {
|
@@ -61,6 +63,10 @@ export const Item = /*#__PURE__*/React.forwardRef(({
|
|
61
63
|
variant: listVariant,
|
62
64
|
showDividers
|
63
65
|
} = React.useContext(ListContext);
|
66
|
+
const {
|
67
|
+
itemRole,
|
68
|
+
afterSelect
|
69
|
+
} = React.useContext(MenuContext);
|
64
70
|
const {
|
65
71
|
theme
|
66
72
|
} = useTheme();
|
@@ -135,16 +141,23 @@ export const Item = /*#__PURE__*/React.forwardRef(({
|
|
135
141
|
const clickHandler = React.useCallback(event => {
|
136
142
|
if (typeof onSelect !== 'function') return;
|
137
143
|
if (disabled) return;
|
138
|
-
|
139
|
-
|
144
|
+
|
145
|
+
if (!event.defaultPrevented) {
|
146
|
+
onSelect(event); // if this Item is inside a Menu, close the Menu
|
147
|
+
|
148
|
+
if (typeof afterSelect === 'function') afterSelect();
|
149
|
+
}
|
150
|
+
}, [onSelect, disabled, afterSelect]);
|
140
151
|
const keyPressHandler = React.useCallback(event => {
|
141
152
|
if (typeof onSelect !== 'function') return;
|
142
153
|
if (disabled) return;
|
143
154
|
|
144
155
|
if (!event.defaultPrevented && [' ', 'Enter'].includes(event.key)) {
|
145
|
-
onSelect(event);
|
156
|
+
onSelect(event); // if this Item is inside a Menu, close the Menu
|
157
|
+
|
158
|
+
if (typeof afterSelect === 'function') afterSelect();
|
146
159
|
}
|
147
|
-
}, [onSelect, disabled]); // use props.id if provided, otherwise generate one.
|
160
|
+
}, [onSelect, disabled, afterSelect]); // use props.id if provided, otherwise generate one.
|
148
161
|
|
149
162
|
const labelId = useSSRSafeId(id);
|
150
163
|
const inlineDescriptionId = useSSRSafeId(id && `${id}--inline-description`);
|
@@ -166,7 +179,8 @@ export const Item = /*#__PURE__*/React.forwardRef(({
|
|
166
179
|
"aria-disabled": disabled ? true : undefined,
|
167
180
|
tabIndex: disabled || _PrivateItemWrapper ? undefined : 0,
|
168
181
|
"aria-labelledby": `${labelId} ${slots.InlineDescription ? inlineDescriptionId : ''}`,
|
169
|
-
"aria-describedby": slots.BlockDescription ? blockDescriptionId : undefined
|
182
|
+
"aria-describedby": slots.BlockDescription ? blockDescriptionId : undefined,
|
183
|
+
role: role || itemRole
|
170
184
|
}, props), /*#__PURE__*/React.createElement(ItemWrapper, null, /*#__PURE__*/React.createElement(Selection, {
|
171
185
|
selected: selected
|
172
186
|
}), slots.LeadingVisual, /*#__PURE__*/React.createElement(Box, {
|
@@ -3,6 +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 { MenuContext } from './MenuContext';
|
6
7
|
export const ListContext = /*#__PURE__*/React.createContext({});
|
7
8
|
const ListBox = styled.ul.withConfig({
|
8
9
|
displayName: "List__ListBox",
|
@@ -12,6 +13,7 @@ export const List = /*#__PURE__*/React.forwardRef(({
|
|
12
13
|
variant = 'inset',
|
13
14
|
selectionVariant,
|
14
15
|
showDividers = false,
|
16
|
+
role,
|
15
17
|
sx: sxProp = {},
|
16
18
|
...props
|
17
19
|
}, forwardedRef) => {
|
@@ -21,8 +23,14 @@ export const List = /*#__PURE__*/React.forwardRef(({
|
|
21
23
|
// reset ul styles
|
22
24
|
paddingY: variant === 'inset' ? 2 : 0
|
23
25
|
};
|
26
|
+
/** if list is inside a Menu, it will get a role from the Menu */
|
27
|
+
|
28
|
+
const {
|
29
|
+
listRole
|
30
|
+
} = React.useContext(MenuContext);
|
24
31
|
return /*#__PURE__*/React.createElement(ListBox, _extends({
|
25
|
-
sx: merge(styles, sxProp)
|
32
|
+
sx: merge(styles, sxProp),
|
33
|
+
role: role || listRole
|
26
34
|
}, props, {
|
27
35
|
ref: forwardedRef
|
28
36
|
}), /*#__PURE__*/React.createElement(ListContext.Provider, {
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/** This context can be used by components that compose ActionList inside a Menu */
|
2
|
+
import React from 'react';
|
3
|
+
declare type ContextProps = {
|
4
|
+
parent?: string;
|
5
|
+
listRole?: string;
|
6
|
+
itemRole?: string;
|
7
|
+
afterSelect?: () => void;
|
8
|
+
};
|
9
|
+
export declare const MenuContext: React.Context<ContextProps>;
|
10
|
+
export {};
|
@@ -2,6 +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 { MenuContext } from './MenuContext';
|
5
6
|
import { LeadingVisualContainer } from './Visuals';
|
6
7
|
export const Selection = ({
|
7
8
|
selected
|
@@ -12,6 +13,9 @@ export const Selection = ({
|
|
12
13
|
const {
|
13
14
|
selectionVariant: groupSelectionVariant
|
14
15
|
} = React.useContext(GroupContext);
|
16
|
+
const {
|
17
|
+
parent
|
18
|
+
} = React.useContext(MenuContext);
|
15
19
|
/** selectionVariant in Group can override the selectionVariant in List root */
|
16
20
|
|
17
21
|
const selectionVariant = typeof groupSelectionVariant !== 'undefined' ? groupSelectionVariant : listSelectionVariant; // if selectionVariant is not set on List, don't show selection
|
@@ -22,6 +26,11 @@ export const Selection = ({
|
|
22
26
|
return null;
|
23
27
|
}
|
24
28
|
|
29
|
+
if (parent === 'ActionMenu') {
|
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
|
+
return null;
|
32
|
+
}
|
33
|
+
|
25
34
|
if (selectionVariant === 'single') {
|
26
35
|
return /*#__PURE__*/React.createElement(LeadingVisualContainer, null, selected && /*#__PURE__*/React.createElement(CheckIcon, null));
|
27
36
|
}
|