@ctlyst.id/internal-ui 3.2.1 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -513,6 +513,7 @@ var Field = (props) => {
513
513
  isRequired,
514
514
  children,
515
515
  isSuccess,
516
+ isDisabled,
516
517
  boxProps = {}
517
518
  } = props;
518
519
  const getHelperColor = () => {
@@ -526,12 +527,39 @@ var Field = (props) => {
526
527
  };
527
528
  const helperColor = getHelperColor();
528
529
  const justifyHelper = getJustifyContentHelper();
530
+ const getProperties = () => {
531
+ let outlineColor2 = "neutral.400";
532
+ let focusColor2 = "primary.500";
533
+ if (isError || isDisabled || isSuccess) {
534
+ if (isError) outlineColor2 = "danger.500";
535
+ else if (isSuccess) outlineColor2 = "success.500";
536
+ focusColor2 = outlineColor2;
537
+ }
538
+ return {
539
+ outlineColor: outlineColor2,
540
+ focusColor: focusColor2
541
+ };
542
+ };
543
+ const { outlineColor, focusColor } = getProperties();
529
544
  return /* @__PURE__ */ jsxs3(FormControl, { isInvalid: isError, ...boxProps, children: [
530
545
  label && (typeof label === "string" ? /* @__PURE__ */ jsxs3(FormLabel, { mb: 1, fontSize: "text.sm", requiredIndicator: void 0, children: [
531
546
  isRequired && /* @__PURE__ */ jsx17(Box6, { as: "span", color: "danger.500", ml: 0, mr: 1, children: "*" }),
532
547
  label
533
548
  ] }) : label),
534
- children,
549
+ /* @__PURE__ */ jsx17(
550
+ Box6,
551
+ {
552
+ transition: "all 0.15s",
553
+ boxShadow: "none",
554
+ borderRadius: "sm",
555
+ border: "1px solid",
556
+ borderColor: outlineColor,
557
+ _focusWithin: {
558
+ borderColor: focusColor
559
+ },
560
+ children
561
+ }
562
+ ),
535
563
  (isError && errorMessage || leftHelperText || rightHelperText) && /* @__PURE__ */ jsxs3(Box6, { display: "flex", width: "full", justifyContent: justifyHelper, children: [
536
564
  !isError ? leftHelperText && (typeof leftHelperText === "string" ? /* @__PURE__ */ jsx17(FormHelperText, { fontSize: "text.xs", color: helperColor, mt: 1, children: leftHelperText }) : leftHelperText) : typeof errorMessage === "string" ? /* @__PURE__ */ jsx17(FormErrorMessage, { fontSize: "text.xs", color: "danger.500", mt: 1, children: errorMessage }) : errorMessage,
537
565
  rightHelperText && (typeof rightHelperText === "string" ? /* @__PURE__ */ jsx17(FormHelperText, { fontSize: "text.xs", color: helperColor, mt: 1, children: rightHelperText }) : rightHelperText)
@@ -669,19 +697,6 @@ var InputField = React2.forwardRef((props, ref) => {
669
697
  isLoading,
670
698
  ...inputProps
671
699
  } = props;
672
- const getProperties = () => {
673
- let outlineColor2 = "neutral.400";
674
- let focusColor2 = "primary.500";
675
- if (isError || isDisabled || isSuccess) {
676
- if (isError) outlineColor2 = "danger.500";
677
- else if (isSuccess) outlineColor2 = "success.500";
678
- focusColor2 = outlineColor2;
679
- }
680
- return {
681
- outlineColor: outlineColor2,
682
- focusColor: focusColor2
683
- };
684
- };
685
700
  const [isShowPassword, setIsShowPassword] = useState(false);
686
701
  const inputType = useMemo(() => {
687
702
  return type === "password" && isShowPassword ? "text" : type;
@@ -695,7 +710,6 @@ var InputField = React2.forwardRef((props, ref) => {
695
710
  const iconColor = useMemo(() => {
696
711
  return isDisabled ? "black.low" : "black.medium";
697
712
  }, [isDisabled]);
698
- const { outlineColor, focusColor } = getProperties();
699
713
  return /* @__PURE__ */ jsx21(
700
714
  field_default,
701
715
  {
@@ -706,92 +720,80 @@ var InputField = React2.forwardRef((props, ref) => {
706
720
  leftHelperText,
707
721
  rightHelperText,
708
722
  isRequired,
709
- children: /* @__PURE__ */ jsx21(
710
- Box8,
723
+ isDisabled,
724
+ children: /* @__PURE__ */ jsxs5(
725
+ InputGroup,
711
726
  {
712
- transition: "all 0.15s",
713
- boxShadow: "none",
727
+ size: size2,
714
728
  borderRadius: "sm",
715
- border: "1px solid",
716
- borderColor: outlineColor,
717
- _focusWithin: {
718
- borderColor: focusColor
719
- },
720
- children: /* @__PURE__ */ jsxs5(
721
- InputGroup,
722
- {
723
- size: size2,
724
- borderRadius: "sm",
725
- backgroundColor: isDisabled ? "neutral.300" : "white.high",
726
- cursor: isDisabled ? "not-allowed" : "default",
727
- children: [
728
- addOnLeft,
729
- /* @__PURE__ */ jsx21(
730
- ChakraInput,
731
- {
732
- ref,
733
- type: inputType,
734
- value,
735
- isDisabled,
736
- isSuccess,
737
- ...inputProps,
738
- fontSize
739
- }
740
- ),
741
- (withClear || isLoading || type === "password") && /* @__PURE__ */ jsxs5(
742
- Box8,
743
- {
744
- "data-test-id": "CT_Component_ClearInput",
745
- display: "flex",
746
- alignItems: "center",
747
- justifyContent: "center",
748
- width: "16px",
749
- mr: "10px",
750
- children: [
751
- withClear && !isLoading && /* @__PURE__ */ jsx21(
752
- Box8,
753
- {
754
- display: "flex",
755
- justifyContent: "center",
756
- onClick: !isDisabled ? onClear : void 0,
757
- cursor: isDisabled ? "not-allowed" : "pointer",
758
- children: /* @__PURE__ */ jsx21(Close2, { size: 4, color: iconColor })
759
- }
760
- ),
761
- type === "password" && !isShowPassword && !isLoading && /* @__PURE__ */ jsx21(
762
- Box8,
763
- {
764
- "data-test-id": "q2Bj2G4FlamXyHuRKMZ1Q",
765
- onClick: () => {
766
- if (!isDisabled) setIsShowPassword(true);
767
- },
768
- cursor: isDisabled ? "not-allowed" : "pointer",
769
- display: "flex",
770
- justifyContent: "center",
771
- children: /* @__PURE__ */ jsx21(EyeOff, { size: 4, color: iconColor })
772
- }
773
- ),
774
- type === "password" && isShowPassword && !isLoading && /* @__PURE__ */ jsx21(
775
- Box8,
776
- {
777
- "data-test-id": "sfc2388bmeXBmdla45Ibk",
778
- onClick: () => {
779
- if (!isDisabled) setIsShowPassword(false);
780
- },
781
- cursor: isDisabled ? "not-allowed" : "pointer",
782
- display: "flex",
783
- justifyContent: "center",
784
- children: /* @__PURE__ */ jsx21(Eye2, { size: 4, color: iconColor })
785
- }
786
- ),
787
- isLoading && /* @__PURE__ */ jsx21(loader_default, { size: "sm" })
788
- ]
789
- }
790
- ),
791
- addOnRight
792
- ]
793
- }
794
- )
729
+ backgroundColor: isDisabled ? "neutral.300" : "white.high",
730
+ cursor: isDisabled ? "not-allowed" : "default",
731
+ children: [
732
+ addOnLeft,
733
+ /* @__PURE__ */ jsx21(
734
+ ChakraInput,
735
+ {
736
+ ref,
737
+ type: inputType,
738
+ value,
739
+ isDisabled,
740
+ isSuccess,
741
+ ...inputProps,
742
+ fontSize
743
+ }
744
+ ),
745
+ (withClear || isLoading || type === "password") && /* @__PURE__ */ jsxs5(
746
+ Box8,
747
+ {
748
+ "data-test-id": "CT_Component_ClearInput",
749
+ display: "flex",
750
+ alignItems: "center",
751
+ justifyContent: "center",
752
+ width: "16px",
753
+ mr: "10px",
754
+ children: [
755
+ withClear && !isLoading && /* @__PURE__ */ jsx21(
756
+ Box8,
757
+ {
758
+ display: "flex",
759
+ justifyContent: "center",
760
+ onClick: !isDisabled ? onClear : void 0,
761
+ cursor: isDisabled ? "not-allowed" : "pointer",
762
+ children: /* @__PURE__ */ jsx21(Close2, { size: 4, color: iconColor })
763
+ }
764
+ ),
765
+ type === "password" && !isShowPassword && !isLoading && /* @__PURE__ */ jsx21(
766
+ Box8,
767
+ {
768
+ "data-test-id": "q2Bj2G4FlamXyHuRKMZ1Q",
769
+ onClick: () => {
770
+ if (!isDisabled) setIsShowPassword(true);
771
+ },
772
+ cursor: isDisabled ? "not-allowed" : "pointer",
773
+ display: "flex",
774
+ justifyContent: "center",
775
+ children: /* @__PURE__ */ jsx21(EyeOff, { size: 4, color: iconColor })
776
+ }
777
+ ),
778
+ type === "password" && isShowPassword && !isLoading && /* @__PURE__ */ jsx21(
779
+ Box8,
780
+ {
781
+ "data-test-id": "sfc2388bmeXBmdla45Ibk",
782
+ onClick: () => {
783
+ if (!isDisabled) setIsShowPassword(false);
784
+ },
785
+ cursor: isDisabled ? "not-allowed" : "pointer",
786
+ display: "flex",
787
+ justifyContent: "center",
788
+ children: /* @__PURE__ */ jsx21(Eye2, { size: 4, color: iconColor })
789
+ }
790
+ ),
791
+ isLoading && /* @__PURE__ */ jsx21(loader_default, { size: "sm" })
792
+ ]
793
+ }
794
+ ),
795
+ addOnRight
796
+ ]
795
797
  }
796
798
  )
797
799
  }
@@ -1228,7 +1230,6 @@ import {
1228
1230
  FormControl as FormControl3,
1229
1231
  FormErrorMessage as FormErrorMessage3,
1230
1232
  FormHelperText as FormHelperText3,
1231
- FormLabel as FormLabel3,
1232
1233
  IconButton as IconButton4,
1233
1234
  InputGroup as InputGroup4,
1234
1235
  InputRightElement as InputRightElement3
@@ -2169,7 +2170,7 @@ var Datepicker = ({
2169
2170
  id,
2170
2171
  name,
2171
2172
  selected,
2172
- customInput: /* @__PURE__ */ jsx27(input_field_default, { autoComplete: "off" }),
2173
+ customInput: /* @__PURE__ */ jsx27(input_field_default, { label, isRequired, autoComplete: "off", isError }),
2173
2174
  showPopperArrow: false,
2174
2175
  calendarClassName: cx8({ inline: props.inline }),
2175
2176
  dropdownMode: "select",
@@ -2186,8 +2187,7 @@ var Datepicker = ({
2186
2187
  if (props.inline) {
2187
2188
  return component;
2188
2189
  }
2189
- return /* @__PURE__ */ jsxs10(FormControl3, { isRequired, "data-test-id": "CT_Component_datepicker_wrapper", isInvalid: isError, children: [
2190
- label && /* @__PURE__ */ jsx27(FormLabel3, { fontSize: "text.sm", children: label }),
2190
+ return /* @__PURE__ */ jsxs10(FormControl3, { "data-test-id": "CT_Component_datepicker_wrapper", isInvalid: isError, children: [
2191
2191
  /* @__PURE__ */ jsxs10(InputGroup4, { children: [
2192
2192
  component,
2193
2193
  /* @__PURE__ */ jsxs10(InputRightElement3, { alignSelf: "center", bottom: 0, flexDir: "row-reverse", width: "auto", mr: 2, gap: 2, children: [
@@ -4812,7 +4812,7 @@ import {
4812
4812
  Button as Button7,
4813
4813
  Flex as Flex18,
4814
4814
  FormControl as FormControl4,
4815
- FormLabel as FormLabel4,
4815
+ FormLabel as FormLabel3,
4816
4816
  Heading as Heading2,
4817
4817
  Image as ChakraImage,
4818
4818
  ListItem as ListItem2,
@@ -4970,7 +4970,7 @@ var Uploader = ({
4970
4970
  return /* @__PURE__ */ jsxs30(FormControl4, { isRequired, children: [
4971
4971
  label && typeof label === "string" ? (
4972
4972
  // eslint-disable-next-line react/jsx-no-useless-fragment
4973
- /* @__PURE__ */ jsxs30(FormLabel4, { requiredIndicator: /* @__PURE__ */ jsx65(Fragment11, {}), fontSize: "text.sm", children: [
4973
+ /* @__PURE__ */ jsxs30(FormLabel3, { requiredIndicator: /* @__PURE__ */ jsx65(Fragment11, {}), fontSize: "text.sm", children: [
4974
4974
  isRequired && /* @__PURE__ */ jsx65(RequiredIndicator2, { mr: 1, ml: 0 }),
4975
4975
  label
4976
4976
  ] })
@@ -5884,10 +5884,10 @@ var baseStyle5 = defineStyle2({
5884
5884
  marginEnd: 1,
5885
5885
  mb: 1
5886
5886
  });
5887
- var FormLabel5 = defineStyleConfig3({
5887
+ var FormLabel4 = defineStyleConfig3({
5888
5888
  baseStyle: baseStyle5
5889
5889
  });
5890
- var form_label_default = FormLabel5;
5890
+ var form_label_default = FormLabel4;
5891
5891
 
5892
5892
  // src/config/theme/components/input.ts
5893
5893
  import { inputAnatomy as parts3 } from "@chakra-ui/anatomy";