@splunk/react-ui 4.24.0 → 4.26.0

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 (50) hide show
  1. package/Breadcrumbs.js +65 -42
  2. package/Button.js +8 -7
  3. package/ButtonSimple.js +40 -39
  4. package/CHANGELOG.md +30 -1
  5. package/Code.js +193 -100
  6. package/Color.js +18 -15
  7. package/JSONTree.js +1 -1
  8. package/MIGRATION.mdx +48 -0
  9. package/Modal.js +69 -58
  10. package/RadioList.js +12 -11
  11. package/Table.js +2330 -2543
  12. package/TextArea.js +298 -302
  13. package/cypress/README.md +11 -0
  14. package/cypress/support/commands.ts +1 -0
  15. package/cypress/support/component.ts +0 -1
  16. package/cypress/tsconfig.cypress.json +14 -0
  17. package/package.json +13 -13
  18. package/types/src/Breadcrumbs/Breadcrumbs.d.ts +18 -2
  19. package/types/src/Breadcrumbs/Item.d.ts +7 -1
  20. package/types/src/Breadcrumbs/docs/examples/CustomizedClick.d.ts +2 -0
  21. package/types/src/Button/Button.d.ts +4 -2
  22. package/types/src/Button/docs/examples/Block.d.ts +2 -2
  23. package/types/src/Button/docs/examples/Dimmed.d.ts +2 -0
  24. package/types/src/Button/docs/examples/Disabled.d.ts +2 -2
  25. package/types/src/Button/docs/examples/Icons.d.ts +2 -2
  26. package/types/src/Button/docs/examples/Menus.d.ts +2 -2
  27. package/types/src/Button/docs/examples/To.d.ts +2 -2
  28. package/types/src/Button/docs/examples/Truncated.d.ts +2 -2
  29. package/types/src/Button/docs/examples/prisma/Basic.d.ts +2 -2
  30. package/types/src/Button/docs/examples/prisma/Block.d.ts +2 -2
  31. package/types/src/Button/docs/examples/prisma/Dimmed.d.ts +2 -0
  32. package/types/src/Button/docs/examples/prisma/Disabled.d.ts +2 -2
  33. package/types/src/Button/docs/examples/prisma/Menus.d.ts +2 -2
  34. package/types/src/Button/docs/examples/prisma/To.d.ts +2 -2
  35. package/types/src/Button/docs/examples/prisma/Truncated.d.ts +2 -2
  36. package/types/src/ButtonSimple/ButtonSimple.d.ts +4 -2
  37. package/types/src/Color/Color.d.ts +5 -3
  38. package/types/src/JSONTree/JSONTree.d.ts +1 -1
  39. package/types/src/Modal/Header.d.ts +6 -7
  40. package/types/src/Modal/Modal.d.ts +10 -2
  41. package/types/src/Modal/ModalContext.d.ts +1 -0
  42. package/types/src/RadioList/RadioList.d.ts +27 -27
  43. package/types/src/RadioList/RadioListContext.d.ts +5 -4
  44. package/types/src/Table/Body.d.ts +26 -22
  45. package/types/src/Table/Row.d.ts +47 -16
  46. package/types/src/Table/RowDragCell.d.ts +23 -42
  47. package/types/src/Table/Table.d.ts +28 -78
  48. package/types/src/TextArea/TextArea.d.ts +1 -0
  49. package/types/unit-test-setup-testing-library.d.ts +1 -0
  50. package/types/src/Modal/docs/examples/prisma/TypicalUsage.d.ts +0 -2
