@zenkigen-inc/component-ui 1.3.0 → 1.4.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/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-area';
21
23
  export * from './text-input';
22
24
  export * from './toast';
23
25
  export * from './toggle';
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { userColors, typography, buttonColors, focusVisible, iconColors, tagColors, tagLightColors } from '@zenkigen-inc/component-theme';
2
2
  import clsx$1, { clsx } from 'clsx';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
- import aa, { useState, useCallback, useEffect, createContext, useContext, useRef, forwardRef } from 'react';
4
+ import aa, { useState, useCallback, useEffect, createContext, useContext, useRef, useLayoutEffect, forwardRef } from 'react';
5
5
  import { iconElements } from '@zenkigen-inc/component-icons';
6
6
 
7
7
  function _extends() {
@@ -31,7 +31,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
31
31
  return target;
32
32
  }
33
33
 
34
- var _excluded$6 = ["size"];
34
+ var _excluded$7 = ["size"];
35
35
  var isAsciiString = function isAsciiString(str) {
36
36
  return str.charCodeAt(0) < 256;
37
37
  };
@@ -39,7 +39,7 @@ function Avatar(_ref) {
39
39
  var _clsx;
40
40
  var _ref$size = _ref.size,
41
41
  size = _ref$size === void 0 ? 'medium' : _ref$size,
42
- props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
42
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
43
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));
44
44
  var trimmedFirstName = props.firstName.trim();
45
45
  var trimmedLastName = props.lastName.trim();
@@ -70,13 +70,13 @@ function Breadcrumb(_ref) {
70
70
  }
71
71
  Breadcrumb.Item = BreadcrumbItem;
72
72
 
73
- var _excluded$5 = ["size", "variant"];
73
+ var _excluded$6 = ["size", "variant"];
74
74
  function Button(_ref) {
75
75
  var _ref$size = _ref.size,
76
76
  size = _ref$size === void 0 ? 'medium' : _ref$size,
77
77
  _ref$variant = _ref.variant,
78
78
  variant = _ref$variant === void 0 ? 'fill' : _ref$variant,
79
- props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
79
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
80
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, {
81
81
  'h-6 px-2.5': size === 'small'
82
82
  }, {
@@ -229,12 +229,12 @@ var useOutsideClick = function useOutsideClick(ref, handler, enabled) {
229
229
  }, [ref, enabled, handler]);
230
230
  };
231
231
 
