@symbo.ls/icon 2.11.451 → 2.11.455
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/index.js +90 -66
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -2,91 +2,75 @@
|
|
|
2
2
|
|
|
3
3
|
import { isString, exec, replaceLiteralsWithObjectFields } from '@domql/utils'
|
|
4
4
|
|
|
5
|
+
const inheritFromIsActive = (el) => {
|
|
6
|
+
const { props } = el
|
|
7
|
+
const propsActive = props['.isActive']
|
|
8
|
+
return el.call('exec', propsActive.name || propsActive.icon)
|
|
9
|
+
}
|
|
10
|
+
|
|
5
11
|
const getIconName = (el, s) => {
|
|
6
|
-
const { key, props
|
|
7
|
-
let
|
|
12
|
+
const { key, props } = el
|
|
13
|
+
let icon = el.call('exec', props.name || props.icon || key, el)
|
|
8
14
|
|
|
9
|
-
if (isString(
|
|
10
|
-
|
|
15
|
+
if (isString(icon) && icon.includes('{{')) {
|
|
16
|
+
icon = el.call('replaceLiteralsWithObjectFields', icon, s)
|
|
11
17
|
}
|
|
12
18
|
|
|
13
|
-
return
|
|
19
|
+
return el.call('isString', icon) ? icon : key
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
export const Icon = {
|
|
17
23
|
extend: 'Svg',
|
|
18
24
|
deps: { isString, replaceLiteralsWithObjectFields },
|
|
19
|
-
props: (el, s) => {
|
|
20
|
-
const { props, parent,
|
|
21
|
-
const { ICONS,
|
|
22
|
-
const { toCamelCase } =
|
|
25
|
+
props: (el, s, ctx) => {
|
|
26
|
+
const { props, parent, deps } = el
|
|
27
|
+
const { ICONS, useIconSprite, verbose } = ctx && ctx.designSystem
|
|
28
|
+
const { toCamelCase } = ctx && ctx.utils
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
const iconName = getIconName(el, s)
|
|
25
31
|
const camelCase = toCamelCase(iconName)
|
|
26
32
|
const isArray = camelCase.split(/([a-z])([A-Z])/g)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const semanticIcon = SEMANTIC_ICONS && SEMANTIC_ICONS[semanticIconRootName]
|
|
30
|
-
if (semanticIcon) {
|
|
31
|
-
const iconKey = iconName.includes('.') ? 'sfsymbols.' + iconName.split('.').slice(1).join('.') : 'sfsymbols'
|
|
32
|
-
iconName = semanticIcon[iconKey] || semanticIcon[iconName.split('.')[0].split(' ')[0]]
|
|
33
|
-
return {
|
|
34
|
-
tag: 'span',
|
|
35
|
-
semantic_symbols: true,
|
|
36
|
-
width: 'A',
|
|
37
|
-
height: 'A',
|
|
38
|
-
lineHeight: '1em',
|
|
39
|
-
':after': {
|
|
40
|
-
fontSize: 'Z',
|
|
41
|
-
fontWeight: '300',
|
|
42
|
-
content: `"${iconName}"`,
|
|
43
|
-
textAlign: 'center',
|
|
44
|
-
display: 'inline-block',
|
|
45
|
-
style: {
|
|
46
|
-
color: 'currentColor',
|
|
47
|
-
fontFamily: "'SF Pro Icons', 'SF Pro', 'SF Symbols', 'Segoe UI'"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
33
|
+
const semanticIcon = getSemanticIcon(el, s, ctx)
|
|
34
|
+
if (semanticIcon) return semanticIcon
|
|
52
35
|
|
|
53
36
|
let activeIconName
|
|
54
|
-
if (props.isActive)
|
|
55
|
-
|
|
56
|
-
|
|
37
|
+
if (props.isActive) activeIconName = inheritFromIsActive(el)
|
|
38
|
+
const parentProps = parent.props
|
|
39
|
+
const parentPropsActive = parentProps['.isActive']
|
|
57
40
|
if (
|
|
58
41
|
parent &&
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
42
|
+
parentProps &&
|
|
43
|
+
parentProps.isActive &&
|
|
44
|
+
parentPropsActive &&
|
|
45
|
+
parentPropsActive.icon
|
|
63
46
|
) {
|
|
64
47
|
activeIconName = exec(
|
|
65
|
-
|
|
66
|
-
|
|
48
|
+
parentPropsActive.icon || parentPropsActive.Icon.name || parentPropsActive.Icon.icon,
|
|
49
|
+
el
|
|
50
|
+
)
|
|
67
51
|
}
|
|
68
52
|
|
|
69
53
|
if (isString(activeIconName) && activeIconName.includes('{{')) {
|
|
70
|
-
activeIconName = deps.replaceLiteralsWithObjectFields(activeIconName,
|
|
54
|
+
activeIconName = deps.replaceLiteralsWithObjectFields(activeIconName, s)
|
|
71
55
|
}
|
|
72
56
|
|
|
73
|
-
let
|
|
74
|
-
if (ICONS[activeIconName])
|
|
75
|
-
if (ICONS[camelCase])
|
|
76
|
-
else if (ICONS[isArray[0] + isArray[1]])
|
|
77
|
-
else if (ICONS[isArray[0]])
|
|
57
|
+
let iconInContext
|
|
58
|
+
if (ICONS[activeIconName]) iconInContext = activeIconName
|
|
59
|
+
if (ICONS[camelCase]) iconInContext = camelCase
|
|
60
|
+
else if (ICONS[isArray[0] + isArray[1]]) iconInContext = isArray[0] + isArray[1]
|
|
61
|
+
else if (ICONS[isArray[0]]) iconInContext = isArray[0]
|
|
78
62
|
else {
|
|
79
|
-
if (verbose)
|
|
63
|
+
if (verbose) el.warn('Can\'t find icon:', iconName, iconInContext)
|
|
80
64
|
}
|
|
81
65
|
|
|
82
|
-
const iconFromLibrary = ICONS[
|
|
66
|
+
const iconFromLibrary = ICONS[iconInContext]
|
|
83
67
|
const directSrc = (parent && parent.props && parent.props.src) || props.src
|
|
84
68
|
|
|
85
69
|
return {
|
|
86
70
|
width: 'A',
|
|
87
71
|
height: 'A',
|
|
88
72
|
display: 'inline-block',
|
|
89
|
-
spriteId: useIconSprite &&
|
|
73
|
+
spriteId: useIconSprite && iconInContext,
|
|
90
74
|
src: iconFromLibrary || directSrc || ICONS.noIcon,
|
|
91
75
|
style: { fill: 'currentColor', '*': { fill: 'currentColor' } }
|
|
92
76
|
}
|
|
@@ -99,25 +83,32 @@ export const IconText = {
|
|
|
99
83
|
|
|
100
84
|
props: {
|
|
101
85
|
align: 'center center',
|
|
102
|
-
lineHeight: 1
|
|
103
|
-
},
|
|
86
|
+
lineHeight: 1,
|
|
104
87
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
88
|
+
'.reversed': {
|
|
89
|
+
flow: 'row-reverse'
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
'.vertical': {
|
|
93
|
+
flow: 'column'
|
|
109
94
|
}
|
|
110
95
|
},
|
|
111
96
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
97
|
+
Icon: {
|
|
98
|
+
if: (el) => {
|
|
99
|
+
const { parent, props } = el
|
|
100
|
+
return el.call('exec', parent.props.icon ||
|
|
101
|
+
parent.props.Icon ||
|
|
102
|
+
props.name ||
|
|
103
|
+
props.icon ||
|
|
104
|
+
props.sfSymbols ||
|
|
105
|
+
parent.props.sfSymbols
|
|
106
|
+
, el)
|
|
107
|
+
},
|
|
108
|
+
icon: el => el.call('exec', el.parent.props.icon, el.parent)
|
|
116
109
|
},
|
|
117
110
|
|
|
118
|
-
|
|
119
|
-
props: { flow: 'column' }
|
|
120
|
-
}
|
|
111
|
+
text: ({ props }) => props.text
|
|
121
112
|
}
|
|
122
113
|
|
|
123
114
|
export const FileIcon = {
|
|
@@ -134,3 +125,36 @@ export const FileIcon = {
|
|
|
134
125
|
icon: 'file'
|
|
135
126
|
}
|
|
136
127
|
}
|
|
128
|
+
|
|
129
|
+
const getSemanticIcon = (el, s, ctx) => {
|
|
130
|
+
const { SEMANTIC_ICONS } = ctx && ctx.designSystem
|
|
131
|
+
const { toCamelCase } = ctx && ctx.utils
|
|
132
|
+
|
|
133
|
+
let iconName = getIconName(el, s)
|
|
134
|
+
const camelCase = toCamelCase(iconName)
|
|
135
|
+
const isArray = camelCase.split(/([a-z])([A-Z])/g)
|
|
136
|
+
const semanticIconRootName = isArray[1] ? isArray[0] : iconName.split('.')[0].split(' ')[0]
|
|
137
|
+
const semanticIcon = SEMANTIC_ICONS && SEMANTIC_ICONS[semanticIconRootName]
|
|
138
|
+
if (semanticIcon) {
|
|
139
|
+
const iconKey = iconName.includes('.') ? 'sfsymbols.' + iconName.split('.').slice(1).join('.') : 'sfsymbols'
|
|
140
|
+
iconName = semanticIcon[iconKey] || semanticIcon[iconName.split('.')[0].split(' ')[0]]
|
|
141
|
+
return {
|
|
142
|
+
tag: 'span',
|
|
143
|
+
semantic_symbols: true,
|
|
144
|
+
width: 'A',
|
|
145
|
+
height: 'A',
|
|
146
|
+
lineHeight: '1em',
|
|
147
|
+
':after': {
|
|
148
|
+
fontSize: 'Z',
|
|
149
|
+
fontWeight: '300',
|
|
150
|
+
content: `"${iconName}"`,
|
|
151
|
+
textAlign: 'center',
|
|
152
|
+
display: 'inline-block',
|
|
153
|
+
style: {
|
|
154
|
+
color: 'currentColor',
|
|
155
|
+
fontFamily: "'SF Pro Icons', 'SF Pro', 'SF Symbols', 'Segoe UI'"
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/icon",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.455",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "2ec12ac36ba08a2d424a3806dba7ccb6f7bddfba",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@symbo.ls/atoms": "^2.11.
|
|
9
|
-
"@symbo.ls/utils": "^2.11.
|
|
8
|
+
"@symbo.ls/atoms": "^2.11.455",
|
|
9
|
+
"@symbo.ls/utils": "^2.11.453"
|
|
10
10
|
},
|
|
11
11
|
"source": "src/index.js"
|
|
12
12
|
}
|