@window-splitter/web-component 1.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.
- package/.storybook/main.js +27 -0
- package/.storybook/preview.css +23 -0
- package/.storybook/preview.js +15 -0
- package/.tshy/build.json +8 -0
- package/.tshy/commonjs.json +19 -0
- package/.tshy/esm.json +18 -0
- package/.turbo/turbo-build.log +5 -0
- package/CHANGELOG.md +24 -0
- package/LICENSE +7 -0
- package/README.md +59 -0
- package/dist/commonjs/index.d.ts +77 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +533 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/esm/index.d.ts +77 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +527 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/eslint.config.mjs +10 -0
- package/package.json +84 -0
- package/src/WebComponentWindowSplitter.stories.ts +873 -0
- package/src/WebComponentWindowSplitter.test.ts +299 -0
- package/src/__snapshots__/WebComponentWindowSplitter.test.ts.snap +54 -0
- package/src/index.ts +660 -0
- package/tsconfig.json +8 -0
- package/vitest.config.js +17 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { join, dirname } from "path";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This function is used to resolve the absolute path of a package.
|
|
5
|
+
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
|
|
6
|
+
*/
|
|
7
|
+
function getAbsolutePath(value) {
|
|
8
|
+
return dirname(require.resolve(join(value, "package.json")));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** @type { import('@storybook/web-components-vite').StorybookConfig } */
|
|
12
|
+
const config = {
|
|
13
|
+
stories: ["../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
|
|
14
|
+
addons: [
|
|
15
|
+
{
|
|
16
|
+
name: getAbsolutePath("@storybook/addon-essentials"),
|
|
17
|
+
options: {
|
|
18
|
+
docs: false,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
framework: {
|
|
23
|
+
name: getAbsolutePath("@storybook/web-components-vite"),
|
|
24
|
+
options: {},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export default config;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.panel-group {
|
|
2
|
+
border: 1px solid rgba(0, 0, 0, 0.3);
|
|
3
|
+
background: rgba(0, 0, 0, 0.1);
|
|
4
|
+
border-radius: 12px;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
min-width: 500px;
|
|
7
|
+
display: block;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.panel {
|
|
11
|
+
height: 100%;
|
|
12
|
+
width: 100%;
|
|
13
|
+
padding: 20px;
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.panel-resizer {
|
|
22
|
+
background: red;
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "./preview.css";
|
|
2
|
+
|
|
3
|
+
/** @type { import('@storybook/web-components').Preview } */
|
|
4
|
+
const preview = {
|
|
5
|
+
parameters: {
|
|
6
|
+
controls: {
|
|
7
|
+
matchers: {
|
|
8
|
+
color: /(background|color)$/i,
|
|
9
|
+
date: /Date$/i,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default preview;
|
package/.tshy/build.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./build.json",
|
|
3
|
+
"include": [
|
|
4
|
+
"../src/**/*.ts",
|
|
5
|
+
"../src/**/*.cts",
|
|
6
|
+
"../src/**/*.tsx",
|
|
7
|
+
"../src/**/*.json"
|
|
8
|
+
],
|
|
9
|
+
"exclude": [
|
|
10
|
+
"../node_modules",
|
|
11
|
+
"../src/**/*.test.ts",
|
|
12
|
+
"../**/*stories.*",
|
|
13
|
+
"../src/**/*.mts",
|
|
14
|
+
"../src/package.json"
|
|
15
|
+
],
|
|
16
|
+
"compilerOptions": {
|
|
17
|
+
"outDir": "../.tshy-build/commonjs"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/.tshy/esm.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./build.json",
|
|
3
|
+
"include": [
|
|
4
|
+
"../src/**/*.ts",
|
|
5
|
+
"../src/**/*.mts",
|
|
6
|
+
"../src/**/*.tsx",
|
|
7
|
+
"../src/**/*.json"
|
|
8
|
+
],
|
|
9
|
+
"exclude": [
|
|
10
|
+
"../node_modules",
|
|
11
|
+
"../src/**/*.test.ts",
|
|
12
|
+
"../**/*stories.*",
|
|
13
|
+
"../src/package.json"
|
|
14
|
+
],
|
|
15
|
+
"compilerOptions": {
|
|
16
|
+
"outDir": "../.tshy-build/esm"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# v1.0.1 (Sun May 11 2025)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- Web Component [#59](https://github.com/hipstersmoothie/window-splitter/pull/59) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
6
|
+
- fix build ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
7
|
+
- add readme ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
8
|
+
- fix disabled ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
9
|
+
- tests ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
10
|
+
- stories in TS ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
11
|
+
- lint ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
12
|
+
- get build working ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
13
|
+
- imperative api ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
14
|
+
- add event callbacks ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
15
|
+
- conditional panels ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
16
|
+
- switch to lit context ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
17
|
+
- working on conditional ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
18
|
+
- better children measurement ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
19
|
+
- more stories ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
20
|
+
- start ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
21
|
+
|
|
22
|
+
#### Authors: 1
|
|
23
|
+
|
|
24
|
+
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2025 Andrew Lisowski
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @window-splitter/web-component
|
|
2
|
+
|
|
3
|
+
A full featured window splitter as a web component.
|
|
4
|
+
|
|
5
|
+
- Support for the full [window splitter](https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/) ARIA spec
|
|
6
|
+
- Support for percentage and pixel based constraints
|
|
7
|
+
- Collapsible panels
|
|
8
|
+
- Controlled panels
|
|
9
|
+
- Layout Persistance - LocalStorage and Cookie
|
|
10
|
+
|
|
11
|
+
[Read the full docs](https://react-window-splitter-six.vercel.app)
|
|
12
|
+
|
|
13
|
+
> NOTE: Docs are currently on react but it's the same API. Refer the the stories for usage examples.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @window-splitter/web-component
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
First register the elements.
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import {
|
|
27
|
+
Panel,
|
|
28
|
+
PanelGroup,
|
|
29
|
+
PanelResizer,
|
|
30
|
+
} from "@window-splitter/web-component";
|
|
31
|
+
|
|
32
|
+
customElements.define("window-panel-group", PanelGroup);
|
|
33
|
+
customElements.define("window-panel", Panel);
|
|
34
|
+
customElements.define("window-panel-resizer", PanelResizer);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Then you can use them.
|
|
38
|
+
|
|
39
|
+
```html
|
|
40
|
+
<window-panel-group>
|
|
41
|
+
<window-panel min="130px" max="400px" />
|
|
42
|
+
<window-panel-resizer />
|
|
43
|
+
<window-panel min="130px" />
|
|
44
|
+
</window-panel-group>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- WAI-ARIA compliant
|
|
50
|
+
- Keyboard accessible
|
|
51
|
+
- Touch friendly
|
|
52
|
+
- Customizable
|
|
53
|
+
- TypeScript support
|
|
54
|
+
|
|
55
|
+
## Prior Art
|
|
56
|
+
|
|
57
|
+
This library is heavily inspired by the following libraries:
|
|
58
|
+
|
|
59
|
+
- [react-resizable-panels](https://github.com/bvaughn/react-resizable-panels)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { SendFn, GroupMachineContextValue, Unit, OnResizeCallback } from "@window-splitter/state";
|
|
2
|
+
import { LitElement, PropertyValues } from "lit";
|
|
3
|
+
import { MoveEvents, SharedPanelProps } from "@window-splitter/interface";
|
|
4
|
+
export declare class PanelGroup extends LitElement {
|
|
5
|
+
private observer;
|
|
6
|
+
private cleanupChildrenObserver;
|
|
7
|
+
private groupId;
|
|
8
|
+
private context;
|
|
9
|
+
private send;
|
|
10
|
+
private isPrerender;
|
|
11
|
+
private state;
|
|
12
|
+
constructor();
|
|
13
|
+
getId(): string;
|
|
14
|
+
getPixelSizes(): number[];
|
|
15
|
+
getPercentageSizes(): number[];
|
|
16
|
+
getTemplate(): string;
|
|
17
|
+
getState(): "idle" | "dragging";
|
|
18
|
+
setSizes(updates: Unit[]): void;
|
|
19
|
+
private measureSize;
|
|
20
|
+
private measureChildren;
|
|
21
|
+
firstUpdated(): void;
|
|
22
|
+
disconnectedCallback(): void;
|
|
23
|
+
render(): import("lit", { with: { "resolution-mode": "import" } }).TemplateResult<1>;
|
|
24
|
+
}
|
|
25
|
+
export declare class Panel extends LitElement {
|
|
26
|
+
static observedContexts: string[];
|
|
27
|
+
onCollapseChange?: (newCollapsed: boolean, el: Panel) => void;
|
|
28
|
+
onResize?: OnResizeCallback;
|
|
29
|
+
collapseAnimation?: SharedPanelProps<boolean>["collapseAnimation"];
|
|
30
|
+
collapsed?: boolean;
|
|
31
|
+
min?: string;
|
|
32
|
+
max?: string;
|
|
33
|
+
default?: string;
|
|
34
|
+
collapsible?: string;
|
|
35
|
+
defaultCollapsed?: string;
|
|
36
|
+
collapsedSize?: string;
|
|
37
|
+
isStaticAtRest?: string;
|
|
38
|
+
context: GroupMachineContextValue;
|
|
39
|
+
send: SendFn;
|
|
40
|
+
isPrerender: boolean;
|
|
41
|
+
id: string;
|
|
42
|
+
constructor();
|
|
43
|
+
collapse(): void;
|
|
44
|
+
isCollapsed(): boolean;
|
|
45
|
+
expand(): void;
|
|
46
|
+
isExpanded(): boolean;
|
|
47
|
+
getPixelSize(): number;
|
|
48
|
+
getPercentageSize(): number;
|
|
49
|
+
setSize(size: Unit): void;
|
|
50
|
+
private initPanel;
|
|
51
|
+
private getPanelData;
|
|
52
|
+
private getAttributes;
|
|
53
|
+
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
54
|
+
disconnectedCallback(): void;
|
|
55
|
+
updated(changedProperties: PropertyValues): void;
|
|
56
|
+
render(): import("lit", { with: { "resolution-mode": "import" } }).TemplateResult<1>;
|
|
57
|
+
}
|
|
58
|
+
export declare class PanelResizer extends LitElement {
|
|
59
|
+
static observedContexts: string[];
|
|
60
|
+
onDragStart?: () => void;
|
|
61
|
+
onDrag?: (e: Parameters<NonNullable<MoveEvents["onMove"]>>[0]) => void;
|
|
62
|
+
onDragEnd?: () => void;
|
|
63
|
+
context: GroupMachineContextValue;
|
|
64
|
+
send: SendFn;
|
|
65
|
+
isPrerender: boolean;
|
|
66
|
+
size?: string;
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
constructor();
|
|
69
|
+
private initPanelResizer;
|
|
70
|
+
private getHandleData;
|
|
71
|
+
private getAttributes;
|
|
72
|
+
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
73
|
+
updated(changedProperties: PropertyValues): void;
|
|
74
|
+
disconnectedCallback(): void;
|
|
75
|
+
render(): import("lit", { with: { "resolution-mode": "import" } }).TemplateResult<1>;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sour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