@flywheel-io/vision 21.1.3 → 21.2.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flywheel-io/vision",
3
- "version": "21.1.3",
3
+ "version": "21.2.0",
4
4
  "description": "Flywheel UI elements provided as Angular components and native web components",
5
5
  "author": "Flywheel",
6
6
  "license": "MIT",
@@ -18,6 +18,7 @@
18
18
  "dependencies": {
19
19
  "@date-fns/tz": "^1.4.1",
20
20
  "date-fns": "^2.28.0",
21
+ "json-logic-js": "^2.0.5",
21
22
  "libphonenumber-js": "^1.10.11",
22
23
  "tslib": "^2.4.1"
23
24
  },
@@ -4,11 +4,12 @@ import * as i1 from '@angular/common';
4
4
  import { Location } from '@angular/common';
5
5
  import { SafeStyle } from '@angular/platform-browser';
6
6
  import * as i2 from '@angular/forms';
7
- import { ControlValueAccessor, FormControl, ValidatorFn, AbstractControl, NgControl } from '@angular/forms';
7
+ import { ControlValueAccessor, FormControl, FormControlStatus, FormGroup, ValidatorFn, AbstractControl, NgControl } from '@angular/forms';
8
8
  import * as i2$1 from '@angular/cdk/dialog';
9
9
  import { DialogRef, Dialog, DialogConfig } from '@angular/cdk/dialog';
10
10
  import * as i3 from '@angular/cdk/overlay';
11
11
  import { OverlayContainer, ComponentType, CdkOverlayOrigin, ConnectedPosition, OverlayConfig, FlexibleConnectedPositionStrategyOrigin, ConnectedOverlayPositionChange } from '@angular/cdk/overlay';
12
+ import { RulesLogic } from 'json-logic-js';
12
13
  import * as i1$1 from '@angular/cdk/menu';
13
14
  import { CdkMenuTrigger } from '@angular/cdk/menu';
14
15
  import * as i4 from '@angular/cdk/table';
@@ -1043,6 +1044,117 @@ declare class FwFormHeadingModule {
1043
1044
  static ɵinj: _angular_core.ɵɵInjectorDeclaration<FwFormHeadingModule>;
1044
1045
  }
1045
1046
 
