@ng-zen/cli 19.0.0-alpha.1 → 19.0.0-alpha.3

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/README.md CHANGED
@@ -24,12 +24,6 @@ You can generate code using the ng-zen CLI.
24
24
  ng generate @ng-zen/cli:component
25
25
  ```
26
26
 
27
- #### Directives
28
-
29
- ```bash
30
- ng generate @ng-zen/cli:directive
31
- ```
32
-
33
27
  ## License
34
28
 
35
29
  This project is licensed under the BSD 2-Clause License. For more details, refer to the LICENSE file in the repository.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-zen/cli",
3
- "version": "19.0.0-alpha.1",
3
+ "version": "19.0.0-alpha.3",
4
4
  "description": "A blank schematics",
5
5
  "license": "BSD-2-Clause",
6
6
  "private": false,
@@ -1 +1 @@
1
- {"version":3,"file":"components-generator.js","sourceRoot":"","sources":["../../../../../projects/cli/src/schematics/components/components-generator.ts"],"names":[],"mappings":"","sourcesContent":["import { GeneratorSchemaBase } from '../../types';\n\nexport interface ComponentGeneratorSchema extends GeneratorSchemaBase {\n components: 'button'[];\n}\n"]}
1
+ {"version":3,"file":"components-generator.js","sourceRoot":"","sources":["../../../../../projects/cli/src/schematics/components/components-generator.ts"],"names":[],"mappings":"","sourcesContent":["import { GeneratorSchemaBase } from '../../types';\n\nexport type ComponentType = 'avatar' | 'button' | 'input';\n\nexport interface ComponentGeneratorSchema extends GeneratorSchemaBase {\n components: ComponentType[];\n}\n"]}
@@ -1,5 +1,7 @@
1
1
  import { GeneratorSchemaBase } from '../../types';
2
2
 
3
+ export type ComponentType = 'avatar' | 'button' | 'input';
4
+
3
5
  export interface ComponentGeneratorSchema extends GeneratorSchemaBase {
4
- components: 'button'[];
6
+ components: ComponentType[];
5
7
  }
@@ -0,0 +1 @@
1
+ export * from './input.component';
@@ -0,0 +1,28 @@
1
+ $border: var(--zen-input-border, 1px solid #cbcbcb);
2
+ $border-radius: var(--zen-input-border-radius, 8px);
3
+ $padding: var(--zen-input-padding, 0.5rem 1rem);
4
+ $outline: var(--zen-outline, 1px solid #999);
5
+ $border-invalid: var(--zen-error, #dc2626);
6
+
7
+ input {
8
+ border: $border;
9
+ border-radius: $border-radius;
10
+ padding: $padding;
11
+
12
+ &:disabled {
13
+ opacity: 0.6;
14
+ }
15
+
16
+ &:focus-visible {
17
+ outline: $outline;
18
+ box-shadow: 0 1px 4px #9999993f inset;
19
+ }
20
+
21
+ &:user-invalid {
22
+ border-color: $border-invalid;
23
+ }
24
+
25
+ &::placeholder {
26
+ color: #999;
27
+ }
28
+ }
@@ -0,0 +1,22 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { ZenInputComponent } from './input.component';
4
+
5
+ describe('InputComponent', () => {
6
+ let component: ZenInputComponent;
7
+ let fixture: ComponentFixture<ZenInputComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [ZenInputComponent],
12
+ }).compileComponents();
13
+
14
+ fixture = TestBed.createComponent(ZenInputComponent);
15
+ component = fixture.componentInstance;
16
+ fixture.detectChanges();
17
+ });
18
+
19
+ it('should create', () => {
20
+ expect(component).toBeTruthy();
21
+ });
22
+ });
@@ -0,0 +1,85 @@
1
+ import { booleanAttribute, ChangeDetectionStrategy, Component, forwardRef, input, model } from '@angular/core';
2
+ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
3
+
4
+ /**
5
+ * ZenInputComponent is a reusable text input component designed to provide
6
+ * a consistent and customizable input style across the application.
7
+ * It supports Angular forms integration and provides two-way data binding.
8
+ *
9
+ * @example
10
+ * <zen-input value="string" />
11
+ *
12
+ * @implements {ControlValueAccessor}
13
+ *
14
+ * @author Konrad Stępień
15
+ * @license {@link https://github.com/Kordrad/ng-zen?tab=BSD-2-Clause-1-ov-file|BSD-2-Clause}
16
+ * @see [GitHub](https://github.com/Kordrad/ng-zen)
17
+ */
18
+ @Component({
19
+ selector: 'zen-input',
20
+ standalone: true,
21
+ template: `
22
+ <input
23
+ [attr.id]="id()"
24
+ [attr.placeholder]="placeholder()"
25
+ [attr.required]="required()"
26
+ [disabled]="disabled()"
27
+ [value]="value()"
28
+ (blur)="onTouched()"
29
+ (input)="onInputChange($event)"
30
+ />
31
+ `,
32
+ styleUrls: ['./input.component.scss'],
33
+ providers: [
34
+ {
35
+ provide: NG_VALUE_ACCESSOR,
36
+ useExisting: forwardRef(() => ZenInputComponent),
37
+ multi: true,
38
+ },
39
+ ],
40
+ changeDetection: ChangeDetectionStrategy.OnPush,
41
+ })
42
+ export class ZenInputComponent implements ControlValueAccessor {
43
+ /** Holds the current input value. */
44
+ readonly value = model('');
45
+ /** Determines if the input is disabled. */
46
+ readonly disabled = model(false);
47
+ /** Determines if the input is required.*/
48
+ readonly required = input(false, { transform: booleanAttribute });
49
+ /** Sets the HTML id attribute for the input element.*/
50
+ readonly id = input<string>();
51
+ /** Provides a hint or example text that will be displayed */
52
+ readonly placeholder = input<string>();
53
+
54
+ /** @ignore */
55
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
56
+ onChange: (value: string) => void = () => {};
57
+ /** @ignore */
58
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
59
+ onTouched: () => void = () => {};
60
+
61
+ /** @ignore */
62
+ writeValue(value: string): void {
63
+ this.value.set(value);
64
+ }
65
+ /** @ignore */
66
+ registerOnChange(fn: (value: string) => void): void {
67
+ this.onChange = fn;
68
+ }
69
+ /** @ignore */
70
+ registerOnTouched(fn: () => void): void {
71
+ this.onTouched = fn;
72
+ }
73
+
74
+ /** @ignore */
75
+ setDisabledState(isDisabled: boolean): void {
76
+ this.disabled.set(isDisabled);
77
+ }
78
+
79
+ /** @ignore */
80
+ onInputChange(event: Event): void {
81
+ const newValue = (event.target as HTMLInputElement).value;
82
+ this.value.set(newValue);
83
+ this.onChange(newValue);
84
+ }
85
+ }
@@ -0,0 +1,46 @@
1
+ import { Meta, StoryObj } from '@storybook/angular';
2
+ import { ZenInputComponent } from './input.component';
3
+
4
+ export default {
5
+ title: 'Components/Input',
6
+ component: ZenInputComponent,
7
+ tags: ['autodocs'],
8
+ argTypes: {
9
+ value: { control: 'text' },
10
+ placeholder: { control: 'text' },
11
+ disabled: { control: 'boolean' },
12
+ required: { control: 'boolean' },
13
+ },
14
+ args: {
15
+ value: '',
16
+ placeholder: '',
17
+ disabled: false,
18
+ required: false,
19
+ },
20
+ } satisfies Meta<ZenInputComponent>;
21
+
22
+ type Story = StoryObj<ZenInputComponent>;
23
+
24
+ export const Default: Story = {
25
+ render: args => ({
26
+ props: { ...args },
27
+ template: `
28
+ <zen-input
29
+ [disabled]="${args.disabled}"
30
+ [value]="'${args.value}'"
31
+ [placeholder]="${args.placeholder}"
32
+ ${args.required ? 'required' : ''}
33
+ />`,
34
+ }),
35
+ };
36
+
37
+ export const WithLabel: Story = {
38
+ render: () => ({
39
+ template: `
40
+ <div style="display: flex; flex-direction: column">
41
+ <label for="label-example"> With label </label>
42
+ <zen-input id="label-example"/>
43
+ </div>
44
+ `,
45
+ }),
46
+ };
@@ -10,7 +10,7 @@
10
10
  "type": "array",
11
11
  "items": {
12
12
  "type": "string",
13
- "enum": ["button"]
13
+ "enum": ["avatar", "button", "input"]
14
14
  },
15
15
  "multiselect": true,
16
16
  "x-prompt": "Which component should be generated?"
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schematics-folder.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schematics-folder.type.js","sourceRoot":"","sources":["../../../../projects/cli/src/types/schematics-folder.type.ts"],"names":[],"mappings":"","sourcesContent":["import { ComponentType } from '../schematics/components/components-generator';\n\nexport type SchematicsFolder = ComponentType;\n"]}
@@ -0,0 +1,3 @@
1
+ import { ComponentType } from '../schematics/components/components-generator';
2
+
3
+ export type SchematicsFolder = ComponentType;
@@ -15,7 +15,7 @@ const getTemplates = (rules) => (0, schematics_1.apply)((0, schematics_1.url)(`.
15
15
  const includeStories = (include) => (0, schematics_1.filter)(filePath => include || !filePath.endsWith('.stories.ts'));
