kiban-design-system 1.1.10-hotfix.0 → 1.1.12-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,7 +30537,7 @@ 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, }) => {
30541
30541
  const [isFocusActive, setIsFocusActive] = useState(false);
30542
30542
  const [showPopover, setShowPopover] = useState(false);
30543
30543
  const handleOnBlur = () => {
@@ -30547,7 +30547,7 @@ const AlphaZipCodeInput = ({ label, isRequired, items, onBlur, onFocus, onChange
30547
30547
  };
30548
30548
  const handleOnFocus = () => {
30549
30549
  setIsFocusActive(true);
30550
- 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));
30551
30551
  if (onFocus)
30552
30552
  onFocus();
30553
30553
  };
@@ -30555,12 +30555,11 @@ const AlphaZipCodeInput = ({ label, isRequired, items, onBlur, onFocus, onChange
30555
30555
  const handleOnChange = (event) => {
30556
30556
  const isValid = /^[0-9]+$/i.test(event.target.value) || event.target.value === '';
30557
30557
  if (isValid && onChange) {
30558
- setShowPopover(event.target.value.length > 2);
30559
30558
  onChange(event.target.value);
30560
30559
  }
30561
30560
  };
30562
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;
30563
- const classesInput = cssClassName(`${COMPONENT_NAME}__InputWrapper`, isFocusActive && 'isFocus');
30562
+ const classesInput = cssClassName(`${COMPONENT_NAME}__InputWrapper`, isFocusActive && 'isFocus', loading && 'loading');
30564
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 }, void 0) }), void 0));
30565
30564
  const handleOnSelectItem = (item) => {
30566
30565
  if (onChange)
@@ -30568,13 +30567,27 @@ const AlphaZipCodeInput = ({ label, isRequired, items, onBlur, onFocus, onChange
30568
30567
  setShowPopover(false);
30569
30568
  };
30570
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));
30571
- const itemsOptions = items.map((item) => ({
30570
+ const itemsOptions = items === null || items === void 0 ? void 0 : items.map((item) => ({
30572
30571
  label: renderLabelItem(item),
30573
30572
  value: item.id,
30574
30573
  }));
30575
- const optionListMarkup = items.length > 0 ? (jsx(OptionList, { items: itemsOptions, selected: [''], onChange: handleOnSelectItem }, void 0)) : null;
30576
- const emptyItemsMarkup = items.length === 0 ? (jsx("div", Object.assign({ className: `${COMPONENT_NAME}__EmptyItems` }, { children: labelEmpty }), void 0)) : null;
30577
- 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)), [items, value, showPopover, isFocusActive]);
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)), [
30577
+ items,
30578
+ value,
30579
+ showPopover,
30580
+ emptyItemsMarkup,
30581
+ optionListMarkup,
30582
+ isFocusActive,
30583
+ ]);
30584
+ useEffect(() => {
30585
+ if (items) {
30586
+ setShowPopover(true);
30587
+ }
30588
+ else
30589
+ setShowPopover(false);
30590
+ }, [items]);
30578
30591
  return (jsxs("div", Object.assign({ className: `${COMPONENT_NAME}__Wrapper` }, { children: [labelMarkup, popoverMarkup] }), void 0));
30579
30592
  };
30580
30593