@ng-zen/cli 20.2.0 → 20.2.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.
@@ -2,40 +2,63 @@ import { Meta, StoryObj } from '@storybook/angular';
2
2
 
3
3
  import { ZenSwitch } from './switch';
4
4
 
5
+ type Options = ZenSwitch;
6
+
5
7
  export default {
6
8
  title: 'Components/Switch',
7
9
  component: ZenSwitch,
8
- tags: ['autodocs'],
9
10
  argTypes: {
10
- value: { control: 'boolean' },
11
- disabled: { control: 'boolean' },
11
+ value: {
12
+ control: 'boolean',
13
+ table: {
14
+ category: 'models',
15
+ type: {
16
+ summary: 'boolean',
17
+ },
18
+ },
19
+ },
20
+ disabled: {
21
+ control: 'boolean',
22
+ table: {
23
+ category: 'models',
24
+ type: {
25
+ summary: 'boolean',
26
+ },
27
+ },
28
+ },
29
+ required: {
30
+ control: 'boolean',
31
+ table: {
32
+ category: 'inputs',
33
+ type: {
34
+ summary: 'boolean',
35
+ },
36
+ defaultValue: {
37
+ summary: 'false',
38
+ },
39
+ },
40
+ },
41
+ onInput: {
42
+ table: {
43
+ readonly: true,
44
+ type: {
45
+ summary: '(value: boolean) => void',
46
+ },
47
+ },
48
+ },
49
+ onKeyDown: {
50
+ table: {
51
+ readonly: true,
52
+ },
53
+ },
12
54
  },
13
55
  args: {
14
56
  value: false,
15
57
  disabled: false,
58
+ required: false,
16
59
  },
17
- } satisfies Meta<ZenSwitch>;
18
-
19
- type Story = StoryObj<ZenSwitch>;
60
+ } satisfies Meta<Options>;
20
61
 
21
- export const Default: Story = {
22
- render: args => ({
23
- props: { ...args },
24
- template: `
25
- <zen-switch
26
- [disabled]="${args.disabled}"
27
- [value]="${args.value}"
28
- />`,
29
- }),
30
- };
62
+ type Story = StoryObj<Options>;
31
63
 
32
- export const WithLabel: Story = {
33
- render: () => ({
34
- template: `
35
- <div style="display: flex; align-items: center; gap: 0.25rem">
36
- <zen-switch id="label-example"/>
37
- <label for="label-example"> With label </label>
38
- </div>
39
- `,
40
- }),
41
- };
64
+ export const Default: Story = {};
@@ -58,6 +58,7 @@ export class ZenSwitch extends ZenFormControl<boolean> {
58
58
 
59
59
  /**
60
60
  * Handles keyboard events for accessibility.
61
+ * Supports `Enter`, `Space`, `ArrowRight`, and `ArrowLeft` keys.
61
62
  */
62
63
  onKeyDown(event: KeyboardEvent): void {
63
64
  switch (event.code) {
@@ -3,47 +3,80 @@ import { Meta, StoryObj } from '@storybook/angular';
3
3
  import { ZenTextarea } from './textarea';
4
4
 
5
5
  interface StoryParams {
6
- value: string;
6
+ content: string;
7
7
  placeholder: string;
8
8
  required: boolean;
9
9
  autoresize: boolean;
10
10
  disabled: boolean;
11
11
  }
12
+ type Options = ZenTextarea & StoryParams;
12
13
 
13
14
  export default {
14
15
  title: 'Components/Textarea',
15
16
  component: ZenTextarea,
16
- tags: ['autodocs'],
17
17
  args: {
18
- value: '',
18
+ content: '',
19
19
  autoresize: false,
20
20
  placeholder: 'ZenTextareaComponent',
21
21
  required: false,
22
22
  disabled: false,
23
23
  },
24
24
  argTypes: {
25
- value: { control: 'text' },
26
- autoresize: { control: 'boolean' },
27
- placeholder: { control: 'text' },
28
- required: { control: 'boolean' },
29
- disabled: { control: 'boolean' },
25
+ content: {
26
+ control: 'text',
27
+ table: {
28
+ category: 'story parameters',
29
+ type: {
30
+ summary: 'ng-content',
31
+ },
32
+ },
33
+ },
34
+ placeholder: {
35
+ control: 'text',
36
+ table: {
37
+ category: 'attributes',
38
+ type: {
39
+ summary: 'string',
40
+ },
41
+ },
42
+ },
43
+ required: {
44
+ control: 'boolean',
45
+ table: {
46
+ category: 'attributes',
47
+ type: {
48
+ summary: 'boolean',
49
+ },
50
+ },
51
+ },
52
+ disabled: {
53
+ control: 'boolean',
54
+ table: {
55
+ category: 'attributes',
56
+ type: {
57
+ summary: 'boolean',
58
+ },
59
+ },
60
+ },
61
+ autoresize: {
62
+ table: {
63
+ category: 'attributes',
64
+ },
65
+ },
30
66
  },
31
- } satisfies Meta<ZenTextarea & StoryParams>;
32
-
33
- type Story = StoryObj<ZenTextarea & StoryParams>;
34
-
35
- export const Default: Story = {
36
- render: args => ({
67
+ render: ({ content, ...args }) => ({
68
+ props: args,
37
69
  template: `
38
- <textarea
39
- zen-textarea
40
- placeholder="${args.placeholder}"
41
- ${args.required ? 'required' : ''}
42
- ${args.autoresize ? 'autoresize' : ''}
43
- ${args.disabled ? 'disabled' : ''}
44
- >${args.value}</textarea>`,
70
+ <textarea zen-textarea placeholder="${args.placeholder}" ${args.required ? 'required' : ''} ${args.autoresize ? 'autoresize' : ''} ${args.disabled ? 'disabled' : ''}>${content}</textarea>`.replace(
71
+ /\s+/g,
72
+ ' '
73
+ ),
45
74
  }),
46
- };
75
+ } satisfies Meta<Options>;
76
+
77
+ type Story = StoryObj<Options>;
78
+
79
+ export const Default: Story = {};
47
80
 
48
81
  export const WithLabel: Story = {
49
82
  render: () => ({
@@ -26,9 +26,9 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
26
26
  * @see [GitHub](https://github.com/kstepien3/ng-zen)
27
27
  */
28
28
  @Component({
29
+ // @TODO: add support for autoresize for mozilla browsers https://developer.mozilla.org/en-US/docs/Web/CSS/field-sizing
29
30
  // eslint-disable-next-line @angular-eslint/component-selector
30
31
  selector: 'textarea[zen-textarea], textarea[zen-textarea][autoresize]',
31
- standalone: true,
32
32
  template: `
33
33
  <ng-content />
34
34
  `,