@primer/components 0.0.0-202192602912 → 0.0.0-2021926114132
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 +4 -8
- package/dist/browser.esm.js +616 -616
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +177 -177
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList2/Description.d.ts +6 -0
- package/lib/ActionList2/Description.js +53 -0
- package/lib/ActionList2/Divider.d.ts +8 -0
- package/lib/ActionList2/Divider.js +42 -0
- package/lib/ActionList2/Group.d.ts +8 -0
- package/lib/ActionList2/Group.js +39 -0
- package/lib/ActionList2/Header.d.ts +26 -0
- package/lib/ActionList2/Header.js +55 -0
- package/lib/ActionList2/Item.d.ts +49 -0
- package/lib/ActionList2/Item.js +205 -0
- package/lib/ActionList2/List.d.ts +11 -0
- package/lib/ActionList2/List.js +53 -0
- package/lib/ActionList2/Selection.d.ts +5 -0
- package/lib/ActionList2/Selection.js +67 -0
- package/lib/ActionList2/Visuals.d.ts +11 -0
- package/lib/ActionList2/Visuals.js +90 -0
- package/lib/ActionList2/hacks.d.ts +30 -0
- package/lib/ActionList2/hacks.js +38 -0
- package/lib/ActionList2/index.d.ts +26 -0
- package/lib/ActionList2/index.js +36 -0
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +2 -4
- package/lib/Autocomplete/Autocomplete.d.ts +2 -4
- package/lib/Autocomplete/AutocompleteInput.d.ts +2 -4
- package/lib/SelectMenu/SelectMenu.d.ts +2 -4
- package/lib/TextInputWithTokens.d.ts +2 -4
- package/lib/index.d.ts +1 -0
- package/lib/index.js +8 -0
- package/lib/sx.d.ts +2 -0
- package/lib/sx.js +8 -0
- package/lib/theme-preval.js +2 -2
- package/lib/utils/create-slots.d.ts +17 -0
- package/lib/utils/create-slots.js +105 -0
- package/lib/utils/testing.d.ts +1 -1
- package/lib/utils/use-force-update.d.ts +1 -0
- package/lib/utils/use-force-update.js +19 -0
- package/lib-esm/ActionList2/Description.d.ts +6 -0
- package/lib-esm/ActionList2/Description.js +37 -0
- package/lib-esm/ActionList2/Divider.d.ts +8 -0
- package/lib-esm/ActionList2/Divider.js +30 -0
- package/lib-esm/ActionList2/Group.d.ts +8 -0
- package/lib-esm/ActionList2/Group.js +29 -0
- package/lib-esm/ActionList2/Header.d.ts +26 -0
- package/lib-esm/ActionList2/Header.js +45 -0
- package/lib-esm/ActionList2/Item.d.ts +49 -0
- package/lib-esm/ActionList2/Item.js +198 -0
- package/lib-esm/ActionList2/List.d.ts +11 -0
- package/lib-esm/ActionList2/List.js +35 -0
- package/lib-esm/ActionList2/Selection.d.ts +5 -0
- package/lib-esm/ActionList2/Selection.js +50 -0
- package/lib-esm/ActionList2/Visuals.d.ts +11 -0
- package/lib-esm/ActionList2/Visuals.js +68 -0
- package/lib-esm/ActionList2/hacks.d.ts +30 -0
- package/lib-esm/ActionList2/hacks.js +30 -0
- package/lib-esm/ActionList2/index.d.ts +26 -0
- package/lib-esm/ActionList2/index.js +23 -0
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +2 -4
- package/lib-esm/Autocomplete/Autocomplete.d.ts +2 -4
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +2 -4
- package/lib-esm/SelectMenu/SelectMenu.d.ts +2 -4
- package/lib-esm/TextInputWithTokens.d.ts +2 -4
- package/lib-esm/index.d.ts +1 -0
- package/lib-esm/index.js +1 -0
- package/lib-esm/sx.d.ts +2 -0
- package/lib-esm/sx.js +3 -1
- package/lib-esm/theme-preval.js +2 -2
- package/lib-esm/utils/create-slots.d.ts +17 -0
- package/lib-esm/utils/create-slots.js +84 -0
- package/lib-esm/utils/testing.d.ts +1 -1
- package/lib-esm/utils/use-force-update.d.ts +1 -0
- package/lib-esm/utils/use-force-update.js +6 -0
- package/package.json +8 -9
- package/lib/DatePicker/DatePicker.d.ts +0 -48
- package/lib/DatePicker/DatePicker.js +0 -92
- package/lib/DatePicker/DatePickerAnchor.d.ts +0 -5
- package/lib/DatePicker/DatePickerAnchor.js +0 -158
- package/lib/DatePicker/DatePickerOverlay.d.ts +0 -3
- package/lib/DatePicker/DatePickerOverlay.js +0 -39
- package/lib/DatePicker/DatePickerPanel.d.ts +0 -2
- package/lib/DatePicker/DatePickerPanel.js +0 -126
- package/lib/DatePicker/Day.d.ts +0 -14
- package/lib/DatePicker/Day.js +0 -174
- package/lib/DatePicker/Month.d.ts +0 -9
- package/lib/DatePicker/Month.js +0 -107
- package/lib/DatePicker/index.d.ts +0 -2
- package/lib/DatePicker/index.js +0 -13
- package/lib/DatePicker/useDatePicker.d.ts +0 -83
- package/lib/DatePicker/useDatePicker.js +0 -375
- package/lib/hooks/useDebounce.d.ts +0 -2
- package/lib/hooks/useDebounce.js +0 -24
- package/lib-esm/DatePicker/DatePicker.d.ts +0 -48
- package/lib-esm/DatePicker/DatePicker.js +0 -75
- package/lib-esm/DatePicker/DatePickerAnchor.d.ts +0 -5
- package/lib-esm/DatePicker/DatePickerAnchor.js +0 -132
- package/lib-esm/DatePicker/DatePickerOverlay.d.ts +0 -3
- package/lib-esm/DatePicker/DatePickerOverlay.js +0 -24
- package/lib-esm/DatePicker/DatePickerPanel.d.ts +0 -2
- package/lib-esm/DatePicker/DatePickerPanel.js +0 -100
- package/lib-esm/DatePicker/Day.d.ts +0 -14
- package/lib-esm/DatePicker/Day.js +0 -151
- package/lib-esm/DatePicker/Month.d.ts +0 -9
- package/lib-esm/DatePicker/Month.js +0 -83
- package/lib-esm/DatePicker/index.d.ts +0 -2
- package/lib-esm/DatePicker/index.js +0 -1
- package/lib-esm/DatePicker/useDatePicker.d.ts +0 -83
- package/lib-esm/DatePicker/useDatePicker.js +0 -347
- package/lib-esm/hooks/useDebounce.d.ts +0 -2
- package/lib-esm/hooks/useDebounce.js +0 -16
@@ -0,0 +1,90 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.TrailingVisual = exports.LeadingVisual = exports.LeadingVisualContainer = void 0;
|
7
|
+
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
9
|
+
|
10
|
+
var _Box = _interopRequireDefault(require("../Box"));
|
11
|
+
|
12
|
+
var _sx = require("../sx");
|
13
|
+
|
14
|
+
var _constants = require("../constants");
|
15
|
+
|
16
|
+
var _Item = require("./Item");
|
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
|
+
const LeadingVisualContainer = ({
|
23
|
+
sx = {},
|
24
|
+
...props
|
25
|
+
}) => {
|
26
|
+
return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
|
27
|
+
as: "span",
|
28
|
+
sx: (0, _sx.merge)({
|
29
|
+
height: '20px',
|
30
|
+
// match height of text row
|
31
|
+
minWidth: (0, _constants.get)('space.3'),
|
32
|
+
maxWidth: '20px',
|
33
|
+
// square (same as height)
|
34
|
+
display: 'flex',
|
35
|
+
justifyContent: 'center',
|
36
|
+
alignItems: 'center',
|
37
|
+
flexShrink: 0,
|
38
|
+
marginRight: 2
|
39
|
+
}, sx)
|
40
|
+
}, props));
|
41
|
+
};
|
42
|
+
|
43
|
+
exports.LeadingVisualContainer = LeadingVisualContainer;
|
44
|
+
LeadingVisualContainer.displayName = "LeadingVisualContainer";
|
45
|
+
|
46
|
+
const LeadingVisual = ({
|
47
|
+
sx = {},
|
48
|
+
...props
|
49
|
+
}) => {
|
50
|
+
return /*#__PURE__*/_react.default.createElement(_Item.Slot, {
|
51
|
+
name: "LeadingVisual"
|
52
|
+
}, ({
|
53
|
+
variant,
|
54
|
+
disabled
|
55
|
+
}) => /*#__PURE__*/_react.default.createElement(LeadingVisualContainer, _extends({
|
56
|
+
sx: (0, _sx.merge)({
|
57
|
+
color: (0, _Item.getVariantStyles)(variant, disabled).iconColor,
|
58
|
+
svg: {
|
59
|
+
fontSize: 0
|
60
|
+
}
|
61
|
+
}, sx)
|
62
|
+
}, props), props.children));
|
63
|
+
};
|
64
|
+
|
65
|
+
exports.LeadingVisual = LeadingVisual;
|
66
|
+
LeadingVisual.displayName = "LeadingVisual";
|
67
|
+
|
68
|
+
const TrailingVisual = ({
|
69
|
+
sx = {},
|
70
|
+
...props
|
71
|
+
}) => {
|
72
|
+
return /*#__PURE__*/_react.default.createElement(_Item.Slot, {
|
73
|
+
name: "TrailingVisual"
|
74
|
+
}, ({
|
75
|
+
variant,
|
76
|
+
disabled
|
77
|
+
}) => /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
|
78
|
+
as: "span",
|
79
|
+
sx: (0, _sx.merge)({
|
80
|
+
height: '20px',
|
81
|
+
// match height of text row
|
82
|
+
flexShrink: 0,
|
83
|
+
color: (0, _Item.getVariantStyles)(variant, disabled).annotationColor,
|
84
|
+
marginLeft: 2
|
85
|
+
}, sx)
|
86
|
+
}, props), props.children));
|
87
|
+
};
|
88
|
+
|
89
|
+
exports.TrailingVisual = TrailingVisual;
|
90
|
+
TrailingVisual.displayName = "TrailingVisual";
|
@@ -0,0 +1,30 @@
|
|
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
|
+
};
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.customItemThemes = void 0;
|
7
|
+
|
8
|
+
/**
|
9
|
+
* These colors are not yet in our default theme.
|
10
|
+
* TODO: Need to remove this once they are added.
|
11
|
+
*/
|
12
|
+
const customItemThemes = {
|
13
|
+
default: {
|
14
|
+
hover: {
|
15
|
+
light: 'rgba(46, 77, 108, 0.06)',
|
16
|
+
dark: 'rgba(201, 206, 212, 0.12)',
|
17
|
+
dark_dimmed: 'rgba(201, 206, 212, 0.12)'
|
18
|
+
},
|
19
|
+
focus: {
|
20
|
+
light: 'rgba(54, 77, 100, 0.16)',
|
21
|
+
dark: 'rgba(201, 206, 212, 0.24)',
|
22
|
+
dark_dimmed: 'rgba(201, 206, 212, 0.24)'
|
23
|
+
}
|
24
|
+
},
|
25
|
+
danger: {
|
26
|
+
hover: {
|
27
|
+
light: 'rgba(234, 74, 90, 0.08)',
|
28
|
+
dark: 'rgba(248, 81, 73, 0.16)',
|
29
|
+
dark_dimmed: 'rgba(248, 81, 73, 0.16)'
|
30
|
+
},
|
31
|
+
focus: {
|
32
|
+
light: 'rgba(234, 74, 90, 0.14)',
|
33
|
+
dark: 'rgba(248, 81, 73, 0.24)',
|
34
|
+
dark_dimmed: 'rgba(248, 81, 73, 0.24)'
|
35
|
+
}
|
36
|
+
}
|
37
|
+
};
|
38
|
+
exports.customItemThemes = customItemThemes;
|
@@ -0,0 +1,26 @@
|
|
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
|
+
};
|
@@ -0,0 +1,36 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.ActionList = void 0;
|
7
|
+
|
8
|
+
var _List = require("./List");
|
9
|
+
|
10
|
+
var _Group = require("./Group");
|
11
|
+
|
12
|
+
var _Item = require("./Item");
|
13
|
+
|
14
|
+
var _Divider = require("./Divider");
|
15
|
+
|
16
|
+
var _Description = require("./Description");
|
17
|
+
|
18
|
+
var _Visuals = require("./Visuals");
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Collection of list-related components.
|
22
|
+
*/
|
23
|
+
const ActionList = Object.assign(_List.List, {
|
24
|
+
/** Collects related `Items` in an `ActionList`. */
|
25
|
+
Group: _Group.Group,
|
26
|
+
|
27
|
+
/** An actionable or selectable `Item` with an optional icon and description. */
|
28
|
+
Item: _Item.Item,
|
29
|
+
|
30
|
+
/** Visually separates `Item`s or `Group`s in an `ActionList`. */
|
31
|
+
Divider: _Divider.Divider,
|
32
|
+
Description: _Description.Description,
|
33
|
+
LeadingVisual: _Visuals.LeadingVisual,
|
34
|
+
TrailingVisual: _Visuals.TrailingVisual
|
35
|
+
});
|
36
|
+
exports.ActionList = ActionList;
|
@@ -26,8 +26,6 @@ interface AnchoredOverlayPropsWithoutAnchor {
|
|
26
26
|
*/
|
27
27
|
anchorRef: React.RefObject<HTMLElement>;
|
28
28
|
}
|
29
|
-
export declare type OverlayOpenGesture = 'anchor-click' | 'anchor-key-press';
|
30
|
-
export declare type OverlayCloseGesture = 'anchor-click' | 'click-outside' | 'escape';
|
31
29
|
export declare type AnchoredOverlayWrapperAnchorProps = Partial<AnchoredOverlayPropsWithAnchor> | AnchoredOverlayPropsWithoutAnchor;
|
32
30
|
interface AnchoredOverlayBaseProps extends Pick<OverlayProps, 'height' | 'width'> {
|
33
31
|
/**
|
@@ -37,11 +35,11 @@ interface AnchoredOverlayBaseProps extends Pick<OverlayProps, 'height' | 'width'
|
|
37
35
|
/**
|
38
36
|
* A callback which is called whenever the overlay is currently closed and an "open gesture" is detected.
|
39
37
|
*/
|
40
|
-
onOpen?: (gesture:
|
38
|
+
onOpen?: (gesture: 'anchor-click' | 'anchor-key-press') => unknown;
|
41
39
|
/**
|
42
40
|
* A callback which is called whenever the overlay is currently open and a "close gesture" is detected.
|
43
41
|
*/
|
44
|
-
onClose?: (gesture:
|
42
|
+
onClose?: (gesture: 'anchor-click' | 'click-outside' | 'escape') => unknown;
|
45
43
|
/**
|
46
44
|
* Props to be spread on the internal `Overlay` component.
|
47
45
|
*/
|
@@ -12,14 +12,12 @@ export type { AutocompleteOverlayProps } from './AutocompleteOverlay';
|
|
12
12
|
declare const _default: React.FC<{
|
13
13
|
id?: string | undefined;
|
14
14
|
}> & {
|
15
|
-
Input: import("@radix-ui/react-polymorphic").ForwardRefComponent<React.ForwardRefExoticComponent<Pick<Omit<Pick<
|
15
|
+
Input: import("@radix-ui/react-polymorphic").ForwardRefComponent<React.ForwardRefExoticComponent<Pick<Omit<Pick<{
|
16
16
|
[x: string]: any;
|
17
17
|
[x: number]: any;
|
18
18
|
} & {
|
19
19
|
theme?: any;
|
20
|
-
} &
|
21
|
-
children?: React.ReactNode;
|
22
|
-
})) & {
|
20
|
+
} & {
|
23
21
|
as?: string | React.ComponentType<any> | undefined;
|
24
22
|
forwardedAs?: string | React.ComponentType<any> | undefined;
|
25
23
|
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast"> & {
|
@@ -4,14 +4,12 @@ import { ComponentProps } from '../utils/types';
|
|
4
4
|
declare type InternalAutocompleteInputProps = {
|
5
5
|
as?: React.ComponentType<any>;
|
6
6
|
};
|
7
|
-
declare const AutocompleteInput: PolymorphicForwardRefComponent<React.ForwardRefExoticComponent<Pick<Omit<Pick<
|
7
|
+
declare const AutocompleteInput: PolymorphicForwardRefComponent<React.ForwardRefExoticComponent<Pick<Omit<Pick<{
|
8
8
|
[x: string]: any;
|
9
9
|
[x: number]: any;
|
10
10
|
} & {
|
11
11
|
theme?: any;
|
12
|
-
} &
|
13
|
-
children?: React.ReactNode;
|
14
|
-
})) & {
|
12
|
+
} & {
|
15
13
|
as?: string | React.ComponentType<any> | undefined;
|
16
14
|
forwardedAs?: string | React.ComponentType<any> | undefined;
|
17
15
|
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast"> & {
|
@@ -32,14 +32,12 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
|
|
32
32
|
Divider: import("styled-components").StyledComponent<"div", any, SystemCommonProps & SxProp, never>;
|
33
33
|
Filter: React.ForwardRefExoticComponent<Pick<{
|
34
34
|
value?: string | undefined;
|
35
|
-
} & Pick<Omit<Pick<
|
35
|
+
} & Pick<Omit<Pick<{
|
36
36
|
[x: string]: any;
|
37
37
|
[x: number]: any;
|
38
38
|
} & {
|
39
39
|
theme?: any;
|
40
|
-
} &
|
41
|
-
children?: React.ReactNode;
|
42
|
-
})) & {
|
40
|
+
} & {
|
43
41
|
as?: string | React.ComponentType<any> | undefined;
|
44
42
|
forwardedAs?: string | React.ComponentType<any> | undefined;
|
45
43
|
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast"> & {
|
@@ -32,14 +32,12 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
32
32
|
* Whether the remove buttons should be rendered in the tokens
|
33
33
|
*/
|
34
34
|
hideTokenRemoveButtons?: boolean | undefined;
|
35
|
-
} & Pick<Omit<Pick<
|
35
|
+
} & Pick<Omit<Pick<{
|
36
36
|
[x: string]: any;
|
37
37
|
[x: number]: any;
|
38
38
|
} & {
|
39
39
|
theme?: any;
|
40
|
-
} &
|
41
|
-
children?: React.ReactNode;
|
42
|
-
})) & {
|
40
|
+
} & {
|
43
41
|
as?: string | React.ComponentType<any> | undefined;
|
44
42
|
forwardedAs?: string | React.ComponentType<any> | undefined;
|
45
43
|
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast"> & {
|
package/lib/index.d.ts
CHANGED
@@ -22,6 +22,7 @@ export { useOnEscapePress } from './hooks/useOnEscapePress';
|
|
22
22
|
export { useOverlay } from './hooks/useOverlay';
|
23
23
|
export { useConfirm } from './Dialog/ConfirmationDialog';
|
24
24
|
export { ActionList } from './ActionList';
|
25
|
+
export { ActionList as ActionList2 } from './ActionList2';
|
25
26
|
export { ActionMenu } from './ActionMenu';
|
26
27
|
export type { ActionMenuProps } from './ActionMenu';
|
27
28
|
export { default as Autocomplete } from './Autocomplete';
|
package/lib/index.js
CHANGED
@@ -147,6 +147,12 @@ Object.defineProperty(exports, "ActionList", {
|
|
147
147
|
return _ActionList.ActionList;
|
148
148
|
}
|
149
149
|
});
|
150
|
+
Object.defineProperty(exports, "ActionList2", {
|
151
|
+
enumerable: true,
|
152
|
+
get: function () {
|
153
|
+
return _ActionList2.ActionList;
|
154
|
+
}
|
155
|
+
});
|
150
156
|
Object.defineProperty(exports, "ActionMenu", {
|
151
157
|
enumerable: true,
|
152
158
|
get: function () {
|
@@ -536,6 +542,8 @@ var _ConfirmationDialog = require("./Dialog/ConfirmationDialog");
|
|
536
542
|
|
537
543
|
var _ActionList = require("./ActionList");
|
538
544
|
|
545
|
+
var _ActionList2 = require("./ActionList2");
|
546
|
+
|
539
547
|
var _ActionMenu = require("./ActionMenu");
|
540
548
|
|
541
549
|
var _Autocomplete = _interopRequireDefault(require("./Autocomplete"));
|
package/lib/sx.d.ts
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
import { SystemStyleObject } from '@styled-system/css';
|
2
|
+
import merge from 'deepmerge';
|
2
3
|
export interface SxProp {
|
3
4
|
sx?: SystemStyleObject;
|
4
5
|
}
|
5
6
|
declare const sx: (props: SxProp) => import("@styled-system/css").CssFunctionReturnType;
|
6
7
|
export default sx;
|
8
|
+
export { merge };
|
package/lib/sx.js
CHANGED
@@ -3,10 +3,18 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
Object.defineProperty(exports, "merge", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function () {
|
9
|
+
return _deepmerge.default;
|
10
|
+
}
|
11
|
+
});
|
6
12
|
exports.default = void 0;
|
7
13
|
|
8
14
|
var _css = _interopRequireDefault(require("@styled-system/css"));
|
9
15
|
|
16
|
+
var _deepmerge = _interopRequireDefault(require("deepmerge"));
|
17
|
+
|
10
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
19
|
|
12
20
|
const sx = props => (0, _css.default)(props.sx);
|
package/lib/theme-preval.js
CHANGED
@@ -515,7 +515,7 @@ module.exports = {
|
|
515
515
|
}
|
516
516
|
}
|
517
517
|
},
|
518
|
-
"
|
518
|
+
"light_protanopia": {
|
519
519
|
"colors": {
|
520
520
|
"canvasDefaultTransparent": "rgba(255,255,255,0)",
|
521
521
|
"marketingIcon": {
|
@@ -2456,7 +2456,7 @@ module.exports = {
|
|
2456
2456
|
}
|
2457
2457
|
}
|
2458
2458
|
},
|
2459
|
-
"
|
2459
|
+
"dark_protanopia": {
|
2460
2460
|
"colors": {
|
2461
2461
|
"canvasDefaultTransparent": "rgba(13,17,23,0)",
|
2462
2462
|
"marketingIcon": {
|
@@ -0,0 +1,17 @@
|
|
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;
|
@@ -0,0 +1,105 @@
|
|
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 _useForceUpdate = require("./use-force-update");
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
/** createSlots is a factory that can create a
|
15
|
+
* typesafe Slots + Slot pair to use in a component definition
|
16
|
+
* For example: ActionList.Item uses createSlots to get a Slots wrapper
|
17
|
+
* + Slot component that is used by LeadingVisual, Description
|
18
|
+
*/
|
19
|
+
const createSlots = slotNames => {
|
20
|
+
const SlotsContext = /*#__PURE__*/_react.default.createContext({
|
21
|
+
registerSlot: () => null,
|
22
|
+
unregisterSlot: () => null,
|
23
|
+
context: {}
|
24
|
+
});
|
25
|
+
/** Slots uses a Double render strategy inspired by [reach-ui/descendants](https://github.com/reach/reach-ui/tree/develop/packages/descendants)
|
26
|
+
* Slot registers themself with the Slots parent.
|
27
|
+
* When all the children have mounted = registered themselves in slot,
|
28
|
+
* we re-render the parent component to render with slots
|
29
|
+
*/
|
30
|
+
|
31
|
+
|
32
|
+
const Slots = ({
|
33
|
+
context,
|
34
|
+
children
|
35
|
+
}) => {
|
36
|
+
// initialise slots
|
37
|
+
const slotsDefinition = {};
|
38
|
+
slotNames.map(name => slotsDefinition[name] = null);
|
39
|
+
|
40
|
+
const slotsRef = _react.default.useRef(slotsDefinition);
|
41
|
+
|
42
|
+
const rerenderWithSlots = (0, _useForceUpdate.useForceUpdate)();
|
43
|
+
|
44
|
+
const [isMounted, setIsMounted] = _react.default.useState(false); // fires after all the effects in children
|
45
|
+
|
46
|
+
|
47
|
+
_react.default.useEffect(() => {
|
48
|
+
rerenderWithSlots();
|
49
|
+
setIsMounted(true);
|
50
|
+
}, [rerenderWithSlots]);
|
51
|
+
|
52
|
+
const registerSlot = _react.default.useCallback((name, contents) => {
|
53
|
+
slotsRef.current[name] = contents; // don't render until the component mounts = all slots are registered
|
54
|
+
|
55
|
+
if (isMounted) rerenderWithSlots();
|
56
|
+
}, [isMounted, rerenderWithSlots]); // Slot can be removed from the tree as well,
|
57
|
+
// we need to unregister them from the slot
|
58
|
+
|
59
|
+
|
60
|
+
const unregisterSlot = _react.default.useCallback(name => {
|
61
|
+
slotsRef.current[name] = null;
|
62
|
+
rerenderWithSlots();
|
63
|
+
}, [rerenderWithSlots]);
|
64
|
+
/**
|
65
|
+
* Slots uses a render prop API so abstract the
|
66
|
+
* implementation detail of using a context provider.
|
67
|
+
*/
|
68
|
+
|
69
|
+
|
70
|
+
const slots = slotsRef.current;
|
71
|
+
return /*#__PURE__*/_react.default.createElement(SlotsContext.Provider, {
|
72
|
+
value: {
|
73
|
+
registerSlot,
|
74
|
+
unregisterSlot,
|
75
|
+
context
|
76
|
+
}
|
77
|
+
}, children(slots));
|
78
|
+
};
|
79
|
+
|
80
|
+
const Slot = ({
|
81
|
+
name,
|
82
|
+
children
|
83
|
+
}) => {
|
84
|
+
const {
|
85
|
+
registerSlot,
|
86
|
+
unregisterSlot,
|
87
|
+
context
|
88
|
+
} = _react.default.useContext(SlotsContext);
|
89
|
+
|
90
|
+
_react.default.useEffect(() => {
|
91
|
+
registerSlot(name, typeof children === 'function' ? children(context) : children);
|
92
|
+
return () => unregisterSlot(name);
|
93
|
+
}, [name, children, registerSlot, unregisterSlot, context]);
|
94
|
+
|
95
|
+
return null;
|
96
|
+
};
|
97
|
+
|
98
|
+
return {
|
99
|
+
Slots,
|
100
|
+
Slot
|
101
|
+
};
|
102
|
+
};
|
103
|
+
|
104
|
+
var _default = createSlots;
|
105
|
+
exports.default = _default;
|
package/lib/utils/testing.d.ts
CHANGED
@@ -53,7 +53,7 @@ export declare function render(component: React.ReactElement, theme?: {
|
|
53
53
|
xlarge: string;
|
54
54
|
};
|
55
55
|
space: string[];
|
56
|
-
colorSchemes: Record<"light" | "
|
56
|
+
colorSchemes: Record<"light" | "light_protanopia" | "dark" | "dark_dimmed" | "dark_high_contrast" | "dark_protanopia", Record<"colors" | "shadows", Partial<{
|
57
57
|
canvasDefaultTransparent: string;
|
58
58
|
marketingIcon: {
|
59
59
|
primary: string;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const useForceUpdate: () => () => void;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.useForceUpdate = void 0;
|
7
|
+
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
9
|
+
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
+
|
12
|
+
// Inspired from reach-ui: https://github.com/reach/reach-ui/blob/develop/packages/utils/src/use-force-update.ts
|
13
|
+
const useForceUpdate = () => {
|
14
|
+
const [, rerender] = _react.default.useState({});
|
15
|
+
|
16
|
+
return _react.default.useCallback(() => rerender({}), []);
|
17
|
+
};
|
18
|
+
|
19
|
+
exports.useForceUpdate = useForceUpdate;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import Box from '../Box';
|
3
|
+
import { merge } from '../sx';
|
4
|
+
import Truncate from '../Truncate';
|
5
|
+
import { Slot } from './Item';
|
6
|
+
export const Description = ({
|
7
|
+
variant = 'inline',
|
8
|
+
sx = {},
|
9
|
+
...props
|
10
|
+
}) => {
|
11
|
+
const styles = {
|
12
|
+
color: 'fg.muted',
|
13
|
+
fontSize: 0,
|
14
|
+
lineHeight: '16px',
|
15
|
+
flexGrow: 1,
|
16
|
+
flexBasis: 0,
|
17
|
+
minWidth: 0,
|
18
|
+
marginLeft: variant === 'block' ? 0 : 2
|
19
|
+
};
|
20
|
+
return /*#__PURE__*/React.createElement(Slot, {
|
21
|
+
name: variant === 'block' ? 'BlockDescription' : 'InlineDescription'
|
22
|
+
}, ({
|
23
|
+
blockDescriptionId,
|
24
|
+
inlineDescriptionId
|
25
|
+
}) => variant === 'block' ? /*#__PURE__*/React.createElement(Box, {
|
26
|
+
as: "span",
|
27
|
+
sx: merge(styles, sx),
|
28
|
+
id: blockDescriptionId
|
29
|
+
}, props.children) : /*#__PURE__*/React.createElement(Truncate, {
|
30
|
+
id: inlineDescriptionId,
|
31
|
+
sx: merge(styles, sx),
|
32
|
+
title: props.children,
|
33
|
+
inline: true,
|
34
|
+
maxWidth: "100%"
|
35
|
+
}, props.children));
|
36
|
+
};
|
37
|
+
Description.displayName = "Description";
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import Box from '../Box';
|
3
|
+
import { get } from '../constants';
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Visually separates `Item`s or `Group`s in an `ActionList`.
|
7
|
+
*/
|
8
|
+
export function Divider() {
|
9
|
+
return /*#__PURE__*/React.createElement(Box, {
|
10
|
+
as: "hr",
|
11
|
+
sx: {
|
12
|
+
border: 'none',
|
13
|
+
// override browser styles
|
14
|
+
height: 1,
|
15
|
+
backgroundColor: 'border.muted',
|
16
|
+
marginTop: theme => `calc(${get('space.2')(theme)} - 1px)`,
|
17
|
+
marginBottom: 2
|
18
|
+
},
|
19
|
+
"data-component": "ActionList.Divider"
|
20
|
+
});
|
21
|
+
}
|
22
|
+
Divider.displayName = "Divider";
|
23
|
+
|
24
|
+
/**
|
25
|
+
* `Divider` fulfills the `ItemPropsWithCustomRenderer` contract,
|
26
|
+
* so it can be used inline in an `ActionList`’s `items` prop.
|
27
|
+
* In other words, `items={[ActionList.Divider]}` is supported as a concise
|
28
|
+
* alternative to `items={[{renderItem: () => <ActionList.Divider />}]}`.
|
29
|
+
*/
|
30
|
+
Divider.renderItem = Divider;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/**
|
2
|
+
* show item dividers
|
3
|
+
*/
|
4
|
+
/// <reference types="react" />
|
5
|
+
import { SxProp } from '../sx';
|
6
|
+
import { HeaderProps } from './Header';
|
7
|
+
export declare type GroupProps = HeaderProps & SxProp;
|
8
|
+
export declare function Group({ title, variant, auxiliaryText, sx, ...props }: GroupProps): JSX.Element;
|