문서 입력 폼

UIQuantityField

수량과 단위를 함께 입력합니다.

기본 사용법

단위가 붙은 길이 입력

기준 단위와 단위계를 지정하면 입력 옆에 표시 단위가 나타납니다. 확정한 수량은 v-model로 읽습니다.

m
확정한 길이 1.25 m
<script setup lang="ts">
import { UIQuantityField } from "@connextable/ui";
import { ref } from "vue";

const length = ref<{ value: string; unit: string } | null>({
  value: "1.25",
  unit: "metre",
});
</script>

<template>
  <UIQuantityField
    v-model="length"
    unit="metre"
    unit-system="metric"
    label="길이"
    placeholder="예: 1.25"
    clearable
  />
</template>

설정과 동작

단위와 값을 함께 확정

새 수량을 입력하고 Enter를 눌러 확정값을 확인합니다. 지우면 미입력 상태로 돌아갑니다.

확정된 길이

값이나 단위 변경을 잠급니다.

실전 예제

표시 단위 환산

포장 길이와 배송 무게의 표시 단위를 바꿔 보세요. 입력 숫자가 환산되고 아래의 기준값은 유지됩니다.

구성 컴포넌트

값 입력과 선택

UIQuantityFieldInput

키보드로 값을 입력하거나 수정하는 요소입니다.

UIQuantityFieldUnitSelect

같은 수량을 표시할 다른 단위를 선택하는 영역입니다.

값과 상태 표시

UIQuantityFieldValue

수량 필드를 직접 조립할 때 확정값과 표시 단위를 슬롯으로 읽는 구성 요소입니다.

주요 API

속성과 모델

v-model타입QuantityValue | null | undefined

확정한 수치와 기준 단위를 읽고 변경합니다.

단위와 값을 함께 확정 예제
v-model:display-unit타입string | undefined

입력에 표시하는 단위를 읽고 변경합니다.

표시 단위 환산 예제
unit타입string | string | undefined

확정값에 사용할 기준 단위입니다.

단위와 값을 함께 확정 예제
unit-system타입StandardQuantityUnitSystem | undefined

표준 단위계를 지정합니다. metric, imperial, all을 지원하며 기본값은 all입니다.

단위와 값을 함께 확정 예제
policies타입QuantityFieldPolicies | undefined | QuantityFieldPolicies

사용자 정의 단위 등록부와 변환 규칙을 전달할 때 사용합니다.

placeholder타입string기본값수량 입력

수치가 비어 있을 때 표시합니다. 입력 단위는 필드 끝에서 확인할 수 있습니다.

단위가 붙은 길이 입력 예제
display-units타입readonly string[] | undefined

사용자가 바꿀 수 있는 표시 단위의 목록입니다.

표시 단위 환산 예제

입력 상태

readonly타입boolean

값을 유지하고 사용자 조작으로 변경되는 것을 막습니다. 읽기와 탐색은 계속 지원합니다.

확정된 길이 예제
disabled타입boolean

입력과 선택을 비활성화합니다. 네이티브 입력은 Tab 순서에서 빠집니다.

팩토리와 유틸리티

createUIStandardQuantityPolicies

기준 단위와 단위계를 사용해 수량을 해석하고 환산합니다.

전체 속성, 이벤트와 슬롯

UIQuantityField

as
PrimitiveAs | undefined
as-child
boolean | undefined
disabled
boolean | undefined
label
string | undefined
model-value
QuantityValue | null | undefined
default-value
QuantityValue | null | undefined
readonly
boolean | undefined
display-unit
string | undefined
default-display-unit
string | undefined
unit
string | string | undefined
policies
QuantityFieldPolicies | undefined | QuantityFieldPolicies
unit-system
StandardQuantityUnitSystem | undefined
id
string | undefined
name
string | undefined
form
string | undefined
required
boolean | undefined
placeholder
string | undefined
display-units
readonly string[] | undefined
@commit
(details: Pick<QuantityFieldRootSlotProps, "value" | "displayUnit"> & { expression: string; }) => any
@update:model-value
(value: QuantityValue | null) => any
@update:display-unit
(unit: string) => any
clearable
boolean | undefined
clear-label
string | undefined
#default
(state: QuantityFieldRootSlotProps) => unknown

UIQuantityFieldInput

name
string | undefined
form
string | undefined
required
boolean | undefined
as
PrimitiveAs | undefined
as-child
boolean | undefined

UIQuantityFieldUnitSelect

as
PrimitiveAs | undefined
as-child
boolean | undefined

UIQuantityFieldValue

as
PrimitiveAs | undefined
as-child
boolean | undefined
#default
(props: QuantityFieldRootSlotProps) => VNodeChild