@ballistix.digital/react-components 9.10.0 → 9.10.1

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
@@ -2233,14 +2233,14 @@ const $0c7305af577f9538$var$base = {
2233
2233
  input: 'w-full flex border',
2234
2234
  menuButton: '',
2235
2235
  menu: 'z-10 px-0! py-0! w-full! rounded-md overflow-hidden border mt-1! absolute bg-white',
2236
- tagItem: 'bg-gray-200 px-2 py-1 flex flex-row gap-x-1 items-center justify-between rounded-xs',
2236
+ tagItem: 'bg-gray-200 px-2 py-1 flex flex-row gap-x-1 items-center justify-between rounded-md',
2237
2237
  tagItemText: 'text-xs',
2238
2238
  tagItemIconContainer: 'p-0! rounded-full hover:bg-gray-400 text-sm hover:text-white aspect-square w-4 flex items-center justify-center cursor-pointer',
2239
2239
  tagItemIcon: '',
2240
2240
  list: 'px-0! w-full! *:px-0 max-h-56 overflow-scroll py-1!',
2241
2241
  listGroupLabel: '',
2242
2242
  listItem: 'w-full! list-none! hover:bg-primary-500 hover:text-white py-2! px-2! cursor-pointer',
2243
- listDisabledItem: '',
2243
+ listDisabledItem: 'w-full! list-none! py-2! px-2! cursor-not-allowed text-gray-400',
2244
2244
  searchContainer: 'w-full! px-2! py-2! border-b',
2245
2245
  searchBox: '',
2246
2246
  searchIcon: '',
@@ -2297,7 +2297,7 @@ var $0c7305af577f9538$export$2e2bcd8739ae039 = $0c7305af577f9538$var$styles;
2297
2297
 
2298
2298
 
2299
2299
  const $cb1b9d36d0757897$var$SelectMenu = (props)=>{
2300
- const { name: name = 'select-menu-form', label: label, description: description, hint: hint, placeholder: placeholder, options: options, required: required, value: value, error: error, isRequired: isRequired = false, isLoading: isLoading, isTouched: isTouched = false, isDisabled: isDisabled, isClearable: isClearable = true, isMultiple: isMultiple = false, isSearchable: isSearchable = true, isSolo: isSolo = false, isOptionalLabelHidden: isOptionalLabelHidden = false, onChange: onChange, onSearchInputChange: onSearchInputChange, onClear: onClear, onBlur: onBlur, searchInputOptionRenderer: searchInputOptionRenderer, dataTestId: dataTestId, styles: stylesOverrides } = props;
2300
+ const { name: name = 'select-menu-form', label: label, description: description, hint: hint, placeholder: placeholder, options: options, required: required, value: value, error: error, isRequired: isRequired = false, isLoading: isLoading, isTouched: isTouched = false, isDisabled: isDisabled, isClearable: isClearable = true, isMultiple: isMultiple = false, isSearchable: isSearchable = true, isSolo: isSolo = false, isOptionalLabelHidden: isOptionalLabelHidden = false, onChange: onChange, onSearchInputChange: onSearchInputChange, onClear: onClear, onBlur: onBlur, optionRenderer: optionRenderer, searchInputOptionRenderer: searchInputOptionRenderer, dataTestId: dataTestId, styles: stylesOverrides } = props;
2301
2301
  const [isFocus, setIsFocus] = (0, $iA2ta$react.useState)(true);
2302
2302
  const [state, setState] = (0, $iA2ta$react.useState)(value ?? null);
2303
2303
  const [searchValue, setSearchValue] = (0, $iA2ta$react.useState)();
@@ -2311,16 +2311,6 @@ const $cb1b9d36d0757897$var$SelectMenu = (props)=>{
2311
2311
  });
2312
2312
  return result;
2313
2313
  };
2314
- const handleChange = (selectValue)=>{
2315
- setState(selectValue);
2316
- onChange && onChange(selectValue);
2317
- setIsFocus(false);
2318
- if (searchInputOptionRenderer) setSearchValue(null);
2319
- };
2320
- const handleSearchInputChange = (e)=>{
2321
- if (searchInputOptionRenderer) setSearchValue(e.target.value);
2322
- onSearchInputChange?.(e);
2323
- };
2324
2314
  const computedOptions = (0, $iA2ta$react.useMemo)(()=>{
2325
2315
  if (!searchInputOptionRenderer || !searchValue) return options;
2326
2316
  if (options.some((opt)=>opt.label.toLowerCase().includes(searchValue.toLowerCase()))) return options;
@@ -2337,6 +2327,26 @@ const $cb1b9d36d0757897$var$SelectMenu = (props)=>{
2337
2327
  options,
2338
2328
  searchValue
2339
2329
  ]);
2330
+ const optionsByValue = (0, $iA2ta$react.useMemo)(()=>(0, $iA2ta$lodash.keyBy)(computedOptions, 'value'), [
2331
+ computedOptions
2332
+ ]);
2333
+ const handleChange = (selectValue)=>{
2334
+ const applyValue = (nextValue)=>{
2335
+ setState(nextValue);
2336
+ onChange && onChange(nextValue);
2337
+ setIsFocus(false);
2338
+ if (searchInputOptionRenderer) setSearchValue(null);
2339
+ };
2340
+ // A single selection is handed back straight from `options`.
2341
+ if (!Array.isArray(selectValue)) return applyValue(selectValue);
2342
+ // A multiple selection echoes the value we passed in, which carries a rendered `label`
2343
+ // (see `libraryValue`), so resolve those entries to the options we were given.
2344
+ return applyValue(selectValue.map((option)=>optionsByValue[option.value] ?? option));
2345
+ };
2346
+ const handleSearchInputChange = (e)=>{
2347
+ if (searchInputOptionRenderer) setSearchValue(e.target.value);
2348
+ onSearchInputChange?.(e);
2349
+ };
2340
2350
  const styles = handleGenerateStyle();
2341
2351
  // Simulate onClear event.
2342
2352
  (0, $iA2ta$react.useEffect)(()=>{
@@ -2386,8 +2396,10 @@ const $cb1b9d36d0757897$var$SelectMenu = (props)=>{
2386
2396
  name
2387
2397
  ]);
2388
2398
  const formattedError = (0, $iA2ta$react.useMemo)(()=>{
2389
- if (error) return JSON.stringify(error).replaceAll('"', '');
2390
- return null;
2399
+ if (!error) return null;
2400
+ if (typeof error === 'string') return error;
2401
+ if ((0, $iA2ta$lodash.isArray)(error)) return (0, $iA2ta$lodash.join)((0, $iA2ta$lodash.map)(error, 'label'), ', ');
2402
+ return error.label;
2391
2403
  }, [
2392
2404
  error
2393
2405
  ]);
@@ -2406,10 +2418,30 @@ const $cb1b9d36d0757897$var$SelectMenu = (props)=>{
2406
2418
  });
2407
2419
  }
