@primer/components 0.0.0-202192515932 → 0.0.0-202192522854

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.
Files changed (104) hide show
  1. package/CHANGELOG.md +8 -4
  2. package/dist/browser.esm.js +616 -616
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +177 -177
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +4 -2
  7. package/lib/Autocomplete/Autocomplete.d.ts +4 -2
  8. package/lib/Autocomplete/AutocompleteInput.d.ts +4 -2
  9. package/lib/DatePicker/DatePicker.d.ts +48 -0
  10. package/lib/DatePicker/DatePicker.js +92 -0
  11. package/lib/DatePicker/DatePickerAnchor.d.ts +5 -0
  12. package/lib/DatePicker/DatePickerAnchor.js +137 -0
  13. package/lib/DatePicker/DatePickerOverlay.d.ts +3 -0
  14. package/lib/DatePicker/DatePickerOverlay.js +39 -0
  15. package/lib/DatePicker/DatePickerPanel.d.ts +2 -0
  16. package/lib/DatePicker/DatePickerPanel.js +126 -0
  17. package/lib/DatePicker/Day.d.ts +14 -0
  18. package/lib/DatePicker/Day.js +174 -0
  19. package/lib/DatePicker/Month.d.ts +9 -0
  20. package/lib/DatePicker/Month.js +107 -0
  21. package/lib/DatePicker/index.d.ts +2 -0
  22. package/lib/DatePicker/index.js +13 -0
  23. package/lib/DatePicker/useDatePicker.d.ts +83 -0
  24. package/lib/DatePicker/useDatePicker.js +375 -0
  25. package/lib/SelectMenu/SelectMenu.d.ts +4 -2
  26. package/lib/TextInputWithTokens.d.ts +4 -2
  27. package/lib/index.d.ts +0 -1
  28. package/lib/index.js +0 -8
  29. package/lib/theme-preval.js +2 -2
  30. package/lib/utils/testing.d.ts +1 -1
  31. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +4 -2
  32. package/lib-esm/Autocomplete/Autocomplete.d.ts +4 -2
  33. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +4 -2
  34. package/lib-esm/DatePicker/DatePicker.d.ts +48 -0
  35. package/lib-esm/DatePicker/DatePicker.js +75 -0
  36. package/lib-esm/DatePicker/DatePickerAnchor.d.ts +5 -0
  37. package/lib-esm/DatePicker/DatePickerAnchor.js +111 -0
  38. package/lib-esm/DatePicker/DatePickerOverlay.d.ts +3 -0
  39. package/lib-esm/DatePicker/DatePickerOverlay.js +24 -0
  40. package/lib-esm/DatePicker/DatePickerPanel.d.ts +2 -0
  41. package/lib-esm/DatePicker/DatePickerPanel.js +100 -0
  42. package/lib-esm/DatePicker/Day.d.ts +14 -0
  43. package/lib-esm/DatePicker/Day.js +151 -0
  44. package/lib-esm/DatePicker/Month.d.ts +9 -0
  45. package/lib-esm/DatePicker/Month.js +83 -0
  46. package/lib-esm/DatePicker/index.d.ts +2 -0
  47. package/lib-esm/DatePicker/index.js +1 -0
  48. package/lib-esm/DatePicker/useDatePicker.d.ts +83 -0
  49. package/lib-esm/DatePicker/useDatePicker.js +347 -0
  50. package/lib-esm/SelectMenu/SelectMenu.d.ts +4 -2
  51. package/lib-esm/TextInputWithTokens.d.ts +4 -2
  52. package/lib-esm/index.d.ts +0 -1
  53. package/lib-esm/index.js +0 -1
  54. package/lib-esm/theme-preval.js +2 -2
  55. package/lib-esm/utils/testing.d.ts +1 -1
  56. package/package.json +9 -8
  57. package/lib/ActionList2/Description.d.ts +0 -6
  58. package/lib/ActionList2/Description.js +0 -53
  59. package/lib/ActionList2/Divider.d.ts +0 -8
  60. package/lib/ActionList2/Divider.js +0 -42
  61. package/lib/ActionList2/Group.d.ts +0 -8
  62. package/lib/ActionList2/Group.js +0 -39
  63. package/lib/ActionList2/Header.d.ts +0 -26
  64. package/lib/ActionList2/Header.js +0 -55
  65. package/lib/ActionList2/Item.d.ts +0 -48
  66. package/lib/ActionList2/Item.js +0 -189
  67. package/lib/ActionList2/List.d.ts +0 -18
  68. package/lib/ActionList2/List.js +0 -52
  69. package/lib/ActionList2/Selection.d.ts +0 -5
  70. package/lib/ActionList2/Selection.js +0 -67
  71. package/lib/ActionList2/Visuals.d.ts +0 -11
  72. package/lib/ActionList2/Visuals.js +0 -91
  73. package/lib/ActionList2/hacks.d.ts +0 -30
  74. package/lib/ActionList2/hacks.js +0 -38
  75. package/lib/ActionList2/index.d.ts +0 -26
  76. package/lib/ActionList2/index.js +0 -36
  77. package/lib/utils/create-slots.d.ts +0 -17
  78. package/lib/utils/create-slots.js +0 -105
  79. package/lib/utils/use-force-update.d.ts +0 -1
  80. package/lib/utils/use-force-update.js +0 -19
  81. package/lib-esm/ActionList2/Description.d.ts +0 -6
  82. package/lib-esm/ActionList2/Description.js +0 -38
  83. package/lib-esm/ActionList2/Divider.d.ts +0 -8
  84. package/lib-esm/ActionList2/Divider.js +0 -30
  85. package/lib-esm/ActionList2/Group.d.ts +0 -8
  86. package/lib-esm/ActionList2/Group.js +0 -29
  87. package/lib-esm/ActionList2/Header.d.ts +0 -26
  88. package/lib-esm/ActionList2/Header.js +0 -45
  89. package/lib-esm/ActionList2/Item.d.ts +0 -48
  90. package/lib-esm/ActionList2/Item.js +0 -182
  91. package/lib-esm/ActionList2/List.d.ts +0 -18
  92. package/lib-esm/ActionList2/List.js +0 -42
  93. package/lib-esm/ActionList2/Selection.d.ts +0 -5
  94. package/lib-esm/ActionList2/Selection.js +0 -50
  95. package/lib-esm/ActionList2/Visuals.d.ts +0 -11
  96. package/lib-esm/ActionList2/Visuals.js +0 -70
  97. package/lib-esm/ActionList2/hacks.d.ts +0 -30
  98. package/lib-esm/ActionList2/hacks.js +0 -30
  99. package/lib-esm/ActionList2/index.d.ts +0 -26
  100. package/lib-esm/ActionList2/index.js +0 -23
  101. package/lib-esm/utils/create-slots.d.ts +0 -17
  102. package/lib-esm/utils/create-slots.js +0 -84
  103. package/lib-esm/utils/use-force-update.d.ts +0 -1
  104. package/lib-esm/utils/use-force-update.js +0 -6
