-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
117 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
packages/slice-machine/src/legacy/lib/models/common/widgets/Table/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Table } from "@prismicio/types-internal/lib/customtypes/widgets/nestable"; | ||
import { FaTable } from "react-icons/fa"; | ||
import * as yup from "yup"; | ||
|
||
import { DefaultFields } from "../../../../forms/defaults"; | ||
import { Widget } from "../Widget"; | ||
|
||
/** : { | ||
"type" : "Table", | ||
"config" : { | ||
"label" : "Gable's Fabled Table" | ||
} | ||
} */ | ||
|
||
const FormFields = { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access | ||
label: DefaultFields.label, | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access | ||
id: DefaultFields.id, | ||
}; | ||
|
||
const schema = yup.object().shape({ | ||
type: yup | ||
.string() | ||
.matches(/^Table$/, { excludeEmptyString: true }) | ||
.required(), | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call | ||
config: yup | ||
.object() | ||
.shape({ | ||
label: yup.string(), | ||
}) | ||
.required() | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
.default(undefined) | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
.noUnknown(true), | ||
}); | ||
|
||
const Meta = { | ||
icon: FaTable, | ||
}; | ||
|
||
export const TableWidget: Widget<Table, typeof schema> = { | ||
create: (label: string) => ({ | ||
type: "Table", | ||
config: { | ||
label, | ||
}, | ||
}), | ||
FormFields, | ||
TYPE_NAME: "Table", | ||
schema, | ||
Meta, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters