@koobiq/tokens-builder 3.17.0 → 3.17.1

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Koobiq
3
+ Copyright (c) 2026 Koobiq
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,208 @@
1
+ const semanticPaletteColors = ['theme', 'success', 'warning', 'error', 'contrast', 'white', 'black', 'purple'];
2
+ const newPaletteColors = [
3
+ 'blue',
4
+ 'slate',
5
+ 'red',
6
+ 'orange',
7
+ 'yellow',
8
+ 'green',
9
+ 'teal',
10
+ 'purple',
11
+ 'darkBlue',
12
+ 'darkSlate',
13
+ 'darkRed',
14
+ 'darkOrange',
15
+ 'darkYellow',
16
+ 'darkGreen',
17
+ 'darkTeal',
18
+ 'darkPurple',
19
+ 'grey',
20
+ 'darkGrey',
21
+ 'greyA',
22
+ 'darkGreyA',
23
+ 'whiteA',
24
+ 'blackA',
25
+ 'blueA',
26
+ 'slateA',
27
+ 'redA',
28
+ 'orangeA',
29
+ 'yellowA',
30
+ 'greenA',
31
+ 'tealA',
32
+ 'purpleA',
33
+ 'darkBlueA',
34
+ 'darkSlateA',
35
+ 'darkRedA',
36
+ 'darkOrangeA',
37
+ 'darkYellowA',
38
+ 'darkGreenA',
39
+ 'darkTealA',
40
+ 'darkPurpleA',
41
+ 'yellowFixed',
42
+ 'orangeFixed',
43
+ 'darkYellowFixed',
44
+ 'darkOrangeFixed',
45
+ 'yellowFixedA',
46
+ 'orangeFixedA',
47
+ 'darkYellowFixedA',
48
+ 'darkOrangeFixedA',
49
+ 'white',
50
+ 'black'
51
+ ];
52
+ const newSemanticPaletteColors = [
53
+ 'contrast',
54
+ 'contrastA',
55
+ 'theme',
56
+ 'themeA',
57
+ 'error',
58
+ 'errorA',
59
+ 'warning',
60
+ 'warningA',
61
+ 'warningFixed',
62
+ 'warningFixedA',
63
+ 'success',
64
+ 'successA',
65
+ 'visited',
66
+ 'visitedA',
67
+ 'darkContrast',
68
+ 'darkContrastA',
69
+ 'darkTheme',
70
+ 'darkThemeA',
71
+ 'darkError',
72
+ 'darkErrorA',
73
+ 'darkWarning',
74
+ 'darkWarningA',
75
+ 'darkWarningFixed',
76
+ 'darkWarningFixedA',
77
+ 'darkSuccess',
78
+ 'darkSuccessA',
79
+ 'darkVisited',
80
+ 'darkVisitedA'
81
+ ];
82
+
83
+ const newPaletteByColorsConfig = newPaletteColors.map((color) => ({
84
+ destination: `palette/${color}.css`,
85
+ format: 'kbq-css/variables',
86
+ filter: (token) => token.attributes.category === 'plt' && token.attributes.type === color,
87
+ prefix: 'kbq'
88
+ }));
89
+
90
+ const newSemanticPaletteConfig = newSemanticPaletteColors.map((color) => ({
91
+ destination: `semantic-palette/${color}.css`,
92
+ format: 'kbq-css/palette',
93
+ filter: (token) => token.attributes.category === 'semantic' && token.attributes.type === color,
94
+ prefix: 'kbq',
95
+ options: {
96
+ outputReferences: true
97
+ }
98
+ }));
99
+
100
+ module.exports = {
101
+ css: {
102
+ transformGroup: 'kbq/css',
103
+ files: [
104
+ ...newSemanticPaletteConfig,
105
+ ...newPaletteByColorsConfig,
106
+ {
107
+ destination: 'palette.css',
108
+ format: 'kbq-css/variables',
109
+ filter: (token) => token.attributes.category === 'plt',
110
+ prefix: 'kbq'
111
+ },
112
+ {
113
+ destination: 'semantic-palette.css',
114
+ format: 'kbq-css/variables',
115
+ filter: (token) => token.attributes.category === 'semantic',
116
+ prefix: 'kbq',
117
+ options: {
118
+ outputReferences: true
119
+ }
120
+ },
121
+ {
122
+ destination: 'light/shadows.css',
123
+ format: 'kbq-css/variables',
124
+ filter: (token) => token.attributes.light && token.attributes.category === 'shadow',
125
+ prefix: 'kbq',
126
+ options: {
127
+ selector: '.kbq-light',
128
+ outputReferences: true
129
+ }
130
+ },
131
+ {
132
+ destination: 'light/semantic-colors.css',
133
+ format: 'kbq-css/variables',
134
+ filter: (token) =>
135
+ token.attributes.light &&
136
+ token.filePath.includes('colors.v2.json5') &&
137
+ !semanticPaletteColors.includes(token.attributes.type),
138
+ prefix: 'kbq',
139
+ options: {
140
+ selector: '.kbq-light',
141
+ outputReferences: true
142
+ }
143
+ },
144
+ {
145
+ destination: 'dark/shadows.css',
146
+ format: 'kbq-css/variables',
147
+ filter: (token) => token.attributes.dark && token.attributes.category === 'shadow',
148
+ prefix: 'kbq',
149
+ options: {
150
+ selector: '.kbq-dark',
151
+ outputReferences: true
152
+ }
153
+ },
154
+ {
155
+ destination: 'dark/semantic-colors.css',
156
+ format: 'kbq-css/variables',
157
+ filter: (token) =>
158
+ token.attributes.dark &&
159
+ token.filePath.includes('colors.v2.json5') &&
160
+ !semanticPaletteColors.includes(token.attributes.type),
161
+ prefix: 'kbq',
162
+ options: {
163
+ selector: '.kbq-dark',
164
+ outputReferences: true
165
+ }
166
+ },
167
+ {
168
+ destination: 'css-tokens.css',
169
+ format: 'css/variables',
170
+ filter: (token) =>
171
+ !token.attributes.font &&
172
+ !token.attributes.palette &&
173
+ !token.attributes.light &&
174
+ !token.attributes.dark &&
175
+ token.type !== 'font' &&
176
+ token.attributes.category !== 'palette',
177
+ prefix: 'kbq',
178
+ options: {
179
+ outputReferences: true
180
+ }
181
+ },
182
+ {
183
+ destination: 'css-tokens-light.css',
184
+ format: 'kbq-css/variables',
185
+ filter: (token) =>
186
+ token.attributes.light &&
187
+ !token.attributes.palette &&
188
+ !semanticPaletteColors.includes(token.attributes.type),
189
+ prefix: 'kbq',
190
+ options: {
191
+ selector: '.kbq-light'
192
+ }
193
+ },
194
+ {
195
+ destination: 'css-tokens-dark.css',
196
+ format: 'kbq-css/variables',
197
+ filter: (token) =>
198
+ token.attributes.dark &&
199
+ !token.attributes.palette &&
200
+ !semanticPaletteColors.includes(token.attributes.type),
201
+ prefix: 'kbq',
202
+ options: {
203
+ selector: '.kbq-dark'
204
+ }
205
+ }
206
+ ]
207
+ }
208
+ };
package/configs/css.js CHANGED
@@ -2,87 +2,7 @@ const fs = require('fs');
2
2
  const path = require('node:path');
