Skip to content

Commit

Permalink
Checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
fortezhuo committed Aug 30, 2023
1 parent a71041d commit ad4f6f8
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tawasukha/ui",
"version": "0.0.61",
"version": "0.0.62",
"type": "module",
"types": "dist/index.d.ts",
"exports": {
Expand Down
12 changes: 9 additions & 3 deletions src/components/dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react"
import React, { useEffect } from "react"
import { InputText } from "./inputText"
import { RawTextArea } from "./inputTextArea"
import { create } from "./modal-promise"
Expand Down Expand Up @@ -38,9 +38,15 @@ function useDialogInput({

const Input = React.useMemo(() => {
return !option ? null : option === "input" ? (
<InputText placeholder={placeholder} className="mt-2" ref={refInput} onKeyDown={onKeyDown} />
<InputText
autoFocus
placeholder={placeholder}
className="mt-2"
ref={refInput}
onKeyDown={onKeyDown}
/>
) : (
<RawTextArea placeholder={placeholder} className="mt-2 h-28" ref={refInput} />
<RawTextArea autoFocus placeholder={placeholder} className="mt-2 h-28" ref={refInput} />
)
}, [])

Expand Down
14 changes: 5 additions & 9 deletions src/components/inputNumber.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NumericFormat, type NumericFormatProps } from "react-number-format"
import { cva, type VariantProps } from "../helpers/cva"
import { forwardRef, useMemo } from "react"
import { forwardRef, useCallback, useMemo, useRef } from "react"

const _input = cva(
[
Expand Down Expand Up @@ -37,14 +37,10 @@ export interface InputNumberProps
onChange?: (value: number | undefined) => void
}

export const InputNumber = forwardRef<HTMLInputElement,InputNumberProps>(function InputNumber({
mode = "base",
className,
onChange,
value: _value,
decimal,
...props
},ref) {
export const InputNumber = forwardRef<HTMLInputElement, InputNumberProps>(function InputNumber(
{ mode = "base", className, onChange, value: _value, decimal, ...props },
ref,
) {
const value = useMemo(() => numberParser(_value), [_value])
const decimalScale = useMemo(
() => (decimal ? (typeof decimal === "boolean" ? 2 : decimal) : 0),
Expand Down
34 changes: 18 additions & 16 deletions src/components/inputPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,23 @@ const _input = cva(

export interface InputPasswordProps extends Omit<InputProps, "type">, VariantProps<typeof _input> {}

export const InputPassword = forwardRef<HTMLInputElement,InputPasswordProps>(function InputPassword({ mode = "base", className, ...props },ref) {
const { value, toggle, eye } = useEye(mode)
export const InputPassword = forwardRef<HTMLInputElement, InputPasswordProps>(
function InputPassword({ mode = "base", className, ...props }, ref) {
const { value, toggle, eye } = useEye(mode)

return (
<div className="relative flex items-center">
<button onClick={toggle} className="absolute right-3 focus:outline-none">
{eye}
</button>
return (
<div className="relative flex items-center">
<button type="button" onClick={toggle} className="absolute right-3 focus:outline-none">
{eye}
</button>

<input
ref={ref}
type={value ? "text" : "password"}
{...props}
className={_input({ mode, className })}
/>
</div>
)
})
<input
ref={ref}
type={value ? "text" : "password"}
{...props}
className={_input({ mode, className })}
/>
</div>
)
},
)
1 change: 1 addition & 0 deletions src/components/inputSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ export const InputSelect = forwardRef(function InputSelect<T>(
>
{multiple ? displayValue : isOpen ? <span></span> : displayValue}
<input
disabled={disabled}
placeholder="Select ..."
className={cx(
"place-base-3 bg-[transparent!important] focus:outline-none text-md",
Expand Down
7 changes: 5 additions & 2 deletions src/components/upload/Uploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ProgressBar } from "./ProgressBar"
import { useDropzone, type Accept } from "react-dropzone"
import { useCallback, useState } from "react"
import { uploadFile } from "./util"
import { cx } from "src/helpers"

export type UploaderProps = {
responseKey?: string
Expand Down Expand Up @@ -54,8 +55,10 @@ export function Uploader({
return (
<div
{...getRootProps({
className:
"relative flex flex-col p-4 w-40 items-center justify-center border rounded-lg border-base-2 h-28 cursor-pointer border-dashed",
className: cx(
"relative flex flex-col p-4 items-center justify-center rounded-lg",
disabled ? "" : "w-40 border border-base-2 h-28 cursor-pointer border-dashed",
),
})}
>
{progress === 0 ? (
Expand Down

0 comments on commit ad4f6f8

Please sign in to comment.