@demos-europe/demosplan-ui 0.3.5 → 0.3.6

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/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ Since v0.0.10, this Changelog is formatted according to the [Common Changelog][c
4
4
 
5
5
  ## UNRELEASED
6
6
 
7
+ ## v0.3.6 - 2024-02-07
8
+ ### Fixed
9
+
10
+ - ([#729](https://github.com/demos-europe/demosplan-ui/pull/729)) Fix DpAnonymizeText functionality ([@sakutademos](https://github.com/sakutademos))
11
+
12
+ ### Added
13
+
14
+ - ([#721](https://github.com/demos-europe/demosplan-ui/pull/721)) Pass the allowEmpty prop to vue-multiselect, which prevents the deselection of values ([@sakutademos](https://github.com/sakutademos))
15
+ - ([#718](https://github.com/demos-europe/demosplan-ui/pull/718)) Add missing data attr for E-2-E Test ([@ahmad-demos](https://github.com/ahmad-demos))
16
+ - ([#714](https://github.com/demos-europe/demosplan-ui/pull/714)) add csrf token to dpRpc to prevent missing csrf errors ([@muellerdemos](https://github.com/muellerdemos))
17
+ - ([#734](https://github.com/demos-europe/demosplan-ui/pull/734)) Allow mailto links in DpEditor link modal ([@spiess-demos](https://github.com/spiess-demos))
18
+
7
19
  ## v0.3.5 - 2024-01-09
8
20
 
9
21
  ### Fixed
package/buildTokens.js CHANGED
@@ -1,6 +1,12 @@
1
1
  const glob = require('glob')
2
2
  const StyleDictionary = require('style-dictionary')
3
3
 
4
+ const {
5
+ createPropertyFormatter,
6
+ fileHeader,
7
+ sortByReference
8
+ } = StyleDictionary.formatHelpers
9
+
4
10
  const prefix = 'dp-'
5
11
 
6
12
  const tokensPath = 'tokens/src/**/*.json'
@@ -14,36 +20,73 @@ const files = glob
14
20
  // Do not render tokens only used internally
15
21
  .filter(filePath => !filePath.startsWith('_'))
16
22
 
23
+ // Adds prefix to variables
17
24
  StyleDictionary.registerTransform({
18
25
  name: 'name/scss',
19
26
  type: 'name',
20
- transformer: (token) => {
21
- // The domain part ("palette", "ui"...) within color tokens should not be part of the variable name.
22
- // The domain part ("scale", "heading", "ui"...) within font-size tokens should not be part of the variable name.
23
- if (token.path[0] === 'color' || token.path[0] === 'font-size') {
24
- token.path.splice(1, 1)
25
- }
26
- // The key "z-index" should be shortened in the variable name to match Tailwind syntax
27
- if (token.path[0] === 'z-index') {
28
- token.path[0] = 'z'
29
- }
30
- // Scss does not like variable names with dots in them, but Tailwind does, apparently.
31
- if (token.path[0] === 'space') {
32
- token.path[1] = token.path[1].replace('.', '_')
33
- }
34
- // "DEFAULT" is a Tailwind convention that should not be part of the Scss name
35
- if (token.path[1] === 'DEFAULT') {
36
- token.path.splice(1, 1)
37
- }
38
- return prefix + token.path.join('-')
39
- }
27
+ transformer: (token) => prefix + token.path.join('-')
40
28
  })
41
29
 
30
+ // Adds prefix transform to default scss transform group
42
31
  StyleDictionary.registerTransformGroup({
43
32
  name: 'custom/scss',
44
33
  transforms: StyleDictionary.transformGroup.scss.concat(['name/scss'])
45
34
  })
46
35
 
36
+ /**
37
+ * This format is a customized version of the implementation
38
+ * in `formattedVariables`. It applies some transformations
39
+ * to scss variables according to the conventions in demosplan-ui.
40
+ * See https://github.com/amzn/style-dictionary/blob/17f4cb2f30bd002dfd55d6ef8c5bee4138de8d64/lib/common/formatHelpers/formattedVariables.js#L46
41
+ */
42
+ StyleDictionary.registerFormat({
43
+ name: 'scss/customVariables',
44
+ formatter: ({dictionary, options, file}) => {
45
+ const { outputReferences, themeable = false, formatting} = options
46
+ let { allTokens } = dictionary
47
+
48
+ if (outputReferences) {
49
+ allTokens = [...allTokens].sort(sortByReference(dictionary))
50
+ }
51
+
52
+ const propertyFormatter = createPropertyFormatter({ outputReferences, dictionary, format: 'sass', formatting, themeable })
53
+
54
+ const tokens = allTokens
55
+ .map(token => {
56
+ let formattedVar = propertyFormatter(token)
57
+
58
+ // The domain part within color tokens should not be part of the variable name.
59
+ if (token.path[0] === 'color') {
60
+ formattedVar = formattedVar.replace(/-(brand|data|palette|ui)/g, '')
61
+ }
62
+
63
+ // The domain part within font-size tokens should not be part of the variable name.
64
+ if (token.path[0] === 'font-size') {
65
+ formattedVar = formattedVar.replace(/-(scale|brand|heading|ui)/g, '')
66
+ }
67
+
68
+ // The key "z-index" should be shortened in the variable name to match Tailwind syntax
69
+ if (token.path[0] === 'z-index') {
70
+ formattedVar = formattedVar.replace(/z-index-/g, 'z-')
71
+ }
72
+
73
+ // Scss does not like variable names with dots in them, but Tailwind does, apparently.
74
+ if (token.path[0] === 'space') {
75
+ formattedVar = formattedVar.replace(/\./g, '_')
76
+ }
77
+
78
+ // "DEFAULT" is a Tailwind convention that should not be part of the Scss name
79
+ formattedVar = formattedVar.replace(/-DEFAULT/g, '')
80
+
81
+ return formattedVar
82
+ })
83
+ .filter(function(strVal) { return !!strVal })
84
+ .join('\n')
85
+
86
+ return fileHeader({file, commentStyle: 'short'}) + '\n' + tokens + '\n'
87
+ }
88
+ })
89
+
47
90
  const StyleDictionaryExtended = StyleDictionary.extend({
48
91
  source: [tokensPath],
49
92
  platforms: {
@@ -53,7 +96,7 @@ const StyleDictionaryExtended = StyleDictionary.extend({
53
96
  files: files.map((filePath) => {
54
97
  return {
55
98
  destination: `_${filePath}.scss`,
56
- format: 'scss/variables',
99
+ format: 'scss/customVariables',
57
100
  filter: (token) => token.filePath.includes(filePath),
58
101
  options: {
59
102
  outputReferences: true