@activecollab/components 1.0.323 → 1.0.325

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.
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- var _excluded = ["className", "style", "type", "disabled", "size", "invalid", "startAdornment", "endAdornment", "wrapRef"];
3
+ var _excluded = ["className", "style", "type", "disabled", "size", "invalid", "startAdornment", "endAdornment", "wrapRef", "wrapperClick"];
4
4
  import React, { useCallback, useRef } from "react";
5
5
  import classnames from "classnames";
6
6
  import { StyledInput, StyledInputWrapper } from "./Styles";
@@ -20,13 +20,15 @@ export var Input = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
20
20
  startAdornment = _ref.startAdornment,
21
21
  endAdornment = _ref.endAdornment,
22
22
  wrapRef = _ref.wrapRef,
23
+ wrapperClick = _ref.wrapperClick,
23
24
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
24
25
  var intInputRef = useRef(null);
25
26
  var handleRef = useForkRef(ref, intInputRef);
26
27
  var handleWrapperClick = useCallback(function () {
27
28
  var _intInputRef$current;
28
29
  (_intInputRef$current = intInputRef.current) == null ? void 0 : _intInputRef$current.focus();
29
- }, []);
30
+ wrapperClick && wrapperClick();
31
+ }, [wrapperClick]);
30
32
  return /*#__PURE__*/React.createElement(StyledInputWrapper, {
31
33
  $size: size,
32
34
  $invalid: invalid,
@@ -1 +1 @@
1
- {"version":3,"file":"Input.js","names":["React","useCallback","useRef","classnames","StyledInput","StyledInputWrapper","useForkRef","Input","forwardRef","ref","className","style","type","disabled","size","invalid","startAdornment","endAdornment","wrapRef","rest","intInputRef","handleRef","handleWrapperClick","current","focus","displayName"],"sources":["../../../../src/components/Input/Input.tsx"],"sourcesContent":["import React, { ReactNode, Ref, useCallback, useRef } from \"react\";\nimport classnames from \"classnames\";\nimport { StyledInput, StyledInputWrapper } from \"./Styles\";\nimport useForkRef from \"../../utils/useForkRef\";\nimport { InputSize } from \"./types\";\nexport interface InputProps {\n /** Velicina inputa koja definse font-size i border radius */\n size?: InputSize;\n invalid?: boolean;\n startAdornment?: ReactNode;\n endAdornment?: ReactNode;\n wrapRef?: Ref<HTMLDivElement>;\n}\n\nexport const Input = React.forwardRef<\n HTMLInputElement,\n InputProps & Omit<React.ComponentPropsWithoutRef<\"input\">, keyof InputProps>\n>(\n (\n {\n className = \"\",\n style,\n type = \"text\",\n disabled = false,\n size = \"regular\",\n invalid = false,\n startAdornment,\n endAdornment,\n wrapRef,\n ...rest\n },\n ref\n ) => {\n const intInputRef = useRef<HTMLInputElement>(null);\n const handleRef = useForkRef(ref, intInputRef);\n\n const handleWrapperClick = useCallback(() => {\n intInputRef.current?.focus();\n }, []);\n\n return (\n <StyledInputWrapper\n $size={size}\n $invalid={invalid}\n $disabled={disabled}\n style={style}\n className={classnames(\"c-input-wrapper\", className)}\n onClick={handleWrapperClick}\n ref={wrapRef}\n >\n {startAdornment}\n <StyledInput\n ref={handleRef}\n type={type}\n $size={size}\n disabled={disabled}\n className=\"c-input\"\n aria-invalid={invalid}\n data-form-type=\"other\"\n {...rest}\n />\n {endAdornment}\n </StyledInputWrapper>\n );\n }\n);\n\nInput.displayName = \"Input\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAoBC,WAAW,EAAEC,MAAM,QAAQ,OAAO;AAClE,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,WAAW,EAAEC,kBAAkB,QAAQ,UAAU;AAC1D,OAAOC,UAAU,MAAM,wBAAwB;AAW/C,OAAO,IAAMC,KAAK,gBAAGP,KAAK,CAACQ,UAAU,CAInC,gBAaEC,GAAG,EACA;EAAA,0BAZDC,SAAS;IAATA,SAAS,+BAAG,EAAE;IACdC,KAAK,QAALA,KAAK;IAAA,iBACLC,IAAI;IAAJA,IAAI,0BAAG,MAAM;IAAA,qBACbC,QAAQ;IAARA,QAAQ,8BAAG,KAAK;IAAA,iBAChBC,IAAI;IAAJA,IAAI,0BAAG,SAAS;IAAA,oBAChBC,OAAO;IAAPA,OAAO,6BAAG,KAAK;IACfC,cAAc,QAAdA,cAAc;IACdC,YAAY,QAAZA,YAAY;IACZC,OAAO,QAAPA,OAAO;IACJC,IAAI;EAIT,IAAMC,WAAW,GAAGlB,MAAM,CAAmB,IAAI,CAAC;EAClD,IAAMmB,SAAS,GAAGf,UAAU,CAACG,GAAG,EAAEW,WAAW,CAAC;EAE9C,IAAME,kBAAkB,GAAGrB,WAAW,CAAC,YAAM;IAAA;IAC3C,wBAAAmB,WAAW,CAACG,OAAO,qBAAnB,qBAAqBC,KAAK,EAAE;EAC9B,CAAC,EAAE,EAAE,CAAC;EAEN,oBACE,oBAAC,kBAAkB;IACjB,KAAK,EAAEV,IAAK;IACZ,QAAQ,EAAEC,OAAQ;IAClB,SAAS,EAAEF,QAAS;IACpB,KAAK,EAAEF,KAAM;IACb,SAAS,EAAER,UAAU,CAAC,iBAAiB,EAAEO,SAAS,CAAE;IACpD,OAAO,EAAEY,kBAAmB;IAC5B,GAAG,EAAEJ;EAAQ,GAEZF,cAAc,eACf,oBAAC,WAAW;IACV,GAAG,EAAEK,SAAU;IACf,IAAI,EAAET,IAAK;IACX,KAAK,EAAEE,IAAK;IACZ,QAAQ,EAAED,QAAS;IACnB,SAAS,EAAC,SAAS;IACnB,gBAAcE,OAAQ;IACtB,kBAAe;EAAO,GAClBI,IAAI,EACR,EACDF,YAAY,CACM;AAEzB,CAAC,CACF;AAEDV,KAAK,CAACkB,WAAW,GAAG,OAAO"}
1
+ {"version":3,"file":"Input.js","names":["React","useCallback","useRef","classnames","StyledInput","StyledInputWrapper","useForkRef","Input","forwardRef","ref","className","style","type","disabled","size","invalid","startAdornment","endAdornment","wrapRef","wrapperClick","rest","intInputRef","handleRef","handleWrapperClick","current","focus","displayName"],"sources":["../../../../src/components/Input/Input.tsx"],"sourcesContent":["import React, { ReactNode, Ref, useCallback, useRef } from \"react\";\nimport classnames from \"classnames\";\nimport { StyledInput, StyledInputWrapper } from \"./Styles\";\nimport useForkRef from \"../../utils/useForkRef\";\nimport { InputSize } from \"./types\";\nexport interface InputProps {\n /** Velicina inputa koja definse font-size i border radius */\n size?: InputSize;\n invalid?: boolean;\n startAdornment?: ReactNode;\n endAdornment?: ReactNode;\n wrapRef?: Ref<HTMLDivElement>;\n wrapperClick?: () => void;\n}\n\nexport const Input = React.forwardRef<\n HTMLInputElement,\n InputProps & Omit<React.ComponentPropsWithoutRef<\"input\">, keyof InputProps>\n>(\n (\n {\n className = \"\",\n style,\n type = \"text\",\n disabled = false,\n size = \"regular\",\n invalid = false,\n startAdornment,\n endAdornment,\n wrapRef,\n wrapperClick,\n ...rest\n },\n ref\n ) => {\n const intInputRef = useRef<HTMLInputElement>(null);\n const handleRef = useForkRef(ref, intInputRef);\n\n const handleWrapperClick = useCallback(() => {\n intInputRef.current?.focus();\n wrapperClick && wrapperClick();\n }, [wrapperClick]);\n\n return (\n <StyledInputWrapper\n $size={size}\n $invalid={invalid}\n $disabled={disabled}\n style={style}\n className={classnames(\"c-input-wrapper\", className)}\n onClick={handleWrapperClick}\n ref={wrapRef}\n >\n {startAdornment}\n <StyledInput\n ref={handleRef}\n type={type}\n $size={size}\n disabled={disabled}\n className=\"c-input\"\n aria-invalid={invalid}\n data-form-type=\"other\"\n {...rest}\n />\n {endAdornment}\n </StyledInputWrapper>\n );\n }\n);\n\nInput.displayName = \"Input\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAoBC,WAAW,EAAEC,MAAM,QAAQ,OAAO;AAClE,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,WAAW,EAAEC,kBAAkB,QAAQ,UAAU;AAC1D,OAAOC,UAAU,MAAM,wBAAwB;AAY/C,OAAO,IAAMC,KAAK,gBAAGP,KAAK,CAACQ,UAAU,CAInC,gBAcEC,GAAG,EACA;EAAA,0BAbDC,SAAS;IAATA,SAAS,+BAAG,EAAE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put$2.displayName = "StyledInput";
10930
10930
 
10931
- var _excluded$I = ["className", "style", "type", "disabled", "size", "invalid", "startAdornment", "endAdornment", "wrapRef"];
10931
+ var _excluded$I = ["className", "style", "type", "disabled", "size", "invalid", "startAdornment", "endAdornment", "wrapRef", "wrapperClick"];
10932
10932
  var Input = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
10933
10933
  var _ref$className = _ref.className,
10934
10934
  className = _ref$className === void 0 ? "" : _ref$className,
@@ -10944,13 +10944,15 @@
10944
10944
  startAdornment = _ref.startAdornment,
10945
10945
  endAdornment = _ref.endAdornment,
10946
10946
  wrapRef = _ref.wrapRef,
10947
+ wrapperClick = _ref.wrapperClick,
10947
10948
  rest = _objectWithoutProperties(_ref, _excluded$I);
10948
10949
  var intInputRef = React.useRef(null);
10949
10950
  var handleRef = useForkRef(ref, intInputRef);
10950
10951
  var handleWrapperClick = React.useCallback(function () {
10951
10952
  var _intInputRef$current;
10952
10953
  (_intInputRef$current = intInputRef.current) === null || _intInputRef$current === void 0 ? void 0 : _intInputRef$current.focus();
10953
- }, []);
10954
+ wrapperClick && wrapperClick();
10955
+ }, [wrapperClick]);
10954
10956
  return /*#__PURE__*/React__default["default"].createElement(StyledInputWrapper, {
10955
10957
  $size: size,
10956
10958
  $invalid: invalid,
@@ -14436,6 +14438,10 @@
14436
14438
  _useState2 = _slicedToArray(_useState, 2),
14437
14439
  value = _useState2[0],
14438
14440
  setValue = _useState2[1];
14441
+ var _useState3 = React.useState(false),
14442
+ _useState4 = _slicedToArray(_useState3, 2),
14443
+ focused = _useState4[0],
14444
+ setFocused = _useState4[1];
14439
14445
  var handleOnChange = React.useCallback(function (e) {
14440
14446
  return setValue(e.target.value);
14441
14447
  }, []);
@@ -14445,10 +14451,10 @@
14445
14451
  var wrapperRef = React.useRef(null);
14446
14452
  var chipWrapper = React.useRef(null);
14447
14453
  var comboBoxRef = React.useRef(null);
14448
- var _useState3 = React.useState(false),
14449
- _useState4 = _slicedToArray(_useState3, 2),
14450
- open = _useState4[0],
14451
- setOpen = _useState4[1];
14454
+ var _useState5 = React.useState(false),
14455
+ _useState6 = _slicedToArray(_useState5, 2),
14456
+ open = _useState6[0],
14457
+ setOpen = _useState6[1];
14452
14458
  var isFirstRender = useIsFirstRender();
14453
14459
  useOnClickOutside(wrapperRef, function (e) {
14454
14460
  var _comboBoxRef$current;
@@ -14466,10 +14472,10 @@
14466
14472
  if (e.key === "Enter" && type === "multiple") {
14467
14473
  setValue("");
14468
14474
  }
14469
- if (e.key === "Enter" && !open) {
14475
+ if (e.key === "Enter" && !open && focused) {
14470
14476
  setOpen(true);
14471
14477
  }
14472
- }, [open, selectedName, type]);
14478
+ }, [focused, open, selectedName, type]);
14473
14479
  React.useEffect(function () {
14474
14480
  var _childNode$current, _childNode$current2;
14475
14481
  open && (childNode === null || childNode === void 0 ? void 0 : (_childNode$current = childNode.current) === null || _childNode$current === void 0 ? void 0 : _childNode$current.focus());
@@ -14479,12 +14485,12 @@
14479
14485
  setValue(selectedName);
14480
14486
  }, [selectedName]);
14481
14487
  React.useEffect(function () {
14482
- if (!open && !isFirstRender) {
14488
+ if (!open && !isFirstRender && !focused) {
14483
14489
  if (typeof onClose === "function") {
14484
14490
  onClose();
14485
14491
  }
14486
14492
  }
14487
- }, [isFirstRender, onClose, open]);
14493
+ }, [focused, isFirstRender, onClose, open]);
14488
14494
  var emptyAction = React.useCallback(function (v) {
14489
14495
  handleEmptyAction === null || handleEmptyAction === void 0 ? void 0 : handleEmptyAction(v);
14490
14496
  setOpen(false);
@@ -14537,7 +14543,8 @@
14537
14543
  }, []);
14538
14544
  var handleBlur = React.useCallback(function () {
14539
14545
  setValue(selectedName);
14540
- }, [selectedName]);
14546
+ setFocused(!focused);
14547
+ }, [focused, selectedName]);
14541
14548
  var renderChipAdornment = React.useCallback(function (option, index) {
14542
14549
  if (typeof renderChip === "function") {
14543
14550
  return renderChip(option, index);
@@ -14669,7 +14676,7 @@
14669
14676
  className: classNames__default["default"]("c-combo-box-input-wrapper", inputWrapperClassName),
14670
14677
  onClick: function onClick() {
14671
14678
  var _elementRef$current;
14672
- (_elementRef$current = elementRef.current) === null || _elementRef$current === void 0 ? void 0 : _elementRef$current.focus();
14679
+ (_elementRef$current = elementRef.current) === null || _elementRef$current === void 0 ? void 0 : _elementRef$current.click();
14673
14680
  },
14674
14681
  $_css3: autoSize === "auto" ? "auto" : undefined,
14675
14682
  $_css4: autoSize === "auto" && scrollWrapper ? "scroll" : undefined,
@@ -14681,6 +14688,9 @@
14681
14688
  }, startAdornment, /*#__PURE__*/React__default["default"].createElement(StyledInput$2, {
14682
14689
  className: "c-combo-box-input",
14683
14690
  onBlur: handleBlur,
14691
+ onFocus: function onFocus() {
14692
+ setFocused(!focused);
14693
+ },
14684
14694
  onClick: onOpen,
14685
14695
  ref: handleRef,
14686
14696
  value: loading && loadingText ? loadingText : value,
@@ -14705,6 +14715,10 @@
14705
14715
  }))))) : /*#__PURE__*/React__default["default"].createElement(StyledComboBoxInput, {
14706
14716
  className: classNames__default["default"]("c-combo-box-input", inputWrapperClassName),
14707
14717
  onBlur: handleBlur,
14718
+ wrapperClick: onOpen,
14719
+ onFocus: function onFocus() {
14720
+ setFocused(!focused);
14721
+ },
14708
14722
  onClick: onOpen,
14709
14723
  wrapRef: comboBoxRef,
14710
14724
  ref: handleRef,