@ctlyst.id/internal-ui 2.1.20 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -3478,13 +3478,13 @@ var selectStyle = {
3478
3478
  };
3479
3479
  function selectStyles(colorMode, _isError) {
3480
3480
  return {
3481
- control: (base, { isDisabled, isFocused }) => {
3481
+ control: (base, { isFocused }) => {
3482
3482
  const style = {
3483
3483
  ...base,
3484
3484
  flexWrap: "nowrap",
3485
3485
  borderColor: isFocused ? "var(--chakra-colors-primary-500)" : "var(--chakra-colors-neutral-400)",
3486
3486
  boxShadow: "none",
3487
- color: isDisabled ? "var(--chakra-colors-black-low)" : "var(--chakra-colors-black-high)",
3487
+ color: "var(--chakra-colors-black-low)",
3488
3488
  "&:hover": {
3489
3489
  borderColor: _isError ? "" : isFocused ? "var(--chakra-colors-primary-500)" : "var(--chakra-colors-neutral-500)"
3490
3490
  }
@@ -3502,23 +3502,47 @@ function selectStyles(colorMode, _isError) {
3502
3502
  ...selectStyle,
3503
3503
  color: "var(--chakra-colors-neutral-900)"
3504
3504
  }),
3505
- menu: (base) => colorMode === "dark" ? {
3506
- ...base,
3507
- ...selectStyle,
3508
- background: "dark.800",
3509
- zIndex: 5
3510
- } : {
3511
- ...base,
3512
- ...selectStyle,
3513
- zIndex: 5
3505
+ menu: (base) => {
3506
+ return {
3507
+ ...base,
3508
+ ...selectStyle,
3509
+ zIndex: 5
3510
+ };
3511
+ },
3512
+ singleValue: (base) => {
3513
+ return { ...base, ...selectStyle };
3514
+ },
3515
+ input: (base) => {
3516
+ return { ...base, ...selectStyle };
3517
+ },
3518
+ dropdownIndicator: (base) => {
3519
+ return { ...base, ...selectStyle };
3520
+ },
3521
+ indicatorSeparator: (base) => {
3522
+ return { ...base, ...selectStyle };
3514
3523
  },
3515
- singleValue: (base) => colorMode === "dark" ? { ...base, ...selectStyle, color: "white" } : { ...base, ...selectStyle },
3516
- input: (base) => colorMode === "dark" ? { ...base, ...selectStyle, color: "white" } : { ...base, ...selectStyle },
3517
- dropdownIndicator: (base) => colorMode === "dark" ? { ...base, ...selectStyle, color: "secondary.500" } : { ...base, ...selectStyle },
3518
- indicatorSeparator: (base) => colorMode === "dark" ? { ...base, ...selectStyle, backgroundColor: "secondary.500" } : { ...base, ...selectStyle },
3519
3524
  placeholder: (base) => {
3520
- return { ...base, ...selectStyle, color: "black.low" };
3521
- }
3525
+ return { ...base, ...selectStyle, color: "var(--chakra-colors-black-low)" };
3526
+ },
3527
+ multiValue: (base) => {
3528
+ return {
3529
+ ...base,
3530
+ borderRadius: 4,
3531
+ backgroundColor: "var(--chakra-colors-neutral-200)"
3532
+ };
3533
+ },
3534
+ multiValueLabel: (base) => ({
3535
+ ...base,
3536
+ borderRadius: 4,
3537
+ fontWeight: "bold"
3538
+ }),
3539
+ multiValueRemove: (base) => ({
3540
+ ...base,
3541
+ color: "var(--chakra-colors-neutral-900)",
3542
+ ":hover": {
3543
+ backgroundColor: "var(--chakra-colors-neutral-300)"
3544
+ }
3545
+ })
3522
3546
  };
3523
3547
  }
3524
3548
  var themeSelect = (theme6) => {
@@ -3610,12 +3634,149 @@ function SelectCreatable({ styles, isError = false, ...rest }) {
3610
3634
  );
3611
3635
  }
3612
3636
 
3637
+ // src/components/select/components/select-with-checkbox.tsx
3638
+ import { Checkbox as Checkbox3, Flex as Flex8, Text as Text14 } from "@chakra-ui/react";
3639
+ import { useColorMode as useColorMode7 } from "@chakra-ui/system";
3640
+ import ReactSelect2, { components as ComponentRS } from "react-select";
3641
+ import { Fragment as Fragment6, jsx as jsx55, jsxs as jsxs23 } from "react/jsx-runtime";
3642
+ var CHECKBOX_STATE = {
3643
+ UNCHECKED: 0,
3644
+ INDETERMINATE: 1,
3645
+ CHECKED: 2
3646
+ };
3647
+ var getSelectAllCheckboxState = (totalSelected, totalOption) => {
3648
+ if (totalSelected < 0 || totalOption < 0) {
3649
+ throw new Error("value less than 0");
3650
+ }
3651
+ if (totalSelected > totalOption) {
3652
+ throw new Error("totalSelected couldn't be more than totalOption");
3653
+ }
3654
+ if (totalSelected === 0) {
3655
+ return CHECKBOX_STATE.UNCHECKED;
3656
+ }
3657
+ if (totalSelected < totalOption) {
3658
+ return CHECKBOX_STATE.INDETERMINATE;
3659
+ }
3660
+ if (totalSelected === totalOption) {
3661
+ return CHECKBOX_STATE.CHECKED;
3662
+ }
3663
+ return CHECKBOX_STATE.UNCHECKED;
3664
+ };
3665
+ var InputOption = ({
3666
+ getStyles,
3667
+ isDisabled,
3668
+ isFocused,
3669
+ isSelected,
3670
+ children,
3671
+ innerProps,
3672
+ data,
3673
+ checkedState,
3674
+ isMulti,
3675
+ ...rest
3676
+ }) => {
3677
+ const style = {
3678
+ alignItems: "center",
3679
+ color: "inherit",
3680
+ display: "flex "
3681
+ };
3682
+ const props = {
3683
+ ...innerProps,
3684
+ "aria-disabled": isDisabled,
3685
+ onClick: isDisabled ? void 0 : innerProps.onClick,
3686
+ style
3687
+ };
3688
+ return /* @__PURE__ */ jsxs23(Fragment6, { children: [
3689
+ /* @__PURE__ */ jsx55(
3690
+ ComponentRS.Option,
3691
+ {
3692
+ isMulti: true,
3693
+ data,
3694
+ isDisabled,
3695
+ isFocused,
3696
+ isSelected,
3697
+ getStyles,
3698
+ innerProps: props,
3699
+ ...rest,
3700
+ children: /* @__PURE__ */ jsxs23(
3701
+ Flex8,
3702
+ {
3703
+ alignItems: "center",
3704
+ width: "100%",
3705
+ mb: "3px",
3706
+ gap: 2,
3707
+ "data-test-id": "CT_component_select-checkbox_options",
3708
+ cursor: isDisabled ? "not-allowed" : "default",
3709
+ children: [
3710
+ (data == null ? void 0 : data.selectAllCheckbox) ? /* @__PURE__ */ jsx55(
3711
+ Checkbox3,
3712
+ {
3713
+ isChecked: checkedState === CHECKBOX_STATE.CHECKED,
3714
+ isIndeterminate: checkedState === CHECKBOX_STATE.INDETERMINATE,
3715
+ isDisabled,
3716
+ "data-test-id": "CT_component_select-checkbox_select-all-option"
3717
+ }
3718
+ ) : /* @__PURE__ */ jsx55(Checkbox3, { isChecked: isSelected, "data-test-id": "CT_component_select-checkbox_option-checkbox" }),
3719
+ /* @__PURE__ */ jsx55(Text14, { textStyle: "text.sm", "data-test-id": `select-checkbox-option-label-${data.value}`, children })
3720
+ ]
3721
+ }
3722
+ )
3723
+ }
3724
+ ),
3725
+ (data == null ? void 0 : data.selectAllCheckbox) ? /* @__PURE__ */ jsx55("hr", {}) : null
3726
+ ] });
3727
+ };
3728
+ var SelectWithCheckboxBase = ({
3729
+ isError = false,
3730
+ components,
3731
+ options,
3732
+ ...rest
3733
+ }) => {
3734
+ const { colorMode } = useColorMode7();
3735
+ return /* @__PURE__ */ jsx55(
3736
+ ReactSelect2,
3737
+ {
3738
+ classNamePrefix: "react-select",
3739
+ options,
3740
+ styles: { ...selectStyles(colorMode, !!isError) },
3741
+ theme: themeSelect,
3742
+ closeMenuOnSelect: false,
3743
+ hideSelectedOptions: false,
3744
+ components: {
3745
+ ...components
3746
+ },
3747
+ ...rest
3748
+ }
3749
+ );
3750
+ };
3751
+ var SelectCheckbox = (props) => {
3752
+ const { isMulti, options, value, ...rest } = props;
3753
+ const selectValue = value || [];
3754
+ return /* @__PURE__ */ jsx55(
3755
+ SelectWithCheckboxBase,
3756
+ {
3757
+ isMulti,
3758
+ options,
3759
+ components: {
3760
+ Option: (optionProps) => {
3761
+ const { isSelected, data } = optionProps;
3762
+ const optionLength = (options == null ? void 0 : options.length) ? options.length - 1 : 0;
3763
+ const selectedValue = isSelected ? CHECKBOX_STATE.CHECKED : CHECKBOX_STATE.UNCHECKED;
3764
+ const checkedState = data.selectAllCheckbox ? getSelectAllCheckboxState(selectValue == null ? void 0 : selectValue.length, optionLength) : selectedValue;
3765
+ return /* @__PURE__ */ jsx55(InputOption, { ...optionProps, checkedState });
3766
+ }
3767
+ },
3768
+ ...rest
3769
+ }
3770
+ );
3771
+ };
3772
+ var select_with_checkbox_default = SelectCheckbox;
3773
+
3613
3774
  // src/components/switch/components/switch.tsx
3614
- import { chakra as chakra6, Flex as Flex8, forwardRef as forwardRef13, omitThemingProps as omitThemingProps2, useCheckbox as useCheckbox2, useMultiStyleConfig as useMultiStyleConfig2 } from "@chakra-ui/react";
3775
+ import { chakra as chakra6, Flex as Flex9, forwardRef as forwardRef13, omitThemingProps as omitThemingProps2, useCheckbox as useCheckbox2, useMultiStyleConfig as useMultiStyleConfig2 } from "@chakra-ui/react";
3615
3776
  import { cx as cx9, dataAttr } from "@chakra-ui/shared-utils";
3616
3777
  import { Check, Close as Close4 } from "@ctlyst.id/internal-icon";
3617
3778
  import { useMemo as useMemo4 } from "react";
3618
- import { jsx as jsx55, jsxs as jsxs23 } from "react/jsx-runtime";
3779
+ import { jsx as jsx56, jsxs as jsxs24 } from "react/jsx-runtime";
3619
3780
  var Switch = forwardRef13(function Switch2(props, ref) {
3620
3781
  const styles = useMultiStyleConfig2("Switch", props);
3621
3782
  const { spacing: spacing2 = "0.5rem", children, ...ownProps } = omitThemingProps2(props);
@@ -3658,7 +3819,7 @@ var Switch = forwardRef13(function Switch2(props, ref) {
3658
3819
  };
3659
3820
  return iconSize[value];
3660
3821
  };
3661
- return /* @__PURE__ */ jsxs23(
3822
+ return /* @__PURE__ */ jsxs24(
3662
3823
  chakra6.label,
3663
3824
  {
3664
3825
  ...getRootProps(),
@@ -3667,13 +3828,13 @@ var Switch = forwardRef13(function Switch2(props, ref) {
3667
3828
  className: cx9("chakra-switch", props.className),
3668
3829
  __css: containerStyles,
3669
3830
  children: [
3670
- /* @__PURE__ */ jsx55("input", { "data-test-id": "", className: "chakra-switch__input", ...getInputProps({}, ref) }),
3671
- /* @__PURE__ */ jsxs23(chakra6.span, { ...getCheckboxProps(), className: "chakra-switch__track", pos: "relative", __css: trackStyles, children: [
3672
- /* @__PURE__ */ jsxs23(Flex8, { gap: 2, pos: "absolute", top: "50%", left: "50%", transform: "translate(-50%, -50%)", children: [
3673
- /* @__PURE__ */ jsx55(Check, { color: "white", size: getIconSize(props.size) }),
3674
- /* @__PURE__ */ jsx55(Close4, { color: state.isDisabled ? "neutral.600" : "neutral.900", size: getIconSize(props.size) })
3831
+ /* @__PURE__ */ jsx56("input", { "data-test-id": "", className: "chakra-switch__input", ...getInputProps({}, ref) }),
3832
+ /* @__PURE__ */ jsxs24(chakra6.span, { ...getCheckboxProps(), className: "chakra-switch__track", pos: "relative", __css: trackStyles, children: [
3833
+ /* @__PURE__ */ jsxs24(Flex9, { gap: 2, pos: "absolute", top: "50%", left: "50%", transform: "translate(-50%, -50%)", children: [
3834
+ /* @__PURE__ */ jsx56(Check, { color: "white", size: getIconSize(props.size) }),
3835
+ /* @__PURE__ */ jsx56(Close4, { color: state.isDisabled ? "neutral.600" : "neutral.900", size: getIconSize(props.size) })
3675
3836
  ] }),
3676
- /* @__PURE__ */ jsx55(
3837
+ /* @__PURE__ */ jsx56(
3677
3838
  chakra6.span,
3678
3839
  {
3679
3840
  __css: styles.thumb,
@@ -3683,7 +3844,7 @@ var Switch = forwardRef13(function Switch2(props, ref) {
3683
3844
  }
3684
3845
  )
3685
3846
  ] }),
3686
- children && /* @__PURE__ */ jsx55(
3847
+ children && /* @__PURE__ */ jsx56(
3687
3848
  chakra6.span,
3688
3849
  {
3689
3850
  className: "chakra-switch__label",
@@ -3719,14 +3880,14 @@ import {
3719
3880
  } from "@chakra-ui/react";
3720
3881
 
3721
3882
  // src/components/tabs/components/tab.tsx
3722
- import { Button as Button5, Flex as Flex9, forwardRef as forwardRef14, useMultiStyleConfig as useMultiStyleConfig3, useTab } from "@chakra-ui/react";
3723
- import { jsx as jsx56, jsxs as jsxs24 } from "react/jsx-runtime";
3883
+ import { Button as Button5, Flex as Flex10, forwardRef as forwardRef14, useMultiStyleConfig as useMultiStyleConfig3, useTab } from "@chakra-ui/react";
3884
+ import { jsx as jsx57, jsxs as jsxs25 } from "react/jsx-runtime";
3724
3885
  var Tab = forwardRef14((props, ref) => {
3725
3886
  var _a, _b;
3726
3887
  const tabProps = useTab({ ...props, ref });
3727
3888
  const isSelected = !!tabProps["aria-selected"];
3728
3889
  const styles = useMultiStyleConfig3("Tabs", tabProps);
3729
- return /* @__PURE__ */ jsx56(
3890
+ return /* @__PURE__ */ jsx57(
3730
3891
  Button5,
3731
3892
  {
3732
3893
  "data-test-id": props["data-test-id"],
@@ -3752,7 +3913,7 @@ var Tab = forwardRef14((props, ref) => {
3752
3913
  },
3753
3914
  __css: styles.tab,
3754
3915
  ...tabProps,
3755
- children: /* @__PURE__ */ jsxs24(Flex9, { alignItems: "center", children: [
3916
+ children: /* @__PURE__ */ jsxs25(Flex10, { alignItems: "center", children: [
3756
3917
  (_a = props.leftAddon) == null ? void 0 : _a.call(props, { isSelected }),
3757
3918
  tabProps.children,
3758
3919
  (_b = props.rightAddon) == null ? void 0 : _b.call(props, { isSelected })
@@ -3798,13 +3959,13 @@ import {
3798
3959
  } from "@chakra-ui/react";
3799
3960
 
3800
3961
  // src/components/text/index.ts
3801
- import { Code, CodeProps, Heading, HeadingProps, Link as Link4, LinkProps, Text as Text14, TextProps } from "@chakra-ui/react";
3962
+ import { Code, CodeProps, Heading, HeadingProps, Link as Link4, LinkProps, Text as Text15, TextProps } from "@chakra-ui/react";
3802
3963
 
3803
3964
  // src/components/tooltip/index.ts
3804
3965
  import { Tooltip, TooltipProps } from "@chakra-ui/react";
3805
3966
 
3806
3967
  // src/components/uploader/components/uploader.tsx
3807
- import { Flex as Flex10, Heading as Heading2, Stack as Stack4, Text as Text15 } from "@chakra-ui/react";
3968
+ import { Flex as Flex11, Heading as Heading2, Stack as Stack4, Text as Text16 } from "@chakra-ui/react";
3808
3969
  import * as React15 from "react";
3809
3970
  import { useDropzone } from "react-dropzone";
3810
3971
 
@@ -3818,7 +3979,7 @@ var messages = {
3818
3979
  };
3819
3980
 
3820
3981
  // src/components/uploader/components/uploader.tsx
3821
- import { jsx as jsx57, jsxs as jsxs25 } from "react/jsx-runtime";
3982
+ import { jsx as jsx58, jsxs as jsxs26 } from "react/jsx-runtime";
3822
3983
  var Uploader = ({
3823
3984
  onHandleUploadFile,
3824
3985
  onHandleRejections,
@@ -3866,9 +4027,9 @@ var Uploader = ({
3866
4027
  React15.useEffect(() => {
3867
4028
  setIsSelected(selected != null ? selected : false);
3868
4029
  }, [selected]);
3869
- return /* @__PURE__ */ jsxs25(Stack4, { direction: "column", children: [
3870
- /* @__PURE__ */ jsxs25(
3871
- Flex10,
4030
+ return /* @__PURE__ */ jsxs26(Stack4, { direction: "column", children: [
4031
+ /* @__PURE__ */ jsxs26(
4032
+ Flex11,
3872
4033
  {
3873
4034
  minH: 200,
3874
4035
  border: "1px dashed",
@@ -3879,11 +4040,11 @@ var Uploader = ({
3879
4040
  ...props,
3880
4041
  ...getRootProps(),
3881
4042
  children: [
3882
- /* @__PURE__ */ jsx57("input", { ...getInputProps() }),
3883
- isDragActive ? /* @__PURE__ */ jsx57(Text15, { children: messages.dragActive }) : /* @__PURE__ */ jsxs25(Flex10, { flexDirection: "column", alignItems: "center", color: isError ? "danger.500" : "primary.500", children: [
3884
- !multiple && isSelected && /* @__PURE__ */ jsx57(Heading2, { fontWeight: 400, fontSize: "18px", lineHeight: 28, color: "black.high", mb: 2, children: selectedFirstFile == null ? void 0 : selectedFirstFile.name }),
3885
- !isSelected && /* @__PURE__ */ jsx57(Heading2, { fontWeight: 400, fontSize: "18px", lineHeight: 28, mb: 2, children: messages.uploadFile }),
3886
- isSelected ? /* @__PURE__ */ jsx57(Text15, { children: messages.dragReplace }) : /* @__PURE__ */ jsx57(Text15, { children: messages.dragInActive })
4043
+ /* @__PURE__ */ jsx58("input", { ...getInputProps() }),
4044
+ isDragActive ? /* @__PURE__ */ jsx58(Text16, { children: messages.dragActive }) : /* @__PURE__ */ jsxs26(Flex11, { flexDirection: "column", alignItems: "center", color: isError ? "danger.500" : "primary.500", children: [
4045
+ !multiple && isSelected && /* @__PURE__ */ jsx58(Heading2, { fontWeight: 400, fontSize: "18px", lineHeight: 28, color: "black.high", mb: 2, children: selectedFirstFile == null ? void 0 : selectedFirstFile.name }),
4046
+ !isSelected && /* @__PURE__ */ jsx58(Heading2, { fontWeight: 400, fontSize: "18px", lineHeight: 28, mb: 2, children: messages.uploadFile }),
4047
+ isSelected ? /* @__PURE__ */ jsx58(Text16, { children: messages.dragReplace }) : /* @__PURE__ */ jsx58(Text16, { children: messages.dragInActive })
3887
4048
  ] })
3888
4049
  ]
3889
4050
  }
@@ -4581,14 +4742,14 @@ var variants2 = {
4581
4742
  errors,
4582
4743
  unstyled
4583
4744
  };
4584
- var Checkbox3 = defineMultiStyleConfig3({
4745
+ var Checkbox4 = defineMultiStyleConfig3({
4585
4746
  baseStyle: baseStyle3,
4586
4747
  variants: variants2,
4587
4748
  defaultProps: {
4588
4749
  variant: "unstyled"
4589
4750
  }
4590
4751
  });
4591
- var checkbox_default2 = Checkbox3;
4752
+ var checkbox_default2 = Checkbox4;
4592
4753
 
4593
4754
  // src/config/theme/components/chips.ts
4594
4755
  import { defineStyleConfig as defineStyleConfig3 } from "@chakra-ui/styled-system";
@@ -5490,7 +5651,7 @@ import { useMemo as useMemo7 } from "react";
5490
5651
  import axios from "axios";
5491
5652
  import { createContext as createContext2, useContext, useEffect as useEffect3, useMemo as useMemo6, useRef as useRef2 } from "react";
5492
5653
  import { ToastContainer } from "react-toastify";
5493
- import { jsx as jsx58, jsxs as jsxs26 } from "react/jsx-runtime";
5654
+ import { jsx as jsx59, jsxs as jsxs27 } from "react/jsx-runtime";
5494
5655
  var ProviderContext = createContext2({
5495
5656
  instance: void 0
5496
5657
  });
@@ -5509,8 +5670,8 @@ var Provider = ({ children, config: config2, requestInterceptors, responseInterc
5509
5670
  });
5510
5671
  }, [requestInterceptors, responseInterceptors]);
5511
5672
  const provider = useMemo6(() => ({ instance: instanceRef.current }), []);
5512
- return /* @__PURE__ */ jsxs26(ProviderContext.Provider, { value: provider, children: [
5513
- /* @__PURE__ */ jsx58(ToastContainer, {}),
5673
+ return /* @__PURE__ */ jsxs27(ProviderContext.Provider, { value: provider, children: [
5674
+ /* @__PURE__ */ jsx59(ToastContainer, {}),
5514
5675
  children
5515
5676
  ] });
5516
5677
  };
@@ -5552,7 +5713,7 @@ function useFetcher() {
5552
5713
  import {
5553
5714
  useBoolean,
5554
5715
  useClipboard,
5555
- useColorMode as useColorMode7,
5716
+ useColorMode as useColorMode8,
5556
5717
  useColorModeValue as useColorModeValue12,
5557
5718
  useConst,
5558
5719
  useControllableProp,
@@ -5610,6 +5771,7 @@ export {
5610
5771
  button_default as Button,
5611
5772
  ButtonGroup,
5612
5773
  ButtonGroupProps,
5774
+ CHECKBOX_STATE,
5613
5775
  card_default as Card,
5614
5776
  Center,
5615
5777
  ChakraProvider,
@@ -5756,6 +5918,7 @@ export {
5756
5918
  select_default as Select,
5757
5919
  select_async_default as SelectAsync,
5758
5920
  SelectAsyncCreatable,
5921
+ select_with_checkbox_default as SelectCheckBox,
5759
5922
  SelectCreatable,
5760
5923
  Show,
5761
5924
  ShowProps,
@@ -5800,7 +5963,7 @@ export {
5800
5963
  TabsProvider,
5801
5964
  Tbody2 as Tbody,
5802
5965
  Td2 as Td,
5803
- Text14 as Text,
5966
+ Text15 as Text,
5804
5967
  TextProps,
5805
5968
  textarea_default as TextareaField,
5806
5969
  Th2 as Th,
@@ -5846,6 +6009,7 @@ export {
5846
6009
  WrapProps,
5847
6010
  extendTheme2 as extendTheme,
5848
6011
  forwardRef15 as forwardRef,
6012
+ getSelectAllCheckboxState,
5849
6013
  getTheme,
5850
6014
  theme5 as theme,
5851
6015
  useAccordion,
@@ -5859,7 +6023,7 @@ export {
5859
6023
  useCheckbox,
5860
6024
  useCheckboxGroup,
5861
6025
  useClipboard,
5862
- useColorMode7 as useColorMode,
6026
+ useColorMode8 as useColorMode,
5863
6027
  useColorModePreference,
5864
6028
  useColorModeValue12 as useColorModeValue,
5865
6029
  useConst,