@primer/components 0.0.0-202192231947 → 0.0.0-2021923214017
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 +23 -1
- package/codemods/deprecateUtilityComponents.js +1 -1
- package/dist/browser.esm.js +880 -770
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +883 -773
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Item.js +4 -4
- package/lib/ActionList/List.d.ts +2 -1
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +6 -3
- package/lib/AnchoredOverlay/AnchoredOverlay.js +11 -3
- package/lib/Autocomplete/Autocomplete.d.ts +306 -0
- package/lib/Autocomplete/Autocomplete.js +145 -0
- package/lib/Autocomplete/AutocompleteContext.d.ts +17 -0
- package/lib/Autocomplete/AutocompleteContext.js +11 -0
- package/lib/Autocomplete/AutocompleteInput.d.ts +294 -0
- package/lib/Autocomplete/AutocompleteInput.js +157 -0
- package/lib/Autocomplete/AutocompleteMenu.d.ts +72 -0
- package/lib/Autocomplete/AutocompleteMenu.js +224 -0
- package/lib/Autocomplete/AutocompleteOverlay.d.ts +20 -0
- package/lib/Autocomplete/AutocompleteOverlay.js +80 -0
- package/lib/Autocomplete/index.d.ts +2 -0
- package/lib/Autocomplete/index.js +15 -0
- package/lib/BaseStyles.js +1 -1
- package/lib/BorderBox.js +1 -1
- package/lib/Button/Button.js +1 -1
- package/lib/Button/ButtonInvisible.js +1 -1
- package/lib/Button/ButtonTableList.js +1 -1
- package/lib/Caret.js +2 -2
- package/lib/DatePicker/DatePicker.js +4 -6
- package/lib/DatePicker/DatePickerAnchor.js +7 -2
- package/lib/DatePicker/DatePickerOverlay.d.ts +3 -0
- package/lib/DatePicker/DatePickerOverlay.js +39 -0
- package/lib/DatePicker/Day.js +1 -0
- package/lib/DatePicker/useDatePicker.d.ts +7 -2
- package/lib/DatePicker/useDatePicker.js +138 -50
- package/lib/Dialog.js +1 -1
- package/lib/FilteredActionList/FilteredActionList.js +5 -31
- package/lib/Flash.js +16 -16
- package/lib/Label.js +1 -1
- package/lib/Overlay.d.ts +1 -0
- package/lib/Overlay.js +3 -1
- package/lib/Pagination/Pagination.js +1 -1
- package/lib/ProgressBar.js +1 -1
- package/lib/SelectMenu/SelectMenu.d.ts +12 -10
- package/lib/StateLabel.js +13 -19
- package/lib/TextInput.d.ts +5 -13
- package/lib/TextInput.js +4 -46
- package/lib/TextInputWithTokens.d.ts +325 -0
- package/lib/TextInputWithTokens.js +245 -0
- package/lib/Token/AvatarToken.d.ts +7 -0
- package/lib/Token/AvatarToken.js +64 -0
- package/lib/Token/IssueLabelToken.d.ts +14 -0
- package/lib/Token/IssueLabelToken.js +144 -0
- package/lib/Token/Token.d.ts +15 -0
- package/lib/Token/Token.js +94 -0
- package/lib/Token/TokenBase.d.ts +31 -0
- package/lib/Token/TokenBase.js +108 -0
- package/lib/Token/_RemoveTokenButton.d.ts +12 -0
- package/lib/Token/_RemoveTokenButton.js +77 -0
- package/lib/Token/_TokenTextContainer.d.ts +3 -0
- package/lib/Token/_TokenTextContainer.js +17 -0
- package/lib/Token/index.d.ts +3 -0
- package/lib/Token/index.js +31 -0
- package/lib/_TextInputWrapper.d.ts +10 -0
- package/lib/_TextInputWrapper.js +51 -0
- package/lib/_UnstyledTextInput.d.ts +2 -0
- package/lib/_UnstyledTextInput.js +20 -0
- package/lib/behaviors/scrollIntoViewingArea.d.ts +1 -0
- package/lib/behaviors/scrollIntoViewingArea.js +39 -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 +5 -0
- package/lib/index.js +36 -0
- package/lib/theme-preval.js +372 -3102
- package/lib/utils/testing.d.ts +51 -494
- package/lib/utils/{types.d.ts → types/AriaRole.d.ts} +0 -13
- package/lib/utils/{types.js → types/AriaRole.js} +0 -0
- package/lib/utils/types/ComponentProps.d.ts +9 -0
- package/lib/utils/types/ComponentProps.js +1 -0
- package/lib/utils/types/Flatten.d.ts +4 -0
- package/lib/utils/types/Flatten.js +1 -0
- package/lib/utils/types/MandateProps.d.ts +3 -0
- package/lib/utils/types/MandateProps.js +1 -0
- package/lib/utils/types/Merge.d.ts +19 -0
- package/lib/utils/types/Merge.js +1 -0
- package/lib/utils/types/index.d.ts +5 -0
- package/lib/utils/types/index.js +70 -0
- package/lib-esm/ActionList/Item.js +4 -4
- package/lib-esm/ActionList/List.d.ts +2 -1
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +6 -3
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +11 -3
- package/lib-esm/Autocomplete/Autocomplete.d.ts +306 -0
- package/lib-esm/Autocomplete/Autocomplete.js +123 -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 +294 -0
- package/lib-esm/Autocomplete/AutocompleteInput.js +138 -0
- package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +72 -0
- package/lib-esm/Autocomplete/AutocompleteMenu.js +205 -0
- package/lib-esm/Autocomplete/AutocompleteOverlay.d.ts +20 -0
- package/lib-esm/Autocomplete/AutocompleteOverlay.js +62 -0
- package/lib-esm/Autocomplete/index.d.ts +2 -0
- package/lib-esm/Autocomplete/index.js +1 -0
- package/lib-esm/BaseStyles.js +1 -1
- package/lib-esm/BorderBox.js +1 -1
- package/lib-esm/Button/Button.js +1 -1
- package/lib-esm/Button/ButtonInvisible.js +1 -1
- package/lib-esm/Button/ButtonTableList.js +1 -1
- package/lib-esm/Caret.js +2 -2
- package/lib-esm/DatePicker/DatePicker.js +3 -4
- package/lib-esm/DatePicker/DatePickerAnchor.js +7 -2
- package/lib-esm/DatePicker/DatePickerOverlay.d.ts +3 -0
- package/lib-esm/DatePicker/DatePickerOverlay.js +24 -0
- package/lib-esm/DatePicker/Day.js +1 -0
- package/lib-esm/DatePicker/useDatePicker.d.ts +7 -2
- package/lib-esm/DatePicker/useDatePicker.js +138 -50
- package/lib-esm/Dialog.js +1 -1
- package/lib-esm/FilteredActionList/FilteredActionList.js +3 -31
- package/lib-esm/Flash.js +16 -16
- package/lib-esm/Label.js +1 -1
- package/lib-esm/Overlay.d.ts +1 -0
- package/lib-esm/Overlay.js +3 -1
- package/lib-esm/Pagination/Pagination.js +1 -1
- package/lib-esm/ProgressBar.js +1 -1
- package/lib-esm/SelectMenu/SelectMenu.d.ts +12 -10
- package/lib-esm/StateLabel.js +13 -19
- package/lib-esm/TextInput.d.ts +5 -13
- package/lib-esm/TextInput.js +4 -37
- package/lib-esm/TextInputWithTokens.d.ts +325 -0
- package/lib-esm/TextInputWithTokens.js +220 -0
- package/lib-esm/Token/AvatarToken.d.ts +7 -0
- package/lib-esm/Token/AvatarToken.js +43 -0
- package/lib-esm/Token/IssueLabelToken.d.ts +14 -0
- package/lib-esm/Token/IssueLabelToken.js +124 -0
- package/lib-esm/Token/Token.d.ts +15 -0
- package/lib-esm/Token/Token.js +73 -0
- package/lib-esm/Token/TokenBase.d.ts +31 -0
- package/lib-esm/Token/TokenBase.js +87 -0
- package/lib-esm/Token/_RemoveTokenButton.d.ts +12 -0
- package/lib-esm/Token/_RemoveTokenButton.js +60 -0
- package/lib-esm/Token/_TokenTextContainer.d.ts +3 -0
- package/lib-esm/Token/_TokenTextContainer.js +6 -0
- package/lib-esm/Token/index.d.ts +3 -0
- package/lib-esm/Token/index.js +3 -0
- package/lib-esm/_TextInputWrapper.d.ts +10 -0
- package/lib-esm/_TextInputWrapper.js +31 -0
- package/lib-esm/_UnstyledTextInput.d.ts +2 -0
- package/lib-esm/_UnstyledTextInput.js +7 -0
- package/lib-esm/behaviors/scrollIntoViewingArea.d.ts +1 -0
- package/lib-esm/behaviors/scrollIntoViewingArea.js +30 -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 +5 -0
- package/lib-esm/index.js +3 -0
- package/lib-esm/theme-preval.js +372 -3102
- package/lib-esm/utils/testing.d.ts +51 -494
- package/lib-esm/utils/{types.d.ts → types/AriaRole.d.ts} +0 -13
- package/lib-esm/utils/{types.js → types/AriaRole.js} +0 -0
- package/lib-esm/utils/types/ComponentProps.d.ts +9 -0
- package/lib-esm/utils/types/ComponentProps.js +1 -0
- package/lib-esm/utils/types/Flatten.d.ts +4 -0
- package/lib-esm/utils/types/Flatten.js +1 -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/Merge.d.ts +19 -0
- package/lib-esm/utils/types/Merge.js +1 -0
- package/lib-esm/utils/types/index.d.ts +5 -0
- package/lib-esm/utils/types/index.js +5 -0
- package/package.json +10 -9
@@ -5,35 +5,50 @@ const DatePickerContext = /*#__PURE__*/createContext(null);
|
|
5
5
|
|
6
6
|
const useDatePicker = date => {
|
7
7
|
const value = useContext(DatePickerContext);
|
8
|
+
const [selected, setSelected] = useState(false);
|
8
9
|
|
9
10
|
if (!value) {
|
10
11
|
throw new Error('useDatePicker must be used inside a DatePickerProvider');
|
11
12
|
}
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}
|
27
|
-
|
14
|
+
useEffect(() => {
|
15
|
+
if (date) {
|
16
|
+
if (value.hoverRange) {
|
17
|
+
if (isRangeSelection(value.hoverRange)) {
|
18
|
+
if (isEqual(date, value.hoverRange.from)) {
|
19
|
+
setSelected('start');
|
20
|
+
} else if (value.hoverRange.to && isEqual(date, value.hoverRange.to)) {
|
21
|
+
setSelected('end');
|
22
|
+
} else if (isAfter(date, value.hoverRange.from) && value.hoverRange.to && isBefore(date, value.hoverRange.to)) {
|
23
|
+
setSelected('middle');
|
24
|
+
} else {
|
25
|
+
setSelected(false);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
} else if (value.selection) {
|
29
|
+
if (isMultiSelection(value.selection)) {
|
30
|
+
setSelected(!!value.selection.find(d => isEqual(d, date)));
|
31
|
+
} else if (isRangeSelection(value.selection)) {
|
32
|
+
if (isEqual(date, value.selection.from)) {
|
33
|
+
setSelected('start');
|
34
|
+
} else if (value.selection.to && isEqual(date, value.selection.to)) {
|
35
|
+
setSelected('end');
|
36
|
+
} else if (isAfter(date, value.selection.from) && value.selection.to && isBefore(date, value.selection.to)) {
|
37
|
+
setSelected('middle');
|
38
|
+
} else {
|
39
|
+
setSelected(false);
|
40
|
+
}
|
28
41
|
} else {
|
29
|
-
|
42
|
+
setSelected(isEqual(date, value.selection));
|
30
43
|
}
|
31
|
-
} else {
|
32
|
-
selected = isEqual(date, value.selection);
|
33
44
|
}
|
34
|
-
}
|
35
|
-
|
45
|
+
}
|
46
|
+
}, [date, value.hoverRange, value.selection]);
|
47
|
+
let blocked,
|
48
|
+
disabled = false;
|
36
49
|
|
50
|
+
if (date) {
|
51
|
+
// Determine if date is blocked out
|
37
52
|
if (value.configuration.blockedDates) {
|
38
53
|
blocked = !!value.configuration.blockedDates.find(d => isEqual(d, date));
|
39
54
|
} // Determine if date is disabled
|
@@ -56,7 +71,7 @@ export function isSingleSelection(selection) {
|
|
56
71
|
return selection instanceof Date;
|
57
72
|
}
|
58
73
|
export function isMultiSelection(selection) {
|
59
|
-
return Array.isArray(selection)
|
74
|
+
return Array.isArray(selection);
|
60
75
|
}
|
61
76
|
export function isRangeSelection(selection) {
|
62
77
|
return !!selection.from;
|
@@ -65,24 +80,57 @@ export function isStringRangeSelection(selection) {
|
|
65
80
|
return !!selection.from;
|
66
81
|
}
|
67
82
|
|
68
|
-
function parseSelection(selection) {
|
83
|
+
function parseSelection(selection, variant) {
|
69
84
|
if (!selection) return;
|
70
85
|
|
71
|
-
if (
|
72
|
-
|
86
|
+
if (variant === 'multi') {
|
87
|
+
if (isMultiSelection(selection)) {
|
88
|
+
const parsedSelection = [];
|
73
89
|
|
74
|
-
|
75
|
-
|
76
|
-
|
90
|
+
for (const d of selection) {
|
91
|
+
parsedSelection.push(new Date(new Date(d).toDateString()));
|
92
|
+
}
|
77
93
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
94
|
+
return parsedSelection.sort((a, b) => a.getTime() - b.getTime());
|
95
|
+
} else if (selection instanceof Date) {
|
96
|
+
return [new Date(new Date(selection).toDateString())];
|
97
|
+
} else if (isRangeSelection(selection)) {
|
98
|
+
const parsedSelection = [];
|
99
|
+
parsedSelection.push(new Date(new Date(selection.from).toDateString()));
|
100
|
+
|
101
|
+
if (selection.to) {
|
102
|
+
parsedSelection.push(new Date(new Date(selection.to).toDateString()));
|
103
|
+
}
|
104
|
+
|
105
|
+
return parsedSelection.sort((a, b) => a.getTime() - b.getTime());
|
106
|
+
}
|
107
|
+
} else if (variant === 'range') {
|
108
|
+
if (isRangeSelection(selection)) {
|
109
|
+
return {
|
110
|
+
from: new Date(new Date(selection.from).toDateString()),
|
111
|
+
to: selection.to ? new Date(new Date(selection.to).toDateString()) : null
|
112
|
+
};
|
113
|
+
} else if (isMultiSelection(selection)) {
|
114
|
+
return {
|
115
|
+
from: new Date(new Date(selection[0]).toDateString()),
|
116
|
+
to: selection[1] ? new Date(new Date(selection[1]).toDateString()) : null
|
117
|
+
};
|
118
|
+
} else if (selection instanceof Date) {
|
119
|
+
return {
|
120
|
+
from: new Date(new Date(selection).toDateString()),
|
121
|
+
to: null
|
122
|
+
};
|
123
|
+
}
|
84
124
|
} else {
|
85
|
-
|
125
|
+
if (selection instanceof Date) {
|
126
|
+
return new Date(new Date(selection).toDateString());
|
127
|
+
} else if (isMultiSelection(selection)) {
|
128
|
+
return new Date(new Date(selection[0]).toDateString());
|
129
|
+
} else if (isRangeSelection(selection)) {
|
130
|
+
return new Date(new Date(selection.from).toDateString());
|
131
|
+
} else {
|
132
|
+
return;
|
133
|
+
}
|
86
134
|
}
|
87
135
|
}
|
88
136
|
|
@@ -102,11 +150,14 @@ export const DatePickerProvider = ({
|
|
102
150
|
value
|
103
151
|
}) => {
|
104
152
|
const [configuration, setConfiguration] = useState(deepmerge(defaultConfiguration, externalConfig));
|
105
|
-
const [
|
153
|
+
const [previousSelection, setPreviousSelection] = useState(parseSelection(value, configuration.selection));
|
154
|
+
const [selection, setSelection] = useState(parseSelection(value, configuration.selection));
|
106
155
|
const [hoverRange, setHoverRange] = useState(null);
|
107
156
|
useEffect(() => {
|
108
157
|
setConfiguration(deepmerge(defaultConfiguration, externalConfig));
|
109
|
-
|
158
|
+
setSelection(parseSelection(selection, configuration.selection)); // Don't want this to run every time selection gets updated
|
159
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
160
|
+
}, [configuration.selection, externalConfig]);
|
110
161
|
const getFormattedDate = useMemo(() => {
|
111
162
|
if (!selection) {
|
112
163
|
return configuration.placeholder;
|
@@ -135,6 +186,10 @@ export const DatePickerProvider = ({
|
|
135
186
|
{
|
136
187
|
if (selection instanceof Date) {
|
137
188
|
return format(selection, template);
|
189
|
+
} else if (Array.isArray(selection)) {
|
190
|
+
return format(selection[0], template);
|
191
|
+
} else if (isRangeSelection(selection)) {
|
192
|
+
return format(selection.from, template);
|
138
193
|
} else {
|
139
194
|
return 'Invalid Selection';
|
140
195
|
}
|
@@ -143,7 +198,13 @@ export const DatePickerProvider = ({
|
|
143
198
|
case 'multi':
|
144
199
|
{
|
145
200
|
if (Array.isArray(selection)) {
|
146
|
-
|
201
|
+
if (selection.length > 3) return `${selection.length} Selected`;
|
202
|
+
const formatted = selection.map(d => format(d, template)).join(', ');
|
203
|
+
return formatted;
|
204
|
+
} else if (selection instanceof Date) {
|
205
|
+
return [selection].map(d => format(d, template)).join(', ');
|
206
|
+
} else if (isRangeSelection(selection)) {
|
207
|
+
return [selection.to, selection.from].map(d => d ? format(d, template) : '').join(', ');
|
147
208
|
} else {
|
148
209
|
return 'Invalid Selection';
|
149
210
|
}
|
@@ -153,6 +214,18 @@ export const DatePickerProvider = ({
|
|
153
214
|
{
|
154
215
|
if (isRangeSelection(selection)) {
|
155
216
|
return Object.entries(selection).map(([_, date]) => date ? format(date, template) : '').join(' - ');
|
217
|
+
} else if (selection instanceof Date) {
|
218
|
+
return Object.entries({
|
219
|
+
from: selection,
|
220
|
+
to: null
|
221
|
+
}).map(([_, date]) => date ? format(date, template) : '').join(' - ');
|
222
|
+
} else if (Array.isArray(selection)) {
|
223
|
+
return Object.entries({
|
224
|
+
from: selection[0],
|
225
|
+
to: selection[1]
|
226
|
+
}) // to date can still be null
|
227
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
228
|
+
.map(([_, date]) => date ? format(date, template) : '').join(' - ');
|
156
229
|
} else {
|
157
230
|
return 'Invalid Selection';
|
158
231
|
}
|
@@ -164,30 +237,41 @@ export const DatePickerProvider = ({
|
|
164
237
|
}
|
165
238
|
}
|
166
239
|
}, [configuration.dateFormat, configuration.placeholder, configuration.selection, selection]);
|
240
|
+
const handleSave = useCallback(updatedSelection => {
|
241
|
+
setPreviousSelection(updatedSelection);
|
242
|
+
closePicker === null || closePicker === void 0 ? void 0 : closePicker();
|
243
|
+
}, [closePicker]);
|
167
244
|
const selectionHandler = useCallback(date => {
|
168
245
|
if (configuration.selection === 'multi') {
|
169
|
-
const selections = selection;
|
246
|
+
const selections = [...selection];
|
170
247
|
const existingIndex = selections.findIndex(s => isEqual(s, date));
|
171
248
|
|
172
249
|
if (existingIndex > -1) {
|
173
|
-
|
250
|
+
selections.splice(existingIndex, 1);
|
251
|
+
setSelection(selections.sort((a, b) => a.getTime() - b.getTime()));
|
174
252
|
} else {
|
175
|
-
setSelection([...selections, date]);
|
253
|
+
setSelection([...selections, date].sort((a, b) => a.getTime() - b.getTime()));
|
176
254
|
}
|
177
255
|
} else if (configuration.selection === 'range') {
|
178
256
|
if (selection && isRangeSelection(selection) && !selection.to) {
|
179
|
-
|
257
|
+
const updatedSelection = isBefore(date, selection.from) ? {
|
180
258
|
from: date,
|
181
259
|
to: selection.from
|
182
260
|
} : {
|
183
261
|
from: selection.from,
|
184
262
|
to: date
|
185
|
-
}
|
263
|
+
};
|
264
|
+
setSelection(updatedSelection);
|
265
|
+
setHoverRange(null);
|
186
266
|
|
187
267
|
if (!configuration.confirmation) {
|
188
|
-
|
268
|
+
handleSave(updatedSelection);
|
189
269
|
}
|
190
270
|
} else {
|
271
|
+
setHoverRange({
|
272
|
+
from: date,
|
273
|
+
to: date
|
274
|
+
});
|
191
275
|
setSelection({
|
192
276
|
from: date,
|
193
277
|
to: null
|
@@ -197,14 +281,14 @@ export const DatePickerProvider = ({
|
|
197
281
|
setSelection(date);
|
198
282
|
|
199
283
|
if (!configuration.confirmation) {
|
200
|
-
|
284
|
+
handleSave(date);
|
201
285
|
}
|
202
286
|
}
|
203
|
-
}, [
|
287
|
+
}, [configuration.confirmation, configuration.selection, handleSave, selection]);
|
204
288
|
const focusHnadler = useCallback(date => {
|
205
289
|
if (!selection) return;
|
206
290
|
|
207
|
-
if (configuration.selection === 'range' && isRangeSelection(selection)) {
|
291
|
+
if (configuration.selection === 'range' && isRangeSelection(selection) && hoverRange) {
|
208
292
|
setHoverRange(isBefore(date, selection.from) ? {
|
209
293
|
from: date,
|
210
294
|
to: selection.from
|
@@ -213,26 +297,30 @@ export const DatePickerProvider = ({
|
|
213
297
|
to: date
|
214
298
|
});
|
215
299
|
}
|
216
|
-
}, [configuration.selection, selection]);
|
300
|
+
}, [configuration.selection, hoverRange, selection]);
|
217
301
|
const blurHnadler = useCallback(date => {
|
218
302
|
if (!selection || !hoverRange) return;
|
219
303
|
|
220
|
-
if (configuration.selection === 'range' && isRangeSelection(selection) && (hoverRange.from === date || hoverRange.to === date)) {
|
221
|
-
setHoverRange(null);
|
304
|
+
if (configuration.selection === 'range' && isRangeSelection(selection) && (hoverRange.from === date || hoverRange.to === date)) {// setHoverRange({from: hoverRange.from, to: hoverRange.from})
|
222
305
|
}
|
223
306
|
}, [configuration.selection, hoverRange, selection]);
|
307
|
+
const revertValue = useCallback(() => {
|
308
|
+
setSelection(previousSelection);
|
309
|
+
}, [previousSelection]);
|
224
310
|
const datePickerCtx = useMemo(() => {
|
225
311
|
return {
|
226
312
|
configuration,
|
227
313
|
disabled: false,
|
228
314
|
formattedDate: getFormattedDate,
|
315
|
+
hoverRange,
|
229
316
|
onDayBlur: blurHnadler,
|
230
317
|
onDayFocus: focusHnadler,
|
231
318
|
onSelection: selectionHandler,
|
319
|
+
revertValue,
|
232
320
|
selectionActive: false,
|
233
321
|
selection
|
234
322
|
};
|
235
|
-
}, [blurHnadler, configuration, focusHnadler, getFormattedDate, selection, selectionHandler]);
|
323
|
+
}, [blurHnadler, configuration, focusHnadler, getFormattedDate, hoverRange, revertValue, selection, selectionHandler]);
|
236
324
|
return /*#__PURE__*/React.createElement(DatePickerContext.Provider, {
|
237
325
|
value: datePickerCtx
|
238
326
|
}, children);
|
package/lib-esm/Dialog.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
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
2
|
|
3
3
|
import React, { useCallback, useEffect, useRef } from 'react';
|
4
|
+
import { useSSRSafeId } from '@react-aria/ssr';
|
4
5
|
import TextInput from '../TextInput';
|
5
6
|
import Box from '../Box';
|
6
7
|
import { ActionList } from '../ActionList';
|
@@ -11,36 +12,7 @@ import styled from 'styled-components';
|
|
11
12
|
import { get } from '../constants';
|
12
13
|
import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate';
|
13
14
|
import useScrollFlash from '../hooks/useScrollFlash';
|
14
|
-
import {
|
15
|
-
|
16
|
-
function scrollIntoViewingArea(child, container, margin = 8, behavior = 'smooth') {
|
17
|
-
const {
|
18
|
-
top: childTop,
|
19
|
-
bottom: childBottom
|
20
|
-
} = child.getBoundingClientRect();
|
21
|
-
const {
|
22
|
-
top: containerTop,
|
23
|
-
bottom: containerBottom
|
24
|
-
} = container.getBoundingClientRect();
|
25
|
-
const isChildTopAboveViewingArea = childTop < containerTop + margin;
|
26
|
-
const isChildBottomBelowViewingArea = childBottom > containerBottom - margin;
|
27
|
-
|
28
|
-
if (isChildTopAboveViewingArea) {
|
29
|
-
const scrollHeightToChildTop = childTop - containerTop + container.scrollTop;
|
30
|
-
container.scrollTo({
|
31
|
-
behavior,
|
32
|
-
top: scrollHeightToChildTop - margin
|
33
|
-
});
|
34
|
-
} else if (isChildBottomBelowViewingArea) {
|
35
|
-
const scrollHeightToChildBottom = childBottom - containerBottom + container.scrollTop;
|
36
|
-
container.scrollTo({
|
37
|
-
behavior,
|
38
|
-
top: scrollHeightToChildBottom + margin
|
39
|
-
});
|
40
|
-
} // either completely in view or outside viewing area on both ends, don't scroll
|
41
|
-
|
42
|
-
}
|
43
|
-
|
15
|
+
import { scrollIntoViewingArea } from '../behaviors/scrollIntoViewingArea';
|
44
16
|
const StyledHeader = styled.div.withConfig({
|
45
17
|
displayName: "FilteredActionList__StyledHeader",
|
46
18
|
componentId: "yg3jkv-0"
|
@@ -95,7 +67,7 @@ export function FilteredActionList({
|
|
95
67
|
useEffect(() => {
|
96
68
|
// if items changed, we want to instantly move active descendant into view
|
97
69
|
if (activeDescendantRef.current && scrollContainerRef.current) {
|
98
|
-
scrollIntoViewingArea(activeDescendantRef.current, scrollContainerRef.current, undefined, 'auto');
|
70
|
+
scrollIntoViewingArea(activeDescendantRef.current, scrollContainerRef.current, 'vertical', undefined, undefined, 'auto');
|
99
71
|
}
|
100
72
|
}, [items]);
|
101
73
|
useScrollFlash(scrollContainerRef);
|
package/lib-esm/Flash.js
CHANGED
@@ -5,35 +5,35 @@ import sx from './sx';
|
|
5
5
|
const variants = variant({
|
6
6
|
variants: {
|
7
7
|
default: {
|
8
|
-
color: '
|
9
|
-
backgroundColor: '
|
10
|
-
borderColor: '
|
8
|
+
color: 'fg.default',
|
9
|
+
backgroundColor: 'accent.subtle',
|
10
|
+
borderColor: 'accent.muted',
|
11
11
|
svg: {
|
12
|
-
color: '
|
12
|
+
color: 'accent.fg'
|
13
13
|
}
|
14
14
|
},
|
15
15
|
success: {
|
16
|
-
color: '
|
17
|
-
backgroundColor: '
|
18
|
-
borderColor: '
|
16
|
+
color: 'fg.default',
|
17
|
+
backgroundColor: 'success.subtle',
|
18
|
+
borderColor: 'success.muted',
|
19
19
|
svg: {
|
20
|
-
color: '
|
20
|
+
color: 'success.fg'
|
21
21
|
}
|
22
22
|
},
|
23
23
|
danger: {
|
24
|
-
color: '
|
25
|
-
backgroundColor: '
|
26
|
-
borderColor: '
|
24
|
+
color: 'fg.default',
|
25
|
+
backgroundColor: 'danger.subtle',
|
26
|
+
borderColor: 'danger.muted',
|
27
27
|
svg: {
|
28
|
-
color: '
|
28
|
+
color: 'danger.fg'
|
29
29
|
}
|
30
30
|
},
|
31
31
|
warning: {
|
32
|
-
color: '
|
33
|
-
backgroundColor: '
|
34
|
-
borderColor: '
|
32
|
+
color: 'fg.default',
|
33
|
+
backgroundColor: 'attention.subtle',
|
34
|
+
borderColor: 'attention.muted',
|
35
35
|
svg: {
|
36
|
-
color: '
|
36
|
+
color: 'attention.fg'
|
37
37
|
}
|
38
38
|
}
|
39
39
|
}
|
package/lib-esm/Label.js
CHANGED
@@ -33,7 +33,7 @@ const Label = styled.span.withConfig({
|
|
33
33
|
componentId: "sc-1t3ykp0-0"
|
34
34
|
})(["display:inline-block;font-weight:", ";color:", ";border-radius:", ";&:hover{text-decoration:none;}", " ", " ", " ", " ", ""], get('fontWeights.semibold'), get('colors.fg.onEmphasis'), get('radii.3'), sizeVariant, COMMON, props => props.dropshadow ? 'box-shadow: inset 0 -1px 0 rgba(27, 31, 35, 0.12)' : '', props => props.outline ? outlineStyles : '', sx);
|
35
35
|
Label.defaultProps = {
|
36
|
-
bg: '
|
36
|
+
bg: 'neutral.emphasis',
|
37
37
|
variant: 'medium'
|
38
38
|
};
|
39
39
|
export default Label;
|
package/lib-esm/Overlay.d.ts
CHANGED
@@ -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-esm/Overlay.js
CHANGED
@@ -92,6 +92,7 @@ const Overlay = /*#__PURE__*/React.forwardRef(({
|
|
92
92
|
left,
|
93
93
|
anchorSide,
|
94
94
|
portalContainerName,
|
95
|
+
preventFocusOnOpen,
|
95
96
|
...rest
|
96
97
|
}, forwardedRef) => {
|
97
98
|
const overlayRef = useRef(null);
|
@@ -107,7 +108,8 @@ const Overlay = /*#__PURE__*/React.forwardRef(({
|
|
107
108
|
onEscape,
|
108
109
|
ignoreClickRefs,
|
109
110
|
onClickOutside,
|
110
|
-
initialFocusRef
|
111
|
+
initialFocusRef,
|
112
|
+
preventFocusOnOpen
|
111
113
|
});
|
112
114
|
useEffect(() => {
|
113
115
|
var _combinedRef$current;
|
@@ -9,7 +9,7 @@ import { buildComponentData, buildPaginationModel } from './model';
|
|
9
9
|
const Page = styled.a.withConfig({
|
10
10
|
displayName: "Pagination__Page",
|
11
11
|
componentId: "b80nss-0"
|
12
|
-
})(["display:inline-block;min-width:32px;padding:5px 10px;font-style:normal;line-height:20px;color:", ";text-align:center;white-space:nowrap;vertical-align:middle;cursor:pointer;user-select:none;text-decoration:none;margin-right:", ";&:last-child{margin-right:0;}border:", " solid transparent;border-radius:", ";transition:border-color 0.2s cubic-bezier(0.3,0,0.5,1);&:hover,&:focus{text-decoration:none;border-color:", ";outline:0;transition-duration:0.1s;}&:active{border-color:", ";}&[rel='prev'],&[rel='next']{color:", ";}&[aria-current],&[aria-current]:hover{color:", ";background-color:", ";border-color:transparent;}&[aria-disabled],&[aria-disabled]:hover{color:", ";cursor:default;border-color:transparent;}@supports (clip-path:polygon(50% 0,100% 50%,50% 100%)){&[rel='prev']::before,&[rel='next']::after{display:inline-block;width:16px;height:16px;vertical-align:text-bottom;content:'';background-color:currentColor;}&[rel='prev']::before{margin-right:", ";clip-path:polygon( 9.8px 12.8px,8.7px 12.8px,4.5px 8.5px,4.5px 7.5px,8.7px 3.2px,9.8px 4.3px,6.1px 8px,9.8px 11.7px,9.8px 12.8px );}&[rel='next']::after{margin-left:", ";clip-path:polygon( 6.2px 3.2px,7.3px 3.2px,11.5px 7.5px,11.5px 8.5px,7.3px 12.8px,6.2px 11.7px,9.9px 8px,6.2px 4.3px,6.2px 3.2px );}}", ";"], get('colors.fg.default'), get('space.1'), get('borderWidths.1'), get('radii.2'), get('colors.border.default'), get('colors.border.muted'), get('colors.accent.fg'), get('colors.fg.onEmphasis'), get('colors.accent.emphasis'), get('colors.fg.
|
12
|
+
})(["display:inline-block;min-width:32px;padding:5px 10px;font-style:normal;line-height:20px;color:", ";text-align:center;white-space:nowrap;vertical-align:middle;cursor:pointer;user-select:none;text-decoration:none;margin-right:", ";&:last-child{margin-right:0;}border:", " solid transparent;border-radius:", ";transition:border-color 0.2s cubic-bezier(0.3,0,0.5,1);&:hover,&:focus{text-decoration:none;border-color:", ";outline:0;transition-duration:0.1s;}&:active{border-color:", ";}&[rel='prev'],&[rel='next']{color:", ";}&[aria-current],&[aria-current]:hover{color:", ";background-color:", ";border-color:transparent;}&[aria-disabled],&[aria-disabled]:hover{color:", ";cursor:default;border-color:transparent;}@supports (clip-path:polygon(50% 0,100% 50%,50% 100%)){&[rel='prev']::before,&[rel='next']::after{display:inline-block;width:16px;height:16px;vertical-align:text-bottom;content:'';background-color:currentColor;}&[rel='prev']::before{margin-right:", ";clip-path:polygon( 9.8px 12.8px,8.7px 12.8px,4.5px 8.5px,4.5px 7.5px,8.7px 3.2px,9.8px 4.3px,6.1px 8px,9.8px 11.7px,9.8px 12.8px );}&[rel='next']::after{margin-left:", ";clip-path:polygon( 6.2px 3.2px,7.3px 3.2px,11.5px 7.5px,11.5px 8.5px,7.3px 12.8px,6.2px 11.7px,9.9px 8px,6.2px 4.3px,6.2px 3.2px );}}", ";"], get('colors.fg.default'), get('space.1'), get('borderWidths.1'), get('radii.2'), get('colors.border.default'), get('colors.border.muted'), get('colors.accent.fg'), get('colors.fg.onEmphasis'), get('colors.accent.emphasis'), get('colors.primer.fg.disabled'), get('space.1'), get('space.1'), COMMON);
|
13
13
|
|
14
14
|
function usePaginationPages({
|
15
15
|
theme,
|
package/lib-esm/ProgressBar.js
CHANGED
@@ -32,7 +32,17 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
|
|
32
32
|
Divider: import("styled-components").StyledComponent<"div", any, SystemCommonProps & SxProp, never>;
|
33
33
|
Filter: React.ForwardRefExoticComponent<Pick<{
|
34
34
|
value?: string | undefined;
|
35
|
-
} & Pick<{
|
35
|
+
} & Pick<Omit<Pick<({
|
36
|
+
[x: string]: any;
|
37
|
+
[x: number]: any;
|
38
|
+
} & {
|
39
|
+
theme?: any;
|
40
|
+
} & ({} | {
|
41
|
+
children?: React.ReactNode;
|
42
|
+
})) & {
|
43
|
+
as?: string | React.ComponentType<any> | undefined;
|
44
|
+
forwardedAs?: string | React.ComponentType<any> | undefined;
|
45
|
+
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast"> & {
|
36
46
|
className?: string | undefined;
|
37
47
|
icon?: React.ComponentType<{
|
38
48
|
className?: string | undefined;
|
@@ -307,15 +317,7 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
|
|
307
317
|
contrast?: boolean | undefined;
|
308
318
|
} & {
|
309
319
|
theme?: any;
|
310
|
-
}, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "sx" | "disabled" | "variant" | "contrast"> &
|
311
|
-
[x: string]: any;
|
312
|
-
[x: number]: any;
|
313
|
-
} & {
|
314
|
-
theme?: any;
|
315
|
-
} & {
|
316
|
-
as?: string | React.ComponentType<any> | undefined;
|
317
|
-
forwardedAs?: string | React.ComponentType<any> | undefined;
|
318
|
-
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
320
|
+
}, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "sx" | "disabled" | "variant" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
319
321
|
Footer: import("styled-components").StyledComponent<"footer", any, SystemCommonProps & SxProp, never>;
|
320
322
|
Item: React.ForwardRefExoticComponent<Pick<{
|
321
323
|
as?: React.ElementType<any> | undefined;
|
package/lib-esm/StateLabel.js
CHANGED
@@ -19,34 +19,28 @@ const colorVariants = variant({
|
|
19
19
|
prop: 'status',
|
20
20
|
variants: {
|
21
21
|
issueClosed: {
|
22
|
-
backgroundColor: '
|
23
|
-
color: '
|
24
|
-
borderColor: 'prState.closed.border'
|
22
|
+
backgroundColor: 'danger.emphasis',
|
23
|
+
color: 'fg.onEmphasis'
|
25
24
|
},
|
26
25
|
pullClosed: {
|
27
|
-
backgroundColor: '
|
28
|
-
color: '
|
29
|
-
borderColor: 'prState.closed.border'
|
26
|
+
backgroundColor: 'danger.emphasis',
|
27
|
+
color: 'fg.onEmphasis'
|
30
28
|
},
|
31
29
|
pullMerged: {
|
32
|
-
backgroundColor: '
|
33
|
-
color: '
|
34
|
-
borderColor: 'prState.merged.border'
|
30
|
+
backgroundColor: 'done.emphasis',
|
31
|
+
color: 'fg.onEmphasis'
|
35
32
|
},
|
36
33
|
issueOpened: {
|
37
|
-
backgroundColor: '
|
38
|
-
color: '
|
39
|
-
borderColor: 'prState.open.border'
|
34
|
+
backgroundColor: 'success.emphasis',
|
35
|
+
color: 'fg.onEmphasis'
|
40
36
|
},
|
41
37
|
pullOpened: {
|
42
|
-
backgroundColor: '
|
43
|
-
color: '
|
44
|
-
borderColor: 'prState.open.border'
|
38
|
+
backgroundColor: 'success.emphasis',
|
39
|
+
color: 'fg.onEmphasis'
|
45
40
|
},
|
46
41
|
draft: {
|
47
|
-
backgroundColor: '
|
48
|
-
color: '
|
49
|
-
borderColor: 'prState.draft.border'
|
42
|
+
backgroundColor: 'neutral.emphasis',
|
43
|
+
color: 'fg.onEmphasis'
|
50
44
|
}
|
51
45
|
}
|
52
46
|
});
|
@@ -68,7 +62,7 @@ const sizeVariants = variant({
|
|
68
62
|
const StateLabelBase = styled.span.withConfig({
|
69
63
|
displayName: "StateLabel__StateLabelBase",
|
70
64
|
componentId: "k4pd9e-0"
|
71
|
-
})(["display:inline-flex;align-items:center;font-weight:", ";line-height:16px;color:", ";text-align:center;border-radius:", ";
|
65
|
+
})(["display:inline-flex;align-items:center;font-weight:", ";line-height:16px;color:", ";text-align:center;border-radius:", ";", ";", ";", ";", ";"], get('fontWeights.bold'), get('colors.canvas.default'), get('radii.3'), colorVariants, sizeVariants, COMMON, sx);
|
72
66
|
|
73
67
|
function StateLabel({
|
74
68
|
children,
|
package/lib-esm/TextInput.d.ts
CHANGED
@@ -1,22 +1,14 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import {
|
3
|
-
import
|
4
|
-
import
|
5
|
-
declare const Input: import("styled-components").StyledComponent<"input", any, {}, never>;
|
6
|
-
declare const Wrapper: import("styled-components").StyledComponent<"span", any, {
|
7
|
-
disabled?: boolean | undefined;
|
8
|
-
hasIcon?: boolean | undefined;
|
9
|
-
block?: boolean | undefined;
|
10
|
-
contrast?: boolean | undefined;
|
11
|
-
variant?: "large" | "small" | undefined;
|
12
|
-
} & 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>;
|
2
|
+
import { ComponentProps, Merge } from './utils/types';
|
3
|
+
import UnstyledTextInput from './_UnstyledTextInput';
|
4
|
+
import TextInputWrapper from './_TextInputWrapper';
|
13
5
|
declare type NonPassthroughProps = {
|
14
6
|
className?: string;
|
15
7
|
icon?: React.ComponentType<{
|
16
8
|
className?: string;
|
17
9
|
}>;
|
18
|
-
} & Pick<ComponentProps<typeof
|
19
|
-
declare type TextInputInternalProps =
|
10
|
+
} & Pick<ComponentProps<typeof TextInputWrapper>, 'block' | 'contrast' | 'disabled' | 'sx' | 'theme' | 'width' | 'maxWidth' | 'minWidth' | 'variant'>;
|
11
|
+
declare type TextInputInternalProps = Merge<React.ComponentPropsWithoutRef<typeof UnstyledTextInput>, NonPassthroughProps>;
|
20
12
|
declare const TextInput: React.ForwardRefExoticComponent<Pick<TextInputInternalProps, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
21
13
|
export declare type TextInputProps = ComponentProps<typeof TextInput>;
|
22
14
|
export default TextInput;
|