@camaradesuk/m3e-angular 0.0.0-stage → 0.1.0-alpha.4

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 (134) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -2
  3. package/fesm2022/camaradesuk-m3e-angular.mjs +5194 -0
  4. package/fesm2022/camaradesuk-m3e-angular.mjs.map +1 -0
  5. package/package.json +64 -4
  6. package/schematics/collection.json +10 -0
  7. package/schematics/ng-add/angular-json.js +78 -0
  8. package/schematics/ng-add/constants.js +32 -0
  9. package/schematics/ng-add/index.js +67 -0
  10. package/schematics/ng-add/prompts.js +39 -0
  11. package/schematics/ng-add/schema.json +47 -0
  12. package/schematics/ng-add/stylesheet.js +50 -0
  13. package/schematics/ng-add/types.js +2 -0
  14. package/schematics/package.json +3 -0
  15. package/src/lib/styles/_index.scss +12 -0
  16. package/src/lib/styles/_mat-exp-styles.scss +18 -0
  17. package/src/lib/styles/components/all-buttons/_common-selectors.scss +27 -0
  18. package/src/lib/styles/components/all-buttons/_index.scss +19 -0
  19. package/src/lib/styles/components/all-buttons/button/_config.scss +13 -0
  20. package/src/lib/styles/components/all-buttons/button/_index.scss +119 -0
  21. package/src/lib/styles/components/all-buttons/button/configs/_default.scss +9 -0
  22. package/src/lib/styles/components/all-buttons/button/configs/_index.scss +6 -0
  23. package/src/lib/styles/components/all-buttons/button/configs/_l.scss +63 -0
  24. package/src/lib/styles/components/all-buttons/button/configs/_m.scss +63 -0
  25. package/src/lib/styles/components/all-buttons/button/configs/_s.scss +63 -0
  26. package/src/lib/styles/components/all-buttons/button/configs/_xl.scss +63 -0
  27. package/src/lib/styles/components/all-buttons/button/configs/_xs.scss +63 -0
  28. package/src/lib/styles/components/all-buttons/button/tokens/_common.scss +99 -0
  29. package/src/lib/styles/components/all-buttons/button/tokens/_index.scss +5 -0
  30. package/src/lib/styles/components/all-buttons/button/tokens/_l.scss +81 -0
  31. package/src/lib/styles/components/all-buttons/button/tokens/_m.scss +81 -0
  32. package/src/lib/styles/components/all-buttons/button/tokens/_s.scss +81 -0
  33. package/src/lib/styles/components/all-buttons/button/tokens/_xl.scss +81 -0
  34. package/src/lib/styles/components/all-buttons/button/tokens/_xs.scss +81 -0
  35. package/src/lib/styles/components/all-buttons/button-group/_config.scss +16 -0
  36. package/src/lib/styles/components/all-buttons/button-group/_connected-l-corners.scss +81 -0
  37. package/src/lib/styles/components/all-buttons/button-group/_connected-m-corners.scss +81 -0
  38. package/src/lib/styles/components/all-buttons/button-group/_connected-s-corners.scss +83 -0
  39. package/src/lib/styles/components/all-buttons/button-group/_connected-xl-corners.scss +81 -0
  40. package/src/lib/styles/components/all-buttons/button-group/_connected-xs-corners.scss +82 -0
  41. package/src/lib/styles/components/all-buttons/button-group/_index.scss +117 -0
  42. package/src/lib/styles/components/all-buttons/button-group/configs/_connected.scss +78 -0
  43. package/src/lib/styles/components/all-buttons/button-group/configs/_default.scss +12 -0
  44. package/src/lib/styles/components/all-buttons/button-group/configs/_index.scss +7 -0
  45. package/src/lib/styles/components/all-buttons/button-group/configs/_l.scss +9 -0
  46. package/src/lib/styles/components/all-buttons/button-group/configs/_m.scss +9 -0
  47. package/src/lib/styles/components/all-buttons/button-group/configs/_s.scss +19 -0
  48. package/src/lib/styles/components/all-buttons/button-group/configs/_xl.scss +9 -0
  49. package/src/lib/styles/components/all-buttons/button-group/configs/_xs.scss +19 -0
  50. package/src/lib/styles/components/all-buttons/button-group/tokens/_common.scss +40 -0
  51. package/src/lib/styles/components/all-buttons/button-group/tokens/_connected.scss +23 -0
  52. package/src/lib/styles/components/all-buttons/button-group/tokens/_l.scss +12 -0
  53. package/src/lib/styles/components/all-buttons/button-group/tokens/_m.scss +12 -0
  54. package/src/lib/styles/components/all-buttons/button-group/tokens/_s.scss +12 -0
  55. package/src/lib/styles/components/all-buttons/button-group/tokens/_xl.scss +12 -0
  56. package/src/lib/styles/components/all-buttons/button-group/tokens/_xs.scss +12 -0
  57. package/src/lib/styles/components/all-buttons/fab-menu/_config.scss +7 -0
  58. package/src/lib/styles/components/all-buttons/fab-menu/_index.scss +92 -0
  59. package/src/lib/styles/components/all-buttons/fab-menu/configs/_default.scss +9 -0
  60. package/src/lib/styles/components/all-buttons/fab-menu/configs/_index.scss +4 -0
  61. package/src/lib/styles/components/all-buttons/fab-menu/configs/_primary.scss +10 -0
  62. package/src/lib/styles/components/all-buttons/fab-menu/configs/_secondary.scss +10 -0
  63. package/src/lib/styles/components/all-buttons/fab-menu/configs/_tertiary.scss +10 -0
  64. package/src/lib/styles/components/all-buttons/fab-menu/tokens/_common.scss +12 -0
  65. package/src/lib/styles/components/all-buttons/fab-menu/tokens/_index.scss +4 -0
  66. package/src/lib/styles/components/all-buttons/fab-menu/tokens/_primary.scss +3 -0
  67. package/src/lib/styles/components/all-buttons/fab-menu/tokens/_secondary.scss +3 -0
  68. package/src/lib/styles/components/all-buttons/fab-menu/tokens/_tertiary.scss +3 -0
  69. package/src/lib/styles/components/all-buttons/fab-menu-trigger/_config.scss +7 -0
  70. package/src/lib/styles/components/all-buttons/fab-menu-trigger/_index.scss +67 -0
  71. package/src/lib/styles/components/all-buttons/fab-menu-trigger/configs/_default.scss +6 -0
  72. package/src/lib/styles/components/all-buttons/fab-menu-trigger/configs/_index.scss +4 -0
  73. package/src/lib/styles/components/all-buttons/fab-menu-trigger/configs/_primary.scss +7 -0
  74. package/src/lib/styles/components/all-buttons/fab-menu-trigger/configs/_secondary.scss +7 -0
  75. package/src/lib/styles/components/all-buttons/fab-menu-trigger/configs/_tertiary.scss +7 -0
  76. package/src/lib/styles/components/all-buttons/fab-menu-trigger/tokens/_common.scss +7 -0
  77. package/src/lib/styles/components/all-buttons/fab-menu-trigger/tokens/_index.scss +4 -0
  78. package/src/lib/styles/components/all-buttons/fab-menu-trigger/tokens/_primary.scss +13 -0
  79. package/src/lib/styles/components/all-buttons/fab-menu-trigger/tokens/_secondary.scss +13 -0
  80. package/src/lib/styles/components/all-buttons/fab-menu-trigger/tokens/_tertiary.scss +13 -0
  81. package/src/lib/styles/components/all-buttons/icon-button/_config.scss +13 -0
  82. package/src/lib/styles/components/all-buttons/icon-button/_index.scss +134 -0
  83. package/src/lib/styles/components/all-buttons/icon-button/configs/_default.scss +8 -0
  84. package/src/lib/styles/components/all-buttons/icon-button/configs/_index.scss +6 -0
  85. package/src/lib/styles/components/all-buttons/icon-button/configs/_l.scss +265 -0
  86. package/src/lib/styles/components/all-buttons/icon-button/configs/_m.scss +265 -0
  87. package/src/lib/styles/components/all-buttons/icon-button/configs/_s.scss +265 -0
  88. package/src/lib/styles/components/all-buttons/icon-button/configs/_xl.scss +265 -0
  89. package/src/lib/styles/components/all-buttons/icon-button/configs/_xs.scss +265 -0
  90. package/src/lib/styles/components/all-buttons/icon-button/tokens/_common.scss +28 -0
  91. package/src/lib/styles/components/all-buttons/icon-button/tokens/_index.scss +5 -0
  92. package/src/lib/styles/components/all-buttons/icon-button/tokens/_l.scss +135 -0
  93. package/src/lib/styles/components/all-buttons/icon-button/tokens/_m.scss +133 -0
  94. package/src/lib/styles/components/all-buttons/icon-button/tokens/_s.scss +98 -0
  95. package/src/lib/styles/components/all-buttons/icon-button/tokens/_xl.scss +119 -0
  96. package/src/lib/styles/components/all-buttons/icon-button/tokens/_xs.scss +299 -0
  97. package/src/lib/styles/components/all-buttons/split-button/_config.scss +13 -0
  98. package/src/lib/styles/components/all-buttons/split-button/_connected-l-corners.scss +59 -0
  99. package/src/lib/styles/components/all-buttons/split-button/_connected-m-corners.scss +59 -0
  100. package/src/lib/styles/components/all-buttons/split-button/_connected-s-corners.scss +60 -0
  101. package/src/lib/styles/components/all-buttons/split-button/_connected-xl-corners.scss +59 -0
  102. package/src/lib/styles/components/all-buttons/split-button/_connected-xs-corners.scss +60 -0
  103. package/src/lib/styles/components/all-buttons/split-button/_index.scss +114 -0
  104. package/src/lib/styles/components/all-buttons/split-button/configs/_default.scss +8 -0
  105. package/src/lib/styles/components/all-buttons/split-button/configs/_index.scss +6 -0
  106. package/src/lib/styles/components/all-buttons/split-button/configs/_l.scss +56 -0
  107. package/src/lib/styles/components/all-buttons/split-button/configs/_m.scss +56 -0
  108. package/src/lib/styles/components/all-buttons/split-button/configs/_s.scss +74 -0
  109. package/src/lib/styles/components/all-buttons/split-button/configs/_xl.scss +56 -0
  110. package/src/lib/styles/components/all-buttons/split-button/configs/_xs.scss +74 -0
  111. package/src/lib/styles/components/all-buttons/split-button/tokens/_common.scss +24 -0
  112. package/src/lib/styles/components/all-buttons/split-button/tokens/_l.scss +36 -0
  113. package/src/lib/styles/components/all-buttons/split-button/tokens/_m.scss +36 -0
  114. package/src/lib/styles/components/all-buttons/split-button/tokens/_s.scss +36 -0
  115. package/src/lib/styles/components/all-buttons/split-button/tokens/_xl.scss +36 -0
  116. package/src/lib/styles/components/all-buttons/split-button/tokens/_xs.scss +36 -0
  117. package/src/lib/styles/components/all-buttons/utils/_functions.scss +68 -0
  118. package/src/lib/styles/components/dialog/_index.scss +56 -0
  119. package/src/lib/styles/components/lists/_index.scss +278 -0
  120. package/src/lib/styles/components/toolbars/_index.scss +211 -0
  121. package/src/lib/styles/prebuilt.scss +5 -0
  122. package/src/lib/styles/utils/_constants.scss +52 -0
  123. package/src/lib/styles/utils/_generated-attributes.scss +58 -0
  124. package/src/lib/styles/utils/functions/_filter-config.scss +64 -0
  125. package/src/lib/styles/utils/functions/_get-state-pseudo.scss +6 -0
  126. package/src/lib/styles/utils/functions/_index.scss +4 -0
  127. package/src/lib/styles/utils/functions/_rem.scss +5 -0
  128. package/src/lib/styles/utils/functions/_validate-config.scss +179 -0
  129. package/src/lib/styles/utils/mixins/_apply-tokens-properties.scss +25 -0
  130. package/src/lib/styles/utils/mixins/_index.scss +2 -0
  131. package/src/lib/styles/utils/mixins/_keyframes.scss +5 -0
  132. package/src/styles/styles.css +3796 -0
  133. package/src/styles/styles.css.map +1 -0
  134. package/types/camaradesuk-m3e-angular.d.ts +1644 -0
