Skip to content
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
4 changes: 2 additions & 2 deletions apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"typecheck": "tsc --noEmit -p tsconfig.vitest.json --composite false"
},
"dependencies": {
"@prefabs.tech/tsconfig": "0.2.0",
"@prefabs.tech/tsconfig": "0.2.1",
"@prefabs.tech/react-config": "0.71.0",
"@prefabs.tech/react-form": "0.71.0",
"@prefabs.tech/react-i18n": "0.71.0",
Expand All @@ -36,7 +36,7 @@
"zod": "3.23.8"
},
"devDependencies": {
"@prefabs.tech/eslint-config": "0.2.0",
"@prefabs.tech/eslint-config": "0.2.1",
"@babel/core": "7.26.10",
"@babel/plugin-syntax-flow": "7.26.0",
"@babel/plugin-transform-react-jsx": "^7.21.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,14 @@ fallbackLocale = np;
<Section title={t("countryDisplay.customFlagsPath", "Custom Flag Path")}>
<Country code="CA" flagsPath={customFlagsPath} />
<CodeBlock
exampleCode='const flagsPath = (code: string) => {
return `https://flagcdn.com/${code.toLowerCase().trim()}.svg`;
exampleCode={`const flagsPath = (code: string) => {
return \`https://flagcdn.com/\${code.toLowerCase().trim()}.svg\`;
};

<Country
code="CA"
flagsPath={customFlagsPath}
/>'
/>`}
/>
</Section>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,11 @@ const [singleSelectValue, setSingleSelectValue] = useState<string>("");
onChange={(value: string) => setCustomFlagsSelectValue(value)}
/>
<CodeBlock
exampleCode='
exampleCode={`
const [singleSelectValue, setSingleSelectValue] = useState<string>("");

const flagsPath = (code: string) => {
return `https://flagcdn.com/${code.toLowerCase().trim()}.svg`;
return \`https://flagcdn.com/\${code.toLowerCase().trim()}.svg\`;
};

<CountryPicker
Expand All @@ -373,7 +373,7 @@ const flagsPath = (code: string) => {
placeholder={t("countryPicker.placeholders.single")}
value={singleSelectValue}
onChange={(value: string) => setSingleSelectValue(value)}
/>'
/>`}
/>
</Section>

Expand Down
4 changes: 3 additions & 1 deletion apps/demo/src/Views/Ui/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ export const TableDemo = () => {

const date = new Date(rowData as Date);

if (isNaN(date.getTime())) return false;
if (isNaN(date.getTime())) {
return false;
}

return (
value[0].getTime() <= date.getTime() &&
Expand Down
4 changes: 3 additions & 1 deletion apps/demo/src/components/Demo/CodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ export const CodeBlock = ({
};

const renderHeader = () => {
if (!title && !subheader) return null;
if (!title && !subheader) {
return null;
}

return (
<header>
Expand Down
4 changes: 2 additions & 2 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"typecheck": "tsc --noEmit -p tsconfig.vitest.json --composite false"
},
"devDependencies": {
"@prefabs.tech/eslint-config": "0.2.0",
"@prefabs.tech/tsconfig": "0.2.0",
"@prefabs.tech/eslint-config": "0.2.1",
"@prefabs.tech/tsconfig": "0.2.1",
"@types/jsdom": "21.1.7",
"@types/node": "24.10.1",
"@types/react": "18.3.20",
Expand Down
4 changes: 2 additions & 2 deletions packages/form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"zod": "3.23.8"
},
"devDependencies": {
"@prefabs.tech/eslint-config": "0.2.0",
"@prefabs.tech/tsconfig": "0.2.0",
"@prefabs.tech/eslint-config": "0.2.1",
"@prefabs.tech/tsconfig": "0.2.1",
"@prefabs.tech/react-ui": "0.71.0",
"@testing-library/react": "16.3.0",
"@types/jsdom": "21.1.7",
Expand Down
13 changes: 10 additions & 3 deletions packages/form/src/components/CurrencyPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ export const CurrencyPicker = <T extends string | number>({
const { error, invalid } = getFieldState(name);

const checkInvalidState = () => {
if (showInvalidState && invalid) return true;
if (showValidState && !invalid) return false;
if (showInvalidState && invalid) {
return true;
}

if (showValidState && !invalid) {
return false;
}
};

//TODO [MA 2024-05-31]: remove this redundant useEffect for auto selecting single option
Expand All @@ -59,7 +64,9 @@ export const CurrencyPicker = <T extends string | number>({
name={name}
rules={{
validate: (value: T[] | T) => {
if (!multiple || !Array.isArray(value)) return;
if (!multiple || !Array.isArray(value)) {
return;
}

const count = value.length;

Expand Down
16 changes: 12 additions & 4 deletions packages/form/src/components/DateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export const DateInput: React.FC<IDateInput> = ({
register,
getFieldState,
}) => {
if (!register || !getFieldState) return null;
if (!register || !getFieldState) {
return null;
}

const inputReference = useRef<HTMLInputElement | null>(null);

Expand All @@ -42,9 +44,13 @@ export const DateInput: React.FC<IDateInput> = ({
const { ref, ...rest } = register(name);

const checkInvalidState = () => {
if (showInvalidState && invalid) return true;
if (showInvalidState && invalid) {
return true;
}

if (showValidState && !invalid) return false;
if (showValidState && !invalid) {
return false;
}
};

const handleClick = () => {
Expand All @@ -54,7 +60,9 @@ export const DateInput: React.FC<IDateInput> = ({
};

const convertToDateString = (value: string | number | Date | undefined) => {
if (!value) return undefined;
if (!value) {
return undefined;
}

const date = new Date(value);

Expand Down
13 changes: 10 additions & 3 deletions packages/form/src/components/DaysInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export const DaysInput: React.FC<IDaysInputField> = ({
register,
...others
}) => {
if (!register || !getFieldState) return null;
if (!register || !getFieldState) {
return null;
}

const updatedRegister = register(name, {
setValueAs: (value) => {
Expand All @@ -38,8 +40,13 @@ export const DaysInput: React.FC<IDaysInputField> = ({
const { error, isDirty, isTouched, invalid } = getFieldState(name);

let inputClassName = "";
if (isDirty && !invalid) inputClassName = "valid";
if (isTouched && invalid) inputClassName = "invalid";
if (isDirty && !invalid) {
inputClassName = "valid";
}

if (isTouched && invalid) {
inputClassName = "invalid";
}

return (
<div className={`field ${className}`.trimEnd()}>
Expand Down
9 changes: 7 additions & 2 deletions packages/form/src/components/Email.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ export const Email: React.FC<IProperties> = ({
const { error, invalid } = getFieldState(name);

const checkInvalidState = () => {
if (showInvalidState && invalid) return true;
if (showValidState && !invalid) return false;
if (showInvalidState && invalid) {
return true;
}

if (showValidState && !invalid) {
return false;
}
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const FileInputBasic: FC<IFileInputBasicProperties> = ({
const renderInputUi = () => {
const { onClick } = getRootProps();

if (inputMethod == "button")
if (inputMethod == "button") {
return (
<div className="input-button-wrapper">
<Button
Expand All @@ -74,6 +74,7 @@ export const FileInputBasic: FC<IFileInputBasicProperties> = ({
<input id={name} name={name} {...getInputProps()} />
</div>
);
}

return (
<div {...getRootProps({ className })}>
Expand Down
9 changes: 7 additions & 2 deletions packages/form/src/components/NumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ export const NumberInput = ({
const { error, invalid } = getFieldState(name);

const checkInvalidState = () => {
if (showInvalidState && invalid) return true;
if (showValidState && !invalid) return false;
if (showInvalidState && invalid) {
return true;
}

if (showValidState && !invalid) {
return false;
}
};

return (
Expand Down
12 changes: 9 additions & 3 deletions packages/form/src/components/Password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@ export const Password: React.FC<CustomInputProperties & IInputProperties> = ({
submitCount = 0,
...others
}) => {
if (!register || !getFieldState) return null;
if (!register || !getFieldState) {
return null;
}

const { error, invalid } = getFieldState(name);
const [showPassword, setShowPassword] = useState(false);

const checkInvalidState = () => {
if (showInvalidState && invalid) return true;
if (showInvalidState && invalid) {
return true;
}

if (showValidState && !invalid) return false;
if (showValidState && !invalid) {
return false;
}
};

return (
Expand Down
9 changes: 7 additions & 2 deletions packages/form/src/components/RadioInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ export const RadioInput: React.FC<IRadioInput> = ({
const { error, invalid } = getFieldState(name);

const checkInvalidState = () => {
if (showInvalidState && invalid) return true;
if (showValidState && !invalid) return false;
if (showInvalidState && invalid) {
return true;
}

if (showValidState && !invalid) {
return false;
}
};

return (
Expand Down
13 changes: 10 additions & 3 deletions packages/form/src/components/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ export const Select = <T extends string | number>({
const { error, invalid } = getFieldState(name);

const checkInvalidState = () => {
if (showInvalidState && invalid) return true;
if (showValidState && !invalid) return false;
if (showInvalidState && invalid) {
return true;
}

if (showValidState && !invalid) {
return false;
}
};

const flatOptions = useMemo(() => {
Expand Down Expand Up @@ -71,7 +76,9 @@ export const Select = <T extends string | number>({
defaultValue={multiple ? [] : undefined}
rules={{
validate: (value: T[] | T) => {
if (!multiple || !Array.isArray(value)) return;
if (!multiple || !Array.isArray(value)) {
return;
}

const count = value.length;

Expand Down
9 changes: 7 additions & 2 deletions packages/form/src/components/SwitchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ export const SwitchInput: React.FC<ISwitch> = ({
const { error, invalid } = getFieldState(name);

const checkInvalidState = () => {
if (showInvalidState && invalid) return true;
if (showValidState && !invalid) return false;
if (showInvalidState && invalid) {
return true;
}

if (showValidState && !invalid) {
return false;
}
};

return (
Expand Down
9 changes: 7 additions & 2 deletions packages/form/src/components/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ export const TextInput: React.FC<ITextInput> = ({
const { error, invalid } = getFieldState(name);

const checkInvalidState = () => {
if (showInvalidState && invalid) return true;
if (showValidState && !invalid) return false;
if (showInvalidState && invalid) {
return true;
}

if (showValidState && !invalid) {
return false;
}
};

return (
Expand Down
9 changes: 7 additions & 2 deletions packages/form/src/components/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ export const Textarea: React.FC<ITextarea> = ({
const { error, invalid } = getFieldState(name);

const checkInvalidState = () => {
if (showInvalidState && invalid) return true;
if (showValidState && !invalid) return false;
if (showInvalidState && invalid) {
return true;
}

if (showValidState && !invalid) {
return false;
}
};

return (
Expand Down
9 changes: 7 additions & 2 deletions packages/form/src/components/Typeahead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ export const Typeahead = <T extends Suggestion>({
const { error, invalid } = getFieldState(name);

const checkInvalidState = () => {
if (showInvalidState && invalid) return true;
if (showValidState && !invalid) return false;
if (showInvalidState && invalid) {
return true;
}

if (showValidState && !invalid) {
return false;
}
};

return (
Expand Down
4 changes: 2 additions & 2 deletions packages/i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"react-i18next": "15.4.1"
},
"devDependencies": {
"@prefabs.tech/eslint-config": "0.2.0",
"@prefabs.tech/tsconfig": "0.2.0",
"@prefabs.tech/eslint-config": "0.2.1",
"@prefabs.tech/tsconfig": "0.2.1",
"@prefabs.tech/react-config": "0.71.0",
"@testing-library/react": "16.3.0",
"@types/jsdom": "21.1.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { render, fireEvent, screen } from "@testing-library/react";
import React from "react";
import { expect, test } from "vitest";

import i18n from "../../../index";
import { default as i18n } from "../../../index";
import LocaleSwitcher from "../../LocaleSwitcher";

test.skip("Local switcher dropdown is displayed and locale is changed", async () => {
Expand Down
Loading