@seeqdev/qomponents 0.0.190 → 0.0.191

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
@@ -3863,7 +3863,7 @@ var removedBarSizeVariable = '--removed-body-scroll-bar-size';
3863
3863
  * assignRef(refObject, "refValue");
3864
3864
  * assignRef(refFn, "refValue");
3865
3865
  */
3866
- function assignRef(ref, value) {
3866
+ function assignRef$1(ref, value) {
3867
3867
  if (typeof ref === 'function') {
3868
3868
  ref(value);
3869
3869
  }
@@ -3930,7 +3930,7 @@ var currentValues = new WeakMap();
3930
3930
  */
3931
3931
  function useMergeRefs(refs, defaultValue) {
3932
3932
  var callbackRef = useCallbackRef(null, function (newValue) {
3933
- return refs.forEach(function (ref) { return assignRef(ref, newValue); });
3933
+ return refs.forEach(function (ref) { return assignRef$1(ref, newValue); });
3934
3934
  });
3935
3935
  // handle refs changes - added or removed
3936
3936
  useIsomorphicLayoutEffect$1(function () {
@@ -3941,12 +3941,12 @@ function useMergeRefs(refs, defaultValue) {
3941
3941
  var current_1 = callbackRef.current;
3942
3942
  prevRefs_1.forEach(function (ref) {
3943
3943
  if (!nextRefs_1.has(ref)) {
3944
- assignRef(ref, null);
3944
+ assignRef$1(ref, null);
3945
3945
  }
3946
3946
  });
3947
3947
  nextRefs_1.forEach(function (ref) {
3948
3948
  if (!prevRefs_1.has(ref)) {
3949
- assignRef(ref, current_1);
3949
+ assignRef$1(ref, current_1);
3950
3950
  }
3951
3951
  });
3952
3952
  }
@@ -4908,6 +4908,41 @@ const setValidInputDimension = (width, height) => {
4908
4908
  return inputStyle;
4909
4909
  };
4910
4910
 
4911
+ function assignRef(ref, value) {
4912
+ if (typeof ref === "function") {
4913
+ return ref(value);
4914
+ } else if (typeof ref === "object" && ref !== null && "current" in ref) {
4915
+ ref.current = value;
4916
+ }
4917
+ }
4918
+ function mergeRefs(...refs) {
4919
+ const cleanupMap = /* @__PURE__ */ new Map();
4920
+ return (node) => {
4921
+ refs.forEach((ref) => {
4922
+ const cleanup = assignRef(ref, node);
4923
+ if (cleanup) {
4924
+ cleanupMap.set(ref, cleanup);
4925
+ }
4926
+ });
4927
+ if (cleanupMap.size > 0) {
4928
+ return () => {
4929
+ refs.forEach((ref) => {
4930
+ const cleanup = cleanupMap.get(ref);
4931
+ if (cleanup && typeof cleanup === "function") {
4932
+ cleanup();
4933
+ } else {
4934
+ assignRef(ref, null);
4935
+ }
4936
+ });
4937
+ cleanupMap.clear();
4938
+ };
4939
+ }
4940
+ };
4941
+ }
4942
+ function useMergedRef(...refs) {
4943
+ return React.useCallback(mergeRefs(...refs), refs);
4944
+ }
4945
+
4911
4946
  const errorClasses$4 = 'tw:border-sq-danger';
4912
4947
  const borderColorClasses$4 = [
4913
4948
  'tw:border-sq-disabled-gray',
@@ -4933,13 +4968,9 @@ const sizeClasses = {
4933
4968
  const TextField = React.forwardRef((props, ref) => {
4934
4969
  const { readonly = false, disabled = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, id, name, size = 'sm', value, placeholder, extraClassNames, testId, type = 'text', inputGroup, step, showError, errorText, min, max, maxLength, minLength, required = false, autoComplete = 'off', inputWidth = undefined, inputHeight = undefined, autoFocus = false, ...tooltipProps } = props;
4935
4970
  const internalRef = React.useRef(null);
4971
+ const mergedRef = useMergedRef(ref, internalRef);
4936
4972
  const [cursor, setCursor] = React.useState(null);
4937
4973
  const tooltipData = getQTipData(tooltipProps);
4938
- const setAllRefs = (receivedRef) => {
4939
- if (ref)
4940
- ref.current = receivedRef;
4941
- internalRef.current = receivedRef;
4942
- };
4943
4974
  React.useEffect(() => {
4944
4975
  if (autoFocus) {
4945
4976
  setTimeout(() => {
@@ -4985,7 +5016,7 @@ const TextField = React.forwardRef((props, ref) => {
4985
5016
  inputLenghtProp.maxLength = maxLength;
4986
5017
  if (minLength)
4987
5018
  inputLenghtProp.minLength = minLength;
4988
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("input", { ref: setAllRefs, "data-testid": testId, name: name, id: id, type: type, value: value, className: appliedClasses, placeholder: placeholder, disabled: disabled, readOnly: readonly, autoComplete: autoComplete, onChange: handleChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onKeyUp: onKeyUp, step: step, required: required, min: min, max: max, ...inputLenghtProp, ...inputProp, ...tooltipData }), errorText && showError && jsxRuntime.jsx("div", { className: "tw:text-sq-danger tw:text-xs tw:mt-1", children: errorText })] }));
5019
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("input", { ref: mergedRef, "data-testid": testId, name: name, id: id, type: type, value: value, className: appliedClasses, placeholder: placeholder, disabled: disabled, readOnly: readonly, autoComplete: autoComplete, onChange: handleChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onKeyUp: onKeyUp, step: step, required: required, min: min, max: max, ...inputLenghtProp, ...inputProp, ...tooltipData }), errorText && showError && jsxRuntime.jsx("div", { className: "tw:text-sq-danger tw:text-xs tw:mt-1", children: errorText })] }));
4989
5020
  });
4990
5021
 
4991
5022
  const alignment = 'tw:flex';
@@ -5030,6 +5061,7 @@ const borderColorClasses$3 = [
5030
5061
  const TextArea = React.forwardRef(({ readonly = false, disabled = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, onSelectionChange, id, name, rows = 3, cols = undefined, value, placeholder, showError, extraClassNames, testId, autoFocus = false, }, ref) => {
5031
5062
  const appliedClasses = `${baseClasses$4} ${extraClassNames} ${lightTheme$2} ${darkTheme$2} ${showError ? errorClasses$3 : borderColorClasses$3}`;
5032
5063
  const textareaRef = React.useRef(null);
5064
+ const mergedRef = useMergedRef(ref, textareaRef);
5033
5065
  // Handle selection change events
5034
5066
  React.useEffect(() => {
5035
5067
  if (!onSelectionChange || !textareaRef.current) {
@@ -5050,15 +5082,7 @@ const TextArea = React.forwardRef(({ readonly = false, disabled = false, onChang
5050
5082
  textarea.removeEventListener('keyup', handleSelectionChange);
5051
5083
  };
5052
5084
  }, [onSelectionChange]);
5053
- return (jsxRuntime.jsx("textarea", { ref: (element) => {
5054
- textareaRef.current = element;
5055
- if (typeof ref === 'function') {
5056
- ref(element);
5057
- }
5058
- else if (ref) {
5059
- ref.current = element;
5060
- }
5061
- }, "data-testid": testId, name: name, id: id, value: value, className: appliedClasses, placeholder: placeholder, disabled: disabled, readOnly: readonly, onChange: onChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onKeyUp: onKeyUp, rows: rows, cols: cols, autoFocus: autoFocus }));
5085
+ return (jsxRuntime.jsx("textarea", { ref: mergedRef, "data-testid": testId, name: name, id: id, value: value, className: appliedClasses, placeholder: placeholder, disabled: disabled, readOnly: readonly, onChange: onChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onKeyUp: onKeyUp, rows: rows, cols: cols, autoFocus: autoFocus }));
5062
5086
  });
5063
5087
 
5064
5088
  /**
@@ -29443,7 +29467,7 @@ exports.ProgressBar = ProgressBar;
29443
29467
  exports.QTip = QTip;
29444
29468
  exports.SeeqActionDropdown = SeeqActionDropdown;
29445
29469
  exports.Select = Select;
29446
- exports.SelectCompoents = components;
29470
+ exports.SelectComponents = components;
29447
29471
  exports.Slider = Slider;
29448
29472
  exports.Tabs = Tabs;
29449
29473
  exports.TextArea = TextArea;