@@ -0,0 +1,347 @@
1
+ import { format, isEqual, isAfter, isBefore, addMonths, subMonths } from 'date-fns';
2
+ import deepmerge from 'deepmerge';
3
+ import React, { createContext, useCallback, useContext, useMemo, useEffect, useState } from 'react';
4
+ const DatePickerContext = /*#__PURE__*/createContext(null);
5
+
6
+ const useDatePicker = date => {
7
+ const value = useContext(DatePickerContext);
8
+ const [selected, setSelected] = useState(false);
9
+
10
+ if (!value) {
11
+ throw new Error('useDatePicker must be used inside a DatePickerProvider');
12
+ }
13
+
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
+ }
41
+ } else {
42
+ setSelected(isEqual(date, value.selection));
43
+ }
44
+ }
45
+ }
46
+ }, [date, value.hoverRange, value.selection]);
47
+ let blocked,
48
+ disabled = false;
49
+
50
+ if (date) {
51
+ // Determine if date is blocked out
52
+ if (value.configuration.blockedDates) {
53
+ blocked = !!value.configuration.blockedDates.find(d => isEqual(d, date));
54
+ } // Determine if date is disabled
55
+
56
+
57
+ if (value.configuration.minDate || value.configuration.maxDate) {
58
+ disabled = (value.configuration.minDate ? isBefore(date, value.configuration.minDate) : false) || (value.configuration.maxDate ? isAfter(date, value.configuration.maxDate) : false);
59
+ }
60
+ }
61
+
62
+ return { ...value,
63
+ blocked,
64
+ disabled,
65
+ selected
66
+ };
67
+ };
68
+
69
+ export default useDatePicker;
70
+ export function isSingleSelection(selection) {
71
+ return selection instanceof Date;
72
+ }
73
+ export function isMultiSelection(selection) {
74
+ return Array.isArray(selection);
75
+ }
76
+ export function isRangeSelection(selection) {
77
+ return !!selection.from;
78
+ }
79
+ export function isStringRangeSelection(selection) {
80
+ return !!selection.from;
81
+ }
82
+
83
+ function parseSelection(selection, variant) {
84
+ if (!selection) return;
85
+
86
+ if (variant === 'multi') {
87
+ if (isMultiSelection(selection)) {
88
+ const parsedSelection = [];
89
+
90
+ for (const d of selection) {
91
+ parsedSelection.push(new Date(new Date(d).toDateString()));
92
+ }
93
+
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
+ }
124
+ } else {
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
+ }
134
+ }
135
+ }
136
+
137
+ const defaultConfiguration = {
138
+ anchorVariant: 'button',
139
+ confirmation: false,
140
+ contiguousSelection: false,
141
+ dimWeekends: false,
142
+ iconPlacement: 'start',
143
+ placeholder: 'Select a Date...',
144
+ selection: 'single',
145
+ view: '2-month',
146
+ weekStartsOn: 'Sunday'
147
+ };
148
+ export const DatePickerProvider = ({
149
+ configuration: externalConfig = {},
150
+ children,
151
+ closePicker,
152
+ value
153
+ }) => {
154
+ const [configuration, setConfiguration] = useState(deepmerge(defaultConfiguration, externalConfig));
155
+ const [previousSelection, setPreviousSelection] = useState(parseSelection(value, configuration.selection));
156
+ const [selection, setSelection] = useState(parseSelection(value, configuration.selection));
157
+ const [hoverRange, setHoverRange] = useState(null);
158
+ const [currentViewingDate, setCurrentViewingDate] = useState(new Date());
159
+ useEffect(() => {
160
+ setConfiguration(deepmerge(defaultConfiguration, externalConfig));
161
+ setSelection(parseSelection(selection, configuration.selection)); // Don't want this to run every time selection gets updated
162
+ // eslint-disable-next-line react-hooks/exhaustive-deps
163
+ }, [configuration.selection, externalConfig]);
164
+ const goToMonth = useCallback(date => {
165
+ setCurrentViewingDate(new Date(new Date(date).toDateString()));
166
+ }, []);
167
+ const nextMonth = useCallback(() => {
168
+ setCurrentViewingDate(addMonths(currentViewingDate, 1));
169
+ }, [currentViewingDate]);
170
+ const previousMonth = useCallback(() => {
171
+ setCurrentViewingDate(subMonths(currentViewingDate, 1));
172
+ }, [currentViewingDate]);
173
+ const getFormattedDate = useMemo(() => {
174
+ if (!selection) {
175
+ return configuration.placeholder;
176
+ }
177
+
178
+ let template = 'MMM d';
179
+
180
+ if (configuration.anchorVariant !== 'input' && configuration.dateFormat) {
181
+ switch (configuration.dateFormat) {
182
+ case 'short':
183
+ template = 'MMM d';
184
+ break;
185
+
186
+ case 'long':
187
+ template = 'MMM d, yyyy';
188
+ break;
189
+
190
+ default:
191
+ template = configuration.dateFormat;
192
+ break;
193
+ }
194
+ } else {
195
+ template = 'MM/dd/yyyy';
196
+ }
197
+
198
+ switch (configuration.selection) {
199
+ case 'single':
200
+ {
201
+ if (selection instanceof Date) {
202
+ return format(selection, template);
203
+ } else if (Array.isArray(selection)) {
204
+ return format(selection[0], template);
205
+ } else if (isRangeSelection(selection)) {
206
+ return format(selection.from, template);
207
+ } else {
208
+ return 'Invalid Selection';
209
+ }
210
+ }
211
+
212
+ case 'multi':
213
+ {
214
+ if (Array.isArray(selection)) {
215
+ if (selection.length > 3) return `${selection.length} Selected`;
216
+ const formatted = selection.map(d => format(d, template)).join(', ');
217
+ return formatted;
218
+ } else if (selection instanceof Date) {
219
+ return [selection].map(d => format(d, template)).join(', ');
220
+ } else if (isRangeSelection(selection)) {
221
+ return [selection.to, selection.from].map(d => d ? format(d, template) : '').join(', ');
222
+ } else {
223
+ return 'Invalid Selection';
224
+ }
225
+ }
226
+
227
+ case 'range':
228
+ {
229
+ if (isRangeSelection(selection)) {
230
+ return Object.entries(selection).map(([_, date]) => date ? format(date, template) : '').join(' - ');
231
+ } else if (selection instanceof Date) {
232
+ return Object.entries({
233
+ from: selection,
234
+ to: null
235
+ }).map(([_, date]) => date ? format(date, template) : '').join(' - ');
236
+ } else if (Array.isArray(selection)) {
237
+ return Object.entries({
238
+ from: selection[0],
239
+ to: selection[1]
240
+ }) // to date can still be null
241
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
242
+ .map(([_, date]) => date ? format(date, template) : '').join(' - ');
243
+ } else {
244
+ return 'Invalid Selection';
245
+ }
246
+ }
247
+
248
+ default:
249
+ {
250
+ return 'Invalid Configuration';
251
+ }
252
+ }
253
+ }, [configuration.anchorVariant, configuration.dateFormat, configuration.placeholder, configuration.selection, selection]);
254
+ const saveValue = useCallback(updatedSelection => {
255
+ setPreviousSelection(updatedSelection !== null && updatedSelection !== void 0 ? updatedSelection : selection);
256
+ closePicker === null || closePicker === void 0 ? void 0 : closePicker();
257
+ }, [closePicker, selection]);
258
+ const selectionHandler = useCallback(date => {
259
+ if (configuration.selection === 'multi') {
260
+ const selections = [...selection];
261
+ const existingIndex = selections.findIndex(s => isEqual(s, date));
262
+
263
+ if (existingIndex > -1) {
264
+ selections.splice(existingIndex, 1);
265
+ setSelection(selections.sort((a, b) => a.getTime() - b.getTime()));
266
+ } else {
267
+ setSelection([...selections, date].sort((a, b) => a.getTime() - b.getTime()));
268
+ }
269
+ } else if (configuration.selection === 'range') {
270
+ if (selection && isRangeSelection(selection) && !selection.to) {
271
+ const updatedSelection = isBefore(date, selection.from) ? {
272
+ from: date,
273
+ to: selection.from
274
+ } : {
275
+ from: selection.from,
276
+ to: date
277
+ };
278
+ setSelection(updatedSelection);
279
+ setHoverRange(null);
280
+
281
+ if (!configuration.confirmation) {
282
+ saveValue(updatedSelection);
283
+ }
284
+ } else {
285
+ setHoverRange({
286
+ from: date,
287
+ to: date
288
+ });
289
+ setSelection({
290
+ from: date,
291
+ to: null
292
+ });
293
+ }
294
+ } else {
295
+ setSelection(date);
296
+
297
+ if (!configuration.confirmation) {
298
+ saveValue(date);
299
+ }
300
+ }
301
+ }, [configuration.confirmation, configuration.selection, saveValue, selection]);
302
+ const focusHnadler = useCallback(date => {
303
+ if (!selection) return;
304
+
305
+ if (configuration.selection === 'range' && isRangeSelection(selection) && hoverRange) {
306
+ setHoverRange(isBefore(date, selection.from) ? {
307
+ from: date,
308
+ to: selection.from
309
+ } : {
310
+ from: selection.from,
311
+ to: date
312
+ });
313
+ }
314
+ }, [configuration.selection, hoverRange, selection]);
315
+ const blurHnadler = useCallback(date => {
316
+ if (!selection || !hoverRange) return;
317
+
318
+ if (configuration.selection === 'range' && isRangeSelection(selection) && (hoverRange.from === date || hoverRange.to === date)) {// setHoverRange({from: hoverRange.from, to: hoverRange.from})
319
+ }
320
+ }, [configuration.selection, hoverRange, selection]);
321
+ const revertValue = useCallback(() => {
322
+ setSelection(previousSelection);
323
+ }, [previousSelection]);
324
+ const datePickerCtx = useMemo(() => {
325
+ return {
326
+ configuration,
327
+ currentViewingDate,
328
+ disabled: false,
329
+ formattedDate: getFormattedDate,
330
+ goToMonth,
331
+ hoverRange,
332
+ nextMonth,
333
+ onDayBlur: blurHnadler,
334
+ onDayFocus: focusHnadler,
335
+ onSelection: selectionHandler,
336
+ previousMonth,
337
+ revertValue,
338
+ saveValue,
339
+ selectionActive: false,
340
+ selection
341
+ };
342
+ }, [blurHnadler, configuration, currentViewingDate, focusHnadler, getFormattedDate, goToMonth, hoverRange, nextMonth, previousMonth, revertValue, saveValue, selection, selectionHandler]);
343
+ return /*#__PURE__*/React.createElement(DatePickerContext.Provider, {
344
+ value: datePickerCtx
345
+ }, children);
346
+ };
347
+ DatePickerProvider.displayName = "DatePickerProvider";
@@ -32,12 +32,14 @@ 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<Omit<Pick<{
35
+ } & Pick<Omit<Pick<({
36
36
  [x: string]: any;
37
37
  [x: number]: any;
38
38
  } & {
39
39
  theme?: any;
40
- } & {
40
+ } & ({} | {
41
+ children?: React.ReactNode;
42
+ })) & {
41
43
  as?: string | React.ComponentType<any> | undefined;
42
44
  forwardedAs?: string | React.ComponentType<any> | undefined;
43
45
  }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast"> & {
