@grasp-labs/ds-microfrontends-integration 0.25.2 → 1.0.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.
Files changed (41) hide show
  1. package/README.md +1 -1
  2. package/dist/components/language/translations/en.json.d.ts +9 -1
  3. package/dist/components/language/translations/no.json.d.ts +9 -1
  4. package/dist/components/schemaFields/ArrayField.d.ts +5 -0
  5. package/dist/components/schemaFields/BooleanField.d.ts +5 -0
  6. package/dist/components/schemaFields/ConditionalFields.d.ts +19 -0
  7. package/dist/components/schemaFields/DateField.d.ts +5 -0
  8. package/dist/components/schemaFields/DefaultFieldRenderer.d.ts +6 -0
  9. package/dist/components/schemaFields/DependentFields.d.ts +19 -0
  10. package/dist/components/schemaFields/DictionaryField/DictionaryEntry.d.ts +20 -0
  11. package/dist/components/schemaFields/DictionaryField/DictionaryField.d.ts +14 -0
  12. package/dist/components/schemaFields/DictionaryField/index.d.ts +1 -0
  13. package/dist/components/schemaFields/EnumField.d.ts +5 -0
  14. package/dist/components/schemaFields/FieldError.d.ts +5 -0
  15. package/dist/components/schemaFields/JsonField.d.ts +5 -0
  16. package/dist/components/schemaFields/NumberField.d.ts +5 -0
  17. package/dist/components/schemaFields/SchemaFields.d.ts +6 -0
  18. package/dist/components/schemaFields/SchemaFields.stories.d.ts +3 -5
  19. package/dist/components/schemaFields/TextField.d.ts +5 -0
  20. package/dist/components/schemaFields/TupleField.d.ts +13 -0
  21. package/dist/components/schemaFields/VariantField/VariantField.d.ts +14 -0
  22. package/dist/components/schemaFields/VariantField/index.d.ts +1 -0
  23. package/dist/components/schemaFields/VaultField.d.ts +5 -0
  24. package/dist/components/schemaFields/consts/schemas.d.ts +10 -0
  25. package/dist/components/schemaFields/index.d.ts +1 -0
  26. package/dist/components/schemaFields/shared/EntryValueRenderer.d.ts +16 -0
  27. package/dist/components/schemaFields/shared/dictionaryHandlers.d.ts +5 -0
  28. package/dist/{index-nQu71UC3.js → index-B6ZY0zb9.js} +8134 -6720
  29. package/dist/{index.esm-fQDYRCEr-CcUa57B3.js → index.esm-fQDYRCEr-DmkkBbtV.js} +1 -1
  30. package/dist/index.js +50 -38
  31. package/dist/lib/schema/conditional.d.ts +2 -0
  32. package/dist/lib/schema/index.d.ts +2 -1
  33. package/dist/lib/schema/inspector.d.ts +26 -0
  34. package/dist/lib/schema/resolver.d.ts +4 -0
  35. package/dist/lib/schema/schemaResolver/schemaResolver.d.ts +1 -2
  36. package/dist/lib/schema/schemaResolver/utils.d.ts +27 -4
  37. package/dist/lib/schema/types.d.ts +5 -1
  38. package/dist/types/Navigation.d.ts +0 -2
  39. package/dist/types/Schema.d.ts +2 -2
  40. package/dist/types/customErrorHandler.d.ts +13 -3
  41. package/package.json +7 -5
package/README.md CHANGED
@@ -18,8 +18,8 @@ Components for managing secrets with JSON Schema-based forms.
18
18
 
