@ama-styling/style-dictionary 12.5.0-prerelease.10
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 +26 -0
- package/README.md +255 -0
- package/collection.json +14 -0
- package/package.json +199 -0
- package/schemas/design-token.extensions.schema.json +121 -0
- package/schematics/ng-add/index.d.ts +8 -0
- package/schematics/ng-add/index.d.ts.map +1 -0
- package/schematics/ng-add/index.js +100 -0
- package/schematics/ng-add/schema.d.ts +10 -0
- package/schematics/ng-add/schema.d.ts.map +1 -0
- package/schematics/ng-add/schema.js +3 -0
- package/schematics/ng-add/schema.json +26 -0
- package/schematics/ng-add/templates/config.__configExtension__ +50 -0
- package/schematics/ng-add/templates/token.extensions.json.template +3 -0
- package/schematics/package.json +3 -0
- package/src/constants.d.mts +5 -0
- package/src/constants.d.mts.map +1 -0
- package/src/constants.mjs +5 -0
- package/src/constants.mjs.map +1 -0
- package/src/filters/target-file.filter.d.mts +34 -0
- package/src/filters/target-file.filter.d.mts.map +1 -0
- package/src/filters/target-file.filter.mjs +49 -0
- package/src/filters/target-file.filter.mjs.map +1 -0
- package/src/formats/css-formatters/default.formatter.d.mts +7 -0
- package/src/formats/css-formatters/default.formatter.d.mts.map +1 -0
- package/src/formats/css-formatters/default.formatter.mjs +19 -0
- package/src/formats/css-formatters/default.formatter.mjs.map +1 -0
- package/src/formats/css-formatters/gradients.formatter.d.mts +7 -0
- package/src/formats/css-formatters/gradients.formatter.d.mts.map +1 -0
- package/src/formats/css-formatters/gradients.formatter.mjs +32 -0
- package/src/formats/css-formatters/gradients.formatter.mjs.map +1 -0
- package/src/formats/css-formatters/interface.formatter.d.mts +13 -0
- package/src/formats/css-formatters/interface.formatter.d.mts.map +1 -0
- package/src/formats/css-formatters/interface.formatter.mjs +2 -0
- package/src/formats/css-formatters/interface.formatter.mjs.map +1 -0
- package/src/formats/css-formatters/private.formatter.d.mts +7 -0
- package/src/formats/css-formatters/private.formatter.d.mts.map +1 -0
- package/src/formats/css-formatters/private.formatter.mjs +33 -0
- package/src/formats/css-formatters/private.formatter.mjs.map +1 -0
- package/src/formats/css.format.d.mts +3 -0
- package/src/formats/css.format.d.mts.map +1 -0
- package/src/formats/css.format.mjs +60 -0
- package/src/formats/css.format.mjs.map +1 -0
- package/src/formats/metadata.format.d.mts +3 -0
- package/src/formats/metadata.format.d.mts.map +1 -0
- package/src/formats/metadata.format.mjs +71 -0
- package/src/formats/metadata.format.mjs.map +1 -0
- package/src/helpers/config-deflatten.helpers.d.mts +6 -0
- package/src/helpers/config-deflatten.helpers.d.mts.map +1 -0
- package/src/helpers/config-deflatten.helpers.mjs +46 -0
- package/src/helpers/config-deflatten.helpers.mjs.map +1 -0
- package/src/helpers/sort-by-path.sort.helpers.d.mts +8 -0
- package/src/helpers/sort-by-path.sort.helpers.d.mts.map +1 -0
- package/src/helpers/sort-by-path.sort.helpers.mjs +33 -0
- package/src/helpers/sort-by-path.sort.helpers.mjs.map +1 -0
- package/src/interfaces/extensions.interface.d.mts +56 -0
- package/src/interfaces/extensions.interface.d.mts.map +1 -0
- package/src/interfaces/extensions.interface.mjs +2 -0
- package/src/interfaces/extensions.interface.mjs.map +1 -0
- package/src/interfaces/metadata.interface.d.mts +57 -0
- package/src/interfaces/metadata.interface.d.mts.map +1 -0
- package/src/interfaces/metadata.interface.mjs +2 -0
- package/src/interfaces/metadata.interface.mjs.map +1 -0
- package/src/interfaces/style-dictionary.interface.d.mts +11 -0
- package/src/interfaces/style-dictionary.interface.d.mts.map +1 -0
- package/src/interfaces/style-dictionary.interface.mjs +2 -0
- package/src/interfaces/style-dictionary.interface.mjs.map +1 -0
- package/src/parsers/extensions.json.parser.d.mts +6 -0
- package/src/parsers/extensions.json.parser.d.mts.map +1 -0
- package/src/parsers/extensions.json.parser.mjs +19 -0
- package/src/parsers/extensions.json.parser.mjs.map +1 -0
- package/src/parsers/one-line-token.json.parser.d.mts +6 -0
- package/src/parsers/one-line-token.json.parser.d.mts.map +1 -0
- package/src/parsers/one-line-token.json.parser.mjs +17 -0
- package/src/parsers/one-line-token.json.parser.mjs.map +1 -0
- package/src/preprocessors/extensions.preprocessor.d.mts +6 -0
- package/src/preprocessors/extensions.preprocessor.d.mts.map +1 -0
- package/src/preprocessors/extensions.preprocessor.mjs +74 -0
- package/src/preprocessors/extensions.preprocessor.mjs.map +1 -0
- package/src/presets.d.mts +12 -0
- package/src/presets.d.mts.map +1 -0
- package/src/presets.mjs +33 -0
- package/src/presets.mjs.map +1 -0
- package/src/public_api.d.mts +14 -0
- package/src/public_api.d.mts.map +1 -0
- package/src/public_api.mjs +14 -0
- package/src/public_api.mjs.map +1 -0
- package/src/transform-groups/css-recommended.transform-group.d.mts +4 -0
- package/src/transform-groups/css-recommended.transform-group.d.mts.map +1 -0
- package/src/transform-groups/css-recommended.transform-group.mjs +25 -0
- package/src/transform-groups/css-recommended.transform-group.mjs.map +1 -0
- package/src/transforms/ratio.transform.d.mts +6 -0
- package/src/transforms/ratio.transform.d.mts.map +1 -0
- package/src/transforms/ratio.transform.mjs +48 -0
- package/src/transforms/ratio.transform.mjs.map +1 -0
- package/src/transforms/unit.transform.d.mts +6 -0
- package/src/transforms/unit.transform.d.mts.map +1 -0
- package/src/transforms/unit.transform.mjs +41 -0
- package/src/transforms/unit.transform.mjs.map +1 -0
package/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright Amadeus SAS
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without modification,
|
4
|
+
are permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
7
|
+
list of conditions and the following disclaimer.
|
8
|
+
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation and/or
|
11
|
+
other materials provided with the distribution.
|
12
|
+
|
13
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
14
|
+
may be used to endorse or promote products derived from this software without
|
15
|
+
specific prior written permission.
|
16
|
+
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
18
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
20
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
21
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
22
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
23
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
24
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
25
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
@@ -0,0 +1,255 @@
|
|
1
|
+
<h1 align="center">Otter Style Dictionary</h1>
|
2
|
+
<p align="center">
|
3
|
+
<img src="https://raw.githubusercontent.com/AmadeusITGroup/otter/main/assets/logo/otter.png" alt="Super cute Otter!" width="40%"/>
|
4
|
+
</p>
|
5
|
+
|
6
|
+
This package is an [Otter Framework Module](https://github.com/AmadeusITGroup/otter/tree/main/docs/core/MODULE.md).
|
7
|
+
<br />
|
8
|
+
<br />
|
9
|
+
|
10
|
+
## Description
|
11
|
+
|
12
|
+
[](https://www.npmjs.com/package/@ama-styling/style-dictionary)
|
13
|
+
[](https://www.npmjs.com/package/@ama-styling/style-dictionary)
|
14
|
+
|
15
|
+
This package exposes a set of **Hooks** and **Modules** for the [Style Dictionary](https://styledictionary.com/) to enhance the capabilities of Design Tokens.
|
16
|
+
|
17
|
+
## Get Started
|
18
|
+
|
19
|
+
Set up your [Style Dictionary](https://styledictionary.com/) in your project thanks to the command:
|
20
|
+
|
21
|
+
```shell
|
22
|
+
ng add @ama-styling/style-dictionary
|
23
|
+
```
|
24
|
+
|
25
|
+
By default, the command will do the following updates:
|
26
|
+
|
27
|
+
- Add a dev dependency to the [Style Dictionary package](https://www.npmjs.com/package/style-dictionary).
|
28
|
+
- Create a minimal [config.mjs](https://styledictionary.com/reference/config/#_top) configuration file with the required setup for CSS and Metadata generation.
|
29
|
+
- Add the `generate:theme` and `generate:metadata` scripts in the project *package.json*.
|
30
|
+
|
31
|
+
You will then be able to customize this setup with your project's specifications:
|
32
|
+
|
33
|
+
- Customize the [Style Dictionary configuration](https://styledictionary.com/reference/config/#_top) in the generated *config.mjs* file.
|
34
|
+
- Add [extensions](https://tr.designtokens.org/format/#extensions) to your source Design Token via the [enhancement mechanism](#enhancement).
|
35
|
+
- Configure output files thanks to the [`getTargetFiles` helper](#gettargetfiles).
|
36
|
+
|
37
|
+
## Enhancement
|
38
|
+
|
39
|
+
### Design Token Extensions
|
40
|
+
|
41
|
+
The [Design Tokens](https://tr.designtokens.org/format/#extensions) format allows to provide the `$extensions` property to enhance the Token it is applied to.\
|
42
|
+
The property can be applied to the Token directly as follows:
|
43
|
+
|
44
|
+
```json5
|
45
|
+
// colors.token.json
|
46
|
+
{
|
47
|
+
"colors": {
|
48
|
+
"primary": {
|
49
|
+
"$value": "#000000",
|
50
|
+
"$extensions": {
|
51
|
+
"o3rPrivate": true
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
```
|
57
|
+
|
58
|
+
or in a dedicated `.extensions.json` file (when the [o3r/json-parser/extensions](#parsers) parser is loaded):
|
59
|
+
|
60
|
+
```json5
|
61
|
+
// color.token.json
|
62
|
+
{
|
63
|
+
"colors": {
|
64
|
+
"primary": {
|
65
|
+
"$value": "#000000"
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
```
|
70
|
+
|
71
|
+
```json5
|
72
|
+
// custom.extensions.json
|
73
|
+
{
|
74
|
+
"colors.primary": {
|
75
|
+
"$description": "Primary private color",
|
76
|
+
"$extensions": {
|
77
|
+
"o3rPrivate": true
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
```
|
82
|
+
|
83
|
+
### Available Otter Extensions
|
84
|
+
|
85
|
+
| Extensions | Type | Description | Required hooks |
|
86
|
+
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
87
|
+
| o3rPrivate | `boolean` | Determine if the token is flagged as private | pre-processor: **o3r/pre-processor/extensions** <br />formatter: **o3r/css/variable** |
|
88
|
+
| o3rImportant | `boolean` | Determine if the token should be flagged as important when generated | pre-processor: **o3r/pre-processor/extensions** <br />formatter: **o3r/css/variable** |
|
89
|
+
| o3rScope | `string` | Scope to apply to the generated variable | pre-processor: **o3r/pre-processor/extensions** <br />formatter: **o3r/css/variable** |
|
90
|
+
| o3rMetadata | [CMS Metadata](https://github.com/AmadeusITGroup/otter/blob/main/packages/%40ama-styling/style-dictionary/src/interfaces/style-dictionary.interface.mts) | Additional information to provide to the metadata if generated | pre-processor: **o3r/pre-processor/extensions** <br />formatter: **o3r/json/metadata** |
|
91
|
+
| o3rUnit | `string` | Convert a numeric value from the specified unit to the new unit. It will add a unit to the tokens of type \"number\" for which the unit is not specified.<br />In the case of complex types (such as shadow, transition, etc...), the unit will be applied to all numeric types they contain. | pre-processor: **o3r/pre-processor/extensions** <br />transforms: **o3r/transform/unit** |
|
92
|
+
| o3rRatio | `number` | Ratio to apply to the previous value. The ratio will only be applied to tokens of type \"number\" or to the first numbers determined in \"string\" like types.<br />In the case of complex types (such as shadow, transition, etc...), the ratio will be applied to all numeric types they contain. | pre-processor: **o3r/pre-processor/extensions** <br />transforms: **o3r/transform/ratio** |
|
93
|
+
| o3rExpectOverride | `boolean` | Indicate that the token is expected to be overridden by external rules | pre-processor: **o3r/pre-processor/extensions** |
|
94
|
+
|
95
|
+
> [!WARNING]
|
96
|
+
> The **required hooks** need to be registered to the [Style Dictionary configuration](https://styledictionary.com/reference/config/) to fully support the extension.
|
97
|
+
|
98
|
+
## Modules
|
99
|
+
|
100
|
+
### [Parsers](https://styledictionary.com/reference/hooks/parsers/)
|
101
|
+
|
102
|
+
| Name | Matching files | Description |
|
103
|
+
| ------------------------------ | ---------------------- | -------------------------------------------------------------------------------- |
|
104
|
+
| o3r/json-parser/one-line-token | `**/*.json` | Allow *dot notation* Token in JSON file |
|
105
|
+
| o3r/json-parser/extensions | `**/*.extensions.json` | Parse file containing `$extensions` instructions to apply on top of Design Token |
|
106
|
+
|
107
|
+
### [Pre-processor](https://styledictionary.com/reference/hooks/preprocessors/)
|
108
|
+
|
109
|
+
| Name | Description |
|
110
|
+
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
111
|
+
| o3r/pre-processor/extensions | Pre-processor to add the support of the `$extensions` instructions in the Token (or dedicated `extensions.json` file). This pre-processor is mandatory for any Otter hooks. |
|
112
|
+
|
113
|
+
### [Transforms](https://styledictionary.com/reference/hooks/transforms/)
|
114
|
+
|
115
|
+
| Name | Type | Criteria | Description |
|
116
|
+
| ------------------- | ------- | -------------------------------- | --------------------------------------------------------------------------------------- |
|
117
|
+
| o3r/transform/ratio | `value` | `o3rRatio` extension is provided | Apply the given `o3rRatio` to the numeric values of the Token(s) it refers to. |
|
118
|
+
| o3r/transform/unit | `value` | `o3rUnit` extension is provided | Replace the unit of the values of the Token(s) it refers to, by the provided `o3rUnit`. |
|
119
|
+
|
120
|
+
### [Transform-groups](https://styledictionary.com/reference/hooks/transform-groups/)
|
121
|
+
|
122
|
+
| Name | Description |
|
123
|
+
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
124
|
+
| o3r/css/recommended | Extend the official [CSS transform groups](https://styledictionary.com/reference/hooks/transform-groups/predefined/#css) by adding `o3r/transform/ratio` and `o3r/transform/unit` |
|
125
|
+
|
126
|
+
### [Formats](https://styledictionary.com/reference/hooks/formats/)
|
127
|
+
|
128
|
+
| Name | Options | Description |
|
129
|
+
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
130
|
+
| o3r/css/variable | See [css/variables options](https://styledictionary.com/reference/hooks/formats/predefined/#cssvariables) | Render CSS variable block (based on the [built-in format](https://styledictionary.com/reference/hooks/formats/predefined/#cssvariables)) supporting additional [Otter Extensions features](#enhancement). |
|
131
|
+
| o3r/json/metadata | See [css/variables options](https://styledictionary.com/reference/hooks/formats/predefined/#cssvariables) *(applied to `defaultValue`)*<br />- **keepPrivate**: include private variables | Render [CMS style metadata](https://github.com/AmadeusITGroup/otter/blob/main/docs/styling/THEME.md). |
|
132
|
+
|
133
|
+
### Registration process
|
134
|
+
|
135
|
+
The different hooks/modules can be registered individually via the different [register...()](https://styledictionary.com/getting-started/using_the_npm_module/) functions from `StyleDictionary` or all at once with the `register` function as follows:
|
136
|
+
|
137
|
+
```typescript
|
138
|
+
import { register, baseConfig } from '@ama-styling/style-dictionary';
|
139
|
+
|
140
|
+
const sd = new StyleDictionary({
|
141
|
+
...baseConfig,
|
142
|
+
// custom configs ...
|
143
|
+
});
|
144
|
+
|
145
|
+
register(sd); // Register all Otter modules
|
146
|
+
```
|
147
|
+
|
148
|
+
> [!IMPORTANT]
|
149
|
+
> To be able to use any of the listed modules/hooks, they have to be registered to the `StyleDefinition` instance.
|
150
|
+
|
151
|
+
> [!TIP]
|
152
|
+
> The helper `baseConfig` will provide the minimal configuration for Otter extension support.
|
153
|
+
|
154
|
+
### Helpers
|
155
|
+
|
156
|
+
To enhance and facilitate the configuration of the `StyleDictionary` instance, the `@ama-styling/style-dictionary` exposes a set of helpers.
|
157
|
+
|
158
|
+
#### getTargetFiles
|
159
|
+
|
160
|
+
The `getTargetFiles` function is used to parameterize the generated file based on Design Token (following the same logic as `$extensions`):
|
161
|
+
|
162
|
+
```typescript
|
163
|
+
// Example to generate the `color-primary-**` variables in `my-color-primary.css`
|
164
|
+
|
165
|
+
import { getTargetFiles } from '@ama-styling/style-dictionary';
|
166
|
+
|
167
|
+
const rule = {
|
168
|
+
'color.primary': 'my-color-primary.css'
|
169
|
+
};
|
170
|
+
|
171
|
+
// or `const rule = {color: {primary: 'my-color-primary.css'}}`
|
172
|
+
// or `const rule = {'color.primary': {$extensions: {o3rTargetFile: 'my-color-primary.css'}}}`
|
173
|
+
// or `const rule = {'color: {primary': {$extensions: {o3rTargetFile: 'my-color-primary.css'}}}}`
|
174
|
+
|
175
|
+
const sd = new StyleDictionary({
|
176
|
+
//...
|
177
|
+
plateforms: {
|
178
|
+
css: {
|
179
|
+
files: [
|
180
|
+
...getTargetFiles({ rule, { format: 'css', defaultFile: 'default-file.css' } })
|
181
|
+
]
|
182
|
+
}
|
183
|
+
}
|
184
|
+
});
|
185
|
+
|
186
|
+
register(sd); // Register all Otter modules
|
187
|
+
```
|
188
|
+
|
189
|
+
> [!NOTE]
|
190
|
+
> The `format` option will be applied to all the files provided to the `getTargetFiles` function (including `defaultFile`).
|
191
|
+
> `defaultFile` defines the default file where variables not matching any rule will be generated.
|
192
|
+
|
193
|
+
## Advanced
|
194
|
+
|
195
|
+
### Basic Node Configuration Example
|
196
|
+
|
197
|
+
```typescript
|
198
|
+
// style-builder.mjs
|
199
|
+
|
200
|
+
import { register, getTargetFiles, baseConfiguration } from '@ama-styling/style-dictionary';
|
201
|
+
import StyleDictionary from 'style-dictionary';
|
202
|
+
|
203
|
+
// Rules to generate different CSS files according to Token name
|
204
|
+
const fileRules = {
|
205
|
+
colors: 'style/colors.tokens.css',
|
206
|
+
'components.panel': 'components/panel/panel.tokens.css'
|
207
|
+
}
|
208
|
+
|
209
|
+
const sd = new StyleDictionary({
|
210
|
+
...baseConfiguration, // Use basic Otter configuration setup
|
211
|
+
usesDtcg: true, // Use Design Token Standard format
|
212
|
+
|
213
|
+
source: ['tokens/*.tokens.json'], // Design Token files
|
214
|
+
include: ['token.extensions.json'], // Custom extensions
|
215
|
+
|
216
|
+
platforms: {
|
217
|
+
// Generate CSS Files
|
218
|
+
css: {
|
219
|
+
options: {
|
220
|
+
outputReferences: true // to output `--var: var(--other-var)` instead of the value of `--other-var`
|
221
|
+
},
|
222
|
+
transformGroup: 'o3r/css/recommended',
|
223
|
+
files: [
|
224
|
+
...getTargetFiles(fileRules, { format: 'css' }),
|
225
|
+
// default CSS file where generate variables
|
226
|
+
{ destination: 'style/default.tokens.css', format: 'css' }
|
227
|
+
]
|
228
|
+
},
|
229
|
+
cms: {
|
230
|
+
options: {
|
231
|
+
outputReferences: true
|
232
|
+
},
|
233
|
+
transformGroup: 'o3r/css/recommended',
|
234
|
+
files: [
|
235
|
+
{ destination: 'style.metadata.json', format: 'o3r/json/metadata' }
|
236
|
+
]
|
237
|
+
}
|
238
|
+
}
|
239
|
+
});
|
240
|
+
|
241
|
+
// Register otter hooks/modules
|
242
|
+
register(sd);
|
243
|
+
|
244
|
+
if (process.env.CSS_ONLY){
|
245
|
+
sd.buildPlatform('css');
|
246
|
+
} else {
|
247
|
+
sd.buildAllPlatforms();
|
248
|
+
}
|
249
|
+
```
|
250
|
+
|
251
|
+
Can be run with the following command:
|
252
|
+
|
253
|
+
```bash
|
254
|
+
node ./style-builder.mjs
|
255
|
+
```
|
package/collection.json
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://raw.githubusercontent.com/angular/angular-cli/master/packages/angular_devkit/schematics/collection-schema.json",
|
3
|
+
"schematics": {
|
4
|
+
"ng-add": {
|
5
|
+
"description": "Add Otter Style-Dictionary to the project.",
|
6
|
+
"factory": "./schematics/ng-add/index#ngAdd",
|
7
|
+
"schema": "./schematics/ng-add/schema.json",
|
8
|
+
"aliases": [
|
9
|
+
"install",
|
10
|
+
"i"
|
11
|
+
]
|
12
|
+
}
|
13
|
+
}
|
14
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
{
|
2
|
+
"name": "@ama-styling/style-dictionary",
|
3
|
+
"version": "12.5.0-prerelease.10",
|
4
|
+
"type": "module",
|
5
|
+
"publishConfig": {
|
6
|
+
"access": "public"
|
7
|
+
},
|
8
|
+
"typings": "./src/public_api.d.mts",
|
9
|
+
"main": "./src/public_api.mjs",
|
10
|
+
"description": "Package exposing modules and hooks for Style Dictionary",
|
11
|
+
"keywords": [
|
12
|
+
"design",
|
13
|
+
"otter",
|
14
|
+
"otter-module",
|
15
|
+
"style-dictionary"
|
16
|
+
],
|
17
|
+
"scripts": {
|
18
|
+
"nx": "nx",
|
19
|
+
"ng": "yarn nx",
|
20
|
+
"copy:schemas": "yarn cpy 'schemas/**/*' dist/schemas",
|
21
|
+
"copy:templates": "yarn cpy 'schematics/**/templates/**' dist/schematics",
|
22
|
+
"build:builders": "tsc -b tsconfig.builders.json --pretty && yarn generate-cjs-manifest",
|
23
|
+
"build:source": "tsc -b tsconfig.build.json && yarn cpy package.json dist/",
|
24
|
+
"build": "yarn nx build design",
|
25
|
+
"prepare:build:builders": "yarn cpy 'schematics/**/*.json' dist/schematics && yarn cpy 'collection.json' dist && yarn copy:templates",
|
26
|
+
"postbuild": "patch-package-json-main"
|
27
|
+
},
|
28
|
+
"exports": {
|
29
|
+
"./package.json": {
|
30
|
+
"default": "./package.json"
|
31
|
+
},
|
32
|
+
"./schemas/*.json": {
|
33
|
+
"default": "./schemas/*.json"
|
34
|
+
},
|
35
|
+
".": {
|
36
|
+
"module": "./src/public_api.mjs",
|
37
|
+
"typings": "./src/public_api.d.mts",
|
38
|
+
"default": "./src/public_api.mjs"
|
39
|
+
}
|
40
|
+
},
|
41
|
+
"dependencies": {
|
42
|
+
"@angular-devkit/architect": "~0.1902.0",
|
43
|
+
"@angular-devkit/schematics": "~19.2.0",
|
44
|
+
"@o3r/schematics": "^12.5.0-prerelease.10",
|
45
|
+
"@schematics/angular": "~19.2.0",
|
46
|
+
"tslib": "^2.6.2"
|
47
|
+
},
|
48
|
+
"peerDependencies": {
|
49
|
+
"@o3r/core": "^12.5.0-prerelease.10",
|
50
|
+
"@o3r/schematics": "^12.5.0-prerelease.10",
|
51
|
+
"@o3r/telemetry": "^12.5.0-prerelease.10",
|
52
|
+
"style-dictionary": "^4.3.2",
|
53
|
+
"type-fest": "^4.30.1"
|
54
|
+
},
|
55
|
+
"peerDependenciesMeta": {
|
56
|
+
"@o3r/core": {
|
57
|
+
"optional": true
|
58
|
+
},
|
59
|
+
"@o3r/schematics": {
|
60
|
+
"optional": true
|
61
|
+
},
|
62
|
+
"@o3r/telemetry": {
|
63
|
+
"optional": true
|
64
|
+
},
|
65
|
+
"chokidar": {
|
66
|
+
"optional": true
|
67
|
+
},
|
68
|
+
"globby": {
|
69
|
+
"optional": true
|
70
|
+
},
|
71
|
+
"type-fest": {
|
72
|
+
"optional": true
|
73
|
+
}
|
74
|
+
},
|
75
|
+
"devDependencies": {
|
76
|
+
"@babel/core": "~7.27.0",
|
77
|
+
"@babel/preset-env": "~7.27.0",
|
78
|
+
"@babel/preset-typescript": "~7.27.0",
|
79
|
+
"@compodoc/compodoc": "^1.1.19",
|
80
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
|
81
|
+
"@nx/eslint": "~20.8.0",
|
82
|
+
"@nx/eslint-plugin": "~20.8.0",
|
83
|
+
"@nx/jest": "~20.8.0",
|
84
|
+
"@nx/js": "~20.8.0",
|
85
|
+
"@o3r/build-helpers": "^12.5.0-prerelease.10",
|
86
|
+
"@o3r/core": "^12.5.0-prerelease.10",
|
87
|
+
"@o3r/eslint-plugin": "^12.5.0-prerelease.10",
|
88
|
+
"@o3r/telemetry": "^12.5.0-prerelease.10",
|
89
|
+
"@o3r/test-helpers": "^12.5.0-prerelease.10",
|
90
|
+
"@schematics/angular": "~19.2.0",
|
91
|
+
"@stylistic/eslint-plugin": "~3.1.0",
|
92
|
+
"@types/jest": "~29.5.2",
|
93
|
+
"@types/minimist": "^1.2.2",
|
94
|
+
"@types/node": "^20.0.0",
|
95
|
+
"@types/semver": "^7.3.13",
|
96
|
+
"@typescript-eslint/parser": "~8.34.0",
|
97
|
+
"angular-eslint": "~19.4.0",
|
98
|
+
"babel-jest": "^29.7.0",
|
99
|
+
"chokidar": "^4.0.3",
|
100
|
+
"cpy-cli": "^5.0.0",
|
101
|
+
"eslint": "~9.29.0",
|
102
|
+
"eslint-import-resolver-node": "~0.3.9",
|
103
|
+
"eslint-import-resolver-typescript": "~3.10.0",
|
104
|
+
"eslint-plugin-import": "~2.31.0",
|
105
|
+
"eslint-plugin-import-newlines": "~1.4.0",
|
106
|
+
"eslint-plugin-jest": "~28.14.0",
|
107
|
+
"eslint-plugin-jsdoc": "~50.8.0",
|
108
|
+
"eslint-plugin-prefer-arrow": "~1.2.3",
|
109
|
+
"eslint-plugin-unicorn": "~56.0.0",
|
110
|
+
"eslint-plugin-unused-imports": "~4.1.4",
|
111
|
+
"globals": "^15.9.0",
|
112
|
+
"jest": "~29.7.0",
|
113
|
+
"jest-junit": "~16.0.0",
|
114
|
+
"jest-resolve": "~29.7.0",
|
115
|
+
"jsonc-eslint-parser": "~2.4.0",
|
116
|
+
"nx": "~20.8.0",
|
117
|
+
"pid-from-port": "^1.1.3",
|
118
|
+
"style-dictionary": "~4.4.0",
|
119
|
+
"ts-jest": "~29.3.0",
|
120
|
+
"ts-node": "~10.9.2",
|
121
|
+
"type-fest": "^4.30.1",
|
122
|
+
"typescript": "~5.8.2",
|
123
|
+
"typescript-eslint": "~8.34.0",
|
124
|
+
"zone.js": "~0.15.0"
|
125
|
+
},
|
126
|
+
"engines": {
|
127
|
+
"node": "^20.11.1 || >=22.0.0"
|
128
|
+
},
|
129
|
+
"schematics": "./collection.json",
|
130
|
+
"contributors": [
|
131
|
+
{
|
132
|
+
"name": "Yannick Adam",
|
133
|
+
"url": "https://github.com/yannickadam",
|
134
|
+
"email": "yannickadam@users.noreply.github.com"
|
135
|
+
},
|
136
|
+
{
|
137
|
+
"name": "Kilian Panot",
|
138
|
+
"url": "https://github.com/kpanot",
|
139
|
+
"email": "kpanot@users.noreply.github.com"
|
140
|
+
},
|
141
|
+
{
|
142
|
+
"name": "Jeremy Bourgeois",
|
143
|
+
"url": "https://github.com/jbourgeois-1A",
|
144
|
+
"email": "jbourgeois-1A@users.noreply.github.com"
|
145
|
+
},
|
146
|
+
{
|
147
|
+
"name": "Pierre Henri Ginoux",
|
148
|
+
"url": "https://github.com/pginoux-1A",
|
149
|
+
"email": "pginoux-1A@users.noreply.github.com"
|
150
|
+
},
|
151
|
+
{
|
152
|
+
"name": "Mircea Vasile Rednic",
|
153
|
+
"url": "https://github.com/mrednic-1A",
|
154
|
+
"email": "mrednic-1A@users.noreply.github.com"
|
155
|
+
},
|
156
|
+
{
|
157
|
+
"name": "Stephane Dalle",
|
158
|
+
"url": "https://github.com/sdalle-1A",
|
159
|
+
"email": "sdalle-1A@users.noreply.github.com"
|
160
|
+
},
|
161
|
+
{
|
162
|
+
"name": "Nicolas Hoffmann",
|
163
|
+
"url": "https://github.com/nhoffmann-1A",
|
164
|
+
"email": "nhoffmann-1A@users.noreply.github.com"
|
165
|
+
},
|
166
|
+
{
|
167
|
+
"name": "Victor Scaiceanu",
|
168
|
+
"url": "https://github.com/vscaiceanu-1a",
|
169
|
+
"email": "vscaiceanu-1A@users.noreply.github.com"
|
170
|
+
},
|
171
|
+
{
|
172
|
+
"name": "Florian Paul",
|
173
|
+
"url": "https://github.com/fpaul-1A",
|
174
|
+
"email": "fpaul-1A@users.noreply.github.com"
|
175
|
+
},
|
176
|
+
{
|
177
|
+
"name": "Corinne Paulve",
|
178
|
+
"url": "https://github.com/cpaulve-1A",
|
179
|
+
"email": "cpaulve-1A@users.noreply.github.com"
|
180
|
+
},
|
181
|
+
{
|
182
|
+
"name": "Matthieu Crouzet",
|
183
|
+
"url": "https://github.com/matthieu-crouzet",
|
184
|
+
"email": "matthieu-crouzet@users.noreply.github.com"
|
185
|
+
},
|
186
|
+
{
|
187
|
+
"name": "Salome Do",
|
188
|
+
"url": "https://github.com/sdo-1A",
|
189
|
+
"email": "sdo-1A@users.noreply.github.com"
|
190
|
+
}
|
191
|
+
],
|
192
|
+
"bugs": "https://github.com/AmadeusITGroup/otter/issues",
|
193
|
+
"repository": {
|
194
|
+
"type": "git",
|
195
|
+
"url": "git+https://github.com/AmadeusITGroup/otter.git"
|
196
|
+
},
|
197
|
+
"license": "BSD-3-Clause",
|
198
|
+
"homepage": "https://amadeusitgroup.github.io/otter/"
|
199
|
+
}
|
@@ -0,0 +1,121 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
3
|
+
"$id": "DesignTokenTemplateSchema",
|
4
|
+
"description": "Schema Describing the structure of the Design Token template, to enhance a Design Token structure",
|
5
|
+
"allOf": [
|
6
|
+
{
|
7
|
+
"$ref": "#/definitions/tokenTemplateGroup"
|
8
|
+
}
|
9
|
+
],
|
10
|
+
"definitions": {
|
11
|
+
"otterExtensionMetadata": {
|
12
|
+
"type": "object",
|
13
|
+
"properties": {
|
14
|
+
"tags": {
|
15
|
+
"type": "array",
|
16
|
+
"description": "List of tags associated to the variable",
|
17
|
+
"items": {
|
18
|
+
"type": "string"
|
19
|
+
}
|
20
|
+
},
|
21
|
+
"label": {
|
22
|
+
"type": "string",
|
23
|
+
"description": "Label of the variable, it will be used to display the variable name in the CMS if specified"
|
24
|
+
},
|
25
|
+
"category": {
|
26
|
+
"type": "string",
|
27
|
+
"description": "Category of the variable"
|
28
|
+
},
|
29
|
+
"component": {
|
30
|
+
"type": "object",
|
31
|
+
"description": "Component reference if the variable is linked to one",
|
32
|
+
"properties": {
|
33
|
+
"library": {
|
34
|
+
"type": "string",
|
35
|
+
"description": "Name of the library containing the component"
|
36
|
+
},
|
37
|
+
"name": {
|
38
|
+
"type": "string",
|
39
|
+
"description": "Name of the component"
|
40
|
+
}
|
41
|
+
},
|
42
|
+
"required": [
|
43
|
+
"library",
|
44
|
+
"name"
|
45
|
+
],
|
46
|
+
"additionalProperties": false
|
47
|
+
}
|
48
|
+
}
|
49
|
+
},
|
50
|
+
"otterExtension": {
|
51
|
+
"type": "object",
|
52
|
+
"properties": {
|
53
|
+
"o3rPrivate": {
|
54
|
+
"description": "Determine if the token is flagged as private",
|
55
|
+
"type": "boolean",
|
56
|
+
"default": false
|
57
|
+
},
|
58
|
+
"o3rImportant": {
|
59
|
+
"description": "Determine if the token should be flagged as important when generated",
|
60
|
+
"examples": [
|
61
|
+
"Css Generation of `my-var` with `o3rImportant: true` will result to `:root { --my-var: #000 !important; }`"
|
62
|
+
],
|
63
|
+
"type": "boolean",
|
64
|
+
"default": false
|
65
|
+
},
|
66
|
+
"o3rScope": {
|
67
|
+
"description": "Scope to apply to the generated variable",
|
68
|
+
"examples": [
|
69
|
+
"Css Generation of `my-var` with `o3rScope: 'html .my-class'` will result to `:root { html .my-class { --my-var: #000; } }`"
|
70
|
+
],
|
71
|
+
"type": "string"
|
72
|
+
},
|
73
|
+
"o3rMetadata": {
|
74
|
+
"description": "Additional information to provide to the metadata if generated. The metadata properties will be used only with the `o3r/<type>/metadata` formats.",
|
75
|
+
"$ref": "#/definitions/otterExtensionMetadata"
|
76
|
+
},
|
77
|
+
"o3rUnit": {
|
78
|
+
"description": "Convert a numeric value from the specified unit to the new unit. It will add a unit to the token with type \"number\" for which the unit is not specified.\nIn case of complex type (such as shadow, transition, etc...), the unit will be applied to all numeric types in it.",
|
79
|
+
"type": "string"
|
80
|
+
},
|
81
|
+
"o3rRatio": {
|
82
|
+
"description": "Ratio to apply to previous value. The ratio will be applied only on token with \"number\" type or on the first numbers determined in \"string\" like types.\nIn case of complex type (such as shadow, transition, etc...), the ratio will be applied to all numeric types in it.",
|
83
|
+
"type": "number"
|
84
|
+
},
|
85
|
+
"o3rExpectOverride": {
|
86
|
+
"description": "Indicate that the token is expected to be overridden by external rules. This is converted to the Style Dictionary themeable attribute",
|
87
|
+
"type": "boolean",
|
88
|
+
"default": false
|
89
|
+
}
|
90
|
+
}
|
91
|
+
},
|
92
|
+
"extensions": {
|
93
|
+
"description": "Information to enhance generation",
|
94
|
+
"allOf": [
|
95
|
+
{
|
96
|
+
"$ref": "#/definitions/otterExtension"
|
97
|
+
}
|
98
|
+
]
|
99
|
+
},
|
100
|
+
"tokenTemplateGroup": {
|
101
|
+
"type": "object",
|
102
|
+
"properties": {
|
103
|
+
"$schema": {
|
104
|
+
"type": "string"
|
105
|
+
},
|
106
|
+
"$description": {
|
107
|
+
"type": "string"
|
108
|
+
},
|
109
|
+
"$extensions": {
|
110
|
+
"$ref": "#/definitions/extensions"
|
111
|
+
}
|
112
|
+
},
|
113
|
+
"patternProperties": {
|
114
|
+
"^[^$.].*$": {
|
115
|
+
"$ref": "#/definitions/tokenTemplateGroup"
|
116
|
+
}
|
117
|
+
},
|
118
|
+
"additionalProperties": false
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { Rule } from '@angular-devkit/schematics';
|
2
|
+
import type { NgAddSchematicsSchema } from './schema';
|
3
|
+
/**
|
4
|
+
* Add Otter Style Dictionary to an Angular Project
|
5
|
+
* @param options
|
6
|
+
*/
|
7
|
+
export declare const ngAdd: (options: NgAddSchematicsSchema) => Rule;
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,IAAI,EAGL,MAAM,4BAA4B,CAAC;AAiBpC,OAAO,KAAK,EACV,qBAAqB,EACtB,MAAM,UAAU,CAAC;AA+FlB;;;GAGG;AACH,eAAO,MAAM,KAAK,GAAI,SAAS,qBAAqB,SAA2C,CAAC"}
|