@primer/components 0.0.0-202111194229 → 0.0.0-2021112133435

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 (54) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/dist/browser.esm.js +191 -203
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +190 -202
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList2/Divider.d.ts +3 -2
  7. package/lib/ActionList2/Divider.js +10 -5
  8. package/lib/ActionList2/Item.js +21 -5
  9. package/lib/ActionList2/List.js +11 -1
  10. package/lib/ActionList2/MenuContext.d.ts +10 -0
  11. package/lib/ActionList2/MenuContext.js +15 -0
  12. package/lib/ActionList2/Selection.js +11 -0
  13. package/lib/ActionList2/index.d.ts +1 -2
  14. package/lib/ActionMenu2.d.ts +310 -0
  15. package/lib/ActionMenu2.js +91 -0
  16. package/lib/Autocomplete/Autocomplete.d.ts +2 -10
  17. package/lib/Autocomplete/AutocompleteInput.d.ts +2 -10
  18. package/lib/Radio.d.ts +38 -0
  19. package/lib/Radio.js +55 -0
  20. package/lib/SelectMenu/SelectMenu.d.ts +2 -10
  21. package/lib/TextInput.d.ts +1 -8
  22. package/lib/TextInput.js +5 -16
  23. package/lib/TextInputWithTokens.d.ts +2 -10
  24. package/lib/_TextInputWrapper.d.ts +0 -3
  25. package/lib/_TextInputWrapper.js +7 -18
  26. package/lib/drafts.d.ts +1 -0
  27. package/lib/drafts.js +13 -0
  28. package/lib/index.d.ts +2 -0
  29. package/lib/index.js +8 -0
  30. package/lib-esm/ActionList2/Divider.d.ts +3 -2
  31. package/lib-esm/ActionList2/Divider.js +8 -5
  32. package/lib-esm/ActionList2/Item.js +19 -5
  33. package/lib-esm/ActionList2/List.js +9 -1
  34. package/lib-esm/ActionList2/MenuContext.d.ts +10 -0
  35. package/lib-esm/ActionList2/MenuContext.js +3 -0
  36. package/lib-esm/ActionList2/Selection.js +9 -0
  37. package/lib-esm/ActionList2/index.d.ts +1 -2
  38. package/lib-esm/ActionMenu2.d.ts +310 -0
  39. package/lib-esm/ActionMenu2.js +67 -0
  40. package/lib-esm/Autocomplete/Autocomplete.d.ts +2 -10
  41. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +2 -10
  42. package/lib-esm/Radio.d.ts +38 -0
  43. package/lib-esm/Radio.js +40 -0
  44. package/lib-esm/SelectMenu/SelectMenu.d.ts +2 -10
  45. package/lib-esm/TextInput.d.ts +1 -8
  46. package/lib-esm/TextInput.js +5 -16
  47. package/lib-esm/TextInputWithTokens.d.ts +2 -10
  48. package/lib-esm/_TextInputWrapper.d.ts +0 -3
  49. package/lib-esm/_TextInputWrapper.js +7 -18
  50. package/lib-esm/drafts.d.ts +1 -0
  51. package/lib-esm/drafts.js +2 -1
  52. package/lib-esm/index.d.ts +2 -0
  53. package/lib-esm/index.js +1 -0
  54. package/package.json +3 -1
@@ -7,21 +7,16 @@ import TextInputWrapper from './_TextInputWrapper';
7
7
  // using forwardRef is important so that other components (ex. SelectMenu) can autofocus the input
