thailife-react 0.0.31 → 0.0.32

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.
@@ -13,6 +13,7 @@ export interface SelectProps {
13
13
  className?: string;
14
14
  onChange?: (value: string) => void;
15
15
  register?: UseFormRegisterReturn;
16
+ error?: string;
16
17
  }
17
18
  export declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLDivElement>>;
18
19
  //# sourceMappingURL=Select.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,WAAW,YAAY;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IACxB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CACpC;AAED,eAAO,MAAM,MAAM,oFA0FlB,CAAC"}
1
+ {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,WAAW,YAAY;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IACxB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,MAAM,oFAgGlB,CAAC"}
package/dist/esm/index.js CHANGED
@@ -397,7 +397,7 @@ const Radio = forwardRef(function RadioItem(_a, ref) {
397
397
  });
398
398
  Radio.displayName = "Radio";
399
399
 
400
- const Select = React.forwardRef(({ options, value, placeholder = 'Select an option', disabled = false, className = '', onChange, register, }, ref) => {
400
+ const Select = React.forwardRef(({ options, value, placeholder = 'Select an option', disabled = false, className = '', onChange, register, error, }, ref) => {
401
401
  const [isOpen, setIsOpen] = useState(false);
402
402
  const [selectedValue, setSelectedValue] = useState(value || '');
403
403
  const selectRef = useRef(null);
@@ -422,7 +422,7 @@ const Select = React.forwardRef(({ options, value, placeholder = 'Select an opti
422
422
  };
423
423
  }, []);
424
424
  return (React.createElement("div", { ref: ref, className: `relative ${className}` },
425
- React.createElement("button", Object.assign({ type: "button", onClick: () => !disabled && setIsOpen(!isOpen), disabled: disabled, className: `w-full px-4 h-[44px] text-left bg-white border border-gray-300 rounded-md focus:outline-none focus:border-2 focus:border-primary ${disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'} flex items-center justify-between` }, register),
425
+ React.createElement("button", Object.assign({ type: "button", onClick: () => !disabled && setIsOpen(!isOpen), disabled: disabled, className: `w-full px-4 h-[44px] text-left bg-white border rounded-md focus:outline-none focus:border-2 ${error ? 'border-danger focus:border-danger' : 'border-gray-300 focus:border-primary'} ${disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'} flex items-center justify-between` }, register),
426
426
  React.createElement("div", { className: "flex items-center" },
427
427
  (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.icon) && (React.createElement("span", { className: "mr-2" }, selectedOption.icon)),
428
428
  React.createElement("span", { className: selectedOption ? 'text-gray-900' : 'text-gray-500' }, selectedOption ? selectedOption.label : placeholder)),
@@ -430,7 +430,8 @@ const Select = React.forwardRef(({ options, value, placeholder = 'Select an opti
430
430
  React.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }))),
431
431
  isOpen && (React.createElement("div", { className: "absolute z-10 w-full mt-1 bg-white border border-gray-300 rounded-md shadow-lg max-h-60 overflow-auto" }, options.map((option) => (React.createElement("button", { key: option.value, type: "button", onClick: () => handleSelect(option), className: `w-full px-4 py-2 text-left hover:bg-gray-100 focus:outline-none focus:bg-gray-100 flex items-center ${option.value === selectedValue ? 'bg-blue-50 text-primary' : ''}` },
432
432
  option.icon && React.createElement("span", { className: "mr-2" }, option.icon),
433
- option.label)))))));
433
+ option.label))))),
434
+ error && (React.createElement("p", { className: "mt-1 text-danger" }, error))));
434
435
  });
435
436
  Select.displayName = 'Select';
436
437