@primer/components 0.0.0-2021104225742 → 0.0.0-20211081215
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 +3 -5
- package/dist/browser.esm.js +473 -471
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +104 -102
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList2/Description.d.ts +12 -0
- package/lib/ActionList2/Description.js +53 -0
- package/lib/ActionList2/Divider.d.ts +5 -0
- package/lib/ActionList2/Divider.js +35 -0
- package/lib/ActionList2/Group.d.ts +11 -0
- package/lib/ActionList2/Group.js +57 -0
- package/lib/ActionList2/Header.d.ts +26 -0
- package/lib/ActionList2/Header.js +55 -0
- package/lib/ActionList2/Item.d.ts +71 -0
- package/lib/ActionList2/Item.js +234 -0
- package/lib/ActionList2/LinkItem.d.ts +17 -0
- package/lib/ActionList2/LinkItem.js +57 -0
- package/lib/ActionList2/List.d.ts +26 -0
- package/lib/ActionList2/List.js +59 -0
- package/lib/ActionList2/Selection.d.ts +5 -0
- package/lib/ActionList2/Selection.js +70 -0
- package/lib/ActionList2/Visuals.d.ts +11 -0
- package/lib/ActionList2/Visuals.js +90 -0
- package/lib/ActionList2/index.d.ts +40 -0
- package/lib/ActionList2/index.js +47 -0
- package/lib/Autocomplete/Autocomplete.d.ts +28 -28
- package/lib/Autocomplete/AutocompleteInput.d.ts +28 -28
- package/lib/Button/Button.d.ts +25 -25
- package/lib/Button/ButtonClose.d.ts +45 -45
- package/lib/Button/ButtonDanger.d.ts +25 -25
- package/lib/Button/ButtonInvisible.d.ts +25 -25
- package/lib/Button/ButtonOutline.d.ts +25 -25
- package/lib/Button/ButtonPrimary.d.ts +25 -25
- package/lib/CircleOcticon.d.ts +42 -42
- package/lib/Dialog.d.ts +45 -45
- package/lib/Dropdown.d.ts +176 -176
- package/lib/DropdownMenu/DropdownButton.d.ts +46 -46
- package/lib/FilterList.d.ts +42 -42
- package/lib/Position.d.ts +4 -4
- package/lib/SelectMenu/SelectMenu.d.ts +246 -246
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib/TextInputWithTokens.d.ts +28 -28
- package/lib/Timeline.d.ts +43 -43
- package/lib/Token/AvatarToken.d.ts +1 -1
- package/lib/Token/IssueLabelToken.d.ts +1 -1
- package/lib/Token/Token.d.ts +1 -1
- package/lib/Truncate.d.ts +2 -1
- package/lib/Truncate.js +3 -1
- package/lib/experiments.d.ts +1 -0
- package/lib/experiments.js +18 -0
- package/lib/sx.d.ts +2 -0
- package/lib/sx.js +8 -0
- package/lib/theme-preval.js +81 -2
- package/lib/utils/create-slots.d.ts +17 -0
- package/lib/utils/create-slots.js +105 -0
- package/lib/utils/testing.d.ts +14 -1
- package/lib/utils/use-force-update.d.ts +1 -0
- package/lib/utils/use-force-update.js +19 -0
- package/lib-esm/ActionList2/Description.d.ts +12 -0
- package/lib-esm/ActionList2/Description.js +37 -0
- package/lib-esm/ActionList2/Divider.d.ts +5 -0
- package/lib-esm/ActionList2/Divider.js +23 -0
- package/lib-esm/ActionList2/Group.d.ts +11 -0
- package/lib-esm/ActionList2/Group.js +40 -0
- package/lib-esm/ActionList2/Header.d.ts +26 -0
- package/lib-esm/ActionList2/Header.js +44 -0
- package/lib-esm/ActionList2/Item.d.ts +71 -0
- package/lib-esm/ActionList2/Item.js +201 -0
- package/lib-esm/ActionList2/LinkItem.d.ts +17 -0
- package/lib-esm/ActionList2/LinkItem.js +43 -0
- package/lib-esm/ActionList2/List.d.ts +26 -0
- package/lib-esm/ActionList2/List.js +37 -0
- package/lib-esm/ActionList2/Selection.d.ts +5 -0
- package/lib-esm/ActionList2/Selection.js +52 -0
- package/lib-esm/ActionList2/Visuals.d.ts +11 -0
- package/lib-esm/ActionList2/Visuals.js +68 -0
- package/lib-esm/ActionList2/index.d.ts +40 -0
- package/lib-esm/ActionList2/index.js +33 -0
- package/lib-esm/Autocomplete/Autocomplete.d.ts +28 -28
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +28 -28
- package/lib-esm/Button/Button.d.ts +25 -25
- package/lib-esm/Button/ButtonClose.d.ts +45 -45
- package/lib-esm/Button/ButtonDanger.d.ts +25 -25
- package/lib-esm/Button/ButtonInvisible.d.ts +25 -25
- package/lib-esm/Button/ButtonOutline.d.ts +25 -25
- package/lib-esm/Button/ButtonPrimary.d.ts +25 -25
- package/lib-esm/CircleOcticon.d.ts +42 -42
- package/lib-esm/Dialog.d.ts +45 -45
- package/lib-esm/Dropdown.d.ts +176 -176
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +46 -46
- package/lib-esm/FilterList.d.ts +42 -42
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/SelectMenu/SelectMenu.d.ts +246 -246
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib-esm/TextInputWithTokens.d.ts +28 -28
- package/lib-esm/Timeline.d.ts +43 -43
- package/lib-esm/Token/AvatarToken.d.ts +1 -1
- package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
- package/lib-esm/Token/Token.d.ts +1 -1
- package/lib-esm/Truncate.d.ts +2 -1
- package/lib-esm/Truncate.js +2 -1
- package/lib-esm/experiments.d.ts +1 -0
- package/lib-esm/experiments.js +2 -0
- package/lib-esm/sx.d.ts +2 -0
- package/lib-esm/sx.js +3 -1
- package/lib-esm/theme-preval.js +81 -2
- package/lib-esm/utils/create-slots.d.ts +17 -0
- package/lib-esm/utils/create-slots.js +84 -0
- package/lib-esm/utils/testing.d.ts +14 -1
- package/lib-esm/utils/use-force-update.d.ts +1 -0
- package/lib-esm/utils/use-force-update.js +6 -0
- package/package.json +4 -2
package/lib-esm/theme-preval.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
// this file was prevaled
|
2
2
|
// This file needs to be a JavaScript file using CommonJS to be compatiable with preval
|
3
|
+
// Cache bust: 2021-11-04 12:00:00 GMT (This file is cached by our deployment tooling, update this timestamp to rebuild this file)
|
3
4
|
module.exports = {
|
4
5
|
"theme": {
|
5
6
|
"animation": {
|
@@ -389,6 +390,19 @@ module.exports = {
|
|
389
390
|
"icon": "#6e7781",
|
390
391
|
"borderHover": "rgba(175,184,193,0.2)"
|
391
392
|
},
|
393
|
+
"actionListItem": {
|
394
|
+
"inlineDivider": "rgba(208,215,222,0.48)",
|
395
|
+
"default": {
|
396
|
+
"hoverBg": "rgba(208,215,222,0.32)",
|
397
|
+
"activeBg": "rgba(208,215,222,0.48)",
|
398
|
+
"selectedBg": "rgba(208,215,222,0.24)"
|
399
|
+
},
|
400
|
+
"danger": {
|
401
|
+
"hoverBg": "rgba(255,235,233,0.64)",
|
402
|
+
"activeBg": "#FFEBE9",
|
403
|
+
"hoverText": "#cf222e"
|
404
|
+
}
|
405
|
+
},
|
392
406
|
"fg": {
|
393
407
|
"default": "#24292f",
|
394
408
|
"muted": "#57606a",
|
@@ -515,7 +529,7 @@ module.exports = {
|
|
515
529
|
}
|
516
530
|
}
|
517
531
|
},
|
518
|
-
"
|
532
|
+
"light_colorblind": {
|
519
533
|
"colors": {
|
520
534
|
"canvasDefaultTransparent": "rgba(255,255,255,0)",
|
521
535
|
"marketingIcon": {
|
@@ -872,6 +886,19 @@ module.exports = {
|
|
872
886
|
"icon": "#6e7781",
|
873
887
|
"borderHover": "rgba(175,184,193,0.2)"
|
874
888
|
},
|
889
|
+
"actionListItem": {
|
890
|
+
"inlineDivider": "rgba(208,215,222,0.48)",
|
891
|
+
"default": {
|
892
|
+
"hoverBg": "rgba(208,215,222,0.32)",
|
893
|
+
"activeBg": "rgba(208,215,222,0.48)",
|
894
|
+
"selectedBg": "rgba(208,215,222,0.24)"
|
895
|
+
},
|
896
|
+
"danger": {
|
897
|
+
"hoverBg": "rgba(254,254,72,0.64)",
|
898
|
+
"activeBg": "#fefe48",
|
899
|
+
"hoverText": "#ac5e00"
|
900
|
+
}
|
901
|
+
},
|
875
902
|
"fg": {
|
876
903
|
"default": "#24292f",
|
877
904
|
"muted": "#57606a",
|
@@ -1355,6 +1382,19 @@ module.exports = {
|
|
1355
1382
|
"icon": "#484f58",
|
1356
1383
|
"borderHover": "rgba(110,118,129,0.4)"
|
1357
1384
|
},
|
1385
|
+
"actionListItem": {
|
1386
|
+
"inlineDivider": "rgba(48,54,61,0.48)",
|
1387
|
+
"default": {
|
1388
|
+
"hoverBg": "rgba(177,186,196,0.12)",
|
1389
|
+
"activeBg": "rgba(177,186,196,0.2)",
|
1390
|
+
"selectedBg": "rgba(177,186,196,0.08)"
|
1391
|
+
},
|
1392
|
+
"danger": {
|
1393
|
+
"hoverBg": "rgba(248,81,73,0.16)",
|
1394
|
+
"activeBg": "rgba(248,81,73,0.24)",
|
1395
|
+
"hoverText": "#ff7b72"
|
1396
|
+
}
|
1397
|
+
},
|
1358
1398
|
"fg": {
|
1359
1399
|
"default": "#c9d1d9",
|
1360
1400
|
"muted": "#8b949e",
|
@@ -1841,6 +1881,19 @@ module.exports = {
|
|
1841
1881
|
"icon": "#545d68",
|
1842
1882
|
"borderHover": "rgba(99,110,123,0.4)"
|
1843
1883
|
},
|
1884
|
+
"actionListItem": {
|
1885
|
+
"inlineDivider": "rgba(68,76,86,0.48)",
|
1886
|
+
"default": {
|
1887
|
+
"hoverBg": "rgba(144,157,171,0.12)",
|
1888
|
+
"activeBg": "rgba(144,157,171,0.2)",
|
1889
|
+
"selectedBg": "rgba(144,157,171,0.08)"
|
1890
|
+
},
|
1891
|
+
"danger": {
|
1892
|
+
"hoverBg": "rgba(229,83,75,0.16)",
|
1893
|
+
"activeBg": "rgba(229,83,75,0.24)",
|
1894
|
+
"hoverText": "#f47067"
|
1895
|
+
}
|
1896
|
+
},
|
1844
1897
|
"fg": {
|
1845
1898
|
"default": "#adbac7",
|
1846
1899
|
"muted": "#768390",
|
@@ -2327,6 +2380,19 @@ module.exports = {
|
|
2327
2380
|
"icon": "#f0f3f6",
|
2328
2381
|
"borderHover": "#bdc4cc"
|
2329
2382
|
},
|
2383
|
+
"actionListItem": {
|
2384
|
+
"inlineDivider": "#7a828e",
|
2385
|
+
"default": {
|
2386
|
+
"hoverBg": "rgba(217,222,227,0.12)",
|
2387
|
+
"activeBg": "rgba(217,222,227,0.24)",
|
2388
|
+
"selectedBg": "rgba(217,222,227,0.08)"
|
2389
|
+
},
|
2390
|
+
"danger": {
|
2391
|
+
"hoverBg": "#ff6a69",
|
2392
|
+
"activeBg": "#ff4445",
|
2393
|
+
"hoverText": "#0a0c10"
|
2394
|
+
}
|
2395
|
+
},
|
2330
2396
|
"fg": {
|
2331
2397
|
"default": "#f0f3f6",
|
2332
2398
|
"muted": "#f0f3f6",
|
@@ -2456,7 +2522,7 @@ module.exports = {
|
|
2456
2522
|
}
|
2457
2523
|
}
|
2458
2524
|
},
|
2459
|
-
"
|
2525
|
+
"dark_colorblind": {
|
2460
2526
|
"colors": {
|
2461
2527
|
"canvasDefaultTransparent": "rgba(13,17,23,0)",
|
2462
2528
|
"marketingIcon": {
|
@@ -2813,6 +2879,19 @@ module.exports = {
|
|
2813
2879
|
"icon": "#484f58",
|
2814
2880
|
"borderHover": "rgba(110,118,129,0.4)"
|
2815
2881
|
},
|
2882
|
+
"actionListItem": {
|
2883
|
+
"inlineDivider": "rgba(48,54,61,0.48)",
|
2884
|
+
"default": {
|
2885
|
+
"hoverBg": "rgba(177,186,196,0.12)",
|
2886
|
+
"activeBg": "rgba(177,186,196,0.2)",
|
2887
|
+
"selectedBg": "rgba(177,186,196,0.08)"
|
2888
|
+
},
|
2889
|
+
"danger": {
|
2890
|
+
"hoverBg": "rgba(195,128,0,0.16)",
|
2891
|
+
"activeBg": "rgba(195,128,0,0.24)",
|
2892
|
+
"hoverText": "#d69a00"
|
2893
|
+
}
|
2894
|
+
},
|
2816
2895
|
"fg": {
|
2817
2896
|
"default": "#c9d1d9",
|
2818
2897
|
"muted": "#8b949e",
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
/** createSlots is a factory that can create a
|
3
|
+
* typesafe Slots + Slot pair to use in a component definition
|
4
|
+
* For example: ActionList.Item uses createSlots to get a Slots wrapper
|
5
|
+
* + Slot component that is used by LeadingVisual, Description
|
6
|
+
*/
|
7
|
+
declare const createSlots: <SlotNames extends string>(slotNames: SlotNames[]) => {
|
8
|
+
Slots: React.FC<{
|
9
|
+
context?: Record<string, unknown> | undefined;
|
10
|
+
children: (slots: { [key in SlotNames]?: React.ReactNode; }) => React.ReactNode;
|
11
|
+
}>;
|
12
|
+
Slot: React.FC<{
|
13
|
+
name: SlotNames;
|
14
|
+
children: React.ReactNode;
|
15
|
+
}>;
|
16
|
+
};
|
17
|
+
export default createSlots;
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { useForceUpdate } from './use-force-update';
|
3
|
+
/** createSlots is a factory that can create a
|
4
|
+
* typesafe Slots + Slot pair to use in a component definition
|
5
|
+
* For example: ActionList.Item uses createSlots to get a Slots wrapper
|
6
|
+
* + Slot component that is used by LeadingVisual, Description
|
7
|
+
*/
|
8
|
+
|
9
|
+
const createSlots = slotNames => {
|
10
|
+
const SlotsContext = /*#__PURE__*/React.createContext({
|
11
|
+
registerSlot: () => null,
|
12
|
+
unregisterSlot: () => null,
|
13
|
+
context: {}
|
14
|
+
});
|
15
|
+
/** Slots uses a Double render strategy inspired by [reach-ui/descendants](https://github.com/reach/reach-ui/tree/develop/packages/descendants)
|
16
|
+
* Slot registers themself with the Slots parent.
|
17
|
+
* When all the children have mounted = registered themselves in slot,
|
18
|
+
* we re-render the parent component to render with slots
|
19
|
+
*/
|
20
|
+
|
21
|
+
const Slots = ({
|
22
|
+
context = {},
|
23
|
+
children
|
24
|
+
}) => {
|
25
|
+
// initialise slots
|
26
|
+
const slotsDefinition = {};
|
27
|
+
slotNames.map(name => slotsDefinition[name] = null);
|
28
|
+
const slotsRef = React.useRef(slotsDefinition);
|
29
|
+
const rerenderWithSlots = useForceUpdate();
|
30
|
+
const [isMounted, setIsMounted] = React.useState(false); // fires after all the effects in children
|
31
|
+
|
32
|
+
React.useEffect(() => {
|
33
|
+
rerenderWithSlots();
|
34
|
+
setIsMounted(true);
|
35
|
+
}, [rerenderWithSlots]);
|
36
|
+
const registerSlot = React.useCallback((name, contents) => {
|
37
|
+
slotsRef.current[name] = contents; // don't render until the component mounts = all slots are registered
|
38
|
+
|
39
|
+
if (isMounted) rerenderWithSlots();
|
40
|
+
}, [isMounted, rerenderWithSlots]); // Slot can be removed from the tree as well,
|
41
|
+
// we need to unregister them from the slot
|
42
|
+
|
43
|
+
const unregisterSlot = React.useCallback(name => {
|
44
|
+
slotsRef.current[name] = null;
|
45
|
+
rerenderWithSlots();
|
46
|
+
}, [rerenderWithSlots]);
|
47
|
+
/**
|
48
|
+
* Slots uses a render prop API so abstract the
|
49
|
+
* implementation detail of using a context provider.
|
50
|
+
*/
|
51
|
+
|
52
|
+
const slots = slotsRef.current;
|
53
|
+
return /*#__PURE__*/React.createElement(SlotsContext.Provider, {
|
54
|
+
value: {
|
55
|
+
registerSlot,
|
56
|
+
unregisterSlot,
|
57
|
+
context
|
58
|
+
}
|
59
|
+
}, children(slots));
|
60
|
+
};
|
61
|
+
|
62
|
+
const Slot = ({
|
63
|
+
name,
|
64
|
+
children
|
65
|
+
}) => {
|
66
|
+
const {
|
67
|
+
registerSlot,
|
68
|
+
unregisterSlot,
|
69
|
+
context
|
70
|
+
} = React.useContext(SlotsContext);
|
71
|
+
React.useEffect(() => {
|
72
|
+
registerSlot(name, typeof children === 'function' ? children(context) : children);
|
73
|
+
return () => unregisterSlot(name);
|
74
|
+
}, [name, children, registerSlot, unregisterSlot, context]);
|
75
|
+
return null;
|
76
|
+
};
|
77
|
+
|
78
|
+
return {
|
79
|
+
Slots,
|
80
|
+
Slot
|
81
|
+
};
|
82
|
+
};
|
83
|
+
|
84
|
+
export default createSlots;
|
@@ -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;
|
@@ -434,6 +434,19 @@ export declare function render(component: React.ReactElement, theme?: {
|
|
434
434
|
icon: string;
|
435
435
|
borderHover: string;
|
436
436
|
};
|
437
|
+
actionListItem: {
|
438
|
+
inlineDivider: string;
|
439
|
+
default: {
|
440
|
+
hoverBg: string;
|
441
|
+
activeBg: string;
|
442
|
+
selectedBg: string;
|
443
|
+
};
|
444
|
+
danger: {
|
445
|
+
hoverBg: string;
|
446
|
+
activeBg: string;
|
447
|
+
hoverText: string;
|
448
|
+
};
|
449
|
+
};
|
437
450
|
fg: {
|
438
451
|
default: string;
|
439
452
|
muted: string;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const useForceUpdate: () => () => void;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
// Inspired from reach-ui: https://github.com/reach/reach-ui/blob/develop/packages/utils/src/use-force-update.ts
|
2
|
+
import React from 'react';
|
3
|
+
export const useForceUpdate = () => {
|
4
|
+
const [, rerender] = React.useState({});
|
5
|
+
return React.useCallback(() => rerender({}), []);
|
6
|
+
};
|
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-20211081215",
|
4
4
|
"description": "Primer react components",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"module": "lib-esm/index.js",
|
@@ -44,7 +44,7 @@
|
|
44
44
|
"license": "MIT",
|
45
45
|
"dependencies": {
|
46
46
|
"@primer/octicons-react": "^13.0.0",
|
47
|
-
"@primer/primitives": "
|
47
|
+
"@primer/primitives": "6.1.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",
|
@@ -124,6 +124,8 @@
|
|
124
124
|
"lodash.isobject": "3.0.2",
|
125
125
|
"prettier": "2.3.2",
|
126
126
|
"react": "17.0.2",
|
127
|
+
"react-dnd": "14.0.4",
|
128
|
+
"react-dnd-html5-backend": "14.0.2",
|
127
129
|
"react-dom": "17.0.2",
|
128
130
|
"react-test-renderer": "17.0.2",
|
129
131
|
"rollup": "2.56.3",
|