16
16
  function applyFileTemplateUtil(folders, config) {
17
17
  return folders.map(folder => {
18
- const RULES = createTemplateRules(folders, config.path);
18
+ const RULES = createTemplateRules(folder, config.path);
19
19
  const folderSource = (0, schematics_1.apply)((0, schematics_1.url)(`./files/${folder}`), [includeStories(config.stories), ...RULES]);
20
20
  return (0, schematics_1.chain)([folderSource, getTemplates(RULES)].map(schematics_1.mergeWith));
21
21
  });
@@ -1 +1 @@
1
- {"version":3,"file":"apply-file-template.util.js","sourceRoot":"","sources":["../../../../projects/cli/src/utils/apply-file-template.util.ts"],"names":[],"mappings":";;AAmBA,sDAQC;AA3BD,+CAA0D;AAC1D,2DAA8G;AAM9G,MAAM,mBAAmB,GAAG,CAAC,MAAe,EAAE,IAAY,EAAU,EAAE,CAAC;IACrE,IAAA,2BAAc,EAAC;QACb,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,cAAc,EAAE;QACvC,GAAG,cAAO;KACX,CAAC;IACF,IAAA,iBAAI,EAAC,IAAA,gBAAS,EAAC,GAAG,IAAI,IAAI,MAAM,EAAE,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,aAAa,CAAC,EAAE,KAAK,CAAC,CAAC;AACzE,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,IAAA,mBAAM,EAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;AAE9G,SAAgB,qBAAqB,CAAC,OAAgB,EAAE,MAA2B;IACjF,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,KAAK,GAAG,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAExD,MAAM,YAAY,GAAG,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,WAAW,MAAM,EAAE,CAAC,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;QAEjG,OAAO,IAAA,kBAAK,EAAC,CAAC,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,sBAAS,CAAC,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { normalize, strings } from '@angular-devkit/core';\nimport { apply, applyTemplates, chain, filter, mergeWith, move, Rule, url } from '@angular-devkit/schematics';\nimport { ComponentGeneratorSchema } from '../schematics/components/components-generator';\nimport { GeneratorSchemaBase } from '../types';\n\ntype Folders = ComponentGeneratorSchema['components'];\n\nconst createTemplateRules = (folder: Folders, path: string): Rule[] => [\n applyTemplates({\n name: folder,\n localeDate: new Date().toLocaleString(),\n ...strings,\n }),\n move(normalize(`${path}/${folder}`)),\n];\n\nconst getTemplates = (rules: Rule[]) => apply(url(`./templates`), rules);\nconst includeStories = (include: boolean) => filter(filePath => include || !filePath.endsWith('.stories.ts'));\n\nexport function applyFileTemplateUtil(folders: Folders, config: GeneratorSchemaBase): Rule[] {\n return folders.map(folder => {\n const RULES = createTemplateRules(folders, config.path);\n\n const folderSource = apply(url(`./files/${folder}`), [includeStories(config.stories), ...RULES]);\n\n return chain([folderSource, getTemplates(RULES)].map(mergeWith));\n });\n}\n"]}
1
+ {"version":3,"file":"apply-file-template.util.js","sourceRoot":"","sources":["../../../../projects/cli/src/utils/apply-file-template.util.ts"],"names":[],"mappings":";;AAiBA,sDAQC;AAzBD,+CAA0D;AAC1D,2DAA8G;AAI9G,MAAM,mBAAmB,GAAG,CAAC,MAAc,EAAE,IAAY,EAAU,EAAE,CAAC;IACpE,IAAA,2BAAc,EAAC;QACb,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,cAAc,EAAE;QACvC,GAAG,cAAO;KACX,CAAC;IACF,IAAA,iBAAI,EAAC,IAAA,gBAAS,EAAC,GAAG,IAAI,IAAI,MAAM,EAAE,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,aAAa,CAAC,EAAE,KAAK,CAAC,CAAC;AACzE,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,IAAA,mBAAM,EAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;AAE9G,SAAgB,qBAAqB,CAAC,OAA2B,EAAE,MAA2B;IAC5F,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,KAAK,GAAG,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAEvD,MAAM,YAAY,GAAG,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,WAAW,MAAM,EAAE,CAAC,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;QAEjG,OAAO,IAAA,kBAAK,EAAC,CAAC,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,sBAAS,CAAC,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { normalize, strings } from '@angular-devkit/core';\nimport { apply, applyTemplates, chain, filter, mergeWith, move, Rule, url } from '@angular-devkit/schematics';\nimport { GeneratorSchemaBase } from '../types';\nimport { SchematicsFolder } from '../types/schematics-folder.type';\n\nconst createTemplateRules = (folder: string, path: string): Rule[] => [\n applyTemplates({\n name: folder,\n localeDate: new Date().toLocaleString(),\n ...strings,\n }),\n move(normalize(`${path}/${folder}`)),\n];\n\nconst getTemplates = (rules: Rule[]) => apply(url(`./templates`), rules);\nconst includeStories = (include: boolean) => filter(filePath => include || !filePath.endsWith('.stories.ts'));\n\nexport function applyFileTemplateUtil(folders: SchematicsFolder[], config: GeneratorSchemaBase): Rule[] {\n return folders.map(folder => {\n const RULES = createTemplateRules(folder, config.path);\n\n const folderSource = apply(url(`./files/${folder}`), [includeStories(config.stories), ...RULES]);\n\n return chain([folderSource, getTemplates(RULES)].map(mergeWith));\n });\n}\n"]}
@@ -1,11 +1,9 @@
1
1
  import { normalize, strings } from '@angular-devkit/core';
