@o3r/design 10.0.0-prerelease.2 → 10.0.0-prerelease.21
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/collection.json +8 -0
- package/package.json +12 -12
- package/schematics/design-token-to-component/index.d.ts +13 -0
- package/schematics/design-token-to-component/index.d.ts.map +1 -0
- package/schematics/design-token-to-component/index.js +31 -0
- package/schematics/design-token-to-component/schema.d.ts +8 -0
- package/schematics/design-token-to-component/schema.d.ts.map +1 -0
- package/schematics/design-token-to-component/schema.js +3 -0
- package/schematics/design-token-to-component/schema.json +20 -0
- package/schematics/design-token-to-component/templates/__fileName__.template +8 -0
- package/schematics/generate-css/schema.json +3 -3
- package/schematics/ng-add/index.d.ts +2 -1
- package/schematics/ng-add/index.d.ts.map +1 -1
- package/schematics/ng-add/index.js +17 -2
- package/schematics/ng-add/register-generate-css/register-task.d.ts.map +1 -1
- package/schematics/ng-add/register-generate-css/register-task.js +7 -1
- package/schematics/ng-add/schema.d.ts +2 -0
- package/schematics/ng-add/schema.d.ts.map +1 -1
- package/schematics/ng-add/schema.json +4 -0
package/collection.json
CHANGED
|
@@ -19,6 +19,14 @@
|
|
|
19
19
|
"description": "Extract the Design Token specification from SCSS",
|
|
20
20
|
"factory": "./schematics/extract-token/index#extractToken",
|
|
21
21
|
"schema": "./schematics/extract-token/schema.json"
|
|
22
|
+
},
|
|
23
|
+
"design-token-to-component": {
|
|
24
|
+
"description": "Add design token to an Otter component",
|
|
25
|
+
"factory": "./schematics/design-token-to-component/index#ngAddDesignToken",
|
|
26
|
+
"schema": "./schematics/design-token-to-component/schema.json",
|
|
27
|
+
"aliases": [
|
|
28
|
+
"add-design-token"
|
|
29
|
+
]
|
|
22
30
|
}
|
|
23
31
|
}
|
|
24
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/design",
|
|
3
|
-
"version": "10.0.0-prerelease.
|
|
3
|
+
"version": "10.0.0-prerelease.21",
|
|
4
4
|
"description": "A design framework to generate theme on an Otter application based on Design Tokens.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design",
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
"tslib": "^2.5.3"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@o3r/core": "^10.0.0-prerelease.
|
|
50
|
-
"@o3r/schematics": "^10.0.0-prerelease.
|
|
51
|
-
"@o3r/styling": "^10.0.0-prerelease.
|
|
49
|
+
"@o3r/core": "^10.0.0-prerelease.21",
|
|
50
|
+
"@o3r/schematics": "^10.0.0-prerelease.21",
|
|
51
|
+
"@o3r/styling": "^10.0.0-prerelease.21",
|
|
52
52
|
"chokidar": "^3.5.2",
|
|
53
53
|
"globby": "^11.1.0",
|
|
54
54
|
"minimatch": "~9.0.3",
|
|
55
|
-
"sass": "~1.
|
|
55
|
+
"sass": "~1.70.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"@o3r/core": {
|
|
@@ -94,12 +94,12 @@
|
|
|
94
94
|
"@nx/eslint-plugin": "~17.2.0",
|
|
95
95
|
"@nx/jest": "~17.2.0",
|
|
96
96
|
"@nx/js": "~17.2.0",
|
|
97
|
-
"@o3r/build-helpers": "^10.0.0-prerelease.
|
|
98
|
-
"@o3r/core": "^10.0.0-prerelease.
|
|
99
|
-
"@o3r/eslint-plugin": "^10.0.0-prerelease.
|
|
100
|
-
"@o3r/schematics": "^10.0.0-prerelease.
|
|
101
|
-
"@o3r/styling": "^10.0.0-prerelease.
|
|
102
|
-
"@o3r/test-helpers": "^10.0.0-prerelease.
|
|
97
|
+
"@o3r/build-helpers": "^10.0.0-prerelease.21",
|
|
98
|
+
"@o3r/core": "^10.0.0-prerelease.21",
|
|
99
|
+
"@o3r/eslint-plugin": "^10.0.0-prerelease.21",
|
|
100
|
+
"@o3r/schematics": "^10.0.0-prerelease.21",
|
|
101
|
+
"@o3r/styling": "^10.0.0-prerelease.21",
|
|
102
|
+
"@o3r/test-helpers": "^10.0.0-prerelease.21",
|
|
103
103
|
"@schematics/angular": "~17.0.3",
|
|
104
104
|
"@types/jest": "~29.5.2",
|
|
105
105
|
"@types/minimist": "^1.2.2",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"minimatch": "~9.0.3",
|
|
124
124
|
"nx": "~17.2.0",
|
|
125
125
|
"rxjs": "^7.8.1",
|
|
126
|
-
"sass": "~1.
|
|
126
|
+
"sass": "~1.70.0",
|
|
127
127
|
"ts-jest": "~29.1.1",
|
|
128
128
|
"ts-node": "~10.9.1",
|
|
129
129
|
"type-fest": "^4.3.1",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Rule } from '@angular-devkit/schematics';
|
|
2
|
+
import type { NgAddDesignTokenSchematicsSchema } from './schema';
|
|
3
|
+
/**
|
|
4
|
+
* Add Design Token to an existing component
|
|
5
|
+
* @param options
|
|
6
|
+
*/
|
|
7
|
+
export declare function ngAddDesignTokenFn(options: NgAddDesignTokenSchematicsSchema): Rule;
|
|
8
|
+
/**
|
|
9
|
+
* Add Design Token to an existing component
|
|
10
|
+
* @param options
|
|
11
|
+
*/
|
|
12
|
+
export declare const ngAddDesignToken: (opts: NgAddDesignTokenSchematicsSchema) => Rule;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/design-token-to-component/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,IAAI,EAGL,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gCAAgC,GAAG,IAAI,CAelF;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,kDAA4D,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ngAddDesignToken = exports.ngAddDesignTokenFn = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const schematics_2 = require("@o3r/schematics");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
/**
|
|
8
|
+
* Add Design Token to an existing component
|
|
9
|
+
* @param options
|
|
10
|
+
*/
|
|
11
|
+
function ngAddDesignTokenFn(options) {
|
|
12
|
+
const fileName = (0, node_path_1.basename)(options.path.endsWith('.json') ? options.path : `${options.path}.json`);
|
|
13
|
+
const name = fileName.slice(0, fileName.indexOf('.') > -1 ? fileName.indexOf('.') : undefined);
|
|
14
|
+
const createDesignTokenFilesRule = (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./templates'), [
|
|
15
|
+
(0, schematics_1.template)({
|
|
16
|
+
name,
|
|
17
|
+
fileName,
|
|
18
|
+
stylingFile: options.stylePath ? (0, node_path_1.relative)((0, node_path_1.dirname)(options.path), options.stylePath) : undefined
|
|
19
|
+
}),
|
|
20
|
+
(0, schematics_1.renameTemplateFiles)(),
|
|
21
|
+
(0, schematics_1.move)((0, node_path_1.dirname)(options.path))
|
|
22
|
+
]), schematics_1.MergeStrategy.Overwrite);
|
|
23
|
+
return createDesignTokenFilesRule;
|
|
24
|
+
}
|
|
25
|
+
exports.ngAddDesignTokenFn = ngAddDesignTokenFn;
|
|
26
|
+
/**
|
|
27
|
+
* Add Design Token to an existing component
|
|
28
|
+
* @param options
|
|
29
|
+
*/
|
|
30
|
+
exports.ngAddDesignToken = (0, schematics_2.createSchematicWithMetricsIfInstalled)(ngAddDesignTokenFn);
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SchematicOptionObject } from '@o3r/schematics';
|
|
2
|
+
export interface NgAddDesignTokenSchematicsSchema extends SchematicOptionObject {
|
|
3
|
+
/** Path to the component's design token file */
|
|
4
|
+
path: string;
|
|
5
|
+
/** Path to the Style file to update */
|
|
6
|
+
stylePath?: string;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../schematics/design-token-to-component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,WAAW,gCAAiC,SAAQ,qBAAqB;IAC7E,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IAEb,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "NgAddDesignTokenSchematicsSchema",
|
|
4
|
+
"title": "Add Otter Design Token to an existing component",
|
|
5
|
+
"description": "Add Otter Design Token to an existing component",
|
|
6
|
+
"properties": {
|
|
7
|
+
"path": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Path to the component's Design Token specification file"
|
|
10
|
+
},
|
|
11
|
+
"stylePath": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "Path to the Style file to update"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"additionalProperties": true,
|
|
17
|
+
"required": [
|
|
18
|
+
"path"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
-
"$id": "
|
|
4
|
-
"title": "
|
|
5
|
-
"description": "
|
|
3
|
+
"$id": "generateCssSchematicsSchema",
|
|
4
|
+
"title": "Generate CSS from design token",
|
|
5
|
+
"description": "Generate CSS from design token",
|
|
6
6
|
"properties": {
|
|
7
7
|
"designTokenFilePatterns": {
|
|
8
8
|
"description": "Path patterns to the Design Token JSON files",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type Rule } from '@angular-devkit/schematics';
|
|
2
|
+
import type { NgAddSchematicsSchema } from './schema';
|
|
2
3
|
/**
|
|
3
4
|
* Add Otter design to an Angular Project
|
|
4
5
|
* @param options
|
|
5
6
|
*/
|
|
6
|
-
export declare function ngAdd(): Rule;
|
|
7
|
+
export declare function ngAdd(options: NgAddSchematicsSchema): Rule;
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAIpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD;;;GAGG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAoB1D"}
|
|
@@ -4,15 +4,30 @@ exports.ngAdd = void 0;
|
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
5
|
const register_generate_css_1 = require("./register-generate-css");
|
|
6
6
|
const _extract_token_1 = require("../ extract-token");
|
|
7
|
+
const schematics_2 = require("@o3r/schematics");
|
|
7
8
|
/**
|
|
8
9
|
* Add Otter design to an Angular Project
|
|
9
10
|
* @param options
|
|
10
11
|
*/
|
|
11
|
-
function ngAdd() {
|
|
12
|
+
function ngAdd(options) {
|
|
12
13
|
/* ng add rules */
|
|
13
14
|
return (0, schematics_1.chain)([
|
|
14
15
|
(0, register_generate_css_1.registerGenerateCssBuilder)(),
|
|
15
|
-
(0,
|
|
16
|
+
(0, schematics_2.setupSchematicsDefaultParams)({
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
18
|
+
'@o3r/core:component': {
|
|
19
|
+
useOtterDesignToken: true
|
|
20
|
+
},
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
22
|
+
'@o3r/core:component-presenter': {
|
|
23
|
+
useOtterDesignToken: true
|
|
24
|
+
},
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
26
|
+
'*:*': {
|
|
27
|
+
useOtterDesignToken: true
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
30
|
+
options.extractDesignToken ? (0, _extract_token_1.extractToken)({ componentFilePatterns: ['**/*.scss'], includeTags: true }) : schematics_1.noop
|
|
16
31
|
]);
|
|
17
32
|
}
|
|
18
33
|
exports.ngAdd = ngAdd;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-task.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/register-generate-css/register-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqE,KAAK,IAAI,EAAiB,MAAM,4BAA4B,CAAC;AAKzI;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,iBAAkB,MAAM,wBAA8B,
|
|
1
|
+
{"version":3,"file":"register-task.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/register-generate-css/register-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqE,KAAK,IAAI,EAAiB,MAAM,4BAA4B,CAAC;AAKzI;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,iBAAkB,MAAM,wBAA8B,IAyD5F,CAAC"}
|
|
@@ -14,7 +14,7 @@ const registerGenerateCssBuilder = (projectName, taskName = 'generate-css') => {
|
|
|
14
14
|
const workspaceProject = projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[projectName] : undefined;
|
|
15
15
|
const srcBasePath = workspaceProject?.sourceRoot || (workspaceProject?.root ? node_path_1.posix.resolve(workspaceProject.root, 'src') : '');
|
|
16
16
|
const themeFile = node_path_1.posix.resolve(srcBasePath, 'style', 'theme.scss');
|
|
17
|
-
const
|
|
17
|
+
const taskOptions = {
|
|
18
18
|
defaultStyleFile: themeFile,
|
|
19
19
|
renderPrivateVariableTo: 'sass',
|
|
20
20
|
designTokenFilePatterns: [
|
|
@@ -22,6 +22,12 @@ const registerGenerateCssBuilder = (projectName, taskName = 'generate-css') => {
|
|
|
22
22
|
`${node_path_1.posix.resolve(srcBasePath, '**', '*.theme.json')}`
|
|
23
23
|
]
|
|
24
24
|
};
|
|
25
|
+
const taskParameters = {
|
|
26
|
+
options: taskOptions,
|
|
27
|
+
configuration: {
|
|
28
|
+
watch: { watch: true }
|
|
29
|
+
}
|
|
30
|
+
};
|
|
25
31
|
if (!workspaceProject) {
|
|
26
32
|
logger.warn(`No angular.json found, the task ${taskName} will not be created`);
|
|
27
33
|
return tree;
|
|
@@ -2,5 +2,7 @@ import type { SchematicOptionObject } from '@o3r/schematics';
|
|
|
2
2
|
export interface NgAddSchematicsSchema extends SchematicOptionObject {
|
|
3
3
|
/** Project name */
|
|
4
4
|
projectName?: string | undefined;
|
|
5
|
+
/** Extract the design token from Sass file in the project */
|
|
6
|
+
extractDesignToken?: boolean;
|
|
5
7
|
}
|
|
6
8
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAClE,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAClE,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,6DAA6D;IAC7D,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B"}
|