@tide-design/components 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { InputSize } from "../_internal/constants/inputClass.js";
2
- import { MaskFormatOptions, NumericFormatOptions, WithoutNumericOptions } from "./types.js";
2
+ import { MaskFormatOptions, NumericFormatOptions, NumericRangeOptions, WithoutNumericOptions } from "./types.js";
3
3
  import { ComponentProps, ReactElement } from "react";
4
- export interface NumberFormatInputOwnProps extends NumericFormatOptions {
4
+ export interface NumberFormatInputOwnProps extends NumericFormatOptions, NumericRangeOptions {
5
5
  /** 패턴 모드 틀. `#` 자리에 숫자가 들어간다(`"###-####-####"`). 주면 숫자 모드 옵션은 받지 않는다. */
6
6
  mask?: MaskFormatOptions["mask"];
7
7
  /**
@@ -28,12 +28,12 @@ type NumberFormatInputModeProps = {
28
28
  mask?: undefined;
29
29
  value?: number | null;
30
30
  defaultValue?: number | null;
31
- } | (Required<Pick<MaskFormatOptions, "mask">> & WithoutNumericOptions);
31
+ } | (Required<Pick<MaskFormatOptions, "mask">> & WithoutNumericOptions & { [K in keyof NumericRangeOptions]?: undefined; });
32
32
  export type NumberFormatInputProps = NumberFormatInputModeProps & NumberFormatInputOwnProps & Omit<ComponentProps<"input">, keyof NumberFormatInputOwnProps | "type" | "pattern" | "children" | "dangerouslySetInnerHTML">;
33
33
  /**
34
34
  * 칠 때 바로 포맷하는 숫자 입력. 자릿수 묶음·prefix·suffix·소수 자릿수(숫자 모드)와
35
35
  * `mask` 틀(패턴 모드)을 다룬다. `<input type="text">`이고 Field 안에서 label·설명·오류가 연결된다.
36
- * Tide props: `mask`, `value`, `defaultValue`, `onValueChange`, `size`, `invalid`, `prefix`, `suffix`, `decimalPlaces`, `fixedDecimalPlaces`, `allowNegative`, `groupStyle`, `groupSeparator`, `decimalSeparator`, `locale` ({@link NumberFormatInputOwnProps}). 나머지는 `<input>` 속성.
36
+ * Tide props: `mask`, `value`, `defaultValue`, `onValueChange`, `size`, `invalid`, `prefix`, `suffix`, `decimalPlaces`, `fixedDecimalPlaces`, `allowNegative`, `min`, `max`, `groupStyle`, `groupSeparator`, `decimalSeparator`, `locale` ({@link NumberFormatInputOwnProps}). 나머지는 `<input>` 속성.
37
37
  */
38
- export declare function NumberFormatInput({ mask, value, defaultValue, onValueChange, prefix, suffix, decimalPlaces, fixedDecimalPlaces, allowNegative, groupStyle, groupSeparator, decimalSeparator, locale, inputMode, ref, onInput, onChange, ...props }: NumberFormatInputProps): ReactElement;
38
+ export declare function NumberFormatInput({ mask, value, defaultValue, onValueChange, prefix, suffix, decimalPlaces, fixedDecimalPlaces, allowNegative, min, max, groupStyle, groupSeparator, decimalSeparator, locale, inputMode, ref, onInput, onChange, ...props }: NumberFormatInputProps): ReactElement;
39
39
  export {};
@@ -14,15 +14,17 @@ import { mergeRefs } from "react-aria";
14
14
  /**
15
15
  * 칠 때 바로 포맷하는 숫자 입력. 자릿수 묶음·prefix·suffix·소수 자릿수(숫자 모드)와
16
16
  * `mask` 틀(패턴 모드)을 다룬다. `<input type="text">`이고 Field 안에서 label·설명·오류가 연결된다.
17
- * Tide props: `mask`, `value`, `defaultValue`, `onValueChange`, `size`, `invalid`, `prefix`, `suffix`, `decimalPlaces`, `fixedDecimalPlaces`, `allowNegative`, `groupStyle`, `groupSeparator`, `decimalSeparator`, `locale` ({@link NumberFormatInputOwnProps}). 나머지는 `<input>` 속성.
17
+ * Tide props: `mask`, `value`, `defaultValue`, `onValueChange`, `size`, `invalid`, `prefix`, `suffix`, `decimalPlaces`, `fixedDecimalPlaces`, `allowNegative`, `min`, `max`, `groupStyle`, `groupSeparator`, `decimalSeparator`, `locale` ({@link NumberFormatInputOwnProps}). 나머지는 `<input>` 속성.
18
18
  */
19
- function NumberFormatInput({ mask, value, defaultValue, onValueChange, prefix, suffix, decimalPlaces, fixedDecimalPlaces, allowNegative, groupStyle, groupSeparator, decimalSeparator, locale, inputMode, ref, onInput, onChange, ...props }) {
19
+ function NumberFormatInput({ mask, value, defaultValue, onValueChange, prefix, suffix, decimalPlaces, fixedDecimalPlaces, allowNegative, min, max, groupStyle, groupSeparator, decimalSeparator, locale, inputMode, ref, onInput, onChange, ...props }) {
20
20
  const formatterKey = JSON.stringify(mask === void 0 ? {
21
21
  prefix,
22
22
  suffix,
23
23
  decimalPlaces,
24
24
  fixedDecimalPlaces,
25
25
  allowNegative,
26
+ min,
27
+ max,
26
28
  groupStyle,
27
29
  groupSeparator,
28
30
  decimalSeparator,
@@ -17,7 +17,9 @@ function createNumericFormatter(options) {
17
17
  const foldedSuffix = fold(suffix);
18
18
  const allowNegative = options.allowNegative ?? false;
19
19
  const { decimalPlaces } = options;
20
- const params = {
20
+ const min = options.min ?? void 0;
21
+ const max = options.max ?? void 0;
22
+ const display = {
21
23
  prefix,
22
24
  postfix: suffix,
23
25
  thousandSeparator: group,
@@ -30,6 +32,11 @@ function createNumericFormatter(options) {
30
32
  negativePattern: "minusFirst",
31
33
  ...allowNegative ? {} : { min: 0 }
32
34
  };
35
+ const params = {
36
+ ...display,
37
+ min: allowNegative ? min : Math.max(min ?? 0, 0),
38
+ max
39
+ };
33
40
  /** prefix·suffix를 뺀 숫자 부분. prefix·suffix 안의 점을 소수점으로 보지 않으려고 쓴다. */
34
41
  const numberRange = (text) => {
35
42
  let start = text.startsWith("-") ? 1 : 0;
@@ -142,7 +149,7 @@ function createNumericFormatter(options) {
142
149
  parse,
143
150
  format: (digits) => {
144
151
  const signed = allowNegative ? digits : digits.replace("-", "");
145
- return signed === "" ? "" : maskitoTransform(signed.replace(".", decimal), maskitoNumber(params));
152
+ return signed === "" ? "" : maskitoTransform(signed.replace(".", decimal), maskitoNumber(display));
146
153
  },
147
154
  toValue: (digits) => {
148
155
  const value = Number.parseFloat(digits);
@@ -23,6 +23,16 @@ export interface NumericFormatOptions {
23
23
  /** 구분자 기본값을 가져올 BCP 47 locale(예: `"de-DE"`). 소수점은 늘 적용되고, 묶으려면 `groupStyle`도 준다. */
24
24
  locale?: string;
25
25
  }
26
+ /** 숫자 모드 입력 칸이 받는 값의 범위. 표시만 하는 `formatNumber`에는 없다. */
27
+ export interface NumericRangeOptions {
28
+ /**
29
+ * 받는 가장 작은 값. 입력 중에는 음수만 바로 맞추고, 양수는 칸을 벗어날 때 맞춘다.
30
+ * `allowNegative`가 아니면 `0`보다 작게 주어도 `0`이다.
31
+ */
32
+ min?: number;
33
+ /** 받는 가장 큰 값. 양수가 넘으면 입력 중에 바로, 음수가 넘으면 칸을 벗어날 때 이 값으로 맞춘다. */
34
+ max?: number;
35
+ }
26
36
  /** 패턴 모드 포맷 옵션 */
27
37
  export interface MaskFormatOptions {
28
38
  /**
package/dist/index.d.ts CHANGED
@@ -18,7 +18,7 @@ import { Textarea, TextareaOwnProps, TextareaProps } from "./Textarea/Textarea.j
18
18
  import "./NumberFormatInput/index.js";
19
19
  import { formatNumber } from "./NumberFormatInput/libs/formatNumber.js";
20
20
  import { NumberFormatInput, NumberFormatInputOwnProps, NumberFormatInputProps } from "./NumberFormatInput/NumberFormatInput.js";
21
- import { MaskFormatOptions, NumberFormatOptions, NumericFormatOptions } from "./NumberFormatInput/types.js";
21
+ import { MaskFormatOptions, NumberFormatOptions, NumericFormatOptions, NumericRangeOptions } from "./NumberFormatInput/types.js";
22
22
  import "./Checkbox/index.js";
23
23
  import { Checkbox, CheckboxOwnProps, CheckboxProps, CheckboxShape } from "./Checkbox/Checkbox.js";
24
24
  import "./CheckboxGroup/index.js";
@@ -121,4 +121,4 @@ import { TooltipTrigger, TooltipTriggerOwnProps, TooltipTriggerProps } from "./T
121
121
  import { TooltipPlacement } from "./Tooltip/types.js";
122
122
  import { TooltipContent, TooltipContentOwnProps, TooltipContentProps } from "./Tooltip/components/TooltipContent.js";
123
123
  import { Color, ColorFamilyName, ColorFamilyRegistry, FillVariant, Role, RoleRegistry, Size } from "./types.js";
124
- export { Accordion, type AccordionHeadingLevel, AccordionItem, type AccordionItemOwnProps, type AccordionItemProps, type AccordionOwnProps, AccordionPanel, type AccordionPanelOwnProps, type AccordionPanelProps, type AccordionProps, AccordionTrigger, type AccordionTriggerOwnProps, type AccordionTriggerProps, Alert, AlertDialog, type AlertDialogProps, type AlertOwnProps, type AlertProps, Avatar, type AvatarOwnProps, type AvatarProps, Badge, type BadgeOwnProps, type BadgeProps, Breadcrumb, BreadcrumbCurrent, type BreadcrumbCurrentProps, BreadcrumbItem, type BreadcrumbItemProps, BreadcrumbLink, type BreadcrumbLinkOwnProps, type BreadcrumbLinkProps, type BreadcrumbOwnProps, type BreadcrumbProps, Button, type ButtonOwnProps, type ButtonProps, Card, type CardOwnProps, type CardProps, Checkbox, CheckboxGroup, type CheckboxGroupOwnProps, type CheckboxGroupProps, type CheckboxOwnProps, type CheckboxProps, type CheckboxShape, type ChoiceOrientation, type Color, type ColorFamilyName, type ColorFamilyRegistry, Combobox, ComboboxItem, type ComboboxItemOwnProps, type ComboboxItemProps, type ComboboxOwnProps, type ComboboxProps, ComboboxSection, type ComboboxSectionProps, Dialog, DialogClose, type DialogCloseOwnProps, type DialogCloseProps, DialogContent, type DialogContentOwnProps, type DialogContentProps, DialogDescription, type DialogDescriptionProps, DialogFooter, type DialogFooterProps, DialogHeader, type DialogHeaderAlign, type DialogHeaderOwnProps, type DialogHeaderProps, type DialogProps, type DialogSize, DialogTitle, type DialogTitleProps, DialogTrigger, type DialogTriggerOwnProps, type DialogTriggerProps, Field, type FieldOwnProps, type FieldProps, type FillVariant, IconButton, type IconButtonOwnProps, type IconButtonProps, Input, type InputOwnProps, type InputProps, Link, type LinkOwnProps, type LinkProps, type MaskFormatOptions, Menu, MenuContent, type MenuContentOwnProps, type MenuContentProps, MenuItem, type MenuItemOwnProps, type MenuItemProps, type MenuPlacement, type MenuProps, MenuSection, type MenuSectionProps, MenuTrigger, type MenuTriggerOwnProps, type MenuTriggerProps, NumberFormatInput, type NumberFormatInputOwnProps, type NumberFormatInputProps, type NumberFormatOptions, type NumericFormatOptions, Pagination, PaginationEllipsis, type PaginationEllipsisOwnProps, type PaginationEllipsisProps, PaginationItem, type PaginationItemProps, PaginationLink, type PaginationLinkOwnProps, type PaginationLinkProps, PaginationNext, type PaginationNextOwnProps, type PaginationNextProps, type PaginationOwnProps, PaginationPrevious, type PaginationPreviousOwnProps, type PaginationPreviousProps, type PaginationProps, Popover, PopoverContent, type PopoverContentOwnProps, type PopoverContentProps, type PopoverPlacement, type PopoverProps, PopoverTrigger, type PopoverTriggerOwnProps, type PopoverTriggerProps, Progress, type ProgressOwnProps, type ProgressProps, Radio, RadioGroup, type RadioGroupOwnProps, type RadioGroupProps, type RadioOwnProps, type RadioProps, type Role, type RoleRegistry, Select, SelectItem, type SelectItemOwnProps, type SelectItemProps, type SelectOwnProps, type SelectProps, SelectSection, type SelectSectionProps, Separator, type SeparatorOwnProps, type SeparatorProps, type Size, Skeleton, type SkeletonOwnProps, type SkeletonProps, Spinner, type SpinnerOwnProps, type SpinnerProps, Switch, type SwitchOwnProps, type SwitchProps, Tab, TabList, type TabListOwnProps, type TabListProps, type TabOwnProps, TabPanel, type TabPanelOwnProps, type TabPanelProps, type TabProps, Table, TableBody, type TableBodyProps, TableCell, type TableCellProps, TableHead, type TableHeadProps, TableHeaderCell, type TableHeaderCellOwnProps, type TableHeaderCellProps, type TableProps, TableRow, type TableRowProps, Tabs, type TabsActivationMode, type TabsOrientation, type TabsOwnProps, type TabsProps, type TabsShape, Tag, TagGroup, type TagGroupOwnProps, type TagGroupProps, type TagOwnProps, type TagProps, Textarea, type TextareaOwnProps, type TextareaProps, type ToastAction, type ToastOptions, ToastQueue, type ToastQueueOptions, ToastRegion, type ToastRegionOwnProps, type ToastRegionProps, Tooltip, TooltipContent, type TooltipContentOwnProps, type TooltipContentProps, type TooltipPlacement, type TooltipProps, TooltipTrigger, type TooltipTriggerOwnProps, type TooltipTriggerProps, VisuallyHidden, type VisuallyHiddenProps, cn, formatNumber };
124
+ export { Accordion, type AccordionHeadingLevel, AccordionItem, type AccordionItemOwnProps, type AccordionItemProps, type AccordionOwnProps, AccordionPanel, type AccordionPanelOwnProps, type AccordionPanelProps, type AccordionProps, AccordionTrigger, type AccordionTriggerOwnProps, type AccordionTriggerProps, Alert, AlertDialog, type AlertDialogProps, type AlertOwnProps, type AlertProps, Avatar, type AvatarOwnProps, type AvatarProps, Badge, type BadgeOwnProps, type BadgeProps, Breadcrumb, BreadcrumbCurrent, type BreadcrumbCurrentProps, BreadcrumbItem, type BreadcrumbItemProps, BreadcrumbLink, type BreadcrumbLinkOwnProps, type BreadcrumbLinkProps, type BreadcrumbOwnProps, type BreadcrumbProps, Button, type ButtonOwnProps, type ButtonProps, Card, type CardOwnProps, type CardProps, Checkbox, CheckboxGroup, type CheckboxGroupOwnProps, type CheckboxGroupProps, type CheckboxOwnProps, type CheckboxProps, type CheckboxShape, type ChoiceOrientation, type Color, type ColorFamilyName, type ColorFamilyRegistry, Combobox, ComboboxItem, type ComboboxItemOwnProps, type ComboboxItemProps, type ComboboxOwnProps, type ComboboxProps, ComboboxSection, type ComboboxSectionProps, Dialog, DialogClose, type DialogCloseOwnProps, type DialogCloseProps, DialogContent, type DialogContentOwnProps, type DialogContentProps, DialogDescription, type DialogDescriptionProps, DialogFooter, type DialogFooterProps, DialogHeader, type DialogHeaderAlign, type DialogHeaderOwnProps, type DialogHeaderProps, type DialogProps, type DialogSize, DialogTitle, type DialogTitleProps, DialogTrigger, type DialogTriggerOwnProps, type DialogTriggerProps, Field, type FieldOwnProps, type FieldProps, type FillVariant, IconButton, type IconButtonOwnProps, type IconButtonProps, Input, type InputOwnProps, type InputProps, Link, type LinkOwnProps, type LinkProps, type MaskFormatOptions, Menu, MenuContent, type MenuContentOwnProps, type MenuContentProps, MenuItem, type MenuItemOwnProps, type MenuItemProps, type MenuPlacement, type MenuProps, MenuSection, type MenuSectionProps, MenuTrigger, type MenuTriggerOwnProps, type MenuTriggerProps, NumberFormatInput, type NumberFormatInputOwnProps, type NumberFormatInputProps, type NumberFormatOptions, type NumericFormatOptions, type NumericRangeOptions, Pagination, PaginationEllipsis, type PaginationEllipsisOwnProps, type PaginationEllipsisProps, PaginationItem, type PaginationItemProps, PaginationLink, type PaginationLinkOwnProps, type PaginationLinkProps, PaginationNext, type PaginationNextOwnProps, type PaginationNextProps, type PaginationOwnProps, PaginationPrevious, type PaginationPreviousOwnProps, type PaginationPreviousProps, type PaginationProps, Popover, PopoverContent, type PopoverContentOwnProps, type PopoverContentProps, type PopoverPlacement, type PopoverProps, PopoverTrigger, type PopoverTriggerOwnProps, type PopoverTriggerProps, Progress, type ProgressOwnProps, type ProgressProps, Radio, RadioGroup, type RadioGroupOwnProps, type RadioGroupProps, type RadioOwnProps, type RadioProps, type Role, type RoleRegistry, Select, SelectItem, type SelectItemOwnProps, type SelectItemProps, type SelectOwnProps, type SelectProps, SelectSection, type SelectSectionProps, Separator, type SeparatorOwnProps, type SeparatorProps, type Size, Skeleton, type SkeletonOwnProps, type SkeletonProps, Spinner, type SpinnerOwnProps, type SpinnerProps, Switch, type SwitchOwnProps, type SwitchProps, Tab, TabList, type TabListOwnProps, type TabListProps, type TabOwnProps, TabPanel, type TabPanelOwnProps, type TabPanelProps, type TabProps, Table, TableBody, type TableBodyProps, TableCell, type TableCellProps, TableHead, type TableHeadProps, TableHeaderCell, type TableHeaderCellOwnProps, type TableHeaderCellProps, type TableProps, TableRow, type TableRowProps, Tabs, type TabsActivationMode, type TabsOrientation, type TabsOwnProps, type TabsProps, type TabsShape, Tag, TagGroup, type TagGroupOwnProps, type TagGroupProps, type TagOwnProps, type TagProps, Textarea, type TextareaOwnProps, type TextareaProps, type ToastAction, type ToastOptions, ToastQueue, type ToastQueueOptions, ToastRegion, type ToastRegionOwnProps, type ToastRegionProps, Tooltip, TooltipContent, type TooltipContentOwnProps, type TooltipContentProps, type TooltipPlacement, type TooltipProps, TooltipTrigger, type TooltipTriggerOwnProps, type TooltipTriggerProps, VisuallyHidden, type VisuallyHiddenProps, cn, formatNumber };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tide-design/components",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "description": "Tide 디자인 시스템의 React Component",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -37,8 +37,8 @@
37
37
  "@maskito/core": "5.6.1",
38
38
  "@maskito/kit": "5.6.1",
39
39
  "@maskito/react": "5.6.1",
40
- "@tide-design/foundation": "0.24.0",
41
- "@tide-design/icons": "0.24.0",
40
+ "@tide-design/foundation": "0.25.0",
41
+ "@tide-design/icons": "0.25.0",
42
42
  "clsx": "^2.1.1",
43
43
  "react-aria": "^3.53.1",
44
44
  "react-number-format": "^5.4.5",