@primer/components 0.0.0-20219815255 → 0.0.0-20219835928
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 -1
- package/dist/browser.esm.js +252 -256
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +331 -335
- package/dist/browser.umd.js.map +1 -1
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +2 -1
- package/lib/AnchoredOverlay/AnchoredOverlay.js +11 -3
- package/lib/Autocomplete/Autocomplete.d.ts +40 -0
- package/lib/Autocomplete/Autocomplete.js +68 -0
- package/lib/Autocomplete/AutocompleteContext.d.ts +17 -0
- package/lib/Autocomplete/AutocompleteContext.js +11 -0
- package/lib/Autocomplete/AutocompleteInput.d.ts +9 -0
- package/lib/Autocomplete/AutocompleteInput.js +150 -0
- package/lib/Autocomplete/AutocompleteMenu.d.ts +71 -0
- package/lib/Autocomplete/AutocompleteMenu.js +223 -0
- package/lib/Autocomplete/AutocompleteOverlay.d.ts +17 -0
- package/lib/Autocomplete/AutocompleteOverlay.js +69 -0
- package/lib/Autocomplete/index.d.ts +2 -0
- package/lib/Autocomplete/index.js +15 -0
- package/lib/FilteredActionList/FilteredActionList.js +5 -31
- package/lib/Overlay.d.ts +2 -1
- package/lib/Overlay.js +10 -5
- package/lib/SelectMenu/SelectMenu.d.ts +3 -8
- package/lib/TextInput.d.ts +3 -13
- package/lib/TextInput.js +3 -43
- package/lib/TextInputWithTokens.d.ts +11 -14
- package/lib/TextInputWithTokens.js +119 -119
- package/lib/_TextInputWrapper.d.ts +10 -0
- package/lib/_TextInputWrapper.js +51 -0
- package/lib/hooks/useOpenAndCloseFocus.d.ts +2 -1
- package/lib/hooks/useOpenAndCloseFocus.js +7 -2
- package/lib/hooks/useOverlay.d.ts +2 -1
- package/lib/hooks/useOverlay.js +4 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +8 -0
- package/lib/utils/scrollIntoViewingArea.d.ts +1 -0
- package/lib/utils/scrollIntoViewingArea.js +39 -0
- package/lib/utils/types/MandateProps.d.ts +3 -0
- package/lib/utils/types/MandateProps.js +1 -0
- package/lib/utils/types/index.d.ts +1 -0
- package/lib/utils/types/index.js +13 -0
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +2 -1
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +11 -3
- package/lib-esm/Autocomplete/Autocomplete.d.ts +40 -0
- package/lib-esm/Autocomplete/Autocomplete.js +47 -0
- package/lib-esm/Autocomplete/AutocompleteContext.d.ts +17 -0
- package/lib-esm/Autocomplete/AutocompleteContext.js +2 -0
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +9 -0
- package/lib-esm/Autocomplete/AutocompleteInput.js +131 -0
- package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +71 -0
- package/lib-esm/Autocomplete/AutocompleteMenu.js +204 -0
- package/lib-esm/Autocomplete/AutocompleteOverlay.d.ts +17 -0
- package/lib-esm/Autocomplete/AutocompleteOverlay.js +51 -0
- package/lib-esm/Autocomplete/index.d.ts +2 -0
- package/lib-esm/Autocomplete/index.js +1 -0
- package/lib-esm/FilteredActionList/FilteredActionList.js +3 -31
- package/lib-esm/Overlay.d.ts +2 -1
- package/lib-esm/Overlay.js +8 -5
- package/lib-esm/SelectMenu/SelectMenu.d.ts +3 -8
- package/lib-esm/TextInput.d.ts +3 -13
- package/lib-esm/TextInput.js +3 -34
- package/lib-esm/TextInputWithTokens.d.ts +11 -14
- package/lib-esm/TextInputWithTokens.js +117 -115
- package/lib-esm/_TextInputWrapper.d.ts +10 -0
- package/lib-esm/_TextInputWrapper.js +31 -0
- package/lib-esm/hooks/useOpenAndCloseFocus.d.ts +2 -1
- package/lib-esm/hooks/useOpenAndCloseFocus.js +7 -2
- package/lib-esm/hooks/useOverlay.d.ts +2 -1
- package/lib-esm/hooks/useOverlay.js +4 -2
- package/lib-esm/index.d.ts +1 -0
- package/lib-esm/index.js +1 -0
- package/lib-esm/utils/scrollIntoViewingArea.d.ts +1 -0
- package/lib-esm/utils/scrollIntoViewingArea.js +30 -0
- package/lib-esm/utils/types/MandateProps.d.ts +3 -0
- package/lib-esm/utils/types/MandateProps.js +1 -0
- package/lib-esm/utils/types/index.d.ts +1 -0
- package/lib-esm/utils/types/index.js +2 -1
- package/package.json +1 -1
@@ -0,0 +1,69 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
9
|
+
|
10
|
+
var _hooks = require("../hooks");
|
11
|
+
|
12
|
+
var _Overlay = _interopRequireDefault(require("../Overlay"));
|
13
|
+
|
14
|
+
var _AutocompleteContext = require("./AutocompleteContext");
|
15
|
+
|
16
|
+
var _useCombinedRefs = require("../hooks/useCombinedRefs");
|
17
|
+
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
|
+
|
20
|
+
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); }
|
21
|
+
|
22
|
+
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; }
|
23
|
+
|
24
|
+
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); }
|
25
|
+
|
26
|
+
// TODO: consider making 'aria-labelledby' required
|
27
|
+
const AutocompleteOverlay = ({
|
28
|
+
menuAnchorRef,
|
29
|
+
overlayProps,
|
30
|
+
children
|
31
|
+
}) => {
|
32
|
+
const {
|
33
|
+
inputRef,
|
34
|
+
scrollContainerRef,
|
35
|
+
selectedItemLength,
|
36
|
+
setShowMenu,
|
37
|
+
showMenu = false
|
38
|
+
} = (0, _react.useContext)(_AutocompleteContext.AutocompleteContext);
|
39
|
+
const {
|
40
|
+
floatingElementRef,
|
41
|
+
position
|
42
|
+
} = (0, _hooks.useAnchoredPosition)({
|
43
|
+
side: 'outside-bottom',
|
44
|
+
align: 'start',
|
45
|
+
anchorElementRef: menuAnchorRef ? menuAnchorRef : inputRef
|
46
|
+
}, [showMenu, selectedItemLength]);
|
47
|
+
const combinedOverlayRef = (0, _useCombinedRefs.useCombinedRefs)(scrollContainerRef, floatingElementRef);
|
48
|
+
const closeOptionList = (0, _react.useCallback)(() => {
|
49
|
+
setShowMenu && setShowMenu(false);
|
50
|
+
}, [setShowMenu]);
|
51
|
+
return /*#__PURE__*/_react.default.createElement(_Overlay.default, _extends({
|
52
|
+
returnFocusRef: inputRef,
|
53
|
+
preventFocusOnOpen: true,
|
54
|
+
onClickOutside: closeOptionList,
|
55
|
+
onEscape: closeOptionList,
|
56
|
+
ref: combinedOverlayRef,
|
57
|
+
top: position === null || position === void 0 ? void 0 : position.top,
|
58
|
+
left: position === null || position === void 0 ? void 0 : position.left,
|
59
|
+
visibility: showMenu ? 'visible' : 'hidden',
|
60
|
+
sx: {
|
61
|
+
overflow: 'auto'
|
62
|
+
}
|
63
|
+
}, overlayProps), children);
|
64
|
+
};
|
65
|
+
|
66
|
+
AutocompleteOverlay.displayName = "AutocompleteOverlay";
|
67
|
+
AutocompleteOverlay.displayName = 'AutocompleteOverlay';
|
68
|
+
var _default = AutocompleteOverlay;
|
69
|
+
exports.default = _default;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
Object.defineProperty(exports, "default", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function () {
|
9
|
+
return _Autocomplete.default;
|
10
|
+
}
|
11
|
+
});
|
12
|
+
|
13
|
+
var _Autocomplete = _interopRequireDefault(require("./Autocomplete"));
|
14
|
+
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -7,6 +7,8 @@ exports.FilteredActionList = FilteredActionList;
|
|
7
7
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
9
9
|
|
10
|
+
var _ssr = require("@react-aria/ssr");
|
11
|
+
|
10
12
|
var _TextInput = _interopRequireDefault(require("../TextInput"));
|
11
13
|
|
12
14
|
var _Box = _interopRequireDefault(require("../Box"));
|
@@ -27,7 +29,7 @@ var _useProvidedRefOrCreate = require("../hooks/useProvidedRefOrCreate");
|
|
27
29
|
|
28
30
|
var _useScrollFlash = _interopRequireDefault(require("../hooks/useScrollFlash"));
|
29
31
|
|
30
|
-
var
|
32
|
+
var _scrollIntoViewingArea = require("../utils/scrollIntoViewingArea");
|
31
33
|
|
32
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
33
35
|
|
@@ -37,34 +39,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
37
39
|
|
38
40
|
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); }
|
39
41
|
|
40
|
-
function scrollIntoViewingArea(child, container, margin = 8, behavior = 'smooth') {
|
41
|
-
const {
|
42
|
-
top: childTop,
|
43
|
-
bottom: childBottom
|
44
|
-
} = child.getBoundingClientRect();
|
45
|
-
const {
|
46
|
-
top: containerTop,
|
47
|
-
bottom: containerBottom
|
48
|
-
} = container.getBoundingClientRect();
|
49
|
-
const isChildTopAboveViewingArea = childTop < containerTop + margin;
|
50
|
-
const isChildBottomBelowViewingArea = childBottom > containerBottom - margin;
|
51
|
-
|
52
|
-
if (isChildTopAboveViewingArea) {
|
53
|
-
const scrollHeightToChildTop = childTop - containerTop + container.scrollTop;
|
54
|
-
container.scrollTo({
|
55
|
-
behavior,
|
56
|
-
top: scrollHeightToChildTop - margin
|
57
|
-
});
|
58
|
-
} else if (isChildBottomBelowViewingArea) {
|
59
|
-
const scrollHeightToChildBottom = childBottom - containerBottom + container.scrollTop;
|
60
|
-
container.scrollTo({
|
61
|
-
behavior,
|
62
|
-
top: scrollHeightToChildBottom + margin
|
63
|
-
});
|
64
|
-
} // either completely in view or outside viewing area on both ends, don't scroll
|
65
|
-
|
66
|
-
}
|
67
|
-
|
68
42
|
const StyledHeader = _styledComponents.default.div.withConfig({
|
69
43
|
displayName: "FilteredActionList__StyledHeader",
|
70
44
|
componentId: "yg3jkv-0"
|
@@ -112,7 +86,7 @@ function FilteredActionList({
|
|
112
86
|
activeDescendantRef.current = current;
|
113
87
|
|
114
88
|
if (current && scrollContainerRef.current && directlyActivated) {
|
115
|
-
scrollIntoViewingArea(current, scrollContainerRef.current);
|
89
|
+
(0, _scrollIntoViewingArea.scrollIntoViewingArea)(current, scrollContainerRef.current);
|
116
90
|
}
|
117
91
|
}
|
118
92
|
}, [// List ref isn't set while loading. Need to re-bind focus zone when it changes
|
@@ -120,7 +94,7 @@ function FilteredActionList({
|
|
120
94
|
(0, _react.useEffect)(() => {
|
121
95
|
// if items changed, we want to instantly move active descendant into view
|
122
96
|
if (activeDescendantRef.current && scrollContainerRef.current) {
|
123
|
-
scrollIntoViewingArea(activeDescendantRef.current, scrollContainerRef.current, undefined, 'auto');
|
97
|
+
(0, _scrollIntoViewingArea.scrollIntoViewingArea)(activeDescendantRef.current, scrollContainerRef.current, 'vertical', undefined, undefined, 'auto');
|
124
98
|
}
|
125
99
|
}, [items]);
|
126
100
|
(0, _useScrollFlash.default)(scrollContainerRef);
|
package/lib/Overlay.d.ts
CHANGED
@@ -4,7 +4,7 @@ import { ComponentProps } from './utils/types';
|
|
4
4
|
import { TouchOrMouseEvent } from './hooks';
|
5
5
|
import { SxProp } from './sx';
|
6
6
|
import { AnchorSide } from './behaviors/anchoredPosition';
|
7
|
-
declare type StyledOverlayProps = {
|
7
|
+
export declare type StyledOverlayProps = {
|
8
8
|
width?: keyof typeof widthMap;
|
9
9
|
height?: keyof typeof heightMap;
|
10
10
|
maxHeight?: keyof Omit<typeof heightMap, 'auto' | 'initial'>;
|
@@ -40,6 +40,7 @@ export declare type OverlayProps = {
|
|
40
40
|
top: number;
|
41
41
|
left: number;
|
42
42
|
portalContainerName?: string;
|
43
|
+
preventFocusOnOpen?: boolean;
|
43
44
|
} & Omit<ComponentProps<typeof StyledOverlay>, 'visibility' | keyof SystemPositionProps>;
|
44
45
|
/**
|
45
46
|
* An `Overlay` is a flexible floating surface, used to display transient content such as menus,
|
package/lib/Overlay.js
CHANGED
@@ -113,6 +113,7 @@ const Overlay = /*#__PURE__*/_react.default.forwardRef(({
|
|
113
113
|
left,
|
114
114
|
anchorSide,
|
115
115
|
portalContainerName,
|
116
|
+
preventFocusOnOpen,
|
116
117
|
...rest
|
117
118
|
}, forwardedRef) => {
|
118
119
|
const overlayRef = (0, _react.useRef)(null);
|
@@ -128,7 +129,8 @@ const Overlay = /*#__PURE__*/_react.default.forwardRef(({
|
|
128
129
|
onEscape,
|
129
130
|
ignoreClickRefs,
|
130
131
|
onClickOutside,
|
131
|
-
initialFocusRef
|
132
|
+
initialFocusRef,
|
133
|
+
preventFocusOnOpen
|
132
134
|
});
|
133
135
|
(0, _react.useEffect)(() => {
|
134
136
|
var _combinedRef$current;
|
@@ -157,9 +159,8 @@ const Overlay = /*#__PURE__*/_react.default.forwardRef(({
|
|
157
159
|
easing: slideAnimationEasing
|
158
160
|
});
|
159
161
|
}, [anchorSide, slideAnimationDistance, slideAnimationEasing, visibility]);
|
160
|
-
|
161
|
-
|
162
|
-
}, /*#__PURE__*/_react.default.createElement(StyledOverlay, _extends({
|
162
|
+
|
163
|
+
const styledOverlay = /*#__PURE__*/_react.default.createElement(StyledOverlay, _extends({
|
163
164
|
height: height,
|
164
165
|
role: role
|
165
166
|
}, rest, {
|
@@ -170,7 +171,11 @@ const Overlay = /*#__PURE__*/_react.default.forwardRef(({
|
|
170
171
|
...rest.style,
|
171
172
|
'--styled-overlay-visibility': visibility
|
172
173
|
}
|
173
|
-
}))
|
174
|
+
}));
|
175
|
+
|
176
|
+
return /*#__PURE__*/_react.default.createElement(_Portal.default, {
|
177
|
+
containerName: portalContainerName
|
178
|
+
}, styledOverlay);
|
174
179
|
});
|
175
180
|
|
176
181
|
Overlay.defaultProps = {
|
@@ -32,9 +32,7 @@ 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
|
-
} & Omit<Pick<
|
36
|
-
ref?: ((instance: HTMLInputElement | null) => void) | React.RefObject<HTMLInputElement> | null | undefined;
|
37
|
-
}, string | number | symbol> & Omit<Pick<{
|
35
|
+
} & Pick<Omit<Pick<{
|
38
36
|
[x: string]: any;
|
39
37
|
[x: number]: any;
|
40
38
|
} & {
|
@@ -42,12 +40,11 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
|
|
42
40
|
} & {
|
43
41
|
as?: string | React.ComponentType<any> | undefined;
|
44
42
|
forwardedAs?: string | React.ComponentType<any> | undefined;
|
45
|
-
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast"
|
43
|
+
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast"> & {
|
46
44
|
className?: string | undefined;
|
47
45
|
icon?: React.ComponentType<{
|
48
46
|
className?: string | undefined;
|
49
47
|
}> | undefined;
|
50
|
-
wrapperRef?: React.RefObject<HTMLSpanElement> | undefined;
|
51
48
|
} & Pick<{
|
52
49
|
color?: string | undefined;
|
53
50
|
maxWidth?: import("styled-system").ResponsiveValue<import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
@@ -318,9 +315,7 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
|
|
318
315
|
contrast?: boolean | undefined;
|
319
316
|
} & {
|
320
317
|
theme?: any;
|
321
|
-
}, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "sx" | "disabled" | "variant" | "contrast"> &
|
322
|
-
as?: "input" | undefined;
|
323
|
-
}, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
318
|
+
}, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "sx" | "disabled" | "variant" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
324
319
|
Footer: import("styled-components").StyledComponent<"footer", any, SystemCommonProps & SxProp, never>;
|
325
320
|
Item: React.ForwardRefExoticComponent<Pick<{
|
326
321
|
as?: React.ElementType<any> | undefined;
|
package/lib/TextInput.d.ts
CHANGED
@@ -1,24 +1,14 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { MaxWidthProps, MinWidthProps, WidthProps } from 'styled-system';
|
3
|
-
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
4
|
-
import { SxProp } from './sx';
|
5
2
|
import { ComponentProps, Merge } from './utils/types';
|
6
3
|
import UnstyledTextInput from './_UnstyledTextInput';
|
7
|
-
|
8
|
-
disabled?: boolean | undefined;
|
9
|
-
hasIcon?: boolean | undefined;
|
10
|
-
block?: boolean | undefined;
|
11
|
-
contrast?: boolean | undefined;
|
12
|
-
variant?: "large" | "small" | undefined;
|
13
|
-
} & 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>;
|
4
|
+
import TextInputWrapper from './_TextInputWrapper';
|
14
5
|
declare type NonPassthroughProps = {
|
15
6
|
className?: string;
|
16
7
|
icon?: React.ComponentType<{
|
17
8
|
className?: string;
|
18
9
|
}>;
|
19
|
-
|
20
|
-
} & Pick<ComponentProps<typeof Wrapper>, 'block' | 'contrast' | 'disabled' | 'sx' | 'theme' | 'width' | 'maxWidth' | 'minWidth' | 'variant'>;
|
10
|
+
} & Pick<ComponentProps<typeof TextInputWrapper>, 'block' | 'contrast' | 'disabled' | 'sx' | 'theme' | 'width' | 'maxWidth' | 'minWidth' | 'variant'>;
|
21
11
|
declare type TextInputInternalProps = Merge<React.ComponentPropsWithoutRef<typeof UnstyledTextInput>, NonPassthroughProps>;
|
22
|
-
declare const TextInput:
|
12
|
+
declare const TextInput: React.ForwardRefExoticComponent<Pick<TextInputInternalProps, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
23
13
|
export declare type TextInputProps = ComponentProps<typeof TextInput>;
|
24
14
|
export default TextInput;
|
package/lib/TextInput.js
CHANGED
@@ -9,52 +9,14 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
9
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
11
11
|
|
12
|
-
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
13
|
-
|
14
|
-
var _styledSystem = require("styled-system");
|
15
|
-
|
16
|
-
var _constants = require("./constants");
|
17
|
-
|
18
|
-
var _sx = _interopRequireDefault(require("./sx"));
|
19
|
-
|
20
12
|
var _UnstyledTextInput = _interopRequireDefault(require("./_UnstyledTextInput"));
|
21
13
|
|
22
|
-
|
23
|
-
|
24
|
-
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; }
|
14
|
+
var _TextInputWrapper = _interopRequireDefault(require("./_TextInputWrapper"));
|
25
15
|
|
26
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
27
17
|
|
28
18
|
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); }
|
29
19
|
|
30
|
-
const sizeVariants = (0, _styledSystem.variant)({
|
31
|
-
variants: {
|
32
|
-
small: {
|
33
|
-
minHeight: '28px',
|
34
|
-
px: 2,
|
35
|
-
py: '3px',
|
36
|
-
fontSize: 0,
|
37
|
-
lineHeight: '20px'
|
38
|
-
},
|
39
|
-
large: {
|
40
|
-
px: 2,
|
41
|
-
py: '10px',
|
42
|
-
fontSize: 3
|
43
|
-
}
|
44
|
-
}
|
45
|
-
});
|
46
|
-
|
47
|
-
const Wrapper = _styledComponents.default.span.withConfig({
|
48
|
-
displayName: "TextInput__Wrapper",
|
49
|
-
componentId: "sc-1apmpmt-0"
|
50
|
-
})(["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 => {
|
51
|
-
if (props.hasIcon) {
|
52
|
-
return (0, _styledComponents.css)(["padding:0;"]);
|
53
|
-
} else {
|
54
|
-
return (0, _styledComponents.css)(["padding:6px 12px;"]);
|
55
|
-
}
|
56
|
-
}, (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);
|
57
|
-
|
58
20
|
// using forwardRef is important so that other components (ex. SelectMenu) can autofocus the input
|
59
21
|
const TextInput = /*#__PURE__*/_react.default.forwardRef(({
|
60
22
|
icon: IconComponent,
|
@@ -68,12 +30,11 @@ const TextInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
68
30
|
minWidth: minWidthProp,
|
69
31
|
maxWidth: maxWidthProp,
|
70
32
|
variant: variantProp,
|
71
|
-
wrapperRef,
|
72
33
|
...inputProps
|
73
34
|
}, ref) => {
|
74
35
|
// this class is necessary to style FilterSearch, plz no touchy!
|
75
36
|
const wrapperClasses = (0, _classnames.default)(className, 'TextInput-wrapper');
|
76
|
-
return /*#__PURE__*/_react.default.createElement(
|
37
|
+
return /*#__PURE__*/_react.default.createElement(_TextInputWrapper.default, {
|
77
38
|
block: block,
|
78
39
|
className: wrapperClasses,
|
79
40
|
contrast: contrast,
|
@@ -84,8 +45,7 @@ const TextInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
84
45
|
width: widthProp,
|
85
46
|
minWidth: minWidthProp,
|
86
47
|
maxWidth: maxWidthProp,
|
87
|
-
variant: variantProp
|
88
|
-
ref: wrapperRef
|
48
|
+
variant: variantProp
|
89
49
|
}, IconComponent && /*#__PURE__*/_react.default.createElement(IconComponent, {
|
90
50
|
className: "TextInput-icon"
|
91
51
|
}), /*#__PURE__*/_react.default.createElement(_UnstyledTextInput.default, _extends({
|
@@ -2,11 +2,11 @@ import React from 'react';
|
|
2
2
|
import { ComponentProps } from './utils/types';
|
3
3
|
import { TokenSizeKeys } from './Token/TokenBase';
|
4
4
|
declare type AnyReactComponent = React.ComponentType<any>;
|
5
|
-
declare
|
5
|
+
declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
6
6
|
/**
|
7
7
|
* The array of tokens to render
|
8
8
|
*/
|
9
|
-
tokens:
|
9
|
+
tokens: any[];
|
10
10
|
/**
|
11
11
|
* The function that gets called when a token is removed
|
12
12
|
*/
|
@@ -14,7 +14,7 @@ declare type TextInputWithTokensInternalProps<TokenComponentType extends AnyReac
|
|
14
14
|
/**
|
15
15
|
* The component used to render each token
|
16
16
|
*/
|
17
|
-
tokenComponent?:
|
17
|
+
tokenComponent?: AnyReactComponent | undefined;
|
18
18
|
/**
|
19
19
|
* The maximum height of the component. If the content in the input exceeds this height,
|
20
20
|
* it will scroll vertically
|
@@ -23,19 +23,16 @@ declare type TextInputWithTokensInternalProps<TokenComponentType extends AnyReac
|
|
23
23
|
/**
|
24
24
|
* Whether tokens should render inline horizontally. By default, tokens wrap to new lines.
|
25
25
|
*/
|
26
|
-
preventTokenWrapping?: boolean;
|
26
|
+
preventTokenWrapping?: boolean | undefined;
|
27
27
|
/**
|
28
28
|
* The size of the tokens
|
29
29
|
*/
|
30
|
-
size?: TokenSizeKeys;
|
30
|
+
size?: TokenSizeKeys | undefined;
|
31
31
|
/**
|
32
32
|
* Whether the remove buttons should be rendered in the tokens
|
33
33
|
*/
|
34
|
-
hideTokenRemoveButtons?: boolean;
|
35
|
-
}
|
36
|
-
declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<TextInputWithTokensInternalProps<AnyReactComponent> & Omit<Pick<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "key" | keyof React.InputHTMLAttributes<HTMLInputElement>> & {
|
37
|
-
ref?: ((instance: HTMLInputElement | null) => void) | React.RefObject<HTMLInputElement> | null | undefined;
|
38
|
-
}, string | number | symbol> & Omit<Pick<{
|
34
|
+
hideTokenRemoveButtons?: boolean | undefined;
|
35
|
+
} & Pick<Omit<Pick<{
|
39
36
|
[x: string]: any;
|
40
37
|
[x: number]: any;
|
41
38
|
} & {
|
@@ -43,12 +40,11 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<TextInpu
|
|
43
40
|
} & {
|
44
41
|
as?: string | React.ComponentType<any> | undefined;
|
45
42
|
forwardedAs?: string | React.ComponentType<any> | undefined;
|
46
|
-
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast"
|
43
|
+
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast"> & {
|
47
44
|
className?: string | undefined;
|
48
45
|
icon?: React.ComponentType<{
|
49
46
|
className?: string | undefined;
|
50
47
|
}> | undefined;
|
51
|
-
wrapperRef?: React.RefObject<HTMLSpanElement> | undefined;
|
52
48
|
} & Pick<{
|
53
49
|
color?: string | undefined;
|
54
50
|
maxWidth?: import("styled-system").ResponsiveValue<import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
@@ -319,8 +315,9 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<TextInpu
|
|
319
315
|
contrast?: boolean | undefined;
|
320
316
|
} & {
|
321
317
|
theme?: any;
|
322
|
-
}, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "sx" | "disabled" | "variant" | "contrast"> & {
|
323
|
-
|
318
|
+
}, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "sx" | "disabled" | "variant" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement> & {
|
319
|
+
selectedTokenIndex: number | undefined;
|
320
|
+
setSelectedTokenIndex: React.Dispatch<React.SetStateAction<number | undefined>>;
|
324
321
|
}, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
325
322
|
export declare type TextInputWithTokensProps = ComponentProps<typeof TextInputWithTokens>;
|
326
323
|
export default TextInputWithTokens;
|