@spectrum-web-components/split-view 0.0.0-20241209155954
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/README.md +200 -0
- package/package.json +76 -0
- package/sp-split-view.d.ts +6 -0
- package/sp-split-view.dev.js +5 -0
- package/sp-split-view.dev.js.map +7 -0
- package/sp-split-view.js +2 -0
- package/sp-split-view.js.map +7 -0
- package/src/SplitView.d.ts +68 -0
- package/src/SplitView.dev.js +370 -0
- package/src/SplitView.dev.js.map +7 -0
- package/src/SplitView.js +26 -0
- package/src/SplitView.js.map +7 -0
- package/src/index.d.ts +1 -0
- package/src/index.dev.js +3 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +2 -0
- package/src/index.js.map +7 -0
- package/src/spectrum-config.js +84 -0
- package/src/spectrum-split-view.css.d.ts +2 -0
- package/src/spectrum-split-view.css.dev.js +7 -0
- package/src/spectrum-split-view.css.dev.js.map +7 -0
- package/src/spectrum-split-view.css.js +4 -0
- package/src/spectrum-split-view.css.js.map +7 -0
- package/src/split-view-overrides.css.d.ts +2 -0
- package/src/split-view-overrides.css.dev.js +7 -0
- package/src/split-view-overrides.css.dev.js.map +7 -0
- package/src/split-view-overrides.css.js +4 -0
- package/src/split-view-overrides.css.js.map +7 -0
- package/src/split-view.css.d.ts +2 -0
- package/src/split-view.css.dev.js +7 -0
- package/src/split-view.css.dev.js.map +7 -0
- package/src/split-view.css.js +4 -0
- package/src/split-view.css.js.map +7 -0
- package/src/types.d.ts +13 -0
- package/src/types.dev.js +2 -0
- package/src/types.dev.js.map +7 -0
- package/src/types.js +2 -0
- package/src/types.js.map +7 -0
package/README.md
ADDED
@@ -0,0 +1,200 @@
|
|
1
|
+
## Description
|
2
|
+
|
3
|
+
An `sp-split-view` element delivers its first two direct child elements in a horizontal or vertical (`<sp-split-view vertical>`) orientation that distributes the available page real estate as per the supplied attribute API. When leveraging the resizable attribute a pointer and keyboard accessible affordance is provided for the user to customize the distribution of that area between the available children.
|
4
|
+
|
5
|
+
### Usage
|
6
|
+
|
7
|
+
[](https://www.npmjs.com/package/@spectrum-web-components/split-view)
|
8
|
+
[](https://bundlephobia.com/result?p=@spectrum-web-components/split-view)
|
9
|
+
[](https://webcomponents.dev/edit/collection/fO75441E1Q5ZlI0e9pgq/WzGXekJkbnJjUiBjwUEb/src/index.ts)
|
10
|
+
|
11
|
+
```
|
12
|
+
yarn add @spectrum-web-components/split-view
|
13
|
+
```
|
14
|
+
|
15
|
+
Import the side effectful registration of `<sp-split-view>` via:
|
16
|
+
|
17
|
+
```
|
18
|
+
import '@spectrum-web-components/split-view/sp-split-view.js';
|
19
|
+
```
|
20
|
+
|
21
|
+
When looking to leverage the `SplitView` base class as a type and/or for extension purposes, do so via:
|
22
|
+
|
23
|
+
```
|
24
|
+
import { SplitView } from '@spectrum-web-components/split-view';
|
25
|
+
```
|
26
|
+
|
27
|
+
## Variants
|
28
|
+
|
29
|
+
### Horizontal
|
30
|
+
|
31
|
+
```html
|
32
|
+
<sp-split-view>
|
33
|
+
<div>Left panel</div>
|
34
|
+
<div>Right panel</div>
|
35
|
+
</sp-split-view>
|
36
|
+
```
|
37
|
+
|
38
|
+
### Horizontal Resizable
|
39
|
+
|
40
|
+
```html
|
41
|
+
<sp-split-view
|
42
|
+
resizable
|
43
|
+
primary-min="50"
|
44
|
+
secondary-min="50"
|
45
|
+
primary-size="100"
|
46
|
+
label="Resize the horizontal panels"
|
47
|
+
>
|
48
|
+
<div>
|
49
|
+
<h1>Left panel</h1>
|
50
|
+
<p>
|
51
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting
|
52
|
+
industry.
|
53
|
+
</p>
|
54
|
+
</div>
|
55
|
+
<div>
|
56
|
+
<h2>Right panel</h2>
|
57
|
+
<p>
|
58
|
+
It is a long established fact that a reader will be distracted by
|
59
|
+
the readable content of a page when looking at its layout.
|
60
|
+
</p>
|
61
|
+
</div>
|
62
|
+
</sp-split-view>
|
63
|
+
```
|
64
|
+
|
65
|
+
### Horizontal Resizable & Collapsible
|
66
|
+
|
67
|
+
```html
|
68
|
+
<sp-split-view resizable label="Resize the horizontal collapsible panels">
|
69
|
+
<div>
|
70
|
+
<h1>Left panel</h1>
|
71
|
+
<p>
|
72
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting
|
73
|
+
industry.
|
74
|
+
</p>
|
75
|
+
</div>
|
76
|
+
<div>
|
77
|
+
<h2>Right panel</h2>
|
78
|
+
<p>
|
79
|
+
It is a long established fact that a reader will be distracted by
|
80
|
+
the readable content of a page when looking at its layout.
|
81
|
+
</p>
|
82
|
+
</div>
|
83
|
+
</sp-split-view>
|
84
|
+
```
|
85
|
+
|
86
|
+
### Vertical
|
87
|
+
|
88
|
+
```html
|
89
|
+
<sp-split-view vertical>
|
90
|
+
<div>Top panel</div>
|
91
|
+
<div>Bottom panel</div>
|
92
|
+
</sp-split-view>
|
93
|
+
```
|
94
|
+
|
95
|
+
### Vertical Resizable
|
96
|
+
|
97
|
+
```html
|
98
|
+
<sp-split-view
|
99
|
+
vertical
|
100
|
+
resizable
|
101
|
+
primary-min="50"
|
102
|
+
primary-max="150"
|
103
|
+
secondary-min="50"
|
104
|
+
label="Resize the vertical panels"
|
105
|
+
>
|
106
|
+
<div>
|
107
|
+
<h1>Top panel</h1>
|
108
|
+
<p>
|
109
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting
|
110
|
+
industry.
|
111
|
+
</p>
|
112
|
+
</div>
|
113
|
+
<div>
|
114
|
+
<h2>Bottom panel</h2>
|
115
|
+
<p>
|
116
|
+
It is a long established fact that a reader will be distracted by
|
117
|
+
the readable content of a page when looking at its layout.
|
118
|
+
</p>
|
119
|
+
</div>
|
120
|
+
</sp-split-view>
|
121
|
+
```
|
122
|
+
|
123
|
+
### Vertical Resizable & Collapsible
|
124
|
+
|
125
|
+
```html
|
126
|
+
<sp-split-view
|
127
|
+
vertical
|
128
|
+
resizable
|
129
|
+
style="height: 300px;"
|
130
|
+
label="Resize the vertical collapsible panels"
|
131
|
+
>
|
132
|
+
<div>
|
133
|
+
<h1>Top panel</h1>
|
134
|
+
<p>
|
135
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting
|
136
|
+
industry.
|
137
|
+
</p>
|
138
|
+
</div>
|
139
|
+
<div>
|
140
|
+
<h2>Bottom panel</h2>
|
141
|
+
<p>
|
142
|
+
It is a long established fact that a reader will be distracted by
|
143
|
+
the readable content of a page when looking at its layout.
|
144
|
+
</p>
|
145
|
+
</div>
|
146
|
+
</sp-split-view>
|
147
|
+
```
|
148
|
+
|
149
|
+
### Multiple Levels
|
150
|
+
|
151
|
+
```html
|
152
|
+
<sp-split-view
|
153
|
+
resizable
|
154
|
+
primary-min="50"
|
155
|
+
primary-max="200"
|
156
|
+
secondary-min="50"
|
157
|
+
style="height: 400px; width: 600px;"
|
158
|
+
>
|
159
|
+
<div>
|
160
|
+
<h1>First panel - Level 1</h1>
|
161
|
+
<p>
|
162
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting
|
163
|
+
industry. Lorem Ipsum has been the industry's standard dummy text
|
164
|
+
ever since the 1500s, when an unknown printer took a galley of type
|
165
|
+
and scrambled it to make a type specimen book.
|
166
|
+
</p>
|
167
|
+
</div>
|
168
|
+
<div>
|
169
|
+
<h2>Second panel - Level 1</h2>
|
170
|
+
<sp-split-view
|
171
|
+
vertical
|
172
|
+
resizable
|
173
|
+
primary-min="50"
|
174
|
+
primary-size="100"
|
175
|
+
secondary-min="50"
|
176
|
+
style="height: 300px;"
|
177
|
+
>
|
178
|
+
<div>
|
179
|
+
<h3>First panel - Level 2</h3>
|
180
|
+
<p>
|
181
|
+
Lorem Ipsum is simply dummy text of the printing and
|
182
|
+
typesetting industry.
|
183
|
+
</p>
|
184
|
+
</div>
|
185
|
+
<div>
|
186
|
+
<h4>Second panel - Level 2</h4>
|
187
|
+
<p>
|
188
|
+
It is a long established fact that a reader will be
|
189
|
+
distracted by the readable content of a page when looking at
|
190
|
+
its layout.
|
191
|
+
</p>
|
192
|
+
</div>
|
193
|
+
</sp-split-view>
|
194
|
+
</div>
|
195
|
+
</sp-split-view>
|
196
|
+
```
|
197
|
+
|
198
|
+
## Accessibility
|
199
|
+
|
200
|
+
By default, the "separator" element within an `<sp-split-view>` is given the label "Resize the panels". A label is required to surface the interaction correctly to screen readers. You can customize or internationalize this with the `label` attribute.
|
package/package.json
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
{
|
2
|
+
"name": "@spectrum-web-components/split-view",
|
3
|
+
"version": "0.0.0-20241209155954",
|
4
|
+
"publishConfig": {
|
5
|
+
"access": "public"
|
6
|
+
},
|
7
|
+
"description": "",
|
8
|
+
"license": "Apache-2.0",
|
9
|
+
"repository": {
|
10
|
+
"type": "git",
|
11
|
+
"url": "https://github.com/adobe/spectrum-web-components.git",
|
12
|
+
"directory": "packages/split-view"
|
13
|
+
},
|
14
|
+
"author": "",
|
15
|
+
"homepage": "https://opensource.adobe.com/spectrum-web-components/components/split-view",
|
16
|
+
"bugs": {
|
17
|
+
"url": "https://github.com/adobe/spectrum-web-components/issues"
|
18
|
+
},
|
19
|
+
"main": "src/index.js",
|
20
|
+
"module": "src/index.js",
|
21
|
+
"type": "module",
|
22
|
+
"exports": {
|
23
|
+
".": {
|
24
|
+
"development": "./src/index.dev.js",
|
25
|
+
"default": "./src/index.js"
|
26
|
+
},
|
27
|
+
"./package.json": "./package.json",
|
28
|
+
"./src/SplitView.js": {
|
29
|
+
"development": "./src/SplitView.dev.js",
|
30
|
+
"default": "./src/SplitView.js"
|
31
|
+
},
|
32
|
+
"./src/index.js": {
|
33
|
+
"development": "./src/index.dev.js",
|
34
|
+
"default": "./src/index.js"
|
35
|
+
},
|
36
|
+
"./src/split-view-overrides.css.js": "./src/split-view-overrides.css.js",
|
37
|
+
"./src/split-view.css.js": "./src/split-view.css.js",
|
38
|
+
"./src/types.js": {
|
39
|
+
"development": "./src/types.dev.js",
|
40
|
+
"default": "./src/types.js"
|
41
|
+
},
|
42
|
+
"./sp-split-view.js": {
|
43
|
+
"development": "./sp-split-view.dev.js",
|
44
|
+
"default": "./sp-split-view.js"
|
45
|
+
}
|
46
|
+
},
|
47
|
+
"scripts": {
|
48
|
+
"test": "echo \"Error: run tests from mono-repo root.\" && exit 1"
|
49
|
+
},
|
50
|
+
"files": [
|
51
|
+
"**/*.d.ts",
|
52
|
+
"**/*.js",
|
53
|
+
"**/*.js.map",
|
54
|
+
"custom-elements.json",
|
55
|
+
"!stories/",
|
56
|
+
"!test/"
|
57
|
+
],
|
58
|
+
"keywords": [
|
59
|
+
"spectrum css",
|
60
|
+
"web components",
|
61
|
+
"lit-element",
|
62
|
+
"lit-html"
|
63
|
+
],
|
64
|
+
"dependencies": {
|
65
|
+
"@spectrum-web-components/base": "0.0.0-20241209155954"
|
66
|
+
},
|
67
|
+
"devDependencies": {
|
68
|
+
"@spectrum-css/splitview": "^6.0.0-s2-foundations.15"
|
69
|
+
},
|
70
|
+
"types": "./src/index.d.ts",
|
71
|
+
"customElements": "custom-elements.json",
|
72
|
+
"sideEffects": [
|
73
|
+
"./sp-*.js",
|
74
|
+
"./**/*.dev.js"
|
75
|
+
]
|
76
|
+
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["sp-split-view.ts"],
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { SplitView } from './src/SplitView.dev.js'\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\n\ndefineElement('sp-split-view', SplitView);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-split-view': SplitView;\n }\n}\n"],
|
5
|
+
"mappings": ";AAYA,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAE9B,cAAc,iBAAiB,SAAS;",
|
6
|
+
"names": []
|
7
|
+
}
|
package/sp-split-view.js
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["sp-split-view.ts"],
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { SplitView } from './src/SplitView.js';\nimport { defineElement } from '@spectrum-web-components/base/src/define-element.js';\n\ndefineElement('sp-split-view', SplitView);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-split-view': SplitView;\n }\n}\n"],
|
5
|
+
"mappings": "aAYA,OAAS,aAAAA,MAAiB,qBAC1B,OAAS,iBAAAC,MAAqB,sDAE9BA,EAAc,gBAAiBD,CAAS",
|
6
|
+
"names": ["SplitView", "defineElement"]
|
7
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import { CSSResultArray, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
|
2
|
+
/**
|
3
|
+
* @element sp-split-view
|
4
|
+
*
|
5
|
+
* @slot Two sibling elements to be sized by the element attritubes
|
6
|
+
* @fires change - Announces the new position of the splitter
|
7
|
+
*/
|
8
|
+
export declare class SplitView extends SpectrumElement {
|
9
|
+
static get styles(): CSSResultArray;
|
10
|
+
controlledEl?: HTMLElement;
|
11
|
+
vertical: boolean;
|
12
|
+
resizable: boolean;
|
13
|
+
collapsible: boolean;
|
14
|
+
/** The minimum size of the primary pane */
|
15
|
+
primaryMin: number;
|
16
|
+
/** The maximum size of the primary pane */
|
17
|
+
primaryMax: number;
|
18
|
+
/**
|
19
|
+
* The start size of the primary pane, can be a real pixel number|string, percentage or "auto"
|
20
|
+
* For example: "100", "120px", "75%" or "auto" are valid values
|
21
|
+
* @type {number | number + "px" | number + "%" | "auto"}
|
22
|
+
* @attr
|
23
|
+
*/
|
24
|
+
primarySize?: string;
|
25
|
+
/** The minimum size of the secondary pane */
|
26
|
+
secondaryMin: number;
|
27
|
+
/** The maximum size of the secondary pane */
|
28
|
+
secondaryMax: number;
|
29
|
+
/** The current splitter position of split-view */
|
30
|
+
splitterPos?: number;
|
31
|
+
/** The current size of first pane of split-view */
|
32
|
+
private firstPaneSize;
|
33
|
+
label?: string;
|
34
|
+
private enoughChildren;
|
35
|
+
private viewSize;
|
36
|
+
private paneSlot;
|
37
|
+
private splitter;
|
38
|
+
private offset;
|
39
|
+
private minPos;
|
40
|
+
private maxPos;
|
41
|
+
private observer?;
|
42
|
+
private rect?;
|
43
|
+
private _splitterSize?;
|
44
|
+
constructor();
|
45
|
+
connectedCallback(): void;
|
46
|
+
disconnectedCallback(): void;
|
47
|
+
/**
|
48
|
+
* @private
|
49
|
+
**/
|
50
|
+
get splitterSize(): number;
|
51
|
+
protected render(): TemplateResult;
|
52
|
+
private controlledElIDApplied;
|
53
|
+
private onContentSlotChange;
|
54
|
+
private onPointerdown;
|
55
|
+
private onPointermove;
|
56
|
+
private onPointerup;
|
57
|
+
private getOffset;
|
58
|
+
private getPosition;
|
59
|
+
private movePosition;
|
60
|
+
private onKeydown;
|
61
|
+
private checkResize;
|
62
|
+
private updateMinMax;
|
63
|
+
private updatePosition;
|
64
|
+
private getLimitedPosition;
|
65
|
+
private calcStartPos;
|
66
|
+
private dispatchChangeEvent;
|
67
|
+
protected willUpdate(changed: PropertyValues): void;
|
68
|
+
}
|