package/package.json CHANGED
@@ -1,6 +1,66 @@
1
1
  {
2
2
  "name": "@camaradesuk/m3e-angular",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-alpha.4",
4
+ "description": "Angular Material Expressive is a library that provides a set of components and styles for Angular Material based on the latest Material Design 3 Expressive Design System.",
5
+ "keywords": [
6
+ "angular",
7
+ "material",
8
+ "expressive",
9
+ "design system",
10
+ "components",
11
+ "styles"
12
+ ],
13
+ "author": {
14
+ "name": "Dharmen Shah",
15
+ "url": "https://github.com/shhdharmen"
16
+ },
17
+ "publishConfig": {
18
+ "registry": "https://registry.npmjs.org",
19
+ "access": "public",
20
+ "provenance": false
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/camaradesuk/m3e-angular/issues"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/camaradesuk/m3e-angular.git",
28
+ "directory": "projects/ngm-dev/mat-exp"
29
+ },
30
+ "homepage": "https://github.com/camaradesuk/m3e-angular",
31
+ "peerDependencies": {
32
+ "@angular/cdk": "^22.0.0",
33
+ "@angular/common": "^22.0.0",
34
+ "@angular/core": "^22.0.0",
35
+ "@angular/forms": "^22.0.0",
36
+ "@angular/material": "^22.0.0",
37
+ "gsap": "^3.13.0",
38
+ "rxjs": "^7.8.0"
39
+ },
40
+ "dependencies": {
41
+ "tslib": "^2.3.0"
42
+ },
43
+ "license": "MIT",
44
+ "sideEffects": false,
45
+ "schematics": "./schematics/collection.json",
46
+ "ng-add": {
47
+ "save": "dependencies"
48
+ },
49
+ "exports": {
50
+ ".": {
51
+ "sass": "./src/lib/styles/_index.scss",
52
+ "types": "./types/camaradesuk-m3e-angular.d.ts",
53
+ "default": "./fesm2022/camaradesuk-m3e-angular.mjs"
54
+ },
55
+ "./styles.css": {
56
+ "style": "./src/styles/styles.css"
57
+ },
58
+ "./schematics/*": "./schematics/*",
59
+ "./package.json": {
60
+ "default": "./package.json"
61
+ }
62
+ },
63
+ "module": "fesm2022/camaradesuk-m3e-angular.mjs",
64
+ "typings": "types/camaradesuk-m3e-angular.d.ts",
65
+ "type": "module"
66
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "../../../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
+ "schematics": {
4
+ "ng-add": {
5
+ "description": "Sets up Mat Expressive in an Angular workspace by wiring the global stylesheet.",
6
+ "factory": "./ng-add/index",
7
+ "schema": "./ng-add/schema.json"
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findGlobalStylesheet = findGlobalStylesheet;
4
+ exports.addCssStylesheetEntry = addCssStylesheetEntry;
5
+ const constants_1 = require("./constants");
6
+ function resolveProject(tree, projectName) {
7
+ const raw = tree.read('/angular.json');
8
+ if (!raw) {
9
+ return null;
10
+ }
11
+ const workspace = JSON.parse(raw.toString('utf-8'));
12
+ const projects = workspace.projects ?? {};
13
+ const name = projectName ?? workspace.defaultProject ?? Object.keys(projects)[0];
14
+ const project = name ? projects[name] : undefined;
15
+ return project ? { name, project } : null;
16
+ }
17
+ /**
18
+ * Resolves the project's global stylesheet path and syntax from `angular.json`'s `styles` array,
19
+ * e.g. `projects.<name>.architect.build.options.styles`.
20
+ */
21
+ function findGlobalStylesheet(tree, projectName) {
22
+ const resolved = resolveProject(tree, projectName);
23
+ if (!resolved) {
24
+ return null;
25
+ }
26
+ const targets = resolved.project.architect ?? resolved.project.targets ?? {};
27
+ const buildTarget = targets['build'];
28
+ const styles = buildTarget?.options?.styles ?? [];
29
+ for (const style of styles) {
30
+ const stylePath = typeof style === 'string' ? style : style.input;
31
+ const match = stylePath?.match(/\.(scss|sass|css)$/);
32
+ if (stylePath && match) {
33
+ return {
34
+ path: stylePath.startsWith('/') ? stylePath : `/${stylePath}`,
35
+ type: match[1],
36
+ };
37
+ }
38
+ }
39
+ return null;
40
+ }
41
+ /**
42
+ * Adds `@camaradesuk/m3e-angular/styles.css` as the first entry of the project's build target
43
+ * `styles` array in `angular.json` (library base styles before app-level overrides in cascade
44
+ * order, matching how Angular Material's own schematics position their prebuilt theme CSS).
45
+ * Idempotent — no-ops if already present.
46
+ */
47
+ function addCssStylesheetEntry(tree, projectName, context) {
48
+ const raw = tree.read('/angular.json');
49
+ if (!raw) {
50
+ context.logger.warn('mat-exp: could not read "angular.json".');
51
+ return;
52
+ }
53
+ const workspace = JSON.parse(raw.toString('utf-8'));
54
+ const projects = workspace.projects ?? {};
55
+ const name = projectName ?? workspace.defaultProject ?? Object.keys(projects)[0];
56
+ const project = name ? projects[name] : undefined;
57
+ if (!project) {
58
+ context.logger.warn('mat-exp: could not resolve a project in "angular.json".');
59
+ return;
60
+ }
61
+ const targets = project.architect ?? project.targets;
62
+ const buildTarget = targets?.['build'];
63
+ if (!buildTarget) {
64
+ context.logger.warn('mat-exp: could not find a "build" target in "angular.json".');
65
+ return;
66
+ }
67
+ buildTarget.options = buildTarget.options ?? {};
68
+ buildTarget.options.styles = buildTarget.options.styles ?? [];
69
+ const styles = buildTarget.options.styles;
70
+ const alreadyPresent = styles.some((style) => (typeof style === 'string' ? style : style.input) === constants_1.CSS_STYLES_ENTRY);
71
+ if (alreadyPresent) {
72
+ context.logger.info(`mat-exp: "angular.json" already includes "${constants_1.CSS_STYLES_ENTRY}". Skipping.`);
73
+ return;
74
+ }
75
+ styles.unshift(constants_1.CSS_STYLES_ENTRY);
76
+ tree.overwrite('/angular.json', `${JSON.stringify(workspace, null, 2)}\n`);
77
+ context.logger.info(`mat-exp: added "${constants_1.CSS_STYLES_ENTRY}" to the "styles" array in "angular.json".`);
78
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LEADING_USE_FORWARD_BLOCK = exports.COMPONENT_STYLE_MIXINS = exports.GETTING_STARTED_URL = exports.CSS_STYLES_ENTRY = exports.USE_STATEMENT = void 0;
4
+ /** The `@use` line that must precede any other Sass rule in the global stylesheet. */
5
+ exports.USE_STATEMENT = `@use '@camaradesuk/m3e-angular' as mat-exp;`;
6
+ /** The prebuilt CSS entry point added to `angular.json`'s `styles` array for CSS projects. */
7
+ exports.CSS_STYLES_ENTRY = '@camaradesuk/m3e-angular/styles.css';
8
+ exports.GETTING_STARTED_URL = 'https://github.com/camaradesuk/m3e-angular/blob/main/docs/package-release.md';
9
+ /**
10
+ * Maps the `components` option / picker keys to their Sass style mixin, in the order they're
11
+ * offered in the component picker prompt (`schema.json`'s `components.x-prompt.items` — keep the
12
+ * labels there in sync with these keys). Verified against
13
+ * `projects/ngm-dev/mat-exp/src/lib/styles/components/**\/_index.scss`.
14
+ */
15
+ exports.COMPONENT_STYLE_MIXINS = {
16
+ toolbar: 'mat-exp-toolbar-styles',
17
+ list: 'mat-exp-list-styles',
18
+ button: 'mat-exp-button-styles',
19
+ 'icon-button': 'mat-exp-icon-button-styles',
20
+ 'button-group': 'mat-exp-button-group-styles',
21
+ 'split-button': 'mat-exp-split-button-styles',
22
+ 'fab-menu': 'mat-exp-fab-menu-styles',
23
+ 'fab-menu-trigger': 'mat-exp-fab-menu-trigger-styles',
24
+ };
25
+ /**
26
+ * Matches the leading run of `@use`/`@forward` statements (plus any interleaved blank lines or
27
+ * comments) at the very start of a Sass file. Sass requires all `@use`/`@forward` rules to
28
+ * precede every other rule in the stylesheet, so this is used to find the exact position where
29
+ * it's safe to insert another `@use` statement (and the first rule that depends on it) without
30
+ * pushing any pre-existing `@use` rule below a non-`@use` rule.
31
+ */
32
+ exports.LEADING_USE_FORWARD_BLOCK = /^(?:[ \t]*\r?\n|[ \t]*\/\/[^\n]*\r?\n|[ \t]*\/\*[\s\S]*?\*\/[ \t]*\r?\n|[ \t]*@(?:use|forward)\b[^;]*;[ \t]*\r?\n?)+/;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = ngAdd;
4
+ const angular_json_1 = require("./angular-json");
5
+ const constants_1 = require("./constants");
6
+ const prompts_1 = require("./prompts");
7
+ const stylesheet_1 = require("./stylesheet");
8
+ /**
9
+ * `ng add @camaradesuk/m3e-angular` schematic.
10
+ *
11
+ * 1. Verifies `@angular/material` is installed (Mat Expressive builds on top of it).
12
+ * 2. Locates the project's global stylesheet via `angular.json`.
13
+ * - CSS projects: adds `@camaradesuk/m3e-angular/styles.css` as the first entry of the build
14
+ * target's `styles` array (idempotent).
15
+ * - SCSS/Sass projects: asks (or reads `components`) which components to
16
+ * include, then inserts the `@use` + `@include` block into the global stylesheet, positioned
17
+ * after any existing `@use`/`@forward` statements but before any other rule.
18
+ * 3. Prints a pointer to the getting-started docs.
19
+ */
20
+ function ngAdd(options) {
21
+ return async (tree, context) => {
22
+ verifyAngularMaterialInstalled(tree);
23
+ const stylesheet = (0, angular_json_1.findGlobalStylesheet)(tree, options.project);
24
+ if (!stylesheet) {
25
+ context.logger.warn((0, stylesheet_1.buildManualInstructions)());
26
+ printGettingStartedLink(context);
27
+ return tree;
28
+ }
29
+ if (stylesheet.type === 'css') {
30
+ if (options.components !== undefined) {
31
+ context.logger.info('mat-exp: the "components" option is ignored for CSS projects — the prebuilt ' +
32
+ '"@camaradesuk/m3e-angular/styles.css" stylesheet always includes every component.');
33
+ }
34
+ (0, angular_json_1.addCssStylesheetEntry)(tree, options.project, context);
35
+ }
36
+ else {
37
+ const components = (0, prompts_1.resolveComponents)(options, context);
38
+ (0, stylesheet_1.insertStylesBlock)(tree, stylesheet.path, context, components);
39
+ }
40
+ printGettingStartedLink(context);
41
+ return tree;
42
+ };
43
+ }
44
+ function printGettingStartedLink(context) {
45
+ context.logger.info('');
46
+ context.logger.info(`mat-exp: for the full setup guide, see ${constants_1.GETTING_STARTED_URL}`);
47
+ }
48
+ /**
49
+ * Mat Expressive is built on top of Angular Material and its styles assume Angular Material's
50
+ * theme (`mat.theme()`) is already configured. Abort with an actionable message rather than
51
+ * silently wiring up a broken install.
52
+ */
53
+ function verifyAngularMaterialInstalled(tree) {
54
+ const raw = tree.read('/package.json');
55
+ if (!raw) {
56
+ throw new Error('mat-exp: could not find a "package.json" at the workspace root; are you running ' +
57
+ 'this from an Angular workspace?');
58
+ }
59
+ const packageJson = JSON.parse(raw.toString('utf-8'));
60
+ const hasMaterial = !!packageJson.dependencies?.['@angular/material'] ||
61
+ !!packageJson.devDependencies?.['@angular/material'];
62
+ if (!hasMaterial) {
63
+ throw new Error('mat-exp: "@angular/material" was not found in this workspace. Mat Expressive is ' +
64
+ 'built on top of Angular Material and requires it to be installed and configured first. ' +
65
+ 'Run "ng add @angular/material", then re-run "ng add @camaradesuk/m3e-angular".');
66
+ }
67
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveComponents = resolveComponents;
4
+ const constants_1 = require("./constants");
5
+ /**
6
+ * Resolves which components to include styles for (SCSS projects only). Same
7
+ * explicit-option-wins, x-prompt-handles-interactive-elsewhere precedence as
8
+ * {@link resolveConfigureStyles} — the CLI's `components` x-prompt (`schema.json`) already
9
+ * resolves to a value before this runs when interactive, so this only needs to parse/validate
10
+ * whatever ends up in `options.components` and fall back to `'all'` when it's still undefined.
11
+ */
12
+ function resolveComponents(options, context) {
13
+ if (options.components === undefined) {
14
+ return 'all';
15
+ }
16
+ return parseComponentsOption(options.components, context);
17
+ }
18
+ /**
19
+ * Parses the `components` option (a string array; each entry may itself be a comma-separated
20
+ * group, since the CLI's array-option parsing collapses `--components=a,b` into a single
21
+ * `['a,b']` entry rather than always splitting per-flag) into a validated component-key list, or
22
+ * `'all'`.
23
+ */
24
+ function parseComponentsOption(value, context) {
25
+ const requested = value
26
+ .flatMap((entry) => entry.split(','))
27
+ .map((entry) => entry.trim())
28
+ .filter(Boolean);
29
+ if (requested.length === 0 || requested.some((entry) => entry.toLowerCase() === 'all')) {
30
+ return 'all';
31
+ }
32
+ const valid = requested.filter((key) => key in constants_1.COMPONENT_STYLE_MIXINS);
33
+ const invalid = requested.filter((key) => !(key in constants_1.COMPONENT_STYLE_MIXINS));
34
+ if (invalid.length > 0) {
35
+ context.logger.warn(`mat-exp: ignoring unknown component key(s) in "components" option: ` +
36
+ `${invalid.join(', ')}. Valid keys: ${Object.keys(constants_1.COMPONENT_STYLE_MIXINS).join(', ')}, or "all".`);
37
+ }
38
+ return valid.length > 0 ? valid : 'all';
39
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "NgmDevMatExpNgAdd",
4
+ "title": "Mat Expressive ng-add schema",
5
+ "type": "object",
6
+ "properties": {
7
+ "project": {
8
+ "type": "string",
9
+ "description": "The name of the project to add Mat Expressive styles to.",
10
+ "$default": {
11
+ "$source": "projectName"
12
+ }
13
+ },
14
+ "components": {
15
+ "type": "array",
16
+ "items": {
17
+ "type": "string"
18
+ },
19
+ "description": "Components to include styles for in a SCSS project, or [\"all\"] (default). Valid keys: toolbar, list, button, icon-button, button-group, split-button, fab-menu, fab-menu-trigger, or \"all\" \u2014 validated by the schematic itself (not this schema, and deliberately not an `items.enum` \u2014 see below) so a single comma-separated entry (e.g. from --components=button,icon-button on the command line) and unknown keys are both handled gracefully with a warning rather than a hard schema-validation failure. When omitted in an interactive terminal for a SCSS project, the Angular CLI asks which components to include (via x-prompt below). Ignored (with a log note) for CSS projects, which always get the full prebuilt stylesheet.",
20
+ "default": [
21
+ "list",
22
+ "button",
23
+ "icon-button",
24
+ "button-group",
25
+ "split-button",
26
+ "fab-menu",
27
+ "fab-menu-trigger",
28
+ "toolbar"
29
+ ],
30
+ "x-prompt": {
31
+ "type": "list",
32
+ "message": "mat-exp: which components would you like to include styles for?",
33
+ "items": [
34
+ { "value": "toolbar", "label": "Toolbar" },
35
+ { "value": "list", "label": "List" },
36
+ { "value": "button", "label": "Button" },
37
+ { "value": "icon-button", "label": "Icon Button" },
38
+ { "value": "button-group", "label": "Button Group" },
39
+ { "value": "split-button", "label": "Split Button" },
40
+ { "value": "fab-menu", "label": "FAB Menu" },
41
+ { "value": "fab-menu-trigger", "label": "FAB Menu Trigger" }
42
+ ]
43
+ }
44
+ }
45
+ },
46
+ "additionalProperties": false
47
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.insertStylesBlock = insertStylesBlock;
4
+ exports.buildIncludeBlock = buildIncludeBlock;
5
+ exports.buildManualInstructions = buildManualInstructions;
6
+ const constants_1 = require("./constants");
7
+ /**
8
+ * Inserts the `@use`/`@include` block into the given stylesheet, right after any leading
9
+ * `@use`/`@forward` statements (or at the very top if there are none). No-ops if the stylesheet
10
+ * already references the package.
11
+ */
12
+ function insertStylesBlock(tree, stylesPath, context, components) {
13
+ const raw = tree.read(stylesPath);
14
+ if (!raw) {
15
+ context.logger.warn(`mat-exp: could not read "${stylesPath}".`);
16
+ return;
17
+ }
18
+ const content = raw.toString('utf-8');
19
+ if (content.includes('@camaradesuk/m3e-angular')) {
20
+ context.logger.info(`mat-exp: "${stylesPath}" already sets up Mat Expressive. Skipping.`);
21
+ return;
22
+ }
23
+ const leadingMatch = content.match(constants_1.LEADING_USE_FORWARD_BLOCK);
24
+ const insertAt = leadingMatch ? leadingMatch[0].length : 0;
25
+ const block = `${constants_1.USE_STATEMENT}\n\n${buildIncludeBlock(components)}\n`;
26
+ const updated = content.slice(0, insertAt) + block + content.slice(insertAt);
27
+ tree.overwrite(stylesPath, updated);
28
+ context.logger.info(`mat-exp: updated "${stylesPath}" with the Mat Expressive styles.`);
29
+ }
30
+ /** Builds the `html { @include ...; }` block for the given component selection. */
31
+ function buildIncludeBlock(components) {
32
+ if (components === 'all') {
33
+ return `html {\n @include mat-exp.mat-exp-all-styles();\n}\n`;
34
+ }
35
+ const includes = components
36
+ .map((key) => ` @include mat-exp.${constants_1.COMPONENT_STYLE_MIXINS[key]}();`)
37
+ .join('\n');
38
+ return `html {\n${includes}\n}\n`;
39
+ }
40
+ /** Manual setup instructions covering both the SCSS and CSS paths, for the no-stylesheet-found case. */
41
+ function buildManualInstructions() {
42
+ const includeBlock = buildIncludeBlock('all');
43
+ return ('mat-exp: could not automatically locate a global stylesheet for this project ' +
44
+ '(checked the "styles" array in angular.json). Set up styles manually using whichever of ' +
45
+ 'the following matches your project:\n\n' +
46
+ `If your project uses Sass, add this to your global styles, making sure the \`@use\` line ` +
47
+ `precedes any other \`@use\` or rule:\n\n${constants_1.USE_STATEMENT}\n\n${includeBlock}\n` +
48
+ 'If your project does not compile Sass, add the prebuilt CSS to the "styles" array in ' +
49
+ `"angular.json" instead:\n\n"styles": ["${constants_1.CSS_STYLES_ENTRY}"]\n`);
50
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,12 @@
1
+ @forward './components/all-buttons';
2
+ @forward './components/all-buttons/button/';
3
+ @forward './components/all-buttons/icon-button/';
4
+ @forward './components/all-buttons/button-group/';
5
+ @forward './components/all-buttons/split-button/';
6
+ @forward './components/all-buttons/fab-menu/';
7
+ @forward './components/all-buttons/fab-menu-trigger/';
8
+ @forward './mat-exp-styles';
9
+ @forward './components/dialog';
10
+
11
+ @forward './components/toolbars';
12
+ @forward './components/lists';
@@ -0,0 +1,18 @@
1
+ @use './components/all-buttons';
2
+ @use './components/dialog';
3
+ @use './components/toolbars';
4
+ @use './components/lists';
5
+
6
+ @mixin mat-exp-all-styles(
7
+ $options: (
8
+ skip-html-element-styles: false,
9
+ // mat-exp-button-class: 'mat-exp-button',
10
+ // mat-exp-icon-button-class: 'mat-exp-icon-button',
11
+ // mat-exp-button-group-class: 'mat-exp-button-group',
12
+ )
13
+ ) {
14
+ @include all-buttons.mat-exp-all-buttons-styles($options);
15
+ @include dialog.mat-exp-dialog-styles($options);
16
+ @include toolbars.mat-exp-toolbar-styles($options);
17
+ @include lists.mat-exp-list-styles($options);
18
+ }
@@ -0,0 +1,27 @@
1
+ $button-icon-selectors: (
2
+ '.mat-mdc-button>.mat-icon',
3
+ '.mat-mdc-unelevated-button>.mat-icon',
4
+ '.mat-mdc-raised-button>.mat-icon',
5
+ '.mat-mdc-outlined-button>.mat-icon',
6
+ '.mat-tonal-button>.mat-icon'
7
+ );
8
+ $button-shape-selectors: (
9
+ '.mdc-button',
10
+ '.mat-mdc-raised-button',
11
+ '.mat-mdc-raised-button .mdc-button__ripple'
12
+ );
13
+ $button-line-height-selectors: ('.mdc-button');
14
+ $icon-button-icon-selectors: ('.mat-mdc-icon-button .mat-icon');
15
+ $icon-button-shape-selectors: ('.mat-mdc-icon-button');
16
+ $icon-button-appearance-selectors: ('.mat-mdc-icon-button');
17
+ $icon-button-width-selectors: ('.mat-mdc-icon-button');
18
+ $icon-button-ripple-selectors: (
19
+ '.mat-mdc-icon-button .mat-mdc-button-ripple',
20
+ '.mat-mdc-icon-button .mat-mdc-button-persistent-ripple',
21
+ '.mat-mdc-icon-button .mat-mdc-button-persistent-ripple::before'
22
+ );
23
+ $icon-button-only-ripple-selectors: (
24
+ '.mat-mdc-button-ripple',
25
+ '.mat-mdc-button-persistent-ripple',
26
+ '.mat-mdc-button-persistent-ripple::before'
27
+ );
@@ -0,0 +1,19 @@
1
+ @use './button';
2
+ @use './icon-button';
3
+ @use './button-group';
4
+ @use './fab-menu';
5
+ @use './fab-menu-trigger';
6
+ @use './split-button';
7
+
8
+ @mixin mat-exp-all-buttons-styles(
9
+ $options: (
10
+ skip-html-element-styles: false,
11
+ )
12
+ ) {
13
+ @include button.mat-exp-button-styles($options);
14
+ @include icon-button.mat-exp-icon-button-styles($options);
15
+ @include button-group.mat-exp-button-group-styles($options);
16
+ @include split-button.mat-exp-split-button-styles($options);
17
+ @include fab-menu.mat-exp-fab-menu-styles($options);
18
+ @include fab-menu-trigger.mat-exp-fab-menu-trigger-styles($options);
19
+ }
@@ -0,0 +1,13 @@
1
+ @use './configs' as configs;
2
+ @use 'sass:list';
3
+
4
+ $button-config: list.join(
5
+ configs.$default-config,
6
+ list.join(
7
+ configs.$xs-config,
8
+ list.join(
9
+ configs.$s-config,
10
+ list.join(configs.$m-config, list.join(configs.$l-config, configs.$xl-config))
11
+ )
12
+ )
13
+ );
@@ -0,0 +1,119 @@
1
+ @use './config';
2
+ @use '../../../utils/functions';
3
+ @use '../../../utils/mixins';
4
+ @use '@angular/material' as mat;
5
+ @use 'sass:map';
6
+
7
+ $_mat-exp-button-class: 'mat-exp-button';
8
+
9
+ @mixin mat-exp-button-styles(
10
+ $options: (
11
+ skip-html-element-styles: false,
12
+ sizes: null,
13
+ // mat-exp-button-class: $_mat-exp-button-class,
14
+ )
15
+ ) {
16
+ $skip-html-element-styles: map.get($options, skip-html-element-styles);
17
+ // $mat-exp-button-class: '.' + map.get($options, mat-exp-button-class);
18
+ $mat-exp-button-class: '.' + $_mat-exp-button-class;
19
+
20
+ // Validate the entire configuration
21
+ $validation-result: functions.validate-config(
22
+ config.$button-config,
23
+ functions.$default-allowed-keys,
24
+ 'button-config'
25
+ );
26
+
27
+ @if $validation-result != true {
28
+ @error $validation-result;
29
+ }
30
+
31
+ // Opt out of unused size combinations at compile time (see issue #133) —
32
+ // pass `sizes: ('s', 'm')` to only emit those size axes. The size-agnostic
33
+ // base entry from configs/_default.scss always stays. `sizes: null`
34
+ // (default) is a no-op — the full combinatorial config is emitted.
35
+ $button-config: functions.filter-config(
36
+ config.$button-config,
37
+ (
38
+ size: map.get($options, sizes),
39
+ )
40
+ );
41
+
42
+ // Process each combination item in the list
43
+ @each $item in $button-config {
44
+ // Extract tokens and properties
45
+ $item-tokens: map.get($item, tokens);
46
+ $item-properties: map.get($item, properties);
47
+
48
+ // Build the selector based on the attributes present
49
+ $selector: $mat-exp-button-class;
50
+
51
+ // Check for size attribute
52
+ @if map.has-key($item, size) {
53
+ $size: map.get($item, size);
54
+ $selector: $selector + "[data-size='#{$size}']";
55
+ }
56
+
57
+ // Check for shape attribute
58
+ @if map.has-key($item, shape) {
59
+ $shape: map.get($item, shape);
60
+ $selector: $selector + "[data-shape='#{$shape}']";
61
+ }
62
+
63
+ // Check for toggle attribute
64
+ @if map.has-key($item, toggle) {
65
+ $toggle: map.get($item, toggle);
66
+ $selector: $selector + "[data-toggle='#{$toggle}']";
67
+ }
68
+
69
+ // Check for state attribute
70
+ @if map.has-key($item, state) {
71
+ $state: map.get($item, state);
72
+ $pseudo-selector: functions.get-state-pseudo($state);
73
+
74
+ // Generate styles with data attribute selector
75
+ #{$selector}[data-state='#{$state}'] {
76
+ @include mixins.apply-tokens-properties(
77
+ $item-tokens,
78
+ $item-properties,
79
+ $skip-html-element-styles
80
+ )
81
+ using ($slot) {
82
+ @if $slot == tokens {
83
+ @include mat.button-overrides($item-tokens);
84
+ }
85
+ }
86
+ }
87
+
88
+ // Also generate styles with CSS pseudo-selector if available
89
+ @if $pseudo-selector {
90
+ #{$selector}#{$pseudo-selector} {
91
+ @include mixins.apply-tokens-properties(
92
+ $item-tokens,
93
+ $item-properties,
94
+ $skip-html-element-styles
95
+ )
96
+ using ($slot) {
97
+ @if $slot == tokens {
98
+ @include mat.button-overrides($item-tokens);
99
+ }
100
+ }
101
+ }
102
+ }
103
+ } @else {
104
+ // No state attribute, generate styles directly
105
+ #{$selector} {
106
+ @include mixins.apply-tokens-properties(
107
+ $item-tokens,
108
+ $item-properties,
109
+ $skip-html-element-styles
110
+ )
111
+ using ($slot) {
112
+ @if $slot == tokens {
113
+ @include mat.button-overrides($item-tokens);
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
@@ -0,0 +1,9 @@
1
+ @use '../tokens' as tokens;
2
+
3
+ // prettier-ignore
4
+ $config: (
5
+ (
6
+ tokens: tokens.$s-tokens,
7
+ properties: tokens.$s-properties,
8
+ ),
9
+ );
@@ -0,0 +1,6 @@
1
+ @forward './default' as default-*;
2
+ @forward './xs' as xs-*;
3
+ @forward './s' as s-*;
4
+ @forward './m' as m-*;
5
+ @forward './l' as l-*;
6
+ @forward './xl' as xl-*;