@primer/components 0.0.0-2021919182815 → 0.0.0-2021919184749

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 (64) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/browser.esm.js +605 -604
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +175 -174
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/TextInputWithTokens.d.ts +4 -0
  7. package/lib/TextInputWithTokens.js +61 -8
  8. package/lib/_TextInputWrapper.js +1 -1
  9. package/lib/index.d.ts +0 -1
  10. package/lib/index.js +0 -8
  11. package/lib-esm/TextInputWithTokens.d.ts +4 -0
  12. package/lib-esm/TextInputWithTokens.js +61 -9
  13. package/lib-esm/_TextInputWrapper.js +1 -1
  14. package/lib-esm/index.d.ts +0 -1
  15. package/lib-esm/index.js +0 -1
  16. package/package.json +1 -1
  17. package/lib/ActionList2/Description.d.ts +0 -5
  18. package/lib/ActionList2/Description.js +0 -45
  19. package/lib/ActionList2/Divider.d.ts +0 -8
  20. package/lib/ActionList2/Divider.js +0 -42
  21. package/lib/ActionList2/Group.d.ts +0 -8
  22. package/lib/ActionList2/Group.js +0 -39
  23. package/lib/ActionList2/Header.d.ts +0 -26
  24. package/lib/ActionList2/Header.js +0 -55
  25. package/lib/ActionList2/Item.d.ts +0 -52
  26. package/lib/ActionList2/Item.js +0 -171
  27. package/lib/ActionList2/List.d.ts +0 -18
  28. package/lib/ActionList2/List.js +0 -52
  29. package/lib/ActionList2/Selection.d.ts +0 -5
  30. package/lib/ActionList2/Selection.js +0 -67
  31. package/lib/ActionList2/Visuals.d.ts +0 -12
  32. package/lib/ActionList2/Visuals.js +0 -87
  33. package/lib/ActionList2/hacks.d.ts +0 -30
  34. package/lib/ActionList2/hacks.js +0 -38
  35. package/lib/ActionList2/index.d.ts +0 -26
  36. package/lib/ActionList2/index.js +0 -36
  37. package/lib/utils/create-slots.d.ts +0 -15
  38. package/lib/utils/create-slots.js +0 -101
  39. package/lib/utils/use-force-update.d.ts +0 -1
  40. package/lib/utils/use-force-update.js +0 -19
  41. package/lib-esm/ActionList2/Description.d.ts +0 -5
  42. package/lib-esm/ActionList2/Description.js +0 -30
  43. package/lib-esm/ActionList2/Divider.d.ts +0 -8
  44. package/lib-esm/ActionList2/Divider.js +0 -30
  45. package/lib-esm/ActionList2/Group.d.ts +0 -8
  46. package/lib-esm/ActionList2/Group.js +0 -29
  47. package/lib-esm/ActionList2/Header.d.ts +0 -26
  48. package/lib-esm/ActionList2/Header.js +0 -45
  49. package/lib-esm/ActionList2/Item.d.ts +0 -52
  50. package/lib-esm/ActionList2/Item.js +0 -172
  51. package/lib-esm/ActionList2/List.d.ts +0 -18
  52. package/lib-esm/ActionList2/List.js +0 -42
  53. package/lib-esm/ActionList2/Selection.d.ts +0 -5
  54. package/lib-esm/ActionList2/Selection.js +0 -50
  55. package/lib-esm/ActionList2/Visuals.d.ts +0 -12
  56. package/lib-esm/ActionList2/Visuals.js +0 -66
  57. package/lib-esm/ActionList2/hacks.d.ts +0 -30
  58. package/lib-esm/ActionList2/hacks.js +0 -30
  59. package/lib-esm/ActionList2/index.d.ts +0 -26
  60. package/lib-esm/ActionList2/index.js +0 -23
  61. package/lib-esm/utils/create-slots.d.ts +0 -15
  62. package/lib-esm/utils/create-slots.js +0 -80
  63. package/lib-esm/utils/use-force-update.d.ts +0 -1
  64. package/lib-esm/utils/use-force-update.js +0 -6
