Skip to content

Commit 9e06b34

Browse files
authored
feat(Splitter): expose collapse, expand, and resize on SplitterPanel slot (#1888)
1 parent 995ecc4 commit 9e06b34

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

packages/core/src/Splitter/SplitterPanel.vue

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ defineSlots<{
7474
isCollapsed: typeof isCollapsed.value
7575
/** Is the panel expanded */
7676
isExpanded: typeof isExpanded.value
77+
/** If panel is `collapsible`, collapse it fully. */
78+
collapse: typeof collapse
79+
/** If panel is currently collapsed, expand it to its most recent size. */
80+
expand: typeof expand
81+
/** Resize panel to the specified percentage (1 - 100). */
82+
resize: typeof resize
7783
}) => any
7884
}>()
7985
@@ -134,23 +140,29 @@ const style = computed(() => getPanelStyle(panelDataRef.value, props.defaultSize
134140
const isCollapsed = computed(() => isPanelCollapsed(panelDataRef.value))
135141
const isExpanded = computed(() => !isCollapsed.value)
136142
143+
function collapse() {
144+
collapsePanel(panelDataRef.value)
145+
}
146+
147+
function expand() {
148+
expandPanel(panelDataRef.value)
149+
}
150+
151+
function resize(size: number) {
152+
resizePanel(panelDataRef.value, size)
153+
}
154+
137155
defineExpose({
138156
/** If panel is `collapsible`, collapse it fully. */
139-
collapse: () => {
140-
collapsePanel(panelDataRef.value)
141-
},
157+
collapse,
142158
/** If panel is currently collapsed, expand it to its most recent size. */
143-
expand: () => {
144-
expandPanel(panelDataRef.value)
145-
},
159+
expand,
146160
/** Gets the current size of the panel as a percentage (1 - 100). */
147161
getSize() {
148162
return getPanelSize(panelDataRef.value)
149163
},
150164
/** Resize panel to the specified percentage (1 - 100). */
151-
resize: (size: number) => {
152-
resizePanel(panelDataRef.value, size)
153-
},
165+
resize,
154166
/** Returns `true` if the panel is currently collapsed */
155167
isCollapsed,
156168
/** Returns `true` if the panel is currently not collapsed */
@@ -174,6 +186,9 @@ defineExpose({
174186
<slot
175187
:is-collapsed="isCollapsed"
176188
:is-expanded="isExpanded"
189+
:expand="expand"
190+
:collapse="collapse"
191+
:resize="resize"
177192
/>
178193
</Primitive>
179194
</template>

0 commit comments

Comments
 (0)