1047
+ declare enum FieldType {
1048
+ Checkbox = "checkbox",
1049
+ Switch = "switch",
1050
+ Radio = "radio",
1051
+ Text = "text",
1052
+ TextArea = "text-area",
1053
+ Date = "date",
1054
+ Phone = "phone",
1055
+ Select = "select",
1056
+ Paragraph = "paragraph",
1057
+ Instruction = "instruction",
1058
+ Int = "int",
1059
+ Float = "float"
1060
+ }
1061
+ interface LogicRule {
1062
+ logic: RulesLogic;
1063
+ message?: string;
1064
+ }
1065
+ interface CustomField {
1066
+ type: string;
1067
+ label?: string;
1068
+ description?: string;
1069
+ placeholder?: string;
1070
+ key: string;
1071
+ helperText?: string;
1072
+ errorText?: string;
1073
+ requiredWhenVisible?: RulesLogic[];
1074
+ validation?: LogicRule[];
1075
+ visible?: RulesLogic[];
1076
+ options?: {
1077
+ value: string;
1078
+ label?: string;
1079
+ }[];
1080
+ }
1081
+ interface CustomSection {
1082
+ title: string;
1083
+ description?: string | null;
1084
+ key: string;
1085
+ fields: CustomField[];
1086
+ }
1087
+ interface CustomForm {
1088
+ fields: (CustomField | CustomSection)[];
1089
+ }
1090
+
1091
+ /**
1092
+ * Renders a {@link CustomForm} schema as a reactive form, resolving JSONLogic-driven
1093
+ * visibility and validation rules for each field.
1094
+ * @see [Vision storybook](https://cdn.flywheel.io/docs/vision/master/?path=/docs/form-controls-form-renderer--docs)
1095
+ */
1096
+ declare class FwFormRendererComponent {
1097
+ readonly formData: _angular_core.InputSignal<CustomForm>;
1098
+ /** Whether accordion sections render with an outer border. Defaults to `false`. */
1099
+ readonly sectionBorder: _angular_core.InputSignal<boolean>;
1100
+ /** Emits the normalized `{ [fieldKey]: value }` record whenever any field's value changes. */
1101
+ readonly valueChange: _angular_core.OutputEmitterRef<Record<string, unknown>>;
1102
+ /** Emits the FormGroup's overall status whenever it changes. */
1103
+ readonly statusChange: _angular_core.OutputEmitterRef<FormControlStatus>;
1104
+ /**
1105
+ * The underlying FormGroup, exposed as an escape hatch for consumers that need to bind
1106
+ * `[formGroup]` directly (e.g. to call `.patchValue()` or read `.status`/`.value` themselves)
1107
+ * rather than relying solely on `valueChange`/`statusChange`.
1108
+ */
1109
+ readonly form: _angular_core.WritableSignal<FormGroup<any>>;
1110
+ readonly flatFields: _angular_core.WritableSignal<CustomField[]>;
1111
+ readonly FieldType: typeof FieldType;
1112
+ private readonly submitted;
1113
+ private readonly hideByKey;
1114
+ private readonly requiredByKey;
1115
+ private readonly expandedSectionKeys;
1116
+ structuredItems: _angular_core.Signal<(CustomField | CustomSection)[]>;
1117
+ isHidden(field: CustomField): boolean;
1118
+ isRequired(field: CustomField): boolean;
1119
+ isSection(item: CustomField | CustomSection): item is CustomSection;
1120
+ isSectionExpanded(section: CustomSection): boolean;
1121
+ onSectionToggle(section: CustomSection, expanded: boolean): void;
1122
+ /**
1123
+ * Forces a section back open when focus lands on one of its fields while it's collapsed
1124
+ * — e.g. tabbing through the form shouldn't leave focus inside a hidden (height: 0)
1125
+ * section. Wired to `focusin` on each section's content wrapper.
1126
+ */
1127
+ onSectionContentFocusIn(section: CustomSection): void;
1128
+ private destroyRef;
1129
+ private currentKeys;
1130
+ private currentFields;
1131
+ private readonly formRebuilt$;
1132
+ constructor();
1133
+ private flattenFields;
1134
+ private buildForm;
1135
+ /**
1136
+ * Recomputes field visibility and requiredWhenVisible from the form's current values, and
1137
+ * re-runs validation so the field that was just blurred shows its errorText immediately
1138
+ * (validateFields only assigns errorText for touched controls, and the blurred control's
1139
+ * CVA already marked it touched before this native `focusout` handler runs). Wired to the
1140
+ * form's `focusout` so fields only appear/disappear/error once a field loses focus, rather
1141
+ * than on every keystroke.
1142
+ */
1143
+ onFieldBlur(): void;
1144
+ /**
1145
+ * Marks every control touched/dirty and triggers validation immediately, then flips
1146
+ * validation into live (onChange) mode for the remainder of the form's lifetime. Call
1147
+ * this from the consumer's submit handler; returns whether the form is currently valid.
1148
+ */
1149
+ validateOnSubmit(): boolean;
1150
+ private validateFields;
1151
+ private isEmpty;
1152
+ private evaluateRule;
1153
+ private normalizeValues;
1154
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<FwFormRendererComponent, never>;
1155
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<FwFormRendererComponent, "fw-form-renderer", never, { "formData": { "alias": "formData"; "required": false; "isSignal": true; }; "sectionBorder": { "alias": "sectionBorder"; "required": false; "isSignal": true; }; }, { "valueChange": "valueChange"; "statusChange": "statusChange"; }, never, never, true, never>;
1156
+ }
1157
+
1046
1158
  declare class FwValidators {
1047
1159
  static phone: ValidatorFn;
1048
1160
  static email: ValidatorFn;
@@ -2953,7 +3065,7 @@ declare class FwWrappedInputComponent {
2953
3065
  get hostTitle(): null;
2954
3066
  class: boolean;
2955
3067
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<FwWrappedInputComponent, never>;
2956
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<FwWrappedInputComponent, "fw-wrapped-input", never, { "title": { "alias": "title"; "required": false; "isSignal": true; }; "status": { "alias": "status"; "required": false; "isSignal": true; }; "statusColor": { "alias": "statusColor"; "required": false; "isSignal": true; }; "description": { "alias": "description"; "required": false; "isSignal": true; }; "helperText": { "alias": "helperText"; "required": false; "isSignal": true; }; "errorText": { "alias": "errorText"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; }, {}, never, ["fw-form-heading", "fw-button-toggle, fw-date-input, fw-text-input, fw-number-input, fw-phone-input, fw-textarea-input, fw-select, fw-multi-select, fw-checkbox, fw-typeahead, fw-time-zone-select"], true, never>;
3068
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<FwWrappedInputComponent, "fw-wrapped-input", never, { "title": { "alias": "title"; "required": false; "isSignal": true; }; "status": { "alias": "status"; "required": false; "isSignal": true; }; "statusColor": { "alias": "statusColor"; "required": false; "isSignal": true; }; "description": { "alias": "description"; "required": false; "isSignal": true; }; "helperText": { "alias": "helperText"; "required": false; "isSignal": true; }; "errorText": { "alias": "errorText"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; }, {}, never, ["fw-form-heading", "fw-button-toggle, fw-date-input, fw-text-input, fw-number-input, fw-phone-input, fw-textarea-input, fw-select, fw-multi-select, fw-checkbox, fw-checkbox-group, fw-radio-group, fw-typeahead, fw-time-zone-select"], true, never>;
2957
3069
  }
2958
3070
 
2959
3071
  /**
@@ -2965,5 +3077,5 @@ declare class FwWrappedInputModule {
2965
3077
  static ɵinj: _angular_core.ɵɵInjectorDeclaration<FwWrappedInputModule>;
2966
3078
  }
2967
3079
 
2968
- export { DialogWidth, FwAlertComponent, FwAlertModule, FwAppIconComponent, FwAppIconModule, FwAvatarComponent, FwAvatarListComponent, FwAvatarModule, FwBackButtonComponent, FwBadgeComponent, FwBadgeModule, FwBreadcrumbsComponent, FwBreadcrumbsModule, FwButtonComponent, FwButtonDangerDirective, FwButtonDirective, FwButtonGroupComponent, FwButtonGroupModule, FwButtonModule, FwButtonPrimaryDirective, FwButtonSecondaryDirective, FwButtonSuccessDirective, FwButtonToggleComponent, FwButtonToggleItemComponent, FwButtonToggleModule, FwCardAttributeComponent, FwCardAuthorComponent, FwCardComponent, FwCardContentComponent, FwCardFooterComponent, FwCardHeaderComponent, FwCardModule, FwCell, FwCellDef, FwCheckboxComponent, FwCheckboxGroupComponent, FwCheckboxModule, FwChipComponent, FwChipModule, FwColumnDef, FwContainedInputComponent, FwContainedInputModule, FwCrumbComponent, FwDateInputComponent, FwDateInputModule, FwDialogActionsComponent, FwDialogComponent, FwDialogConfirmComponent, FwDialogContentComponent, FwDialogHeaderComponent, FwDialogService, FwDialogSimpleComponent, FwDialogsModule, FwFooterCell, FwFooterCellDef, FwFooterRow, FwFooterRowDef, FwFormHeadingComponent, FwFormHeadingModule, FwGridComponent, FwGridItemComponent, FwHeaderCell, FwHeaderCellDef, FwHeaderRow, FwHeaderRowDef, FwIconButtonComponent, FwIconButtonModule, FwIconComponent, FwIconModule, FwLayoutContextComponent, FwLayoutGroupComponent, FwLayoutPanelComponent, FwLayoutSidebarComponent, FwLayoutToolbarComponent, FwLayoutsModule, FwMenuCloseTriggersDirective, FwMenuComponent, FwMenuContainerComponent, FwMenuHeaderComponent, FwMenuItemComponent, FwMenuItemGroupComponent, FwMenuModule, FwMenuSeparatorComponent, FwMenuSubItemComponent, FwMultiSelectMenuComponent, FwNavbarComponent, FwNavbarHeaderComponent, FwNavbarItemComponent, FwNavbarModule, FwNavbarSubItemComponent, FwNoDataRow, FwNumberInputComponent, FwNumberInputModule, FwPaginatorAdvancedComponent, FwPaginatorComponent, FwPaginatorModule, FwPhoneInputComponent, FwPhoneInputModule, FwPopoverComponent, FwPopoverModule, FwPopoverPanelComponent, FwProgressBarComponent, FwProgressModule, FwProgressSpinnerComponent, FwRadioComponent, FwRadioGroupComponent, FwRadioModule, FwRow, FwRowDef, FwSectionHeadingComponent, FwSectionHeadingModule, FwSelectMenuComponent, FwSelectMenuModule, FwSnackbarComponent, FwSnackbarContainerComponent, FwSnackbarModule, FwSnackbarService, FwStepComponent, FwStepDecoratorComponent, FwStepperComponent, FwStepperModule, FwSubsectionHeadingComponent, FwSwitchComponent, FwSwitchModule, FwTabComponent, FwTabPanelComponent, FwTableComponent, FwTableDenseComponent, FwTableModule, FwTabsComponent, FwTabsModule, FwTagComponent, FwTagModule, FwTextAreaInputComponent, FwTextAreaInputModule, FwTextComponent, FwTextInputComponent, FwTextInputModule, FwTimeZoneSelectComponent, FwTooltipComponent, FwTooltipDirective, FwTooltipModule, FwTooltipPanelComponent, FwTypeaheadComponent, FwValidators, FwWrappedInputComponent, FwWrappedInputModule, LayoutWidth, MenuManagerService, MenuRegisterDirective, MinimalTranslationService, NoopValueAccessorDirective, TranslationService, allIcons, genMessageId, notBeforeDate, notFutureDate };
2969
- export type { DelayLength$3 as DelayLength, FwButtonColorOption, FwDialogRef, FwPaginatorEvent, FwSnackbarMessage, IconSize, IconType, MenuFilterFn, PaginationPage, PopoverPosition, SimplePosition };
3080
+ export { DialogWidth, FieldType, FwAlertComponent, FwAlertModule, FwAppIconComponent, FwAppIconModule, FwAvatarComponent, FwAvatarListComponent, FwAvatarModule, FwBackButtonComponent, FwBadgeComponent, FwBadgeModule, FwBreadcrumbsComponent, FwBreadcrumbsModule, FwButtonComponent, FwButtonDangerDirective, FwButtonDirective, FwButtonGroupComponent, FwButtonGroupModule, FwButtonModule, FwButtonPrimaryDirective, FwButtonSecondaryDirective, FwButtonSuccessDirective, FwButtonToggleComponent, FwButtonToggleItemComponent, FwButtonToggleModule, FwCardAttributeComponent, FwCardAuthorComponent, FwCardComponent, FwCardContentComponent, FwCardFooterComponent, FwCardHeaderComponent, FwCardModule, FwCell, FwCellDef, FwCheckboxComponent, FwCheckboxGroupComponent, FwCheckboxModule, FwChipComponent, FwChipModule, FwColumnDef, FwContainedInputComponent, FwContainedInputModule, FwCrumbComponent, FwDateInputComponent, FwDateInputModule, FwDialogActionsComponent, FwDialogComponent, FwDialogConfirmComponent, FwDialogContentComponent, FwDialogHeaderComponent, FwDialogService, FwDialogSimpleComponent, FwDialogsModule, FwFooterCell, FwFooterCellDef, FwFooterRow, FwFooterRowDef, FwFormHeadingComponent, FwFormHeadingModule, FwFormRendererComponent, FwGridComponent, FwGridItemComponent, FwHeaderCell, FwHeaderCellDef, FwHeaderRow, FwHeaderRowDef, FwIconButtonComponent, FwIconButtonModule, FwIconComponent, FwIconModule, FwLayoutContextComponent, FwLayoutGroupComponent, FwLayoutPanelComponent, FwLayoutSidebarComponent, FwLayoutToolbarComponent, FwLayoutsModule, FwMenuCloseTriggersDirective, FwMenuComponent, FwMenuContainerComponent, FwMenuHeaderComponent, FwMenuItemComponent, FwMenuItemGroupComponent, FwMenuModule, FwMenuSeparatorComponent, FwMenuSubItemComponent, FwMultiSelectMenuComponent, FwNavbarComponent, FwNavbarHeaderComponent, FwNavbarItemComponent, FwNavbarModule, FwNavbarSubItemComponent, FwNoDataRow, FwNumberInputComponent, FwNumberInputModule, FwPaginatorAdvancedComponent, FwPaginatorComponent, FwPaginatorModule, FwPhoneInputComponent, FwPhoneInputModule, FwPopoverComponent, FwPopoverModule, FwPopoverPanelComponent, FwProgressBarComponent, FwProgressModule, FwProgressSpinnerComponent, FwRadioComponent, FwRadioGroupComponent, FwRadioModule, FwRow, FwRowDef, FwSectionHeadingComponent, FwSectionHeadingModule, FwSelectMenuComponent, FwSelectMenuModule, FwSnackbarComponent, FwSnackbarContainerComponent, FwSnackbarModule, FwSnackbarService, FwStepComponent, FwStepDecoratorComponent, FwStepperComponent, FwStepperModule, FwSubsectionHeadingComponent, FwSwitchComponent, FwSwitchModule, FwTabComponent, FwTabPanelComponent, FwTableComponent, FwTableDenseComponent, FwTableModule, FwTabsComponent, FwTabsModule, FwTagComponent, FwTagModule, FwTextAreaInputComponent, FwTextAreaInputModule, FwTextComponent, FwTextInputComponent, FwTextInputModule, FwTimeZoneSelectComponent, FwTooltipComponent, FwTooltipDirective, FwTooltipModule, FwTooltipPanelComponent, FwTypeaheadComponent, FwValidators, FwWrappedInputComponent, FwWrappedInputModule, LayoutWidth, MenuManagerService, MenuRegisterDirective, MinimalTranslationService, NoopValueAccessorDirective, TranslationService, allIcons, genMessageId, notBeforeDate, notFutureDate };
3081
+ export type { CustomField, CustomForm, CustomSection, DelayLength$3 as DelayLength, FwButtonColorOption, FwDialogRef, FwPaginatorEvent, FwSnackbarMessage, IconSize, IconType, LogicRule, MenuFilterFn, PaginationPage, PopoverPosition, SimplePosition };