Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 93293db

Browse files
Merge branch 'develop' into fix/textarea-event-error
2 parents 7a108cd + c4307d6 commit 93293db

File tree

4 files changed

+48
-19
lines changed

4 files changed

+48
-19
lines changed

.changeset/dull-books-judge.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@chakra-ui/vue": patch
3+
---
4+
5+
Include CGridItem in type definitions

packages/chakra-ui-core/src/CInputGroup/CInputGroup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const CInputGroup = {
5353
const clone = cloneVNode(vnode, h)
5454
return h(clone.componentOptions.Ctor, {
5555
...clone.data,
56-
...(clone.componentOptions.listeners || {}),
56+
on: (clone.componentOptions.listeners || {}),
5757
props: {
5858
...(clone.data.props || {}),
5959
...clone.componentOptions.propsData,
Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,72 @@
11
import { merge } from 'lodash-es'
22

3+
/**
4+
* @param {String} prefix - prefix for the icon pack
5+
* @param {Array} icon - icon definition
6+
* @returns {{path: string, viewBox: string, attrs: *}}
7+
*/
8+
const createIcon = (prefix, icon) => {
9+
const [w, h, content, svg, data, , attrs] = icon
10+
let path
11+
12+
const createPath = (d, attrs = {}) => `<path d="${d}" ${attrs.className ? `class="${attrs.className}"` : ''} fill="currentColor" />`
13+
14+
const createGroupedPath = (groups, prefix) => {
15+
const paths = groups.map((d, idx) =>
16+
createPath(d, {
17+
className: idx ? `${prefix}-primary` : `${prefix}-secondary`,
18+
})
19+
)
20+
21+
return `<g fill="currentColor" class="${prefix}-group">${paths.join('')}</g>`
22+
}
23+
24+
if (prefix.startsWith('fa')) {
25+
path = Array.isArray(data)
26+
? createGroupedPath(data, prefix.substr(0, 2))
27+
: createPath(data)
28+
} else {
29+
path = prefix.startsWith('fe') ? content : svg
30+
}
31+
32+
return {
33+
path,
34+
viewBox: `0 0 ${w} ${h}`,
35+
attrs,
36+
}
37+
}
38+
339
/**
440
* @description Custom parse all Icons provided by user
541
* @param {Object} iconSet - Registered Icons object
642
* @returns {Object}
743
*/
844
const parseIcons = (iconSet = {}) => {
945
const parseIcon = (iconObject) => {
10-
const { icon } = iconObject
46+
const { icon, prefix, iconName } = iconObject
1147
// Is library icon
1248
if (icon) {
13-
const [w, h, content, svg, path, , attrs] = icon
1449
return {
15-
[`${iconObject.iconName}`]: {
16-
path: iconObject.prefix.startsWith('fa')
17-
? `<path d="${path}" fill="currentColor" />`
18-
: iconObject.prefix.startsWith('fe')
19-
? content
20-
: svg,
21-
viewBox: `0 0 ${w} ${h}`,
22-
attrs
23-
}
50+
[`${iconName}`]: createIcon(prefix, icon)
2451
}
2552
} else {
2653
return {}
2754
}
2855
}
2956

30-
const result = Object.values(iconSet)
57+
return Object.values(iconSet)
3158
.map(value => parseIcon(value))
3259
.reduce((target, source) => merge(target, source), {})
33-
34-
return result
3560
}
3661

3762
/**
3863
* @description Parse Icon packs
39-
* @param {String} pack Icon pack name
4064
* @param {Object} iconSet Registered Icon set
4165
* @returns {Object} Parsed pack icons object
4266
*/
4367
export const parsePackIcons = (iconSet) => {
4468
// TODO: Add support for other icon libraries
45-
// - Material Icons
69+
// - Material Icons: these are string constants, and need lots of work
4670
// - Tailwind Icons (Hero icons)
47-
const packIcons = parseIcons(iconSet)
48-
return packIcons
71+
return parseIcons(iconSet)
4972
}

packages/chakra-ui-core/types/component.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export class CFormHelperText extends Vue {}
5858
export class CFormLabel extends Vue {}
5959
export class CFragment extends Vue {}
6060
export class CGrid extends Vue {}
61+
export class CGridItem extends Vue {}
6162
export class CHeading extends Vue {}
6263
export class CIcon extends Vue {}
6364
export class CIconButton extends Vue {}

0 commit comments

Comments
 (0)