react-split-pane 2.0.3 → 3.0.1

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/README.md +451 -144
  2. package/dist/components/Divider.d.ts +31 -0
  3. package/dist/components/Divider.d.ts.map +1 -0
  4. package/dist/components/Pane.d.ts +27 -0
  5. package/dist/components/Pane.d.ts.map +1 -0
  6. package/dist/components/SplitPane.d.ts +29 -0
  7. package/dist/components/SplitPane.d.ts.map +1 -0
  8. package/dist/hooks/useKeyboardResize.d.ts +34 -0
  9. package/dist/hooks/useKeyboardResize.d.ts.map +1 -0
  10. package/dist/hooks/usePaneSize.d.ts +16 -0
  11. package/dist/hooks/usePaneSize.d.ts.map +1 -0
  12. package/dist/hooks/useResizer.d.ts +44 -0
  13. package/dist/hooks/useResizer.d.ts.map +1 -0
  14. package/dist/index.cjs +2 -0
  15. package/dist/index.cjs.map +1 -0
  16. package/dist/index.d.ts +8 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +2 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/keyboard.cjs +2 -0
  21. package/dist/keyboard.cjs.map +1 -0
  22. package/dist/keyboard.d.ts +3 -0
  23. package/dist/keyboard.d.ts.map +1 -0
  24. package/dist/keyboard.js +2 -0
  25. package/dist/keyboard.js.map +1 -0
  26. package/dist/persistence.cjs +2 -0
  27. package/dist/persistence.cjs.map +1 -0
  28. package/dist/persistence.d.ts +24 -0
  29. package/dist/persistence.d.ts.map +1 -0
  30. package/dist/persistence.js +2 -0
  31. package/dist/persistence.js.map +1 -0
  32. package/dist/test/setup.d.ts +2 -0
  33. package/dist/test/setup.d.ts.map +1 -0
  34. package/dist/types/index.d.ts +89 -0
  35. package/dist/types/index.d.ts.map +1 -0
  36. package/dist/utils/accessibility.d.ts +17 -0
  37. package/dist/utils/accessibility.d.ts.map +1 -0
  38. package/dist/utils/calculations.d.ts +29 -0
  39. package/dist/utils/calculations.d.ts.map +1 -0
  40. package/package.json +82 -67
  41. package/styles.css +106 -0
  42. package/.editorconfig +0 -6
  43. package/.storybook/addons.js +0 -2
  44. package/.storybook/config.js +0 -9
  45. package/.storybook/preview-head.html +0 -33
  46. package/.travis.yml +0 -10
  47. package/index.d.ts +0 -53
  48. package/index.js +0 -3
  49. package/lcov.info +0 -700
  50. package/lib/Pane.js +0 -130
  51. package/lib/Resizer.js +0 -105
  52. package/lib/SplitPane.js +0 -512
  53. package/stories/index.stories.js +0 -40
  54. package/tsconfig.json +0 -11
package/package.json CHANGED
@@ -1,83 +1,98 @@
1
1
  {
2
2
  "name": "react-split-pane",
3
- "description": "React split-pane component",
4
- "main": "index.js",
5
- "types": "index.d.ts",
6
- "version": "2.0.3",
3
+ "version": "3.0.1",
4
+ "description": "React split-pane component with hooks and TypeScript",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ },
15
+ "./keyboard": {
16
+ "types": "./dist/keyboard.d.ts",
17
+ "import": "./dist/keyboard.js",
18
+ "require": "./dist/keyboard.cjs"
19
+ },
20
+ "./persistence": {
21
+ "types": "./dist/persistence.d.ts",
22
+ "import": "./dist/persistence.js",
23
+ "require": "./dist/persistence.cjs"
24
+ },
25
+ "./styles.css": "./styles.css"
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "styles.css"
30
+ ],
31
+ "sideEffects": false,
32
+ "scripts": {
33
+ "dev": "rollup -c -w",
34
+ "build": "rollup -c && npm run build:types",
35
+ "build:types": "tsc --emitDeclarationOnly",
36
+ "test": "vitest run",
37
+ "test:watch": "vitest",
38
+ "test:coverage": "vitest run --coverage",
39
+ "lint": "eslint src",
40
+ "format": "prettier --write src examples",
41
+ "format:check": "prettier --check src examples",
42
+ "typecheck": "tsc --noEmit",
43
+ "examples": "vite --config examples/vite.config.ts",
44
+ "examples:build": "vite build --config examples/vite.config.ts",
45
+ "prepublishOnly": "npm run test && npm run build"
46
+ },
7
47
  "repository": {
8
48
  "type": "git",
9
49
  "url": "https://github.com/tomkp/react-split-pane"
10
50
  },
