mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-05 00:03:08 +00:00
dd419ade94
* 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
87 lines
1.6 KiB
Svelte
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
|
|
}}
|
|
/>
|