Files
windmill/frontend/src/lib/components/IntegerInput.svelte
T
Guilhem dd419ade94 fix(frontend): redesign instance settings (#7916)
* handle dirty config

* Move instance update in drawer actions

* Put windmill version in drawer header

* Use sidebar instead of tabs

* Rework user section

* improve user table

* Handle EE

* Add settings section header

* test-1

* option 2

* create new settings group

* harmonize all settings inputs

* improve members/users table styling

* refactor instance setup

* show user count

* nit

* Create setting card component

* harmonize instance settings and workspace settings

* fix python version loader

* nit

* clean code

* nit

* add email validation

* fix reactivity issue on default value

* fix dirty config check

* fix object storage dirty config check

* Fix object storage settings reactivity

* fix indexer dirty reactivity

* Add validation for indexer

* fix sso dirty issues

* clean

* nit
2026-02-12 09:50:01 +00:00

87 lines
1.6 KiB
Svelte

<script lang="ts">
import TextInput from './text_input/TextInput.svelte'
import type { ButtonType } from './common/button/model'
import { untrack } from 'svelte'
interface Props {
value?: number
oninput?: (value: number | undefined) => void
placeholder?: string
id?: string
disabled?: boolean
error?: string
class?: string
size?: ButtonType.UnifiedSize
}
let {
value,
oninput,
placeholder,
id,
disabled,
error = '',
class: className = '',
size
}: Props = $props()
let displayValue: string | number = $state('')
$effect(() => {
const incoming = value
const current = String(untrack(() => displayValue))
const currentNum = current === '' ? undefined : Number(current)
if (incoming !== currentNum) {
displayValue = incoming != null ? String(incoming) : ''
}
})
function handleKeydown(e: KeyboardEvent) {
if (e.ctrlKey || e.metaKey) return
if (
!/[0-9]/.test(e.key) &&
![
'Backspace',
'Delete',
'ArrowLeft',
'ArrowRight',
'ArrowUp',
'ArrowDown',
'Tab',
'Enter'
].includes(e.key)
) {
e.preventDefault()
}
}
function handleInput(e: Event) {
if (e.target instanceof HTMLInputElement) {
const raw = e.target.value.replace(/[^0-9]/g, '')
e.target.value = raw
displayValue = raw
if (raw === '') {
oninput?.(undefined)
return
}
oninput?.(Number(raw))
}
}
</script>
<TextInput
{size}
class={className}
{error}
value={displayValue}
inputProps={{
type: 'number',
inputmode: 'numeric',
placeholder,
id,
disabled,
onkeydown: handleKeydown,
oninput: handleInput
}}
/>