@primer/components 0.0.0-2021103235619 → 0.0.0-2021104151625

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 (192) hide show
  1. package/CHANGELOG.md +27 -1
  2. package/dist/browser.esm.js +509 -505
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +112 -108
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList/Header.js +1 -1
  7. package/lib/ActionList/Item.d.ts +6 -0
  8. package/lib/ActionList/Item.js +5 -1
  9. package/lib/ActionList2/Description.d.ts +12 -0
  10. package/lib/ActionList2/Description.js +53 -0
  11. package/lib/ActionList2/Divider.d.ts +5 -0
  12. package/lib/ActionList2/Divider.js +35 -0
  13. package/lib/ActionList2/Group.d.ts +11 -0
  14. package/lib/ActionList2/Group.js +57 -0
  15. package/lib/ActionList2/Header.d.ts +26 -0
  16. package/lib/ActionList2/Header.js +55 -0
  17. package/lib/ActionList2/Item.d.ts +67 -0
  18. package/lib/ActionList2/Item.js +221 -0
  19. package/lib/ActionList2/LinkItem.d.ts +17 -0
  20. package/lib/ActionList2/LinkItem.js +57 -0
  21. package/lib/ActionList2/List.d.ts +26 -0
  22. package/lib/ActionList2/List.js +51 -0
  23. package/lib/ActionList2/Selection.d.ts +5 -0
  24. package/lib/ActionList2/Selection.js +70 -0
  25. package/lib/ActionList2/Visuals.d.ts +11 -0
  26. package/lib/ActionList2/Visuals.js +90 -0
  27. package/lib/ActionList2/index.d.ts +40 -0
  28. package/lib/ActionList2/index.js +47 -0
  29. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +2 -4
  30. package/lib/Autocomplete/Autocomplete.d.ts +30 -32
  31. package/lib/Autocomplete/AutocompleteInput.d.ts +30 -32
  32. package/lib/Button/Button.d.ts +27 -27
  33. package/lib/Button/ButtonBase.d.ts +1 -1
  34. package/lib/Button/ButtonClose.d.ts +45 -45
  35. package/lib/Button/ButtonDanger.d.ts +27 -27
  36. package/lib/Button/ButtonInvisible.d.ts +27 -27
  37. package/lib/Button/ButtonOutline.d.ts +27 -27
  38. package/lib/Button/ButtonPrimary.d.ts +27 -27
  39. package/lib/CircleBadge.d.ts +2 -2
  40. package/lib/CircleOcticon.d.ts +43 -43
  41. package/lib/Dialog.d.ts +46 -46
  42. package/lib/Dropdown.d.ts +178 -178
  43. package/lib/DropdownMenu/DropdownButton.d.ts +47 -47
  44. package/lib/FilterList.d.ts +42 -42
  45. package/lib/Flash.d.ts +1 -1
  46. package/lib/Label.d.ts +1 -1
  47. package/lib/Position.d.ts +4 -4
  48. package/lib/ProgressBar.d.ts +1 -1
  49. package/lib/SelectMenu/SelectMenu.d.ts +246 -248
  50. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  51. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  52. package/lib/TextInputWithTokens.d.ts +34 -32
  53. package/lib/TextInputWithTokens.js +102 -29
  54. package/lib/Timeline.d.ts +44 -44
  55. package/lib/Token/AvatarToken.d.ts +1 -1
  56. package/lib/Token/IssueLabelToken.d.ts +1 -1
  57. package/lib/Token/Token.d.ts +1 -1
  58. package/lib/Token/Token.js +13 -2
  59. package/lib/Token/TokenBase.js +0 -4
  60. package/lib/Token/_RemoveTokenButton.js +15 -2
  61. package/lib/_TextInputWrapper.d.ts +1 -1
  62. package/lib/_TextInputWrapper.js +1 -1
  63. package/lib/experiments.d.ts +1 -0
  64. package/lib/experiments.js +18 -0
  65. package/lib/hooks/useResizeObserver.d.ts +1 -1
  66. package/lib/hooks/useResizeObserver.js +1 -1
  67. package/lib/sx.d.ts +10 -2
  68. package/lib/sx.js +8 -0
  69. package/lib/theme-preval.js +79 -0
  70. package/lib/theme.d.ts +78 -0
  71. package/lib/theme.js +3 -1
  72. package/lib/utils/create-slots.d.ts +17 -0
  73. package/lib/utils/create-slots.js +105 -0
  74. package/lib/utils/testing.d.ts +13 -0
  75. package/lib/utils/types/KeyPaths.d.ts +3 -0
  76. package/lib/utils/types/KeyPaths.js +1 -0
  77. package/lib/utils/use-force-update.d.ts +1 -0
  78. package/lib/utils/use-force-update.js +19 -0
  79. package/lib-esm/ActionList/Header.js +1 -1
  80. package/lib-esm/ActionList/Item.d.ts +6 -0
  81. package/lib-esm/ActionList/Item.js +5 -1
  82. package/lib-esm/ActionList2/Description.d.ts +12 -0
  83. package/lib-esm/ActionList2/Description.js +37 -0
  84. package/lib-esm/ActionList2/Divider.d.ts +5 -0
  85. package/lib-esm/ActionList2/Divider.js +23 -0
  86. package/lib-esm/ActionList2/Group.d.ts +11 -0
  87. package/lib-esm/ActionList2/Group.js +40 -0
  88. package/lib-esm/ActionList2/Header.d.ts +26 -0
  89. package/lib-esm/ActionList2/Header.js +44 -0
  90. package/lib-esm/ActionList2/Item.d.ts +67 -0
  91. package/lib-esm/ActionList2/Item.js +195 -0
  92. package/lib-esm/ActionList2/LinkItem.d.ts +17 -0
  93. package/lib-esm/ActionList2/LinkItem.js +43 -0
  94. package/lib-esm/ActionList2/List.d.ts +26 -0
  95. package/lib-esm/ActionList2/List.js +34 -0
  96. package/lib-esm/ActionList2/Selection.d.ts +5 -0
  97. package/lib-esm/ActionList2/Selection.js +52 -0
  98. package/lib-esm/ActionList2/Visuals.d.ts +11 -0
  99. package/lib-esm/ActionList2/Visuals.js +68 -0
  100. package/lib-esm/ActionList2/index.d.ts +40 -0
  101. package/lib-esm/ActionList2/index.js +33 -0
  102. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +2 -4
  103. package/lib-esm/Autocomplete/Autocomplete.d.ts +30 -32
  104. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +30 -32
  105. package/lib-esm/Button/Button.d.ts +27 -27
  106. package/lib-esm/Button/ButtonBase.d.ts +1 -1
  107. package/lib-esm/Button/ButtonClose.d.ts +45 -45
  108. package/lib-esm/Button/ButtonDanger.d.ts +27 -27
  109. package/lib-esm/Button/ButtonInvisible.d.ts +27 -27
  110. package/lib-esm/Button/ButtonOutline.d.ts +27 -27
  111. package/lib-esm/Button/ButtonPrimary.d.ts +27 -27
  112. package/lib-esm/CircleBadge.d.ts +2 -2
  113. package/lib-esm/CircleOcticon.d.ts +43 -43
  114. package/lib-esm/Dialog.d.ts +46 -46
  115. package/lib-esm/Dropdown.d.ts +178 -178
  116. package/lib-esm/DropdownMenu/DropdownButton.d.ts +47 -47
  117. package/lib-esm/FilterList.d.ts +42 -42
  118. package/lib-esm/Flash.d.ts +1 -1
  119. package/lib-esm/Label.d.ts +1 -1
  120. package/lib-esm/Position.d.ts +4 -4
  121. package/lib-esm/ProgressBar.d.ts +1 -1
  122. package/lib-esm/SelectMenu/SelectMenu.d.ts +246 -248
  123. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  124. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  125. package/lib-esm/TextInputWithTokens.d.ts +34 -32
  126. package/lib-esm/TextInputWithTokens.js +101 -30
  127. package/lib-esm/Timeline.d.ts +44 -44
  128. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  129. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  130. package/lib-esm/Token/Token.d.ts +1 -1
  131. package/lib-esm/Token/Token.js +13 -2
  132. package/lib-esm/Token/TokenBase.js +0 -4
  133. package/lib-esm/Token/_RemoveTokenButton.js +11 -2
  134. package/lib-esm/_TextInputWrapper.d.ts +1 -1
  135. package/lib-esm/_TextInputWrapper.js +1 -1
  136. package/lib-esm/experiments.d.ts +1 -0
  137. package/lib-esm/experiments.js +2 -0
  138. package/lib-esm/hooks/useResizeObserver.d.ts +1 -1
  139. package/lib-esm/hooks/useResizeObserver.js +1 -1
  140. package/lib-esm/sx.d.ts +10 -2
  141. package/lib-esm/sx.js +3 -1
  142. package/lib-esm/theme-preval.js +79 -0
  143. package/lib-esm/theme.d.ts +78 -0
  144. package/lib-esm/theme.js +2 -1
  145. package/lib-esm/utils/create-slots.d.ts +17 -0
  146. package/lib-esm/utils/create-slots.js +84 -0
  147. package/lib-esm/utils/testing.d.ts +13 -0
  148. package/lib-esm/utils/types/KeyPaths.d.ts +3 -0
  149. package/lib-esm/utils/types/KeyPaths.js +1 -0
  150. package/lib-esm/utils/use-force-update.d.ts +1 -0
  151. package/lib-esm/utils/use-force-update.js +6 -0
  152. package/package.json +12 -9
  153. package/lib/DatePicker/DatePicker.d.ts +0 -52
  154. package/lib/DatePicker/DatePicker.js +0 -109
  155. package/lib/DatePicker/DatePickerAnchor.d.ts +0 -5
  156. package/lib/DatePicker/DatePickerAnchor.js +0 -202
  157. package/lib/DatePicker/DatePickerOverlay.d.ts +0 -3
  158. package/lib/DatePicker/DatePickerOverlay.js +0 -55
  159. package/lib/DatePicker/DatePickerPanel.d.ts +0 -2
  160. package/lib/DatePicker/DatePickerPanel.js +0 -363
  161. package/lib/DatePicker/Day.d.ts +0 -15
  162. package/lib/DatePicker/Day.js +0 -206
  163. package/lib/DatePicker/Month.d.ts +0 -8
  164. package/lib/DatePicker/Month.js +0 -122
  165. package/lib/DatePicker/dateParser.d.ts +0 -12
  166. package/lib/DatePicker/dateParser.js +0 -192
  167. package/lib/DatePicker/index.d.ts +0 -2
  168. package/lib/DatePicker/index.js +0 -13
  169. package/lib/DatePicker/useDatePicker.d.ts +0 -107
  170. package/lib/DatePicker/useDatePicker.js +0 -558
  171. package/lib/hooks/useDebounce.d.ts +0 -2
  172. package/lib/hooks/useDebounce.js +0 -24
  173. package/lib-esm/DatePicker/DatePicker.d.ts +0 -52
  174. package/lib-esm/DatePicker/DatePicker.js +0 -92
  175. package/lib-esm/DatePicker/DatePickerAnchor.d.ts +0 -5
  176. package/lib-esm/DatePicker/DatePickerAnchor.js +0 -174
  177. package/lib-esm/DatePicker/DatePickerOverlay.d.ts +0 -3
  178. package/lib-esm/DatePicker/DatePickerOverlay.js +0 -40
  179. package/lib-esm/DatePicker/DatePickerPanel.d.ts +0 -2
  180. package/lib-esm/DatePicker/DatePickerPanel.js +0 -332
  181. package/lib-esm/DatePicker/Day.d.ts +0 -15
  182. package/lib-esm/DatePicker/Day.js +0 -182
  183. package/lib-esm/DatePicker/Month.d.ts +0 -8
  184. package/lib-esm/DatePicker/Month.js +0 -98
  185. package/lib-esm/DatePicker/dateParser.d.ts +0 -12
  186. package/lib-esm/DatePicker/dateParser.js +0 -178
  187. package/lib-esm/DatePicker/index.d.ts +0 -2
  188. package/lib-esm/DatePicker/index.js +0 -1
  189. package/lib-esm/DatePicker/useDatePicker.d.ts +0 -107
  190. package/lib-esm/DatePicker/useDatePicker.js +0 -523
  191. package/lib-esm/hooks/useDebounce.d.ts +0 -2
  192. package/lib-esm/hooks/useDebounce.js +0 -16