11
- "license": "MIT",
12
- "bugs": {
13
- "url": "https://github.com/tomkp/react-split-pane"
14
- },
15
- "homepage": "https://github.com/tomkp/react-split-pane",
16
- "author": "tomkp <tom@tomkp.com>",
17
51
  "keywords": [
18
52
  "react",
19
53
  "react-component",
20
54
  "split-pane",
21
55
  "react-split-pane",
22
- "es6"
56
+ "typescript",
57
+ "hooks",
58
+ "resizable",
59
+ "panes",
60
+ "layout",
61
+ "accessibility"
23
62
  ],
24
- "dependencies": {
25
- "glamor": "^2.20.40",
26
- "glamorous": "^4.11.2",
27
- "inline-style-prefixer": "^4.0.0",
28
- "normalize.css": "^7.0.0",
29
- "styled-components": "^2.4.0",
30
- "prop-types": "^15.6.0",
31
- "react": "^16.2.0",
32
- "react-dom": "^16.2.0"
63
+ "author": "tomkp <tom@tomkp.com>",
64
+ "license": "MIT",
65
+ "peerDependencies": {
66
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
67
+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
33
68
  },
34
69
  "devDependencies": {
35
- "babel-cli": "^6.26.0",
36
- "babel-plugin-add-module-exports": "^0.2.1",
37
- "babel-plugin-transform-object-assign": "^6.22.0",
38
- "babel-plugin-transform-object-rest-spread": "^6.26.0",
39
- "babel-preset-es2015": "^6.24.1",
40
- "babel-preset-react": "^6.24.1",
41
- "babelify": "^8.0.0",
42
- "browserify": "^14.5.0",
43
- "chai": "^4.1.2",
44
- "chai-spies": "^0.7.1",
45
- "core-js": "^2.5.3",
46
- "coveralls": "^3.0.0",
47
- "express": "^4.16.2",
48
- "mochify": "^4.0.0",
49
- "mochify-istanbul": "^2.4.2",
50
- "prettier": "^1.9.2",
51
- "react": "^16.2.0",
52
- "react-dom": "^16.2.0",
53
- "sinon": "^5.0.7",
54
- "surge": "^0.19.0",
55
- "typescript": "^2.6.2",
56
- "watchify": "^3.9.0",
57
- "@storybook/react": "^3.3.3",
58
- "@storybook/addon-actions": "^3.3.3",
59
- "@storybook/addon-links": "^3.3.3"
60
- },
61
- "scripts": {
62
- "compile": "babel -d lib/ src/",
63
- "compile:watch": "babel -w -d lib/ src/",
64
- "test": "npm run compile && mochify -R spec",
65
- "test:watch": "npm run compile:watch & mochify -R spec --watch",
66
- "test:coverage": "mochify --plugin [ mochify-istanbul --exclude '**/test/**' --report lcovonly ] && cat lcov.info | coveralls && rm lcov.info",
67
- "demo": "npm run compile && browserify demo/Examples.js -d -t -o demo/bundle.js",
68
- "demo:watch": "npm run compile:watch & watchify demo/Examples.js -d -t -o demo/bundle.js",
69
- "demo:publish": "npm run compile && browserify demo/Examples.js -d -t -o demo/bundle.js && surge demo react-split-pane-v2.surge.sh",
70
- "prettier": "prettier --single-quote --trailing-comma es5 --write './{src,test}/**/*.js'",
71
- "storybook": "start-storybook -p 6006",
72
- "build-storybook": "build-storybook",
73
- "release:patch": "npm test && npm version patch && git push && npm publish --tag next"
74
- },
75
- "browserify": {
76
- "transform": [
77
- [
78
- "babelify"
79
- ]
80
- ]
70
+ "@rollup/plugin-commonjs": "^29.0.0",
71
+ "@rollup/plugin-node-resolve": "^16.0.3",
72
+ "@rollup/plugin-terser": "^0.4.4",
73
+ "@rollup/plugin-typescript": "^12.3.0",
74
+ "@testing-library/dom": "^10.4.0",
75
+ "@testing-library/jest-dom": "^6.9.1",
76
+ "@testing-library/react": "^16.3.1",
77
+ "@testing-library/user-event": "^14.5.2",
78
+ "@types/react": "^18.3.27",
79
+ "@types/react-dom": "^18.3.7",
80
+ "@vitejs/plugin-react": "^4.7.0",
81
+ "@vitest/coverage-v8": "^4.0.16",
82
+ "eslint": "^9.39.2",
83
+ "globals": "^16.2.0",
84
+ "jsdom": "^26.1.0",
85
+ "prettier": "^3.7.4",
86
+ "react": "^18.3.1",
87
+ "react-dom": "^18.3.1",
88
+ "rollup": "^4.54.0",
89
+ "tslib": "^2.8.1",
90
+ "typescript": "^5.8.3",
91
+ "typescript-eslint": "^8.50.0",
92
+ "vite": "^6.3.5",
93
+ "vitest": "^4.0.16"
81
94
  },
82
- "false": {}
95
+ "engines": {
96
+ "node": ">=20.0.0"
97
+ }
83
98
  }