2
2
  import { apply, applyTemplates, chain, filter, mergeWith, move, Rule, url } from '@angular-devkit/schematics';
3
- import { ComponentGeneratorSchema } from '../schematics/components/components-generator';
4
3
  import { GeneratorSchemaBase } from '../types';
4
+ import { SchematicsFolder } from '../types/schematics-folder.type';
5
5
 
6
- type Folders = ComponentGeneratorSchema['components'];
7
-
8
- const createTemplateRules = (folder: Folders, path: string): Rule[] => [
6
+ const createTemplateRules = (folder: string, path: string): Rule[] => [
9
7
  applyTemplates({
10
8
  name: folder,
11
9
  localeDate: new Date().toLocaleString(),
@@ -17,9 +15,9 @@ const createTemplateRules = (folder: Folders, path: string): Rule[] => [
17
15
  const getTemplates = (rules: Rule[]) => apply(url(`./templates`), rules);
18
16
  const includeStories = (include: boolean) => filter(filePath => include || !filePath.endsWith('.stories.ts'));
19
17
 
20
- export function applyFileTemplateUtil(folders: Folders, config: GeneratorSchemaBase): Rule[] {
18
+ export function applyFileTemplateUtil(folders: SchematicsFolder[], config: GeneratorSchemaBase): Rule[] {
21
19
  return folders.map(folder => {
22
- const RULES = createTemplateRules(folders, config.path);
20
+ const RULES = createTemplateRules(folder, config.path);
23
21
 
24
22
  const folderSource = apply(url(`./files/${folder}`), [includeStories(config.stories), ...RULES]);
25
23