2408
2420
  return (0, $iA2ta$reactjsxruntime.jsx)("div", {
2409
- className: styles.listItem,
2410
- children: data.label
2421
+ role: "option",
2422
+ "aria-selected": !!data.isSelected,
2423
+ className: data.disabled ? styles.listDisabledItem : styles.listItem,
2424
+ // Formatted options are rendered inside a wrapper that carries the select's own click
2425
+ // handler, which bypasses its disabled handling.
2426
+ onClick: (e)=>data.disabled && e.stopPropagation(),
2427
+ children: optionRenderer ? optionRenderer(data) : data.label
2411
2428
  });
2412
2429
  };
2430
+ // The select renders `label` as children everywhere except its search filter, which only ever
2431
+ // reads `options`. Rendering the value keeps the selected button and tags in sync with the list.
2432
+ const libraryValue = (0, $iA2ta$react.useMemo)(()=>{
2433
+ if (!optionRenderer || !state) return state;
2434
+ return (0, $iA2ta$lodash.isArray)(state) ? (0, $iA2ta$lodash.map)(state, (option)=>({
2435
+ ...option,
2436
+ label: optionRenderer(option)
2437
+ })) : {
2438
+ ...state,
2439
+ label: optionRenderer(state)
2440
+ };
2441
+ }, [
2442
+ optionRenderer,
2443
+ state
2444
+ ]);
2413
2445
  return (0, $iA2ta$reactjsxruntime.jsxs)("div", {
2414
2446
  className: styles.container,
2415
2447
  "data-testid": selectDataTestId,
@@ -2450,11 +2482,11 @@ const $cb1b9d36d0757897$var$SelectMenu = (props)=>{
2450
2482
  //
2451
2483
  options: computedOptions,
2452
2484
  //
2453
- value: state,
2485
+ value: libraryValue,
2454
2486
  onChange: handleChange,
2455
2487
  onSearchInputChange: handleSearchInputChange,
2456
2488
  //
2457
- formatOptionLabel: searchInputOptionRenderer ? handleFormatOptionLabel : undefined,
2489
+ formatOptionLabel: searchInputOptionRenderer || optionRenderer ? handleFormatOptionLabel : undefined,
2458
2490
  classNames: {
2459
2491
  menuButton: ()=>(0, $622cd2936b18c771$export$4370d69198e9314a)(styles.input, `bx-select-menu-${name}`, state === null && '*:text-gray-300! ', state === null && !isValid && isTouched && '*:text-red-300!'),
2460
2492
  menu: styles.menu,
@@ -6410,7 +6442,7 @@ var $df1ad8019f5459e8$export$2e2bcd8739ae039 = $df1ad8019f5459e8$var$styles;
6410
6442
 
6411
6443
 
6412
6444
  const $a8e0e51381520cae$var$FileInputGroup = (props)=>{
6413
- const { name: name = 'multiple-file-input', label: label, description: description, hint: hint, required: required, value: value, max: max, error: error, isDisabled: isDisabled, isRequired: isRequired = false, isTouched: isTouched = false, isMulti: isMulti = false, children: children, onChange: onChange, onBlur: onBlur, styles: stylesOverrides } = props;
6445
+ const { name: name = 'multiple-file-input', label: label, description: description, hint: hint, required: required, value: value, max: max, accept: accept, error: error, isDisabled: isDisabled, isRequired: isRequired = false, isTouched: isTouched = false, isMulti: isMulti = false, children: children, onChange: onChange, onBlur: onBlur, styles: stylesOverrides } = props;
6414
6446
  const isValid = error === undefined;
6415
6447
  const [isDragging, setIsDragging] = (0, $iA2ta$react.useState)(false);
6416
6448
  const handleChangeInput = (0, $iA2ta$react.useCallback)((files)=>{
@@ -6449,6 +6481,7 @@ const $a8e0e51381520cae$var$FileInputGroup = (props)=>{
6449
6481
  onDrop: onDrop,
6450
6482
  multiple: isMulti,
6451
6483
  disabled: isDisabled,
6484
+ accept: accept,
6452
6485
  onError: ()=>{
6453
6486
  // console.log('error');
6454
6487
  // setFieldError('file', t('component.form.error.multipleFiles') as string);