@zenkigen-inc/component-ui 1.17.0 → 1.18.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.
package/README.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @zenkigen-inc/component-ui
2
2
 
3
+ ## 目次
4
+
5
+ - [インストール](#インストール)
6
+ - [利用方法](#利用方法)
7
+ - [開発者向け](#開発者向け)
8
+ - [コンポーネントの雛形を生成する](#コンポーネントの雛形を生成する)
9
+ - [実装したコンポーネントを export する](#実装したコンポーネントを-export-する)
10
+ - [ライセンス](#ライセンス)
11
+
3
12
  ## インストール
4
13
 
5
14
  ```bash
package/dist/index.d.mts CHANGED
@@ -3,22 +3,23 @@ import react__default, { PropsWithChildren, ElementType, ComponentPropsWithoutRe
3
3
  import { IconName } from '@zenkigen-inc/component-icons';
4
4
  import { iconColors, tagLightColors } from '@zenkigen-inc/component-theme';
5
5
  import { tokens } from '@zenkigen-inc/component-config';
6
+ import { useFloating } from '@floating-ui/react';
6
7
 
7
- type Props$x = {
8
+ type Props$z = {
8
9
  size?: 'x-small' | 'small' | 'medium' | 'large' | 'x-large';
9
10
  userId?: number;
10
11
  firstName?: string;
11
12
  lastName?: string;
12
13
  isDisabled?: boolean;
13
14
  };
14
- declare function Avatar({ size, ...props }: Props$x): react.JSX.Element;
15
+ declare function Avatar({ size, ...props }: Props$z): react.JSX.Element;
15
16
 
16
17
  declare function Breadcrumb({ children }: PropsWithChildren): react.JSX.Element;
17
18
  declare namespace Breadcrumb {
18
19
  var Item: ({ children }: PropsWithChildren) => react.JSX.Element;
19
20
  }
20
21
 
21
- type Size$2 = 'small' | 'medium' | 'large';
22
+ type Size$3 = 'small' | 'medium' | 'large';
22
23
  type Variant$1 = 'fill' | 'fillDanger' | 'outline' | 'text';
23
24
  type JustifyContent = 'start' | 'center';
24
25
  type ElementAs = ElementType;
@@ -26,20 +27,22 @@ type AsProp<T extends ElementAs> = {
26
27
  elementAs?: T;
27
28
  };
28
29
  type PolymorphicPropsWithoutRef<T extends ElementAs, P extends object> = PropsWithChildren<P> & ComponentPropsWithoutRef<T> & AsProp<T>;
29
- type Props$w<T extends ElementAs> = PolymorphicPropsWithoutRef<T, {
30
- size?: Size$2;
30
+ type BaseProps$1<T extends ElementAs> = PolymorphicPropsWithoutRef<T, {
31
+ size?: Size$3;
31
32
  width?: CSSProperties['width'];
32
33
  isSelected?: boolean;
33
34
  isDisabled?: boolean;
34
- variant?: Variant$1;
35
35
  before?: ReactNode;
36
36
  after?: ReactNode;
37
37
  borderRadius?: CSSProperties['borderRadius'];
38
38
  justifyContent?: JustifyContent;
39
39
  }>;
40
- declare const Button: <T extends ElementAs = "button">({ size, variant, isDisabled, isSelected, width, borderRadius, justifyContent, before, after, elementAs, children, ...props }: Props$w<T>) => react.JSX.Element;
40
+ type PublicProps<T extends ElementAs> = BaseProps$1<T> & {
41
+ variant?: Variant$1;
42
+ };
43
+ declare const Button: <T extends ElementAs = "button">(props: PublicProps<T>) => react.JSX.Element;
41
44
 
42
- type Props$v = {
45
+ type Props$y = {
43
46
  name?: string;
44
47
  value?: string;
45
48
  id?: string;
@@ -50,13 +53,13 @@ type Props$v = {
50
53
  label?: string;
51
54
  onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
52
55
  };
53
- declare function Checkbox({ name, value, id, isChecked, isIndeterminate, isDisabled, onChange, label, color, }: Props$v): react.JSX.Element;
56
+ declare function Checkbox({ name, value, id, isChecked, isIndeterminate, isDisabled, onChange, label, color, }: Props$y): react.JSX.Element;
54
57
 
55
- type Props$u = {
58
+ type Props$x = {
56
59
  color?: 'gray' | 'red';
57
60
  onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
58
61
  };
59
- declare function DropdownItem({ children, color, onClick }: PropsWithChildren<Props$u>): react.JSX.Element;
62
+ declare function DropdownItem({ children, color, onClick }: PropsWithChildren<Props$x>): react.JSX.Element;
60
63
 
61
64
  type DropdownItemType = {
62
65
  id: string;
@@ -67,15 +70,15 @@ type DropdownItemType = {
67
70
  type DropdownVerticalPosition = 'top' | 'bottom';
68
71
  type DropdownHorizontalAlign = 'left' | 'center' | 'right';
69
72
 
70
- type Props$t = {
73
+ type Props$w = {
71
74
  maxHeight?: CSSProperties['height'];
72
75
  isNoPadding?: boolean;
73
76
  verticalPosition?: DropdownVerticalPosition;
74
77
  horizontalAlign?: DropdownHorizontalAlign;
75
78
  };
76
- declare function DropdownMenu({ children, maxHeight, isNoPadding, verticalPosition, horizontalAlign, }: PropsWithChildren<Props$t>): false | react.JSX.Element;
79
+ declare function DropdownMenu({ children, maxHeight, isNoPadding, verticalPosition, horizontalAlign, }: PropsWithChildren<Props$w>): false | react.JSX.Element;
77
80
 
78
- type Props$s = {
81
+ type Props$v = {
79
82
  size?: 'x-small' | 'small' | 'medium' | 'large';
80
83
  variant?: 'text' | 'outline';
81
84
  title?: string;
@@ -91,28 +94,73 @@ type Props$s = {
91
94
  label: string;
92
95
  icon?: IconName;
93
96
  });
94
- declare function Dropdown({ children, target, label, icon, size, variant, title, isDisabled, isArrowHidden, portalTargetRef, }: PropsWithChildren<Props$s>): react.JSX.Element;
97
+ declare function Dropdown({ children, target, label, icon, size, variant, title, isDisabled, isArrowHidden, portalTargetRef, }: PropsWithChildren<Props$v>): react.JSX.Element;
95
98
  declare namespace Dropdown {
96
99
  var Menu: typeof DropdownMenu;
97
100
  var Item: typeof DropdownItem;
98
101
  }
99
102
 
100
- type Props$r = {
103
+ type Props$u = {
101
104
  value: number;
102
105
  isEditable?: boolean;
103
106
  onChangeRating?: (newRating: number) => void | null;
104
107
  size?: 'medium' | 'large';
105
108
  };
106
- declare function EvaluationStar({ value, isEditable, onChangeRating, size }: Props$r): react.JSX.Element;
109
+ declare function EvaluationStar({ value, isEditable, onChangeRating, size }: Props$u): react.JSX.Element;
110
+
111
+ type Size$2 = 'small' | 'medium' | 'large';
112
+ declare const ERROR_TYPES: {
113
+ readonly SIZE_TOO_LARGE: "SIZE_TOO_LARGE";
114
+ readonly UNSUPPORTED_FORMAT: "UNSUPPORTED_FORMAT";
115
+ };
116
+ type FileInputErrorType = (typeof ERROR_TYPES)[keyof typeof ERROR_TYPES];
117
+ type FileInputError = {
118
+ type: FileInputErrorType;
119
+ message: string;
120
+ };
121
+ type BaseFileInputProps = {
122
+ /** input要素のID(外部のlabel要素との連携用) */
123
+ id?: string;
124
+ /** 許可するファイル形式(MIMEタイプ) */
125
+ accept?: string;
126
+ /** 最大ファイルサイズ(バイト単位) */
127
+ maxSize?: number;
128
+ /** 無効化状態 */
129
+ isDisabled?: boolean;
130
+ /** エラー状態 */
131
+ isError?: boolean;
132
+ /** ファイル選択時のコールバック */
133
+ onSelect?: (file: File | null) => void;
134
+ /** エラー時のコールバック */
135
+ onError?: (errors: FileInputError[]) => void;
136
+ /** エラーメッセージリスト */
137
+ errorMessages?: string[];
138
+ };
139
+ type ButtonFileInputProps = BaseFileInputProps & {
140
+ /** コンポーネントのバリエーション */
141
+ variant: 'button';
142
+ /** サイズ */
143
+ size?: Size$2;
144
+ };
145
+ type DropzoneFileInputProps = BaseFileInputProps & {
146
+ /** コンポーネントのバリエーション */
147
+ variant: 'dropzone';
148
+ };
149
+ type FileInputProps = ButtonFileInputProps | DropzoneFileInputProps;
150
+ type FileInputRef = {
151
+ /** ファイル選択状態をリセット */
152
+ reset: () => void;
153
+ };
154
+ declare const FileInput: react.ForwardRefExoticComponent<FileInputProps & react.RefAttributes<FileInputRef>>;
107
155
 
108
156
  type Level = 1 | 2 | 3 | 4 | 5;
109
- type Props$q = {
157
+ type Props$t = {
110
158
  level: Level;
111
159
  before?: ReactNode;
112
160
  after?: ReactNode;
113
161
  children?: ReactNode;
114
162
  };
115
- declare function Heading(props: Props$q): react.JSX.Element;
163
+ declare function Heading(props: Props$t): react.JSX.Element;
116
164
 
117
165
  declare const useOutsideClick: <T extends HTMLElement = HTMLElement>(ref: RefObject<T | null>, handler: (event: Event) => void, enabled?: boolean) => void;
118
166
 
@@ -183,7 +231,7 @@ type ColorToken = UserColorToken | TextColorToken | LinkColorToken | BackgroundC
183
231
 
184
232
  type Size$1 = 'x-small' | 'small' | 'medium' | 'large' | 'x-large';
185
233
  type Color = keyof typeof iconColors;
186
- type Props$p = {
234
+ type Props$s = {
187
235
  name: IconName;
188
236
  size?: Size$1;
189
237
  color?: Color;
@@ -191,11 +239,11 @@ type Props$p = {
191
239
  isDisabled?: boolean;
192
240
  className?: string;
193
241
  };
194
- declare const Icon: ({ size, isDisabled, ...props }: Props$p) => react.JSX.Element;
242
+ declare const Icon: ({ size, isDisabled, ...props }: Props$s) => react.JSX.Element;
195
243
 
196
244
  type Size = 'small' | 'medium' | 'large';
197
245
  type Variant = 'outline' | 'text';
198
- type Props$o = {
246
+ type Props$r = {
199
247
  /** 表示するアイコン名 */
200
248
  icon: IconName;
201
249
  /** ボタンのサイズ */
@@ -214,30 +262,29 @@ type Props$o = {
214
262
  target?: HTMLAnchorElement['target'];
215
263
  } & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'className'>) | ({
216
264
  isAnchor?: false;
217
- onClick?: () => void;
218
- } & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'disabled' | 'className'>));
219
- declare function IconButton({ icon, size, variant, isNoPadding, isDisabled, isSelected, ...props }: Props$o): react.JSX.Element;
265
+ } & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'disabled' | 'className'>));
266
+ declare function IconButton({ icon, size, variant, isNoPadding, isDisabled, isSelected, ...props }: Props$r): react.JSX.Element;
220
267
 
221
- type Props$n = {
268
+ type Props$q = {
222
269
  size?: 'small' | 'medium' | 'large';
223
270
  position?: 'fixed' | 'absolute' | 'static';
224
271
  height?: string;
225
272
  };
226
- declare function Loading({ size, position, height }: Props$n): react.JSX.Element;
273
+ declare function Loading({ size, position, height }: Props$q): react.JSX.Element;
227
274
 
228
275
  declare function ModalBody({ children }: PropsWithChildren): react.JSX.Element;
229
276
 
230
- type Props$m = {
277
+ type Props$p = {
231
278
  isNoBorder?: boolean;
232
279
  };
233
- declare function ModalFooter({ children, isNoBorder }: PropsWithChildren<Props$m>): react__default.JSX.Element;
280
+ declare function ModalFooter({ children, isNoBorder }: PropsWithChildren<Props$p>): react__default.JSX.Element;
234
281
 
235
- type Props$l = {
282
+ type Props$o = {
236
283
  isNoBorder?: boolean;
237
284
  };
238
- declare function ModalHeader({ children, isNoBorder }: PropsWithChildren<Props$l>): react.JSX.Element;
285
+ declare function ModalHeader({ children, isNoBorder }: PropsWithChildren<Props$o>): react.JSX.Element;
239
286
 
240
- type Props$k = {
287
+ type Props$n = {
241
288
  width?: CSSProperties['width'];
242
289
  height?: CSSProperties['height'];
243
290
  maxWidth?: CSSProperties['maxWidth'];
@@ -245,14 +292,14 @@ type Props$k = {
245
292
  onClose?: () => void;
246
293
  portalTargetRef?: MutableRefObject<HTMLElement | null>;
247
294
  };
248
- declare function Modal({ children, width, height, maxWidth, isOpen, onClose, portalTargetRef, }: PropsWithChildren<Props$k>): react.JSX.Element | null;
295
+ declare function Modal({ children, width, height, maxWidth, isOpen, onClose, portalTargetRef, }: PropsWithChildren<Props$n>): react.JSX.Element | null;
249
296
  declare namespace Modal {
250
297
  var Body: typeof ModalBody;
251
298
  var Header: typeof ModalHeader;
252
299
  var Footer: typeof ModalFooter;
253
300
  }
254
301
 
255
- type Props$j = {
302
+ type Props$m = {
256
303
  state?: 'success' | 'warning' | 'information' | 'attention' | 'default';
257
304
  size?: 'small' | 'medium';
258
305
  children?: ReactNode;
@@ -262,9 +309,9 @@ type Props$j = {
262
309
  showClose: true;
263
310
  onClickClose: () => void;
264
311
  });
265
- declare function NotificationInline({ state, size, ...props }: Props$j): react.JSX.Element;
312
+ declare function NotificationInline({ state, size, ...props }: Props$m): react.JSX.Element;
266
313
 
267
- type Props$i = {
314
+ type Props$l = {
268
315
  /** 現在のページ番号 */
269
316
  currentPage: number;
270
317
  /** トータルのページ数 */
@@ -274,9 +321,9 @@ type Props$i = {
274
321
  /** ボタンが押されたときのイベントハンドラ */
275
322
  onClick: (value: number) => void;
276
323
  };
277
- declare function Pagination({ currentPage, totalPage, sideNumPagesToShow, onClick }: Props$i): react.JSX.Element;
324
+ declare function Pagination({ currentPage, totalPage, sideNumPagesToShow, onClick }: Props$l): react.JSX.Element;
278
325
 
279
- type Props$h = {
326
+ type Props$k = {
280
327
  /** トータル件数 */
281
328
  totalSize: number;
282
329
  /** ページあたり件数 */
@@ -296,7 +343,7 @@ type Props$h = {
296
343
  /** Selectが切り替わった時のイベントハンドラ */
297
344
  onChange: (value: number) => void;
298
345
  };
299
- declare function PaginationSelect({ totalSize, currentPage, sizePerPage, countLabel, pageLabel, optionListMaxHeight, onClickPrevButton, onClickNextButton, onChange, }: Props$h): react.JSX.Element;
346
+ declare function PaginationSelect({ totalSize, currentPage, sizePerPage, countLabel, pageLabel, optionListMaxHeight, onClickPrevButton, onClickNextButton, onChange, }: Props$k): react.JSX.Element;
300
347
 
301
348
  declare const TextInput: react.ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "size"> & {
302
349
  size?: "medium" | "large";
@@ -308,8 +355,85 @@ declare const TextInput: react.ForwardRefExoticComponent<Omit<InputHTMLAttribute
308
355
  after?: ReactNode;
309
356
  } & react.RefAttributes<HTMLInputElement>>;
310
357
 
311
- type Props$g = Omit<ComponentPropsWithoutRef<typeof TextInput>, 'type' | 'onClickClearButton'>;
312
- declare const PasswordInput: react.ForwardRefExoticComponent<Props$g & react.RefAttributes<HTMLInputElement>>;
358
+ type Props$j = Omit<ComponentPropsWithoutRef<typeof TextInput>, 'type' | 'onClickClearButton'>;
359
+ declare const PasswordInput: react.ForwardRefExoticComponent<Props$j & react.RefAttributes<HTMLInputElement>>;
360
+
361
+ /**
362
+ * Popoverが閉じられる理由を定義する型
363
+ */
364
+ type CloseReason = 'outside-click' | 'escape-key-down';
365
+ /**
366
+ * Popoverのクローズイベントの型定義
367
+ */
368
+ type PopoverCloseEvent = {
369
+ /** 閉じられた理由 */
370
+ reason: CloseReason;
371
+ };
372
+ /**
373
+ * Popoverの配置位置を定義する型
374
+ */
375
+ type PopoverPlacement = 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end' | 'right-start' | 'right-end';
376
+ /**
377
+ * Popover Context の値の型定義
378
+ */
379
+ type PopoverContextValue = {
380
+ isOpen: boolean;
381
+ triggerRef: react.RefObject<HTMLElement | null>;
382
+ anchorRef?: react.RefObject<HTMLElement | null>;
383
+ floating: ReturnType<typeof useFloating>;
384
+ contentId: string;
385
+ panelId: string;
386
+ onClose?: (event: PopoverCloseEvent) => void;
387
+ };
388
+
389
+ type Props$i = {
390
+ isOpen: boolean;
391
+ placement?: PopoverPlacement;
392
+ offset?: number;
393
+ onClose?: (event: PopoverCloseEvent) => void;
394
+ anchorRef?: React.RefObject<HTMLElement | null>;
395
+ };
396
+ declare function Popover({ isOpen, children, placement, offset: offsetValue, onClose, anchorRef, }: PropsWithChildren<Props$i>): react.JSX.Element;
397
+ declare namespace Popover {
398
+ var Trigger: react.ForwardRefExoticComponent<{
399
+ children: React.ReactElement;
400
+ } & react.RefAttributes<HTMLElement>>;
401
+ var Content: react.ForwardRefExoticComponent<{
402
+ children?: React.ReactNode;
403
+ } & react.RefAttributes<HTMLDivElement>>;
404
+ }
405
+
406
+ type PopoverContentProps = {
407
+ children?: react.ReactNode;
408
+ };
409
+ declare const PopoverContent: react.ForwardRefExoticComponent<PopoverContentProps & react.RefAttributes<HTMLDivElement>>;
410
+
411
+ type PopoverTriggerProps = {
412
+ children: react.ReactElement;
413
+ };
414
+ declare const PopoverTrigger: react.ForwardRefExoticComponent<PopoverTriggerProps & react.RefAttributes<HTMLElement>>;
415
+
416
+ declare function PopupBody({ children }: PropsWithChildren): react.JSX.Element;
417
+
418
+ declare function PopupFooter({ children }: PropsWithChildren): react__default.JSX.Element;
419
+
420
+ type Props$h = PropsWithChildren<{
421
+ before?: ReactNode;
422
+ }>;
423
+ declare function PopupHeader({ children, before }: Props$h): react.JSX.Element;
424
+
425
+ type Props$g = {
426
+ isOpen?: boolean;
427
+ width?: CSSProperties['width'];
428
+ height?: CSSProperties['height'];
429
+ onClose?: () => void;
430
+ };
431
+ declare function Popup({ children, isOpen: controlledIsOpen, width, height, onClose }: PropsWithChildren<Props$g>): react.JSX.Element | null;
432
+ declare namespace Popup {
433
+ var Body: typeof PopupBody;
434
+ var Header: typeof PopupHeader;
435
+ var Footer: typeof PopupFooter;
436
+ }
313
437
 
314
438
  type Props$f = {
315
439
  name?: string;
@@ -560,4 +684,4 @@ type Props = {
560
684
  };
561
685
  declare function Tooltip({ children, content, size, maxWidth, verticalPosition, horizontalAlign, isDisabledHover, portalTarget, }: PropsWithChildren<Props>): react.JSX.Element;
562
686
 
563
- export { Avatar, Breadcrumb, Button, Checkbox, type ColorVariant, Dropdown, type DropdownHorizontalAlign, type DropdownItemType, type DropdownVerticalPosition, EvaluationStar, Heading, Icon, IconButton, Loading, Modal, NotificationInline, Pagination, PaginationSelect, PasswordInput, Radio, Search, SegmentedControl, Select, type SelectOption, SelectSort, SortButton, type SortOrder, Tab, TabItem, Table, TableCell, TableRow, Tag, type TagColor, TextArea, TextInput, Toast, ToastProvider, Toggle, Tooltip, type UseRovingFocusProps, type UseRovingFocusReturn, useOutsideClick, useRovingFocus, useToast };
687
+ export { Avatar, Breadcrumb, Button, Checkbox, type ColorVariant, Dropdown, type DropdownHorizontalAlign, type DropdownItemType, type DropdownVerticalPosition, EvaluationStar, FileInput, type FileInputRef, Heading, Icon, IconButton, Loading, Modal, NotificationInline, Pagination, PaginationSelect, PasswordInput, Popover, PopoverContent, type PopoverContextValue, type PopoverPlacement, PopoverTrigger, Popup, Radio, Search, SegmentedControl, Select, type SelectOption, SelectSort, SortButton, type SortOrder, Tab, TabItem, Table, TableCell, TableRow, Tag, type TagColor, TextArea, TextInput, Toast, ToastProvider, Toggle, Tooltip, type UseRovingFocusProps, type UseRovingFocusReturn, useOutsideClick, useRovingFocus, useToast };