3
3
 
4
4
  const paletteColors = ['black', 'blue', 'cyan', 'green', 'grey', 'orange', 'purple', 'red', 'white', 'yellow'];
5
- const newPaletteColors = [
6
- 'blue',
7
- 'slate',
8
- 'red',
9
- 'orange',
10
- 'yellow',
11
- 'green',
12
- 'teal',
13
- 'purple',
14
- 'darkBlue',
15
- 'darkSlate',
16
- 'darkRed',
17
- 'darkOrange',
18
- 'darkYellow',
19
- 'darkGreen',
20
- 'darkTeal',
21
- 'darkPurple',
22
- 'grey',
23
- 'darkGrey',
24
- 'greyA',
25
- 'darkGreyA',
26
- 'whiteA',
27
- 'blackA',
28
- 'blueA',
29
- 'slateA',
30
- 'redA',
31
- 'orangeA',
32
- 'yellowA',
33
- 'greenA',
34
- 'tealA',
35
- 'purpleA',
36
- 'darkBlueA',
37
- 'darkSlateA',
38
- 'darkRedA',
39
- 'darkOrangeA',
40
- 'darkYellowA',
41
- 'darkGreenA',
42
- 'darkTealA',
43
- 'darkPurpleA',
44
- 'yellowFixed',
45
- 'orangeFixed',
46
- 'darkYellowFixed',
47
- 'darkOrangeFixed',
48
- 'yellowFixedA',
49
- 'orangeFixedA',
50
- 'darkYellowFixedA',
51
- 'darkOrangeFixedA',
52
- 'white',
53
- 'black'
54
- ];
55
5
  const semanticPaletteColors = ['theme', 'success', 'warning', 'error', 'contrast', 'white', 'black', 'purple'];
