@zenkigen-inc/component-ui 1.1.3 → 1.3.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.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
- const _excluded$5 = ["size"];
34
+ const _excluded$6 = ["size"];
21
35
  const isAsciiString = str => {
22
36
  return str.charCodeAt(0) < 256;
23
37
  };
@@ -25,7 +39,7 @@ function Avatar(_ref) {
25
39
  let {
26
40
  size = 'medium'
27
41
  } = _ref,
28
- props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
42
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
29
43
  const 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', {
30
44
  [`w-16 h-16 ${typography.label.label1regular}`]: size === 'x-large',
31
45
  [`w-12 h-12 ${typography.label.label2regular}`]: size === 'large',
@@ -64,13 +78,13 @@ function Breadcrumb({
64
78
  }
65
79
  Breadcrumb.Item = BreadcrumbItem;
66
80
 
67
- const _excluded$4 = ["size", "variant"];
81
+ const _excluded$5 = ["size", "variant"];
68
82
  function Button(_ref) {
69
83
  let {
70
84
  size = 'medium',
71
85
  variant = 'fill'
72
86
  } = _ref,
73
- props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
87
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
74
88
  const 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, {
75
89
  'h-6 px-2.5': size === 'small'
76
90
  }, {
@@ -213,12 +227,12 @@ const useOutsideClick = (ref, handler, enabled = true) => {
213
227
  }, [ref, enabled, handler]);
214
228
  };
215
229
 
216
- const _excluded$3 = ["size"];
230
+ const _excluded$4 = ["size"];
217
231
  const Icon = _ref => {
218
232
  let {
219
233
  size = 'medium'
220
234
  } = _ref,
221
- props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
235
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
222
236
  return /*#__PURE__*/jsx("span", {
223
237
  className: clsx('inline-block', 'shrink-0', props.isDisabled ? 'fill-disabled-disabled01' : {
224
238
  [iconColors.icon01]: props.color === 'icon01',
@@ -447,13 +461,13 @@ function Heading(props) {
447
461
  });
448
462
  }
449
463
 
450
- const _excluded$2 = ["size", "variant"];
464
+ const _excluded$3 = ["size", "variant"];
451
465
  function IconButton(_ref) {
452
466
  let {
453
467
  size = 'medium',
454
468
  variant = 'outline'
455
469
  } = _ref,
456
- props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
470
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
457
471
  const 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, {
458
472
  'h-6 w-6': size === 'small' && !props.isNoPadding
459
473
  }, {
@@ -31414,85 +31428,29 @@ if (process.env.NODE_ENV === 'production') {
31414
31428
  }
31415
31429
  });
31416
31430
 
31431
+ function ModalBody({
31432
+ children
31433
+ }) {
31434
+ return /*#__PURE__*/jsx("div", {
31435
+ className: "overflow-y-auto",
31436
+ children: children
31437
+ });
31438
+ }
31439
+
31417
31440
  const ModalContext = /*#__PURE__*/createContext({
31418
- width: 480,
31419
31441
  setIsOpen: () => false
31420
31442
  });
31421
31443
 
31422
- const sizeSmallLimit = 420;
31423
- function ModalButtonTab({
31424
- primaryButtonLabel,
31425
- secondaryButtonLabel,
31426
- onClickPrimaryButton,
31427
- onClickSecondaryButton,
31428
- isDanger,
31429
- isNoBorder,
31430
- isWithCheckbox,
31431
- checkboxLabel,
31432
- isChecked,
31433
- onChange,
31434
- subButtonLabel,
31435
- onClickSubButton
31444
+ function ModalFooter({
31445
+ children,
31446
+ isNoBorder
31436
31447
  }) {
31437
- const {
31438
- width,
31439
- setIsOpen
31440
- } = useContext(ModalContext);
31441
- const handleClickPrimaryButton = useCallback(() => {
31442
- onClickPrimaryButton();
31443
- setIsOpen(false);
31444
- }, [onClickPrimaryButton, setIsOpen]);
31445
- const handleClickSecondaryButton = useCallback(() => {
31446
- onClickSecondaryButton();
31447
- setIsOpen(false);
31448
- }, [onClickSecondaryButton, setIsOpen]);
31449
- const handleClickSubButton = useCallback(() => {
31450
- onClickSubButton == null || onClickSubButton();
31451
- }, [onClickSubButton]);
31452
31448
  const wrapperClasses = clsx$1('flex', 'shrink-0', 'items-center', 'w-full', 'rounded-b-lg', 'py-4', 'px-6', {
31453
- 'justify-between': isWithCheckbox || subButtonLabel && sizeSmallLimit <= width,
31454
- 'justify-end': !isWithCheckbox || !subButtonLabel,
31455
- 'justify-center': subButtonLabel && width < sizeSmallLimit,
31456
- 'border-t-[1px] border-border-uiBorder01': !isNoBorder,
31457
- 'gap-y-4': width < sizeSmallLimit,
31458
- 'flex-wrap': width < sizeSmallLimit && isWithCheckbox,
31459
- 'flex-wrap-reverse': width < sizeSmallLimit && subButtonLabel
31449
+ 'border-t-[1px] border-border-uiBorder01': !isNoBorder
31460
31450
  });
31461
- const buttonContainerClasses = clsx$1('flex', 'items-center', {
31462
- 'w-full justify-center': width < sizeSmallLimit,
31463
- 'gap-x-2': width < sizeSmallLimit,
31464
- 'gap-x-4': sizeSmallLimit <= width
31465
- });
31466
- return /*#__PURE__*/jsxs("div", {
31451
+ return /*#__PURE__*/jsx("div", {
31467
31452
  className: wrapperClasses,
31468
- children: [isWithCheckbox ? /*#__PURE__*/jsx("div", {
31469
- children: /*#__PURE__*/jsx(Checkbox, {
31470
- id: "modal-checkbox",
31471
- label: checkboxLabel,
31472
- isChecked: isChecked,
31473
- onChange: onChange
31474
- })
31475
- }) : subButtonLabel && onClickSubButton ? /*#__PURE__*/jsx(Button, {
31476
- variant: "text",
31477
- size: "large",
31478
- onClick: handleClickSubButton,
31479
- children: subButtonLabel
31480
- }, "0") : null, /*#__PURE__*/jsxs("div", {
31481
- className: buttonContainerClasses,
31482
- children: [/*#__PURE__*/jsx(Button, {
31483
- variant: "outline",
31484
- size: "large",
31485
- width: width < sizeSmallLimit ? 132 : 'auto',
31486
- onClick: handleClickSecondaryButton,
31487
- children: secondaryButtonLabel
31488
- }, "1"), /*#__PURE__*/jsx(Button, {
31489
- variant: isDanger ? 'fillDanger' : 'fill',
31490
- size: "large",
31491
- width: width < sizeSmallLimit ? 132 : 'auto',
31492
- onClick: handleClickPrimaryButton,
31493
- children: primaryButtonLabel
31494
- }, "2")]
31495
- })]
31453
+ children: children
31496
31454
  });
31497
31455
  }
31498
31456
 
@@ -31511,7 +31469,9 @@ function ModalHeader({
31511
31469
  });
31512
31470
  return /*#__PURE__*/jsxs("div", {
31513
31471
  className: headerClasses,
31514
- children: [children, !isNoCloseButton && /*#__PURE__*/jsx(IconButton, {
31472
+ children: [/*#__PURE__*/jsx("div", {
31473
+ children: children
31474
+ }), !isNoCloseButton && /*#__PURE__*/jsx(IconButton, {
31515
31475
  icon: "close",
31516
31476
  size: "small",
31517
31477
  variant: "text",
@@ -31520,100 +31480,46 @@ function ModalHeader({
31520
31480
  });
31521
31481
  }
31522
31482
 
31523
- const TabItem = props => {
31524
- const classes = clsx('relative', 'flex', 'z-0', 'py-2', 'leading-[24px]', 'before:h-px', 'before:absolute', 'before:left-0', 'before:right-0', 'before:bottom-0', 'hover:text-text-text01', 'disabled:text-disabled-disabled01', 'disabled:pointer-events-none', {
31525
- [`${typography.label.label2regular}`]: !props.isSelected,
31526
- ['text-interactive-interactive02 hover:before:bg-border-uiBorder02Dark']: !props.isSelected,
31527
- [`${typography.label.label2bold}`]: props.isSelected,
31528
- ['before:bg-interactive-interactive01 hover:before:bg-interactive-interactive01 pointer-events-none']: props.isSelected
31529
- });
31530
- return /*#__PURE__*/jsx("button", {
31531
- type: "button",
31532
- role: "tab",
31533
- "aria-selected": props.isSelected,
31534
- className: classes,
31535
- disabled: props.isDisabled,
31536
- onClick: () => props.onClick(props.id),
31537
- children: props.children
31538
- });
31539
- };
31540
-
31541
- function Tab({
31542
- children
31543
- }) {
31544
- const classes = clsx('flex', 'px-6', 'gap-4', 'relative', 'before:bg-border-uiBorder01', 'before:h-px', 'before:bottom-0', 'before:left-0', 'before:right-0', 'before:absolute', {});
31545
- return /*#__PURE__*/jsx("div", {
31546
- role: "tablist",
31547
- className: classes,
31548
- children: children
31549
- });
31550
- }
31551
- Tab.Item = TabItem;
31552
-
31553
- function ModalTab({
31554
- tabItems,
31555
- selectedTab,
31556
- setSelectedTab
31557
- }) {
31558
- return /*#__PURE__*/jsx("div", {
31559
- className: "mt-2 w-full",
31560
- children: /*#__PURE__*/jsx(Tab, {
31561
- children: tabItems.map(item => /*#__PURE__*/jsx(TabItem, {
31562
- id: item.id,
31563
- isSelected: selectedTab === item.id,
31564
- onClick: setSelectedTab,
31565
- children: item.label
31566
- }, item.id))
31567
- })
31568
- });
31569
- }
31570
-
31483
+ const LIMIT_WIDTH = 320;
31484
+ const LIMIT_HEIGHT = 184;
31571
31485
  function Modal({
31572
31486
  children,
31573
31487
  width = 480,
31574
31488
  height,
31575
31489
  isOpen,
31576
31490
  setIsOpen,
31577
- portalTargetRef,
31578
- headerElement,
31579
- tabElement,
31580
- buttonTabElement
31491
+ portalTargetRef
31581
31492
  }) {
31582
- const wrapperClasses = 'flex items-center justify-center z-overlay bg-background-backgroundOverlayBlack fixed left-0 top-0 h-full w-full';
31583
- const modalBaseClasses = 'flex shrink-0 flex-col bg-background-uiBackground01 rounded-lg shadow-modalShadow';
31584
- const contentClasses = 'flex items-center justify-center overflow-y-auto';
31493
+ const renderWidth = typeof width === 'number' ? Math.max(width, LIMIT_WIDTH) : width;
31494
+ const renderHeight = typeof height === 'number' ? Math.max(height, LIMIT_HEIGHT) : height;
31585
31495
  return /*#__PURE__*/reactDom.createPortal(isOpen && /*#__PURE__*/jsx(ModalContext.Provider, {
31586
31496
  value: {
31587
- width,
31588
31497
  setIsOpen
31589
31498
  },
31590
31499
  children: /*#__PURE__*/jsx("div", {
31591
- className: wrapperClasses,
31592
- children: /*#__PURE__*/jsxs("div", {
31593
- className: modalBaseClasses,
31500
+ className: "fixed left-0 top-0 z-overlay flex h-full w-full items-center justify-center bg-background-backgroundOverlayBlack",
31501
+ children: /*#__PURE__*/jsx("div", {
31502
+ className: "flex shrink-0 flex-col rounded-lg bg-background-uiBackground01 shadow-modalShadow",
31594
31503
  style: {
31595
- width,
31596
- height
31504
+ width: renderWidth,
31505
+ height: renderHeight
31597
31506
  },
31598
- children: [headerElement, tabElement, /*#__PURE__*/jsx("div", {
31599
- className: contentClasses,
31600
- children: children
31601
- }), buttonTabElement]
31507
+ children: children
31602
31508
  })
31603
31509
  })
31604
31510
  }), !portalTargetRef || (portalTargetRef == null ? void 0 : portalTargetRef.current) === null ? document.body : portalTargetRef.current);
31605
31511
  }
31512
+ Modal.Body = ModalBody;
31606
31513
  Modal.Header = ModalHeader;
31607
- Modal.Tab = ModalTab;
31608
- Modal.ButtonTab = ModalButtonTab;
31514
+ Modal.Footer = ModalFooter;
31609
31515
 
31610
- const _excluded$1 = ["state", "size"];
31516
+ const _excluded$2 = ["state", "size"];
31611
31517
  function NotificationInline(_ref) {
31612
31518
  let {
31613
31519
  state = 'default',
31614
31520
  size = 'medium'
31615
31521
  } = _ref,
31616
- props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
31522
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
31617
31523
  const wrapperClasses = clsx('rounded', 'text-text-text01', 'flex', 'gap-1', 'items-center', typography.body.body2regular, {
31618
31524
  'bg-background-uiBackgroundError': state === 'attention',
31619
31525
  'bg-background-uiBackgroundWarning': state === 'warning',
@@ -31961,13 +31867,13 @@ function Radio({
31961
31867
  });
31962
31868
  }
31963
31869
 
31964
- const _excluded = ["width", "size"];
31870
+ const _excluded$1 = ["width", "size"];
31965
31871
  const Search = /*#__PURE__*/forwardRef((_ref, ref) => {
31966
31872
  let {
31967
31873
  width = '100%',
31968
31874
  size = 'medium'
31969
31875
  } = _ref,
31970
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
31876
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
31971
31877
  const classes = clsx('flex', 'items-center', 'rounded-full', 'border', 'border-border-uiBorder02', 'focus-within:border-active-activeInput', {
31972
31878
  'h-8 px-3': size === 'medium'
31973
31879
  }, {
@@ -32138,6 +32044,36 @@ function SelectSort({
32138
32044
  });
32139
32045
  }
32140
32046
 
32047
+ const TabItem = props => {
32048
+ const classes = clsx('relative', 'flex', 'z-0', 'py-2', 'leading-[24px]', 'before:h-px', 'before:absolute', 'before:left-0', 'before:right-0', 'before:bottom-0', 'hover:text-text-text01', 'disabled:text-disabled-disabled01', 'disabled:pointer-events-none', {
32049
+ [`${typography.label.label2regular}`]: !props.isSelected,
32050
+ ['text-interactive-interactive02 hover:before:bg-border-uiBorder02Dark']: !props.isSelected,
32051
+ [`${typography.label.label2bold}`]: props.isSelected,
32052
+ ['before:bg-interactive-interactive01 hover:before:bg-interactive-interactive01 pointer-events-none']: props.isSelected
32053
+ });
32054
+ return /*#__PURE__*/jsx("button", {
32055
+ type: "button",
32056
+ role: "tab",
32057
+ "aria-selected": props.isSelected,
32058
+ className: classes,
32059
+ disabled: props.isDisabled,
32060
+ onClick: () => props.onClick(props.id),
32061
+ children: props.children
32062
+ });
32063
+ };
32064
+
32065
+ function Tab({
32066
+ children
32067
+ }) {
32068
+ const classes = clsx('flex', 'px-6', 'gap-4', 'relative', 'before:bg-border-uiBorder01', 'before:h-px', 'before:bottom-0', 'before:left-0', 'before:right-0', 'before:absolute', {});
32069
+ return /*#__PURE__*/jsx("div", {
32070
+ role: "tablist",
32071
+ className: classes,
32072
+ children: children
32073
+ });
32074
+ }
32075
+ Tab.Item = TabItem;
32076
+
32141
32077
  function TableCell({
32142
32078
  children,
32143
32079
  className
@@ -32237,6 +32173,44 @@ function Tag({
32237
32173
  });
32238
32174
  }
32239
32175
 
32176
+ const _excluded = ["size"];
32177
+ const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
32178
+ let {
32179
+ size = 'medium'
32180
+ } = _ref,
32181
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
32182
+ const inputWrapClasses = clsx('flex items-center gap-2 overflow-hidden rounded border pl-2 pr-3', {
32183
+ 'border-border-uiBorder01': !props.isError,
32184
+ 'border-support-supportError': props.isError && !props.disabled,
32185
+ 'hover:border-hover-hoverInput': !props.disabled && !props.isError,
32186
+ 'hover:focus-within:border-active-activeInput': !props.isError,
32187
+ 'focus-within:border-active-activeInput': !props.isError,
32188
+ 'bg-disabled-disabled02 border-disabled-disabled02': props.disabled
32189
+ });
32190
+ const inputClasses = clsx('flex-1 outline-0 placeholder:text-text-textPlaceholder disabled:text-text-text03', {
32191
+ [`${typography.label.label2regular} pt-1.5 pb-2`]: size === 'medium',
32192
+ [`${typography.label.label1regular} py-2.5`]: size === 'large',
32193
+ 'text-text-text01': !props.isError,
32194
+ 'text-support-supportError': props.isError
32195
+ });
32196
+ return /*#__PURE__*/jsxs("div", {
32197
+ className: inputWrapClasses,
32198
+ children: [/*#__PURE__*/jsx("input", _extends({
32199
+ ref: ref,
32200
+ size: 1,
32201
+ className: inputClasses,
32202
+ onChange: props.onChange
32203
+ }, props)), props.onClickClearButton && props.value && props.value.length !== 0 && !props.disabled && /*#__PURE__*/jsx(IconButton, {
32204
+ variant: "text",
32205
+ icon: "close",
32206
+ size: "small",
32207
+ isNoPadding: true,
32208
+ onClick: props.onClickClearButton
32209
+ })]
32210
+ });
32211
+ });
32212
+ TextInput.displayName = 'TextInput';
32213
+
32240
32214
  const CLOSE_TIME_MSEC = 5000;
32241
32215
  function Toast({
32242
32216
  state = 'information',
@@ -32492,5 +32466,5 @@ function Tooltip({
32492
32466
  });
32493
32467
  }
32494
32468
 
32495
- 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 };
32469
+ 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 };
32496
32470
  //# sourceMappingURL=index.js.map