@@ -1,66 +0,0 @@
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 { get } from '../constants';
6
- import { getVariantStyles, Slot } from './Item';
7
- export const LeadingVisualContainer = ({
8
- sx = {},
9
- ...props
10
- }) => {
11
- return /*#__PURE__*/React.createElement(Box, _extends({
12
- as: "span",
13
- sx: {
14
- height: '20px',
15
- // match height of text row
16
- minWidth: get('space.3'),
17
- maxWidth: '20px',
18
- // square (same as height)
19
- display: 'flex',
20
- justifyContent: 'center',
21
- alignItems: 'center',
22
- flexShrink: 0,
23
- marginRight: 2,
24
- ...sx
25
- }
26
- }, props));
27
- };
28
- LeadingVisualContainer.displayName = "LeadingVisualContainer";
29
- export const LeadingVisual = ({
30
- variant,
31
- disabled,
32
- sx = {},
33
- ...props
34
- }) => {
35
- return /*#__PURE__*/React.createElement(Slot, {
36
- name: "LeadingVisual"
37
- }, /*#__PURE__*/React.createElement(LeadingVisualContainer, _extends({
38
- sx: {
39
- color: getVariantStyles(variant, disabled).iconColor,
40
- svg: {
41
- fontSize: 0
42
- },
43
- ...sx
44
- }
45
- }, props), props.children));
46
- };
47
- LeadingVisual.displayName = "LeadingVisual";
48
- export const TrailingVisual = ({
49
- variant,
50
- disabled,
51
- ...props
52
- }) => {
53
- return /*#__PURE__*/React.createElement(Slot, {
54
- name: "TrailingVisual"
55
- }, /*#__PURE__*/React.createElement(Box, _extends({
56
- as: "span",
57
- sx: {
58
- height: '20px',
59
- // match height of text row
60
- flexShrink: 0,
61
- color: getVariantStyles(variant, disabled).annotationColor,
62
- marginLeft: 2
63
- }
64
- }, props), props.children));
65
- };
66
- TrailingVisual.displayName = "TrailingVisual";
@@ -1,30 +0,0 @@
1
- /**
2
- * These colors are not yet in our default theme.
3
- * TODO: Need to remove this once they are added.
4
- */
5
- export declare const customItemThemes: {
6
- default: {
7
- hover: {
8
- light: string;
9
- dark: string;
10
- dark_dimmed: string;
11
- };
12
- focus: {
13
- light: string;
14
- dark: string;
15
- dark_dimmed: string;
16
- };
17
- };
18
- danger: {
19
- hover: {
20
- light: string;
21
- dark: string;
22
- dark_dimmed: string;
23
- };
24
- focus: {
25
- light: string;
26
- dark: string;
27
- dark_dimmed: string;
28
- };
29
- };
30
- };
@@ -1,30 +0,0 @@
1
- /**
2
- * These colors are not yet in our default theme.
3
- * TODO: Need to remove this once they are added.
4
- */
5
- export const customItemThemes = {
6
- default: {
7
- hover: {
8
- light: 'rgba(46, 77, 108, 0.06)',
9
- dark: 'rgba(201, 206, 212, 0.12)',
10
- dark_dimmed: 'rgba(201, 206, 212, 0.12)'
11
- },
12
- focus: {
13
- light: 'rgba(54, 77, 100, 0.16)',
14
- dark: 'rgba(201, 206, 212, 0.24)',
15
- dark_dimmed: 'rgba(201, 206, 212, 0.24)'
16
- }
17
- },
18
- danger: {
19
- hover: {
20
- light: 'rgba(234, 74, 90, 0.08)',
21
- dark: 'rgba(248, 81, 73, 0.16)',
22
- dark_dimmed: 'rgba(248, 81, 73, 0.16)'
23
- },
24
- focus: {
25
- light: 'rgba(234, 74, 90, 0.14)',
26
- dark: 'rgba(248, 81, 73, 0.24)',
27
- dark_dimmed: 'rgba(248, 81, 73, 0.24)'
28
- }
29
- }
30
- };
@@ -1,26 +0,0 @@
1
- /// <reference types="react" />
2
- import { Group } from './Group';
3
- import { Divider } from './Divider';
4
- export type { ListProps as ActionListProps } from './List';
5
- export type { GroupProps } from './Group';
6
- export type { ItemProps } from './Item';
7
- export type { DescriptionProps } from './Description';
8
- export type { LeadingVisualProps, TrailingVisualProps } from './Visuals';
9
- /**
10
- * Collection of list-related components.
11
- */
12
- export declare const ActionList: import("@radix-ui/react-polymorphic").ForwardRefComponent<"ul", import("./List").ListProps> & {
13
- /** Collects related `Items` in an `ActionList`. */
14
- Group: typeof Group;
15
- /** An actionable or selectable `Item` with an optional icon and description. */
16
- Item: import("@radix-ui/react-polymorphic").ForwardRefComponent<"li", import("./Item").ItemProps>;
17
- /** Visually separates `Item`s or `Group`s in an `ActionList`. */
18
- Divider: typeof Divider;
19
- Description: import("react").FC<import("./Description").DescriptionProps>;
20
- LeadingVisual: import("react").FC<Pick<import("./Item").ItemProps, "sx" | "disabled" | "variant"> & {
21
- children: import("react").ReactNode;
22
- }>;
23
- TrailingVisual: import("react").FC<Pick<import("./Item").ItemProps, "sx" | "disabled" | "variant"> & {
24
- children: import("react").ReactNode;
25
- }>;
26
- };
@@ -1,23 +0,0 @@
1
- import { List } from './List';
2
- import { Group } from './Group';
3
- import { Item } from './Item';
4
- import { Divider } from './Divider';
5
- import { Description } from './Description';
6
- import { LeadingVisual, TrailingVisual } from './Visuals';
7
-
8
- /**
9
- * Collection of list-related components.
10
- */
11
- export const ActionList = Object.assign(List, {
12
- /** Collects related `Items` in an `ActionList`. */
13
- Group,
14
-
15
- /** An actionable or selectable `Item` with an optional icon and description. */
16
- Item,
17
-
18
- /** Visually separates `Item`s or `Group`s in an `ActionList`. */
19
- Divider,
20
- Description,
21
- LeadingVisual,
22
- TrailingVisual
23
- });
@@ -1,15 +0,0 @@
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
- children: (slots: { [key in SlotNames]?: React.ReactNode; }) => React.ReactNode;
10
- }>;
11
- Slot: React.FC<{
12
- name: SlotNames;
13
- }>;
14
- };
15
- export default createSlots;
@@ -1,80 +0,0 @@
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
- });
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
- const Slots = ({
21
- children
22
- }) => {
23
- // initialise slots
24
- const slotsDefinition = {};
25
- slotNames.map(name => slotsDefinition[name] = null);
26
- const slotsRef = React.useRef(slotsDefinition);
27
- const rerenderWithSlots = useForceUpdate();
28
- const [isMounted, setIsMounted] = React.useState(false); // fires after all the effects in children
29
-
30
- React.useEffect(() => {
31
- rerenderWithSlots();
32
- setIsMounted(true);
33
- }, [rerenderWithSlots]);
34
- const slots = slotsRef.current;
35
- const registerSlot = React.useCallback((name, contents) => {
36
- slotsRef.current[name] = contents; // don't render until the component mounts = all slots are registered
37
-
38
- if (isMounted) rerenderWithSlots();
39
- }, [isMounted, rerenderWithSlots]); // Slot can be removed from the tree as well,
40
- // we need to unregister them from the slot
41
-
42
- const unregisterSlot = React.useCallback(name => {
43
- slotsRef.current[name] = null;
44
- rerenderWithSlots();
45
- }, [rerenderWithSlots]);
46
- /**
47
- * Slots uses a render prop API so abstract the
48
- * implementation detail of using a context provider.
49
- */
50
-
51
- return /*#__PURE__*/React.createElement(SlotsContext.Provider, {
52
- value: {
53
- registerSlot,
54
- unregisterSlot
55
- }
56
- }, children(slots));
57
- };
58
-
59
- const Slot = ({
60
- name,
61
- children
62
- }) => {
63
- const {
64
- registerSlot,
65
- unregisterSlot
66
- } = React.useContext(SlotsContext);
67
- React.useEffect(() => {
68
- registerSlot(name, children);
69
- return () => unregisterSlot(name);
70
- }, [name, children, registerSlot, unregisterSlot]);
71
- return null;
72
- };
73
-
74
- return {
75
- Slots,
76
- Slot
77
- };
78
- };
79
-
80
- export default createSlots;
@@ -1 +0,0 @@
1
- export declare const useForceUpdate: () => () => void;
@@ -1,6 +0,0 @@
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
- };