Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/vue-split-panel/src/SplitPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/** Whether the primary column is collapsed or not */
const collapsed = defineModel<boolean>('collapsed', { default: false });

const panelEl = useTemplateRef('split-panel');

Check failure on line 33 in packages/vue-split-panel/src/SplitPanel.vue

View workflow job for this annotation

GitHub Actions / test

tests/mounting.test.ts > basic mounting and rendering > renders default divider div when no divider slot content is given

TypeError: Cannot define property split-panel, object is not extensible ❯ useTemplateRef ../../node_modules/.pnpm/@VUE+runtime-core@3.5.19/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1508:14 ❯ setup src/SplitPanel.vue:33:17 ❯ callWithErrorHandling ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7934:25 ❯ setupComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7895:36 ❯ mountComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5225:7 ❯ processComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5191:9 ❯ patch ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4718:11 ❯ ReactiveEffect.componentUpdateFn [as fn] ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5337:11

Check failure on line 33 in packages/vue-split-panel/src/SplitPanel.vue

View workflow job for this annotation

GitHub Actions / test

tests/mounting.test.ts > basic mounting and rendering > renders slot content correctly

TypeError: Cannot define property split-panel, object is not extensible ❯ useTemplateRef ../../node_modules/.pnpm/@VUE+runtime-core@3.5.19/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1508:14 ❯ setup src/SplitPanel.vue:33:17 ❯ callWithErrorHandling ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7934:25 ❯ setupComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7895:36 ❯ mountComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5225:7 ❯ processComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5191:9 ❯ patch ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4718:11 ❯ ReactiveEffect.componentUpdateFn [as fn] ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5337:11

Check failure on line 33 in packages/vue-split-panel/src/SplitPanel.vue

View workflow job for this annotation

GitHub Actions / test

tests/mounting.test.ts > basic mounting and rendering > renders start, divider, and end slots

TypeError: Cannot define property split-panel, object is not extensible ❯ useTemplateRef ../../node_modules/.pnpm/@VUE+runtime-core@3.5.19/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1508:14 ❯ setup src/SplitPanel.vue:33:17 ❯ callWithErrorHandling ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7934:25 ❯ setupComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7895:36 ❯ mountComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5225:7 ❯ processComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5191:9 ❯ patch ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4718:11 ❯ ReactiveEffect.componentUpdateFn [as fn] ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5337:11

Check failure on line 33 in packages/vue-split-panel/src/SplitPanel.vue

View workflow job for this annotation

GitHub Actions / test

tests/mounting.test.ts > basic mounting and rendering > mounts without crashing

TypeError: Cannot define property split-panel, object is not extensible ❯ useTemplateRef ../../node_modules/.pnpm/@VUE+runtime-core@3.5.19/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1508:14 ❯ setup src/SplitPanel.vue:33:17 ❯ callWithErrorHandling ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7934:25 ❯ setupComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7895:36 ❯ mountComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5225:7 ❯ processComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5191:9 ❯ patch ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4718:11 ❯ ReactiveEffect.componentUpdateFn [as fn] ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5337:11

Check failure on line 33 in packages/vue-split-panel/src/SplitPanel.vue

View workflow job for this annotation

GitHub Actions / test

tests/collapse.test.ts > collapse > preserves size when expanding back from collapsed state

TypeError: Cannot define property split-panel, object is not extensible ❯ useTemplateRef ../../node_modules/.pnpm/@VUE+runtime-core@3.5.19/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1508:14 ❯ setup src/SplitPanel.vue:33:17 ❯ callWithErrorHandling ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7934:25 ❯ setupComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7895:36 ❯ mountComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5225:7 ❯ processComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5191:9 ❯ patch ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4718:11 ❯ ReactiveEffect.componentUpdateFn [as fn] ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5337:11

Check failure on line 33 in packages/vue-split-panel/src/SplitPanel.vue

View workflow job for this annotation

GitHub Actions / test

tests/collapse.test.ts > collapse > sets size to 0 when collapsed

TypeError: Cannot define property split-panel, object is not extensible ❯ useTemplateRef ../../node_modules/.pnpm/@VUE+runtime-core@3.5.19/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1508:14 ❯ setup src/SplitPanel.vue:33:17 ❯ callWithErrorHandling ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7934:25 ❯ setupComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7895:36 ❯ mountComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5225:7 ❯ processComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5191:9 ❯ patch ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4718:11 ❯ ReactiveEffect.componentUpdateFn [as fn] ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5337:11

Check failure on line 33 in packages/vue-split-panel/src/SplitPanel.vue

View workflow job for this annotation

GitHub Actions / test

tests/collapse.test.ts > collapse > can be collapsed through a prop even when collapsible is false

TypeError: Cannot define property split-panel, object is not extensible ❯ useTemplateRef ../../node_modules/.pnpm/@VUE+runtime-core@3.5.19/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1508:14 ❯ setup src/SplitPanel.vue:33:17 ❯ callWithErrorHandling ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7934:25 ❯ setupComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7895:36 ❯ mountComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5225:7 ❯ processComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5191:9 ❯ patch ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4718:11 ❯ ReactiveEffect.componentUpdateFn [as fn] ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5337:11

Check failure on line 33 in packages/vue-split-panel/src/SplitPanel.vue

View workflow job for this annotation

GitHub Actions / test

tests/collapse.test.ts > collapse > is not collapsed when collapsed is set to false

TypeError: Cannot define property split-panel, object is not extensible ❯ useTemplateRef ../../node_modules/.pnpm/@VUE+runtime-core@3.5.19/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1508:14 ❯ setup src/SplitPanel.vue:33:17 ❯ callWithErrorHandling ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7934:25 ❯ setupComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7895:36 ❯ mountComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5225:7 ❯ processComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5191:9 ❯ patch ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4718:11 ❯ ReactiveEffect.componentUpdateFn [as fn] ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5337:11