@@ -32,12 +32,14 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
32
32
  * Whether the remove buttons should be rendered in the tokens
33
33
  */
34
34
  hideTokenRemoveButtons?: boolean | undefined;
35
- } & Pick<Omit<Pick<{
35
+ } & Pick<Omit<Pick<({
36
36
  [x: string]: any;
37
37
  [x: number]: any;
38
38
  } & {
39
39
  theme?: any;
40
- } & {
40
+ } & ({} | {
41
+ children?: React.ReactNode;
42
+ })) & {
41
43
  as?: string | React.ComponentType<any> | undefined;
42
44
  forwardedAs?: string | React.ComponentType<any> | undefined;
43
45
  }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "className" | "block" | "icon" | "sx" | "disabled" | "variant" | "contrast"> & {
@@ -22,7 +22,6 @@ export { useOnEscapePress } from './hooks/useOnEscapePress';
22
22
  export { useOverlay } from './hooks/useOverlay';
23
23
  export { useConfirm } from './Dialog/ConfirmationDialog';
24
24
  export { ActionList } from './ActionList';
25
- export { ActionList as ActionList2 } from './ActionList2';
26
25
  export { ActionMenu } from './ActionMenu';
27
26
  export type { ActionMenuProps } from './ActionMenu';
28
27
  export { default as Autocomplete } from './Autocomplete';
package/lib-esm/index.js CHANGED
@@ -18,7 +18,6 @@ export { useOverlay } from './hooks/useOverlay';
18
18
  export { useConfirm } from './Dialog/ConfirmationDialog'; // Components
19
19
 
20
20
  export { ActionList } from './ActionList';
21
- export { ActionList as ActionList2 } from './ActionList2';
22
21
  export { ActionMenu } from './ActionMenu';
23
22
  export { default as Autocomplete } from './Autocomplete';
24
23
  export { default as Avatar } from './Avatar';
@@ -515,7 +515,7 @@ module.exports = {
515
515
  }
516
516
  }
