vue-panel-splitter 1.0.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.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # vue-panel-splitter
2
+
3
+ A component for vuejs resizeable areas,Supports random combination,support custom styles
4
+
5
+ [![vue-resizeable.gif](https://i.postimg.cc/8C0Rfsvj/vue-resizeable.gif)](https://postimg.cc/JyjD9rPL)
6
+ ### install
7
+
8
+ ```bash
9
+ npm install vue-panel-splitter
10
+ ```
11
+
12
+ ## Component Registration
13
+ ### Global Registration All Components
14
+ ```javascript
15
+ // main.ts
16
+
17
+ import { createApp } from 'vue'
18
+ import vuePanelSplitter from 'vue-panel-splitter'
19
+ import 'vue-panel-splitter/style.css'
20
+
21
+ createApp(App).use(vuePanelSplitter).mount('#app')
22
+ ```
23
+ The above imports vuePanelSplitter entirely. Note that CSS file needs to be imported separately.
24
+
25
+ ### Local Registration
26
+ In this way, component sub-components, such as ResizeableContainer and ResizeablePanel and ResizeableSplitter, need to be registered separately, and they are only valid in the current component after registration.that CSS file needs to be imported separately.
27
+
28
+ ```javascript
29
+ // index.vue
30
+ <script setup>
31
+ import { ResizeableContainer, ResizeablePanel, ResizeableSplitter } from 'vue-panel-splitter'
32
+ import 'vue-panel-splitter/style.css'
33
+ </script>
34
+ ```
35
+ ## Example
36
+
37
+
38
+ ```javascript
39
+ // index.vue
40
+ <template>
41
+ <!-- horizontal -->
42
+ <ResizeableContainer direction="horizontal" style="height: 100vh">
43
+ <ResizeablePanel style="min-width: 150px; background: #ffe0b2">Left</ResizeablePanel>
44
+ <ResizeableSplitter />
45
+ <ResizeablePanel :style="middleStyle">
46
+ <!-- vertical -->
47
+ <ResizeableContainer direction="vertical">
48
+ <ResizeablePanel style="min-height: 150px">Top</ResizeablePanel>
49
+ <ResizeableSplitter style="background: #000" />
50
+ <ResizeablePanel style="height: 200px; min-height: 150px">center</ResizeablePanel>
51
+ <ResizeableSplitter />
52
+ <ResizeablePanel style="height: 300px; min-height: 50px; border: 1px solid #ccc">Bottom</ResizeablePanel>
53
+ </ResizeableContainer>
54
+ </ResizeablePanel>
55
+ <ResizeableSplitter />
56
+ <ResizeablePanel :style="rightStyle">Right</ResizeablePanel>
57
+ </ResizeableContainer>
58
+ </template>
59
+
60
+ <script setup>
61
+ const rightStyle = {
62
+ width: '500px',
63
+ minWidth: '150px',
64
+ border: '1px solid #ccc'
65
+ }
66
+ const middleStyle = {
67
+ width: '500px',
68
+ minWidth: '150px',
69
+ border: '1px solid #ccc',
70
+ display: 'flex',
71
+ flexDirection: 'column',
72
+ height: '100%',
73
+ overflow: 'hidden'
74
+ }
75
+ </script>
76
+ ```
@@ -0,0 +1,20 @@
1
+ type __VLS_Props = {
2
+ direction: "horizontal" | "vertical";
3
+ };
4
+ declare function __VLS_template(): {
5
+ attrs: Partial<{}>;
6
+ slots: {
7
+ default?(_: {}): any;
8
+ };
9
+ refs: {};
10
+ rootEl: HTMLDivElement;
11
+ };
12
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
13
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
14
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
15
+ export default _default;
16
+ type __VLS_WithTemplateSlots<T, S> = T & {
17
+ new (): {
18
+ $slots: S;
19
+ };
20
+ };
@@ -0,0 +1,17 @@
1
+ declare function __VLS_template(): {
2
+ attrs: Partial<{}>;
3
+ slots: {
4
+ default?(_: {}): any;
5
+ };
6
+ refs: {};
7
+ rootEl: HTMLDivElement;
8
+ };
9
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
10
+ declare const __VLS_component: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
11
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
12
+ export default _default;
13
+ type __VLS_WithTemplateSlots<T, S> = T & {
14
+ new (): {
15
+ $slots: S;
16
+ };
17
+ };
@@ -0,0 +1,4 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
2
+ splitterRef: HTMLDivElement;
3
+ }, HTMLDivElement>;
4
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import { Plugin } from 'vue';
2
+ import { default as ResizeableContainer } from './ResizeableContainer.vue';
3
+ import { default as ResizeablePanel } from './ResizeablePanel.vue';
4
+ import { default as ResizeableSplitter } from './ResizeableSplitter.vue';
5
+ export declare const vuePanelSplitter: Plugin;
6
+ export { ResizeableContainer, ResizeablePanel, ResizeableSplitter };
7
+ export default vuePanelSplitter;
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1 @@
1
+ .resize-container{display:flex;overflow:hidden;flex-wrap:nowrap}.horizontal{flex-direction:row}.vertical{flex-direction:column}.resize-panel[data-v-df94088a]{flex-shrink:0}.resize-splitter{background:#e0e0e0;transition:background-color .2s}.resize-splitter.horizontal{width:5px;cursor:col-resize}.resize-splitter.vertical{height:5px;cursor:row-resize}.resize-splitter.active{background:#2196f3}.resize-splitter:hover{background:#90caf9}
@@ -0,0 +1,60 @@
1
+ import { defineComponent as b, provide as C, createElementBlock as m, openBlock as v, normalizeClass as P, renderSlot as R, inject as E, ref as S, withModifiers as D, unref as M } from "vue";
2
+ const k = /* @__PURE__ */ b({
3
+ __name: "ResizeableContainer",
4
+ props: {
5
+ direction: {}
6
+ },
7
+ setup(e) {
8
+ return C("resizeDirection", e.direction), (t, o) => (v(), m("div", {
9
+ class: P(["resize-container", t.direction])
10
+ }, [
11
+ R(t.$slots, "default")
12
+ ], 2));
13
+ }
14
+ }), H = (e, s) => {
15
+ const t = e.__vccOpts || e;
16
+ for (const [o, p] of s)
17
+ t[o] = p;
18
+ return t;
19
+ }, L = {}, I = { class: "resize-panel" };
20
+ function W(e, s) {
21
+ return v(), m("div", I, [
22
+ R(e.$slots, "default", {}, void 0, !0)
23
+ ]);
24
+ }
25
+ const B = /* @__PURE__ */ H(L, [["render", W], ["__scopeId", "data-v-df94088a"]]), X = /* @__PURE__ */ b({
26
+ __name: "ResizeableSplitter",
27
+ setup(e) {
28
+ const s = E("resizeDirection"), t = S(), o = S(!1), p = (d) => {
29
+ if (!t.value) return;
30
+ o.value = !0;
31
+ const f = (l, x) => {
32
+ const c = getComputedStyle(l);
33
+ return x ? parseInt(c.minWidth) || 0 : parseInt(c.minHeight) || 0;
34
+ }, i = t.value.previousElementSibling, r = t.value.nextElementSibling, n = s === "horizontal", y = n ? i.offsetWidth : i.offsetHeight, $ = n ? r.offsetWidth : r.offsetHeight, _ = f(i, n), z = f(r, n), w = n ? d.clientX : d.clientY, h = (l) => {
35
+ const c = (n ? l.clientX : l.clientY) - w, a = y + c, u = $ - c;
36
+ n ? a >= _ && u >= z && (i.style.width = `${a}px`, r.style.width = `${u}px`) : a >= _ && u >= z && (i.style.height = `${a}px`, r.style.height = `${u}px`);
37
+ }, g = () => {
38
+ o.value = !1, document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", g);
39
+ };
40
+ document.addEventListener("mousemove", h), document.addEventListener("mouseup", g, { once: !0 });
41
+ };
42
+ return (d, f) => (v(), m("div", {
43
+ class: P(["resize-splitter", [M(s), { active: o.value }]]),
44
+ onMousedown: D(p, ["prevent"]),
45
+ ref_key: "splitterRef",
46
+ ref: t
47
+ }, null, 34));
48
+ }
49
+ }), j = {
50
+ install(e) {
51
+ e.component("ResizeableContainer", k), e.component("ResizeablePanel", B), e.component("ResizeableSplitter", X);
52
+ }
53
+ };
54
+ export {
55
+ k as ResizeableContainer,
56
+ B as ResizeablePanel,
57
+ X as ResizeableSplitter,
58
+ j as default,
59
+ j as vuePanelSplitter
60
+ };
@@ -0,0 +1 @@
1
+ (function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.vuePanelSplitter={},t.Vue))})(this,function(t,e){"use strict";const h=e.defineComponent({__name:"ResizeableContainer",props:{direction:{}},setup(n){const o=n;return e.provide("resizeDirection",o.direction),(i,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["resize-container",i.direction])},[e.renderSlot(i.$slots,"default")],2))}}),k=(n,o)=>{const i=n.__vccOpts||n;for(const[r,u]of o)i[r]=u;return i},x={},C={class:"resize-panel"};function E(n,o){return e.openBlock(),e.createElementBlock("div",C,[e.renderSlot(n.$slots,"default",{},void 0,!0)])}const z=k(x,[["render",E],["__scopeId","data-v-df94088a"]]),v=e.defineComponent({__name:"ResizeableSplitter",setup(n){const o=e.inject("resizeDirection"),i=e.ref(),r=e.ref(!1),u=m=>{if(!i.value)return;r.value=!0;const _=(d,R)=>{const a=getComputedStyle(d);return R?parseInt(a.minWidth)||0:parseInt(a.minHeight)||0},l=i.value.previousElementSibling,c=i.value.nextElementSibling,s=o==="horizontal",$=s?l.offsetWidth:l.offsetHeight,M=s?c.offsetWidth:c.offsetHeight,g=_(l,s),P=_(c,s),w=s?m.clientX:m.clientY,b=d=>{const a=(s?d.clientX:d.clientY)-w,f=$+a,p=M-a;s?f>=g&&p>=P&&(l.style.width=`${f}px`,c.style.width=`${p}px`):f>=g&&p>=P&&(l.style.height=`${f}px`,c.style.height=`${p}px`)},y=()=>{r.value=!1,document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",y)};document.addEventListener("mousemove",b),document.addEventListener("mouseup",y,{once:!0})};return(m,_)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["resize-splitter",[e.unref(o),{active:r.value}]]),onMousedown:e.withModifiers(u,["prevent"]),ref_key:"splitterRef",ref:i},null,34))}}),S={install(n){n.component("ResizeableContainer",h),n.component("ResizeablePanel",z),n.component("ResizeableSplitter",v)}};t.ResizeableContainer=h,t.ResizeablePanel=z,t.ResizeableSplitter=v,t.default=S,t.vuePanelSplitter=S,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "vue-panel-splitter",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "./dist/vue-panel-splitter.umd.js",
6
+ "module": "./dist/vue-panel-splitter.es.js",
7
+ "types": "./dist/types/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/types/index.d.ts",
14
+ "import": "./dist/vue-panel-splitter.es.js",
15
+ "require": "./dist/vue-panel-splitter.umd.js"
16
+ },
17
+ "./style.css": "./dist/vue-panel-splitter.css"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/taoman/vue-resizeable"
22
+ },
23
+ "scripts": {
24
+ "dev": "vite",
25
+ "build": "vue-tsc -b && vite build",
26
+ "preview": "vite preview"
27
+ },
28
+ "dependencies": {
29
+ "vue": "^3.5.13"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^22.13.4",
33
+ "@vitejs/plugin-vue": "^5.2.1",
34
+ "@vue/tsconfig": "^0.7.0",
35
+ "typescript": "~5.7.2",
36
+ "vite": "^6.1.0",
37
+ "vite-plugin-dts": "^4.5.0",
38
+ "vue-tsc": "^2.2.0"
39
+ }
40
+ }