@zenkigen-inc/component-ui 1.2.0 → 1.3.1

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,4 +1,4 @@
1
- import { CSSProperties, ReactNode } from 'react';
1
+ import { CSSProperties, PropsWithChildren, ReactNode } from 'react';
2
2
  type Size = 'small' | 'medium' | 'large';
3
3
  type Variant = 'fill' | 'fillDanger' | 'outline' | 'text';
4
4
  type Props = {
@@ -8,7 +8,6 @@ type Props = {
8
8
  variant?: Variant;
9
9
  before?: ReactNode;
10
10
  after?: ReactNode;
11
- children: ReactNode;
12
11
  } & ({
13
12
  isAnchor: true;
14
13
  href: string;
@@ -17,5 +16,5 @@ type Props = {
17
16
  isAnchor?: false;
18
17
  onClick?: () => void;
19
18
  });
20
- export declare function Button({ size, variant, ...props }: Props): import("react").JSX.Element;
19
+ export declare function Button({ size, variant, ...props }: PropsWithChildren<Props>): import("react").JSX.Element;
21
20
  export {};
@@ -1,8 +1,7 @@
1
- import { MouseEvent, ReactNode } from 'react';
1
+ import { MouseEvent, PropsWithChildren } from 'react';
2
2
  type Props = {
3
- children: ReactNode;
4
3
  color?: 'gray' | 'red';
5
4
  onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
6
5
  };
7
- export declare function DropdownItem({ children, color, onClick }: Props): import("react").JSX.Element;
6
+ export declare function DropdownItem({ children, color, onClick }: PropsWithChildren<Props>): import("react").JSX.Element;
8
7
  export {};
@@ -1,11 +1,10 @@
1
- import { CSSProperties, ReactNode } from 'react';
1
+ import { CSSProperties, PropsWithChildren } from 'react';
2
2
  import { DropdownHorizontalAlign, DropdownVerticalPosition } from './type';
3
3
  type Props = {
4
- children: ReactNode;
5
4
  maxHeight?: CSSProperties['height'];
6
5
  isNoPadding?: boolean;
7
6
  verticalPosition?: DropdownVerticalPosition;
8
7
  horizontalAlign?: DropdownHorizontalAlign;
9
8
  };
10
- export declare function DropdownMenu({ children, maxHeight, isNoPadding, verticalPosition, horizontalAlign, }: Props): false | import("react").JSX.Element;
9
+ export declare function DropdownMenu({ children, maxHeight, isNoPadding, verticalPosition, horizontalAlign, }: PropsWithChildren<Props>): false | import("react").JSX.Element;
11
10
  export {};
@@ -1,5 +1,5 @@
1
- import { ReactElement, ReactNode } from 'react';
2
1
  import { IconName } from '@zenkigen-inc/component-icons';
2
+ import { PropsWithChildren, ReactElement } from 'react';
3
3
  import { DropdownItem } from './dropdown-item';
4
4
  import { DropdownMenu } from './dropdown-menu';
5
5
  type Props = {
@@ -8,7 +8,6 @@ type Props = {
8
8
  title?: string;
9
9
  isDisabled?: boolean;
10
10
  isArrowHidden?: boolean;
11
- children: ReactNode;
12
11
  } & ({
13
12
  target: ReactElement;
14
13
  label?: never;
@@ -18,7 +17,7 @@ type Props = {
18
17
  label: string;
19
18
  icon?: IconName;
20
19
  });
21
- export declare function Dropdown({ children, target, label, icon, size, variant, title, isDisabled, isArrowHidden, }: Props): import("react").JSX.Element;
20
+ export declare function Dropdown({ children, target, label, icon, size, variant, title, isDisabled, isArrowHidden, }: PropsWithChildren<Props>): import("react").JSX.Element;
22
21
  export declare namespace Dropdown {
23
22
  var Menu: typeof DropdownMenu;
24
23
  var Item: typeof DropdownItem;
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export * from './icon-button';
10
10
  export * from './loading';
11
11
  export * from './modal';
12
12
  export * from './notification-inline';
13
+ export * from './pagination';
13
14
  export * from './pagination-select';
14
15
  export * from './radio';
15
16
  export * from './search';
@@ -18,6 +19,7 @@ export * from './select-sort';
18
19
  export * from './tab';
19
20
  export * from './table';
20
21
  export * from './tag';
22
+ export * from './text-input';
21
23
  export * from './toast';
22
24
  export * from './toggle';
23
25
  export * from './tooltip';
package/dist/index.esm.js CHANGED
@@ -4,6 +4,20 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import aa, { useState, useCallback, useEffect, createContext, useContext, useRef, forwardRef } from 'react';
5
5
  import { iconElements } from '@zenkigen-inc/component-icons';
6
6
 
7
+ function _extends() {
8
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
9
+ for (var i = 1; i < arguments.length; i++) {
10
+ var source = arguments[i];
11
+ for (var key in source) {
12
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
13
+ target[key] = source[key];
14
+ }
15
+ }
16
+ }
17
+ return target;
18
+ };
19
+ return _extends.apply(this, arguments);
20
+ }
7
21
  function _objectWithoutPropertiesLoose(source, excluded) {
8
22
  if (source == null) return {};
9
23
  var target = {};
@@ -17,7 +31,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
17
31
  return target;
18
32
  }
19
33
 
20
- var _excluded$5 = ["size"];
34
+ var _excluded$6 = ["size"];
21
35
  var isAsciiString = function isAsciiString(str) {
22
36
  return str.charCodeAt(0) < 256;
23
37
  };
@@ -25,7 +39,7 @@ function Avatar(_ref) {
25
39
  var _clsx;
26
40
  var _ref$size = _ref.size,
27
41
  size = _ref$size === void 0 ? 'medium' : _ref$size,
28
- props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
42
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
29
43
  var classes = clsx('text-text-textOnColor', 'rounded-full', 'flex items-center justify-center', props.isDisabled ? 'bg-disabled-disabled01' : props.userId ? userColors[props.userId % userColors.length] : 'bg-icon-icon01', (_clsx = {}, _clsx["w-16 h-16 " + typography.label.label1regular] = size === 'x-large', _clsx["w-12 h-12 " + typography.label.label2regular] = size === 'large', _clsx["w-10 h-10 " + typography.label.label2regular] = size === 'medium', _clsx["w-8 h-8 " + typography.label.label4regular] = size === 'small', _clsx["w-6 h-6 " + typography.label.label4regular] = size === 'x-small', _clsx));
30
44
  var trimmedFirstName = props.firstName.trim();
31
45
  var trimmedLastName = props.lastName.trim();
@@ -56,13 +70,13 @@ function Breadcrumb(_ref) {
56
70
  }
57
71
  Breadcrumb.Item = BreadcrumbItem;
58
72
 
59
- var _excluded$4 = ["size", "variant"];
73
+ var _excluded$5 = ["size", "variant"];
60
74
  function Button(_ref) {
61
75
  var _ref$size = _ref.size,
62
76
  size = _ref$size === void 0 ? 'medium' : _ref$size,
63
77
  _ref$variant = _ref.variant,
64
78
  variant = _ref$variant === void 0 ? 'fill' : _ref$variant,
65
- props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
79
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
66
80
  var baseClasses = clsx('rounded-button', 'flex', 'shrink-0', 'gap-1', 'items-center', 'justify-center', buttonColors[variant].base, buttonColors[variant].hover, buttonColors[variant].active, buttonColors[variant].disabled, focusVisible.normal, size === 'large' ? typography.label.label1regular : typography.label.label2regular, {
67
81
  'h-6 px-2.5': size === 'small'
68
82
  }, {
@@ -215,12 +229,12 @@ var useOutsideClick = function useOutsideClick(ref, handler, enabled) {
215
229
  }, [ref, enabled, handler]);
216
230
  };
217
231
 
218
- var _excluded$3 = ["size"];
232
+ var _excluded$4 = ["size"];
219
233
  var Icon = function Icon(_ref) {
220
234
  var _ref2;
221
235
  var _ref$size = _ref.size,
222
236
  size = _ref$size === void 0 ? 'medium' : _ref$size,
223
- props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
237
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
224
238
  return /*#__PURE__*/jsx("span", {
225
239
  className: clsx('inline-block', 'shrink-0', props.isDisabled ? 'fill-disabled-disabled01' : (_ref2 = {}, _ref2[iconColors.icon01] = props.color === 'icon01', _ref2[iconColors.icon01Dark] = props.color === 'icon01Dark', _ref2[iconColors.icon02] = props.color === 'icon02', _ref2[iconColors.icon02Dark] = props.color === 'icon02Dark', _ref2[iconColors.icon03] = props.color === 'icon03', _ref2[iconColors.icon03Dark] = props.color === 'icon03Dark', _ref2[iconColors.iconOnColor] = props.color === 'iconOnColor', _ref2), {
226
240
  'w-3 h-3': size === 'x-small',
@@ -459,13 +473,13 @@ function Heading(props) {
459
473
  });
460
474
  }
461
475
 
462
- var _excluded$2 = ["size", "variant"];
476
+ var _excluded$3 = ["size", "variant"];
463
477
  function IconButton(_ref) {
464
478
  var _ref$size = _ref.size,
465
479
  size = _ref$size === void 0 ? 'medium' : _ref$size,
466
480
  _ref$variant = _ref.variant,
467
481
  variant = _ref$variant === void 0 ? 'outline' : _ref$variant,
468
- props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
482
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
469
483
  var baseClasses = clsx('rounded', 'flex', 'gap-1', 'items-center', 'justify-center', buttonColors[variant].base, buttonColors[variant].hover, buttonColors[variant].active, buttonColors[variant].disabled, focusVisible.normal, typography.label.label1regular, {
470
484
  'h-6 w-6': size === 'small' && !props.isNoPadding
471
485
  }, {
@@ -31513,13 +31527,13 @@ Modal.Body = ModalBody;
31513
31527
  Modal.Header = ModalHeader;
31514
31528
  Modal.Footer = ModalFooter;
31515
31529
 
31516
- var _excluded$1 = ["state", "size"];
31530
+ var _excluded$2 = ["state", "size"];
31517
31531
  function NotificationInline(_ref) {
31518
31532
  var _ref$state = _ref.state,
31519
31533
  state = _ref$state === void 0 ? 'default' : _ref$state,
31520
31534
  _ref$size = _ref.size,
31521
31535
  size = _ref$size === void 0 ? 'medium' : _ref$size,
31522
- props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
31536
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
31523
31537
  var wrapperClasses = clsx('rounded', 'text-text-text01', 'flex', 'gap-1', 'items-center', typography.body.body2regular, {
31524
31538
  'bg-background-uiBackgroundError': state === 'attention',
31525
31539
  'bg-background-uiBackgroundWarning': state === 'warning',
@@ -31567,6 +31581,108 @@ function NotificationInline(_ref) {
31567
31581
  });
31568
31582
  }
31569
31583
 
31584
+ var PaginationContext = /*#__PURE__*/createContext({
31585
+ currentPage: 0
31586
+ });
31587
+
31588
+ function PaginationButton(_ref) {
31589
+ var page = _ref.page,
31590
+ _onClick = _ref.onClick;
31591
+ var _useContext = useContext(PaginationContext),
31592
+ currentPage = _useContext.currentPage;
31593
+ return /*#__PURE__*/jsx(Button, {
31594
+ variant: page === currentPage ? 'outline' : 'text',
31595
+ onClick: function onClick() {
31596
+ return _onClick(page);
31597
+ },
31598
+ children: page
31599
+ });
31600
+ }
31601
+
31602
+ var START_PAGE = 1;
31603
+ function Pagination(_ref) {
31604
+ var currentPage = _ref.currentPage,
31605
+ totalPage = _ref.totalPage,
31606
+ _ref$sideNumPagesToSh = _ref.sideNumPagesToShow,
31607
+ sideNumPagesToShow = _ref$sideNumPagesToSh === void 0 ? 3 : _ref$sideNumPagesToSh,
31608
+ _onClick = _ref.onClick;
31609
+ var center = Math.max(currentPage, START_PAGE + 1);
31610
+ center = Math.min(center, totalPage - 1);
31611
+ var start = Math.max(center - sideNumPagesToShow, START_PAGE + 1);
31612
+ var end = Math.min(center + sideNumPagesToShow, totalPage - 1);
31613
+ var offsetStart = center + sideNumPagesToShow >= totalPage ? totalPage - center - sideNumPagesToShow : 0;
31614
+ var offsetEnd = center <= sideNumPagesToShow ? sideNumPagesToShow - center + 1 : 0;
31615
+ var pageList = [];
31616
+ for (var i = start + offsetStart; i <= end + offsetEnd; i++) {
31617
+ pageList.push(i);
31618
+ }
31619
+ var threeDotIconClasses = 'flex h-8 w-8 items-center justify-center gap-1 fill-icon-icon01';
31620
+ return /*#__PURE__*/jsx(PaginationContext.Provider, {
31621
+ value: {
31622
+ currentPage: currentPage
31623
+ },
31624
+ children: /*#__PURE__*/jsxs("ul", {
31625
+ className: "flex gap-2",
31626
+ children: [/*#__PURE__*/jsx("li", {
31627
+ children: /*#__PURE__*/jsx(IconButton, {
31628
+ isDisabled: currentPage === START_PAGE,
31629
+ variant: "text",
31630
+ icon: "angle-left",
31631
+ size: "medium",
31632
+ onClick: function onClick() {
31633
+ return _onClick(currentPage - 1);
31634
+ }
31635
+ })
31636
+ }), /*#__PURE__*/jsx("li", {
31637
+ children: /*#__PURE__*/jsx(PaginationButton, {
31638
+ onClick: function onClick() {
31639
+ return _onClick(START_PAGE);
31640
+ },
31641
+ page: START_PAGE
31642
+ })
31643
+ }), pageList.length !== 0 && pageList[0] !== 2 && /*#__PURE__*/jsx("li", {
31644
+ className: threeDotIconClasses,
31645
+ children: /*#__PURE__*/jsx(Icon, {
31646
+ name: "more",
31647
+ size: "small"
31648
+ })
31649
+ }), pageList.map(function (page, index) {
31650
+ return /*#__PURE__*/jsx("li", {
31651
+ children: /*#__PURE__*/jsx(PaginationButton, {
31652
+ onClick: function onClick() {
31653
+ return _onClick(page);
31654
+ },
31655
+ page: page
31656
+ })
31657
+ }, index);
31658
+ }), pageList.length !== 0 && pageList[pageList.length - 1] !== totalPage - 1 && /*#__PURE__*/jsx("li", {
31659
+ className: threeDotIconClasses,
31660
+ children: /*#__PURE__*/jsx(Icon, {
31661
+ name: "more",
31662
+ size: "small"
31663
+ })
31664
+ }), /*#__PURE__*/jsx("li", {
31665
+ children: /*#__PURE__*/jsx(PaginationButton, {
31666
+ onClick: function onClick() {
31667
+ return _onClick(totalPage);
31668
+ },
31669
+ page: totalPage
31670
+ })
31671
+ }), /*#__PURE__*/jsx("li", {
31672
+ children: /*#__PURE__*/jsx(IconButton, {
31673
+ isDisabled: currentPage === totalPage,
31674
+ variant: "text",
31675
+ icon: "angle-right",
31676
+ size: "medium",
31677
+ onClick: function onClick() {
31678
+ return _onClick(currentPage + 1);
31679
+ }
31680
+ })
31681
+ })]
31682
+ })
31683
+ });
31684
+ }
31685
+
31570
31686
  var SelectContext = /*#__PURE__*/createContext({
31571
31687
  size: 'medium',
31572
31688
  setIsOptionListOpen: function setIsOptionListOpen() {
@@ -31891,14 +32007,14 @@ function Radio(_ref) {
31891
32007
  });
31892
32008
  }
31893
32009
 
31894
- var _excluded = ["width", "size"];
32010
+ var _excluded$1 = ["width", "size"];
31895
32011
  var Search = /*#__PURE__*/forwardRef(function (_ref, ref) {
31896
32012
  var _clsx;
31897
32013
  var _ref$width = _ref.width,
31898
32014
  width = _ref$width === void 0 ? '100%' : _ref$width,
31899
32015
  _ref$size = _ref.size,
31900
32016
  size = _ref$size === void 0 ? 'medium' : _ref$size,
31901
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
32017
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
31902
32018
  var classes = clsx('flex', 'items-center', 'rounded-full', 'border', 'border-border-uiBorder02', 'focus-within:border-active-activeInput', {
31903
32019
  'h-8 px-3': size === 'medium'
31904
32020
  }, {
@@ -32193,6 +32309,41 @@ function Tag(_ref) {
32193
32309
  });
32194
32310
  }
32195
32311
 
32312
+ var _excluded = ["size", "isError", "onClickClearButton"];
32313
+ var TextInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
32314
+ var _clsx;
32315
+ var _ref$size = _ref.size,
32316
+ size = _ref$size === void 0 ? 'medium' : _ref$size,
32317
+ isError = _ref.isError,
32318
+ onClickClearButton = _ref.onClickClearButton,
32319
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
32320
+ var inputWrapClasses = clsx('flex items-center gap-2 overflow-hidden rounded border pl-2 pr-3', {
32321
+ 'border-border-uiBorder01': !isError,
32322
+ 'border-support-supportError': isError && !props.disabled,
32323
+ 'hover:border-hover-hoverInput': !props.disabled && !isError,
32324
+ 'hover:focus-within:border-active-activeInput': !isError,
32325
+ 'focus-within:border-active-activeInput': !isError,
32326
+ 'bg-disabled-disabled02 border-disabled-disabled02': props.disabled
32327
+ });
32328
+ var inputClasses = clsx('flex-1 outline-0 placeholder:text-text-textPlaceholder disabled:text-text-textPlaceholder', (_clsx = {}, _clsx[typography.label.label2regular + " pt-1.5 pb-2"] = size === 'medium', _clsx[typography.label.label1regular + " py-2.5"] = size === 'large', _clsx['text-text-text01'] = !isError, _clsx['text-support-supportError'] = isError, _clsx));
32329
+ return /*#__PURE__*/jsxs("div", {
32330
+ className: inputWrapClasses,
32331
+ children: [/*#__PURE__*/jsx("input", _extends({
32332
+ ref: ref,
32333
+ size: 1,
32334
+ className: inputClasses,
32335
+ onChange: props.onChange
32336
+ }, props)), onClickClearButton && props.value && props.value.length !== 0 && !props.disabled && /*#__PURE__*/jsx(IconButton, {
32337
+ variant: "text",
32338
+ icon: "close",
32339
+ size: "small",
32340
+ isNoPadding: true,
32341
+ onClick: onClickClearButton
32342
+ })]
32343
+ });
32344
+ });
32345
+ TextInput.displayName = 'TextInput';
32346
+
32196
32347
  var CLOSE_TIME_MSEC = 5000;
32197
32348
  function Toast(_ref) {
32198
32349
  var _clsx;
@@ -32470,5 +32621,5 @@ function Tooltip(_ref) {
32470
32621
  });
32471
32622
  }
32472
32623
 
32473
- export { Avatar, Breadcrumb, Button, Checkbox, Dropdown, EvaluationStar, Heading, Icon, IconButton, Loading, Modal, NotificationInline, PaginationSelect, Radio, Search, Select, SelectSort, Tab, TabItem, Table, TableCell, TableRow, Tag, Toast, ToastProvider, Toggle, Tooltip, useToast };
32624
+ export { Avatar, Breadcrumb, Button, Checkbox, Dropdown, EvaluationStar, Heading, Icon, IconButton, Loading, Modal, NotificationInline, Pagination, PaginationSelect, Radio, Search, Select, SelectSort, Tab, TabItem, Table, TableCell, TableRow, Tag, TextInput, Toast, ToastProvider, Toggle, Tooltip, useToast };
32474
32625
  //# sourceMappingURL=index.esm.js.map