@@ -0,0 +1,11 @@
1
+ #TS Configuration
2
+
3
+ Cypress' expect type clashes with Jest's: see https://docs.cypress.io/guides/tooling/typescript-support#Clashing-types-with-Jest.
4
+ To get around this we use separate tsconfigs to check src files from Cypress tests (.spec.tsx) files, following [cypress' example](https://github.com/cypress-io/cypress-and-jest-typescript-example)
5
+
6
+ There are some notable specifics in the cypress config that need to be maintained:
7
+ * Cypress tests only need to be compiled but do not have public types, so this config sets `"noEmit": true,`
8
+ * When types are specified they must be relative paths to the tsconfig, hence the `../node_modules`.
9
+ * The inheritance method when using `extends` means that `include` and `exclude` entries need to be explicitly listed or repeated. This affects:
10
+ * Common types, jest and cypress types.
11
+ * `include` must be repeated in `cypress.tsconfig` so that `.spec` files are not excluded
@@ -1 +1,2 @@
1
1
  import '@testing-library/cypress/add-commands';
2
+ import 'cypress-real-events';
@@ -1,5 +1,4 @@
1
1
  import { mount } from 'cypress/react';
2
- import 'cypress-real-events';
3
2
  import { setGlobalConfig } from '@storybook/testing-react';
4
3
  import { configure } from '@testing-library/cypress';
5
4
 
@@ -0,0 +1,14 @@
1
+ // Cypress tests (.spec.tsx files) need a separate config to avoid clashing types with jest, see README for more details
2
+ {
3
+ "extends": "../tsconfig.json",
4
+ "compilerOptions": {
5
+ "noEmit": true,
6
+ "types": [
7
+ "../../../node_modules/@testing-library/cypress",
8
+ "../../../node_modules/cypress",
9
+ "../../../node_modules/cypress-real-events"
10
+ ]
11
+ },
12
+ "include": ["../stubs-*.d.ts", "../src/**/tests/*.spec.tsx", "../src/**/tests/*.spec.ts"],
13
+ "exclude": ["../src/docs/*"]
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splunk/react-ui",
3
- "version": "4.24.0",
3
+ "version": "4.26.0",
4
4
  "description": "Library of React components that implement the Splunk design language",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Splunk Inc.",
@@ -29,7 +29,8 @@
29
29
  "test:watch": "jest --watch",
30
30
  "test:cypress": "yarn cypress open --component",
31
31
  "test:cypress:ci": "yarn cypress run --component",
32
- "types:build": "tsc --emitDeclarationOnly --declaration --declarationDir ./types && node ./scripts/pruneTypes.js",
32
+ "types:build": "yarn types:build:cypress && tsc --emitDeclarationOnly --declaration --declarationDir ./types && node ./scripts/pruneTypes.js",
33
+ "types:build:cypress": "tsc --p cypress/tsconfig.cypress.json",
33
34
  "types:start": "yarn types:build --watch"
34
35
  },
35
36
  "peerDependencies": {
@@ -41,16 +42,9 @@
41
42
  "@dnd-kit/core": "6.0.8",
42
43
  "@dnd-kit/sortable": "7.0.2",
43
44
  "@dnd-kit/utilities": "3.2.1",
44
- "@splunk/react-icons": "^4.2.0",
45
+ "@splunk/react-icons": "^4.3.0",
45
46
  "@splunk/themes": "^0.16.4",
46
47
  "@splunk/ui-utils": "^1.6.0",
47
- "@types/commonmark": "^0.27.6",
48
- "@types/lodash": "^4.14.156",
49
- "@types/react": "^16.9.38",
50
- "@types/react-dom": "^16.9.8",
51
- "@types/react-resize-detector": "^3.1.1",
52
- "@types/styled-components": "^5.1.0",
53
- "@types/tinycolor2": "^1.4.2",
54
48
  "commonmark": "^0.30.0",
55
49
  "commonmark-react-renderer": "^4.3.2",
56
50
  "decimal.js-light": "^2.2.3",
@@ -86,11 +80,17 @@
86
80
  "@testing-library/react": "^12.1.2",
87
81
  "@testing-library/react-hooks": "^7.0.2",
88
82
  "@testing-library/user-event": "^14.4.3",
83
+ "@types/commonmark": "^0.27.6",
89
84
  "@types/jest": "^26.0.0",
90
- "@types/mocha": "^7.0.2",
85
+ "@types/lodash": "^4.14.156",
91
86
  "@types/node": "^10.17.26",
92
- "@types/prismjs": "^1.16.1",
87
+ "@types/prismjs": "^1.26.3",
88
+ "@types/react": "^16.9.38",
89
+ "@types/react-dom": "^16.9.8",
90
+ "@types/react-resize-detector": "^3.1.1",
93
91
  "@types/sinon": "^4.3.3",
92
+ "@types/styled-components": "^5.1.0",
93
+ "@types/tinycolor2": "^1.4.2",
94
94
  "@types/webdriverio": "^5.0.0",
95
95
  "@types/webpack-env": "^1.15.2",
96
96
  "@typescript-eslint/eslint-plugin": "^4.8.2",
@@ -126,7 +126,7 @@
126
126
  "jest-stare": "^2.4.1",
127
127
  "mkdirp": "^0.5.1",
128
128
  "playwright": "^1.23.3",
129
- "prismjs": "^1.25.0",
129
+ "prismjs": "^1.29.0",
130
130
  "prompt": "^1.0.0",
131
131
  "raw-loader": "^4.0.2",
132
132
  "react": "^16.12.0",
@@ -2,6 +2,11 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Item from './Item';
4
4
  import { ComponentProps } from '../utils/types';
5
+ /** @public */
6
+ declare type BreadcrumbsClickHandler = (event: React.MouseEvent<HTMLAnchorElement>, data: {
7
+ label?: string;
8
+ to: string;
9
+ }) => void;
5
10
  interface BreadcrumbsPropsBase {
6
11
  /**
7
12
  * `children` must be of type `Breadcrumbs.Item`. The last child will be marked as the current page.
@@ -15,17 +20,28 @@ interface BreadcrumbsPropsBase {
15
20
  * By default, the current page is a dimmed link. This prop changes this behavior by enabling the current page link.
16
21
  */
17
22
  enableCurrentPage?: boolean;
23
+ /**
24
+ * An `onClick` handler for all Items.
25
+ * The function takes the event and an options argument with `to` and `label`.
26
+ */
27
+ onClick?: BreadcrumbsClickHandler;
18
28
  }
19
29
  declare type BreadcrumbsProps = ComponentProps<BreadcrumbsPropsBase, 'nav'>;
20
- declare function Breadcrumbs({ children, elementRef, enableCurrentPage, ...otherProps }: BreadcrumbsProps): JSX.Element;
30
+ declare type BreadcrumbsContextValue = {
31
+ onClick?: BreadcrumbsClickHandler;
32
+ prefix?: string;
33
+ };
34
+ declare const BreadcrumbsContext: React.Context<BreadcrumbsContextValue>;
35
+ declare function Breadcrumbs({ children, elementRef, enableCurrentPage, onClick, ...otherProps }: BreadcrumbsProps): JSX.Element;
21
36
  declare namespace Breadcrumbs {
22
37
  var propTypes: {
23
38
  children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
24
39
  elementRef: PropTypes.Requireable<object>;
25
40
  enableCurrentPage: PropTypes.Requireable<boolean>;
41
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
26
42
  };
27
43
  var defaultProps: Required<Pick<BreadcrumbsPropsBase, "enableCurrentPage">>;
28
44
  var Item: typeof import("./Item").default;
29
45
  }
30
46
  export default Breadcrumbs;
31
- export { Item };
47
+ export { Item, BreadcrumbsContext, BreadcrumbsClickHandler };
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
+ import { BreadcrumbsClickHandler } from './Breadcrumbs';
3
4
  import { ComponentProps } from '../utils/types';
4
5
  interface ItemPropsBase {
5
6
  /**
@@ -22,6 +23,10 @@ interface ItemPropsBase {
22
23
  * The label of the `Item`.
23
24
  */
24
25
  label: string;
26
+ /**
27
+ * An `onClick` handler for the current `Item`.
28
+ */
29
+ onClick?: BreadcrumbsClickHandler;
25
30
  /**
26
31
  * Adornment at the start of the label.
27
32
  */
@@ -32,7 +37,7 @@ interface ItemPropsBase {
32
37
  to: string;
33
38
  }
34
39
  declare type ItemProps = ComponentProps<ItemPropsBase, 'a'>;
35
- declare function Item({ enableCurrentPage, endAdornment, isCurrent, label, startAdornment, to, ...otherProps }: ItemProps): JSX.Element;
40
+ declare function Item({ enableCurrentPage, endAdornment, isCurrent, label, onClick, startAdornment, to, ...otherProps }: ItemProps): JSX.Element;
36
41
  declare namespace Item {
37
42
  var propTypes: {
38
43
  elementRef: PropTypes.Requireable<object>;
@@ -40,6 +45,7 @@ declare namespace Item {
40
45
  endAdornment: PropTypes.Requireable<PropTypes.ReactNodeLike>;
41
46
  isCurrent: PropTypes.Requireable<boolean>;
42
47
  label: PropTypes.Validator<string>;
48
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
43
49
  startAdornment: PropTypes.Requireable<PropTypes.ReactNodeLike>;
44
50
  to: PropTypes.Validator<string>;
45
51
  };
@@ -0,0 +1,2 @@
1
+ declare function CustomizedClick(): JSX.Element;
2
+ export default CustomizedClick;
@@ -21,8 +21,10 @@ interface ButtonPropsBase {
21
21
  children?: React.ReactNode;
22
22
  /** @private An additional className to add to the button. */
23
23
  classNamePrivate?: string;
24
- /** Prevents user from clicking the button. */
25
- disabled?: boolean;
24
+ /** Prevents user from clicking the button. If set to `dimmed`, the button
25
+ * does not respond to mouse events but can still receive focus, and
26
+ * `aria-disabled` is set to `true`. */
27
+ disabled?: boolean | 'dimmed';
26
28
  /**
27
29
  * A React ref which is set to the DOM element when the component mounts and null when it unmounts.
28
30
  */
@@ -1,2 +1,2 @@
1
- declare function Buttons(): JSX.Element;
2
- export default Buttons;
1
+ declare function Block(): JSX.Element;
2
+ export default Block;
@@ -0,0 +1,2 @@
1
+ declare function Dimmed(): JSX.Element;
2
+ export default Dimmed;
@@ -1,2 +1,2 @@
1
- declare function Buttons(): JSX.Element;
2
- export default Buttons;
1
+ declare function Disabled(): JSX.Element;
2
+ export default Disabled;
@@ -1,2 +1,2 @@
1
- declare function Buttons(): JSX.Element;
2
- export default Buttons;
1
+ declare function Icons(): JSX.Element;
2
+ export default Icons;
@@ -1,2 +1,2 @@
1
- declare function Buttons(): JSX.Element;
2
- export default Buttons;
1
+ declare function Menus(): JSX.Element;
2
+ export default Menus;
@@ -1,2 +1,2 @@
1
- declare function Buttons(): JSX.Element;
2
- export default Buttons;
1
+ declare function To(): JSX.Element;
2
+ export default To;
@@ -1,2 +1,2 @@
1
- declare function Buttons(): JSX.Element;
2
- export default Buttons;
1
+ declare function Truncated(): JSX.Element;
2
+ export default Truncated;
@@ -1,2 +1,2 @@
1
- declare function Buttons(): JSX.Element;
2
- export default Buttons;
1
+ declare function Basic(): JSX.Element;
2
+ export default Basic;
@@ -1,2 +1,2 @@
1
- declare function Buttons(): JSX.Element;
2
- export default Buttons;
1
+ declare function Block(): JSX.Element;
2
+ export default Block;
@@ -0,0 +1,2 @@
1
+ declare function Dimmed(): JSX.Element;
2
+ export default Dimmed;
@@ -1,2 +1,2 @@
1
- declare function Buttons(): JSX.Element;
2
- export default Buttons;
1
+ declare function Disabled(): JSX.Element;
2
+ export default Disabled;
@@ -1,2 +1,2 @@
1
- declare function Buttons(): JSX.Element;
2
- export default Buttons;
1
+ declare function Menus(): JSX.Element;
2
+ export default Menus;
@@ -1,2 +1,2 @@
1
- declare function Buttons(): JSX.Element;
2
- export default Buttons;
1
+ declare function To(): JSX.Element;
2
+ export default To;
@@ -1,2 +1,2 @@
1
- declare function Buttons(): JSX.Element;
2
- export default Buttons;
1
+ declare function Truncated(): JSX.Element;
2
+ export default Truncated;
@@ -14,8 +14,10 @@ interface ButtonSimplePropsBase {
14
14
  * append things to it. */
15
15
  append?: boolean;
16
16
  children?: React.ReactNode;
17
- /** Add a disabled attribute and prevent clicking. */
18
- disabled?: boolean;
17
+ /** Add a disabled attribute and prevent clicking. If set to `dimmed`,
18
+ * the button does not respond to mouse events but can still receive
19
+ * focus, and `aria-disabled` is set to `true`. */
20
+ disabled?: boolean | 'dimmed';
19
21
  /**
20
22
  * Adds error styling to the button and applies `aria-invalid`.
21
23
  */