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
5 changes: 5 additions & 0 deletions .changeset/light-things-see.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@devup-ui/components': patch
---

Fix component warning
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ jobs:
node-version: 22
cache: 'pnpm'
- run: pnpm i
- run: pnpm build
- run: |
pnpm build
pnpm lint
# rust coverage issue
echo 'max_width = 100000' > .rustfmt.toml
Expand All @@ -83,8 +83,8 @@ jobs:
echo 'merge_derives = true' >> .rustfmt.toml
echo 'use_small_heuristics = "Default"' >> .rustfmt.toml
cargo fmt
pnpm test
rm -rf .rustfmt.toml
- run: pnpm test
- name: Build Landing
run: |
pnpm -F components build-storybook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Stepper', () => {
<Stepper>
<StepperContainer>
<StepperDecreaseButton />
<StepperInput editable={false} />
<StepperInput />
<StepperIncreaseButton />
</StepperContainer>
</Stepper>,
Expand All @@ -24,7 +24,7 @@ describe('Stepper', () => {

it('should throw error if children are used outside of StepperProvider', () => {
expect(() => {
render(<StepperInput editable={false} />)
render(<StepperInput />)
}).toThrow('useStepper must be used within a StepperProvider')
})

Expand Down
26 changes: 15 additions & 11 deletions packages/components/src/components/Stepper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ function StepperIncreaseButton({ ...props }: ComponentProps<typeof Button>) {
)
}

interface StepperInputProps extends ComponentProps<typeof Input> {
editable?: boolean
}
type StepperInputProps = ComponentProps<typeof Input>

function StepperInput({ className, ...props }: StepperInputProps) {
const { value, setValue, type } = useStepper()
Expand All @@ -144,12 +142,15 @@ function StepperInput({ className, ...props }: StepperInputProps) {
h: 'fit-content',
styleOrder: 3,
})
const editable = type === 'input'
const Comp = editable ? Input : 'div'
const isInput = type === 'input'
const Comp = isInput ? Input : 'div'
if (isInput) {
// div tag doesn't support allowClear prop
Object.assign(props, { allowClear: false })
}

return (
<Comp
allowClear={false}
aria-label="Stepper value"
className={clsx(
css({
Expand All @@ -163,17 +164,20 @@ function StepperInput({ className, ...props }: StepperInputProps) {
},
},
}),
!editable && notEditableClass,
!isInput && notEditableClass,
className,
)}
dangerouslySetInnerHTML={
editable ? undefined : { __html: Number(value).toString() }
isInput ? undefined : { __html: Number(value).toString() }
}
data-value={value}
onChange={(e) => setValue(Number(e.target.value))}
readOnly={!editable}
onChange={(e) => {
setValue(Number(e.target.value))
}}
readOnly={!isInput}
type="number"
value={value}
// Fix prefix 0 issue
value={value.toString()}
{...props}
/>
)
Expand Down