package/styles.css ADDED
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Default styles for react-split-pane v3
3
+ *
4
+ * You can import these styles or create your own.
5
+ *
6
+ * Customize by overriding CSS custom properties:
7
+ *
8
+ * .my-split-pane {
9
+ * --split-pane-divider-size: 8px;
10
+ * --split-pane-divider-color: #e0e0e0;
11
+ * --split-pane-focus-color: #ff5722;
12
+ * }
13
+ */
14
+
15
+ :root {
16
+ /* Divider dimensions */
17
+ --split-pane-divider-size: 11px;
18
+ --split-pane-divider-hit-area: 5px;
19
+
20
+ /* Divider colors */
21
+ --split-pane-divider-color: rgba(0, 0, 0, 0.05);
22
+ --split-pane-divider-color-hover: rgba(0, 0, 0, 0.15);
23
+
24
+ /* Focus state */
25
+ --split-pane-focus-color: #2196f3;
26
+ --split-pane-focus-bg: rgba(33, 150, 243, 0.1);
27
+
28
+ /* Animation */
29
+ --split-pane-transition-duration: 0.2s;
30
+ }
31
+
32
+ /* Dark theme defaults */
33
+ @media (prefers-color-scheme: dark) {
34
+ :root {
35
+ --split-pane-divider-color: rgba(255, 255, 255, 0.05);
36
+ --split-pane-divider-color-hover: rgba(255, 255, 255, 0.15);
37
+ }
38
+ }
39
+
40
+ .split-pane {
41
+ position: relative;
42
+ overflow: hidden;
43
+ }
44
+
45
+ .split-pane-pane {
46
+ position: relative;
47
+ overflow: auto;
48
+ }
49
+
50
+ .split-pane-divider {
51
+ position: relative;
52
+ z-index: 1;
53
+ box-sizing: border-box;
54
+ background-clip: padding-box;
55
+ background-color: var(--split-pane-divider-color);
56
+ transition: background-color var(--split-pane-transition-duration) ease;
57
+ }
58
+
59
+ .split-pane-divider:hover {
60
+ background-color: var(--split-pane-divider-color-hover);
61
+ }
62
+
63
+ .split-pane-divider:focus {
64
+ outline: 2px solid var(--split-pane-focus-color);
65
+ outline-offset: -2px;
66
+ background-color: var(--split-pane-focus-bg);
67
+ }
68
+
69
+ .split-pane-divider:focus:not(:focus-visible) {
70
+ outline: none;
71
+ }
72
+
73
+ /* Horizontal layout (vertical divider) */
74
+ .split-pane-divider.horizontal {
75
+ width: var(--split-pane-divider-size);
76
+ margin: 0 calc(var(--split-pane-divider-hit-area) * -1);
77
+ border-left: var(--split-pane-divider-hit-area) solid transparent;
78
+ border-right: var(--split-pane-divider-hit-area) solid transparent;
79
+ cursor: col-resize;
80
+ }
81
+
82
+
83
+ /* Vertical layout (horizontal divider) */
84
+ .split-pane-divider.vertical {
85
+ height: var(--split-pane-divider-size);
86
+ margin: calc(var(--split-pane-divider-hit-area) * -1) 0;
87
+ border-top: var(--split-pane-divider-hit-area) solid transparent;
88
+ border-bottom: var(--split-pane-divider-hit-area) solid transparent;
89
+ cursor: row-resize;
90
+ }
91
+
92
+
93
+ /* Minimal theme (1px divider) */
94
+ .split-pane-divider.minimal {
95
+ --split-pane-divider-size: 1px;
96
+ --split-pane-divider-hit-area: 0px;
97
+ --split-pane-divider-color: rgba(0, 0, 0, 0.12);
98
+ border: none;
99
+ margin: 0;
100
+ }
101
+
102
+ @media (prefers-color-scheme: dark) {
103
+ .split-pane-divider.minimal {
104
+ --split-pane-divider-color: rgba(255, 255, 255, 0.12);
105
+ }
106
+ }
package/.editorconfig DELETED
@@ -1,6 +0,0 @@
1
- # editorconfig.org
2
- root = true
3
-
4
- [*]
5
- indent_style = space
6
- indent_size = 2
@@ -1,2 +0,0 @@
1
- import '@storybook/addon-actions/register';
2
- import '@storybook/addon-links/register';
@@ -1,9 +0,0 @@
1
- import { configure } from '@storybook/react';
2
-
3
- // automatically import all files ending in *.stories.js
4
- const req = require.context('../stories', true, /.stories.js$/);
5
- function loadStories() {
6
- req.keys().forEach((filename) => req(filename));
7
- }
8
-
9
- configure(loadStories, module);
@@ -1,33 +0,0 @@
1
- <style>
2
-
3
-
4
- *, *:before, *:after {
5
- box-sizing: border-box;
6
- position: relative;
7
- }
8
-
9
- html {
10
- font-family: "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
11
- font-weight: 400;
12
- font-size: 16px;
13
- line-height: 1.5;
14
- }
15
-
16
- body, html, #root {
17
- margin: 0;
18
- height: 100vh;
19
- min-height: 100vh;
20
- width: 100vw;
21
- }
22
-
23
- a {
24
- -webkit-tap-highlight-color: rgba(0,0,0,0);
25
- }
26
-
27
- #root {
28
- display: flex;
29
- flex-direction: column;
30
- flex: 1;
31
- }
32
-
33
- </style>
package/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- language: node_js
2
- sudo: required
3
- dist: trusty
4
- node_js:
5
- - stable
6
- script:
7
- - npm test
8
- after_script:
9
- - npm run test:coverage
10
- - '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && npm run demo:publish || false'
package/index.d.ts DELETED
@@ -1,53 +0,0 @@
1
- import * as Prefixer from 'inline-style-prefixer';
2
- import * as React from 'react';
3
-
4
- export type Size = string | number;
5
-
6
- export interface Props {
7
- allowResize?: boolean;
8
- className?: string;
9
- primary?: 'first' | 'second';
10
- minSize?: Size;
11
- maxSize?: Size;
12
- defaultSize?: Size;
13
- size?: Size;
14
- split?: 'vertical' | 'horizontal';
15
- onDragStarted?: () => void;
16
- onDragFinished?: () => void;
17
- onChange?: (newSize: number) => void;
18
- onResizerClick?: (event: MouseEvent) => void;
19
- onResizerDoubleClick?: (event: MouseEvent) => void;
20
- prefixer?: Prefixer;
21
- style?: React.CSSProperties;
22
- resizerStyle?: React.CSSProperties;
23
- paneStyle?: React.CSSProperties;
24
- pane1Style?: React.CSSProperties;
25
- pane2Style?: React.CSSProperties;
26
- resizerClassName?: string;
27
- step?: number;
28
- }
29
-
30
- export interface State {
31
- active: boolean;
32
- resized: boolean;
33
- }
34
-
35
- declare class SplitPane extends React.Component<Props, State> {
36
- constructor();
37
-
38
- onMouseDown(event: MouseEvent): void;
39
-
40
- onTouchStart(event: TouchEvent): void;
41
-
42
- onMouseMove(event: MouseEvent): void;
43
-
44
- onTouchMove(event: TouchEvent): void;
45
-
46
- onMouseUp(): void;
47
-
48
- setSize(props: Props, state: State): void;
49
-
50
- static defaultProps: Props;
51
- }
52
-
53
- export { SplitPane as default };
package/index.js DELETED
@@ -1,3 +0,0 @@
1
- var SplitPane = require('./lib/SplitPane');
2
-
3
- module.exports = SplitPane;