@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.
Files changed (99) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +255 -0
  3. package/collection.json +14 -0
  4. package/package.json +199 -0
  5. package/schemas/design-token.extensions.schema.json +121 -0
  6. package/schematics/ng-add/index.d.ts +8 -0
  7. package/schematics/ng-add/index.d.ts.map +1 -0
  8. package/schematics/ng-add/index.js +100 -0
  9. package/schematics/ng-add/schema.d.ts +10 -0
  10. package/schematics/ng-add/schema.d.ts.map +1 -0
  11. package/schematics/ng-add/schema.js +3 -0
  12. package/schematics/ng-add/schema.json +26 -0
  13. package/schematics/ng-add/templates/config.__configExtension__ +50 -0
  14. package/schematics/ng-add/templates/token.extensions.json.template +3 -0
  15. package/schematics/package.json +3 -0
  16. package/src/constants.d.mts +5 -0
  17. package/src/constants.d.mts.map +1 -0
  18. package/src/constants.mjs +5 -0
  19. package/src/constants.mjs.map +1 -0
  20. package/src/filters/target-file.filter.d.mts +34 -0
  21. package/src/filters/target-file.filter.d.mts.map +1 -0
  22. package/src/filters/target-file.filter.mjs +49 -0
  23. package/src/filters/target-file.filter.mjs.map +1 -0
  24. package/src/formats/css-formatters/default.formatter.d.mts +7 -0
  25. package/src/formats/css-formatters/default.formatter.d.mts.map +1 -0
  26. package/src/formats/css-formatters/default.formatter.mjs +19 -0
  27. package/src/formats/css-formatters/default.formatter.mjs.map +1 -0
  28. package/src/formats/css-formatters/gradients.formatter.d.mts +7 -0
  29. package/src/formats/css-formatters/gradients.formatter.d.mts.map +1 -0
  30. package/src/formats/css-formatters/gradients.formatter.mjs +32 -0
  31. package/src/formats/css-formatters/gradients.formatter.mjs.map +1 -0
  32. package/src/formats/css-formatters/interface.formatter.d.mts +13 -0
  33. package/src/formats/css-formatters/interface.formatter.d.mts.map +1 -0
  34. package/src/formats/css-formatters/interface.formatter.mjs +2 -0
  35. package/src/formats/css-formatters/interface.formatter.mjs.map +1 -0
  36. package/src/formats/css-formatters/private.formatter.d.mts +7 -0
  37. package/src/formats/css-formatters/private.formatter.d.mts.map +1 -0
  38. package/src/formats/css-formatters/private.formatter.mjs +33 -0
  39. package/src/formats/css-formatters/private.formatter.mjs.map +1 -0
  40. package/src/formats/css.format.d.mts +3 -0
  41. package/src/formats/css.format.d.mts.map +1 -0
  42. package/src/formats/css.format.mjs +60 -0
  43. package/src/formats/css.format.mjs.map +1 -0
  44. package/src/formats/metadata.format.d.mts +3 -0
  45. package/src/formats/metadata.format.d.mts.map +1 -0
  46. package/src/formats/metadata.format.mjs +71 -0
  47. package/src/formats/metadata.format.mjs.map +1 -0
  48. package/src/helpers/config-deflatten.helpers.d.mts +6 -0
  49. package/src/helpers/config-deflatten.helpers.d.mts.map +1 -0
  50. package/src/helpers/config-deflatten.helpers.mjs +46 -0
  51. package/src/helpers/config-deflatten.helpers.mjs.map +1 -0
  52. package/src/helpers/sort-by-path.sort.helpers.d.mts +8 -0
  53. package/src/helpers/sort-by-path.sort.helpers.d.mts.map +1 -0
  54. package/src/helpers/sort-by-path.sort.helpers.mjs +33 -0
  55. package/src/helpers/sort-by-path.sort.helpers.mjs.map +1 -0
  56. package/src/interfaces/extensions.interface.d.mts +56 -0
  57. package/src/interfaces/extensions.interface.d.mts.map +1 -0
  58. package/src/interfaces/extensions.interface.mjs +2 -0
  59. package/src/interfaces/extensions.interface.mjs.map +1 -0
  60. package/src/interfaces/metadata.interface.d.mts +57 -0
  61. package/src/interfaces/metadata.interface.d.mts.map +1 -0
  62. package/src/interfaces/metadata.interface.mjs +2 -0
  63. package/src/interfaces/metadata.interface.mjs.map +1 -0
  64. package/src/interfaces/style-dictionary.interface.d.mts +11 -0
  65. package/src/interfaces/style-dictionary.interface.d.mts.map +1 -0
  66. package/src/interfaces/style-dictionary.interface.mjs +2 -0
  67. package/src/interfaces/style-dictionary.interface.mjs.map +1 -0
  68. package/src/parsers/extensions.json.parser.d.mts +6 -0
  69. package/src/parsers/extensions.json.parser.d.mts.map +1 -0
  70. package/src/parsers/extensions.json.parser.mjs +19 -0
  71. package/src/parsers/extensions.json.parser.mjs.map +1 -0
  72. package/src/parsers/one-line-token.json.parser.d.mts +6 -0
  73. package/src/parsers/one-line-token.json.parser.d.mts.map +1 -0
  74. package/src/parsers/one-line-token.json.parser.mjs +17 -0
  75. package/src/parsers/one-line-token.json.parser.mjs.map +1 -0
  76. package/src/preprocessors/extensions.preprocessor.d.mts +6 -0
  77. package/src/preprocessors/extensions.preprocessor.d.mts.map +1 -0
  78. package/src/preprocessors/extensions.preprocessor.mjs +74 -0
  79. package/src/preprocessors/extensions.preprocessor.mjs.map +1 -0
  80. package/src/presets.d.mts +12 -0
  81. package/src/presets.d.mts.map +1 -0
  82. package/src/presets.mjs +33 -0
  83. package/src/presets.mjs.map +1 -0
  84. package/src/public_api.d.mts +14 -0
  85. package/src/public_api.d.mts.map +1 -0
  86. package/src/public_api.mjs +14 -0
  87. package/src/public_api.mjs.map +1 -0
  88. package/src/transform-groups/css-recommended.transform-group.d.mts +4 -0
  89. package/src/transform-groups/css-recommended.transform-group.d.mts.map +1 -0
  90. package/src/transform-groups/css-recommended.transform-group.mjs +25 -0
  91. package/src/transform-groups/css-recommended.transform-group.mjs.map +1 -0
  92. package/src/transforms/ratio.transform.d.mts +6 -0
  93. package/src/transforms/ratio.transform.d.mts.map +1 -0
  94. package/src/transforms/ratio.transform.mjs +48 -0
  95. package/src/transforms/ratio.transform.mjs.map +1 -0
  96. package/src/transforms/unit.transform.d.mts +6 -0
  97. package/src/transforms/unit.transform.d.mts.map +1 -0
  98. package/src/transforms/unit.transform.mjs +41 -0
  99. package/src/transforms/unit.transform.mjs.map +1 -0
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ngAdd = void 0;
4
+ const path = require("node:path");
5
+ const schematics_1 = require("@angular-devkit/schematics");
6
+ const schematics_2 = require("@o3r/schematics");
7
+ /** Prefix of the expose Design Token items */
8
+ const PREFIX = 'ama';
9
+ /**
10
+ * Add Otter Style Dictionary process to an Angular Project
11
+ * @param options
12
+ */
13
+ function ngAddFn(options) {
14
+ const setup = async (tree, context) => {
15
+ const devDependenciesToInstall = [
16
+ 'style-dictionary'
17
+ ];
18
+ const depsInfo = (0, schematics_2.getO3rPeerDeps)(path.resolve(__dirname, '..', '..', 'package.json'), true);
19
+ const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
20
+ const { NodeDependencyType } = await Promise.resolve().then(() => require('@schematics/angular/utility/dependencies'));
21
+ const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
22
+ const dependencies = depsInfo.o3rPeerDeps.reduce((acc, dep) => {
23
+ acc[dep] = {
24
+ inManifest: [{
25
+ range: `${options.exactO3rVersion ? '' : '~'}${depsInfo.packageVersion}`,
26
+ types: (0, schematics_2.getProjectNewDependenciesTypes)(workspaceProject)
27
+ }],
28
+ ngAddOptions: { exactO3rVersion: options.exactO3rVersion }
29
+ };
30
+ return acc;
31
+ }, (0, schematics_2.getPackageInstallConfig)(packageJsonPath, tree, options.projectName, true, !!options.exactO3rVersion));
32
+ Object.entries((0, schematics_2.getExternalDependenciesVersionRange)(devDependenciesToInstall, packageJsonPath, context.logger))
33
+ .forEach(([dep, range]) => {
34
+ dependencies[dep] = {
35
+ inManifest: [{
36
+ range,
37
+ types: [NodeDependencyType.Dev]
38
+ }]
39
+ };
40
+ });
41
+ return (0, schematics_2.setupDependencies)({
42
+ projectName: options.projectName,
43
+ dependencies,
44
+ ngAddToRun: depsInfo.o3rPeerDeps
45
+ });
46
+ };
47
+ const generateConfig = (tree, context) => {
48
+ const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
49
+ const projectType = workspaceProject?.projectType || 'application';
50
+ const projectRoot = workspaceProject?.root;
51
+ if (!projectRoot) {
52
+ context.logger.warn('No workspace detected, the default configuration will not be added.');
53
+ return;
54
+ }
55
+ return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./templates'), [
56
+ (0, schematics_1.template)({
57
+ configExtension: `${options.useJsExt ? '' : 'm'}js`,
58
+ projectType: projectType,
59
+ prefixName: PREFIX
60
+ }),
61
+ (0, schematics_1.move)(projectRoot),
62
+ (0, schematics_1.renameTemplateFiles)()
63
+ ]), schematics_1.MergeStrategy.Overwrite);
64
+ };
65
+ const updatePackageJson = (tree, context) => {
66
+ const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
67
+ const packageJsonPath = workspaceProject?.root && tree.exists(path.posix.join(workspaceProject.root, 'package.json'))
68
+ ? path.posix.join(workspaceProject.root, 'package.json')
69
+ : 'package.json';
70
+ const packageJson = tree.readJson(packageJsonPath);
71
+ packageJson.scripts ||= {};
72
+ if (packageJson.scripts['generate:css']) {
73
+ context.logger.warn('The script "generate:css" already exists in the package.json, it will not be added.');
74
+ }
75
+ else {
76
+ packageJson.scripts['generate:css'] = `style-dictionary build ${options.useJsExt ? '' : '-c config.mjs '}-p css`;
77
+ }
78
+ if (packageJson.scripts['generate:metadata']) {
79
+ context.logger.warn('The script "generate:metadata" already exists in the package.json, it will not be added.');
80
+ }
81
+ else {
82
+ packageJson.scripts['generate:metadata'] = `style-dictionary build ${options.useJsExt ? '' : '-c config.mjs '}-p cms`;
83
+ }
84
+ tree.overwrite(packageJsonPath, JSON.stringify(packageJson, null, 2));
85
+ };
86
+ /* ng add rules */
87
+ return (0, schematics_1.chain)([
88
+ setup,
89
+ generateConfig,
90
+ updatePackageJson,
91
+ options.skipLinter ? (0, schematics_1.noop)() : (0, schematics_2.applyEditorConfig)()
92
+ ]);
93
+ }
94
+ /**
95
+ * Add Otter Style Dictionary to an Angular Project
96
+ * @param options
97
+ */
98
+ const ngAdd = (options) => (0, schematics_2.createOtterSchematic)(ngAddFn)(options);
99
+ exports.ngAdd = ngAdd;
100
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,10 @@
1
+ import type { SchematicOptionObject } from '@o3r/schematics';
2
+ export interface NgAddSchematicsSchema extends SchematicOptionObject {
3
+ /** Project name */
4
+ projectName?: string | undefined;
5
+ /** Use a pinned version for otter packages */
6
+ exactO3rVersion?: boolean;
7
+ /** Generate config file with the default extension .js instead of .mjs */
8
+ useJsExt?: boolean;
9
+ }
10
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAClE,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,8CAA8C;IAC9C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1,26 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "ngAddSchematicsSchema",
4
+ "title": "Add Otter Style-Dictionary hooks to an Angular project",
5
+ "description": "Add Otter Style-Dictionary hooks to an Angular project",
6
+ "properties": {
7
+ "projectName": {
8
+ "type": "string",
9
+ "description": "Project name",
10
+ "$default": {
11
+ "$source": "projectName"
12
+ }
13
+ },
14
+ "exactO3rVersion": {
15
+ "type": "boolean",
16
+ "description": "Use a pinned version for otter packages"
17
+ },
18
+ "useJsExt": {
19
+ "type": "boolean",
20
+ "description": "Generate config file with the default extension .js instead of .mjs"
21
+ }
22
+ },
23
+ "additionalProperties": true,
24
+ "required": [
25
+ ]
26
+ }
@@ -0,0 +1,50 @@
1
+ import { baseConfig, getTargetFiles, register } from '@ama-styling/style-dictionary';
2
+
3
+ // Register the Otter configuration hooks
4
+ register();
5
+
6
+ /** @type {import('@ama-styling/style-dictionary').FileRuleNode} */
7
+ const fileRules = {
8
+
9
+ };
10
+
11
+ /** @type {import('style-dictionary').Config} */
12
+ export default {
13
+ ...baseConfig, // Use basic Otter configuration setup
14
+ usesDtcg: true, // Use Design Token Standard format
15
+
16
+ source: [
17
+ // Design Token files
18
+ '*.tokens.json',
19
+
20
+ // Custom application extension setup
21
+ 'token.extensions.json'
22
+ ],
23
+
24
+ platforms: {
25
+ css: {
26
+ options: {
27
+ outputReferences: true
28
+ },
29
+ transformGroup: '<%= prefixName %>/css/recommended',
30
+ files: [
31
+ ...getTargetFiles(fileRules, {
32
+ format: '<%= prefixName %>/css/variable',
33
+ defaultFile: 'default.tokens.css' // default CSS file
34
+ }),
35
+
36
+ // All CSS outputted in a single file:
37
+ { destination: 'all.tokens.css', format: '<%= prefixName %>/css/variable' }
38
+ ]
39
+ },
40
+ cms: {
41
+ options: {
42
+ outputReferences: true
43
+ },
44
+ transformGroup: '<%= prefixName %>/css/recommended',
45
+ files: [
46
+ { destination: 'style.metadata.json', format: '<%= prefixName %>/json/metadata' }
47
+ ]
48
+ }
49
+ }
50
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/AmadeusITGroup/otter/main/packages/%40ama-styling/style-dictionary/schemas/design-token.extensions.schema.json"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,5 @@
1
+ /** Token Key used to propagate the Extension for Token Extension files */
2
+ export declare const OTTER_EXTENSIONS_NODE_NAME = "__extensions__";
3
+ /** Prefix of the expose Design Token items */
4
+ export declare const OTTER_NAME_PREFIX = "ama";
5
+ //# sourceMappingURL=constants.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../src/constants.mts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,eAAO,MAAM,0BAA0B,mBAAmB,CAAC;AAE3D,8CAA8C;AAC9C,eAAO,MAAM,iBAAiB,QAAQ,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** Token Key used to propagate the Extension for Token Extension files */
2
+ export const OTTER_EXTENSIONS_NODE_NAME = '__extensions__';
3
+ /** Prefix of the expose Design Token items */
4
+ export const OTTER_NAME_PREFIX = 'ama';
5
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/constants.mts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,CAAC,MAAM,0BAA0B,GAAG,gBAAgB,CAAC;AAE3D,8CAA8C;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { File, FormatFn } from 'style-dictionary/types';
2
+ /** Options to get file filters */
3
+ interface TargetFileOptions {
4
+ /** format to apply to the files */
5
+ format?: string | FormatFn;
6
+ /** Root path to calculate the target file */
7
+ rootPath?: string;
8
+ /** Default file if not matching any rule */
9
+ defaultFile?: string;
10
+ }
11
+ /**
12
+ * Legacy configuration to support inputs from @o3r/design templates
13
+ * @deprecated Should prefer simple string to specify the target file, will be removed in v13
14
+ */
15
+ interface LegacyFileConfig extends FileRuleNode {
16
+ /** Extensions node in token */
17
+ $extensions: {
18
+ /** Indicate the file where to generate the token */
19
+ o3rTargetFile: string;
20
+ };
21
+ }
22
+ /** Mapping of the Design Tokens to a given file */
23
+ export interface FileRuleNode {
24
+ /** Indicate the file where to generate the token */
25
+ [path: string]: string | FileRuleNode | LegacyFileConfig;
26
+ }
27
+ /**
28
+ * Get the list of the target files based of given rule
29
+ * @param fileRules List of file targets based on token rule
30
+ * @param options
31
+ */
32
+ export declare const getTargetFiles: (fileRules: FileRuleNode, options?: TargetFileOptions) => File[];
33
+ export {};
34
+ //# sourceMappingURL=target-file.filter.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"target-file.filter.d.mts","sourceRoot":"","sources":["../../../src/filters/target-file.filter.mts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,IAAI,EACJ,QAAQ,EACT,MAAM,wBAAwB,CAAC;AAKhC,kCAAkC;AAClC,UAAU,iBAAiB;IACzB,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,UAAU,gBAAiB,SAAQ,YAAY;IAC7C,+BAA+B;IAC/B,WAAW,EAAE;QACX,oDAAoD;QACpD,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED,mDAAmD;AACnD,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,gBAAgB,CAAC;CAC1D;AAsBD;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,WAAW,YAAY,EAAE,UAAU,iBAAiB,KAAG,IAAI,EAgCzF,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { normalize, resolve, } from 'node:path';
2
+ import { deflatten, } from '../helpers/config-deflatten.helpers.mjs';
3
+ const isLegacyConfig = (config) => typeof config.$extensions?.o3rTargetFile === 'string';
4
+ const getPathMap = (rule, path = [], map = new Map()) => {
5
+ if (isLegacyConfig(rule)) {
6
+ map.set(rule.$extensions.o3rTargetFile, [...(map.get(rule.$extensions.o3rTargetFile) || []), path]);
7
+ return map;
8
+ }
9
+ return Object.entries(rule)
10
+ .filter(([name]) => name !== '$extensions')
11
+ .reduce((acc, [name, value]) => {
12
+ const currentPath = [...path, name];
13
+ if (typeof value === 'string') {
14
+ acc.set(value, [...(acc.get(value) || []), currentPath]);
15
+ return acc;
16
+ }
17
+ return getPathMap(value, currentPath, acc);
18
+ }, map);
19
+ };
20
+ /**
21
+ * Get the list of the target files based of given rule
22
+ * @param fileRules List of file targets based on token rule
23
+ * @param options
24
+ */
25
+ export const getTargetFiles = (fileRules, options) => {
26
+ const flatterRules = deflatten(fileRules);
27
+ const fileMap = getPathMap(flatterRules);
28
+ const fileMapEntries = [...fileMap.entries()];
29
+ return [
30
+ ...fileMapEntries
31
+ .map(([filePath, nodes]) => {
32
+ return {
33
+ destination: options?.rootPath ? resolve(options.rootPath, filePath) : filePath,
34
+ format: options?.format,
35
+ filter: (token) => nodes.some((path) => path.every((item, idx) => token.path[idx] === item))
36
+ };
37
+ }),
38
+ ...(options?.defaultFile
39
+ ? [{
40
+ destination: options.rootPath ? resolve(options.rootPath, options.defaultFile) : options.defaultFile,
41
+ format: options?.format,
42
+ filter: (token) => !fileMapEntries
43
+ .filter(([filePath]) => normalize(filePath) !== normalize(options.defaultFile))
44
+ .some(([, nodes]) => nodes.some((path) => path.every((item, idx) => token.path[idx] === item)))
45
+ }]
46
+ : [])
47
+ ];
48
+ };
49
+ //# sourceMappingURL=target-file.filter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"target-file.filter.mjs","sourceRoot":"","sources":["../../../src/filters/target-file.filter.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,OAAO,GACR,MAAM,WAAW,CAAC;AAKnB,OAAO,EACL,SAAS,GACV,MAAM,yCAAyC,CAAC;AA8BjD,MAAM,cAAc,GAAG,CAAC,MAAoB,EAA8B,EAAE,CAAC,OAAQ,MAAM,CAAC,WAAmB,EAAE,aAAa,KAAK,QAAQ,CAAC;AAE5I,MAAM,UAAU,GAAG,CAAC,IAAkB,EAAE,OAAiB,EAAE,EAAE,MAA+B,IAAI,GAAG,EAAE,EAA2B,EAAE;IAChI,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,a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formatter
4
+ * @param options Options
5
+ */
6
+ export declare const getDefaultCssFormatter: FormatterFactory;
7
+ //# sourceMappingURL=default.formatter.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default.formatter.d.mts","sourceRoot":"","sources":["../../../../src/formats/css-formatters/default.formatter.mts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAGV,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AAKnC;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,gBAkBpC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { createPropertyFormatter, } from 'style-dictionary/utils';
2
+ import { createGradientFormatter, } from './gradients.formatter.mjs';
3
+ import { createPrivateFormatter, } from './private.formatter.mjs';
4
+ /**
5
+ * Get default CSS Formatter
6
+ * @param options Options
7
+ */
8
+ export const getDefaultCssFormatter = (options) => {
9
+ const formatters = [];
10
+ const propertyFormatter = (token) => formatters.reduce((acc, formatter) => formatter(token, acc), undefined);
11
+ const formatterOptions = {
12
+ ...options,
13
+ formatter: propertyFormatter
14
+ };
15
+ // formatter list to chain
16
+ formatters.push(createPropertyFormatter(formatterOptions), createGradientFormatter(formatterOptions), createPrivateFormatter(formatterOptions));
17
+ return propertyFormatter;
18
+ };
19
+ //# sourceMappingURL=default.formatter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default.formatter.mjs","sourceRoot":"","sources":["../../../../src/formats/css-formatters/default.formatter.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EACL,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAqB,CAAC,OAAO,EAAE,EAAE;IAClE,MAAM,UAAU,GAAqB,EAAE,CAAC;IACxC,MAAM,iBAAiB,GAAc,CAAC,KAAK,EAAE,EAAE,CAC7C,UAAU,CAAC,MAAM,CAAC,CAAC,GAAuB,EAAE,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,SAAS,CAAE,CAAC;IAE/F,MAAM,gBAAgB,GAAqB;QACzC,GAAG,OAAO;QACV,SAAS,EAAE,iBAAiB;KAC7B,CAAC;IAEF,0BAA0B;IAC1B,UAAU,CAAC,IAAI,CACb,uBAAuB,CAAC,gBAAgB,CAAC,EACzC,uBAAuB,CAAC,gBAAgB,CAAC,EACzC,sBAAsB,CAAC,gBAAgB,CAAC,CACzC,CAAC;IAEF,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { FormatterFactory } from './interface.formatter.mjs';
2
+ /**
3
+ * Retrieve a formatter for a Token with Gradient type
4
+ * @param options Option of gradient formatter generator
5
+ */
6
+ export declare const createGradientFormatter: FormatterFactory;
7
+ //# sourceMappingURL=gradients.formatter.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gradients.formatter.d.mts","sourceRoot":"","sources":["../../../../src/formats/css-formatters/gradients.formatter.mts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAqBnC;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,gBA4BrC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { getReferences, } from 'style-dictionary/utils';
2
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string -- get the value of serialized object
3
+ const objectString = new Object().toString();
4
+ /**
5
+ * Retrieve a formatter for a Token with Gradient type
6
+ * @param options Option of gradient formatter generator
7
+ */
8
+ export const createGradientFormatter = (options) => {
9
+ const tokens = options.dictionary.tokens;
10
+ const prefix = options.formatting?.prefix ?? '--';
11
+ return (token, str) => {
12
+ const type = options.usesDtcg ? token.$type : token.type;
13
+ if (!str || !str.includes(objectString) || type !== 'gradient') {
14
+ return str || '';
15
+ }
16
+ const value = options.usesDtcg ? token.original.$value : token.original.value;
17
+ const angle = typeof value.angle === 'number' ? value.angle + 'deg' : value.angle;
18
+ let gradientValue = `${value.type || 'linear'}-gradient(${angle || '0deg'}, ${value.stops
19
+ ?.map(({ color, position }) => `${color} ${typeof position === 'number' ? position * 100 + '%' : position}`)
20
+ .join(', ')})`;
21
+ if (options.outputReferences && options.formatter) {
22
+ const refs = getReferences(value, options.dictionary.unfilteredTokens || tokens, options);
23
+ if (refs.length > 0) {
24
+ gradientValue = refs.reduce((acc, ref) => {
25
+ return acc.replaceAll(`{${ref.path.join('.')}}`, `var(${prefix}${ref.name})`);
26
+ }, gradientValue);
27
+ }
28
+ }
29
+ return str.replace(objectString, gradientValue);
30
+ };
31
+ };
32
+ //# sourceMappingURL=gradients.formatter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gradients.formatter.mjs","sourceRoot":"","sources":["../../../../src/formats/css-formatters/gradients.formatter.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GACd,MAAM,wBAAwB,CAAC;AAqBhC,sGAAsG;AACtG,MAAM,YAAY,GAAG,IAAI,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAqB,CAAC,OAAO,EAAE,EAAE;IACnE,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;IACzC,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,MAAM,IAAI,IAAI,CAAC;IAElD,OAAO,CAAC,KAAK,EAAE,GAAG,EAAU,EAAE;QAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;QAEzD,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;YAC/D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AC;QACH,CAAC;QAED,OAAO,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;IAClD,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { TransformedToken } from 'style-dictionary/types';
2
+ import { type createPropertyFormatter } from 'style-dictionary/utils';
3
+ /** Type of a formatter function */
4
+ export type Formatter = ReturnType<typeof createPropertyFormatter>;
5
+ /** Type of a formatter function part of a formatter chain */
6
+ export type ChainFormatter = (token: TransformedToken, str?: string) => string;
7
+ /** Options supported by a formatter factory */
8
+ export type FormatterOptions = Parameters<typeof createPropertyFormatter>['0'] & {
9
+ formatter?: Formatter;
10
+ };
11
+ /** Formatter factory type */
12
+ export type FormatterFactory = (options: FormatterOptions) => ChainFormatter;
13
+ //# sourceMappingURL=interface.formatter.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.formatter.d.mts","sourceRoot":"","sources":["../../../../src/formats/css-formatters/interface.formatter.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,uBAAuB,EAC7B,MAAM,wBAAwB,CAAC;AAEhC,mCAAmC;AACnC,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEnE,6DAA6D;AAC7D,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAE/E,+CAA+C;AAC/C,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC,GAAG,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAE3G,6BAA6B;AAC7B,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,gBAAgB,KAAK,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interface.formatter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.formatter.mjs","sourceRoot":"","sources":["../../../../src/formats/css-formatters/interface.formatter.mts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import type { FormatterFactory } from './interface.formatter.mjs';
2
+ /**
3
+ * Retrieve a formatter for a private Token
4
+ * @param options Option of private formatter generator
5
+ */
6
+ export declare const createPrivateFormatter: FormatterFactory;
7
+ //# sourceMappingURL=private.formatter.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private.formatter.d.mts","sourceRoot":"","sources":["../../../../src/formats/css-formatters/private.formatter.mts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AAEnC;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,gBA8BpC,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { getReferences, } from 'style-dictionary/utils';
2
+ /**
3
+ * Retrieve a formatter for a private Token
4
+ * @param options Option of private formatter generator
5
+ */
6
+ export const createPrivateFormatter = (options) => {
7
+ const tokens = options.dictionary.tokens;
8
+ const prefix = options.formatting?.prefix ?? '--';
9
+ const separator = options.formatting?.separator ?? ':';
10
+ const suffix = options.formatting?.suffix ?? ';';
11
+ const replacePrivateTokenReferences = (token, str) => {
12
+ if (!str) {
13
+ return '';
14
+ }
15
+ let strValue = str;
16
+ const originalValue = options.usesDtcg ? token.original.$value : token.original.value;
17
+ if (options.outputReferences && options.formatter) {
18
+ const refs = getReferences(originalValue, options.dictionary.unfilteredTokens || tokens, options);
19
+ const privateRefs = refs.filter((ref) => ref.attributes?.o3rPrivate);
20
+ if (privateRefs.length > 0) {
21
+ privateRefs.forEach((ref) => {
22
+ const refValue = options.formatter(ref);
23
+ const suffixIdx = refValue.indexOf(suffix);
24
+ strValue = strValue.replaceAll(`${prefix}${ref.name}`, `${prefix}${ref.name}, ${refValue.substring(refValue.indexOf(separator) + 1, suffixIdx === -1 ? undefined : suffixIdx).trim()}`);
25
+ strValue = replacePrivateTokenReferences(ref, strValue);
26
+ });
27
+ }
28
+ }
29
+ return strValue;
30
+ };
31
+ return replacePrivateTokenReferences;
32
+ };
33
+ //# sourceMappingURL=private.formatter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private.formatter.mjs","sourceRoot":"","sources":["../../../../src/formats/css-formatters/private.formatter.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GACd,MAAM,wBAAwB,CAAC;AAOhC;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAqB,CAAC,OAAyB,EAAE,EAAE;IACpF,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;IACzC,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,MAAM,IAAI,IAAI,CAAC;IAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,EAAE,SAAS,IAAI,GAAG,CAAC;IACvD,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,MAAM,IAAI,GAAG,CAAC;IAEjD,MAAM,6BAA6B,GAAmB,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACnE,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAI,QAAQ,GAAG,GAAG,CAAC;QACnB,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;QAEtF,IAAI,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;YAClD,MAAM,IAAI,GAAG,aAAa,CAAC,aAAa,EAAE,OAAO,CAAC,UAAU,CAAC,gBAAgB,IAAI,MAAM,EAAE,OAAO,CAAC,CAAC;YAClG,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YACrE,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3B,WAAW,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;oBAC1B,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAU,CAAC,GAAG,CAAC,CAAC;oBACzC,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBAC3C,QAAQ,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,MAAM,GAAG,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;oBACxL,QAAQ,GAAG,6BAA6B,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;gBAC1D,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO,6BAA6B,CAAC;AACvC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Format } from 'style-dictionary/types';
2
+ export declare const cssFormat: Format;
3
+ //# sourceMappingURL=css.format.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css.format.d.mts","sourceRoot":"","sources":["../../../src/formats/css.format.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACP,MAAM,wBAAwB,CAAC;AAkBhC,eAAO,MAAM,SAAS,EAAE,MA0DvB,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { fileHeader, sortByReference, } from 'style-dictionary/utils';
2
+ import { OTTER_NAME_PREFIX, } from '../constants.mjs';
3
+ import { sortByPath, } from '../helpers/sort-by-path.sort.helpers.mjs';
4
+ import { getDefaultCssFormatter, } from './css-formatters/default.formatter.mjs';
5
+ export const cssFormat = {
6
+ name: `${OTTER_NAME_PREFIX}/css/variable`,
7
+ format: async ({ dictionary, file, options }) => {
8
+ const selector = options.selector || ':root';
9
+ const { outputReferences: outRef, usesDtcg, formatting } = options;
10
+ const outputReferences = outRef ?? true;
11
+ const header = await fileHeader({ file, formatting, options });
12
+ const { lineSeparator } = { lineSeparator: '\n', ...formatting };
13
+ const format = 'css';
14
+ const suffix = ';';
15
+ const prefix = '--';
16
+ const separator = ':';
17
+ const baseFormatterOptions = {
18
+ outputReferences,
19
+ outputReferenceFallbacks: false,
20
+ dictionary,
21
+ format,
22
+ formatting: {
23
+ ...formatting,
24
+ suffix,
25
+ prefix,
26
+ separator
27
+ },
28
+ themeable: false,
29
+ usesDtcg
30
+ };
31
+ const formattedVariables = () => {
32
+ const { allTokens, tokens, unfilteredTokens } = dictionary;
33
+ const propertyFormatter = getDefaultCssFormatter(baseFormatterOptions);
34
+ return allTokens
35
+ .sort(sortByPath)
36
+ .sort(outputReferences ? sortByReference(tokens, { unfilteredTokens, usesDtcg }) : () => 0)
37
+ .filter(({ attributes }) => !attributes?.private)
38
+ .map((token) => ({
39
+ token,
40
+ strValue: propertyFormatter(token)
41
+ }))
42
+ .filter(({ strValue }) => !!strValue)
43
+ .map(({ token, strValue }) => {
44
+ if (token.attributes?.o3rImportant) {
45
+ strValue = strValue.replace(new RegExp(suffix), ' !important' + suffix);
46
+ }
47
+ if (token.attributes?.o3rScope) {
48
+ strValue = strValue.replace(/^(\s*)(.+)$/, `$1${token.attributes.o3rScope} { $2 }`);
49
+ }
50
+ return strValue;
51
+ })
52
+ .join(lineSeparator);
53
+ };
54
+ return header
55
+ + `${selector} {${lineSeparator}`
56
+ + formattedVariables()
57
+ + `${lineSeparator}}${lineSeparator}`;
58
+ }
59
+ };
60
+ //# sourceMappingURL=css.format.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css.format.mjs","sourceRoot":"","sources":["../../../src/formats/css.format.mts"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EACV,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,UAAU,GACX,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,sBAAsB,GACvB,MAAM,wCAAwC,CAAC;AAKhD,MAAM,CAAC,MAAM,SAAS,GAAW;IAC/B,IAAI,EAAE,GAAG,iBAAiB,eAAe;IACzC,MAAM,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QAC9C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC;QAC7C,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QACnE,MAAM,gBAAgB,GAAG,MAAM,IAAI,IAAI,CAAC;QACxC,MAAM,MAAM,GAAW,MAAM,UAAU,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;QACvE,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,UAAU,EAAE,CAAC;QACjE,MAAM,MAAM,GAAG,KAAK,CAAC;QACrB,MAAM,MAAM,GAAG,GAAG,CAAC;QACnB,MAAM,MAAM,GAAG,IAAI,CAAC;QACpB,MAAM,SAAS,GAAG,GAAG,CAAC;QAEtB,MAAM,oBAAoB,GAAG;YAC3B,gBAAgB;YAChB,wBAAwB,EAAE,KAAK;YAC/B,UAAU;YACV,MAAM;YACN,UAAU,EAAE;gBACV,GAAG,UAAU;gBACb,MAAM;gBACN,MAAM;gBACN,SAAS;aACV;YACD,SAAS,EAAE,KAAK;YAChB,QAAQ;S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,CAAC;QAEF,OAAO,MAAM;cACT,GAAG,QAAQ,KAAK,aAAa,EAAE;cAC/B,kBAAkB,EAAE;cACpB,GAAG,aAAa,IAAI,aAAa,EAAE,CAAC;IAC1C,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Format } from 'style-dictionary/types';
2
+ export declare const metadataFormat: Format;
3
+ //# sourceMappingURL=metadata.format.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.format.d.mts","sourceRoot":"","sources":["../../../src/formats/metadata.format.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAEP,MAAM,wBAAwB,CAAC;AAoBhC,eAAO,MAAM,cAAc,EAAE,MA0E5B,CAAC"}