Check failure on line 33 in packages/vue-split-panel/src/SplitPanel.vue

View workflow job for this annotation

GitHub Actions / test

tests/collapse.test.ts > collapse > collapses when collapsed is set to true

TypeError: Cannot define property split-panel, object is not extensible ❯ useTemplateRef ../../node_modules/.pnpm/@VUE+runtime-core@3.5.19/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1508:14 ❯ setup src/SplitPanel.vue:33:17 ❯ callWithErrorHandling ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7934:25 ❯ setupComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7895:36 ❯ mountComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5225:7 ❯ processComponent ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5191:9 ❯ patch ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4718:11 ❯ ReactiveEffect.componentUpdateFn [as fn] ../../node_modules/.pnpm/@VUE+runtime-core@3.5.22/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5337:11
const dividerEl = useTemplateRef('divider');

const {
Expand Down Expand Up @@ -83,7 +83,6 @@

const { gridTemplate } = useGridTemplate({
collapsed,
direction: () => props.direction,
dividerSize,
maxSizePercentage,
minSizePercentage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe('useGridTemplate', () => {
dividerSize: computed(() => 4),
collapsedSizePercentage: computed(() => 0),
primary: 'start',
direction: 'ltr',
orientation: 'horizontal',
...overrides,
});
Expand Down Expand Up @@ -82,13 +81,6 @@ describe('useGridTemplate', () => {
expect(gridTemplate.value).toBe('auto 4px clamp(0%, 50%, calc(100% - 4px))');
});

it('reverses order when direction is rtl and primary is start', () => {
const options = createOptions({ direction: 'rtl' });
const { gridTemplate } = useGridTemplate(options);

expect(gridTemplate.value).toBe('auto 4px clamp(0%, 50%, calc(100% - 4px))');
});

it('handles vertical orientation correctly', () => {
const options = createOptions({ orientation: 'vertical' });
const { gridTemplate } = useGridTemplate(options);
Expand Down
17 changes: 3 additions & 14 deletions packages/vue-split-panel/src/composables/use-grid-template.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ComputedRef, MaybeRefOrGetter, Ref } from 'vue';
import type { Direction, Orientation, Primary } from '../types';
import type { Orientation, Primary } from '../types';
import { computed, toValue } from 'vue';

export interface UseGridTemplateOptions {
Expand All @@ -9,7 +9,6 @@ export interface UseGridTemplateOptions {
sizePercentage: ComputedRef<number>;
dividerSize: ComputedRef<number>;
primary: MaybeRefOrGetter<Primary | undefined>;
direction: MaybeRefOrGetter<Direction>;
orientation: MaybeRefOrGetter<Orientation>;
collapsedSizePercentage: ComputedRef<number>;
}
Expand All @@ -34,20 +33,10 @@ export const useGridTemplate = (options: UseGridTemplateOptions) => {
const secondary = 'auto';

if (!toValue(options.primary) || toValue(options.primary) === 'start') {
if (toValue(options.direction) === 'ltr' || toValue(options.orientation) === 'vertical') {
return `${primary} ${options.dividerSize.value}px ${secondary}`;
}
else {
return `${secondary} ${options.dividerSize.value}px ${primary}`;
}
return `${primary} ${options.dividerSize.value}px ${secondary}`;
}
else {
if (toValue(options.direction) === 'ltr' || toValue(options.orientation) === 'vertical') {
return `${secondary} ${options.dividerSize.value}px ${primary}`;
}
else {
return `${primary} ${options.dividerSize.value}px ${secondary}`;
}
return `${secondary} ${options.dividerSize.value}px ${primary}`;
}
});

Expand Down
7 changes: 4 additions & 3 deletions packages/vue-split-panel/src/composables/use-pointer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,11 @@ describe('usePointer', () => {
options.snapThreshold = ref(5);
usePointer(collapsed, sizePercentage, sizePixels, options);

// With RTL, snap point 100 becomes 400 - 100 = 300
mockDragX.value = 298; // Within threshold of transformed snap point
// With RTL, drag position is mirrored: newPositionInPixels = 400 - mockDragX
// mockDragX = 298 transforms to 102, which is within threshold of snap point 100
mockDragX.value = 298;
await nextTick();
expect(sizePercentage.value).toBe(75); // 300/400 * 100 = 75%
expect(sizePercentage.value).toBe(25); // 100/400 * 100 = 25%
});

it('should clamp sizePercentage between 0 and 100', async () => {
Expand Down
10 changes: 5 additions & 5 deletions packages/vue-split-panel/src/composables/use-pointer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export const usePointer = (collapsed: Ref<boolean>, sizePercentage: Ref<number>,

let newPositionInPixels = toValue(options.orientation) === 'horizontal' ? newX : newY;

if (toValue(options.orientation) === 'horizontal' && toValue(options.direction) === 'rtl') {
newPositionInPixels = options.componentSize.value - newPositionInPixels;
}

if (toValue(options.primary) === 'end') {
newPositionInPixels = options.componentSize.value - newPositionInPixels;
}
Expand All @@ -49,11 +53,7 @@ export const usePointer = (collapsed: Ref<boolean>, sizePercentage: Ref<number>,
}
}

for (let snapPoint of options.snapPixels.value) {
if (toValue(options.direction) === 'rtl' && toValue(options.orientation) === 'horizontal') {
snapPoint = options.componentSize.value - snapPoint;
}

for (const snapPoint of options.snapPixels.value) {
if (
newPositionInPixels >= snapPoint - toValue(options.snapThreshold)
&& newPositionInPixels <= snapPoint + toValue(options.snapThreshold)
Expand Down
Loading