Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes #22

Merged
merged 2 commits into from
Nov 9, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Small changes",
"type": "patch",
"packageName": "@ilbrando/simple-form-joy"
}
],
"packageName": "@ilbrando/simple-form-joy",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Small changes",
"type": "patch",
"packageName": "@ilbrando/simple-form-material-ui"
}
],
"packageName": "@ilbrando/simple-form-material-ui",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Small changes",
"type": "patch",
"packageName": "@ilbrando/simple-form"
}
],
"packageName": "@ilbrando/simple-form",
"email": "[email protected]"
}
11 changes: 11 additions & 0 deletions common/changes/@ilbrando/utils/small-fixes_2024-11-09-11-57.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Small changes",
"type": "patch",
"packageName": "@ilbrando/utils"
}
],
"packageName": "@ilbrando/utils",
"email": "[email protected]"
}
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>;
Loading