@v-c/collapse 0.0.4 → 0.0.5

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/dist/Panel.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),o=require("@v-c/util"),y=require("@v-c/util/dist/KeyCode"),O=require("@v-c/util/dist/omit"),R=require("./PanelContent.cjs"),B={showArrow:!0,classNames:{},styles:{}},j=e.defineComponent({props:e.mergeDefaults({id:{type:String,required:!1},header:{type:null,required:!1},prefixCls:{type:String,required:!1},headerClass:{type:String,required:!1},showArrow:{type:Boolean,required:!1},class:{type:String,required:!1},classNames:{type:Object,required:!1},style:{type:Object,required:!1},styles:{type:Object,required:!1},isActive:{type:Boolean,required:!1},openMotion:{type:null,required:!1},destroyOnHidden:{type:Boolean,required:!1},accordion:{type:Boolean,required:!1},forceRender:{type:Boolean,required:!1},extra:{type:null,required:!1},onItemClick:{type:Function,required:!1},expandIcon:{type:Function,required:!1},panelKey:{type:[String,Number],required:!1},role:{type:String,required:!1},collapsible:{type:String,required:!1},children:{type:null,required:!1}},B),name:"CollapsePanel",inheritAttrs:!1,setup(a,{attrs:m,expose:q}){const d=e.computed(()=>a.collapsible==="disabled"),u=e.ref(),N=e.computed(()=>a.extra!==null&&a.extra!==void 0&&typeof a.extra!="boolean"),c=e.computed(()=>({onClick:()=>{a.onItemClick?.(a.panelKey)},onKeydown:l=>{(l.key==="Enter"||l.keyCode===y.ENTER||l.which===y.ENTER)&&a.onItemClick?.(a.panelKey)},role:a.accordion?"tab":"button","aria-expanded":a.isActive,"aria-disabled":d.value,tabIndex:d.value?-1:0}));return q({ref:u}),()=>{const{extra:l,prefixCls:s,isActive:r,class:h,expandIcon:f,forceRender:v,headerClass:C,collapsible:t,accordion:b,openMotion:x={},onItemClick:M,classNames:n={},showArrow:g=!0,destroyOnHidden:P,styles:i={},header:w,panelKey:T,children:S,...$}=a,A=o.classNames(`${s}-item`,{[`${s}-item-active`]:r,[`${s}-item-disabled`]:d.value},h),I={class:o.classNames(C,`${s}-header`,{[`${s}-collapsible-${t}`]:!!t},n.header),style:i.header,...["header","icon"].includes(t)?{}:c.value},p=typeof f=="function"?f(a):e.createVNode("i",{class:"arrow"},null),V=p&&e.createVNode("div",e.mergeProps({class:o.classNames(`${s}-expand-icon`,n?.icon),style:i?.icon},["header","icon"].includes(t)?c.value:{}),[p]),k=e.withDirectives(e.createVNode(R.default,{prefixCls:s,classNames:n,styles:i,isActive:r,forceRender:v,role:b?"tabpanel":void 0},{default:()=>S}),[[e.vShow,r]]),E={appear:!1,"leave-to-class":`${s}-panel-hidden`,...x},K={...$,...O(m,["class"])};return e.createVNode("div",e.mergeProps(K,{ref:u,class:A}),[e.createVNode("div",I,[g&&V,e.createVNode("span",e.mergeProps({class:o.classNames(`${s}-title`,n?.title),style:i?.title},t==="header"?c.value:{}),[w]),N.value&&e.createVNode("div",{class:`${s}-extra`},[l])]),e.createVNode(e.Transition,E,{default:()=>[!P||r?k:null]})])}}});exports.default=j;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),o=require("@v-c/util"),y=require("@v-c/util/dist/KeyCode"),O=require("@v-c/util/dist/omit"),R=require("./PanelContent.cjs"),B={showArrow:!0,classNames:{},styles:{}},j=e.defineComponent({props:e.mergeDefaults({id:{type:String,required:!1},header:{type:null,required:!1},prefixCls:{type:String,required:!1},headerClass:{type:String,required:!1},showArrow:{type:Boolean,required:!1},class:{type:String,required:!1},classNames:{type:Object,required:!1},style:{type:Object,required:!1},styles:{type:Object,required:!1},isActive:{type:Boolean,required:!1},openMotion:{type:null,required:!1},destroyOnHidden:{type:Boolean,required:!1},accordion:{type:Boolean,required:!1},forceRender:{type:Boolean,required:!1},extra:{type:null,required:!1},onItemClick:{type:Function,required:!1},expandIcon:{type:Function,required:!1},panelKey:{type:[String,Number],required:!1},role:{type:String,required:!1},collapsible:{type:String,required:!1},children:{type:null,required:!1}},B),name:"CollapsePanel",inheritAttrs:!1,setup(a,{attrs:m,expose:q}){const d=e.computed(()=>a.collapsible==="disabled"),u=e.ref(),N=e.computed(()=>a.extra!==null&&a.extra!==void 0&&typeof a.extra!="boolean"),c=e.computed(()=>({onClick:()=>{a.onItemClick?.(a.panelKey)},onKeydown:r=>{(r.key==="Enter"||r.keyCode===y.ENTER||r.which===y.ENTER)&&a.onItemClick?.(a.panelKey)},role:a.accordion?"tab":"button","aria-expanded":a.isActive,"aria-disabled":d.value,tabIndex:d.value?-1:0}));return q({ref:u}),()=>{const{extra:r,prefixCls:s,isActive:l,class:h,expandIcon:f,forceRender:v,headerClass:C,collapsible:t,accordion:b,openMotion:x={},onItemClick:M,classNames:n={},showArrow:g=!0,destroyOnHidden:P,styles:i={},header:w,panelKey:T,children:S,...$}=a,A=o.classNames(`${s}-item`,{[`${s}-item-active`]:l,[`${s}-item-disabled`]:d.value},h),I={class:o.classNames(C,`${s}-header`,{[`${s}-collapsible-${t}`]:!!t},n.header),style:i.header,...["header","icon"].includes(t)?{}:c.value},p=typeof f=="function"?f(a):e.createVNode("i",{class:"arrow"},null),V=p&&e.createVNode("div",e.mergeProps({class:o.classNames(`${s}-expand-icon`,n?.icon),style:i?.icon},["header","icon"].includes(t)?c.value:{}),[p]),k=e.withDirectives(e.createVNode(R.default,{prefixCls:s,classNames:n,styles:i,isActive:l,forceRender:v,role:b?"tabpanel":void 0},{default:()=>S}),[[e.vShow,l]]),E={appear:!1,...x},K={...$,...O(m,["class"])};return e.createVNode("div",e.mergeProps(K,{ref:u,class:A}),[e.createVNode("div",I,[g&&V,e.createVNode("span",e.mergeProps({class:o.classNames(`${s}-title`,n?.title),style:i?.title},t==="header"?c.value:{}),[w]),N.value&&e.createVNode("div",{class:`${s}-extra`},[r])]),e.createVNode(e.Transition,E,{default:()=>[!P||l?k:null]})])}}});exports.default=j;
package/dist/Panel.js CHANGED
@@ -100,7 +100,7 @@ const W = {
100
100
  attrs: q,
101
101
  expose: C
102
102
  }) {
103
- const d = u(() => e.collapsible === "disabled"), p = D(), v = u(() => e.extra !== null && e.extra !== void 0 && typeof e.extra != "boolean"), c = u(() => ({
103
+ const d = u(() => e.collapsible === "disabled"), p = D(), b = u(() => e.extra !== null && e.extra !== void 0 && typeof e.extra != "boolean"), c = u(() => ({
104
104
  onClick: () => {
105
105
  e.onItemClick?.(e.panelKey);
106
106
  },
@@ -119,7 +119,7 @@ const W = {
119
119
  extra: s,
120
120
  prefixCls: a,
121
121
  isActive: t,
122
- class: b,
122
+ class: v,
123
123
  expandIcon: y,
124
124
  forceRender: x,
125
125
  headerClass: N,
@@ -138,7 +138,7 @@ const W = {
138
138
  } = e, k = o(`${a}-item`, {
139
139
  [`${a}-item-active`]: t,
140
140
  [`${a}-item-disabled`]: d.value
141
- }, b), E = {
141
+ }, v), E = {
142
142
  class: o(N, `${a}-header`, {
143
143
  [`${a}-collapsible-${r}`]: !!r
144
144
  }, n.header),
@@ -160,7 +160,7 @@ const W = {
160
160
  default: () => I
161
161
  }), [[H, t]]), B = {
162
162
  appear: !1,
163
- "leave-to-class": `${a}-panel-hidden`,
163
+ // leaveToClass: `${prefixCls}-panel-hidden`,
164
164
  ...g
165
165
  }, O = {
166
166
  ...S,
@@ -172,7 +172,7 @@ const W = {
172
172
  }), [l("div", E, [P && K, l("span", f({
173
173
  class: o(`${a}-title`, n?.title),
174
174
  style: i?.title
175
- }, r === "header" ? c.value : {}), [A]), v.value && l("div", {
175
+ }, r === "header" ? c.value : {}), [A]), b.value && l("div", {
176
176
  class: `${a}-extra`
177
177
  }, [s])]), l(M, B, {
178
178
  default: () => [!$ || t ? R : null]
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@v-c/collapse",
3
3
  "type": "module",
4
- "version": "0.0.4",
4
+ "version": "0.0.5",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
+ "files": [
9
+ "dist"
10
+ ],
8
11
  "exports": {
9
12
  ".": {
10
13
  "types": "./dist/index.d.ts",
package/assets/index.less DELETED
@@ -1,117 +0,0 @@
1
- @prefixCls: vc-collapse;
2
- @text-color: #666;
3
- @borderStyle: 1px solid #d9d9d9;
4
-
5
- @import "./motion.less";
6
-
7
- #arrow {
8
- .common() {
9
- width: 0;
10
- height: 0;
11
- font-size: 0;
12
- line-height: 0;
13
- }
14
- .right(@w, @h, @color) {
15
- border-top: @w solid transparent;
16
- border-bottom: @w solid transparent;
17
- border-left: @h solid @color;
18
- }
19
-
20
- .bottom(@w, @h, @color) {
21
- border-left: @w solid transparent;
22
- border-right: @w solid transparent;
23
- border-top: @h solid @color;
24
- }
25
- }
26
-
27
- .@{prefixCls} {
28
- background-color: #f7f7f7;
29
- border-radius: 3px;
30
- border: @borderStyle;
31
-
32
- // &-anim-active {
33
- // transition: height 0.2s ease-out;
34
- // }
35
-
36
- & > &-item {
37
- border-top: @borderStyle;
38
- &:first-child {
39
- border-top: none;
40
- }
41
-
42
- > .@{prefixCls}-header {
43
- display: flex;
44
- align-items: center;
45
- line-height: 22px;
46
- padding: 10px 16px;
47
- color: #666;
48
- cursor: pointer;
49
- .arrow {
50
- display: inline-block;
51
- content: "\20";
52
- #arrow > .common();
53
- #arrow > .right(3px, 4px, #666);
54
- vertical-align: middle;
55
- margin-right: 8px;
56
- }
57
-
58
- .@{prefixCls}-extra {
59
- margin: 0 16px 0 auto;
60
- }
61
- }
62
- .@{prefixCls}-collapsible-header {
63
- cursor: default;
64
- .@{prefixCls}-title {
65
- cursor: pointer;
66
- }
67
- .@{prefixCls}-expand-icon {
68
- cursor: pointer;
69
- }
70
- }
71
- .@{prefixCls}-collapsible-icon {
72
- cursor: default;
73
- .@{prefixCls}-expand-icon {
74
- cursor: pointer;
75
- }
76
- }
77
- }
78
-
79
- & > &-item-disabled > .@{prefixCls}-header {
80
- cursor: not-allowed;
81
- color: #999;
82
- background-color: #f3f3f3;
83
- }
84
-
85
- &-panel {
86
- overflow: hidden;
87
- color: @text-color;
88
- padding: 0 16px;
89
- background-color: #fff;
90
-
91
- & > &-box {
92
- margin-top: 16px;
93
- margin-bottom: 16px;
94
- }
95
-
96
- // &-inactive {
97
- // display: none;
98
- // }
99
- }
100
-
101
- &-item:last-child {
102
- > .@{prefixCls}-panel {
103
- border-radius: 0 0 3px 3px;
104
- }
105
- }
106
-
107
- & > &-item-active {
108
- > .@{prefixCls}-header {
109
- .arrow {
110
- position: relative;
111
- top: 2px;
112
- #arrow > .bottom(3px, 4px, #666);
113
- margin-right: 6px;
114
- }
115
- }
116
- }
117
- }
@@ -1,14 +0,0 @@
1
- @prefixCls: vc-collapse;
2
-
3
- .@{prefixCls} {
4
- &-enter-active,
5
- &-leave-active {
6
- transition:
7
- height 0.3s,
8
- opacity 0.3s;
9
- }
10
-
11
- &-panal-hidden {
12
- display: none;
13
- }
14
- }
@@ -1,45 +0,0 @@
1
- <script setup lang="ts">
2
- import type { CollapseProps } from '../src/interface'
3
- import { h } from 'vue'
4
- import Collapse from '../src/index'
5
- import CustomIcon from './custom-icon.vue'
6
- import Simple from './simple.vue'
7
- import '../assets/index.less'
8
-
9
- const basicCollapseItems: CollapseProps['items'] = [
10
- {
11
- label: h('input', {
12
- onKeydown: (e: KeyboardEvent) => {
13
- e.stopPropagation()
14
- },
15
- }),
16
- children: 'content',
17
- },
18
- {
19
- label: 'title 2',
20
- children: 'content 2',
21
- collapsible: 'disabled',
22
- },
23
- {
24
- label: 'title 3',
25
- children: 'content 3',
26
- onItemClick: console.log,
27
- },
28
- ]
29
- </script>
30
-
31
- <template>
32
- <Story title="Collapse">
33
- <Variant title="Basic">
34
- <Collapse :items="basicCollapseItems" />
35
- </Variant>
36
-
37
- <Variant title="custom icon">
38
- <CustomIcon />
39
- </Variant>
40
-
41
- <Variant title="simple">
42
- <Simple />
43
- </Variant>
44
- </Story>
45
- </template>
@@ -1,185 +0,0 @@
1
- <script setup lang="ts">
2
- import type { CollapseProps } from '../src/index'
3
- import { h, ref, shallowRef, watch } from 'vue'
4
- import Collapse from '../src/index'
5
-
6
- const initLength = 3
7
-
8
- const text = `
9
- A dog is a type of domesticated animal.
10
- Known for its loyalty and faithfulness,
11
- it can be found as a welcome guest in many households across the world.
12
- `
13
-
14
- function random() {
15
- return parseInt((Math.random() * 10).toString(), 10) + 1
16
- }
17
-
18
- const arrowPath
19
- = 'M869 487.8L491.2 159.9c-2.9-2.5-6.6-3.9-10.5-3.9h-88'
20
- + '.5c-7.4 0-10.8 9.2-5.2 14l350.2 304H152c-4.4 0-8 3.6-8 8v60c0 4.4 3.'
21
- + '6 8 8 8h585.1L386.9 854c-5.6 4.9-2.2 14 5.2 14h91.5c1.9 0 3.8-0.7 5.'
22
- + '2-2L869 536.2c14.7-12.8 14.7-35.6 0-48.4z'
23
-
24
- function expandIcon({ isActive }: { isActive: boolean }) {
25
- return h(
26
- 'i',
27
- {
28
- style: {
29
- 'margin-right': '.5rem',
30
- },
31
- },
32
- [
33
- h(
34
- 'svg',
35
- {
36
- viewBox: '0 0 1024 1024',
37
- width: '1em',
38
- height: '1em',
39
- fill: 'currentColor',
40
- style: {
41
- verticalAlign: '-.125em',
42
- transition: 'transform .2s',
43
- transform: `rotate(${isActive ? 90 : 0}deg)`,
44
- },
45
- },
46
- [
47
- h('path', {
48
- d: arrowPath,
49
- }),
50
- ],
51
- ),
52
- ],
53
- )
54
- }
55
-
56
- const rerender = ref(0)
57
- const accordion = ref(false)
58
- const activeKey = ref<Array<string | number | bigint>>(['4'])
59
-
60
- const time = ref(random())
61
- watch(
62
- () => [rerender.value, accordion.value, activeKey.value],
63
- () => {
64
- time.value = random()
65
- },
66
- )
67
-
68
- function handleSetActiveKey(e: Array<string | number | bigint>) {
69
- activeKey.value = e
70
- }
71
-
72
- function getCollapsedHeight(el: HTMLDivElement) {
73
- el.style.height = '0'
74
- el.style.opacity = '0'
75
- }
76
- function getRealHeight(el: HTMLDivElement) {
77
- console.log(el.scrollHeight)
78
- el.style.height = `${el.scrollHeight}px`
79
- el.style.opacity = '1'
80
- }
81
- function getCurrentHeight(el: HTMLDivElement) {
82
- el.style.height = `${el.offsetHeight}px`
83
- }
84
-
85
- function skipOpacityTransition(el: HTMLDivElement) {
86
- el.style.height = ''
87
- }
88
- const openMotion = {
89
- name: 'vc-collapse',
90
- onBeforeEnter: getCollapsedHeight,
91
- onEnter: getRealHeight,
92
- onAfterEnter: skipOpacityTransition,
93
- onBeforeLeave: getCurrentHeight,
94
- onLeave: getCollapsedHeight,
95
- onAfterLeave: skipOpacityTransition,
96
- }
97
-
98
- const items = shallowRef<CollapseProps['items']>([])
99
- function handleUpdateItems() {
100
- items.value = Array.from({ length: initLength })
101
- .map((_, i) => {
102
- return {
103
- label: `This is panel header ${i + 1}`,
104
- key: i + 1,
105
- children: h('p', {}, [text.repeat(time.value)]),
106
- }
107
- })
108
- .concat([
109
- {
110
- label: `This is panel header ${initLength + 1}`,
111
- key: initLength + 1,
112
- children: h(Collapse, {
113
- defaultActiveKey: '1',
114
- expandIcon,
115
- items: [
116
- {
117
- label: 'This is panel nest panel',
118
- key: '1',
119
- children: h('p', {}, [text]),
120
- },
121
- ],
122
- }),
123
- },
124
- {
125
- label: `This is panel header ${initLength + 2}`,
126
- key: initLength + 2,
127
- children: h(Collapse, {
128
- defaultActiveKey: '1',
129
- items: [
130
- {
131
- label: 'This is panel nest panel',
132
- children: h('form', {}, [
133
- h(
134
- 'label',
135
- {
136
- htmlFor: 'test',
137
- },
138
- ['Name:&nbsp;'],
139
- ),
140
- h('input', {
141
- type: 'text',
142
- id: 'test',
143
- }),
144
- ]),
145
- },
146
- ],
147
- }),
148
- },
149
- ])
150
- }
151
- watch(
152
- () => time.value,
153
- () => {
154
- handleUpdateItems()
155
- },
156
- { immediate: true },
157
- )
158
- </script>
159
-
160
- <template>
161
- <button type="button" @click="rerender += 1">
162
- reRender
163
- </button>
164
- <br>
165
- <br>
166
- <button type="button" @click="accordion = !accordion">
167
- {{ accordion ? "Mode: accordion" : "Mode: collapse" }}
168
- </button>
169
- <br>
170
- <br>
171
- <button type="button" @click="activeKey = ['2']">
172
- active header 2
173
- </button>
174
- <br>
175
- <br>
176
-
177
- <Collapse
178
- :accordion="accordion"
179
- :active-key="activeKey"
180
- :expand-icon="expandIcon"
181
- :open-motion="openMotion"
182
- :items="items"
183
- @change="handleSetActiveKey"
184
- />
185
- </template>
package/docs/simple.vue DELETED
@@ -1,218 +0,0 @@
1
- <script setup lang="ts">
2
- import type { CollapseProps } from '../src/index'
3
- import { h, ref, shallowRef, watch } from 'vue'
4
- import Collapse from '../src/index'
5
-
6
- const initLength = 3
7
-
8
- const text = `
9
- A dog is a type of domesticated animal.
10
- Known for its loyalty and faithfulness,
11
- it can be found as a welcome guest in many households across the world.
12
- `
13
-
14
- function random() {
15
- return parseInt((Math.random() * 10).toString(), 10) + 1
16
- }
17
-
18
- const arrowPath
19
- = 'M869 487.8L491.2 159.9c-2.9-2.5-6.6-3.9-10.5-3.9h-88'
20
- + '.5c-7.4 0-10.8 9.2-5.2 14l350.2 304H152c-4.4 0-8 3.6-8 8v60c0 4.4 3.'
21
- + '6 8 8 8h585.1L386.9 854c-5.6 4.9-2.2 14 5.2 14h91.5c1.9 0 3.8-0.7 5.'
22
- + '2-2L869 536.2c14.7-12.8 14.7-35.6 0-48.4z'
23
-
24
- function expandIcon({ isActive }: { isActive: boolean }) {
25
- return h(
26
- 'i',
27
- {
28
- style: {
29
- 'margin-right': '.5rem',
30
- },
31
- },
32
- [
33
- h(
34
- 'svg',
35
- {
36
- viewBox: '0 0 1024 1024',
37
- width: '1em',
38
- height: '1em',
39
- fill: 'currentColor',
40
- style: {
41
- verticalAlign: '-.125em',
42
- transition: 'transform .2s',
43
- transform: `rotate(${isActive ? 90 : 0}deg)`,
44
- },
45
- },
46
- [
47
- h('path', {
48
- d: arrowPath,
49
- }),
50
- ],
51
- ),
52
- ],
53
- )
54
- }
55
-
56
- const rerender = ref(0)
57
- const accordion = ref(false)
58
- const activeKey = ref<Array<string | number | bigint>>(['4'])
59
- const collapsible = ref<CollapseProps['collapsible']>()
60
-
61
- const time = ref(random())
62
- watch(
63
- () => [rerender.value, accordion.value, activeKey.value],
64
- () => {
65
- time.value = random()
66
- },
67
- )
68
-
69
- function handleSetActiveKey(e: Array<string | number | bigint>) {
70
- activeKey.value = e
71
- }
72
-
73
- function getCollapsedHeight(el: HTMLDivElement) {
74
- el.style.height = '0'
75
- el.style.opacity = '0'
76
- }
77
- function getRealHeight(el: HTMLDivElement) {
78
- console.log(el.scrollHeight)
79
- el.style.height = `${el.scrollHeight}px`
80
- el.style.opacity = '1'
81
- }
82
- function getCurrentHeight(el: HTMLDivElement) {
83
- el.style.height = `${el.offsetHeight}px`
84
- }
85
-
86
- function skipOpacityTransition(el: HTMLDivElement) {
87
- el.style.height = ''
88
- }
89
- const openMotion = {
90
- name: 'vc-collapse',
91
- onBeforeEnter: getCollapsedHeight,
92
- onEnter: getRealHeight,
93
- onAfterEnter: skipOpacityTransition,
94
- onBeforeLeave: getCurrentHeight,
95
- onLeave: getCollapsedHeight,
96
- onAfterLeave: skipOpacityTransition,
97
- }
98
-
99
- const items = shallowRef<CollapseProps['items']>([])
100
- function handleUpdateItems() {
101
- items.value = Array.from({ length: initLength })
102
- .map((_, i) => {
103
- return {
104
- label: `This is panel header ${i + 1}`,
105
- key: i + 1,
106
- children: h('p', {}, [text.repeat(time.value)]),
107
- }
108
- })
109
-
110
- items.value = items.value.concat([
111
- {
112
- label: `This is panel header ${initLength + 1}`,
113
- key: initLength + 1,
114
- children: h(Collapse, {
115
- defaultActiveKey: '1',
116
- expandIcon,
117
- items: [
118
- {
119
- label: 'This is panel nest panel',
120
- key: '1',
121
- children: h('p', {}, [text]),
122
- },
123
- ],
124
- }),
125
- },
126
- {
127
- label: `This is panel header ${initLength + 2}`,
128
- key: initLength + 2,
129
- children: h(Collapse, {
130
- defaultActiveKey: '1',
131
- items: [
132
- {
133
- label: 'This is panel nest panel',
134
- children: h('form', {}, [
135
- h(
136
- 'label',
137
- {
138
- htmlFor: 'test',
139
- },
140
- ['Name:&nbsp;'],
141
- ),
142
- h('input', {
143
- type: 'text',
144
- id: 'test',
145
- }),
146
- ]),
147
- },
148
- ],
149
- }),
150
- },
151
- {
152
- label: `This is panel header ${initLength + 3}`,
153
- key: initLength + 3,
154
- extra: h('span', {}, ['Extra Node']),
155
- children: h('p', {}, ['Panel with extra']),
156
- },
157
- ])
158
- }
159
- watch(
160
- () => time.value,
161
- () => {
162
- handleUpdateItems()
163
- },
164
- { immediate: true },
165
- )
166
-
167
- function handleCollapsibleChange(e: Event) {
168
- const values = [undefined, 'header', 'icon', 'disabled']
169
- collapsible.value = Reflect.get(values, (e.target as HTMLSelectElement).value) as CollapseProps['collapsible']
170
- console.log(collapsible.value)
171
- }
172
- </script>
173
-
174
- <template>
175
- <button type="button" @click="rerender += 1">
176
- reRender
177
- </button>
178
- <br>
179
- <br>
180
- <button type="button" @click="accordion = !accordion">
181
- {{ accordion ? "Mode: accordion" : "Mode: collapse" }}
182
- </button>
183
- <br>
184
- <br>
185
- <div>
186
- collapsible:
187
- <select @change="handleCollapsibleChange">
188
- <option :value="0">
189
- default
190
- </option>
191
- <option :value="1">
192
- header
193
- </option>
194
- <option :value="2">
195
- icon
196
- </option>
197
- <option :value="3">
198
- disabled
199
- </option>
200
- </select>
201
- </div>
202
- <br>
203
- <button type="button" @click="activeKey = ['2']">
204
- active header 2
205
- </button>
206
- <br>
207
- <br>
208
-
209
- <Collapse
210
- :accordion="accordion"
211
- :active-key="activeKey"
212
- :expand-icon="expandIcon"
213
- :open-motion="openMotion"
214
- :collapsible="collapsible"
215
- :items="items"
216
- @change="handleSetActiveKey"
217
- />
218
- </template>