Skip to content

Commit 760ff66

Browse files
Todd Baurpi0
authored andcommitted
created input-group-append and input-group-prepend components with the goal of retaining the input-group-addon component. Ideally the input-group-addon component would become deprecated (including using the slot values left/right on input-group).
1 parent 3b1dc16 commit 760ff66

File tree

8 files changed

+92
-6
lines changed

8 files changed

+92
-6
lines changed

src/components/input-group/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
44
```html
55
<div>
6-
<b-input-group left="$" right=".00">
6+
<b-input-group>
7+
<b-input-group-prepend>$</b-input-group-prepend>
78
<b-form-input></b-form-input>
9+
<b-input-group-append>.00</b-input-group-append>
810
</b-input-group>
911

1012
<br>

src/components/input-group/fixtures/input-group.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<div id="app">
2-
<b-input-group ref="basic" left="$" right=".00">
2+
<b-input-group ref="basic">
3+
<input-group-prepend>$</input-group-prepend>
34
<b-input></b-input>
5+
<input-group-append>$</input-group-append>
46
</b-input-group>
57

68
<b-input-group ref="components">

src/components/input-group/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import bInputGroup from './input-group'
22
import bInputGroupAddon from './input-group-addon'
3+
import bInputGroupPrepend from './input-group-prepend'
4+
import bInputGroupAppend from './input-group-append'
5+
import bInputGroupText from './input-group-text'
36
import bInputGroupButton from './input-group-button'
47
import { registerComponents, vueUse } from '../../utils'
58

@@ -8,7 +11,10 @@ import { registerComponents, vueUse } from '../../utils'
811
const components = {
912
bInputGroup,
1013
bInputGroupAddon,
14+
bInputGroupPrepend,
15+
bInputGroupAppend,
1116
bInputGroupButton,
17+
bInputGroupText,
1218
bInputGroupBtn: bInputGroupButton
1319
}
1420

src/components/input-group/input-group-addon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { mergeData } from '../../utils'
2-
2+
import InputGroupText from './input-group-text'
33
export const props = {
44
id: {
55
type: String,
@@ -21,7 +21,7 @@ export default {
2121
staticClass: `input-group-${data.slot === 'left' ? 'prepend' : 'append'}`,
2222
attrs: { id: props.id }
2323
}),
24-
children
24+
[h(InputGroupText, { }, children)]
2525
)
2626
}
2727
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { mergeData } from '../../utils'
2+
import InputGroupText from './input-group-text'
3+
4+
export const props = {
5+
id: {
6+
type: String,
7+
default: null
8+
},
9+
tag: {
10+
type: String,
11+
default: 'div'
12+
}
13+
}
14+
15+
export default {
16+
props,
17+
functional: true,
18+
render (h, {props, data, children}) {
19+
return h(
20+
props.tag,
21+
mergeData(data, {
22+
staticClass: 'input-group-append',
23+
attrs: {
24+
id: props.id
25+
}
26+
}),
27+
[h(InputGroupText, { }, children )]
28+
)
29+
}
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import InputGroupText from './input-group-text'
2+
import { mergeData } from '../../utils'
3+
4+
export const props = {
5+
id: {
6+
type: String,
7+
default: null
8+
},
9+
tag: {
10+
type: String,
11+
default: 'div'
12+
}
13+
}
14+
15+
export default {
16+
props,
17+
functional: true,
18+
render (h, {props, data, children}) {
19+
return h(
20+
props.tag,
21+
mergeData(data, {
22+
staticClass: 'input-group-prepend',
23+
attrs: {
24+
id: props.id
25+
}
26+
}),
27+
[h(InputGroupText, { domProps: { innerHTML: '' } }, children)]
28+
)
29+
}
30+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { mergeData } from '../../utils'
2+
3+
export const props = {
4+
tag: {
5+
type: String,
6+
default: 'div'
7+
}
8+
}
9+
10+
export default {
11+
props,
12+
functional: true,
13+
render (h, { props, data }) {
14+
return h(props.tag, mergeData(data, { staticClass: 'input-group-text' }))
15+
}
16+
}

src/components/input-group/input-group.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ describe('input-group', async () => {
2424
})
2525
})
2626

27-
it('basic should have `.input-group-append` as first child', async () => {
27+
it('basic should have `div.input-group-prepend` as first child', async () => {
2828
const { app: { $refs } } = window
2929

3030
const left = $refs.basic.children[0]
3131
expect(left).toBeDefined()
32-
expect(left).toHaveClass('input-group-append')
32+
expect(left).toHaveClass('input-group-prepend')
3333
})
3434

3535
it('basic should have content in left `.input-group-prepend`', async () => {

0 commit comments

Comments
 (0)