@@ -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",
@@ -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",
@@ -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",
package/lib/theme.d.ts CHANGED
@@ -1,2 +1,80 @@
1
1
  import { theme } from './theme-preval';
2
+ import { KeyPaths } from './utils/types/KeyPaths';
2
3
  export default theme;
4
+ declare type ThemeColors = {
5
+ fg: {
6
+ default: string;
7
+ muted: string;
8
+ subtle: string;
9
+ onEmphasis: string;
10
+ };
11
+ canvas: {
12
+ default: string;
13
+ overlay: string;
14
+ inset: string;
15
+ subtle: string;
16
+ };
17
+ border: {
18
+ default: string;
19
+ muted: string;
20
+ subtle: string;
21
+ };
22
+ neutral: {
23
+ emphasisPlus: string;
24
+ emphasis: string;
25
+ muted: string;
26
+ subtle: string;
27
+ };
28
+ accent: {
29
+ fg: string;
30
+ emphasis: string;
31
+ muted: string;
32
+ subtle: string;
33
+ };
34
+ success: {
35
+ fg: string;
36
+ emphasis: string;
37
+ muted: string;
38
+ subtle: string;
39
+ };
40
+ attention: {
41
+ fg: string;
42
+ emphasis: string;
43
+ muted: string;
44
+ subtle: string;
45
+ };
46
+ severe: {
47
+ fg: string;
48
+ emphasis: string;
49
+ muted: string;
50
+ subtle: string;
51
+ };
52
+ danger: {
53
+ fg: string;
54
+ emphasis: string;
55
+ muted: string;
56
+ subtle: string;
57
+ };
58
+ done: {
59
+ fg: string;
60
+ emphasis: string;
61
+ muted: string;
62
+ subtle: string;
63
+ };
64
+ sponsors: {
65
+ fg: string;
66
+ emphasis: string;
67
+ muted: string;
68
+ subtle: string;
69
+ };
70
+ };
71
+ declare type ThemeShadows = {
72
+ shadow: {
73
+ small: string;
74
+ medium: string;
75
+ large: string;
76
+ extraLarge: string;
77
+ };
78
+ };
79
+ export declare type ThemeColorPaths = KeyPaths<ThemeColors>;
80
+ export declare type ThemeShadowPaths = KeyPaths<ThemeShadows>;
package/lib/theme.js CHANGED
@@ -7,5 +7,7 @@ exports.default = void 0;
7
7
 
