From 0d821b1eb5ee86e2e5e4c0530514a88114af6826 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia Date: Fri, 6 Oct 2023 14:57:26 +0530 Subject: [PATCH 01/15] chore: swap input component with plane/ui package --- packages/ui/dist/index.d.ts | 4 +- packages/ui/dist/index.js | 4 +- packages/ui/dist/index.mjs | 4 +- packages/ui/src/form-fields/input.tsx | 8 +- web/components/account/email-code-form.tsx | 61 ++++--- .../account/email-password-form.tsx | 59 ++++--- .../account/email-reset-password-form.tsx | 40 +++-- web/components/account/email-signup-form.tsx | 87 ++++++---- .../create-update-analytics-modal.tsx | 36 ++-- .../automation/select-month-modal.tsx | 101 ++++++----- .../command-palette/shortcuts-modal.tsx | 15 +- web/components/core/image-picker-popover.tsx | 60 +++---- .../core/modals/gpt-assistant-modal.tsx | 29 +++- web/components/core/modals/link-modal.tsx | 74 ++++---- .../core/theme/color-picker-input.tsx | 36 ++-- .../core/theme/custom-theme-selector.tsx | 22 ++- .../create-update-estimate-modal.tsx | 162 ++++++++++++------ .../integration/delete-import-modal.tsx | 7 +- .../integration/github/single-user-select.tsx | 12 +- .../integration/jira/give-details.tsx | 101 +++++++---- .../integration/jira/import-users.tsx | 42 ++--- web/components/issues/draft-issue-form.tsx | 27 ++- web/components/issues/form.tsx | 27 ++- .../issues/sidebar-select/label.tsx | 31 ++-- web/components/labels/create-label-modal.tsx | 28 +-- .../labels/create-update-label-inline.tsx | 26 ++- web/components/modules/form.tsx | 40 +++-- web/components/onboarding/invite-members.tsx | 40 ++--- web/components/onboarding/user-details.tsx | 67 ++++---- web/components/pages/page-form.tsx | 35 ++-- .../project/create-project-modal.tsx | 54 +++--- .../project/delete-project-modal.tsx | 27 ++- web/components/project/form.tsx | 39 +++-- .../project/leave-project-modal.tsx | 30 +++- .../project/settings/single-label.tsx | 35 ++-- web/components/states/create-state-modal.tsx | 33 ++-- .../states/create-update-state-inline.tsx | 48 ++++-- web/components/views/form.tsx | 31 ++-- .../web-view/create-update-link-form.tsx | 66 ++++--- .../workspace/create-workspace-form.tsx | 76 ++++---- .../workspace/delete-workspace-modal.tsx | 53 +++--- .../send-workspace-invitation-modal.tsx | 24 +-- web/components/workspace/views/form.tsx | 48 +++--- .../[workspaceSlug]/me/profile/index.tsx | 99 +++++++---- web/pages/[workspaceSlug]/settings/index.tsx | 57 +++--- .../[workspaceSlug]/workspace-views/index.tsx | 29 ++-- web/pages/reset-password.tsx | 77 +++++---- 47 files changed, 1266 insertions(+), 845 deletions(-) diff --git a/packages/ui/dist/index.d.ts b/packages/ui/dist/index.d.ts index d5161da6cc3..4f7437a1d38 100644 --- a/packages/ui/dist/index.d.ts +++ b/packages/ui/dist/index.d.ts @@ -8,10 +8,10 @@ interface InputProps { id: string; value: string; name: string; - onChange: () => void; + onChange: (e: React.ChangeEvent) => void; className?: string; mode?: "primary" | "transparent" | "true-transparent"; - size?: "sm" | "md" | "lg"; + size?: "sm" | "md"; hasError?: boolean; placeholder?: string; disabled?: boolean; diff --git a/packages/ui/dist/index.js b/packages/ui/dist/index.js index e9c8d0e60c2..57d360c3a03 100644 --- a/packages/ui/dist/index.js +++ b/packages/ui/dist/index.js @@ -50,7 +50,7 @@ var Input = React2.forwardRef((props, ref) => { onChange, className = "", mode = "primary", - size = "md", + size = "sm", hasError = false, placeholder = "", disabled = false @@ -64,7 +64,7 @@ var Input = React2.forwardRef((props, ref) => { onChange, placeholder, disabled, - className: `block rounded-md bg-transparent text-sm focus:outline-none placeholder-custom-text-400 ${mode === "primary" ? "rounded-md border border-custom-border-200" : mode === "transparent" ? "rounded border-none bg-transparent ring-0 transition-all focus:ring-1 focus:ring-custom-primary" : mode === "true-transparent" ? "rounded border-none bg-transparent ring-0" : ""} ${hasError ? "border-red-500" : ""} ${hasError && mode === "primary" ? "bg-red-500/20" : ""} ${size === "sm" ? "px-3 py-2" : size === "lg" ? "p-3" : ""} ${className}` + className: `block rounded-md bg-transparent text-sm focus:outline-none placeholder-custom-text-400 ${mode === "primary" ? "rounded-md border border-custom-border-200" : mode === "transparent" ? "rounded border-none bg-transparent ring-0 transition-all focus:ring-1 focus:ring-custom-primary" : mode === "true-transparent" ? "rounded border-none bg-transparent ring-0" : ""} ${hasError ? "border-red-500" : ""} ${hasError && mode === "primary" ? "bg-red-500/20" : ""} ${size === "sm" ? "px-3 py-2" : size === "md" ? "p-3" : ""} ${className}` }); }); Input.displayName = "form-input-field"; diff --git a/packages/ui/dist/index.mjs b/packages/ui/dist/index.mjs index ed0946a3342..42cab7cbd13 100644 --- a/packages/ui/dist/index.mjs +++ b/packages/ui/dist/index.mjs @@ -15,7 +15,7 @@ var Input = React2.forwardRef((props, ref) => { onChange, className = "", mode = "primary", - size = "md", + size = "sm", hasError = false, placeholder = "", disabled = false @@ -29,7 +29,7 @@ var Input = React2.forwardRef((props, ref) => { onChange, placeholder, disabled, - className: `block rounded-md bg-transparent text-sm focus:outline-none placeholder-custom-text-400 ${mode === "primary" ? "rounded-md border border-custom-border-200" : mode === "transparent" ? "rounded border-none bg-transparent ring-0 transition-all focus:ring-1 focus:ring-custom-primary" : mode === "true-transparent" ? "rounded border-none bg-transparent ring-0" : ""} ${hasError ? "border-red-500" : ""} ${hasError && mode === "primary" ? "bg-red-500/20" : ""} ${size === "sm" ? "px-3 py-2" : size === "lg" ? "p-3" : ""} ${className}` + className: `block rounded-md bg-transparent text-sm focus:outline-none placeholder-custom-text-400 ${mode === "primary" ? "rounded-md border border-custom-border-200" : mode === "transparent" ? "rounded border-none bg-transparent ring-0 transition-all focus:ring-1 focus:ring-custom-primary" : mode === "true-transparent" ? "rounded border-none bg-transparent ring-0" : ""} ${hasError ? "border-red-500" : ""} ${hasError && mode === "primary" ? "bg-red-500/20" : ""} ${size === "sm" ? "px-3 py-2" : size === "md" ? "p-3" : ""} ${className}` }); }); Input.displayName = "form-input-field"; diff --git a/packages/ui/src/form-fields/input.tsx b/packages/ui/src/form-fields/input.tsx index 7c93898482f..5a9f9843e91 100644 --- a/packages/ui/src/form-fields/input.tsx +++ b/packages/ui/src/form-fields/input.tsx @@ -5,10 +5,10 @@ export interface InputProps { id: string; value: string; name: string; - onChange: () => void; + onChange: (e: React.ChangeEvent) => void; className?: string; mode?: "primary" | "transparent" | "true-transparent"; - size?: "sm" | "md" | "lg"; + size?: "sm" | "md"; hasError?: boolean; placeholder?: string; disabled?: boolean; @@ -23,7 +23,7 @@ const Input = React.forwardRef((props, ref) => { onChange, className = "", mode = "primary", - size = "md", + size = "sm", hasError = false, placeholder = "", disabled = false, @@ -50,7 +50,7 @@ const Input = React.forwardRef((props, ref) => { } ${hasError ? "border-red-500" : ""} ${ hasError && mode === "primary" ? "bg-red-500/20" : "" } ${ - size === "sm" ? "px-3 py-2" : size === "lg" ? "p-3" : "" + size === "sm" ? "px-3 py-2" : size === "md" ? "p-3" : "" } ${className}`} /> ); diff --git a/web/components/account/email-code-form.tsx b/web/components/account/email-code-form.tsx index 1e68cbb294a..9932b5f0544 100644 --- a/web/components/account/email-code-form.tsx +++ b/web/components/account/email-code-form.tsx @@ -1,8 +1,9 @@ import React, { useEffect, useState } from "react"; -import { useForm } from "react-hook-form"; +import { Controller, useForm } from "react-hook-form"; // ui import { CheckCircleIcon } from "@heroicons/react/20/solid"; -import { Input, PrimaryButton, SecondaryButton } from "components/ui"; +import { PrimaryButton, SecondaryButton } from "components/ui"; +import { Input } from "@plane/ui"; // services import authenticationService from "services/authentication.service"; import useToast from "hooks/use-toast"; @@ -29,6 +30,7 @@ export const EmailCodeForm = ({ handleSignIn }: any) => { const { register, handleSubmit, + control, setError, setValue, getValues, @@ -44,8 +46,7 @@ export const EmailCodeForm = ({ handleSignIn }: any) => { reValidateMode: "onChange", }); - const isResendDisabled = - resendCodeTimer > 0 || isCodeResending || isSubmitting || errorResendingCode; + const isResendDisabled = resendCodeTimer > 0 || isCodeResending || isSubmitting || errorResendingCode; const onSubmit = async ({ email }: EmailCodeFormValues) => { setErrorResendingCode(false); @@ -122,44 +123,58 @@ export const EmailCodeForm = ({ handleSignIn }: any) => { )}
- /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test( value ) || "Email address is not valid", }} - error={errors.email} - placeholder="Enter your email address..." - className="border-custom-border-300 h-[46px]" + render={({ field: { value, onChange, ref } }) => ( + + )} />
{codeSent && ( <> - ( + + )} />