@zenkigen-inc/component-ui 1.1.2 → 1.1.3

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
@@ -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, cloneElement, forwardRef } from 'react';
4
+ import aa, { useState, useCallback, useEffect, createContext, useContext, useRef, forwardRef } from 'react';
5
5
  import { iconElements } from '@zenkigen-inc/component-icons';
6
6
 
7
7
  function _objectWithoutPropertiesLoose(source, excluded) {
@@ -341,11 +341,7 @@ function Dropdown({
341
341
  }
342
342
  }, [isVisible]);
343
343
  const wrapperClasses = clsx$1('relative', 'flex shrink-0 items-center gap-1', 'rounded', isDisabled && 'cursor-not-allowed');
344
- const childrenButtonClasses = clsx$1('flex items-center justify-center', 'rounded', 'hover:bg-hover-hover02', 'active:bg-active-active02', focusVisible.normal, isDisabled && 'pointer-events-none', {
345
- 'h-6 w-6': size === 'x-small',
346
- 'h-8 w-8': size === 'small',
347
- 'h-10 w-10': size === 'medium',
348
- 'h-12 w-12': size === 'large',
344
+ const childrenButtonClasses = clsx$1('flex items-center justify-center', 'rounded', 'hover:bg-hover-hover02', 'active:bg-active-active02', focusVisible.normal, isDisabled && 'pointer-events-none', 'p-1', {
349
345
  'border border-border-uiBorder02': variant === 'outline'
350
346
  });
351
347
  const buttonClasses = clsx$1('flex items-center', 'rounded', buttonColors[variant].base, buttonColors[variant].hover, buttonColors[variant].active, buttonColors[variant].disabled, focusVisible.normal, isDisabled && 'pointer-events-none', {
@@ -354,9 +350,6 @@ function Dropdown({
354
350
  'h-10 px-4': size === 'large'
355
351
  });
356
352
  const labelClasses = clsx$1('flex', 'items-center', !isArrowHidden ? size === 'x-small' ? 'mr-1' : 'mr-2' : null, typography.label[size === 'x-small' ? 'label3regular' : size === 'small' || size === 'medium' ? 'label2regular' : 'label1regular']);
357
- const targetWithProps = target && /*#__PURE__*/cloneElement(target, {
358
- isDisabled
359
- });
360
353
  return /*#__PURE__*/jsx(DropdownContext.Provider, {
361
354
  value: {
362
355
  isVisible,
@@ -374,7 +367,7 @@ function Dropdown({
374
367
  className: childrenButtonClasses,
375
368
  onClick: handleToggle,
376
369
  disabled: isDisabled,
377
- children: targetWithProps
370
+ children: target
378
371
  }) : /*#__PURE__*/jsxs("button", {
379
372
  type: "button",
380
373
  title: title,
@@ -31668,129 +31661,6 @@ function NotificationInline(_ref) {
31668
31661
  });
31669
31662
  }
31670
31663
 
31671
- function Radio({
31672
- name,
31673
- value,
31674
- id,
31675
- label,
31676
- isChecked = false,
31677
- isDisabled = false,
31678
- onChange
31679
- }) {
31680
- const [isMouseOver, setIsMouseOver] = useState(false);
31681
- const handleMouseOverInput = useCallback(() => {
31682
- setIsMouseOver(true);
31683
- }, []);
31684
- const handleMouseOutInput = useCallback(() => {
31685
- setIsMouseOver(false);
31686
- }, []);
31687
- const handleChange = useCallback(e => !isDisabled && (onChange == null ? void 0 : onChange(e)), [isDisabled, onChange]);
31688
- const inputClasses = clsx$1('absolute', 'z-[1]', 'opacity-0', 'peer', 'h-6', 'w-6', {
31689
- 'cursor-not-allowed': isDisabled,
31690
- 'cursor-pointer': !isDisabled
31691
- });
31692
- const boxClasses = clsx$1('inline-flex', 'items-center', 'justify-center', 'h-5', 'w-5', 'bg-white', 'border', 'border-solid', 'rounded-full', focusVisible.normalPeer, {
31693
- 'border-disabled-disabled01 hover:border-disabled-disabled01': isDisabled && !isMouseOver,
31694
- 'border-hover-hoverUiBorder': !isDisabled && isMouseOver,
31695
- 'border-border-uiBorder03': !isDisabled,
31696
- 'cursor-not-allowed': isDisabled,
31697
- 'cursor-pointer': !isDisabled
31698
- });
31699
- const afterClasses = clsx$1('h-3', 'w-3', 'absolute', 'top-0', 'right-0', 'bottom-0', 'left-0', 'block', 'm-auto', 'rounded-full', {
31700
- 'bg-disabled-disabled01': isDisabled && isChecked,
31701
- 'bg-active-activeSelectedUi': !isDisabled && isChecked,
31702
- 'scale-0': !isChecked,
31703
- 'scale-100': isChecked
31704
- });
31705
- const hoverIndicatorClasses = clsx$1('w-3', 'h-3', 'inline-block', 'rounded-full', !isDisabled && !isChecked && isMouseOver && 'bg-hover-hoverUi');
31706
- const labelClasses = clsx$1('flex-[1_0_0]', 'ml-2', typography.label.label2regular, 'break-all', 'select-none', {
31707
- 'pointer-events-none cursor-not-allowed text-disabled-disabled01': isDisabled,
31708
- 'cursor-pointer text-text-text01': !isDisabled
31709
- });
31710
- return /*#__PURE__*/jsxs("div", {
31711
- className: "flex items-center",
31712
- children: [/*#__PURE__*/jsxs("div", {
31713
- className: "flex h-6 w-6 items-center justify-center",
31714
- children: [/*#__PURE__*/jsx("input", {
31715
- type: "checkbox",
31716
- value: value,
31717
- name: name,
31718
- id: id,
31719
- checked: isChecked,
31720
- disabled: isDisabled,
31721
- onChange: handleChange,
31722
- onMouseOver: handleMouseOverInput,
31723
- onMouseLeave: handleMouseOutInput,
31724
- className: inputClasses
31725
- }), /*#__PURE__*/jsx("div", {
31726
- className: boxClasses,
31727
- children: /*#__PURE__*/jsxs("div", {
31728
- className: "relative flex h-5 w-5 flex-[0_0_auto] items-center justify-center",
31729
- children: [/*#__PURE__*/jsx("span", {
31730
- className: afterClasses
31731
- }), /*#__PURE__*/jsx("span", {
31732
- className: hoverIndicatorClasses
31733
- })]
31734
- })
31735
- })]
31736
- }), /*#__PURE__*/jsx("label", {
31737
- htmlFor: id,
31738
- className: labelClasses,
31739
- children: label
31740
- })]
31741
- });
31742
- }
31743
-
31744
- const _excluded = ["width", "size"];
31745
- const Search = /*#__PURE__*/forwardRef((_ref, ref) => {
31746
- let {
31747
- width = '100%',
31748
- size = 'medium'
31749
- } = _ref,
31750
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
31751
- const classes = clsx('flex', 'items-center', 'rounded-full', 'border', 'border-border-uiBorder02', 'focus-within:border-active-activeInput', {
31752
- 'h-8 px-3': size === 'medium'
31753
- }, {
31754
- 'h-10 px-4': size === 'large'
31755
- });
31756
- const inputClasses = clsx('ml-2.5', 'mr-2.5', 'h-full', 'flex-1', 'outline-0', 'text-text-text01', 'placeholder:text-text-textPlaceholder', {
31757
- [`${typography.label.label2regular}`]: size === 'medium',
31758
- [`${typography.label.label1regular}`]: size === 'large'
31759
- });
31760
- return /*#__PURE__*/jsx("div", {
31761
- className: "relative",
31762
- ref: ref,
31763
- children: /*#__PURE__*/jsx("form", {
31764
- onSubmit: props.onSubmit,
31765
- children: /*#__PURE__*/jsxs("div", {
31766
- className: classes,
31767
- style: {
31768
- width
31769
- },
31770
- children: [/*#__PURE__*/jsx(Icon, {
31771
- name: "search",
31772
- color: "icon01",
31773
- size: "medium"
31774
- }), /*#__PURE__*/jsx("input", {
31775
- type: "text",
31776
- size: 1,
31777
- value: props.value,
31778
- className: inputClasses,
31779
- placeholder: props.placeholder,
31780
- onChange: props.onChange
31781
- }), props.onClickClearButton && props.value && props.value.length !== 0 && /*#__PURE__*/jsx(IconButton, {
31782
- variant: "text",
31783
- icon: "close",
31784
- size: size === 'medium' ? 'small' : 'medium',
31785
- isNoPadding: true,
31786
- onClick: props.onClickClearButton
31787
- })]
31788
- })
31789
- })
31790
- });
31791
- });
31792
- Search.displayName = 'Search';
31793
-
31794
31664
  const SelectContext = /*#__PURE__*/createContext({
31795
31665
  size: 'medium',
31796
31666
  setIsOptionListOpen: () => false,
@@ -31958,6 +31828,189 @@ function Select({
31958
31828
  }
31959
31829
  Select.Option = SelectItem$1;
31960
31830
 
31831
+ function PaginationSelect({
31832
+ totalSize,
31833
+ currentPage,
31834
+ sizePerPage,
31835
+ countLabel = '件',
31836
+ pageLabel = 'ページ',
31837
+ optionListMaxHeight = 190,
31838
+ onClickPrevButton,
31839
+ onClickNextButton,
31840
+ onChange
31841
+ }) {
31842
+ const pageMax = Math.ceil(totalSize / sizePerPage);
31843
+ const optionsList = [...Array(pageMax)].map((_, index) => {
31844
+ const value = (index + 1).toString();
31845
+ return {
31846
+ id: value,
31847
+ value,
31848
+ label: value
31849
+ };
31850
+ });
31851
+ return /*#__PURE__*/jsxs("nav", {
31852
+ "aria-label": "pagination",
31853
+ className: "flex items-center gap-x-1",
31854
+ children: [/*#__PURE__*/jsxs("div", {
31855
+ className: "flex items-center gap-x-2",
31856
+ children: [/*#__PURE__*/jsxs("div", {
31857
+ className: clsx$1('text-text-text01', typography.label.label2regular),
31858
+ children: [(currentPage - 1) * sizePerPage + 1, " -", ' ', currentPage * sizePerPage > totalSize ? totalSize : currentPage * sizePerPage, countLabel]
31859
+ }), /*#__PURE__*/jsx(Select, {
31860
+ size: "medium",
31861
+ variant: "outline",
31862
+ selectedOption: optionsList.find(option => option.value === currentPage.toString()),
31863
+ optionListMaxHeight: optionListMaxHeight,
31864
+ onChange: option => option && onChange(Number(option.value)),
31865
+ children: optionsList && optionsList.map(option => /*#__PURE__*/jsx(Select.Option, {
31866
+ option: option
31867
+ }, option.id))
31868
+ }), /*#__PURE__*/jsxs("div", {
31869
+ className: clsx$1('text-text-text03', typography.label.label2regular),
31870
+ children: ["/ ", pageMax, pageLabel]
31871
+ })]
31872
+ }), /*#__PURE__*/jsxs("div", {
31873
+ className: "flex items-center",
31874
+ children: [/*#__PURE__*/jsx(IconButton, {
31875
+ variant: "text",
31876
+ icon: "angle-left",
31877
+ size: "small",
31878
+ isDisabled: currentPage === 1,
31879
+ onClick: onClickPrevButton
31880
+ }), /*#__PURE__*/jsx(IconButton, {
31881
+ variant: "text",
31882
+ icon: "angle-right",
31883
+ size: "small",
31884
+ isDisabled: currentPage === pageMax,
31885
+ onClick: onClickNextButton
31886
+ })]
31887
+ })]
31888
+ });
31889
+ }
31890
+
31891
+ function Radio({
31892
+ name,
31893
+ value,
31894
+ id,
31895
+ label,
31896
+ isChecked = false,
31897
+ isDisabled = false,
31898
+ onChange
31899
+ }) {
31900
+ const [isMouseOver, setIsMouseOver] = useState(false);
31901
+ const handleMouseOverInput = useCallback(() => {
31902
+ setIsMouseOver(true);
31903
+ }, []);
31904
+ const handleMouseOutInput = useCallback(() => {
31905
+ setIsMouseOver(false);
31906
+ }, []);
31907
+ const handleChange = useCallback(e => !isDisabled && (onChange == null ? void 0 : onChange(e)), [isDisabled, onChange]);
31908
+ const inputClasses = clsx$1('absolute', 'z-[1]', 'opacity-0', 'peer', 'h-6', 'w-6', {
31909
+ 'cursor-not-allowed': isDisabled,
31910
+ 'cursor-pointer': !isDisabled
31911
+ });
31912
+ const boxClasses = clsx$1('inline-flex', 'items-center', 'justify-center', 'h-5', 'w-5', 'bg-white', 'border', 'border-solid', 'rounded-full', focusVisible.normalPeer, {
31913
+ 'border-disabled-disabled01 hover:border-disabled-disabled01': isDisabled && !isMouseOver,
31914
+ 'border-hover-hoverUiBorder': !isDisabled && isMouseOver,
31915
+ 'border-border-uiBorder03': !isDisabled,
31916
+ 'cursor-not-allowed': isDisabled,
31917
+ 'cursor-pointer': !isDisabled
31918
+ });
31919
+ const afterClasses = clsx$1('h-3', 'w-3', 'absolute', 'top-0', 'right-0', 'bottom-0', 'left-0', 'block', 'm-auto', 'rounded-full', {
31920
+ 'bg-disabled-disabled01': isDisabled && isChecked,
31921
+ 'bg-active-activeSelectedUi': !isDisabled && isChecked,
31922
+ 'scale-0': !isChecked,
31923
+ 'scale-100': isChecked
31924
+ });
31925
+ const hoverIndicatorClasses = clsx$1('w-3', 'h-3', 'inline-block', 'rounded-full', !isDisabled && !isChecked && isMouseOver && 'bg-hover-hoverUi');
31926
+ const labelClasses = clsx$1('flex-[1_0_0]', 'ml-2', typography.label.label2regular, 'break-all', 'select-none', {
31927
+ 'pointer-events-none cursor-not-allowed text-disabled-disabled01': isDisabled,
31928
+ 'cursor-pointer text-text-text01': !isDisabled
31929
+ });
31930
+ return /*#__PURE__*/jsxs("div", {
31931
+ className: "flex items-center",
31932
+ children: [/*#__PURE__*/jsxs("div", {
31933
+ className: "flex h-6 w-6 items-center justify-center",
31934
+ children: [/*#__PURE__*/jsx("input", {
31935
+ type: "checkbox",
31936
+ value: value,
31937
+ name: name,
31938
+ id: id,
31939
+ checked: isChecked,
31940
+ disabled: isDisabled,
31941
+ onChange: handleChange,
31942
+ onMouseOver: handleMouseOverInput,
31943
+ onMouseLeave: handleMouseOutInput,
31944
+ className: inputClasses
31945
+ }), /*#__PURE__*/jsx("div", {
31946
+ className: boxClasses,
31947
+ children: /*#__PURE__*/jsxs("div", {
31948
+ className: "relative flex h-5 w-5 flex-[0_0_auto] items-center justify-center",
31949
+ children: [/*#__PURE__*/jsx("span", {
31950
+ className: afterClasses
31951
+ }), /*#__PURE__*/jsx("span", {
31952
+ className: hoverIndicatorClasses
31953
+ })]
31954
+ })
31955
+ })]
31956
+ }), /*#__PURE__*/jsx("label", {
31957
+ htmlFor: id,
31958
+ className: labelClasses,
31959
+ children: label
31960
+ })]
31961
+ });
31962
+ }
31963
+
31964
+ const _excluded = ["width", "size"];
31965
+ const Search = /*#__PURE__*/forwardRef((_ref, ref) => {
31966
+ let {
31967
+ width = '100%',
31968
+ size = 'medium'
31969
+ } = _ref,
31970
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
31971
+ const classes = clsx('flex', 'items-center', 'rounded-full', 'border', 'border-border-uiBorder02', 'focus-within:border-active-activeInput', {
31972
+ 'h-8 px-3': size === 'medium'
31973
+ }, {
31974
+ 'h-10 px-4': size === 'large'
31975
+ });
31976
+ const inputClasses = clsx('ml-2.5', 'mr-2.5', 'h-full', 'flex-1', 'outline-0', 'text-text-text01', 'placeholder:text-text-textPlaceholder', {
31977
+ [`${typography.label.label2regular}`]: size === 'medium',
31978
+ [`${typography.label.label1regular}`]: size === 'large'
31979
+ });
31980
+ return /*#__PURE__*/jsx("div", {
31981
+ className: "relative",
31982
+ ref: ref,
31983
+ children: /*#__PURE__*/jsx("form", {
31984
+ onSubmit: props.onSubmit,
31985
+ children: /*#__PURE__*/jsxs("div", {
31986
+ className: classes,
31987
+ style: {
31988
+ width
31989
+ },
31990
+ children: [/*#__PURE__*/jsx(Icon, {
31991
+ name: "search",
31992
+ color: "icon01",
31993
+ size: "medium"
31994
+ }), /*#__PURE__*/jsx("input", {
31995
+ type: "text",
31996
+ size: 1,
31997
+ value: props.value,
31998
+ className: inputClasses,
31999
+ placeholder: props.placeholder,
32000
+ onChange: props.onChange
32001
+ }), props.onClickClearButton && props.value && props.value.length !== 0 && /*#__PURE__*/jsx(IconButton, {
32002
+ variant: "text",
32003
+ icon: "close",
32004
+ size: size === 'medium' ? 'small' : 'medium',
32005
+ isNoPadding: true,
32006
+ onClick: props.onClickClearButton
32007
+ })]
32008
+ })
32009
+ })
32010
+ });
32011
+ });
32012
+ Search.displayName = 'Search';
32013
+
31961
32014
  function SelectItem({
31962
32015
  children,
31963
32016
  isSortKey,
@@ -32439,5 +32492,5 @@ function Tooltip({
32439
32492
  });
32440
32493
  }
32441
32494
 
32442
- export { Avatar, Breadcrumb, Button, Checkbox, Dropdown, EvaluationStar, Heading, Icon, IconButton, Loading, Modal, NotificationInline, Radio, Search, Select, SelectSort, Tab, TabItem, Table, TableCell, TableRow, Tag, Toast, ToastProvider, Toggle, Tooltip, useToast };
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 };
32443
32496
  //# sourceMappingURL=index.js.map