517
517
  },
518
- "light_protanopia": {
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
- "dark_protanopia": {
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" | "light_protanopia" | "dark" | "dark_dimmed" | "dark_high_contrast" | "dark_protanopia", Record<"colors" | "shadows", Partial<{
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-202192515932",
3
+ "version": "0.0.0-202192522854",
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": "^13.0.0",
47
- "@primer/primitives": "5.1.0",
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"
@@ -85,6 +81,11 @@
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",
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import { SxProp } from '../sx';
3
- export declare type DescriptionProps = {
4
- variant?: 'inline' | 'block';
5
- } & SxProp;
6
- export declare const Description: React.FC<DescriptionProps>;
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Description = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _Box = _interopRequireDefault(require("../Box"));
11
-
12
- var _Truncate = _interopRequireDefault(require("../Truncate"));
13
-
14
- var _Item = require("./Item");
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- const Description = ({
19
- variant = 'inline',
20
- sx = {},
21
- ...props
22
- }) => {
23
- const styles = {
24
- color: 'fg.muted',
25
- fontSize: 0,
26
- lineHeight: '16px',
27
- flexGrow: 1,
28
- flexBasis: 0,
29
- minWidth: 0,
30
- marginLeft: variant === 'block' ? 0 : 2
31
- };
32
- return /*#__PURE__*/_react.default.createElement(_Item.Slot, {
33
- name: variant === 'block' ? 'BlockDescription' : 'InlineDescription'
34
- }, ({
35
- blockDescriptionId,
36
- inlineDescriptionId
37
- }) => variant === 'block' ? /*#__PURE__*/_react.default.createElement(_Box.default, {
38
- as: "span",
39
- sx: { ...styles,
40
- ...sx
41
- },
42
- id: blockDescriptionId
43
- }, props.children) : /*#__PURE__*/_react.default.createElement(_Truncate.default, {
44
- id: inlineDescriptionId,
45
- sx: styles,
46
- title: props.children,
47
- inline: true,
48
- maxWidth: "100%"
49
- }, props.children));
50
- };
51
-
52
- exports.Description = Description;
53
- Description.displayName = "Description";
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * Visually separates `Item`s or `Group`s in an `ActionList`.
4
- */
5
- export declare function Divider(): JSX.Element;
6
- export declare namespace Divider {
7
- var renderItem: typeof Divider;
8
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Divider = Divider;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _Box = _interopRequireDefault(require("../Box"));
11
-
12
- var _constants = require("../constants");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- /**
17
- * Visually separates `Item`s or `Group`s in an `ActionList`.
18
- */
19
- function Divider() {
20
- return /*#__PURE__*/_react.default.createElement(_Box.default, {
21
- as: "hr",
22
- sx: {
23
- border: 'none',
24
- // override browser styles
25
- height: 1,
26
- backgroundColor: 'border.muted',
27
- marginTop: theme => `calc(${(0, _constants.get)('space.2')(theme)} - 1px)`,
28
- marginBottom: 2
29
- },
30
- "data-component": "ActionList.Divider"
31
- });
32
- }
33
-
34
- Divider.displayName = "Divider";
35
-
36
- /**
37
- * `Divider` fulfills the `ItemPropsWithCustomRenderer` contract,
38
- * so it can be used inline in an `ActionList`’s `items` prop.
39
- * In other words, `items={[ActionList.Divider]}` is supported as a concise
40
- * alternative to `items={[{renderItem: () => <ActionList.Divider />}]}`.
41
- */
42
- Divider.renderItem = Divider;
@@ -1,8 +0,0 @@
1
- /**
2
- * show item dividers
3
- */
4
- /// <reference types="react" />
5
- import { SxProp } from '../sx';
6
- import { HeaderProps } from './Header';
7
- export declare type GroupProps = HeaderProps & SxProp;
8
- export declare function Group({ title, variant, auxiliaryText, sx, ...props }: GroupProps): JSX.Element;
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Group = Group;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _Box = _interopRequireDefault(require("../Box"));
11
-
12
- var _Header = require("./Header");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- 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); }
17
-
18
- function Group({
19
- title,
20
- variant,
21
- auxiliaryText,
22
- sx = {},
23
- ...props
24
- }) {
25
- return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
26
- sx: {
27
- '&:not(:first-child)': {
28
- marginTop: 2
29
- },
30
- ...sx
31
- }
32
- }, props), title && /*#__PURE__*/_react.default.createElement(_Header.Header, {
33
- title: title,
34
- variant: variant,
35
- auxiliaryText: auxiliaryText
36
- }), props.children);
37
- }
38
-
39
- Group.displayName = "Group";
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import { SxProp } from '../sx';
3
- /**
4
- * Contract for props passed to the `Header` component.
5
- */
6
- export interface HeaderProps extends React.ComponentPropsWithoutRef<'div'>, SxProp {
7
- /**
8
- * Style variations. Usage is discretionary.
9
- *
10
- * - `"filled"` - Superimposed on a background, offset from nearby content
11
- * - `"subtle"` - Relatively less offset from nearby content
12
- */
13
- variant?: 'subtle' | 'filled';
14
- /**
15
- * Primary text which names a `Group`.
16
- */
17
- title?: string;
18
- /**
19
- * Secondary text which provides additional information about a `Group`.
20
- */
21
- auxiliaryText?: string;
22
- }
23
- /**
24
- * Displays the name and description of a `Group`.
25
- */
26
- export declare function Header({ variant, title, auxiliaryText, children: _children, sx, ...props }: HeaderProps): JSX.Element;