@primer/components 0.0.0-202191916821 → 0.0.0-2021920152952
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 +1 -17
- package/codemods/deprecateUtilityComponents.js +1 -1
- package/dist/browser.esm.js +768 -878
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +773 -883
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Item.js +1 -1
- package/lib/ActionList/List.d.ts +1 -2
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +1 -2
- package/lib/AnchoredOverlay/AnchoredOverlay.js +3 -11
- package/lib/BaseStyles.js +1 -1
- package/lib/BorderBox.js +1 -1
- package/lib/Button/ButtonInvisible.js +1 -1
- package/lib/Caret.js +2 -2
- package/lib/DatePicker/DatePicker.d.ts +47 -0
- package/lib/DatePicker/DatePicker.js +76 -0
- package/lib/DatePicker/DatePickerAnchor.d.ts +10 -0
- package/lib/DatePicker/DatePickerAnchor.js +83 -0
- package/lib/DatePicker/DatePickerPanel.d.ts +2 -0
- package/lib/DatePicker/DatePickerPanel.js +38 -0
- package/lib/DatePicker/Day.d.ts +13 -0
- package/lib/DatePicker/Day.js +136 -0
- package/lib/DatePicker/Month.d.ts +9 -0
- package/lib/DatePicker/Month.js +97 -0
- package/lib/DatePicker/index.d.ts +2 -0
- package/lib/DatePicker/index.js +13 -0
- package/lib/DatePicker/useDatePicker.d.ts +51 -0
- package/lib/DatePicker/useDatePicker.js +133 -0
- package/lib/Dialog.js +1 -1
- package/lib/FilteredActionList/FilteredActionList.js +31 -5
- package/lib/Flash.js +16 -16
- package/lib/Label.js +1 -1
- package/lib/Overlay.d.ts +0 -1
- package/lib/Overlay.js +1 -3
- package/lib/ProgressBar.js +1 -1
- package/lib/SelectMenu/SelectMenu.d.ts +10 -10
- package/lib/StateLabel.js +19 -13
- package/lib/TextInput.d.ts +13 -5
- package/lib/TextInput.js +46 -4
- package/lib/hooks/useOpenAndCloseFocus.d.ts +1 -2
- package/lib/hooks/useOpenAndCloseFocus.js +2 -7
- package/lib/hooks/useOverlay.d.ts +1 -2
- package/lib/hooks/useOverlay.js +2 -4
- package/lib/index.d.ts +0 -6
- package/lib/index.js +0 -44
- package/lib/theme-preval.js +3105 -375
- package/lib/utils/testing.d.ts +493 -50
- package/{lib-esm/utils/types/AriaRole.d.ts → lib/utils/types.d.ts} +13 -0
- package/lib/utils/{types/AriaRole.js → types.js} +0 -0
- package/lib-esm/ActionList/Item.js +1 -1
- package/lib-esm/ActionList/List.d.ts +1 -2
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +1 -2
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +3 -11
- package/lib-esm/BaseStyles.js +1 -1
- package/lib-esm/BorderBox.js +1 -1
- package/lib-esm/Button/ButtonInvisible.js +1 -1
- package/lib-esm/Caret.js +2 -2
- package/lib-esm/DatePicker/DatePicker.d.ts +47 -0
- package/lib-esm/DatePicker/DatePicker.js +57 -0
- package/lib-esm/DatePicker/DatePickerAnchor.d.ts +10 -0
- package/lib-esm/DatePicker/DatePickerAnchor.js +59 -0
- package/lib-esm/DatePicker/DatePickerPanel.d.ts +2 -0
- package/lib-esm/DatePicker/DatePickerPanel.js +20 -0
- package/lib-esm/DatePicker/Day.d.ts +13 -0
- package/lib-esm/DatePicker/Day.js +113 -0
- package/lib-esm/DatePicker/Month.d.ts +9 -0
- package/lib-esm/DatePicker/Month.js +74 -0
- package/lib-esm/DatePicker/index.d.ts +2 -0
- package/lib-esm/DatePicker/index.js +1 -0
- package/lib-esm/DatePicker/useDatePicker.d.ts +51 -0
- package/lib-esm/DatePicker/useDatePicker.js +114 -0
- package/lib-esm/Dialog.js +1 -1
- package/lib-esm/FilteredActionList/FilteredActionList.js +31 -3
- package/lib-esm/Flash.js +16 -16
- package/lib-esm/Label.js +1 -1
- package/lib-esm/Overlay.d.ts +0 -1
- package/lib-esm/Overlay.js +1 -3
- package/lib-esm/ProgressBar.js +1 -1
- package/lib-esm/SelectMenu/SelectMenu.d.ts +10 -10
- package/lib-esm/StateLabel.js +19 -13
- package/lib-esm/TextInput.d.ts +13 -5
- package/lib-esm/TextInput.js +37 -4
- package/lib-esm/hooks/useOpenAndCloseFocus.d.ts +1 -2
- package/lib-esm/hooks/useOpenAndCloseFocus.js +2 -7
- package/lib-esm/hooks/useOverlay.d.ts +1 -2
- package/lib-esm/hooks/useOverlay.js +2 -4
- package/lib-esm/index.d.ts +0 -6
- package/lib-esm/index.js +0 -4
- package/lib-esm/theme-preval.js +3105 -375
- package/lib-esm/utils/testing.d.ts +493 -50
- package/{lib/utils/types/AriaRole.d.ts → lib-esm/utils/types.d.ts} +13 -0
- package/lib-esm/utils/{types/AriaRole.js → types.js} +0 -0
- package/package.json +4 -4
- package/lib/ActionList2/Description.d.ts +0 -5
- package/lib/ActionList2/Description.js +0 -45
- package/lib/ActionList2/Divider.d.ts +0 -8
- package/lib/ActionList2/Divider.js +0 -42
- package/lib/ActionList2/Group.d.ts +0 -8
- package/lib/ActionList2/Group.js +0 -39
- package/lib/ActionList2/Header.d.ts +0 -26
- package/lib/ActionList2/Header.js +0 -55
- package/lib/ActionList2/Item.d.ts +0 -52
- package/lib/ActionList2/Item.js +0 -171
- package/lib/ActionList2/List.d.ts +0 -18
- package/lib/ActionList2/List.js +0 -52
- package/lib/ActionList2/Selection.d.ts +0 -5
- package/lib/ActionList2/Selection.js +0 -67
- package/lib/ActionList2/Visuals.d.ts +0 -12
- package/lib/ActionList2/Visuals.js +0 -87
- package/lib/ActionList2/hacks.d.ts +0 -30
- package/lib/ActionList2/hacks.js +0 -38
- package/lib/ActionList2/index.d.ts +0 -26
- package/lib/ActionList2/index.js +0 -36
- package/lib/Autocomplete/Autocomplete.d.ts +0 -304
- package/lib/Autocomplete/Autocomplete.js +0 -145
- package/lib/Autocomplete/AutocompleteContext.d.ts +0 -17
- package/lib/Autocomplete/AutocompleteContext.js +0 -11
- package/lib/Autocomplete/AutocompleteInput.d.ts +0 -292
- package/lib/Autocomplete/AutocompleteInput.js +0 -157
- package/lib/Autocomplete/AutocompleteMenu.d.ts +0 -72
- package/lib/Autocomplete/AutocompleteMenu.js +0 -224
- package/lib/Autocomplete/AutocompleteOverlay.d.ts +0 -20
- package/lib/Autocomplete/AutocompleteOverlay.js +0 -80
- package/lib/Autocomplete/index.d.ts +0 -2
- package/lib/Autocomplete/index.js +0 -15
- package/lib/TextInputWithTokens.d.ts +0 -323
- package/lib/TextInputWithTokens.js +0 -245
- package/lib/Token/AvatarToken.d.ts +0 -7
- package/lib/Token/AvatarToken.js +0 -64
- package/lib/Token/IssueLabelToken.d.ts +0 -14
- package/lib/Token/IssueLabelToken.js +0 -144
- package/lib/Token/Token.d.ts +0 -15
- package/lib/Token/Token.js +0 -94
- package/lib/Token/TokenBase.d.ts +0 -31
- package/lib/Token/TokenBase.js +0 -108
- package/lib/Token/_RemoveTokenButton.d.ts +0 -12
- package/lib/Token/_RemoveTokenButton.js +0 -77
- package/lib/Token/_TokenTextContainer.d.ts +0 -3
- package/lib/Token/_TokenTextContainer.js +0 -17
- package/lib/Token/index.d.ts +0 -3
- package/lib/Token/index.js +0 -31
- package/lib/_TextInputWrapper.d.ts +0 -10
- package/lib/_TextInputWrapper.js +0 -51
- package/lib/_UnstyledTextInput.d.ts +0 -2
- package/lib/_UnstyledTextInput.js +0 -20
- package/lib/behaviors/scrollIntoViewingArea.d.ts +0 -1
- package/lib/behaviors/scrollIntoViewingArea.js +0 -39
- package/lib/utils/create-slots.d.ts +0 -15
- package/lib/utils/create-slots.js +0 -101
- package/lib/utils/types/ComponentProps.d.ts +0 -9
- package/lib/utils/types/ComponentProps.js +0 -1
- package/lib/utils/types/Flatten.d.ts +0 -4
- package/lib/utils/types/Flatten.js +0 -1
- package/lib/utils/types/MandateProps.d.ts +0 -3
- package/lib/utils/types/MandateProps.js +0 -1
- package/lib/utils/types/Merge.d.ts +0 -19
- package/lib/utils/types/Merge.js +0 -1
- package/lib/utils/types/index.d.ts +0 -5
- package/lib/utils/types/index.js +0 -70
- package/lib/utils/use-force-update.d.ts +0 -1
- package/lib/utils/use-force-update.js +0 -19
- package/lib-esm/ActionList2/Description.d.ts +0 -5
- package/lib-esm/ActionList2/Description.js +0 -30
- package/lib-esm/ActionList2/Divider.d.ts +0 -8
- package/lib-esm/ActionList2/Divider.js +0 -30
- package/lib-esm/ActionList2/Group.d.ts +0 -8
- package/lib-esm/ActionList2/Group.js +0 -29
- package/lib-esm/ActionList2/Header.d.ts +0 -26
- package/lib-esm/ActionList2/Header.js +0 -45
- package/lib-esm/ActionList2/Item.d.ts +0 -52
- package/lib-esm/ActionList2/Item.js +0 -172
- package/lib-esm/ActionList2/List.d.ts +0 -18
- package/lib-esm/ActionList2/List.js +0 -42
- package/lib-esm/ActionList2/Selection.d.ts +0 -5
- package/lib-esm/ActionList2/Selection.js +0 -50
- package/lib-esm/ActionList2/Visuals.d.ts +0 -12
- package/lib-esm/ActionList2/Visuals.js +0 -66
- package/lib-esm/ActionList2/hacks.d.ts +0 -30
- package/lib-esm/ActionList2/hacks.js +0 -30
- package/lib-esm/ActionList2/index.d.ts +0 -26
- package/lib-esm/ActionList2/index.js +0 -23
- package/lib-esm/Autocomplete/Autocomplete.d.ts +0 -304
- package/lib-esm/Autocomplete/Autocomplete.js +0 -123
- package/lib-esm/Autocomplete/AutocompleteContext.d.ts +0 -17
- package/lib-esm/Autocomplete/AutocompleteContext.js +0 -2
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +0 -292
- package/lib-esm/Autocomplete/AutocompleteInput.js +0 -138
- package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +0 -72
- package/lib-esm/Autocomplete/AutocompleteMenu.js +0 -205
- package/lib-esm/Autocomplete/AutocompleteOverlay.d.ts +0 -20
- package/lib-esm/Autocomplete/AutocompleteOverlay.js +0 -62
- package/lib-esm/Autocomplete/index.d.ts +0 -2
- package/lib-esm/Autocomplete/index.js +0 -1
- package/lib-esm/TextInputWithTokens.d.ts +0 -323
- package/lib-esm/TextInputWithTokens.js +0 -220
- package/lib-esm/Token/AvatarToken.d.ts +0 -7
- package/lib-esm/Token/AvatarToken.js +0 -43
- package/lib-esm/Token/IssueLabelToken.d.ts +0 -14
- package/lib-esm/Token/IssueLabelToken.js +0 -124
- package/lib-esm/Token/Token.d.ts +0 -15
- package/lib-esm/Token/Token.js +0 -73
- package/lib-esm/Token/TokenBase.d.ts +0 -31
- package/lib-esm/Token/TokenBase.js +0 -87
- package/lib-esm/Token/_RemoveTokenButton.d.ts +0 -12
- package/lib-esm/Token/_RemoveTokenButton.js +0 -60
- package/lib-esm/Token/_TokenTextContainer.d.ts +0 -3
- package/lib-esm/Token/_TokenTextContainer.js +0 -6
- package/lib-esm/Token/index.d.ts +0 -3
- package/lib-esm/Token/index.js +0 -3
- package/lib-esm/_TextInputWrapper.d.ts +0 -10
- package/lib-esm/_TextInputWrapper.js +0 -31
- package/lib-esm/_UnstyledTextInput.d.ts +0 -2
- package/lib-esm/_UnstyledTextInput.js +0 -7
- package/lib-esm/behaviors/scrollIntoViewingArea.d.ts +0 -1
- package/lib-esm/behaviors/scrollIntoViewingArea.js +0 -30
- package/lib-esm/utils/create-slots.d.ts +0 -15
- package/lib-esm/utils/create-slots.js +0 -80
- package/lib-esm/utils/types/ComponentProps.d.ts +0 -9
- package/lib-esm/utils/types/ComponentProps.js +0 -1
- package/lib-esm/utils/types/Flatten.d.ts +0 -4
- package/lib-esm/utils/types/Flatten.js +0 -1
- package/lib-esm/utils/types/MandateProps.d.ts +0 -3
- package/lib-esm/utils/types/MandateProps.js +0 -1
- package/lib-esm/utils/types/Merge.d.ts +0 -19
- package/lib-esm/utils/types/Merge.js +0 -1
- package/lib-esm/utils/types/index.d.ts +0 -5
- package/lib-esm/utils/types/index.js +0 -5
- package/lib-esm/utils/use-force-update.d.ts +0 -1
- package/lib-esm/utils/use-force-update.js +0 -6
package/lib/_TextInputWrapper.js
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
|
8
|
-
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
9
|
-
|
10
|
-
var _styledSystem = require("styled-system");
|
11
|
-
|
12
|
-
var _constants = require("./constants");
|
13
|
-
|
14
|
-
var _sx = _interopRequireDefault(require("./sx"));
|
15
|
-
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
-
|
18
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
19
|
-
|
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
|
-
|
22
|
-
const sizeVariants = (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
|
-
|
39
|
-
const TextInputWrapper = _styledComponents.default.span.withConfig({
|
40
|
-
displayName: "_TextInputWrapper__TextInputWrapper",
|
41
|
-
componentId: "sc-5vfcis-0"
|
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:", ";", " .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.fg.muted'), (0, _constants.get)('colors.input.disabledBg'), (0, _constants.get)('colors.border.default')), props => props.block && (0, _styledComponents.css)(["display:block;width:100%;"]), (0, _constants.get)('breakpoints.1'), (0, _constants.get)('fontSizes.1'), _styledSystem.width, _styledSystem.minWidth, _styledSystem.maxWidth, sizeVariants, _sx.default);
|
49
|
-
|
50
|
-
var _default = TextInputWrapper;
|
51
|
-
exports.default = _default;
|
@@ -1,20 +0,0 @@
|
|
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 _sx = _interopRequireDefault(require("./sx"));
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
14
|
-
const UnstyledTextInput = _styledComponents.default.input.withConfig({
|
15
|
-
displayName: "_UnstyledTextInput__UnstyledTextInput",
|
16
|
-
componentId: "sc-1jgl33s-0"
|
17
|
-
})(["border:0;font-size:inherit;font-family:inherit;background-color:transparent;-webkit-appearance:none;color:inherit;width:100%;&:focus{outline:0;}", ";"], _sx.default);
|
18
|
-
|
19
|
-
var _default = UnstyledTextInput;
|
20
|
-
exports.default = _default;
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const scrollIntoViewingArea: (child: HTMLElement, viewingArea: HTMLElement, direction?: 'horizontal' | 'vertical', startMargin?: number, endMargin?: number, behavior?: ScrollBehavior) => void;
|
@@ -1,39 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.scrollIntoViewingArea = void 0;
|
7
|
-
|
8
|
-
const scrollIntoViewingArea = (child, viewingArea, direction = 'vertical', startMargin = 8, endMargin = 0, behavior = 'smooth') => {
|
9
|
-
const startSide = direction === 'vertical' ? 'top' : 'left';
|
10
|
-
const endSide = direction === 'vertical' ? 'bottom' : 'right';
|
11
|
-
const scrollSide = direction === 'vertical' ? 'scrollTop' : 'scrollLeft';
|
12
|
-
const {
|
13
|
-
[startSide]: childStart,
|
14
|
-
[endSide]: childEnd
|
15
|
-
} = child.getBoundingClientRect();
|
16
|
-
const {
|
17
|
-
[startSide]: viewingAreaStart,
|
18
|
-
[endSide]: viewingAreaEnd
|
19
|
-
} = viewingArea.getBoundingClientRect();
|
20
|
-
const isChildStartAboveViewingArea = childStart < viewingAreaStart + endMargin;
|
21
|
-
const isChildBottomBelowViewingArea = childEnd > viewingAreaEnd - startMargin;
|
22
|
-
|
23
|
-
if (isChildStartAboveViewingArea) {
|
24
|
-
const scrollHeightToChildStart = childStart - viewingAreaStart + viewingArea[scrollSide];
|
25
|
-
viewingArea.scrollTo({
|
26
|
-
behavior,
|
27
|
-
[startSide]: scrollHeightToChildStart - endMargin
|
28
|
-
});
|
29
|
-
} else if (isChildBottomBelowViewingArea) {
|
30
|
-
const scrollHeightToChildBottom = childEnd - viewingAreaEnd + viewingArea[scrollSide];
|
31
|
-
viewingArea.scrollTo({
|
32
|
-
behavior,
|
33
|
-
[startSide]: scrollHeightToChildBottom + startMargin
|
34
|
-
});
|
35
|
-
} // either completely in view or outside viewing area on both ends, don't scroll
|
36
|
-
|
37
|
-
};
|
38
|
-
|
39
|
-
exports.scrollIntoViewingArea = scrollIntoViewingArea;
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
/** createSlots is a factory that can create a
|
3
|
-
* typesafe Slots + Slot pair to use in a component definition
|
4
|
-
* For example: ActionList.Item uses createSlots to get a Slots wrapper
|
5
|
-
* + Slot component that is used by LeadingVisual, Description
|
6
|
-
*/
|
7
|
-
declare const createSlots: <SlotNames extends string>(slotNames: SlotNames[]) => {
|
8
|
-
Slots: React.FC<{
|
9
|
-
children: (slots: { [key in SlotNames]?: React.ReactNode; }) => React.ReactNode;
|
10
|
-
}>;
|
11
|
-
Slot: React.FC<{
|
12
|
-
name: SlotNames;
|
13
|
-
}>;
|
14
|
-
};
|
15
|
-
export default createSlots;
|
@@ -1,101 +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 _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
|
-
});
|
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
|
-
const Slots = ({
|
31
|
-
children
|
32
|
-
}) => {
|
33
|
-
// initialise slots
|
34
|
-
const slotsDefinition = {};
|
35
|
-
slotNames.map(name => slotsDefinition[name] = null);
|
36
|
-
|
37
|
-
const slotsRef = _react.default.useRef(slotsDefinition);
|
38
|
-
|
39
|
-
const rerenderWithSlots = (0, _useForceUpdate.useForceUpdate)();
|
40
|
-
|
41
|
-
const [isMounted, setIsMounted] = _react.default.useState(false); // fires after all the effects in children
|
42
|
-
|
43
|
-
|
44
|
-
_react.default.useEffect(() => {
|
45
|
-
rerenderWithSlots();
|
46
|
-
setIsMounted(true);
|
47
|
-
}, [rerenderWithSlots]);
|
48
|
-
|
49
|
-
const slots = slotsRef.current;
|
50
|
-
|
51
|
-
const registerSlot = _react.default.useCallback((name, contents) => {
|
52
|
-
slotsRef.current[name] = contents; // don't render until the component mounts = all slots are registered
|
53
|
-
|
54
|
-
if (isMounted) rerenderWithSlots();
|
55
|
-
}, [isMounted, rerenderWithSlots]); // Slot can be removed from the tree as well,
|
56
|
-
// we need to unregister them from the slot
|
57
|
-
|
58
|
-
|
59
|
-
const unregisterSlot = _react.default.useCallback(name => {
|
60
|
-
slotsRef.current[name] = null;
|
61
|
-
rerenderWithSlots();
|
62
|
-
}, [rerenderWithSlots]);
|
63
|
-
/**
|
64
|
-
* Slots uses a render prop API so abstract the
|
65
|
-
* implementation detail of using a context provider.
|
66
|
-
*/
|
67
|
-
|
68
|
-
|
69
|
-
return /*#__PURE__*/_react.default.createElement(SlotsContext.Provider, {
|
70
|
-
value: {
|
71
|
-
registerSlot,
|
72
|
-
unregisterSlot
|
73
|
-
}
|
74
|
-
}, children(slots));
|
75
|
-
};
|
76
|
-
|
77
|
-
const Slot = ({
|
78
|
-
name,
|
79
|
-
children
|
80
|
-
}) => {
|
81
|
-
const {
|
82
|
-
registerSlot,
|
83
|
-
unregisterSlot
|
84
|
-
} = _react.default.useContext(SlotsContext);
|
85
|
-
|
86
|
-
_react.default.useEffect(() => {
|
87
|
-
registerSlot(name, children);
|
88
|
-
return () => unregisterSlot(name);
|
89
|
-
}, [name, children, registerSlot, unregisterSlot]);
|
90
|
-
|
91
|
-
return null;
|
92
|
-
};
|
93
|
-
|
94
|
-
return {
|
95
|
-
Slots,
|
96
|
-
Slot
|
97
|
-
};
|
98
|
-
};
|
99
|
-
|
100
|
-
var _default = createSlots;
|
101
|
-
exports.default = _default;
|
@@ -1,9 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
/**
|
3
|
-
* Extract a component's props
|
4
|
-
*
|
5
|
-
* Source: https://react-typescript-cheatsheet.netlify.app/docs/advanced/patterns_by_usecase#wrappingmirroring-a-component
|
6
|
-
*
|
7
|
-
* @example ComponentProps<typeof MyComponent>
|
8
|
-
*/
|
9
|
-
export declare type ComponentProps<T> = T extends React.ComponentType<infer Props> ? Props extends object ? Props : never : never;
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";
|
@@ -1,19 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Given two object types A and B, return a type with all the properties of A that aren't also
|
3
|
-
* properties of B, and all the properties of B.
|
4
|
-
*
|
5
|
-
* Useful when we have a component that spreads a "rest" of its props on a subcomponent:
|
6
|
-
*
|
7
|
-
* ```ts
|
8
|
-
* interface OwnProps {
|
9
|
-
* foo: string
|
10
|
-
* }
|
11
|
-
*
|
12
|
-
* type MyComponentProps = Merge<SubcomponentProps, OwnProps>
|
13
|
-
* const MyComponent = ({foo, ...rest}: MyComponentProps) => {
|
14
|
-
* // ...
|
15
|
-
* return <SubComponent {...rest} />
|
16
|
-
* }
|
17
|
-
* ```
|
18
|
-
*/
|
19
|
-
export declare type Merge<A = {}, B = {}> = Omit<A, keyof B> & B;
|
package/lib/utils/types/Merge.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";
|
package/lib/utils/types/index.js
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
|
7
|
-
var _AriaRole = require("./AriaRole");
|
8
|
-
|
9
|
-
Object.keys(_AriaRole).forEach(function (key) {
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
11
|
-
if (key in exports && exports[key] === _AriaRole[key]) return;
|
12
|
-
Object.defineProperty(exports, key, {
|
13
|
-
enumerable: true,
|
14
|
-
get: function () {
|
15
|
-
return _AriaRole[key];
|
16
|
-
}
|
17
|
-
});
|
18
|
-
});
|
19
|
-
|
20
|
-
var _ComponentProps = require("./ComponentProps");
|
21
|
-
|
22
|
-
Object.keys(_ComponentProps).forEach(function (key) {
|
23
|
-
if (key === "default" || key === "__esModule") return;
|
24
|
-
if (key in exports && exports[key] === _ComponentProps[key]) return;
|
25
|
-
Object.defineProperty(exports, key, {
|
26
|
-
enumerable: true,
|
27
|
-
get: function () {
|
28
|
-
return _ComponentProps[key];
|
29
|
-
}
|
30
|
-
});
|
31
|
-
});
|
32
|
-
|
33
|
-
var _Flatten = require("./Flatten");
|
34
|
-
|
35
|
-
Object.keys(_Flatten).forEach(function (key) {
|
36
|
-
if (key === "default" || key === "__esModule") return;
|
37
|
-
if (key in exports && exports[key] === _Flatten[key]) return;
|
38
|
-
Object.defineProperty(exports, key, {
|
39
|
-
enumerable: true,
|
40
|
-
get: function () {
|
41
|
-
return _Flatten[key];
|
42
|
-
}
|
43
|
-
});
|
44
|
-
});
|
45
|
-
|
46
|
-
var _Merge = require("./Merge");
|
47
|
-
|
48
|
-
Object.keys(_Merge).forEach(function (key) {
|
49
|
-
if (key === "default" || key === "__esModule") return;
|
50
|
-
if (key in exports && exports[key] === _Merge[key]) return;
|
51
|
-
Object.defineProperty(exports, key, {
|
52
|
-
enumerable: true,
|
53
|
-
get: function () {
|
54
|
-
return _Merge[key];
|
55
|
-
}
|
56
|
-
});
|
57
|
-
});
|
58
|
-
|
59
|
-
var _MandateProps = require("./MandateProps");
|
60
|
-
|
61
|
-
Object.keys(_MandateProps).forEach(function (key) {
|
62
|
-
if (key === "default" || key === "__esModule") return;
|
63
|
-
if (key in exports && exports[key] === _MandateProps[key]) return;
|
64
|
-
Object.defineProperty(exports, key, {
|
65
|
-
enumerable: true,
|
66
|
-
get: function () {
|
67
|
-
return _MandateProps[key];
|
68
|
-
}
|
69
|
-
});
|
70
|
-
});
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const useForceUpdate: () => () => void;
|
@@ -1,19 +0,0 @@
|
|
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;
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import Box from '../Box';
|
3
|
-
import Truncate from '../Truncate';
|
4
|
-
import { Slot } from './Item';
|
5
|
-
export const Description = ({
|
6
|
-
variant = 'inline',
|
7
|
-
...props
|
8
|
-
}) => {
|
9
|
-
const styles = {
|
10
|
-
color: 'fg.muted',
|
11
|
-
fontSize: 0,
|
12
|
-
lineHeight: '16px',
|
13
|
-
flexGrow: 1,
|
14
|
-
flexBasis: 0,
|
15
|
-
minWidth: 0,
|
16
|
-
marginLeft: variant === 'block' ? 0 : 2
|
17
|
-
};
|
18
|
-
return /*#__PURE__*/React.createElement(Slot, {
|
19
|
-
name: variant === 'block' ? 'BlockDescription' : 'InlineDescription'
|
20
|
-
}, variant === 'block' ? /*#__PURE__*/React.createElement(Box, {
|
21
|
-
as: "span",
|
22
|
-
sx: styles
|
23
|
-
}, props.children) : /*#__PURE__*/React.createElement(Truncate, {
|
24
|
-
sx: styles,
|
25
|
-
title: props.children,
|
26
|
-
inline: true,
|
27
|
-
maxWidth: "100%"
|
28
|
-
}, props.children));
|
29
|
-
};
|
30
|
-
Description.displayName = "Description";
|
@@ -1,30 +0,0 @@
|
|
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;
|
@@ -1,8 +0,0 @@
|
|
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;
|
@@ -1,29 +0,0 @@
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
-
|
3
|
-
/**
|
4
|
-
* show item dividers
|
5
|
-
*/
|
6
|
-
import React from 'react';
|
7
|
-
import Box from '../Box';
|
8
|
-
import { Header } from './Header';
|
9
|
-
export function Group({
|
10
|
-
title,
|
11
|
-
variant,
|
12
|
-
auxiliaryText,
|
13
|
-
sx = {},
|
14
|
-
...props
|
15
|
-
}) {
|
16
|
-
return /*#__PURE__*/React.createElement(Box, _extends({
|
17
|
-
sx: {
|
18
|
-
'&:not(:first-child)': {
|
19
|
-
marginTop: 2
|
20
|
-
},
|
21
|
-
...sx
|
22
|
-
}
|
23
|
-
}, props), title && /*#__PURE__*/React.createElement(Header, {
|
24
|
-
title: title,
|
25
|
-
variant: variant,
|
26
|
-
auxiliaryText: auxiliaryText
|
27
|
-
}), props.children);
|
28
|
-
}
|
29
|
-
Group.displayName = "Group";
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { SxProp } from '../sx';
|
3
|
-
/**
|
4
|
-
* Contract for props passed to the `Header` component.
|
5
|
-
*/
|
6
|
-
export interface HeaderProps extends React.ComponentPropsWithoutRef<'div'>, SxProp {
|
7
|
-
/**
|
8
|
-
* Style variations. Usage is discretionary.
|
9
|
-
*
|
10
|
-
* - `"filled"` - Superimposed on a background, offset from nearby content
|
11
|
-
* - `"subtle"` - Relatively less offset from nearby content
|
12
|
-
*/
|
13
|
-
variant?: 'subtle' | 'filled';
|
14
|
-
/**
|
15
|
-
* Primary text which names a `Group`.
|
16
|
-
*/
|
17
|
-
title?: string;
|
18
|
-
/**
|
19
|
-
* Secondary text which provides additional information about a `Group`.
|
20
|
-
*/
|
21
|
-
auxiliaryText?: string;
|
22
|
-
}
|
23
|
-
/**
|
24
|
-
* Displays the name and description of a `Group`.
|
25
|
-
*/
|
26
|
-
export declare function Header({ variant, title, auxiliaryText, children: _children, sx, ...props }: HeaderProps): JSX.Element;
|
@@ -1,45 +0,0 @@
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
-
|
3
|
-
import React from 'react';
|
4
|
-
import Box from '../Box';
|
5
|
-
import { ListContext } from './List';
|
6
|
-
/**
|
7
|
-
* Contract for props passed to the `Header` component.
|
8
|
-
*/
|
9
|
-
|
10
|
-
/**
|
11
|
-
* Displays the name and description of a `Group`.
|
12
|
-
*/
|
13
|
-
export function Header({
|
14
|
-
variant = 'subtle',
|
15
|
-
title,
|
16
|
-
auxiliaryText,
|
17
|
-
children: _children,
|
18
|
-
sx = {},
|
19
|
-
...props
|
20
|
-
}) {
|
21
|
-
const {
|
22
|
-
variant: listVariant
|
23
|
-
} = React.useContext(ListContext);
|
24
|
-
const styles = {
|
25
|
-
paddingY: '6px',
|
26
|
-
paddingX: listVariant === 'full' ? 2 : 3,
|
27
|
-
fontSize: 0,
|
28
|
-
fontWeight: 'bold',
|
29
|
-
color: 'fg.muted',
|
30
|
-
...(variant === 'filled' && {
|
31
|
-
backgroundColor: 'canvas.subtle',
|
32
|
-
marginX: 0,
|
33
|
-
marginBottom: 2,
|
34
|
-
borderTop: '1px solid',
|
35
|
-
borderBottom: '1px solid',
|
36
|
-
borderColor: 'neutral.muted'
|
37
|
-
}),
|
38
|
-
...sx
|
39
|
-
};
|
40
|
-
return /*#__PURE__*/React.createElement(Box, _extends({
|
41
|
-
sx: styles,
|
42
|
-
role: "heading"
|
43
|
-
}, props), title, auxiliaryText && /*#__PURE__*/React.createElement("span", null, "auxiliaryText"));
|
44
|
-
}
|
45
|
-
Header.displayName = "Header";
|
@@ -1,52 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* test suite!
|
3
|
-
* id, role
|
4
|
-
* text could be non-text
|
5
|
-
* activeDescendantAttribute
|
6
|
-
* deepmerge sx
|
7
|
-
* nicer name for showDivider?
|
8
|
-
* aria-label
|
9
|
-
* aria-describedby
|
10
|
-
* React.FC<Props> doesn't allow id?
|
11
|
-
* truncate description
|
12
|
-
* icon color
|
13
|
-
* disabled checkbox
|
14
|
-
* check height with divider
|
15
|
-
*
|
16
|
-
* use immediate child slot API instead of double render?
|
17
|
-
* change as= li | div based on context of menu or not?
|
18
|
-
* check if everyone accepts sx prop
|
19
|
-
* link example outside of overlay? (details)
|
20
|
-
* if one item has selected, should we give all of them selected without the need to pass prop?
|
21
|
-
* move custom item themes to primitives?
|
22
|
-
* padding: 8 or 6?
|
23
|
-
* ActionList.Selection or ActionList.Item selected?
|
24
|
-
* different size for icon and avatar, range?
|
25
|
-
* minimize number of divs?
|
26
|
-
* can use layoutEffect on server?
|
27
|
-
*/
|
28
|
-
import React from 'react';
|
29
|
-
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
30
|
-
import { SxProp } from '../sx';
|
31
|
-
export declare const getVariantStyles: (variant: ItemProps['variant'], disabled: ItemProps['disabled']) => {
|
32
|
-
color: (props: any) => any;
|
33
|
-
iconColor: (props: any) => any;
|
34
|
-
annotationColor: (props: any) => any;
|
35
|
-
} | {
|
36
|
-
color: string;
|
37
|
-
iconColor: string;
|
38
|
-
annotationColor: string;
|
39
|
-
};
|
40
|
-
declare const Slot: React.FC<{
|
41
|
-
name: "LeadingVisual" | "InlineDescription" | "BlockDescription" | "TrailingVisual";
|
42
|
-
}>;
|
43
|
-
export { Slot };
|
44
|
-
export declare type ItemProps = {
|
45
|
-
children: React.ReactNode;
|
46
|
-
onAction?: (event: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLLIElement>) => void;
|
47
|
-
selected?: boolean;
|
48
|
-
variant?: 'default' | 'danger';
|
49
|
-
disabled?: boolean;
|
50
|
-
showDivider?: boolean;
|
51
|
-
} & SxProp;
|
52
|
-
export declare const Item: PolymorphicForwardRefComponent<"li", ItemProps>;
|