Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/form/src/json-schema-form.def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ customElements.define('json-schema-form', Jsf);

declare global {
interface HTMLElementTagNameMap {
'json-schema-form': Jsf;
'json-schema-form': Jsf<unknown>;
}
}
7 changes: 4 additions & 3 deletions packages/form/src/json-schema-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@ import type {
JSONSchema7,
} from '@jsfe/types';

export class Jsf extends LitElement {
export class Jsf<TData> extends LitElement {
@property({ type: Object }) public schema: JSONSchema7 = {};

@property({ type: Object }) public data: unknown = {};
// @ts-expect-error TData might not extend {}, but we can't fix until the next breaking change
@property({ type: Object }) public data: TData = {};

@property({ type: Object }) public uiSchema: UiSchema = {};

public submitCallback: OnFormSubmit = () => {};

public dataChangeCallback: DataChangeCallback = () => {};
public dataChangeCallback: DataChangeCallback<TData> = () => {};

@property({ type: Object }) public widgets: Widgets = {};

Expand Down
2 changes: 1 addition & 1 deletion packages/form/src/triage/array-primitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const fieldArrayPrimitive = (
uiState: unknown,
uiOptions: UiSchema,
required: boolean,
handleChange: Jsf['_handleChange'],
handleChange: Jsf<unknown>['_handleChange'],
// dig: Jsf['_dig'],
schemaPath: Path,
widgets: Widgets,
Expand Down
4 changes: 2 additions & 2 deletions packages/form/src/triage/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export const fieldArray = (
path: Path,
uiState: unknown,
uiOptions: UiSchema,
handleChange: Jsf['_handleChange'],
dig: Jsf['_dig'],
handleChange: Jsf<unknown>['_handleChange'],
dig: Jsf<unknown>['_dig'],
schemaPath: Path,
widgets: Widgets,
required = false,
Expand Down
2 changes: 1 addition & 1 deletion packages/form/src/triage/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const fieldObject = (
path: Path,
uiState: unknown,
uiSchema: UiSchema,
dig: Jsf['_dig'],
dig: Jsf<unknown>['_dig'],
schemaPath: Path,
widgets: Widgets,
level = 0,
Expand Down
4 changes: 2 additions & 2 deletions packages/form/src/triage/primitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export const fieldPrimitive = (
path: Path,
uiOptions: UiSchema,
required: boolean,
handleChange: Jsf['_handleChange'],
handleKeydown: Jsf['_handleKeydown'],
handleChange: Jsf<unknown>['_handleChange'],
handleKeydown: Jsf<unknown>['_handleKeydown'],
schemaPath: Path,

widgets: Widgets,
Expand Down
2 changes: 1 addition & 1 deletion packages/shoelace/src/form.def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ customElements.define('jsf-shoelace', JsfShoelace);

declare global {
interface HTMLElementTagNameMap {
'jsf-shoelace': JsfShoelace;
'jsf-shoelace': JsfShoelace<unknown>;
}
}
2 changes: 1 addition & 1 deletion packages/shoelace/src/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Jsf } from '@jsfe/form';
import * as widgets from './widgets/index.js';
import { styles } from './styles.js';

export class JsfShoelace extends Jsf {
export class JsfShoelace<TData> extends Jsf<TData> {
public widgets = widgets;

public styleSheets = [styles];
Expand Down
4 changes: 2 additions & 2 deletions packages/types/src/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export interface FeatureFlags {
additionalProperties?: boolean;
}

export type DataChangeCallback = (
newData: unknown,
export type DataChangeCallback<TData> = (
newData: TData,
path: Path,
value: unknown,
schemaPath: Path,
Expand Down