56
- const newSemanticPaletteColors = [
57
- 'contrast',
58
- 'contrastA',
59
- 'theme',
60
- 'themeA',
61
- 'error',
62
- 'errorA',
63
- 'warning',
64
- 'warningA',
65
- 'warningFixed',
66
- 'warningFixedA',
67
- 'success',
68
- 'successA',
69
- 'visited',
70
- 'visitedA',
71
- 'darkContrast',
72
- 'darkContrastA',
73
- 'darkTheme',
74
- 'darkThemeA',
75
- 'darkError',
76
- 'darkErrorA',
77
- 'darkWarning',
78
- 'darkWarningA',
79
- 'darkWarningFixed',
80
- 'darkWarningFixedA',
81
- 'darkSuccess',
82
- 'darkSuccessA',
83
- 'darkVisited',
84
- 'darkVisitedA'
85
- ];
86
6
 
87
7
  // resolve components path if script used externally
88
8
  const componentsPath = fs.existsSync(path.join('node_modules', '@koobiq/design-tokens', 'web', 'components'))
@@ -131,18 +51,11 @@ const paletteByColorsConfig = paletteColors.map((color) => ({
131
51
  prefix: 'kbq'
132
52
  }));
133
53
 
134
- const newPaletteByColorsConfig = newPaletteColors.map((color) => ({
135
- destination: `css/new/palette/${color}.css`,
136
- format: 'kbq-css/variables',
137
- filter: (token) => token.attributes.category === 'plt' && token.attributes.type === color,
138
- prefix: 'kbq'
139
- }));
140
-
141
54
  const semanticPaletteConfig = semanticPaletteColors.map((color) => ({
142
55
  destination: `css/semantic-palette/${color}.css`,
143
56
  format: 'kbq-css/palette',
144
57
  filter: (token) =>
145
- token.filePath.includes('colors.json5') &&
58
+ token.filePath.includes('colors.v1.json5') &&
146
59
  token.attributes.light &&
147
60
  token.attributes.type === color &&
148
61
  (token.attributes.palette || token.name.includes('default')),
@@ -152,41 +65,29 @@ const semanticPaletteConfig = semanticPaletteColors.map((color) => ({
152
65
  }
153
66
  }));
154
67
 
155
- const newSemanticPaletteConfig = newSemanticPaletteColors.map((color) => ({
156
- destination: `css/new/semantic-palette/${color}.css`,
157
- format: 'kbq-css/palette',
158
- filter: (token) => token.attributes.category === 'semantic' && token.attributes.type === color,
159
- prefix: 'kbq',
160
- options: {
161
- outputReferences: true
162
- }
163
- }));
164
-
165
68
  module.exports = {
166
69
  css: {
167
70
  transformGroup: 'kbq/css',
168
71
  files: [
169
72
  ...semanticPaletteConfig,
170
- ...newSemanticPaletteConfig,
171
73
  {
172
74
  destination: 'css/light/semantic-palette.css',
173
75
  format: 'kbq-css/palette',
174
76
  filter: (token) =>
175
77
  token.attributes.light &&
176
- token.filePath.includes('colors.json5') &&
78
+ token.filePath.includes('colors.v1.json5') &&
177
79
  (token.attributes.palette || token.name.includes('default')),
178
80
  prefix: 'kbq',
179
81
  options: {
180
82
  selector: '.kbq-light'
181
83
  }
182
84
  },
183
- // deprecated
184
85
  {
185
86
  destination: 'css/dark/semantic-palette.css',
186
87
  format: 'kbq-css/palette',
187
88
  filter: (token) =>
188
89
  token.attributes.dark &&
189
- token.filePath.includes('colors.json5') &&
90
+ token.filePath.includes('colors.v1.json5') &&
190
91
  (token.attributes.palette || token.name.includes('default')),
191
92
  prefix: 'kbq',
192
93
  options: {
@@ -198,12 +99,11 @@ module.exports = {
198
99
  format: 'kbq-css/palette',
199
100
  filter: (token) =>
200
101
  token.attributes.light &&
201
- token.filePath.includes('colors.json5') &&
102
+ token.filePath.includes('colors.v1.json5') &&
202
103
  !semanticPaletteColors.includes(token.attributes.type),
203
104
  prefix: 'kbq',
204
105
  options: {
205
- selector: '.kbq-light',
206
- outputReferences: true
106
+ selector: '.kbq-light'
207
107
  }
208
108
  },
209
109
  {
@@ -211,12 +111,11 @@ module.exports = {
211
111
  format: 'kbq-css/palette',
212
112
  filter: (token) =>
213
113
  token.attributes.dark &&
214
- token.filePath.includes('colors.json5') &&
114
+ token.filePath.includes('colors.v1.json5') &&
215
115
  !semanticPaletteColors.includes(token.attributes.type),
216
116
  prefix: 'kbq',
217
117
  options: {
218
- selector: '.kbq-dark',
219
- outputReferences: true
118
+ selector: '.kbq-dark'
220
119
  }
221
120
  },
222
121
  {
@@ -241,28 +140,12 @@ module.exports = {
241
140
  }
242
141
  },
243
142
  ...paletteByColorsConfig,
244
- ...newPaletteByColorsConfig,
245
143
  {
246
144
  destination: 'css/palette.css',
247
145
  format: 'kbq-css/variables',
248
146
  filter: (token) => token.attributes.category === 'palette',
249
147
  prefix: 'kbq'
250
148
  },
251
- {
252
- destination: 'css/new/palette.css',
253
- format: 'kbq-css/variables',
254
- filter: (token) => token.attributes.category === 'plt',
255
- prefix: 'kbq'
256
- },
257
- {
258
- destination: 'css/new/semantic-palette.css',
259
- format: 'kbq-css/variables',
260
- filter: (token) => token.attributes.category === 'semantic',
261
- prefix: 'kbq',
262
- options: {
263
- outputReferences: true
264
- }
265
- },
266
149
  {
267
150
  destination: 'css/light/shadows.css',
268
151
  format: 'kbq-css/variables',
package/configs/index.js CHANGED
@@ -2,6 +2,7 @@ const { join } = require('path');
2
2
  const scssConfig = require('./scss');
3
3
  const jsConfig = require('./js');
4
4
  const cssConfig = require('./css');
5
+ const cssNewConfig = require('./css-new');
5
6
 
6
7
  const filterObj = {
7
8
  options: {
@@ -43,8 +44,10 @@ function getConfigs(theme) {
43
44
  scssConfig.scss.buildPath = theme.outputPath;
44
45
  jsConfig.js.buildPath = theme.outputPath;
45
46
  cssConfig.css.buildPath = theme.outputPath;
47
+ // @TODO: remove when updated to v4 (#DS-3002)
48
+ cssNewConfig.css.buildPath = theme.outputPath;
46
49
 
47
- return filterOptions([scssConfig, jsConfig, cssConfig]);
50
+ return filterOptions([scssConfig, jsConfig, theme?.type === 'new' ? cssNewConfig : cssConfig]);
48
51
  }
49
52
 
50
53
  module.exports = (theme) => {
package/package.json CHANGED
@@ -19,5 +19,5 @@
19
19
  "default": "./*"
20
20
  }
21
21
  },
22
- "version": "3.17.0"
22
+ "version": "3.17.1"
23
23
  }
@@ -8,6 +8,7 @@ module.exports = (StyleDictionary) => {
8
8
  part
9
9
  .replace(/([a-z])([A-Z])/g, '$1-$2')
10
10
  .replace(/"/g, '')
11
+ .replace(/[\s.]+/g, '-')
11
12
  .toLowerCase()
12
13
  )
13
14
  .join('-');