Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ilbrando committed Nov 9, 2024
1 parent 5cad6d0 commit afc4238
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions examples/joy/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import { StrictMode } from "react";
import ReactDOM from "react-dom/client";
import { moduleAugmentation as _ } from "@ilbrando/simple-form-joy";
import { Box, CssBaseline, extendTheme, ThemeProvider } from "@mui/joy";
Expand All @@ -12,12 +12,12 @@ const theme = extendTheme({
});

ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<StrictMode>
<CssBaseline />
<ThemeProvider theme={theme}>
<Box height="100%" maxWidth="1024px" p={4}>
<Persons />
</Box>
</ThemeProvider>
</React.StrictMode>
</StrictMode>
);
2 changes: 1 addition & 1 deletion examples/joy/src/persons-example/person-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const PersonDialog = (props: PersonDialogProps) => {

const handleSubmit = async () => {
if (fm.validateForm()) {
/** the props on `fm.values` can always be null, but when validation is performed, we know which props are guarantied to have a value - ensureValue will throw if this assumption don't hold. */
/** the props on `fm.values` can always be null, but when validation is performed, we know which props are guarantied to have a value - ensureValue will throw if this assumption doesn't hold. */
const updatedPerson: Person = {
id: id ?? ensureValue(fm.values.id),
name: ensureValue(fm.values.name),
Expand Down
2 changes: 1 addition & 1 deletion packages/simple-form-joy/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ilbrando/simple-form-joy",
"version": "2.1.0",
"description": "MUI joy components for @ilbrando/simple-form",
"description": "MUI Joy components for @ilbrando/simple-form",
"license": "MIT",
"author": {
"name": "ilbrando"
Expand Down
2 changes: 1 addition & 1 deletion packages/simple-form-material-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ilbrando/simple-form-material-ui",
"version": "3.0.1",
"description": "MUI material-ui components for @ilbrando/simple-form",
"description": "MUI Material-UI components for @ilbrando/simple-form",
"license": "MIT",
"author": {
"name": "ilbrando"
Expand Down
2 changes: 1 addition & 1 deletion packages/simple-form/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ilbrando/simple-form",
"version": "1.0.2",
"description": "Simple form tools for react",
"description": "Simple form tools for React",
"license": "MIT",
"author": {
"name": "ilbrando"
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ilbrando/utils",
"version": "1.0.1",
"description": "General typescript utilities",
"description": "General TypeScript utilities",
"license": "MIT",
"author": {
"name": "ilbrando"
Expand Down
7 changes: 3 additions & 4 deletions packages/utils/src/utils/object-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ export const hasValueAndNotEmptyString = <T>(value: T | undefined | null): value
};

/** You can use this when the Typescript compiler can't determine that a value is not
* `null` or ùndefined`. If the values i `null` or `undefined` an `Error` is thrown.
* `null` or `undefined`. If the values i `null` or `undefined` an `Error` is thrown.
* You can provide the message for the error to help identifying where in the code the
* error happened.
*
* @example
* const someFunction = (value: number) => console.log(number);
* const someNumber: number | undefined = 42;
* if (hasValue(someNumber)) someFunction(someNumber);
* const someValue: number | undefined = 42;
* const value = ensure(someValue); // => number (or throws)
*/
export const ensureValue = <T>(value: Maybe<T>, message?: string): T => {
if (value === undefined) throw Error(`ensureValue (value is undefined): ${message ?? "did not expect this"}.`);
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/src/utils/type-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export type InferArrayItem<T> = T extends Array<infer I> ? I : never;
*
* @example
* type S = "a" | "b";
* const s = "a"; // intellisense will show "a" and "b".
* const x = "y"; // but all other strings are also valid
* const s: Arbitrary<S> = "a"; // intellisense will show "a" and "b".
* const x: Arbitrary<S> = "y"; // but all other strings are also valid
*/
export type Arbitrary<T extends string> = T | Omit<string, T>;

0 comments on commit afc4238

Please sign in to comment.