kiban-design-system 1.1.11-hotfix.0 → 1.1.13-hotfix.0

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
@@ -30537,18 +30537,17 @@ const AlphaGraphicCard = ({ data }) => {
30537
30537
  };
30538
30538
 
30539
30539
  const COMPONENT_NAME = 'AlphaZipCodeInput';
30540
- const AlphaZipCodeInput = ({ label, isRequired, items, onBlur, onFocus, onChange, value, labelEmpty, }) => {
30540
+ const AlphaZipCodeInput = ({ label, isRequired, items, onBlur, onFocus, onChange, value, labelEmpty, loading, placeholder, }) => {
30541
30541
  const [isFocusActive, setIsFocusActive] = useState(false);
30542
30542
  const [showPopover, setShowPopover] = useState(false);
30543
30543
  const handleOnBlur = () => {
30544
- setShowPopover(false);
30545
30544
  setIsFocusActive(false);
30546
30545
  if (onBlur)
30547
30546
  onBlur();
30548
30547
  };
30549
30548
  const handleOnFocus = () => {
30550
30549
  setIsFocusActive(true);
30551
- setShowPopover(Boolean(value && (value === null || value === void 0 ? void 0 : value.length) > 2));
30550
+ setShowPopover(Boolean(value && (value === null || value === void 0 ? void 0 : value.length) === 5 && items));
30552
30551
  if (onFocus)
30553
30552
  onFocus();
30554
30553
  };
@@ -30556,26 +30555,25 @@ const AlphaZipCodeInput = ({ label, isRequired, items, onBlur, onFocus, onChange
30556
30555
  const handleOnChange = (event) => {
30557
30556
  const isValid = /^[0-9]+$/i.test(event.target.value) || event.target.value === '';
30558
30557
  if (isValid && onChange) {
30559
- setShowPopover(event.target.value.length > 2);
30560
30558
  onChange(event.target.value);
30561
30559
  }
30562
30560
  };
30563
30561
  const labelMarkup = label ? (jsx("div", Object.assign({ className: `${COMPONENT_NAME}__LabelWrapper` }, { children: jsxs("label", Object.assign({ className: `${COMPONENT_NAME}__Label` }, { children: [label, isRequired ? (jsx("span", Object.assign({ className: `${COMPONENT_NAME}__Label--isRequired` }, { children: "*" }), void 0)) : null] }), void 0) }), void 0)) : null;
30564
- const classesInput = cssClassName(`${COMPONENT_NAME}__InputWrapper`, isFocusActive && 'isFocus');
30565
- const inputMarkup = (jsx("div", Object.assign({ className: classesInput }, { children: jsx("input", { className: `${COMPONENT_NAME}__InputWrapper--input`, onBlur: handleOnBlur, onFocus: handleOnFocus, onChange: handleOnChange, maxLength: 5, value: value }, void 0) }), void 0));
30562
+ const classesInput = cssClassName(`${COMPONENT_NAME}__InputWrapper`, isFocusActive && 'isFocus', loading && 'loading');
30563
+ const inputMarkup = (jsx("div", Object.assign({ className: classesInput }, { children: jsx("input", { className: `${COMPONENT_NAME}__InputWrapper--input`, onBlur: handleOnBlur, onFocus: handleOnFocus, onChange: handleOnChange, maxLength: 5, value: value, placeholder: placeholder }, void 0) }), void 0));
30566
30564
  const handleOnSelectItem = (item) => {
30567
30565
  if (onChange)
30568
30566
  onChange(item[0]);
30569
30567
  setShowPopover(false);
30570
30568
  };
30571
30569
  const renderLabelItem = (item) => (jsxs("div", Object.assign({ className: `${COMPONENT_NAME}__ItemWrapper` }, { children: [jsx("div", Object.assign({ className: `${COMPONENT_NAME}__Item__Value` }, { children: item.cp }), void 0), jsxs("div", Object.assign({ className: `${COMPONENT_NAME}__Item__Description` }, { children: [item.municipality, ", ", item.city, ", ", item.state] }), void 0)] }), void 0));
30572
- const itemsOptions = items.map((item) => ({
30570
+ const itemsOptions = items === null || items === void 0 ? void 0 : items.map((item) => ({
30573
30571
  label: renderLabelItem(item),
30574
30572
  value: item.id,
30575
30573
  }));
30576
- const optionListMarkup = items.length > 0 ? (jsx(OptionList, { items: itemsOptions, selected: [''], onChange: handleOnSelectItem }, void 0)) : null;
30577
- const emptyItemsMarkup = items.length === 0 ? (jsx("div", Object.assign({ className: `${COMPONENT_NAME}__EmptyItems` }, { children: labelEmpty }), void 0)) : null;
30578
- const popoverMarkup = useMemo(() => (jsx(Popover$1, Object.assign({ activator: inputMarkup, isActive: showPopover, isFullWidth: true, onClose: () => setShowPopover(false), isFixed: true }, { children: jsxs(Popover$1.Pane, { children: [optionListMarkup, emptyItemsMarkup] }, void 0) }), items.length)), [
30574
+ const optionListMarkup = items && items.length > 0 ? (jsx(OptionList, { items: itemsOptions, selected: [''], onChange: handleOnSelectItem }, void 0)) : null;
30575
+ const emptyItemsMarkup = items && items.length === 0 ? (jsx("div", Object.assign({ className: `${COMPONENT_NAME}__EmptyItems` }, { children: labelEmpty }), void 0)) : null;
30576
+ const popoverMarkup = useMemo(() => (jsx(Popover$1, Object.assign({ activator: inputMarkup, isActive: showPopover, isFullWidth: true, onClose: () => setShowPopover(false), isFixed: true }, { children: jsxs(Popover$1.Pane, { children: [optionListMarkup, emptyItemsMarkup] }, void 0) }), void 0)), [
30579
30577
  items,
30580
30578
  value,
30581
30579
  showPopover,
@@ -30584,10 +30582,11 @@ const AlphaZipCodeInput = ({ label, isRequired, items, onBlur, onFocus, onChange
30584
30582
  isFocusActive,
30585
30583
  ]);
30586
30584
  useEffect(() => {
30587
- if (showPopover) {
30588
- setShowPopover(false);
30589
- requestAnimationFrame(() => setShowPopover(true));
30585
+ if (items) {
30586
+ setShowPopover(true);
30590
30587
  }
30588
+ else
30589
+ setShowPopover(false);
30591
30590
  }, [items]);
30592
30591
  return (jsxs("div", Object.assign({ className: `${COMPONENT_NAME}__Wrapper` }, { children: [labelMarkup, popoverMarkup] }), void 0));
30593
30592
  };