8
8
  const TextInput = /*#__PURE__*/React.forwardRef(({
9
9
  icon: IconComponent,
10
- leadingVisual: LeadingVisual,
11
- trailingVisual: TrailingVisual,
12
10
  block,
13
11
  className,
14
12
  contrast,
15
13
  disabled,
16
- validationStatus,
17
14
  sx: sxProp,
18
- size: sizeProp,
19
- // start deprecated props
15
+ theme,
20
16
  width: widthProp,
21
17
  minWidth: minWidthProp,
22
18
  maxWidth: maxWidthProp,
23
19
  variant: variantProp,
24
- // end deprecated props
25
20
  ...inputProps
26
21
  }, ref) => {
27
22
  // this class is necessary to style FilterSearch, plz no touchy!
@@ -29,27 +24,21 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
29
24
  return /*#__PURE__*/React.createElement(TextInputWrapper, {
30
25
  block: block,
31
26
  className: wrapperClasses,
32
- validationStatus: validationStatus,
33
27
  contrast: contrast,
34
28
  disabled: disabled,
29
+ hasIcon: !!IconComponent,
35
30
  sx: sxProp,
36
- size: sizeProp,
31
+ theme: theme,
37
32
  width: widthProp,
38
33
  minWidth: minWidthProp,
39
34
  maxWidth: maxWidthProp,
40
35
  variant: variantProp
41
36
  }, IconComponent && /*#__PURE__*/React.createElement(IconComponent, {
42
37
  className: "TextInput-icon"
43
- }), LeadingVisual && /*#__PURE__*/React.createElement("span", {
44
- "data-component": "leadingVisual"
45
- }, typeof LeadingVisual === 'function' ? /*#__PURE__*/React.createElement(LeadingVisual, null) : LeadingVisual), /*#__PURE__*/React.createElement(UnstyledTextInput, _extends({
38
+ }), /*#__PURE__*/React.createElement(UnstyledTextInput, _extends({
46
39
  ref: ref,
47
40
  disabled: disabled
48
- }, inputProps, {
49
- "data-component": "input"
50
- })), TrailingVisual && /*#__PURE__*/React.createElement("span", {
51
- "data-component": "leadingVisual"
52
- }, typeof TrailingVisual === 'function' ? /*#__PURE__*/React.createElement(TrailingVisual, null) : TrailingVisual));
41
+ }, inputProps)));
53
42
  });
54
43
  TextInput.defaultProps = {
55
44
  type: 'text'
@@ -44,17 +44,11 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
44
44
  } & {
45
45
  as?: string | React.ComponentType<any> | undefined;
46
46
  forwardedAs?: string | React.ComponentType<any> | undefined;
47
- }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "size" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "leadingVisual" | "trailingVisual" | "contrast"> & {
47
+ }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "contrast"> & {
48
48
  className?: string | undefined;
49
49
  icon?: React.ComponentType<{
50
50
  className?: string | undefined;
51
51
  }> | undefined;
52
- leadingVisual?: string | React.ComponentType<{
53
- className?: string | undefined;
54
- }> | undefined;
55
- trailingVisual?: string | React.ComponentType<{
56
- className?: string | undefined;
57
- }> | undefined;
58
52
  } & Pick<{
59
53
  color?: string | undefined;
60
54
  maxWidth?: import("styled-system").ResponsiveValue<import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
@@ -67,7 +61,6 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
67
61
  slot?: string | undefined;
68
62
  style?: React.CSSProperties | undefined;
69
63
  title?: string | undefined;
70
- size?: "small" | "large" | undefined;
71
64
  block?: boolean | undefined;
72
65
  variant?: "small" | "large" | undefined;
73
66
  role?: React.AriaRole | undefined;
@@ -325,10 +318,9 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
325
318
  disabled?: boolean | undefined;
326
319
  hasIcon?: boolean | undefined;
327
320
  contrast?: boolean | undefined;
328
- validationStatus?: "error" | "warning" | undefined;
329
321
  } & {
330
322
  theme?: any;
331
- }, "maxWidth" | "minWidth" | "width" | "size" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement> & {
323
+ }, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement> & {
332
324
  selectedTokenIndex: number | undefined;
333
325
  setSelectedTokenIndex: React.Dispatch<React.SetStateAction<number | undefined>>;
334
326
  }, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
@@ -5,9 +5,6 @@ declare const TextInputWrapper: import("styled-components").StyledComponent<"spa
5
5
  hasIcon?: boolean | undefined;