232
- var _excluded$4 = ["size"];
232
+ var _excluded$5 = ["size"];
233
233
  var Icon = function Icon(_ref) {
234
234
  var _ref2;
235
235
  var _ref$size = _ref.size,
236
236
  size = _ref$size === void 0 ? 'medium' : _ref$size,
237
- props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
237
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
238
238
  return /*#__PURE__*/jsx("span", {
239
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), {
240
240
  'w-3 h-3': size === 'x-small',
@@ -473,13 +473,13 @@ function Heading(props) {
473
473
  });
474
474
  }
475
475
 
476
- var _excluded$3 = ["size", "variant"];
476
+ var _excluded$4 = ["size", "variant"];
477
477
  function IconButton(_ref) {
478
478
  var _ref$size = _ref.size,
479
479
  size = _ref$size === void 0 ? 'medium' : _ref$size,
480
480
  _ref$variant = _ref.variant,
481
481
  variant = _ref$variant === void 0 ? 'outline' : _ref$variant,
482
- props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
482
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
483
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, {
484
484
  'h-6 w-6': size === 'small' && !props.isNoPadding
485
485
  }, {
@@ -31527,13 +31527,13 @@ Modal.Body = ModalBody;
31527
31527
  Modal.Header = ModalHeader;
31528
31528
  Modal.Footer = ModalFooter;
31529
31529
 
31530
- var _excluded$2 = ["state", "size"];
31530
+ var _excluded$3 = ["state", "size"];
31531
31531
  function NotificationInline(_ref) {
31532
31532
  var _ref$state = _ref.state,
31533
31533
  state = _ref$state === void 0 ? 'default' : _ref$state,
31534
31534
  _ref$size = _ref.size,
31535
31535
  size = _ref$size === void 0 ? 'medium' : _ref$size,
31536
- props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
31536
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
31537
31537
  var wrapperClasses = clsx('rounded', 'text-text-text01', 'flex', 'gap-1', 'items-center', typography.body.body2regular, {
31538
31538
  'bg-background-uiBackgroundError': state === 'attention',
31539
31539
  'bg-background-uiBackgroundWarning': state === 'warning',
@@ -31581,6 +31581,108 @@ function NotificationInline(_ref) {
31581
31581
  });
31582
31582
  }
31583
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
+
31584
31686
  var SelectContext = /*#__PURE__*/createContext({
31585
31687
  size: 'medium',
31586
31688
  setIsOptionListOpen: function setIsOptionListOpen() {
@@ -31599,13 +31701,13 @@ function SelectItem$1(_ref) {
31599
31701
  onChange == null || onChange(option);
31600
31702
  setIsOptionListOpen(false);
31601
31703
  };
31602
- var listItemClasses = clsx$1('flex w-full items-center');
31603
31704
  var itemClasses = clsx$1('flex', 'items-center', 'w-full', 'h-8', 'px-3', 'hover:bg-hover-hover02', 'active:bg-active-active02', focusVisible.inset, typography.label.label2regular, {
31604
31705
  'text-interactive-interactive01 fill-interactive-interactive01 bg-selected-selectedUi': option.id === (selectedOption == null ? void 0 : selectedOption.id),
31605
31706
  'text-interactive-interactive02 fill-icon-icon01 bg-background-uiBackground01': option.id !== (selectedOption == null ? void 0 : selectedOption.id)
31606
31707
  });
31607
31708
  return /*#__PURE__*/jsx("li", {
31608
- className: listItemClasses,
31709
+ className: "flex w-full items-center",
31710
+ "data-id": option.id,
31609
31711
  children: /*#__PURE__*/jsxs("button", {
31610
31712
  className: itemClasses,
31611
31713
  type: "button",
@@ -31632,6 +31734,7 @@ function SelectItem$1(_ref) {
31632
31734
  function SelectList$1(_ref) {
31633
31735
  var children = _ref.children,
31634
31736
  maxHeight = _ref.maxHeight;
31737
+ var ref = useRef(null);
31635
31738
  var _useContext = useContext(SelectContext),
31636
31739
  size = _useContext.size,
31637
31740
  selectedOption = _useContext.selectedOption,
@@ -31643,6 +31746,19 @@ function SelectList$1(_ref) {
31643
31746
  onChange == null || onChange(null);
31644
31747
  setIsOptionListOpen(false);
31645
31748
  };
31749
+ useLayoutEffect(function () {
31750
+ if (maxHeight && ref.current) {
31751
+ var element = Array.from(ref.current.children || []).find(function (item) {
31752
+ return item.getAttribute('data-id') === (selectedOption == null ? void 0 : selectedOption.id);
31753
+ });
31754
+ if (element) {
31755
+ var wrapRect = ref.current.getBoundingClientRect();
31756
+ var rect = element.getBoundingClientRect();
31757
+ ref.current.scroll(0, rect.top - wrapRect.top - wrapRect.height / 2 + rect.height / 2);
31758
+ }
31759
+ }
31760
+ // eslint-disable-next-line react-hooks/exhaustive-deps
31761
+ }, []);
31646
31762
  var listClasses = clsx$1('z-dropdown', 'absolute', 'w-max', 'py-2', 'overflow-y-auto', 'bg-background-uiBackground01', 'rounded', 'shadow-floatingShadow', {
31647
31763
  'top-7': size === 'x-small' || size === 'small',
31648
31764
  'top-9': size === 'medium',
@@ -31655,6 +31771,7 @@ function SelectList$1(_ref) {
31655
31771
  style: {
31656
31772
  maxHeight: maxHeight
31657
31773
  },
31774
+ ref: ref,
31658
31775
  children: [children, placeholder && selectedOption !== null && /*#__PURE__*/jsx("li", {
31659
31776
  children: /*#__PURE__*/jsx("button", {
31660
31777
  className: deselectButtonClasses,
@@ -31905,14 +32022,14 @@ function Radio(_ref) {
31905
32022
  });
31906
32023
  }
31907
32024
 
31908
- var _excluded$1 = ["width", "size"];
32025
+ var _excluded$2 = ["width", "size"];
31909
32026
  var Search = /*#__PURE__*/forwardRef(function (_ref, ref) {
31910
32027
  var _clsx;
31911
32028
  var _ref$width = _ref.width,
31912
32029
  width = _ref$width === void 0 ? '100%' : _ref$width,
31913
32030
  _ref$size = _ref.size,
31914
32031
  size = _ref$size === void 0 ? 'medium' : _ref$size,
31915
- props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
32032
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
31916
32033
  var classes = clsx('flex', 'items-center', 'rounded-full', 'border', 'border-border-uiBorder02', 'focus-within:border-active-activeInput', {
31917
32034
  'h-8 px-3': size === 'medium'
31918
32035
  }, {
@@ -32207,21 +32324,52 @@ function Tag(_ref) {
32207
32324
  });
32208
32325
  }
32209
32326
 
32210
- var _excluded = ["size"];
32327
+ var _excluded$1 = ["size", "isResizable", "isError"];
32328
+ var TextArea = /*#__PURE__*/forwardRef(function (_ref, ref) {
32329
+ var _clsx;
32330
+ var _ref$size = _ref.size,
32331
+ size = _ref$size === void 0 ? 'medium' : _ref$size,
32332
+ _ref$isResizable = _ref.isResizable,
32333
+ isResizable = _ref$isResizable === void 0 ? false : _ref$isResizable,
32334
+ isError = _ref.isError,
32335
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
32336
+ var classes = clsx('w-full rounded border outline-0 placeholder:text-text-textPlaceholder disabled:text-text-textPlaceholder', (_clsx = {
32337
+ 'border-support-supportError': isError && !props.disabled,
32338
+ 'hover:border-hover-hoverInput': !props.disabled && !isError,
32339
+ 'border-border-uiBorder01 hover:focus-within:border-active-activeInput focus-within:border-active-activeInput text-text-text01': !isError,
32340
+ 'bg-disabled-disabled02 border-disabled-disabled02': props.disabled
32341
+ }, _clsx[typography.body.body1regular + " px-2 pt-1.5 pb-2"] = size === 'medium', _clsx["text-4 px-3.5 py-2.5 "] = size === 'large', _clsx['text-support-supportError'] = isError, _clsx['resize-none'] = !isResizable, _clsx));
32342
+ return /*#__PURE__*/jsx("div", {
32343
+ className: "flex",
32344
+ children: /*#__PURE__*/jsx("textarea", _extends({
32345
+ ref: ref,
32346
+ className: classes
32347
+ }, props, {
32348
+ style: {
32349
+ height: props.height
32350
+ }
32351
+ }))
32352
+ });
32353
+ });
32354
+ TextArea.displayName = 'TextArea';
32355
+
32356
+ var _excluded = ["size", "isError", "onClickClearButton"];
32211
32357
  var TextInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
32212
32358
  var _clsx;
32213
32359
  var _ref$size = _ref.size,
32214
32360
  size = _ref$size === void 0 ? 'medium' : _ref$size,
32361
+ isError = _ref.isError,
32362
+ onClickClearButton = _ref.onClickClearButton,
32215
32363
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
32216
32364
  var inputWrapClasses = clsx('flex items-center gap-2 overflow-hidden rounded border pl-2 pr-3', {
32217
- 'border-border-uiBorder01': !props.isError,
32218
- 'border-support-supportError': props.isError && !props.disabled,
32219
- 'hover:border-hover-hoverInput': !props.disabled && !props.isError,
32220
- 'hover:focus-within:border-active-activeInput': !props.isError,
32221
- 'focus-within:border-active-activeInput': !props.isError,
32365
+ 'border-border-uiBorder01': !isError,
32366
+ 'border-support-supportError': isError && !props.disabled,
32367
+ 'hover:border-hover-hoverInput': !props.disabled && !isError,
32368
+ 'hover:focus-within:border-active-activeInput': !isError,
32369
+ 'focus-within:border-active-activeInput': !isError,
32222
32370
  'bg-disabled-disabled02 border-disabled-disabled02': props.disabled
32223
32371
  });
32224
- var inputClasses = clsx('flex-1 outline-0 placeholder:text-text-textPlaceholder disabled:text-text-text03', (_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'] = !props.isError, _clsx['text-support-supportError'] = props.isError, _clsx));
32372
+ 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));
32225
32373
  return /*#__PURE__*/jsxs("div", {
32226
32374
  className: inputWrapClasses,
32227
32375
  children: [/*#__PURE__*/jsx("input", _extends({
@@ -32229,12 +32377,12 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
32229
32377
  size: 1,
32230
32378
  className: inputClasses,
32231
32379
  onChange: props.onChange
32232
- }, props)), props.onClickClearButton && props.value && props.value.length !== 0 && !props.disabled && /*#__PURE__*/jsx(IconButton, {
32380
+ }, props)), onClickClearButton && props.value && props.value.length !== 0 && !props.disabled && /*#__PURE__*/jsx(IconButton, {
32233
32381
  variant: "text",
32234
32382
  icon: "close",
32235
32383
  size: "small",
32236
32384
  isNoPadding: true,
32237
- onClick: props.onClickClearButton
32385
+ onClick: onClickClearButton
32238
32386
  })]
32239
32387
  });
32240
32388
  });
@@ -32517,5 +32665,5 @@ function Tooltip(_ref) {
32517
32665
  });
32518
32666
  }
32519
32667
 
32520
- export { Avatar, Breadcrumb, Button, Checkbox, Dropdown, EvaluationStar, Heading, Icon, IconButton, Loading, Modal, NotificationInline, PaginationSelect, Radio, Search, Select, SelectSort, Tab, TabItem, Table, TableCell, TableRow, Tag, TextInput, Toast, ToastProvider, Toggle, Tooltip, useToast };
32668
+ 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, TextArea, TextInput, Toast, ToastProvider, Toggle, Tooltip, useToast };
32521
32669
  //# sourceMappingURL=index.esm.js.map