@primer/components 0.0.0-2021927184113 → 0.0.0-202192719508
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 +2 -10
- package/dist/browser.esm.js +23 -23
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +28 -28
- 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/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 +421 -0
- package/lib/SelectMenu/SelectMenu.d.ts +4 -2
- package/lib/TextInputWithTokens.d.ts +4 -2
- package/lib/TextInputWithTokens.js +12 -25
- 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/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 +391 -0
- package/lib-esm/SelectMenu/SelectMenu.d.ts +4 -2
- package/lib-esm/TextInputWithTokens.d.ts +4 -2
- package/lib-esm/TextInputWithTokens.js +13 -25
- 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
@@ -9,8 +9,7 @@ import Token from './Token/Token';
|
|
9
9
|
import { useProvidedRefOrCreate } from './hooks';
|
10
10
|
import UnstyledTextInput from './_UnstyledTextInput';
|
11
11
|
import TextInputWrapper from './_TextInputWrapper';
|
12
|
-
import Box from './Box';
|
13
|
-
import { isFocusable } from './utils/iterateFocusableElements'; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
12
|
+
import Box from './Box'; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
14
13
|
|
15
14
|
// using forwardRef is important so that other components (ex. Autocomplete) can use the ref
|
16
15
|
function TextInputWithTokensInnerComponent({
|
@@ -77,25 +76,14 @@ function TextInputWithTokensInnerComponent({
|
|
77
76
|
}, [selectedTokenIndex]);
|
78
77
|
|
79
78
|
const handleTokenRemove = tokenId => {
|
80
|
-
onTokenRemove(tokenId);
|
79
|
+
onTokenRemove(tokenId);
|
81
80
|
|
82
|
-
|
83
|
-
var _containerRef$current2
|
81
|
+
if (selectedTokenIndex) {
|
82
|
+
var _containerRef$current2;
|
84
83
|
|
85
|
-
const nextElementToFocus = (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.children[selectedTokenIndex
|
86
|
-
|
87
|
-
|
88
|
-
const firstFocusable = nextElementToFocus && isFocusable(nextElementToFocus) ? nextElementToFocus : Array.from(((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.children) || []).find(el => isFocusable(el));
|
89
|
-
|
90
|
-
if (firstFocusable) {
|
91
|
-
firstFocusable.focus();
|
92
|
-
} else {
|
93
|
-
var _ref$current;
|
94
|
-
|
95
|
-
// if there are no tokens left, focus the input
|
96
|
-
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
|
97
|
-
}
|
98
|
-
}, 0);
|
84
|
+
const nextElementToFocus = (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.children[selectedTokenIndex];
|
85
|
+
nextElementToFocus.focus();
|
86
|
+
}
|
99
87
|
};
|
100
88
|
|
101
89
|
const handleTokenFocus = tokenIndex => () => {
|
@@ -108,9 +96,9 @@ function TextInputWithTokensInnerComponent({
|
|
108
96
|
|
109
97
|
const handleTokenKeyUp = e => {
|
110
98
|
if (e.key === 'Escape') {
|
111
|
-
var _ref$
|
99
|
+
var _ref$current;
|
112
100
|
|
113
|
-
(_ref$
|
101
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
|
114
102
|
}
|
115
103
|
};
|
116
104
|
|
@@ -120,13 +108,13 @@ function TextInputWithTokensInnerComponent({
|
|
120
108
|
};
|
121
109
|
|
122
110
|
const handleInputKeyDown = e => {
|
123
|
-
var _ref$
|
111
|
+
var _ref$current2;
|
124
112
|
|
125
113
|
if (onKeyDown) {
|
126
114
|
onKeyDown(e);
|
127
115
|
}
|
128
116
|
|
129
|
-
if ((_ref$
|
117
|
+
if ((_ref$current2 = ref.current) !== null && _ref$current2 !== void 0 && _ref$current2.value) {
|
130
118
|
return;
|
131
119
|
}
|
132
120
|
|
@@ -147,9 +135,9 @@ function TextInputWithTokensInnerComponent({
|
|
147
135
|
|
148
136
|
|
149
137
|
setTimeout(() => {
|
150
|
-
var _ref$
|
138
|
+
var _ref$current3;
|
151
139
|
|
152
|
-
(_ref$
|
140
|
+
(_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : _ref$current3.select();
|
153
141
|
}, 0);
|
154
142
|
}
|
155
143
|
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { useEffect, useState } from 'react';
|
2
|
+
|
3
|
+
function useDebounce(value, delay) {
|
4
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
5
|
+
useEffect(() => {
|
6
|
+
const handler = setTimeout(() => {
|
7
|
+
setDebouncedValue(value);
|
8
|
+
}, delay);
|
9
|
+
return () => {
|
10
|
+
clearTimeout(handler);
|
11
|
+
};
|
12
|
+
}, [value, delay]);
|
13
|
+
return debouncedValue;
|
14
|
+
}
|
15
|
+
|
16
|
+
export default useDebounce;
|
package/lib-esm/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": {
|
@@ -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;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@primer/components",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-202192719508",
|
4
4
|
"description": "Primer react components",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"module": "lib-esm/index.js",
|
@@ -43,20 +43,16 @@
|
|
43
43
|
"author": "GitHub, Inc.",
|
44
44
|
"license": "MIT",
|
45
45
|
"dependencies": {
|
46
|
-
"@primer/octicons-react": "^
|
47
|
-
"@primer/primitives": "
|
46
|
+
"@primer/octicons-react": "^16.1.0",
|
47
|
+
"@primer/primitives": "6.0.0",
|
48
48
|
"@radix-ui/react-polymorphic": "0.0.14",
|
49
49
|
"@react-aria/ssr": "3.1.0",
|
50
50
|
"@styled-system/css": "5.1.5",
|
51
51
|
"@styled-system/props": "5.1.5",
|
52
52
|
"@styled-system/theme-get": "5.1.2",
|
53
|
-
"@types/history": "4.7.8",
|
54
|
-
"@types/styled-components": "5.1.11",
|
55
|
-
"@types/styled-system": "5.1.12",
|
56
|
-
"@types/styled-system__css": "5.0.16",
|
57
|
-
"@types/styled-system__theme-get": "5.0.1",
|
58
53
|
"classnames": "2.3.1",
|
59
54
|
"color2k": "1.2.4",
|
55
|
+
"date-fns": "2.25.0",
|
60
56
|
"deepmerge": "4.2.2",
|
61
57
|
"focus-visible": "5.2.0",
|
62
58
|
"styled-system": "5.1.5"
|
@@ -76,15 +72,20 @@
|
|
76
72
|
"@rollup/plugin-commonjs": "19.0.2",
|
77
73
|
"@rollup/plugin-node-resolve": "13.0.5",
|
78
74
|
"@size-limit/preset-big-lib": "5.0.2",
|
79
|
-
"@storybook/addon-a11y": "6.3.
|
80
|
-
"@storybook/addon-actions": "^6.
|
81
|
-
"@storybook/addon-essentials": "6.
|
82
|
-
"@storybook/addon-links": "^6.
|
83
|
-
"@storybook/react": "6.3.
|
75
|
+
"@storybook/addon-a11y": "6.3.4",
|
76
|
+
"@storybook/addon-actions": "^6.2.9",
|
77
|
+
"@storybook/addon-essentials": "6.2.9",
|
78
|
+
"@storybook/addon-links": "^6.2.9",
|
79
|
+
"@storybook/react": "6.3.8",
|
84
80
|
"@testing-library/dom": "7.31.2",
|
85
81
|
"@testing-library/react": "11.2.7",
|
86
82
|
"@testing-library/react-hooks": "7.0.2",
|
87
83
|
"@testing-library/user-event": "13.1.9",
|
84
|
+
"@types/history": "4.7.9",
|
85
|
+
"@types/styled-components": "5.1.15",
|
86
|
+
"@types/styled-system": "5.1.13",
|
87
|
+
"@types/styled-system__css": "5.0.16",
|
88
|
+
"@types/styled-system__theme-get": "5.0.1",
|
88
89
|
"@types/chroma-js": "2.1.3",
|
89
90
|
"@types/enzyme": "3.10.9",
|
90
91
|
"@types/jest": "26.0.23",
|