@ng-zen/cli 22.9.0-next.1 → 22.10.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/package.json +3 -1
  2. package/schematics/ui/files/checkbox/checkbox.html +36 -0
  3. package/schematics/ui/files/checkbox/checkbox.scss +54 -31
  4. package/schematics/ui/files/checkbox/checkbox.spec.ts +94 -2
  5. package/schematics/ui/files/checkbox/checkbox.stories.ts +8 -28
  6. package/schematics/ui/files/checkbox/checkbox.ts +8 -21
  7. package/schematics/ui/files/form-control/form-control.spec.ts +18 -1
  8. package/schematics/ui/files/form-control/form-control.stories.ts +19 -4
  9. package/schematics/ui/files/form-control/form-control.ts +30 -4
  10. package/schematics/ui/files/hint/hint.scss +48 -0
  11. package/schematics/ui/files/hint/hint.spec.ts +54 -0
  12. package/schematics/ui/files/hint/hint.stories.ts +57 -0
  13. package/schematics/ui/files/hint/hint.ts +48 -0
  14. package/schematics/ui/files/hint/index.ts +1 -0
  15. package/schematics/ui/files/input/input.html +29 -0
  16. package/schematics/ui/files/input/input.scss +2 -1
  17. package/schematics/ui/files/input/input.spec.ts +107 -2
  18. package/schematics/ui/files/input/input.stories.ts +23 -16
  19. package/schematics/ui/files/input/input.ts +7 -14
  20. package/schematics/ui/files/label/index.ts +1 -0
  21. package/schematics/ui/files/label/label.html +6 -0
  22. package/schematics/ui/files/label/label.scss +52 -0
  23. package/schematics/ui/files/label/label.spec.ts +77 -0
  24. package/schematics/ui/files/label/label.stories.ts +67 -0
  25. package/schematics/ui/files/label/label.ts +57 -0
  26. package/schematics/ui/files/radio/radio.html +34 -0
  27. package/schematics/ui/files/radio/radio.scss +40 -27
  28. package/schematics/ui/files/radio/radio.spec.ts +40 -0
  29. package/schematics/ui/files/radio/radio.stories.ts +12 -25
  30. package/schematics/ui/files/radio/radio.ts +8 -20
  31. package/schematics/ui/files/switch/switch.html +31 -0
  32. package/schematics/ui/files/switch/switch.scss +34 -2
  33. package/schematics/ui/files/switch/switch.spec.ts +102 -2
  34. package/schematics/ui/files/switch/switch.stories.ts +12 -13
  35. package/schematics/ui/files/switch/switch.ts +7 -17
  36. package/schematics/ui/index.js +18 -8
  37. package/schematics/ui/index.js.map +1 -1
  38. package/schematics/ui/index.ts +19 -7
  39. package/schematics/ui/schema.js.map +1 -1
  40. package/schematics/ui/schema.json +2 -0
  41. package/schematics/ui/schema.ts +2 -0
@@ -9,6 +9,12 @@ const DEFAULT_GENERATION_PATH = 'ui'; // src/app/ui
9
9
 
10
10
  const FORM_CONTROL_DEPS: ReadonlySet<UiType> = new Set(['input', 'checkbox', 'switch', 'radio']);
11
11
 
12
+ const FORM_HELPER_COMPONENTS: readonly { name: UiType; file: string }[] = [
13
+ { name: 'form-control', file: 'form-control/form-control.ts' },
14
+ { name: 'hint', file: 'hint/hint.ts' },
15
+ { name: 'label', file: 'label/label.ts' },
16
+ ];
17
+
12
18
  function resolveFormControlDependency(
13
19
  tree: Tree,
14
20
  logger: SchematicContext['logger'],
@@ -17,12 +23,16 @@ function resolveFormControlDependency(
17
23
  ): void {
18
24
  if (!ui.some(u => FORM_CONTROL_DEPS.has(u))) return;
19
25
 
20
- const fcPath = normalize(`${workingDirectory}/form-control/form-control.ts`);
21
- if (tree.exists(fcPath)) {
22
- logger.info('ℹ form-control skipped — already exists');
23
- } else {
24
- ui.push('form-control');
25
- logger.info('✔ form-control included (auto-included for form components)');
26
+ for (const { name, file } of FORM_HELPER_COMPONENTS) {
27
+ if (ui.includes(name)) continue;
28
+
29
+ const targetPath = normalize(`${workingDirectory}/${file}`);
30
+ if (tree.exists(targetPath)) {
31
+ logger.info(`ℹ ${name} skipped — already exists`);
32
+ } else {
33
+ ui.push(name);
34
+ logger.info(`✔ ${name} included (auto-included for form components)`);
35
+ }
26
36
  }
27
37
  }
28
38
 
@@ -43,6 +53,8 @@ export function uiGenerator({ ui: selected, project, ...options }: UiOptions): R
43
53
 
44
54
  resolveFormControlDependency(tree, context.logger, ui, workingDirectory);
45
55
 
46
- return chain([...applyFileTemplateUtil(ui, { ...options, path: workingDirectory })]);
56
+ const deduplicatedUi = Array.from(new Set(ui));
57
+
58
+ return chain([...applyFileTemplateUtil(deduplicatedUi, { ...options, path: workingDirectory })]);
47
59
  };
48
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../src/schematics/ui/schema.ts"],"names":[],"mappings":"","sourcesContent":["import { Path } from '@angular-devkit/core';\n\nexport interface GeneratorSchemaBase {\n currentDirectory: Path;\n path?: Path;\n stories: boolean;\n project?: string;\n}\n\nexport type UiType =\n | 'alert'\n | 'avatar'\n | 'badge'\n | 'button'\n | 'card'\n | 'checkbox'\n | 'dialog'\n | 'divider'\n | 'drawer'\n | 'form-control'\n | 'icon'\n | 'input'\n | 'pin'\n | 'popover'\n | 'radio'\n | 'sidenav'\n | 'skeleton'\n | 'switch'\n | 'textarea';\n\nexport interface Schema extends GeneratorSchemaBase {\n ui: UiType[];\n}\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../src/schematics/ui/schema.ts"],"names":[],"mappings":"","sourcesContent":["import { Path } from '@angular-devkit/core';\n\nexport interface GeneratorSchemaBase {\n currentDirectory: Path;\n path?: Path;\n stories: boolean;\n project?: string;\n}\n\nexport type UiType =\n | 'alert'\n | 'avatar'\n | 'badge'\n | 'button'\n | 'card'\n | 'checkbox'\n | 'dialog'\n | 'divider'\n | 'drawer'\n | 'form-control'\n | 'hint'\n | 'icon'\n | 'input'\n | 'label'\n | 'pin'\n | 'popover'\n | 'radio'\n | 'sidenav'\n | 'skeleton'\n | 'switch'\n | 'textarea';\n\nexport interface Schema extends GeneratorSchemaBase {\n ui: UiType[];\n}\n"]}
@@ -46,8 +46,10 @@
46
46
  "dialog",
47
47
  "divider",
48
48
  "drawer",
49
+ "hint",
49
50
  "icon",
50
51
  "input",
52
+ "label",
51
53
  "pin",
52
54
  "popover",
53
55
  "radio",
@@ -18,8 +18,10 @@ export type UiType =
18
18
  | 'divider'
19
19
  | 'drawer'
20
20
  | 'form-control'
21
+ | 'hint'
21
22
  | 'icon'
22
23
  | 'input'
24
+ | 'label'
23
25
  | 'pin'
24
26
  | 'popover'
25
27
  | 'radio'