All files / src/stories crud-field.stories.ts

0% Statements 0/16
0% Branches 0/1
0% Functions 0/2
0% Lines 0/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81                                                                                                                                                                 
import './setup';
import type { Meta, StoryObj } from '@storybook/angular';
import { getComponentMeta } from './utils';
import { OperationKeys } from '@decaf-ts/db-decorators';
import {
  IonCheckbox,
  IonDatetime,
  IonInput,
  IonItem,
  IonLabel,
  IonRadio,
  IonRadioGroup,
  IonSelect,
  IonSelectOption,
  IonTextarea,
  IonRange,
  IonToggle,
  IonButton,
  IonDatetimeButton,
} from '@ionic/angular/standalone';
import { CrudFieldComponent } from 'src/lib/components/crud-field/crud-field.component';
import { PossibleInputTypes } from 'src/lib/engine/types';
import { within } from 'storybook/test';
import { FormControl, FormGroup } from '@angular/forms';
import { NgxFormService } from 'src/lib/services/NgxFormService';
 
const component = getComponentMeta<CrudFieldComponent>([
  IonInput,
  IonItem,
  IonCheckbox,
  IonRadioGroup,
  IonRadio,
  IonSelect,
  IonSelectOption,
  IonTextarea,
  IonDatetime,
  IonLabel,
  IonRange,
  IonToggle,
  IonButton,
  IonDatetimeButton,
]);
const meta: Meta<CrudFieldComponent> = {
  title: 'Components/Crud Field',
  component: CrudFieldComponent,
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
  ...component,
  args: {
    operation: OperationKeys.CREATE,
    type: 'text' as PossibleInputTypes,
    name: 'name',
    label: 'Field Label',
    value: '',
    disabled: false,
    required: false,
    formGroup: new FormGroup({}),
    component: undefined,
  },
};
export default meta;
type Story = StoryObj<CrudFieldComponent>;
 
export const init: Story = {};
 
export const focus: Story = {
  play: ({ args, canvasElement }) => {
    const input = canvasElement.querySelector(
      'ion-input'
    ) as HTMLIonInputElement;
    Iif (input) {
      setTimeout(() => {
        input.value = 'New Value';
        input.setFocus();
        // input.dispatchEvent(new CustomEvent('input', { detail: { value: 'New Value' } }));
        // args.formGroup.updateValueAndValidity();
        // args.formGroup.setErrors(null);
      }, 100);
    }
  },
};