6
6
  block?: boolean | undefined;
7
7
  contrast?: boolean | undefined;
8
- validationStatus?: "error" | "warning" | undefined;
9
- /** @deprecated Use `size` prop instead */
10
8
  variant?: "small" | "large" | undefined;
11
- size?: "small" | "large" | undefined;
12
9
  } & 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>;
13
10
  export default TextInputWrapper;
@@ -2,24 +2,7 @@ import styled, { css } from 'styled-components';
2
2
  import { maxWidth, minWidth, variant, width } from 'styled-system';
3
3
  import { get } from './constants';
4
4
  import sx from './sx';
5
- const sizeDeprecatedVariants = variant({
6
- variants: {
7
- small: {
8
- minHeight: '28px',
9
- px: 2,
10
- py: '3px',
11
- fontSize: 0,
12
- lineHeight: '20px'
13
- },
14
- large: {
15
- px: 2,
16
- py: '10px',
17
- fontSize: 3
18
- }
19
- }
20
- });
21
5
  const sizeVariants = variant({
22
- prop: 'size',
23
6
  variants: {
24
7
  small: {
25
8
  minHeight: '28px',
@@ -38,5 +21,11 @@ const sizeVariants = variant({
38
21
  const TextInputWrapper = styled.span.withConfig({
39
22
  displayName: "_TextInputWrapper__TextInputWrapper",
40
23
  componentId: "sc-5vfcis-0"
41
- })(["width:max-content;min-height:34px;font-size:", ";line-height:20px;color:", ";vertical-align:middle;background-color:", ";background-repeat:no-repeat;background-position:right 8px center;border:1px solid ", ";border-radius:", ";outline:none;box-shadow:", ";cursor:text;padding:6px 12px;display:grid;grid-template-columns:auto 1fr auto;justify-items:end;& >:not(:last-child){margin-right:", ";}[data-component=' leadingVisual ']{align-self:center;color:", ";}[data-component=' trailingVisual ']{align-self:center;color:", ";}.TextInput-icon{align-self:center;color:", ";margin:0 ", ";flex-shrink:0;}&:focus-within{border-color:", ";box-shadow:", ";}", " ", " ", " ", " ", " @media (min-width:", "){font-size:", ";}", " ", " ", " ", " ", " ", ";"], get('fontSizes.1'), get('colors.fg.default'), get('colors.canvas.default'), get('colors.border.default'), get('radii.2'), get('shadows.primer.shadow.inset'), get('space.2'), get('colors.fg.muted'), get('colors.fg.muted'), get('colors.fg.muted'), get('space.2'), get('colors.accent.emphasis'), get('shadows.primer.shadow.focus'), props => props.contrast && css(["background-color:", ";"], get('colors.canvas.inset')), props => props.disabled && css(["color:", ";background-color:", ";border-color:", ";"], get('colors.primer.fg.disabled'), get('colors.input.disabledBg'), get('colors.border.default')), props => props.validationStatus === 'error' && css(["border-color:", ";&:focus-within{border-color:", ";box-shadow:", ";}"], get('colors.danger.emphasis'), get('colors.danger.emphasis'), get('shadows.btn.danger.focusShadow')), props => props.validationStatus === 'warning' && css(["border-color:", ";&:focus-within{border-color:", ";box-shadow:0 0 0 3px ", ";}"], get('colors.attention.emphasis'), get('colors.attention.emphasis'), get('colors.attention.muted')), props => props.block && css(["width:100%;"]), get('breakpoints.1'), get('fontSizes.1'), width, minWidth, maxWidth, sizeDeprecatedVariants, sizeVariants, sx);
24
+ })(["display:inline-flex;align-items:stretch;min-height:34px;font-size:", ";line-height:20px;color:", ";vertical-align:middle;background-repeat:no-repeat;background-position:right 8px center;border:1px solid ", ";border-radius:", ";outline:none;box-shadow:", ";cursor:text;", " .TextInput-icon{align-self:center;color:", ";margin:0 ", ";flex-shrink:0;}&:focus-within{border-color:", ";box-shadow:", ";}", " ", " ", " ", " @media (min-width:", "){font-size:", ";}", " ", " ", " ", " ", ";"], get('fontSizes.1'), get('colors.fg.default'), get('colors.border.default'), get('radii.2'), get('shadows.primer.shadow.inset'), props => {
25
+ if (props.hasIcon) {
26
+ return css(["padding:0;"]);
27
+ } else {
28
+ return css(["padding:6px 12px;"]);
29
+ }
30
+ }, get('colors.fg.muted'), get('space.2'), get('colors.accent.emphasis'), get('shadows.primer.shadow.focus'), props => props.contrast && css(["background-color:", ";"], get('colors.canvas.inset')), props => props.disabled && css(["color:", ";background-color:", ";border-color:", ";"], get('colors.primer.fg.disabled'), get('colors.input.disabledBg'), get('colors.border.default')), props => props.block && css(["display:block;width:100%;"]), props => props.block && props.hasIcon && css(["display:flex;"]), get('breakpoints.1'), get('fontSizes.1'), width, minWidth, maxWidth, sizeVariants, sx);
42
31
  export default TextInputWrapper;
@@ -6,3 +6,4 @@
6
6
  */
7
7
  export * from './ActionList2';
8
8
  export * from './NewButton';
9
+ export * from './ActionMenu2';
package/lib-esm/drafts.js CHANGED
@@ -6,4 +6,5 @@
6
6
  */
7
7
  // Components
8
8
  export * from './ActionList2';
9
- export * from './NewButton';
9
+ export * from './NewButton';
10
+ export * from './ActionMenu2';
@@ -21,6 +21,8 @@ export { useOpenAndCloseFocus } from './hooks/useOpenAndCloseFocus';
21
21
  export { useOnEscapePress } from './hooks/useOnEscapePress';
22
22
  export { useOverlay } from './hooks/useOverlay';
23
23
  export { useConfirm } from './Dialog/ConfirmationDialog';
24
+ export { default as Radio } from './Radio';
25
+ export type { RadioProps } from './Radio';
24
26
  export { ActionList } from './ActionList';
25
27
  export { ActionMenu } from './ActionMenu';
26
28
  export type { ActionMenuProps } from './ActionMenu';
package/lib-esm/index.js CHANGED
@@ -17,6 +17,7 @@ export { useOnEscapePress } from './hooks/useOnEscapePress';
17
17
  export { useOverlay } from './hooks/useOverlay';
18
18
  export { useConfirm } from './Dialog/ConfirmationDialog'; // Components
19
19
 
20
+ export { default as Radio } from './Radio';
20
21
  export { ActionList } from './ActionList';
21
22
  export { ActionMenu } from './ActionMenu';
22
23
  export { default as Autocomplete } from './Autocomplete';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/components",
3
- "version": "0.0.0-202111194229",
3
+ "version": "0.0.0-2021112133435",
4
4
  "description": "Primer react components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-esm/index.js",
@@ -91,6 +91,7 @@
91
91
  "@types/jest-axe": "3.5.3",
92
92
  "@types/lodash.isempty": "4.4.6",
93
93
  "@types/lodash.isobject": "3.0.6",
94
+ "@types/node": "16.11.11",
94
95
  "@typescript-eslint/eslint-plugin": "4.31.2",
95
96
  "@typescript-eslint/parser": "4.26.1",
96
97
  "@wojtekmaj/enzyme-adapter-react-17": "0.6.3",
@@ -116,6 +117,7 @@
116
117
  "eslint-plugin-primer-react": "0.7.0",
117
118
  "eslint-plugin-react": "7.24.0",
118
119
  "eslint-plugin-react-hooks": "4.2.0",
120
+ "front-matter": "4.0.2",
119
121
  "jest": "27.0.4",
120
122
  "jest-axe": "5.0.1",
121
123
  "jest-styled-components": "6.3.4",