@ptsecurity/mosaic 14.7.1 → 14.7.2
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/design-tokens/style-dictionary/build.js +0 -13
- package/design-tokens/style-dictionary/configs/index.js +1 -3
- package/esm2020/core/version.mjs +2 -2
- package/fesm2015/ptsecurity-mosaic-core.mjs +1 -1
- package/fesm2015/ptsecurity-mosaic-core.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-core.mjs +1 -1
- package/fesm2020/ptsecurity-mosaic-core.mjs.map +1 -1
- package/package.json +4 -4
- package/design-tokens/style-dictionary/configs/figma.js +0 -11
- package/design-tokens/style-dictionary/figma-types.js +0 -41
- package/design-tokens/style-dictionary/formats/figma.js +0 -104
- package/design-tokens/style-dictionary/transformGroups/figma.js +0 -21
- package/design-tokens/style-dictionary/transforms/attribute/figma-border.js +0 -18
- package/design-tokens/style-dictionary/transforms/attribute/figma-color.js +0 -25
- package/design-tokens/style-dictionary/transforms/attribute/figma-default.js +0 -10
- package/design-tokens/style-dictionary/transforms/attribute/figma-font.js +0 -31
- package/design-tokens/style-dictionary/transforms/attribute/figma-group.js +0 -17
- package/design-tokens/style-dictionary/transforms/attribute/figma-opacity.js +0 -10
- package/design-tokens/style-dictionary/transforms/attribute/figma-shadow.js +0 -66
- package/design-tokens/style-dictionary/transforms/attribute/figma-sizing.js +0 -16
- package/design-tokens/style-dictionary/transforms/attribute/figma-spacing.js +0 -15
- package/design-tokens/style-dictionary/transforms/attribute/figma-typography.js +0 -24
- package/design-tokens/style-dictionary/transforms/value/figma-values.js +0 -7
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ptsecurity/mosaic",
|
3
|
-
"version": "14.7.
|
3
|
+
"version": "14.7.2",
|
4
4
|
"description": "Mosaic",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -22,9 +22,9 @@
|
|
22
22
|
"@angular/core": "^14.2.12",
|
23
23
|
"@angular/common": "^14.2.12",
|
24
24
|
"@angular/forms": "^14.2.12",
|
25
|
-
"@ptsecurity/cdk": "^14.7.
|
26
|
-
"@ptsecurity/mosaic-moment-adapter": "^14.7.
|
27
|
-
"@ptsecurity/mosaic-luxon-adapter": "^14.7.
|
25
|
+
"@ptsecurity/cdk": "^14.7.2",
|
26
|
+
"@ptsecurity/mosaic-moment-adapter": "^14.7.2",
|
27
|
+
"@ptsecurity/mosaic-luxon-adapter": "^14.7.2",
|
28
28
|
"@ptsecurity/mosaic-icons": "^5.0.0"
|
29
29
|
},
|
30
30
|
"dependencies": {
|
@@ -1,41 +0,0 @@
|
|
1
|
-
const typographySingleTypes = {
|
2
|
-
textTransform: 'textTransform',
|
3
|
-
textCase: 'textCase',
|
4
|
-
fontFeatureSettings: 'fontFeatureSettings',
|
5
|
-
lineHeight: 'lineHeight',
|
6
|
-
letterSpacing: 'letterSpacing',
|
7
|
-
fontFamily: 'fontFamily',
|
8
|
-
fontSize: 'fontSize',
|
9
|
-
fontWeight: 'fontWeight'
|
10
|
-
};
|
11
|
-
|
12
|
-
const typographyPluralTypes = {
|
13
|
-
fontFamilies: 'fontFamilies',
|
14
|
-
fontWeights: 'fontWeights',
|
15
|
-
lineHeights: 'lineHeights',
|
16
|
-
fontSizes: 'fontSizes'
|
17
|
-
};
|
18
|
-
|
19
|
-
const typographyTypes = {
|
20
|
-
...typographySingleTypes,
|
21
|
-
...typographyPluralTypes
|
22
|
-
};
|
23
|
-
|
24
|
-
const figmaTypes = {
|
25
|
-
...typographyTypes,
|
26
|
-
typography: 'typography',
|
27
|
-
other: 'other',
|
28
|
-
color: 'color',
|
29
|
-
borderWidth: 'borderWidth',
|
30
|
-
borderRadius: 'borderRadius',
|
31
|
-
sizing: 'sizing',
|
32
|
-
spacing: 'spacing',
|
33
|
-
opacity: 'opacity',
|
34
|
-
boxShadow: 'boxShadow'
|
35
|
-
};
|
36
|
-
|
37
|
-
module.exports = {
|
38
|
-
figmaTypes,
|
39
|
-
typographySingleTypes,
|
40
|
-
typographyPluralTypes
|
41
|
-
};
|
@@ -1,104 +0,0 @@
|
|
1
|
-
const { typographySingleTypes, figmaTypes } = require('../figma-types');
|
2
|
-
const setProperty = require('lodash/set');
|
3
|
-
|
4
|
-
const JSON_INDENTATION = 2;
|
5
|
-
|
6
|
-
function buildTypography(tokens) {
|
7
|
-
return {
|
8
|
-
value: Object.entries(tokens).reduce(
|
9
|
-
(accum, [, item]) => {
|
10
|
-
const { value, attributes: { figmaPropType }} = item;
|
11
|
-
accum[figmaPropType] = cleanValue(value);
|
12
|
-
|
13
|
-
return accum;
|
14
|
-
},
|
15
|
-
{}
|
16
|
-
),
|
17
|
-
type: figmaTypes.typography
|
18
|
-
};
|
19
|
-
}
|
20
|
-
|
21
|
-
function rebuildTokes(tokens, parentCategory = null) {
|
22
|
-
if (tokens.value === undefined) {
|
23
|
-
const firstItemType = Object.values(tokens)[0] ?.attributes?.figmaPropType;
|
24
|
-
if (Object.values(typographySingleTypes).includes(firstItemType)) {
|
25
|
-
return buildTypography(tokens);
|
26
|
-
}
|
27
|
-
|
28
|
-
return Object.entries(tokens).reduce(
|
29
|
-
(accum, [tokenKey, tokenValue]) => {
|
30
|
-
accum[tokenKey] = cleanValue(rebuildTokes(tokenValue, parentCategory));
|
31
|
-
|
32
|
-
return accum;
|
33
|
-
},
|
34
|
-
{}
|
35
|
-
);
|
36
|
-
}
|
37
|
-
|
38
|
-
if (typeof tokens.value === 'object') {
|
39
|
-
return rebuildTokes(tokens.value, tokens.attributes.category);
|
40
|
-
}
|
41
|
-
|
42
|
-
let { category, figmaPropType, figmaValue, figmaLink } = tokens.attributes;
|
43
|
-
const { original } = tokens;
|
44
|
-
figmaValue = figmaLink ? `{${figmaValue}}` : figmaValue;
|
45
|
-
let value = figmaValue ?? original.value;
|
46
|
-
|
47
|
-
if (parentCategory && category !== parentCategory) {
|
48
|
-
value = buildRefFromAttributes(tokens.attributes);
|
49
|
-
}
|
50
|
-
|
51
|
-
return { value: cleanValue(value), type: figmaPropType };
|
52
|
-
}
|
53
|
-
|
54
|
-
function cleanValue(value) {
|
55
|
-
return typeof value === 'string' ? value.replace(/\.value\./g, '.') : value;
|
56
|
-
}
|
57
|
-
|
58
|
-
function buildRefFromAttributes(attributes) {
|
59
|
-
const { category, type, item, subitem } = attributes;
|
60
|
-
const ref = [category, type, item, subitem].filter((refPart) => !!refPart);
|
61
|
-
|
62
|
-
return `{${ref.join('.')}}`;
|
63
|
-
}
|
64
|
-
|
65
|
-
function findLastLeafAttributes(property) {
|
66
|
-
if (!property.attributes) {
|
67
|
-
return findLastLeafAttributes(property[Object.keys(property)[0]]);
|
68
|
-
}
|
69
|
-
|
70
|
-
return property.attributes;
|
71
|
-
}
|
72
|
-
|
73
|
-
function prepareFigmaTitle(value) {
|
74
|
-
return value
|
75
|
-
.replace(/-/g, ' ')
|
76
|
-
.split(' ')
|
77
|
-
.map((titlePart) => titlePart.charAt(0).toUpperCase() + titlePart.slice(1))
|
78
|
-
.join(' ');
|
79
|
-
}
|
80
|
-
|
81
|
-
module.exports = (styleDictionary) => {
|
82
|
-
styleDictionary.registerFormat({
|
83
|
-
name: 'figmaTokensPlugin',
|
84
|
-
formatter: ({ dictionary }) => {
|
85
|
-
const groupedDict = Object.entries(dictionary.tokens)
|
86
|
-
.filter(([, propValue]) => typeof propValue === 'object')
|
87
|
-
.reduce(
|
88
|
-
(accum, [propName, propValue]) => {
|
89
|
-
const { group, subgroup } = findLastLeafAttributes(propValue);
|
90
|
-
const propPath = group === 'properties'
|
91
|
-
? `${prepareFigmaTitle(group)}.${propName}`
|
92
|
-
: `${prepareFigmaTitle(subgroup)}.${propName}`;
|
93
|
-
setProperty(accum, propPath, propValue);
|
94
|
-
|
95
|
-
return accum;
|
96
|
-
},
|
97
|
-
{}
|
98
|
-
);
|
99
|
-
const figmaTokens = rebuildTokes(groupedDict);
|
100
|
-
|
101
|
-
return JSON.stringify(figmaTokens, null, JSON_INDENTATION);
|
102
|
-
}
|
103
|
-
});
|
104
|
-
};
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module.exports = (StyleDictionary) => {
|
2
|
-
|
3
|
-
StyleDictionary.registerTransformGroup({
|
4
|
-
name: 'mc/figma',
|
5
|
-
transforms: [
|
6
|
-
'attribute/cti',
|
7
|
-
"name/cti/kebab",
|
8
|
-
'mc-attribute/figma-group',
|
9
|
-
'mc-attribute/figma-border',
|
10
|
-
'mc-attribute/figma-typography',
|
11
|
-
'mc-attribute/figma-font',
|
12
|
-
'mc-attribute/figma-opacity',
|
13
|
-
'mc-attribute/figma-spacing',
|
14
|
-
'mc-attribute/figma-sizing',
|
15
|
-
'mc-attribute/figma-shadow',
|
16
|
-
'mc-attribute/figma-color',
|
17
|
-
'mc-attribute/figma-default',
|
18
|
-
'mc-value/figma-values',
|
19
|
-
]
|
20
|
-
});
|
21
|
-
};
|
@@ -1,18 +0,0 @@
|
|
1
|
-
const { figmaTypes } = require('../../figma-types');
|
2
|
-
|
3
|
-
module.exports = (styleDictionary) => {
|
4
|
-
styleDictionary.registerTransform({
|
5
|
-
name: 'mc-attribute/figma-border',
|
6
|
-
type: 'attribute',
|
7
|
-
matcher: ({ name, attributes }) => name.includes('border') && !attributes.figmaPropType,
|
8
|
-
transformer: ({ name, attributes }) => {
|
9
|
-
const props = {
|
10
|
-
width: figmaTypes.borderWidth,
|
11
|
-
radius: figmaTypes.borderRadius
|
12
|
-
};
|
13
|
-
const entry = Object.entries(props).find(([key]) => name.includes(key));
|
14
|
-
|
15
|
-
return entry ? { figmaPropType: entry[1] } : attributes;
|
16
|
-
}
|
17
|
-
});
|
18
|
-
};
|
@@ -1,25 +0,0 @@
|
|
1
|
-
const { figmaTypes } = require('../../figma-types');
|
2
|
-
|
3
|
-
const COLOR_MAX_PARTS = 4;
|
4
|
-
|
5
|
-
module.exports = (styleDictionary) => {
|
6
|
-
styleDictionary.registerTransform({
|
7
|
-
name: 'mc-attribute/figma-color',
|
8
|
-
type: 'attribute',
|
9
|
-
matcher: ({name, value, attributes: { category, figmaPropType }}) => {
|
10
|
-
if (figmaPropType) {
|
11
|
-
return false;
|
12
|
-
}
|
13
|
-
|
14
|
-
const stringValue = value.toString();
|
15
|
-
const isColorValue = (
|
16
|
-
stringValue.startsWith('#') ||
|
17
|
-
stringValue.startsWith('rgba') ||
|
18
|
-
name.includes('color')
|
19
|
-
) && stringValue.split(' ').length <= COLOR_MAX_PARTS;
|
20
|
-
|
21
|
-
return isColorValue || category === 'palette';
|
22
|
-
},
|
23
|
-
transformer: () => ({ figmaPropType: figmaTypes.color })
|
24
|
-
});
|
25
|
-
};
|
@@ -1,10 +0,0 @@
|
|
1
|
-
const { figmaTypes } = require('../../figma-types');
|
2
|
-
|
3
|
-
module.exports = (styleDictionary) => {
|
4
|
-
styleDictionary.registerTransform({
|
5
|
-
name: 'mc-attribute/figma-default',
|
6
|
-
type: 'attribute',
|
7
|
-
matcher: ({ attributes }) => !attributes.figmaPropType,
|
8
|
-
transformer: () => ({ figmaPropType: figmaTypes.other })
|
9
|
-
});
|
10
|
-
};
|
@@ -1,31 +0,0 @@
|
|
1
|
-
const { figmaTypes } = require('../../figma-types');
|
2
|
-
|
3
|
-
module.exports = (styleDictionary) => {
|
4
|
-
styleDictionary.registerTransform({
|
5
|
-
name: 'mc-attribute/figma-font',
|
6
|
-
type: 'attribute',
|
7
|
-
matcher: ({ name, attributes }) => name.includes('font') && !attributes.figmaPropType,
|
8
|
-
transformer: ({ name, value }) => {
|
9
|
-
const props = {
|
10
|
-
family: figmaTypes.fontFamilies,
|
11
|
-
size: figmaTypes.fontSizes,
|
12
|
-
weight: figmaTypes.fontWeights,
|
13
|
-
height: figmaTypes.lineHeights,
|
14
|
-
spacing: figmaTypes.letterSpacing,
|
15
|
-
transform: figmaTypes.textCase,
|
16
|
-
settings: figmaTypes.fontFeatureSettings
|
17
|
-
};
|
18
|
-
const [, typeName] = Object.entries(props).find(([key]) => name.includes(key)) ?? [];
|
19
|
-
|
20
|
-
if (!typeName) {
|
21
|
-
return {
|
22
|
-
figmaPropType: 'typography',
|
23
|
-
figmaValue: `typography.${value}`,
|
24
|
-
figmaLink: true
|
25
|
-
};
|
26
|
-
}
|
27
|
-
|
28
|
-
return { figmaPropType: typeName };
|
29
|
-
}
|
30
|
-
});
|
31
|
-
};
|
@@ -1,17 +0,0 @@
|
|
1
|
-
const path = require('path');
|
2
|
-
|
3
|
-
const GROUP_BACK_STEP_INDEX = 2;
|
4
|
-
|
5
|
-
module.exports = (styleDictionary) => {
|
6
|
-
styleDictionary.registerTransform({
|
7
|
-
name: 'mc-attribute/figma-group',
|
8
|
-
type: 'attribute',
|
9
|
-
transformer: (prop) => {
|
10
|
-
const filePathParts = prop.filePath.split('/');
|
11
|
-
const group = filePathParts[filePathParts.length - GROUP_BACK_STEP_INDEX];
|
12
|
-
const subgroup = path.parse(prop.filePath).name;
|
13
|
-
|
14
|
-
return { group, subgroup };
|
15
|
-
}
|
16
|
-
});
|
17
|
-
};
|
@@ -1,10 +0,0 @@
|
|
1
|
-
const { figmaTypes } = require('../../figma-types');
|
2
|
-
|
3
|
-
module.exports = (styleDictionary) => {
|
4
|
-
styleDictionary.registerTransform({
|
5
|
-
name: 'mc-attribute/figma-opacity',
|
6
|
-
type: 'attribute',
|
7
|
-
matcher: ({ name, attributes }) => name.includes('opacity') && !attributes.figmaPropType,
|
8
|
-
transformer: () => ({ figmaPropType: figmaTypes.opacity })
|
9
|
-
});
|
10
|
-
};
|
@@ -1,66 +0,0 @@
|
|
1
|
-
const { figmaTypes } = require('../../figma-types');
|
2
|
-
|
3
|
-
const BLUR_SHADOW_INDEX = 2;
|
4
|
-
const SPREAD_SHADOW_INDEX = 3;
|
5
|
-
const X_SHADOW_INDEX = 0;
|
6
|
-
const Y_SHADOW_INDEX = 1;
|
7
|
-
const SHADOW_MIN_PARTS = 4;
|
8
|
-
|
9
|
-
function transformShadow(value) {
|
10
|
-
const isInnerShadow = value.includes('inset');
|
11
|
-
const valueParts = value.split(' ');
|
12
|
-
|
13
|
-
if (isInnerShadow) {
|
14
|
-
valueParts.shift();
|
15
|
-
}
|
16
|
-
|
17
|
-
return {
|
18
|
-
color: valueParts.pop(),
|
19
|
-
type: isInnerShadow ? 'innerShadow' : 'dropShadow',
|
20
|
-
x: valueParts[X_SHADOW_INDEX] ?? 0,
|
21
|
-
y: valueParts[Y_SHADOW_INDEX] ?? 0,
|
22
|
-
blur: valueParts[BLUR_SHADOW_INDEX] ?? 0,
|
23
|
-
spread: valueParts[SPREAD_SHADOW_INDEX] ?? 0
|
24
|
-
};
|
25
|
-
}
|
26
|
-
|
27
|
-
module.exports = (styleDictionary) => {
|
28
|
-
styleDictionary.registerTransform({
|
29
|
-
name: 'mc-attribute/figma-shadow',
|
30
|
-
type: 'attribute',
|
31
|
-
matcher: ({name, value, attributes }) => (
|
32
|
-
name.includes('shadow') &&
|
33
|
-
value.split(' ').length > SHADOW_MIN_PARTS &&
|
34
|
-
!attributes.figmaPropType
|
35
|
-
),
|
36
|
-
transformer: ({ value }) => {
|
37
|
-
const rgbaGroups = [];
|
38
|
-
let figmaValue = value;
|
39
|
-
|
40
|
-
const check = figmaValue.match(/(rgba\([\w\d\. \,]+\))/) ?? [];
|
41
|
-
|
42
|
-
for (let i = 1; i < check.length; i++) {
|
43
|
-
figmaValue = figmaValue.replace(check[i], `rgba${i - 1}`);
|
44
|
-
rgbaGroups.push(check[i]);
|
45
|
-
}
|
46
|
-
|
47
|
-
const shadowParts = figmaValue.split(',');
|
48
|
-
figmaValue = shadowParts.length > 1
|
49
|
-
? shadowParts.map(transformShadow)
|
50
|
-
: transformShadow(figmaValue);
|
51
|
-
|
52
|
-
rgbaGroups.forEach((rgbaValue, rgbaIndex) => {
|
53
|
-
if (Array.isArray(figmaValue)) {
|
54
|
-
figmaValue.forEach((shadow) => {
|
55
|
-
shadow.color = shadow.color.replace(`rgba${rgbaIndex}`, rgbaValue);
|
56
|
-
});
|
57
|
-
|
58
|
-
return;
|
59
|
-
}
|
60
|
-
figmaValue.color = figmaValue.color.replace(`rgba${rgbaIndex}`, rgbaValue);
|
61
|
-
});
|
62
|
-
|
63
|
-
return { figmaPropType: figmaTypes.boxShadow, figmaValue };
|
64
|
-
}
|
65
|
-
});
|
66
|
-
};
|
@@ -1,16 +0,0 @@
|
|
1
|
-
const { figmaTypes } = require('../../figma-types');
|
2
|
-
|
3
|
-
module.exports = (styleDictionary) => {
|
4
|
-
styleDictionary.registerTransform({
|
5
|
-
name: 'mc-attribute/figma-sizing',
|
6
|
-
type: 'attribute',
|
7
|
-
matcher: ({name, attributes}) => (
|
8
|
-
(
|
9
|
-
name.includes('height') ||
|
10
|
-
name.includes('width') ||
|
11
|
-
name.includes('size')
|
12
|
-
) && !attributes.figmaPropType
|
13
|
-
),
|
14
|
-
transformer: () => ({ figmaPropType: figmaTypes.sizing })
|
15
|
-
});
|
16
|
-
};
|
@@ -1,15 +0,0 @@
|
|
1
|
-
const { figmaTypes } = require('../../figma-types');
|
2
|
-
|
3
|
-
module.exports = (styleDictionary) => {
|
4
|
-
styleDictionary.registerTransform({
|
5
|
-
name: 'mc-attribute/figma-spacing',
|
6
|
-
type: 'attribute',
|
7
|
-
matcher: ({name, attributes}) => (
|
8
|
-
(
|
9
|
-
name.includes('padding') ||
|
10
|
-
name.includes('margin')
|
11
|
-
) && !attributes.figmaPropType
|
12
|
-
),
|
13
|
-
transformer: (() => ({ figmaPropType: figmaTypes.spacing }))
|
14
|
-
});
|
15
|
-
};
|
@@ -1,24 +0,0 @@
|
|
1
|
-
const { figmaTypes } = require('../../figma-types');
|
2
|
-
|
3
|
-
module.exports = (styleDictionary) => {
|
4
|
-
styleDictionary.registerTransform({
|
5
|
-
name: 'mc-attribute/figma-typography',
|
6
|
-
type: 'attribute',
|
7
|
-
matcher: ({ name, attributes}) => name.includes('typography') && !attributes.figmaPropType,
|
8
|
-
transformer: ({ name, attributes }) => {
|
9
|
-
const props = {
|
10
|
-
spacing: figmaTypes.letterSpacing,
|
11
|
-
transform: figmaTypes.textCase,
|
12
|
-
settings: figmaTypes.fontFeatureSettings,
|
13
|
-
family: figmaTypes.fontFamily,
|
14
|
-
size: figmaTypes.fontSize,
|
15
|
-
weight: figmaTypes.fontWeight,
|
16
|
-
height: figmaTypes.lineHeight
|
17
|
-
};
|
18
|
-
|
19
|
-
const entry = Object.entries(props).find(([key]) => name.includes(key));
|
20
|
-
|
21
|
-
return entry ? { figmaPropType: entry[1] } : attributes;
|
22
|
-
}
|
23
|
-
});
|
24
|
-
};
|