@ng-zen/cli 19.0.0-alpha.4 → 19.0.0-alpha.5
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/package.json +1 -1
- package/schematics/components/components-generator.js.map +1 -1
- package/schematics/components/components-generator.ts +1 -1
- package/schematics/components/files/textarea/index.ts +1 -0
- package/schematics/components/files/textarea/textarea.component.scss +38 -0
- package/schematics/components/files/textarea/textarea.component.spec.ts +22 -0
- package/schematics/components/files/textarea/textarea.component.ts +25 -0
- package/schematics/components/files/textarea/textarea.stories.ts +65 -0
- package/schematics/components/schema.json +1 -1
package/package.json
CHANGED
|
@@ -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 type ComponentType = 'avatar' | 'button' | 'checkbox' | 'input';\n\nexport interface ComponentGeneratorSchema extends GeneratorSchemaBase {\n components: ComponentType[];\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' | 'checkbox' | 'input' | 'textarea';\n\nexport interface ComponentGeneratorSchema extends GeneratorSchemaBase {\n components: ComponentType[];\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GeneratorSchemaBase } from '../../types';
|
|
2
2
|
|
|
3
|
-
export type ComponentType = 'avatar' | 'button' | 'checkbox' | 'input';
|
|
3
|
+
export type ComponentType = 'avatar' | 'button' | 'checkbox' | 'input' | 'textarea';
|
|
4
4
|
|
|
5
5
|
export interface ComponentGeneratorSchema extends GeneratorSchemaBase {
|
|
6
6
|
components: ComponentType[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './textarea.component';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Component Variables
|
|
2
|
+
$border: var(--zen-input-border, 1px solid hsl(0% 0% 80%));
|
|
3
|
+
$border-radius: var(--zen-input-border-radius, 8px);
|
|
4
|
+
$padding: var(--zen-input-padding, 0.5rem 1rem);
|
|
5
|
+
$focus-shadow: var(--zen-input-focus-shadow, 0 1px 4px hsla(0% 0% 60% / 20%) inset);
|
|
6
|
+
$placeholder-color: var(--zen-input-placeholder-color, hsl(0% 0% 60%));
|
|
7
|
+
|
|
8
|
+
// Color Palette
|
|
9
|
+
$outline: var(--zen-outline, 1px solid hsl(0% 0% 60%));
|
|
10
|
+
$error: var(--zen-error, hsl(0% 70% 50%));
|
|
11
|
+
|
|
12
|
+
:host {
|
|
13
|
+
border: $border;
|
|
14
|
+
border-radius: $border-radius;
|
|
15
|
+
padding: $padding;
|
|
16
|
+
|
|
17
|
+
&[autoresize] {
|
|
18
|
+
field-sizing: content;
|
|
19
|
+
resize: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&:disabled {
|
|
23
|
+
opacity: 0.6;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&:focus-visible {
|
|
27
|
+
outline: $outline;
|
|
28
|
+
box-shadow: $focus-shadow;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:user-invalid {
|
|
32
|
+
border-color: $error;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&::placeholder {
|
|
36
|
+
color: $placeholder-color;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { ZenTextareaComponent } from './textarea.component';
|
|
4
|
+
|
|
5
|
+
describe('ZenTextareaComponent', () => {
|
|
6
|
+
let component: ZenTextareaComponent;
|
|
7
|
+
let fixture: ComponentFixture<ZenTextareaComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
imports: [ZenTextareaComponent],
|
|
12
|
+
}).compileComponents();
|
|
13
|
+
|
|
14
|
+
fixture = TestBed.createComponent(ZenTextareaComponent);
|
|
15
|
+
component = fixture.componentInstance;
|
|
16
|
+
fixture.detectChanges();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should create', () => {
|
|
20
|
+
expect(component).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ZenTextareaComponent is a reusable textarea component designed to provide
|
|
5
|
+
* a consistent and customizable textarea style across the application.
|
|
6
|
+
* It supports Angular forms integration and provides two-way data binding.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* <textarea zen-textarea></textarea>
|
|
10
|
+
*
|
|
11
|
+
* @author Konrad Stępień
|
|
12
|
+
* @license {@link https://github.com/kstepien3/ng-zen?tab=BSD-2-Clause-1-ov-file|BSD-2-Clause}
|
|
13
|
+
* @see [GitHub](https://github.com/kstepien3/ng-zen)
|
|
14
|
+
*/
|
|
15
|
+
@Component({
|
|
16
|
+
// eslint-disable-next-line @angular-eslint/component-selector
|
|
17
|
+
selector: 'textarea[zen-textarea], textarea[zen-textarea][autoresize]',
|
|
18
|
+
standalone: true,
|
|
19
|
+
template: `
|
|
20
|
+
<ng-content />
|
|
21
|
+
`,
|
|
22
|
+
styleUrls: ['./textarea.component.scss'],
|
|
23
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
24
|
+
})
|
|
25
|
+
export class ZenTextareaComponent {}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/angular';
|
|
2
|
+
import { ZenTextareaComponent } from './textarea.component';
|
|
3
|
+
|
|
4
|
+
interface StoryParams {
|
|
5
|
+
value: string;
|
|
6
|
+
placeholder: string;
|
|
7
|
+
required: boolean;
|
|
8
|
+
autoresize: boolean;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
title: 'Components/Textarea',
|
|
14
|
+
component: ZenTextareaComponent,
|
|
15
|
+
tags: ['autodocs'],
|
|
16
|
+
args: {
|
|
17
|
+
value: '',
|
|
18
|
+
autoresize: false,
|
|
19
|
+
placeholder: 'ZenTextareaComponent',
|
|
20
|
+
required: false,
|
|
21
|
+
disabled: false,
|
|
22
|
+
},
|
|
23
|
+
argTypes: {
|
|
24
|
+
value: { control: 'text' },
|
|
25
|
+
autoresize: { control: 'boolean' },
|
|
26
|
+
placeholder: { control: 'text' },
|
|
27
|
+
required: { control: 'boolean' },
|
|
28
|
+
disabled: { control: 'boolean' },
|
|
29
|
+
},
|
|
30
|
+
} satisfies Meta<ZenTextareaComponent & StoryParams>;
|
|
31
|
+
|
|
32
|
+
type Story = StoryObj<ZenTextareaComponent & StoryParams>;
|
|
33
|
+
|
|
34
|
+
export const Default: Story = {
|
|
35
|
+
render: args => ({
|
|
36
|
+
template: `
|
|
37
|
+
<textarea
|
|
38
|
+
zen-textarea
|
|
39
|
+
placeholder="${args.placeholder}"
|
|
40
|
+
${args.required ? 'required' : ''}
|
|
41
|
+
${args.autoresize ? 'autoresize' : ''}
|
|
42
|
+
${args.disabled ? 'disabled' : ''}
|
|
43
|
+
>${args.value}</textarea>`,
|
|
44
|
+
}),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const WithLabel: Story = {
|
|
48
|
+
render: () => ({
|
|
49
|
+
template: `
|
|
50
|
+
<div style="display: flex; flex-direction: column">
|
|
51
|
+
<label for="label-example"> With label </label>
|
|
52
|
+
<textarea zen-textarea id="label-example"></textarea>
|
|
53
|
+
</div>
|
|
54
|
+
`,
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const Autoresize: Story = {
|
|
59
|
+
render: args => ({
|
|
60
|
+
props: { ...args },
|
|
61
|
+
template: `
|
|
62
|
+
<textarea zen-textarea autoresize style="max-width: 300px">Start typing...</textarea>
|
|
63
|
+
`,
|
|
64
|
+
}),
|
|
65
|
+
};
|