19
19
  ```tsx
20
20
  import {
21
- VaultInput,
22
21
  VaultProvider,
22
+ VaultInput,
23
23
  VaultSecretDialog,
24
24
  } from "@grasp-labs/ds-microfrontends-integration";
25
25
  import "@grasp-labs/ds-microfrontends-integration/styles.css";
@@ -13,7 +13,15 @@ declare const _default: {
13
13
  "vaultSecretDialog.deleteError": "Failed to delete secret. Please try again.",
14
14
  "vaultInput.placeholder": "Select a secret",
15
15
  "vaultInput.addAriaLabel": "Add new secret",
16
- "vaultInput.toggleAriaLabel": "Toggle options menu"
16
+ "vaultInput.toggleAriaLabel": "Toggle options menu",
17
+ "schemaFields.remove": "Remove",
18
+ "schemaFields.addItem": "+ Add Item",
19
+ "schemaFields.addEntry": "+ Add Entry",
20
+ "schemaFields.keyPlaceholder": "Key",
21
+ "schemaFields.variant": "Option",
22
+ "schemaFields.allowedPatterns": "Allowed patterns",
23
+ "schemaFields.invalidValue": "Invalid value",
24
+ "schemaFields.none": "None"
17
25
  }
18
26
  ;
19
27
 
@@ -13,7 +13,15 @@ declare const _default: {
13
13
  "vaultSecretDialog.deleteError": "Kunne ikke slette hemmeligheten. Prøv igjen.",
14
14
  "vaultInput.placeholder": "Velg en hemmelighet",
15
15
  "vaultInput.addAriaLabel": "Legg til ny hemmelighet",
16
- "vaultInput.toggleAriaLabel": "Vis eller skjul alternativer"
16
+ "vaultInput.toggleAriaLabel": "Vis eller skjul alternativer",
17
+ "schemaFields.remove": "Fjern",
18
+ "schemaFields.addItem": "+ Legg til element",
19
+ "schemaFields.addEntry": "+ Legg til oppføring",
20
+ "schemaFields.keyPlaceholder": "Nøkkel",
21
+ "schemaFields.variant": "Alternativ",
22
+ "schemaFields.allowedPatterns": "Tillatte mønstre",
23
+ "schemaFields.invalidValue": "Ugyldig verdi",
24
+ "schemaFields.none": "Ingen"
17
25
  }
18
26
  ;
19
27
 
@@ -4,5 +4,10 @@ type ArrayFieldProps<T extends FieldValues = FieldValues> = {
4
4
  descriptor: FieldDescriptor<Path<T>>;
5
5
  control: Control<T>;
6
6
  };
7
+ /**
8
+ * Dynamic list field for homogeneous array schemas with add/remove support.
9
+ * All items share the same schema from `items`. New items are initialized
10
+ * with the schema's default value. For fixed-length typed arrays, see TupleField.
11
+ */
7
12
  export declare function ArrayField<T extends FieldValues = FieldValues>({ descriptor, control, }: ArrayFieldProps<T>): import("react/jsx-runtime").JSX.Element;
8
13
  export {};
@@ -4,5 +4,10 @@ type BooleanFieldProps<T extends FieldValues = FieldValues> = {
4
4
  descriptor: FieldDescriptor<Path<T>>;
5
5
  control: Control<T>;
6
6
  };
7
+ /**
8
+ * Checkbox field for boolean schema values.
9
+ * Uses the descriptor label as the checkbox label and coerces
10
+ * the stored value to boolean for display.
11
+ */
7
12
  export declare function BooleanField<T extends FieldValues = FieldValues>({ descriptor, control, }: BooleanFieldProps<T>): import("react/jsx-runtime").JSX.Element;
8
13
  export {};
@@ -0,0 +1,19 @@
1
+ import { ReactNode } from 'react';
2
+ import { Control, FieldErrors, FieldValues, Path } from 'react-hook-form';
3
+ import { FieldDescriptor } from 'src/lib/schema/types';
4
+ import { Schema } from 'src/types/Schema';
5
+ type ConditionalFieldsProps<T extends FieldValues = FieldValues> = {
6
+ schema: Schema;
7
+ prefix: string;
8
+ control: Control<T>;
9
+ errors: FieldErrors<T>;
10
+ fieldDirection?: "horizontal" | "vertical";
11
+ renderField?: (descriptor: FieldDescriptor<Path<T>>, defaultRender: () => ReactNode) => ReactNode;
12
+ };
13
+ /**
14
+ * Renders then/else schema fields based on if condition evaluation.
15
+ * Watches form values via useWatch and re-evaluates the if condition reactively.
16
+ * Renders the `then` branch when the condition matches, `else` otherwise.
17
+ */
18
+ export declare function ConditionalFields<T extends FieldValues = FieldValues>({ schema, prefix, control, errors, fieldDirection, renderField, }: ConditionalFieldsProps<T>): import("react/jsx-runtime").JSX.Element | null;
19
+ export {};
@@ -4,5 +4,10 @@ type DateFieldProps<T extends FieldValues = FieldValues> = {
4
4
  descriptor: FieldDescriptor<Path<T>>;
5
5
  control: Control<T>;
6
6
  };
7
+ /**
8
+ * Date picker field with min/max date constraints from schema.
9
+ * Activated for string fields with format "date". Supports locale,
10
+ * minDate, maxDate, and defaultMonth from descriptor constraints.
11
+ */
7
12
  export declare function DateField<T extends FieldValues = FieldValues>({ descriptor, control, }: DateFieldProps<T>): import("react/jsx-runtime").JSX.Element;
8
13
  export {};
@@ -1,5 +1,11 @@
1
1
  import { Control, FieldValues, Path } from 'react-hook-form';
2
2
  import { FieldDescriptor } from 'src/lib/schema/types';
3
+ /**
4
+ * Routes a field descriptor to the appropriate field component based on its type.
5
+ * Maps schema types (string, number, array, tuple, dictionary, etc.) to their
6
+ * corresponding UI components. String fields are further dispatched by format
7
+ * (vault, date, password).
8
+ */
3
9
  export declare function DefaultFieldRenderer<T extends FieldValues>({ descriptor, control, }: {
4
10
  descriptor: FieldDescriptor<Path<T>>;
5
11
  control: Control<T>;
@@ -0,0 +1,19 @@
1
+ import { ReactNode } from 'react';
2
+ import { Control, FieldErrors, FieldValues, Path } from 'react-hook-form';
3
+ import { FieldDescriptor } from 'src/lib/schema/types';
4
+ import { Schema } from 'src/types/Schema';
5
+ type DependentFieldsProps<T extends FieldValues = FieldValues> = {
6
+ schema: Schema;
7
+ prefix: string;
8
+ control: Control<T>;
9
+ errors: FieldErrors<T>;
10
+ fieldDirection?: "horizontal" | "vertical";
11
+ renderField?: (descriptor: FieldDescriptor<Path<T>>, defaultRender: () => ReactNode) => ReactNode;
12
+ };
13
+ /**
14
+ * Renders additional fields from dependentSchemas when their trigger properties have values.
15
+ * Each dependency key gets its own SingleDependency component with an independent useWatch,
16
+ * so changes to one property don't trigger re-renders of unrelated dependent fields.
17
+ */
18
+ export declare function DependentFields<T extends FieldValues = FieldValues>({ schema, prefix, control, errors, fieldDirection, renderField, }: DependentFieldsProps<T>): import("react/jsx-runtime").JSX.Element | null;
19
+ export {};
@@ -0,0 +1,20 @@
1
+ import { Control, FieldValues } from 'react-hook-form';
2
+ import { Schema } from 'src/types/Schema';
3
+ type DictionaryEntryProps<T extends FieldValues = FieldValues> = {
4
+ fieldName: string;
5
+ entryKey: string;
6
+ valueSchema: Schema | null;
7
+ isDisabled: boolean;
8
+ keyPlaceholder: string;
9
+ removeLabel: string;
10
+ control: Control<T>;
11
+ onKeyChange: (newKey: string) => void;
12
+ onRemove: () => void;
13
+ };
14
+ /**
15
+ * Single key-value row in a dictionary field with editable key and typed value.
16
+ * Key renames are committed on blur. The value input is rendered by EntryValueRenderer
17
+ * which adapts to the value schema type (scalar input or nested object fields).
18
+ */
19
+ export declare function DictionaryEntry<T extends FieldValues = FieldValues>({ fieldName, entryKey, valueSchema, isDisabled, keyPlaceholder, removeLabel, control, onKeyChange, onRemove, }: DictionaryEntryProps<T>): import("react/jsx-runtime").JSX.Element;
20
+ export {};
@@ -0,0 +1,14 @@
1
+ import { Control, FieldValues, Path } from 'react-hook-form';
2
+ import { FieldDescriptor } from 'src/lib/schema';
3
+ type DictionaryFieldProps<T extends FieldValues = FieldValues> = {
4
+ descriptor: FieldDescriptor<Path<T>>;
5
+ control: Control<T>;
6
+ };
7
+ /**
8
+ * Key-value dictionary field for schemas with additionalProperties or patternProperties.
9
+ * Supports dynamic add/remove of entries. For additionalProperties, all values share
10
+ * the same schema. For patternProperties, each entry's value schema is determined by
11
+ * the first matching pattern. Key validation is handled by AJV at form submit.
12
+ */
13
+ export declare function DictionaryField<T extends FieldValues = FieldValues>({ descriptor, control, }: DictionaryFieldProps<T>): import("react/jsx-runtime").JSX.Element;
14
+ export {};
@@ -0,0 +1 @@
1
+ export { DictionaryField } from './DictionaryField';
@@ -4,5 +4,10 @@ type EnumFieldProps<T extends FieldValues = FieldValues> = {
4
4
  descriptor: FieldDescriptor<Path<T>>;
5
5
  control: Control<T>;
6
6
  };
7
+ /**
8
+ * Dropdown select for schema enum values.
9
+ * Builds options from the schema's enum array. Nullable schemas
10
+ * include a "None" option that sets the value to null.
11
+ */
7
12
  export declare function EnumField<T extends FieldValues = FieldValues>({ descriptor, control, }: EnumFieldProps<T>): import("react/jsx-runtime").JSX.Element;
8
13
  export {};
@@ -5,5 +5,10 @@ type ErrorObject = {
5
5
  type FieldErrorProps = {
6
6
  error: ErrorObject | undefined;
7
7
  };
8
+ /**
9
+ * Displays validation error messages from react-hook-form.
10
+ * Handles simple errors (single message) and complex nested errors
11
+ * by recursively flattening them into a path-prefixed list.
12
+ */
8
13
  export declare function FieldError({ error }: FieldErrorProps): import("react/jsx-runtime").JSX.Element | null;
9
14
  export {};
@@ -4,5 +4,10 @@ type JsonFieldProps<T extends FieldValues = FieldValues> = {
4
4
  descriptor: FieldDescriptor<Path<T>>;
5
5
  control: Control<T>;
6
6
  };
7
+ /**
8
+ * JSON editor for object-string schema types (objects without defined properties).
9
+ * Used as a fallback for schemas typed as "object" but lacking properties,
10
+ * additionalProperties, or patternProperties definitions.
11
+ */
7
12
  export declare function JsonField<T extends FieldValues = FieldValues>({ descriptor, control, }: JsonFieldProps<T>): import("react/jsx-runtime").JSX.Element;
8
13
  export {};
@@ -4,5 +4,10 @@ type NumberFieldProps<T extends FieldValues = FieldValues> = {
4
4
  descriptor: FieldDescriptor<Path<T>>;
5
5
  control: Control<T>;
6
6
  };
7
+ /**
8
+ * Numeric input that respects min/max/step constraints from the schema.
9
+ * Handles both number and integer types — integers use step=1,
10
+ * numbers use step="any". Emits null for empty values.
11
+ */
7
12
  export declare function NumberField<T extends FieldValues = FieldValues>({ descriptor, control, }: NumberFieldProps<T>): import("react/jsx-runtime").JSX.Element;
8
13
  export {};
@@ -10,5 +10,11 @@ type SchemaFieldsProps<T extends FieldValues = FieldValues> = {
10
10
  fieldDirection?: "horizontal" | "vertical";
11
11
  renderField?: (descriptor: FieldDescriptor<Path<T>>, defaultRender: () => ReactNode) => ReactNode;
12
12
  };
13
+ /**
14
+ * Renders form fields for all properties in a JSON Schema object.
15
+ * Handles nested objects via recursion, oneOf/anyOf via VariantField,
16
+ * conditionals (if/then/else), and dependentSchemas.
17
+ * Supports custom field rendering via the optional renderField callback.
18
+ */
13
19
  export declare function SchemaFields<T extends FieldValues = FieldValues>({ control, errors, schema, prefix, fieldDirection, renderField, }: SchemaFieldsProps<T>): import("react/jsx-runtime").JSX.Element;
14
20
  export {};
@@ -34,9 +34,7 @@ declare const meta: {
34
34
  export default meta;
35
35
  type Story = StoryObj<typeof meta>;
36
36
  export declare const BasicForm: Story;
37
- export declare const BasicFormWithCustomValidation: Story;
38
- export declare const BasicFormWithVerticalAlignment: Story;
37
+ export declare const WithCustomErrors: Story;
39
38
  export declare const NestedWithVault: Story;
40
- export declare const PasswordFields: Story;
41
- export declare const WithCustomField: Story;
42
- export declare const WithFullOverride: Story;
39
+ export declare const WithRenderField: Story;
40
+ export declare const Playground: Story;
@@ -4,5 +4,10 @@ type TextFieldProps<T extends FieldValues = FieldValues> = {
4
4
  descriptor: FieldDescriptor<Path<T>>;
5
5
  control: Control<T>;
6
6
  };
7
+ /**
8
+ * Text input with automatic type detection based on schema format.
9
+ * Renders PasswordTextBox for password/writeOnly fields, standard TextBox otherwise.
10
+ * Supports formats: email, uri/url, date, date-time, password.
11
+ */
7
12
  export declare function TextField<T extends FieldValues = FieldValues>({ descriptor, control, }: TextFieldProps<T>): import("react/jsx-runtime").JSX.Element;
8
13
  export {};
@@ -0,0 +1,13 @@
1
+ import { Control, FieldValues, Path } from 'react-hook-form';
2
+ import { FieldDescriptor } from 'src/lib/schema';
3
+ type TupleFieldProps<T extends FieldValues = FieldValues> = {
4
+ descriptor: FieldDescriptor<Path<T>>;
5
+ control: Control<T>;
6
+ };
7
+ /**
8
+ * Fixed-length array field where each position has its own schema (prefixItems).
9
+ * No add/remove — the number of items is determined by the schema.
10
+ * Object-typed positions render nested SchemaFields, scalars use DefaultFieldRenderer.
11
+ */
12
+ export declare function TupleField<T extends FieldValues = FieldValues>({ descriptor, control, }: TupleFieldProps<T>): import("react/jsx-runtime").JSX.Element | null;
13
+ export {};
@@ -0,0 +1,14 @@
1
+ import { Control, FieldErrors, FieldValues, Path } from 'react-hook-form';
2
+ import { FieldDescriptor } from 'src/lib/schema/types';
3
+ type VariantFieldProps<T extends FieldValues = FieldValues> = {
4
+ descriptor: FieldDescriptor<Path<T>>;
5
+ control: Control<T>;
6
+ errors?: FieldErrors<T>;
7
+ };
8
+ /**
9
+ * Renders a variant selector (oneOf/anyOf) with a dropdown to switch between sub-schemas.
10
+ * Switching variants resets the field value to the new schema's default.
11
+ * Object variants render nested SchemaFields, scalar variants delegate to DefaultFieldRenderer.
12
+ */
13
+ export declare function VariantField<T extends FieldValues = FieldValues>({ descriptor, control, errors, }: VariantFieldProps<T>): import("react/jsx-runtime").JSX.Element;
14
+ export {};
@@ -0,0 +1 @@
1
+ export { VariantField } from './VariantField';
@@ -4,5 +4,10 @@ type VaultFieldProps<T extends FieldValues = FieldValues> = {
4
4
  descriptor: FieldDescriptor<Path<T>>;
5
5
  control: Control<T>;
6
6
  };
7
+ /**
8
+ * Vault secret selector for fields with format "vault".
9
+ * Delegates to VaultInput which provides a secret picker UI.
10
+ * Activated by DefaultFieldRenderer for string fields with format "vault".
11
+ */
7
12
  export declare function VaultField<T extends FieldValues = FieldValues>({ descriptor, control, }: VaultFieldProps<T>): import("react/jsx-runtime").JSX.Element;
8
13
  export {};
@@ -2,4 +2,14 @@ import { Schema } from 'src/types';
2
2
  export declare const SIMPLE_SCHEMA: Schema;
3
3
  export declare const NESTED_SCHEMA: Schema;
4
4
  export declare const SECRET_FORM_SCHEMA: Schema;
5
+ export declare const COMPLEX_SCHEMA: Schema;
6
+ export declare const NULLABLE_SCHEMA: Schema;
7
+ export declare const DEEP_NESTING_SCHEMA: Schema;
8
+ export declare const FULL_FEATURES_SCHEMA: Schema;
9
+ export declare const DICTIONARY_SCHEMA: Schema;
5
10
  export declare const PASSWORD_SCHEMA: Schema;
11
+ export declare const COMPOSITION_SCHEMA: Schema;
12
+ export declare const CONDITIONAL_SCHEMA: Schema;
13
+ export declare const ARRAYS_TUPLES_SCHEMA: Schema;
14
+ export declare const PATTERN_PROPS_SCHEMA: Schema;
15
+ export declare const VARIANTS_SCHEMA: Schema;
@@ -2,6 +2,7 @@ export { ArrayField } from './ArrayField';
2
2
  export { BooleanField } from './BooleanField';
3
3
  export { DateField } from './DateField';
4
4
  export { DefaultFieldRenderer } from './DefaultFieldRenderer';
5
+ export { DictionaryField } from './DictionaryField';
5
6
  export { EnumField } from './EnumField';
6
7
  export { FieldError } from './FieldError';
7
8
  export { JsonField } from './JsonField';
@@ -0,0 +1,16 @@
1
+ import { Control, FieldValues } from 'react-hook-form';
2
+ import { Schema } from 'src/types/Schema';
3
+ type EntryValueRendererProps<T extends FieldValues = FieldValues> = {
4
+ fieldName: string;
5
+ entryKey: string;
6
+ valueSchema: Schema | null;
7
+ control: Control<T>;
8
+ };
9
+ /**
10
+ * Renders the value part of a dictionary entry.
11
+ * Object schemas are rendered as nested SchemaFields, scalar schemas
12
+ * get a single field input via DefaultFieldRenderer. Shared by
13
+ * DictionaryEntry (used by DictionaryField for both regular and pattern dictionaries).
14
+ */
15
+ export declare function EntryValueRenderer<T extends FieldValues = FieldValues>({ fieldName, entryKey, valueSchema, control, }: EntryValueRendererProps<T>): import("react/jsx-runtime").JSX.Element | null;
16
+ export {};
@@ -0,0 +1,5 @@
1
+ type OnChange = (value: Record<string, unknown>) => void;
2
+ export declare const generateUniqueKey: (existingKeys: string[]) => string;
3
+ export declare const removeEntry: (currentValue: Record<string, unknown>, keyToRemove: string, onChange: OnChange) => void;
4
+ export declare const renameEntry: (currentValue: Record<string, unknown>, oldKey: string, newKey: string, onChange: OnChange) => void;
5
+ export {};