8
8
  var _themePreval = require("./theme-preval");
9
9
 
10
- var _default = _themePreval.theme;
10
+ var _default = _themePreval.theme; // NOTE: for now, ThemeColors and ThemeShadows are handcrafted types. It would be nice if these
11
+ // were exports from primitives (or a different shape but derived from those exports).
12
+
11
13
  exports.default = _default;
@@ -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 | ((context: Record<string, unknown>) => React.ReactNode);
15
+ }>;
16
+ };
17
+ export default createSlots;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _useForceUpdate = require("./use-force-update");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ /** createSlots is a factory that can create a
15
+ * typesafe Slots + Slot pair to use in a component definition
16
+ * For example: ActionList.Item uses createSlots to get a Slots wrapper
17
+ * + Slot component that is used by LeadingVisual, Description
18
+ */
19
+ const createSlots = slotNames => {
20
+ const SlotsContext = /*#__PURE__*/_react.default.createContext({
21
+ registerSlot: () => null,
22
+ unregisterSlot: () => null,
23
+ context: {}
24
+ });
25
+ /** Slots uses a Double render strategy inspired by [reach-ui/descendants](https://github.com/reach/reach-ui/tree/develop/packages/descendants)
26
+ * Slot registers themself with the Slots parent.
27
+ * When all the children have mounted = registered themselves in slot,
28
+ * we re-render the parent component to render with slots
29
+ */
30
+
31
+
32
+ const Slots = ({
33
+ context = {},
34
+ children
35
+ }) => {
36
+ // initialise slots
37
+ const slotsDefinition = {};
38
+ slotNames.map(name => slotsDefinition[name] = null);
39
+
40
+ const slotsRef = _react.default.useRef(slotsDefinition);
41
+
42
+ const rerenderWithSlots = (0, _useForceUpdate.useForceUpdate)();
43
+
44
+ const [isMounted, setIsMounted] = _react.default.useState(false); // fires after all the effects in children
45
+
46
+
47
+ _react.default.useEffect(() => {
48
+ rerenderWithSlots();
49
+ setIsMounted(true);
50
+ }, [rerenderWithSlots]);
51
+
52
+ const registerSlot = _react.default.useCallback((name, contents) => {
53
+ slotsRef.current[name] = contents; // don't render until the component mounts = all slots are registered
54
+
55
+ if (isMounted) rerenderWithSlots();
56
+ }, [isMounted, rerenderWithSlots]); // Slot can be removed from the tree as well,
57
+ // we need to unregister them from the slot
58
+
59
+
60
+ const unregisterSlot = _react.default.useCallback(name => {
61
+ slotsRef.current[name] = null;
62
+ rerenderWithSlots();
63
+ }, [rerenderWithSlots]);
64
+ /**
65
+ * Slots uses a render prop API so abstract the
66
+ * implementation detail of using a context provider.
67
+ */
68
+
69
+
70
+ const slots = slotsRef.current;
71
+ return /*#__PURE__*/_react.default.createElement(SlotsContext.Provider, {
72
+ value: {
73
+ registerSlot,
74
+ unregisterSlot,
75
+ context
76
+ }
77
+ }, children(slots));
78
+ };
79
+
80
+ const Slot = ({
81
+ name,
82
+ children
83
+ }) => {
84
+ const {
85
+ registerSlot,
86
+ unregisterSlot,
87
+ context
88
+ } = _react.default.useContext(SlotsContext);
89
+
90
+ _react.default.useEffect(() => {
91
+ registerSlot(name, typeof children === 'function' ? children(context) : children);
92
+ return () => unregisterSlot(name);
93
+ }, [name, children, registerSlot, unregisterSlot, context]);
94
+
95
+ return null;
96
+ };
97
+
98
+ return {
99
+ Slots,
100
+ Slot
101
+ };
102
+ };
103
+
104
+ var _default = createSlots;
105
+ exports.default = _default;
@@ -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,3 @@
1
+ export declare type KeyPaths<O extends Record<string, unknown>> = {
2
+ [K in keyof O]: K extends string ? O[K] extends string ? `${K}` : `${K}.${KeyPaths<O[K]>}` : never;
3
+ }[keyof O];
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ export declare const useForceUpdate: () => () => void;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useForceUpdate = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ // Inspired from reach-ui: https://github.com/reach/reach-ui/blob/develop/packages/utils/src/use-force-update.ts
13
+ const useForceUpdate = () => {
14
+ const [, rerender] = _react.default.useState({});
15
+
16
+ return _react.default.useCallback(() => rerender({}), []);
17
+ };
18
+
19
+ exports.useForceUpdate = useForceUpdate;
@@ -28,6 +28,6 @@ export function Header({
28
28
  return /*#__PURE__*/React.createElement(StyledHeader, _extends({
29
29
  role: "heading",
30
30
  variant: variant
31
- }, props), title, auxiliaryText && /*#__PURE__*/React.createElement("span", null, "auxiliaryText"));
31
+ }, props), title, auxiliaryText && /*#__PURE__*/React.createElement("span", null, auxiliaryText));
32
32
  }
