@primer/components 0.0.0-2021927202224 → 0.0.0-2021927203020
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 -23
- package/dist/browser.esm.js +53 -54
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +50 -51
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Item.d.ts +0 -6
- package/lib/ActionList/Item.js +1 -5
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +4 -2
- package/lib/Autocomplete/Autocomplete.d.ts +4 -2
- package/lib/Autocomplete/AutocompleteInput.d.ts +4 -2
- package/lib/Breadcrumbs.d.ts +7 -8
- package/lib/Breadcrumbs.js +12 -7
- package/lib/DatePicker/DatePicker.d.ts +48 -0
- package/lib/DatePicker/DatePicker.js +104 -0
- package/lib/DatePicker/DatePickerAnchor.d.ts +5 -0
- package/lib/DatePicker/DatePickerAnchor.js +182 -0
- package/lib/DatePicker/DatePickerOverlay.d.ts +3 -0
- package/lib/DatePicker/DatePickerOverlay.js +48 -0
- package/lib/DatePicker/DatePickerPanel.d.ts +2 -0
- package/lib/DatePicker/DatePickerPanel.js +126 -0
- package/lib/DatePicker/Day.d.ts +14 -0
- package/lib/DatePicker/Day.js +190 -0
- package/lib/DatePicker/Month.d.ts +9 -0
- package/lib/DatePicker/Month.js +120 -0
- package/lib/DatePicker/index.d.ts +2 -0
- package/lib/DatePicker/index.js +13 -0
- package/lib/DatePicker/useDatePicker.d.ts +88 -0
- package/lib/DatePicker/useDatePicker.js +433 -0
- package/lib/SelectMenu/SelectMenu.d.ts +4 -2
- package/lib/TextInputWithTokens.d.ts +4 -6
- package/lib/TextInputWithTokens.js +29 -102
- package/lib/Token/Token.js +2 -13
- package/lib/Token/TokenBase.js +4 -0
- package/lib/Token/_RemoveTokenButton.js +2 -15
- package/lib/_TextInputWrapper.js +1 -1
- package/lib/hooks/useDebounce.d.ts +2 -0
- package/lib/hooks/useDebounce.js +24 -0
- package/lib/theme-preval.js +2 -2
- package/lib/utils/testing.d.ts +1 -1
- package/lib-esm/ActionList/Item.d.ts +0 -6
- package/lib-esm/ActionList/Item.js +1 -5
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +4 -2
- package/lib-esm/Autocomplete/Autocomplete.d.ts +4 -2
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +4 -2
- package/lib-esm/Breadcrumbs.d.ts +7 -8
- package/lib-esm/Breadcrumbs.js +13 -8
- package/lib-esm/DatePicker/DatePicker.d.ts +48 -0
- package/lib-esm/DatePicker/DatePicker.js +87 -0
- package/lib-esm/DatePicker/DatePickerAnchor.d.ts +5 -0
- package/lib-esm/DatePicker/DatePickerAnchor.js +155 -0
- package/lib-esm/DatePicker/DatePickerOverlay.d.ts +3 -0
- package/lib-esm/DatePicker/DatePickerOverlay.js +29 -0
- package/lib-esm/DatePicker/DatePickerPanel.d.ts +2 -0
- package/lib-esm/DatePicker/DatePickerPanel.js +100 -0
- package/lib-esm/DatePicker/Day.d.ts +14 -0
- package/lib-esm/DatePicker/Day.js +167 -0
- package/lib-esm/DatePicker/Month.d.ts +9 -0
- package/lib-esm/DatePicker/Month.js +96 -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 +88 -0
- package/lib-esm/DatePicker/useDatePicker.js +403 -0
- package/lib-esm/SelectMenu/SelectMenu.d.ts +4 -2
- package/lib-esm/TextInputWithTokens.d.ts +4 -6
- package/lib-esm/TextInputWithTokens.js +30 -101
- package/lib-esm/Token/Token.js +2 -13
- package/lib-esm/Token/TokenBase.js +4 -0
- package/lib-esm/Token/_RemoveTokenButton.js +2 -11
- package/lib-esm/_TextInputWrapper.js +1 -1
- package/lib-esm/hooks/useDebounce.d.ts +2 -0
- package/lib-esm/hooks/useDebounce.js +16 -0
- package/lib-esm/theme-preval.js +2 -2
- package/lib-esm/utils/testing.d.ts +1 -1
- package/package.json +14 -13
@@ -25,10 +25,6 @@ var _TextInputWrapper = _interopRequireDefault(require("./_TextInputWrapper"));
|
|
25
25
|
|
26
26
|
var _Box = _interopRequireDefault(require("./Box"));
|
27
27
|
|
28
|
-
var _Text = _interopRequireDefault(require("./Text"));
|
29
|
-
|
30
|
-
var _iterateFocusableElements = require("./utils/iterateFocusableElements");
|
31
|
-
|
32
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
33
29
|
|
34
30
|
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); }
|
@@ -37,13 +33,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
37
33
|
|
38
34
|
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
35
|
|
40
|
-
|
41
|
-
small: 0,
|
42
|
-
medium: 1,
|
43
|
-
large: 1,
|
44
|
-
extralarge: 2
|
45
|
-
}; // using forwardRef is important so that other components (ex. Autocomplete) can use the ref
|
46
|
-
|
36
|
+
// using forwardRef is important so that other components (ex. Autocomplete) can use the ref
|
47
37
|
function TextInputWithTokensInnerComponent({
|
48
38
|
icon: IconComponent,
|
49
39
|
contrast,
|
@@ -63,11 +53,9 @@ function TextInputWithTokensInnerComponent({
|
|
63
53
|
minWidth: minWidthProp,
|
64
54
|
maxWidth: maxWidthProp,
|
65
55
|
variant: variantProp,
|
66
|
-
visibleTokenCount,
|
67
56
|
...rest
|
68
57
|
}, externalRef) {
|
69
58
|
const {
|
70
|
-
onBlur,
|
71
59
|
onFocus,
|
72
60
|
onKeyDown,
|
73
61
|
...inputPropsRest
|
@@ -76,7 +64,6 @@ function TextInputWithTokensInnerComponent({
|
|
76
64
|
const localInputRef = (0, _react.useRef)(null);
|
77
65
|
const combinedInputRef = (0, _useCombinedRefs.useCombinedRefs)(localInputRef, ref);
|
78
66
|
const [selectedTokenIndex, setSelectedTokenIndex] = (0, _react.useState)();
|
79
|
-
const [tokensAreTruncated, setTokensAreTruncated] = (0, _react.useState)(Boolean(visibleTokenCount));
|
80
67
|
const {
|
81
68
|
containerRef
|
82
69
|
} = (0, _useFocusZone.useFocusZone)({
|
@@ -111,25 +98,14 @@ function TextInputWithTokensInnerComponent({
|
|
111
98
|
}, [selectedTokenIndex]);
|
112
99
|
|
113
100
|
const handleTokenRemove = tokenId => {
|
114
|
-
onTokenRemove(tokenId);
|
115
|
-
|
116
|
-
setTimeout(() => {
|
117
|
-
var _containerRef$current2, _containerRef$current3;
|
118
|
-
|
119
|
-
const nextElementToFocus = (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.children[selectedTokenIndex || 0]; // when removing the first token by keying "Backspace" or "Delete",
|
120
|
-
// `nextFocusableElement` is the div that wraps the input
|
101
|
+
onTokenRemove(tokenId);
|
121
102
|
|
122
|
-
|
103
|
+
if (selectedTokenIndex) {
|
104
|
+
var _containerRef$current2;
|
123
105
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
var _ref$current;
|
128
|
-
|
129
|
-
// if there are no tokens left, focus the input
|
130
|
-
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
|
131
|
-
}
|
132
|
-
}, 0);
|
106
|
+
const nextElementToFocus = (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.children[selectedTokenIndex];
|
107
|
+
nextElementToFocus.focus();
|
108
|
+
}
|
133
109
|
};
|
134
110
|
|
135
111
|
const handleTokenFocus = tokenIndex => () => {
|
@@ -137,55 +113,30 @@ function TextInputWithTokensInnerComponent({
|
|
137
113
|
};
|
138
114
|
|
139
115
|
const handleTokenBlur = () => {
|
140
|
-
setSelectedTokenIndex(undefined);
|
141
|
-
// this prevents the tokens from hiding when the user is moving focus between tokens,
|
142
|
-
// but still hides the tokens when the user blurs the token by tabbing out or clicking somewhere else on the page
|
143
|
-
|
144
|
-
setTimeout(() => {
|
145
|
-
var _containerRef$current4;
|
146
|
-
|
147
|
-
if (!((_containerRef$current4 = containerRef.current) !== null && _containerRef$current4 !== void 0 && _containerRef$current4.contains(document.activeElement)) && visibleTokenCount) {
|
148
|
-
setTokensAreTruncated(true);
|
149
|
-
}
|
150
|
-
}, 0);
|
116
|
+
setSelectedTokenIndex(undefined);
|
151
117
|
};
|
152
118
|
|
153
|
-
const handleTokenKeyUp =
|
154
|
-
if (
|
155
|
-
var _ref$
|
119
|
+
const handleTokenKeyUp = e => {
|
120
|
+
if (e.key === 'Escape') {
|
121
|
+
var _ref$current;
|
156
122
|
|
157
|
-
(_ref$
|
123
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
|
158
124
|
}
|
159
125
|
};
|
160
126
|
|
161
|
-
const handleInputFocus =
|
162
|
-
onFocus && onFocus(
|
127
|
+
const handleInputFocus = e => {
|
128
|
+
onFocus && onFocus(e);
|
163
129
|
setSelectedTokenIndex(undefined);
|
164
|
-
visibleTokenCount && setTokensAreTruncated(false);
|
165
|
-
};
|
166
|
-
|
167
|
-
const handleInputBlur = event => {
|
168
|
-
onBlur && onBlur(event); // HACK: wait a tick and check the focused element before hiding truncated tokens
|
169
|
-
// this prevents the tokens from hiding when the user is moving focus from the input to a token,
|
170
|
-
// but still hides the tokens when the user blurs the input by tabbing out or clicking somewhere else on the page
|
171
|
-
|
172
|
-
setTimeout(() => {
|
173
|
-
var _containerRef$current5;
|
174
|
-
|
175
|
-
if (!((_containerRef$current5 = containerRef.current) !== null && _containerRef$current5 !== void 0 && _containerRef$current5.contains(document.activeElement)) && visibleTokenCount) {
|
176
|
-
setTokensAreTruncated(true);
|
177
|
-
}
|
178
|
-
}, 0);
|
179
130
|
};
|
180
131
|
|
181
132
|
const handleInputKeyDown = e => {
|
182
|
-
var _ref$
|
133
|
+
var _ref$current2;
|
183
134
|
|
184
135
|
if (onKeyDown) {
|
185
136
|
onKeyDown(e);
|
186
137
|
}
|
187
138
|
|
188
|
-
if ((_ref$
|
139
|
+
if ((_ref$current2 = ref.current) !== null && _ref$current2 !== void 0 && _ref$current2.value) {
|
189
140
|
return;
|
190
141
|
}
|
191
142
|
|
@@ -206,24 +157,13 @@ function TextInputWithTokensInnerComponent({
|
|
206
157
|
|
207
158
|
|
208
159
|
setTimeout(() => {
|
209
|
-
var _ref$
|
160
|
+
var _ref$current3;
|
210
161
|
|
211
|
-
(_ref$
|
162
|
+
(_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : _ref$current3.select();
|
212
163
|
}, 0);
|
213
164
|
}
|
214
165
|
};
|
215
166
|
|
216
|
-
const focusInput = () => {
|
217
|
-
var _combinedInputRef$cur;
|
218
|
-
|
219
|
-
(_combinedInputRef$cur = combinedInputRef.current) === null || _combinedInputRef$cur === void 0 ? void 0 : _combinedInputRef$cur.focus();
|
220
|
-
};
|
221
|
-
|
222
|
-
const preventTokenClickPropagation = event => {
|
223
|
-
event.stopPropagation();
|
224
|
-
};
|
225
|
-
|
226
|
-
const visibleTokens = tokensAreTruncated ? tokens.slice(0, visibleTokenCount) : tokens;
|
227
167
|
return /*#__PURE__*/_react.default.createElement(_TextInputWrapper.default, {
|
228
168
|
block: block,
|
229
169
|
className: className,
|
@@ -235,8 +175,15 @@ function TextInputWithTokensInnerComponent({
|
|
235
175
|
minWidth: minWidthProp,
|
236
176
|
maxWidth: maxWidthProp,
|
237
177
|
variant: variantProp,
|
238
|
-
|
239
|
-
sx: {
|
178
|
+
ref: containerRef,
|
179
|
+
sx: {
|
180
|
+
alignItems: 'center',
|
181
|
+
flexWrap: preventTokenWrapping ? 'nowrap' : 'wrap',
|
182
|
+
gap: '0.25rem',
|
183
|
+
'> *': {
|
184
|
+
flexShrink: 0
|
185
|
+
},
|
186
|
+
...(block ? {
|
240
187
|
display: 'flex',
|
241
188
|
width: '100%'
|
242
189
|
} : {}),
|
@@ -249,21 +196,6 @@ function TextInputWithTokensInnerComponent({
|
|
249
196
|
} : {}),
|
250
197
|
...sxProp
|
251
198
|
}
|
252
|
-
}, /*#__PURE__*/_react.default.createElement(_Box.default, {
|
253
|
-
ref: containerRef,
|
254
|
-
display: "flex",
|
255
|
-
sx: {
|
256
|
-
alignItems: 'center',
|
257
|
-
flexWrap: preventTokenWrapping ? 'nowrap' : 'wrap',
|
258
|
-
marginLeft: '-0.25rem',
|
259
|
-
marginBottom: '-0.25rem',
|
260
|
-
flexGrow: 1,
|
261
|
-
'> *': {
|
262
|
-
flexShrink: 0,
|
263
|
-
marginLeft: '0.25rem',
|
264
|
-
marginBottom: '0.25rem'
|
265
|
-
}
|
266
|
-
}
|
267
199
|
}, /*#__PURE__*/_react.default.createElement(_Box.default, {
|
268
200
|
sx: {
|
269
201
|
order: 1,
|
@@ -275,13 +207,12 @@ function TextInputWithTokensInnerComponent({
|
|
275
207
|
ref: combinedInputRef,
|
276
208
|
disabled: disabled,
|
277
209
|
onFocus: handleInputFocus,
|
278
|
-
onBlur: handleInputBlur,
|
279
210
|
onKeyDown: handleInputKeyDown,
|
280
211
|
type: "text",
|
281
212
|
sx: {
|
282
213
|
height: '100%'
|
283
214
|
}
|
284
|
-
}, inputPropsRest))), TokenComponent ?
|
215
|
+
}, inputPropsRest))), tokens.length && TokenComponent ? tokens.map(({
|
285
216
|
id,
|
286
217
|
...tokenRest
|
287
218
|
}, i) => /*#__PURE__*/_react.default.createElement(TokenComponent, _extends({
|
@@ -289,7 +220,6 @@ function TextInputWithTokensInnerComponent({
|
|
289
220
|
onFocus: handleTokenFocus(i),
|
290
221
|
onBlur: handleTokenBlur,
|
291
222
|
onKeyUp: handleTokenKeyUp,
|
292
|
-
onClick: preventTokenClickPropagation,
|
293
223
|
isSelected: selectedTokenIndex === i,
|
294
224
|
onRemove: () => {
|
295
225
|
handleTokenRemove(id);
|
@@ -297,10 +227,7 @@ function TextInputWithTokensInnerComponent({
|
|
297
227
|
hideRemoveButton: hideTokenRemoveButtons,
|
298
228
|
size: size,
|
299
229
|
tabIndex: 0
|
300
|
-
}, tokenRest))) : null
|
301
|
-
color: "fg.muted",
|
302
|
-
fontSize: size && overflowCountFontSizeMap[size]
|
303
|
-
}, "+", tokens.length - visibleTokens.length) : null));
|
230
|
+
}, tokenRest))) : null);
|
304
231
|
}
|
305
232
|
|
306
233
|
TextInputWithTokensInnerComponent.displayName = "TextInputWithTokensInnerComponent";
|
package/lib/Token/Token.js
CHANGED
@@ -39,16 +39,7 @@ const DefaultTokenStyled = (0, _styledComponents.default)(_TokenBase.default).wi
|
|
39
39
|
const LeadingVisualContainer = (0, _styledComponents.default)('span').withConfig({
|
40
40
|
displayName: "Token__LeadingVisualContainer",
|
41
41
|
componentId: "sc-1dg52pw-1"
|
42
|
-
})(["flex-shrink:0;line-height:0;"
|
43
|
-
switch (props.size) {
|
44
|
-
case 'large':
|
45
|
-
case 'extralarge':
|
46
|
-
return (0, _styledComponents.css)(["margin-right:", ";"], (0, _constants.get)('space.2'));
|
47
|
-
|
48
|
-
default:
|
49
|
-
return (0, _styledComponents.css)(["margin-right:", ";"], (0, _constants.get)('space.1'));
|
50
|
-
}
|
51
|
-
});
|
42
|
+
})(["flex-shrink:0;line-height:0;"]);
|
52
43
|
const Token = /*#__PURE__*/(0, _react.forwardRef)((props, forwardedRef) => {
|
53
44
|
const {
|
54
45
|
as,
|
@@ -83,9 +74,7 @@ const Token = /*#__PURE__*/(0, _react.forwardRef)((props, forwardedRef) => {
|
|
83
74
|
isTokenInteractive: (0, _TokenBase.isTokenInteractive)(props)
|
84
75
|
}, !hasMultipleActionTargets ? interactiveTokenProps : {}, rest, {
|
85
76
|
ref: forwardedRef
|
86
|
-
}), LeadingVisual ? /*#__PURE__*/_react.default.createElement(LeadingVisualContainer, {
|
87
|
-
size: size
|
88
|
-
}, /*#__PURE__*/_react.default.createElement(LeadingVisual, null)) : null, /*#__PURE__*/_react.default.createElement(_TokenTextContainer.default, hasMultipleActionTargets ? interactiveTokenProps : {}, text), !hideRemoveButton && onRemove ? /*#__PURE__*/_react.default.createElement(_RemoveTokenButton.default, {
|
77
|
+
}), LeadingVisual ? /*#__PURE__*/_react.default.createElement(LeadingVisualContainer, null, /*#__PURE__*/_react.default.createElement(LeadingVisual, null)) : null, /*#__PURE__*/_react.default.createElement(_TokenTextContainer.default, hasMultipleActionTargets ? interactiveTokenProps : {}, text), !hideRemoveButton && onRemove ? /*#__PURE__*/_react.default.createElement(_RemoveTokenButton.default, {
|
89
78
|
borderOffset: tokenBorderWidthPx,
|
90
79
|
onClick: onRemoveClick,
|
91
80
|
size: size,
|
package/lib/Token/TokenBase.js
CHANGED
@@ -38,6 +38,7 @@ const variants = (0, _styledSystem.variant)({
|
|
38
38
|
variants: {
|
39
39
|
small: {
|
40
40
|
fontSize: 0,
|
41
|
+
gap: 1,
|
41
42
|
height: tokenSizes.small,
|
42
43
|
// without setting lineHeight to match height, the "x" appears vertically mis-aligned
|
43
44
|
lineHeight: tokenSizes.small,
|
@@ -50,6 +51,7 @@ const variants = (0, _styledSystem.variant)({
|
|
50
51
|
},
|
51
52
|
medium: {
|
52
53
|
fontSize: 0,
|
54
|
+
gap: 1,
|
53
55
|
height: tokenSizes.medium,
|
54
56
|
lineHeight: tokenSizes.medium,
|
55
57
|
paddingLeft: 2,
|
@@ -59,6 +61,7 @@ const variants = (0, _styledSystem.variant)({
|
|
59
61
|
},
|
60
62
|
large: {
|
61
63
|
fontSize: 0,
|
64
|
+
gap: 2,
|
62
65
|
height: tokenSizes.large,
|
63
66
|
lineHeight: tokenSizes.large,
|
64
67
|
paddingLeft: 2,
|
@@ -68,6 +71,7 @@ const variants = (0, _styledSystem.variant)({
|
|
68
71
|
},
|
69
72
|
extralarge: {
|
70
73
|
fontSize: 1,
|
74
|
+
gap: 2,
|
71
75
|
height: tokenSizes.extralarge,
|
72
76
|
lineHeight: tokenSizes.extralarge,
|
73
77
|
paddingLeft: 3,
|
@@ -9,7 +9,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
10
10
|
var _octiconsReact = require("@primer/octicons-react");
|
11
11
|
|
12
|
-
var _styledComponents =
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
13
13
|
|
14
14
|
var _styledSystem = require("styled-system");
|
15
15
|
|
@@ -19,10 +19,6 @@ var _sx = _interopRequireDefault(require("../sx"));
|
|
19
19
|
|
20
20
|
var _TokenBase = require("./TokenBase");
|
21
21
|
|
22
|
-
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); }
|
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; }
|
25
|
-
|
26
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
27
23
|
|
28
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); }
|
@@ -54,16 +50,7 @@ const getTokenButtonIconSize = size => parseInt(_TokenBase.tokenSizes[size || _T
|
|
54
50
|
const StyledTokenButton = _styledComponents.default.span.withConfig({
|
55
51
|
displayName: "_RemoveTokenButton__StyledTokenButton",
|
56
52
|
componentId: "sc-14lvcw1-0"
|
57
|
-
})(["background-color:transparent;font-family:inherit;color:currentColor;cursor:pointer;display:inline-flex;justify-content:center;align-items:center;user-select:none;appearance:none;text-decoration:none;padding:0;transform:", ";align-self:baseline;border:0;border-radius:999px
|
58
|
-
switch (props.size) {
|
59
|
-
case 'large':
|
60
|
-
case 'extralarge':
|
61
|
-
return (0, _styledComponents.css)(["margin-left:", ";"], (0, _constants.get)('space.2'));
|
62
|
-
|
63
|
-
default:
|
64
|
-
return (0, _styledComponents.css)(["margin-left:", ";"], (0, _constants.get)('space.1'));
|
65
|
-
}
|
66
|
-
}, (0, _constants.get)('colors.neutral.muted'), (0, _constants.get)('colors.neutral.subtle'), variants, _sx.default);
|
53
|
+
})(["background-color:transparent;font-family:inherit;color:currentColor;cursor:pointer;display:inline-flex;justify-content:center;align-items:center;user-select:none;appearance:none;text-decoration:none;padding:0;transform:", ";align-self:baseline;border:0;border-radius:999px;&:hover,&:focus{background-color:", ";}&:active{background-color:", ";}", " ", ""], props => `translate(${props.borderOffset}px, -${props.borderOffset}px)`, (0, _constants.get)('colors.neutral.muted'), (0, _constants.get)('colors.neutral.subtle'), variants, _sx.default);
|
67
54
|
|
68
55
|
const RemoveTokenButton = ({
|
69
56
|
'aria-label': ariaLabel,
|
package/lib/_TextInputWrapper.js
CHANGED
@@ -39,7 +39,7 @@ const sizeVariants = (0, _styledSystem.variant)({
|
|
39
39
|
const TextInputWrapper = _styledComponents.default.span.withConfig({
|
40
40
|
displayName: "_TextInputWrapper__TextInputWrapper",
|
41
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:", ";
|
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
43
|
if (props.hasIcon) {
|
44
44
|
return (0, _styledComponents.css)(["padding:0;"]);
|
45
45
|
} else {
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _react = require("react");
|
9
|
+
|
10
|
+
function useDebounce(value, delay) {
|
11
|
+
const [debouncedValue, setDebouncedValue] = (0, _react.useState)(value);
|
12
|
+
(0, _react.useEffect)(() => {
|
13
|
+
const handler = setTimeout(() => {
|
14
|
+
setDebouncedValue(value);
|
15
|
+
}, delay);
|
16
|
+
return () => {
|
17
|
+
clearTimeout(handler);
|
18
|
+
};
|
19
|
+
}, [value, delay]);
|
20
|
+
return debouncedValue;
|
21
|
+
}
|
22
|
+
|
23
|
+
var _default = useDebounce;
|
24
|
+
exports.default = _default;
|
package/lib/theme-preval.js
CHANGED
@@ -515,7 +515,7 @@ module.exports = {
|
|
515
515
|
}
|
516
516
|
}
|
517
517
|
},
|
518
|
-
"
|
518
|
+
"light_colorblind": {
|
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_colorblind": {
|
2460
2460
|
"colors": {
|
2461
2461
|
"canvasDefaultTransparent": "rgba(13,17,23,0)",
|
2462
2462
|
"marketingIcon": {
|
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_colorblind" | "dark" | "dark_dimmed" | "dark_high_contrast" | "dark_colorblind", Record<"colors" | "shadows", Partial<{
|
57
57
|
canvasDefaultTransparent: string;
|
58
58
|
marketingIcon: {
|
59
59
|
primary: string;
|
@@ -28,19 +28,13 @@ export interface ItemProps extends SxProp {
|
|
28
28
|
*/
|
29
29
|
leadingVisual?: React.FunctionComponent<IconProps>;
|
30
30
|
/**
|
31
|
-
* @deprecated Use `trailingVisual` instead
|
32
31
|
* Icon (or similar) positioned after `Item` text.
|
33
32
|
*/
|
34
33
|
trailingIcon?: React.FunctionComponent<IconProps>;
|
35
34
|
/**
|
36
|
-
* @deprecated Use `trailingVisual` instead
|
37
35
|
* Text positioned after `Item` text and optional trailing icon.
|
38
36
|
*/
|
39
37
|
trailingText?: string;
|
40
|
-
/**
|
41
|
-
* Icon or text positioned after `Item` text.
|
42
|
-
*/
|
43
|
-
trailingVisual?: React.ReactNode;
|
44
38
|
/**
|
45
39
|
* Style variations associated with various `Item` types.
|
46
40
|
*
|
@@ -154,7 +154,6 @@ export const Item = /*#__PURE__*/React.forwardRef((itemProps, ref) => {
|
|
154
154
|
selectionVariant,
|
155
155
|
leadingVisual: LeadingVisual,
|
156
156
|
trailingIcon: TrailingIcon,
|
157
|
-
trailingVisual: TrailingVisual,
|
158
157
|
trailingText,
|
159
158
|
variant = 'default',
|
160
159
|
showDivider,
|
@@ -246,10 +245,7 @@ export const Item = /*#__PURE__*/React.forwardRef((itemProps, ref) => {
|
|
246
245
|
title: description,
|
247
246
|
inline: true,
|
248
247
|
maxWidth: "100%"
|
249
|
-
}, description)) : null),
|
250
|
-
variant: variant,
|
251
|
-
disabled: disabled
|
252
|
-
}, typeof TrailingVisual === 'function' ? /*#__PURE__*/React.createElement(TrailingVisual, null) : TrailingVisual) : TrailingIcon || trailingText ? /*#__PURE__*/React.createElement(TrailingContent, {
|
248
|
+
}, description)) : null), TrailingIcon || trailingText ? /*#__PURE__*/React.createElement(TrailingContent, {
|
253
249
|
variant: variant,
|
254
250
|
disabled: disabled
|
255
251
|
}, trailingText, TrailingIcon && /*#__PURE__*/React.createElement(TrailingIcon, null)) : null));
|
@@ -26,6 +26,8 @@ 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';
|
29
31
|
export declare type AnchoredOverlayWrapperAnchorProps = Partial<AnchoredOverlayPropsWithAnchor> | AnchoredOverlayPropsWithoutAnchor;
|
30
32
|
interface AnchoredOverlayBaseProps extends Pick<OverlayProps, 'height' | 'width'> {
|
31
33
|
/**
|
@@ -35,11 +37,11 @@ interface AnchoredOverlayBaseProps extends Pick<OverlayProps, 'height' | 'width'
|
|
35
37
|
/**
|
36
38
|
* A callback which is called whenever the overlay is currently closed and an "open gesture" is detected.
|
37
39
|
*/
|
38
|
-
onOpen?: (gesture:
|
40
|
+
onOpen?: (gesture: OverlayOpenGesture) => unknown;
|
39
41
|
/**
|
40
42
|
* A callback which is called whenever the overlay is currently open and a "close gesture" is detected.
|
41
43
|
*/
|
42
|
-
onClose?: (gesture:
|
44
|
+
onClose?: (gesture: OverlayCloseGesture) => unknown;
|
43
45
|
/**
|
44
46
|
* Props to be spread on the internal `Overlay` component.
|
45
47
|
*/
|
@@ -12,12 +12,14 @@ 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
|
-
} & {
|
20
|
+
} & ({} | {
|
21
|
+
children?: React.ReactNode;
|
22
|
+
})) & {
|
21
23
|
as?: string | React.ComponentType<any> | undefined;
|
22
24
|
forwardedAs?: string | React.ComponentType<any> | undefined;
|
23
25
|
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast"> & {
|
@@ -4,12 +4,14 @@ 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
|
-
} & {
|
12
|
+
} & ({} | {
|
13
|
+
children?: React.ReactNode;
|
14
|
+
})) & {
|
13
15
|
as?: string | React.ComponentType<any> | undefined;
|
14
16
|
forwardedAs?: string | React.ComponentType<any> | undefined;
|
15
17
|
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast"> & {
|
package/lib-esm/Breadcrumbs.d.ts
CHANGED
@@ -1,25 +1,24 @@
|
|
1
1
|
import * as History from 'history';
|
2
2
|
import React from 'react';
|
3
|
+
import { SystemCommonProps, SystemFlexProps } from './constants';
|
3
4
|
import { SxProp } from './sx';
|
4
5
|
import { ComponentProps } from './utils/types';
|
5
|
-
declare const BreadcrumbsBase: import("styled-components").StyledComponent<"nav", any, SxProp, never>;
|
6
|
-
export declare type BreadcrumbsProps =
|
7
|
-
|
8
|
-
} & SxProp>;
|
9
|
-
declare function Breadcrumbs({ className, children, sx: sxProp }: React.PropsWithChildren<BreadcrumbsProps>): JSX.Element;
|
6
|
+
declare const BreadcrumbsBase: import("styled-components").StyledComponent<"nav", any, SystemFlexProps & SystemCommonProps & SxProp, never>;
|
7
|
+
export declare type BreadcrumbsProps = ComponentProps<typeof BreadcrumbsBase>;
|
8
|
+
declare function Breadcrumbs({ className, children, theme, ...rest }: React.PropsWithChildren<BreadcrumbsProps>): JSX.Element;
|
10
9
|
declare namespace Breadcrumbs {
|
11
10
|
var displayName: string;
|
12
11
|
}
|
13
12
|
declare const BreadcrumbsItem: import("styled-components").StyledComponent<"a", any, {
|
14
13
|
to?: History.LocationDescriptor<unknown> | undefined;
|
15
14
|
selected?: boolean | undefined;
|
16
|
-
} & SxProp, never>;
|
15
|
+
} & SystemCommonProps & SxProp, never>;
|
17
16
|
export declare type BreadcrumbsItemProps = ComponentProps<typeof BreadcrumbsItem>;
|
18
17
|
declare const _default: typeof Breadcrumbs & {
|
19
18
|
Item: import("styled-components").StyledComponent<"a", any, {
|
20
19
|
to?: History.LocationDescriptor<unknown> | undefined;
|
21
20
|
selected?: boolean | undefined;
|
22
|
-
} & SxProp, never>;
|
21
|
+
} & SystemCommonProps & SxProp, never>;
|
23
22
|
};
|
24
23
|
export default _default;
|
25
24
|
/**
|
@@ -29,7 +28,7 @@ export declare const Breadcrumb: typeof Breadcrumbs & {
|
|
29
28
|
Item: import("styled-components").StyledComponent<"a", any, {
|
30
29
|
to?: History.LocationDescriptor<unknown> | undefined;
|
31
30
|
selected?: boolean | undefined;
|
32
|
-
} & SxProp, never>;
|
31
|
+
} & SystemCommonProps & SxProp, never>;
|
33
32
|
};
|
34
33
|
/**
|
35
34
|
* @deprecated Use the `BreadcrumbsProps` type instead
|
package/lib-esm/Breadcrumbs.js
CHANGED
@@ -1,9 +1,11 @@
|
|
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
|
+
|
1
3
|
import classnames from 'classnames'; // eslint-disable-next-line import/no-namespace
|
2
4
|
|
3
5
|
import React from 'react';
|
4
6
|
import styled from 'styled-components';
|
5
7
|
import Box from './Box';
|
6
|
-
import { get } from './constants';
|
8
|
+
import { COMMON, FLEX, get } from './constants';
|
7
9
|
import sx from './sx';
|
8
10
|
const SELECTED_CLASS = 'selected';
|
9
11
|
const Wrapper = styled.li.withConfig({
|
@@ -13,19 +15,22 @@ const Wrapper = styled.li.withConfig({
|
|
13
15
|
const BreadcrumbsBase = styled.nav.withConfig({
|
14
16
|
displayName: "Breadcrumbs__BreadcrumbsBase",
|
15
17
|
componentId: "hwwoo0-1"
|
16
|
-
})(["display:flex;justify-content:space-between;", ";"], sx);
|
18
|
+
})(["display:flex;justify-content:space-between;", ";", ";", ";"], COMMON, FLEX, sx);
|
17
19
|
|
18
20
|
function Breadcrumbs({
|
19
21
|
className,
|
20
22
|
children,
|
21
|
-
|
23
|
+
theme,
|
24
|
+
...rest
|
22
25
|
}) {
|
23
|
-
const wrappedChildren = React.Children.map(children, child => /*#__PURE__*/React.createElement(Wrapper,
|
24
|
-
|
26
|
+
const wrappedChildren = React.Children.map(children, child => /*#__PURE__*/React.createElement(Wrapper, {
|
27
|
+
theme: theme
|
28
|
+
}, child));
|
29
|
+
return /*#__PURE__*/React.createElement(BreadcrumbsBase, _extends({
|
25
30
|
className: className,
|
26
31
|
"aria-label": "Breadcrumbs",
|
27
|
-
|
28
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
32
|
+
theme: theme
|
33
|
+
}, rest), /*#__PURE__*/React.createElement(Box, {
|
29
34
|
as: "ol",
|
30
35
|
my: 0,
|
31
36
|
pl: 0
|
@@ -40,7 +45,7 @@ const BreadcrumbsItem = styled.a.attrs(props => ({
|
|
40
45
|
})).withConfig({
|
41
46
|
displayName: "Breadcrumbs__BreadcrumbsItem",
|
42
47
|
componentId: "hwwoo0-2"
|
43
|
-
})(["color:", ";display:inline-block;font-size:", ";text-decoration:none;&:hover{text-decoration:underline;}&.selected{color:", ";pointer-events:none;}", ";"], get('colors.accent.fg'), get('fontSizes.1'), get('colors.fg.default'), sx);
|
48
|
+
})(["color:", ";display:inline-block;font-size:", ";text-decoration:none;&:hover{text-decoration:underline;}&.selected{color:", ";pointer-events:none;}", " ", ";"], get('colors.accent.fg'), get('fontSizes.1'), get('colors.fg.default'), COMMON, sx);
|
44
49
|
Breadcrumbs.displayName = 'Breadcrumbs';
|
45
50
|
BreadcrumbsItem.displayName = 'Breadcrumbs.Item';
|
46
51
|
export default Object.assign(Breadcrumbs, {
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { OverlayProps } from '../Overlay';
|
3
|
+
import { FocusTrapHookSettings } from '../hooks/useFocusTrap';
|
4
|
+
import { FocusZoneHookSettings } from '../hooks/useFocusZone';
|
5
|
+
import { DatePickerConfiguration, Selection } from './useDatePicker';
|
6
|
+
declare type OpenGesture = 'anchor-click' | 'anchor-key-press';
|
7
|
+
declare type CloseGesture = 'anchor-click' | 'click-outside' | 'escape';
|
8
|
+
export interface DatePickerProps extends DatePickerConfiguration {
|
9
|
+
/**
|
10
|
+
* An override to the internal ref that will be spread on to the renderAnchor
|
11
|
+
*/
|
12
|
+
anchorRef?: React.RefObject<HTMLElement>;
|
13
|
+
/**
|
14
|
+
* Settings to apply to the Focus Zone on the internal `Overlay` component.
|
15
|
+
*/
|
16
|
+
focusTrapSettings?: Partial<FocusTrapHookSettings>;
|
17
|
+
/**
|
18
|
+
* Settings to apply to the Focus Zone on the internal `Overlay` component.
|
19
|
+
*/
|
20
|
+
focusZoneSettings?: Partial<FocusZoneHookSettings>;
|
21
|
+
initialValue?: 'today' | Date | string | null;
|
22
|
+
iconOnly?: boolean;
|
23
|
+
placeholder?: string;
|
24
|
+
/**
|
25
|
+
* Determines whether the overlay portion of the component should be shown or not
|
26
|
+
*/
|
27
|
+
open?: boolean;
|
28
|
+
/**
|
29
|
+
* A callback which is called whenever the overlay is currently closed and an "open gesture" is detected.
|
30
|
+
*/
|
31
|
+
onOpen?: (gesture: OpenGesture) => unknown;
|
32
|
+
/**
|
33
|
+
* A callback which is called whenever the overlay is currently open and a "close gesture" is detected.
|
34
|
+
*/
|
35
|
+
onClose?: (gesture: CloseGesture) => unknown;
|
36
|
+
/**
|
37
|
+
* Props to be spread on the internal `Overlay` component.
|
38
|
+
*/
|
39
|
+
overlayProps?: Partial<OverlayProps>;
|
40
|
+
/**
|
41
|
+
* A custom function component used to render the anchor element.
|
42
|
+
* Will receive the selected text as `children` prop when an item is activated.
|
43
|
+
*/
|
44
|
+
renderAnchor: <T extends React.HTMLAttributes<HTMLElement>>(props: T) => JSX.Element;
|
45
|
+
value?: Selection;
|
46
|
+
}
|
47
|
+
export declare const DatePicker: React.FC<DatePickerProps>;
|
48
|
+
export {};
|