@asdp/ferryui 0.1.22-dev.9812 → 0.1.22-dev.9823

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.mjs CHANGED
@@ -8593,6 +8593,7 @@ var ModalTypeOfService = ({
8593
8593
  }
8594
8594
  return [];
8595
8595
  });
8596
+ const scrollContainerRef = useRef(null);
8596
8597
  const defaultRenderImage = ({
8597
8598
  src,
8598
8599
  alt,
@@ -8629,7 +8630,40 @@ var ModalTypeOfService = ({
8629
8630
  } else if (openItems.length > 0) {
8630
8631
  setOpenItems([]);
8631
8632
  }
8632
- }, [open, selectedService?.id]);
8633
+ }, [open, selectedService?.id, serviceTypes?.length]);
8634
+ const getTargetItemId = () => {
8635
+ if (selectedService) {
8636
+ for (const item of serviceTypes) {
8637
+ if (item.children && item.children.length > 0) {
8638
+ const hasSelectedChild = item.children.some(
8639
+ (child) => child.id === selectedService.id
8640
+ );
8641
+ if (hasSelectedChild) {
8642
+ return item.id;
8643
+ }
8644
+ }
8645
+ }
8646
+ }
8647
+ return openItems.length > 0 ? openItems[0] : null;
8648
+ };
8649
+ useEffect(() => {
8650
+ if (!open) return;
8651
+ const timer = setTimeout(() => {
8652
+ const targetId = getTargetItemId();
8653
+ const container = scrollContainerRef.current;
8654
+ if (targetId && container) {
8655
+ const targetEl = document.getElementById(`accordion-header-${targetId}`);
8656
+ if (targetEl) {
8657
+ const containerTop = container.getBoundingClientRect().top;
8658
+ const elTop = targetEl.getBoundingClientRect().top;
8659
+ container.scrollTop += elTop - containerTop;
8660
+ }
8661
+ } else if (container) {
8662
+ container.scrollTop = 0;
8663
+ }
8664
+ }, 150);
8665
+ return () => clearTimeout(timer);
8666
+ }, [open, selectedService?.id, serviceTypes]);
8633
8667
  const handleConfirm = () => {
8634
8668
  if (selectedServiceId) {
8635
8669
  let selectedItem = null;
@@ -8698,70 +8732,81 @@ var ModalTypeOfService = ({
8698
8732
  }
8699
8733
  ) : /* @__PURE__ */ jsxs(Fragment, { children: [
8700
8734
  /* @__PURE__ */ jsx(
8701
- Accordion,
8735
+ "div",
8702
8736
  {
8703
- collapsible: true,
8704
- openItems,
8705
- onToggle: (_, data) => setOpenItems(data.openItems),
8706
- className: styles.passengerSection,
8737
+ ref: scrollContainerRef,
8738
+ style: {
8739
+ maxHeight: "700px",
8740
+ overflowY: "auto"
8741
+ },
8707
8742
  children: /* @__PURE__ */ jsx(
8708
- RadioGroup,
8743
+ Accordion,
8709
8744
  {
8710
- value: String(selectedServiceId),
8711
- onChange: (_, data) => setSelectedServiceId(Number(data.value)),
8712
- children: serviceTypes.map((item, index) => {
8713
- if (item.children.length > 0) {
8714
- return /* @__PURE__ */ jsxs(
8715
- AccordionItem,
8716
- {
8717
- value: item?.id,
8718
- className: styles.accordionItem,
8719
- children: [
8720
- /* @__PURE__ */ jsx(
8721
- AccordionHeader,
8722
- {
8723
- className: styles.accordionHeader,
8724
- expandIconPosition: "end",
8725
- children: /* @__PURE__ */ jsx(
8726
- HoverableAccordionHeaderContent,
8745
+ collapsible: true,
8746
+ openItems,
8747
+ onToggle: (_, data) => setOpenItems(data.openItems),
8748
+ className: styles.passengerSection,
8749
+ children: /* @__PURE__ */ jsx(
8750
+ RadioGroup,
8751
+ {
8752
+ value: String(selectedServiceId),
8753
+ onChange: (_, data) => setSelectedServiceId(Number(data.value)),
8754
+ children: serviceTypes.map((item, index) => {
8755
+ if (item.children.length > 0) {
8756
+ return /* @__PURE__ */ jsxs(
8757
+ AccordionItem,
8758
+ {
8759
+ value: item?.id,
8760
+ className: styles.accordionItem,
8761
+ children: [
8762
+ /* @__PURE__ */ jsx(
8763
+ AccordionHeader,
8727
8764
  {
8728
- item,
8729
- imageRenderer,
8730
- styles
8765
+ id: `accordion-header-${item.id}`,
8766
+ className: styles.accordionHeader,
8767
+ expandIconPosition: "end",
8768
+ children: /* @__PURE__ */ jsx(
8769
+ HoverableAccordionHeaderContent,
8770
+ {
8771
+ item,
8772
+ imageRenderer,
8773
+ styles
8774
+ }
8775
+ )
8731
8776
  }
8732
- )
8733
- }
8734
- ),
8735
- /* @__PURE__ */ jsx(AccordionPanel, { className: styles.accordionBody, children: item.children.length > 0 && item.children.map((childItem, childIndex) => /* @__PURE__ */ jsx(
8736
- HoverableRadioItem,
8737
- {
8738
- item: childItem,
8739
- imageRenderer,
8740
- styles,
8741
- isChild: true,
8742
- onClick: () => setSelectedServiceId(childItem.id)
8743
- },
8744
- childIndex
8745
- )) })
8746
- ]
8747
- },
8748
- index
8749
- );
8750
- } else if (item.children.length === 0) {
8751
- return /* @__PURE__ */ jsx(
8752
- HoverableRadioItem,
8753
- {
8754
- item,
8755
- imageRenderer,
8756
- styles,
8757
- isChild: false,
8758
- onClick: () => setSelectedServiceId(item.id)
8759
- },
8760
- index
8761
- );
8777
+ ),
8778
+ /* @__PURE__ */ jsx(AccordionPanel, { className: styles.accordionBody, children: item.children.length > 0 && item.children.map((childItem, childIndex) => /* @__PURE__ */ jsx(
8779
+ HoverableRadioItem,
8780
+ {
8781
+ item: childItem,
8782
+ imageRenderer,
8783
+ styles,
8784
+ isChild: true,
8785
+ onClick: () => setSelectedServiceId(childItem.id)
8786
+ },
8787
+ childIndex
8788
+ )) })
8789
+ ]
8790
+ },
8791
+ index
8792
+ );
8793
+ } else if (item.children.length === 0) {
8794
+ return /* @__PURE__ */ jsx(
8795
+ HoverableRadioItem,
8796
+ {
8797
+ item,
8798
+ imageRenderer,
8799
+ styles,
8800
+ isChild: false,
8801
+ onClick: () => setSelectedServiceId(item.id)
8802
+ },
8803
+ index
8804
+ );
8805
+ }
8806
+ return null;
8807
+ })
8762
8808
  }
8763
- return null;
8764
- })
8809
+ )
8765
8810
  }
8766
8811
  )
8767
8812
  }
@@ -10610,6 +10655,14 @@ var useStyles23 = makeStyles({
10610
10655
  gap: "1rem",
10611
10656
  justifyContent: "flex-end",
10612
10657
  marginTop: "1rem"
10658
+ },
10659
+ passengerItemDisabled: {
10660
+ opacity: 0.5,
10661
+ cursor: "not-allowed",
10662
+ backgroundColor: tokens.colorNeutralBackgroundDisabled,
10663
+ ":hover": {
10664
+ backgroundColor: tokens.colorNeutralBackgroundDisabled
10665
+ }
10613
10666
  }
10614
10667
  });
10615
10668
  var ModalListPassenger = ({
@@ -10637,11 +10690,6 @@ var ModalListPassenger = ({
10637
10690
  onSelectPassenger(passenger);
10638
10691
  handleClose();
10639
10692
  };
10640
- const filteredPassengers = passengers.filter((passenger) => {
10641
- if (!searchQuery) return true;
10642
- const query = searchQuery.toLowerCase();
10643
- return passenger.fullName && passenger.fullName.toLowerCase().includes(query) || passenger.ageLabel && passenger.ageLabel.toLowerCase().includes(query);
10644
- });
10645
10693
  return /* @__PURE__ */ jsx(
10646
10694
  Dialog,
10647
10695
  {
@@ -10666,71 +10714,103 @@ var ModalListPassenger = ({
10666
10714
  contentBefore: /* @__PURE__ */ jsx(Icon, { icon: "fluent:search-24-regular" }),
10667
10715
  placeholder: mergedLabels.searchPlaceholder,
10668
10716
  value: searchQuery,
10669
- onChange: (_, data) => onSearchChange(data.value),
10717
+ onChange: (_, data) => {
10718
+ console.log(155, data);
10719
+ onSearchChange(data.value);
10720
+ },
10670
10721
  size: "large"
10671
10722
  }
10672
10723
  ),
10673
- /* @__PURE__ */ jsx("div", { className: styles.passengerList, children: filteredPassengers.filter(
10674
- (item) => item.ageId === passengerAgeId
10675
- ).map((passenger, index) => /* @__PURE__ */ jsxs(
10676
- "div",
10677
- {
10678
- className: styles.passengerItem,
10679
- onClick: () => handleSelectPassenger(passenger),
10680
- role: "button",
10681
- tabIndex: 0,
10682
- onKeyDown: (e) => {
10683
- if (e.key === "Enter" || e.key === " ") {
10684
- e.preventDefault();
10685
- handleSelectPassenger(passenger);
10686
- }
10687
- },
10688
- children: [
10689
- /* @__PURE__ */ jsxs("div", { children: [
10690
- /* @__PURE__ */ jsxs(Subtitle2, { children: [
10691
- passenger.fullName,
10692
- " ",
10693
- passenger.isAccountOwner && /* @__PURE__ */ jsx(
10694
- Caption2Strong,
10695
- {
10696
- style: {
10697
- backgroundColor: "#F3F9FD",
10698
- border: `1px solid #A9D3F2`,
10699
- borderRadius: "1em",
10700
- display: "inline-block",
10701
- color: "#0078D4",
10702
- padding: ".4em .9em"
10703
- },
10704
- children: "Pemilik Akun"
10705
- }
10706
- )
10707
- ] }),
10708
- /* @__PURE__ */ jsx("br", {}),
10709
- /* @__PURE__ */ jsxs(Body1, { children: [
10710
- passenger.ageLabel,
10711
- " \xB7 ",
10712
- passenger.identityTypeCode,
10713
- " ",
10714
- passenger.identityId
10715
- ] })
10716
- ] }),
10717
- /* @__PURE__ */ jsx(
10718
- Button,
10719
- {
10720
- appearance: "transparent",
10721
- icon: /* @__PURE__ */ jsx(Icon, { icon: "fluent:chevron-right-24-regular" }),
10722
- onClick: (e) => {
10723
- e.preventDefault();
10724
- e.stopPropagation();
10725
- onEditPassenger(passenger);
10726
- },
10727
- "aria-label": mergedLabels.editPassengerAriaLabel
10724
+ /* @__PURE__ */ jsx("div", { className: styles.passengerList, children: [...passengers].sort((a, b) => {
10725
+ const isDifferentAgeA = a.ageId !== passengerAgeId;
10726
+ const isExcludedFromSearchA = searchQuery ? !a.fullName.toLowerCase().includes(searchQuery.toLowerCase()) : false;
10727
+ const isDisabledA = isDifferentAgeA || isExcludedFromSearchA;
10728
+ const isDifferentAgeB = b.ageId !== passengerAgeId;
10729
+ const isExcludedFromSearchB = searchQuery ? !b.fullName.toLowerCase().includes(searchQuery.toLowerCase()) : false;
10730
+ const isDisabledB = isDifferentAgeB || isExcludedFromSearchB;
10731
+ if (isDisabledA === isDisabledB) return 0;
10732
+ return isDisabledA ? 1 : -1;
10733
+ }).map((passenger, index) => {
10734
+ const isDifferentAge = passenger.ageId !== passengerAgeId;
10735
+ const isExcludedFromSearch = searchQuery ? !passenger.fullName.toLowerCase().includes(searchQuery.toLowerCase()) : false;
10736
+ const isDisabled = isDifferentAge || isExcludedFromSearch;
10737
+ console.log(
10738
+ 170,
10739
+ isDisabled,
10740
+ isDifferentAge,
10741
+ isExcludedFromSearch
10742
+ );
10743
+ return /* @__PURE__ */ jsxs(
10744
+ "div",
10745
+ {
10746
+ className: mergeClasses(
10747
+ styles.passengerItem,
10748
+ isDisabled && styles.passengerItemDisabled
10749
+ ),
10750
+ onClick: () => {
10751
+ if (!isDisabled) {
10752
+ handleSelectPassenger(passenger);
10728
10753
  }
10729
- )
10730
- ]
10731
- },
10732
- passenger.id || `passenger-${index}`
10733
- )) }),
10754
+ },
10755
+ role: "button",
10756
+ tabIndex: isDisabled ? -1 : 0,
10757
+ onKeyDown: (e) => {
10758
+ if (isDisabled) return;
10759
+ if (e.key === "Enter" || e.key === " ") {
10760
+ e.preventDefault();
10761
+ handleSelectPassenger(passenger);
10762
+ }
10763
+ },
10764
+ children: [
10765
+ /* @__PURE__ */ jsxs("div", { children: [
10766
+ /* @__PURE__ */ jsxs(Subtitle2, { children: [
10767
+ passenger.fullName,
10768
+ " ",
10769
+ passenger.isAccountOwner && /* @__PURE__ */ jsx(
10770
+ Caption2Strong,
10771
+ {
10772
+ style: {
10773
+ backgroundColor: "#F3F9FD",
10774
+ border: `1px solid #A9D3F2`,
10775
+ borderRadius: "1em",
10776
+ display: "inline-block",
10777
+ color: "#0078D4",
10778
+ padding: ".4em .9em"
10779
+ },
10780
+ children: "Pemilik Akun"
10781
+ }
10782
+ )
10783
+ ] }),
10784
+ /* @__PURE__ */ jsx("br", {}),
10785
+ /* @__PURE__ */ jsxs(Body1, { children: [
10786
+ passenger.ageLabel,
10787
+ " \xB7 ",
10788
+ passenger.identityTypeCode,
10789
+ " ",
10790
+ passenger.identityId
10791
+ ] })
10792
+ ] }),
10793
+ /* @__PURE__ */ jsx(
10794
+ Button,
10795
+ {
10796
+ appearance: "transparent",
10797
+ icon: /* @__PURE__ */ jsx(Icon, { icon: "fluent:chevron-right-24-regular" }),
10798
+ disabled: isDisabled,
10799
+ onClick: (e) => {
10800
+ e.preventDefault();
10801
+ e.stopPropagation();
10802
+ if (!isDisabled) {
10803
+ onEditPassenger(passenger);
10804
+ }
10805
+ },
10806
+ "aria-label": mergedLabels.editPassengerAriaLabel
10807
+ }
10808
+ )
10809
+ ]
10810
+ },
10811
+ passenger.id || `passenger-${index}`
10812
+ );
10813
+ }) }),
10734
10814
  /* @__PURE__ */ jsxs("div", { className: styles.actions, children: [
10735
10815
  /* @__PURE__ */ jsx(
10736
10816
  Button,