33
33
  Header.displayName = "Header";
@@ -28,13 +28,19 @@ export interface ItemProps extends SxProp {
28
28
  */
29
29
  leadingVisual?: React.FunctionComponent<IconProps>;
30
30
  /**
31
+ * @deprecated Use `trailingVisual` instead
31
32
  * Icon (or similar) positioned after `Item` text.
32
33
  */
33
34
  trailingIcon?: React.FunctionComponent<IconProps>;
34
35
  /**
36
+ * @deprecated Use `trailingVisual` instead
35
37
  * Text positioned after `Item` text and optional trailing icon.
36
38
  */
37
39
  trailingText?: string;
40
+ /**
41
+ * Icon or text positioned after `Item` text.
42
+ */
43
+ trailingVisual?: React.ReactNode;
38
44
  /**
39
45
  * Style variations associated with various `Item` types.
40
46
  *
@@ -154,6 +154,7 @@ export const Item = /*#__PURE__*/React.forwardRef((itemProps, ref) => {
154
154
  selectionVariant,
155
155
  leadingVisual: LeadingVisual,
156
156
  trailingIcon: TrailingIcon,
157
+ trailingVisual: TrailingVisual,
157
158
  trailingText,
158
159
  variant = 'default',
159
160
  showDivider,
@@ -245,7 +246,10 @@ export const Item = /*#__PURE__*/React.forwardRef((itemProps, ref) => {
245
246
  title: description,
246
247
  inline: true,
247
248
  maxWidth: "100%"
248
- }, description)) : null), TrailingIcon || trailingText ? /*#__PURE__*/React.createElement(TrailingContent, {
249
+ }, description)) : null), TrailingVisual ? /*#__PURE__*/React.createElement(TrailingContent, {
250
+ variant: variant,
251
+ disabled: disabled
252
+ }, typeof TrailingVisual === 'function' ? /*#__PURE__*/React.createElement(TrailingVisual, null) : TrailingVisual) : TrailingIcon || trailingText ? /*#__PURE__*/React.createElement(TrailingContent, {
249
253
  variant: variant,
250
254
  disabled: disabled
251
255
  }, trailingText, TrailingIcon && /*#__PURE__*/React.createElement(TrailingIcon, null)) : null));
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { SxProp } from '../sx';
3
+ export declare type DescriptionProps = {
4
+ /**
5
+ * Secondary text style variations.
6
+ *
7
+ * - `"inline"` - Secondary text is positioned beside primary text.
8
+ * - `"block"` - Secondary text is positioned below primary text.
9
+ */
10
+ variant?: 'inline' | 'block';
11
+ } & SxProp;
12
+ export declare const Description: React.FC<DescriptionProps>;
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import Box from '../Box';
3
+ import { merge } from '../sx';
4
+ import Truncate from '../Truncate';
5
+ import { Slot } from './Item';
6
+ export const Description = ({
7
+ variant = 'inline',
8
+ sx = {},
9
+ ...props
10
+ }) => {
11
+ const styles = {
12
+ color: 'fg.muted',
13
+ fontSize: 0,
14
+ lineHeight: '16px',
15
+ flexGrow: 1,
16
+ flexBasis: 0,
17
+ minWidth: 0,
18
+ marginLeft: variant === 'block' ? 0 : 2
19
+ };
20
+ return /*#__PURE__*/React.createElement(Slot, {
21
+ name: variant === 'block' ? 'BlockDescription' : 'InlineDescription'
22
+ }, ({
23
+ blockDescriptionId,
24
+ inlineDescriptionId
25
+ }) => variant === 'block' ? /*#__PURE__*/React.createElement(Box, {
26
+ as: "span",
27
+ sx: merge(styles, sx),
28
+ id: blockDescriptionId
29
+ }, props.children) : /*#__PURE__*/React.createElement(Truncate, {
30
+ id: inlineDescriptionId,
31
+ sx: merge(styles, sx),
32
+ title: props.children,
33
+ inline: true,
34
+ maxWidth: "100%"
35
+ }, props.children));
36
+ };
37
+ Description.displayName = "Description";
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * Visually separates `Item`s or `Group`s in an `ActionList`.
4
+ */
5
+ export declare function Divider(): JSX.Element;
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import Box from '../Box';
3
+ import { get } from '../constants';
4
+
5
+ /**
6
+ * Visually separates `Item`s or `Group`s in an `ActionList`.
7
+ */
8
+ export function Divider() {
9
+ return /*#__PURE__*/React.createElement(Box, {
10
+ as: "li",
11
+ role: "separator",
12
+ sx: {
13
+ height: 1,
14
+ backgroundColor: 'actionListItem.inlineDivider',
15
+ marginTop: theme => `calc(${get('space.2')(theme)} - 1px)`,
16
+ marginBottom: 2,
17
+ listStyle: 'none' // hide the ::marker inserted by browser's stylesheet
18
+
19
+ },
20
+ "data-component": "ActionList.Divider"
21
+ });
22
+ }
23
+ Divider.displayName = "Divider";
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { SxProp } from '../sx';
3
+ import { HeaderProps } from './Header';
4
+ import { ListProps } from './List';
5
+ export declare type GroupProps = HeaderProps & SxProp & {
6
+ selectionVariant?: ListProps['selectionVariant'] | false;
7
+ };
8
+ declare type ContextProps = Pick<GroupProps, 'selectionVariant'>;
9
+ export declare const GroupContext: React.Context<ContextProps>;
10
+ export declare const Group: React.FC<GroupProps>;
11
+ export {};
@@ -0,0 +1,40 @@
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
+
3
+ import React from 'react';
4
+ import Box from '../Box';
5
+ import { Header } from './Header';
6
+ export const GroupContext = /*#__PURE__*/React.createContext({});
7
+ export const Group = ({
8
+ title,
9
+ variant,
10
+ auxiliaryText,
11
+ selectionVariant,
12
+ sx = {},
13
+ ...props
14
+ }) => {
15
+ return /*#__PURE__*/React.createElement(Box, _extends({
16
+ as: "li",
17
+ sx: {
18
+ '&:not(:first-child)': {
19
+ marginTop: 2
20
+ },
21
+ listStyle: 'none',
22
+ // hide the ::marker inserted by browser's stylesheet
23
+ ...sx
24
+ }
25
+ }, props), title && /*#__PURE__*/React.createElement(Header, {
26
+ title: title,
27
+ variant: variant,
28
+ auxiliaryText: auxiliaryText
29
+ }), /*#__PURE__*/React.createElement(GroupContext.Provider, {
30
+ value: {
31
+ selectionVariant
32
+ }
33
+ }, /*#__PURE__*/React.createElement(Box, {
34
+ as: "ul",
35
+ sx: {
36
+ paddingInlineStart: 0
37
+ }
38
+ }, props.children)));
39
+ };
40
+ Group.displayName = "Group";
@@ -0,0 +1,26 @@
1
+ /// <reference types="react" />
2
+ import { SxProp } from '../sx';
3
+ /**
4
+ * Contract for props passed to the `Header` component.
5
+ */
6
+ export declare type HeaderProps = {
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
+ } & SxProp;
23
+ /**
24
+ * Displays the name and description of a `Group`.
25
+ */
26
+ export declare const Header: ({ variant, title, auxiliaryText, sx, ...props }: HeaderProps) => JSX.Element;
@@ -0,0 +1,44 @@
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
+
3
+ import React from 'react';
4
+ import Box from '../Box';
5
+ import { ListContext } from './List';
6
+ /**
7
+ * Contract for props passed to the `Header` component.
8
+ */
9
+
10
+ /**
11
+ * Displays the name and description of a `Group`.
12
+ */
13
+ export const Header = ({
14
+ variant = 'subtle',
15
+ title,
16
+ auxiliaryText,
17
+ sx = {},
18
+ ...props
19
+ }) => {
20
+ const {
21
+ variant: listVariant
22
+ } = React.useContext(ListContext);
23
+ const styles = {
24
+ paddingY: '6px',
25
+ paddingX: listVariant === 'full' ? 2 : 3,
26
+ fontSize: 0,
27
+ fontWeight: 'bold',
28
+ color: 'fg.muted',
29
+ ...(variant === 'filled' && {
30
+ backgroundColor: 'canvas.subtle',
31
+ marginX: 0,
32
+ marginBottom: 2,
33
+ borderTop: '1px solid',
34
+ borderBottom: '1px solid',
35
+ borderColor: 'neutral.muted'
36
+ }),
37
+ ...sx
38
+ };
39
+ return /*#__PURE__*/React.createElement(Box, _extends({
40
+ sx: styles,
41
+ role: "heading"
42
+ }, props), title, auxiliaryText && /*#__PURE__*/React.createElement("span", null, auxiliaryText));
43
+ };
44
+ Header.displayName = "Header";