@app-studio/web 0.8.24 → 0.8.25

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.
@@ -2494,7 +2494,8 @@
2494
2494
  options
2495
2495
  } = _ref;
2496
2496
  // Determines the default value based on the 'placeholder' and 'isMulti' props, setting to an empty array for multi-select or an empty string/single default option
2497
- var defaultValue = placeholder ? isMulti ? [] : '' : options[0].value;
2497
+ var defaultValue = placeholder ? isMulti ? [] : '' // If there's a placeholder, set default to empty array for multi-select or empty string for single select
2498
+ : Array.isArray(options) && options.length > 0 ? options[0].value : ''; // If no placeholder, use the first option value if available, otherwise undefined
2498
2499
  // State hook for managing visibility of the Select dropdown, initially set to hidden
2499
2500
  var [hide, setHide] = React__default.useState(true);
2500
2501
  // State hook for tracking mouse hover status over the Select component
@@ -2838,7 +2839,7 @@
2838
2839
  }, style), option.label));
2839
2840
  };
2840
2841
  var SelectBox = _ref2 => {
2841
- var _option$label;
2842
+ var _ref3;
2842
2843
  var {
2843
2844
  size = 'md',
2844
2845
  styles = {
@@ -2863,16 +2864,21 @@
2863
2864
  color: isDisabled ? 'color.trueGray.600' : 'color.blueGray.700',
2864
2865
  cursor: isDisabled ? 'not-allowed' : 'auto'
2865
2866
  }, styles['field'], styles['text']);
2866
- var option = options.find(option => option.value === value);
2867
- return /*#__PURE__*/React__default.createElement(Text, Object.assign({}, fieldStyles), (value === '' || value && value.length === 0) && !!placeholder ? placeholder : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, typeof value === 'string' ? (_option$label = option == null ? void 0 : option.label) != null ? _option$label : value : value && value.length > 0 && (/*#__PURE__*/React__default.createElement(Horizontal, {
2867
+ var option = options.length > 0 && options.find(option => option.value === value);
2868
+ return /*#__PURE__*/React__default.createElement(Text, Object.assign({}, fieldStyles), (value === '' || Array.isArray(value) && value.length === 0) && !!placeholder ? placeholder : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, typeof value === 'string' ? (_ref3 = option && option.label) != null ? _ref3 : value :
2869
+ // If value is an array and not empty, render MultiSelect options
2870
+ Array.isArray(value) && value.length > 0 ? (/*#__PURE__*/React__default.createElement(Horizontal, {
2868
2871
  gap: 6
2869
2872
  }, value.map(option => (/*#__PURE__*/React__default.createElement(MultiSelect, {
2870
2873
  key: option,
2871
2874
  option: option,
2872
2875
  removeOption: removeOption
2873
- }))))))));
2876
+ }))))) : (
2877
+ /*#__PURE__*/
2878
+ // Handle any other types of value (including objects or unexpected values)
2879
+ React__default.createElement("span", null, value)))));
2874
2880
  };
2875
- var HiddenSelect = _ref3 => {
2881
+ var HiddenSelect = _ref4 => {
2876
2882
  var {
2877
2883
  id,
2878
2884
  name,
@@ -2882,8 +2888,8 @@
2882
2888
  isDisabled = false,
2883
2889
  isReadOnly = false,
2884
2890
  options = []
2885
- } = _ref3,
2886
- props = _objectWithoutPropertiesLoose(_ref3, _excluded2$3);
2891
+ } = _ref4,
2892
+ props = _objectWithoutPropertiesLoose(_ref4, _excluded2$3);
2887
2893
  var handleChange = event => {
2888
2894
  if (onChange) onChange(event);
2889
2895
  };
@@ -2900,14 +2906,14 @@
2900
2906
  readOnly: isReadOnly,
2901
2907
  onChange: handleChange,
2902
2908
  multiple: isMulti
2903
- }, props), options.map(option => {
2909
+ }, props), options.length > 0 && options.map(option => {
2904
2910
  return /*#__PURE__*/React__default.createElement("option", {
2905
2911
  key: option.value,
2906
2912
  value: option.value
2907
2913
  }, option.label);
2908
2914
  }));
2909
2915
  };
2910
- var DropDown = _ref4 => {
2916
+ var DropDown = _ref5 => {
2911
2917
  var {
2912
2918
  size,
2913
2919
  styles = {
@@ -2917,7 +2923,7 @@
2917
2923
  callback = () => {},
2918
2924
  highlightedIndex,
2919
2925
  setHighlightedIndex
2920
- } = _ref4;
2926
+ } = _ref5;
2921
2927
  var itemStates = useItemState();
2922
2928
  var handleCallback = option => callback(option);
2923
2929
  var shadow = typeof document !== undefined ? {
@@ -2957,7 +2963,7 @@
2957
2963
  display: 'none'
2958
2964
  }
2959
2965
  }
2960
- }, shadow, styles['dropDown']), options.map((option, index) => (/*#__PURE__*/React__default.createElement(Item, Object.assign({
2966
+ }, shadow, styles['dropDown']), options.length > 0 && options.map((option, index) => (/*#__PURE__*/React__default.createElement(Item, Object.assign({
2961
2967
  key: option.value,
2962
2968
  size: size,
2963
2969
  style: styles['text'],
@@ -2967,13 +2973,13 @@
2967
2973
  onMouseEnter: () => setHighlightedIndex(index)
2968
2974
  }, itemStates)))));
2969
2975
  };
2970
- var MultiSelect = _ref5 => {
2976
+ var MultiSelect = _ref6 => {
2971
2977
  var {
2972
2978
  option,
2973
2979
  size = 'md',
2974
2980
  removeOption = () => {}
2975
- } = _ref5,
2976
- props = _objectWithoutPropertiesLoose(_ref5, _excluded3$2);
2981
+ } = _ref6,
2982
+ props = _objectWithoutPropertiesLoose(_ref6, _excluded3$2);
2977
2983
  var handleClick = () => removeOption(option);
2978
2984
  return /*#__PURE__*/React__default.createElement(Horizontal, Object.assign({
2979
2985
  gap: 10,
@@ -2992,7 +2998,7 @@
2992
2998
  onClick: handleClick
2993
2999
  }));
2994
3000
  };
2995
- var SelectView = _ref6 => {
3001
+ var SelectView = _ref7 => {
2996
3002
  var {
2997
3003
  id,
2998
3004
  name,
@@ -3028,8 +3034,8 @@
3028
3034
  setIsFocused = () => {},
3029
3035
  setHighlightedIndex,
3030
3036
  highlightedIndex
3031
- } = _ref6,
3032
- props = _objectWithoutPropertiesLoose(_ref6, _excluded4$2);
3037
+ } = _ref7,
3038
+ props = _objectWithoutPropertiesLoose(_ref7, _excluded4$2);
3033
3039
  var isWithLabel = !!(isFocused && label);
3034
3040
  var handleHover = () => setIsHovered(!isHovered);
3035
3041
  var handleFocus = () => setIsFocused(true);