@asdp/ferryui 0.1.22-dev.9813 → 0.1.22-dev.9825

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
@@ -10655,6 +10655,14 @@ var useStyles23 = makeStyles({
10655
10655
  gap: "1rem",
10656
10656
  justifyContent: "flex-end",
10657
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
+ }
10658
10666
  }
10659
10667
  });
10660
10668
  var ModalListPassenger = ({
@@ -10682,11 +10690,6 @@ var ModalListPassenger = ({
10682
10690
  onSelectPassenger(passenger);
10683
10691
  handleClose();
10684
10692
  };
10685
- const filteredPassengers = passengers.filter((passenger) => {
10686
- if (!searchQuery) return true;
10687
- const query = searchQuery.toLowerCase();
10688
- return passenger.fullName && passenger.fullName.toLowerCase().includes(query) || passenger.ageLabel && passenger.ageLabel.toLowerCase().includes(query);
10689
- });
10690
10693
  return /* @__PURE__ */ jsx(
10691
10694
  Dialog,
10692
10695
  {
@@ -10711,71 +10714,96 @@ var ModalListPassenger = ({
10711
10714
  contentBefore: /* @__PURE__ */ jsx(Icon, { icon: "fluent:search-24-regular" }),
10712
10715
  placeholder: mergedLabels.searchPlaceholder,
10713
10716
  value: searchQuery,
10714
- onChange: (_, data) => onSearchChange(data.value),
10717
+ onChange: (_, data) => {
10718
+ onSearchChange(data.value);
10719
+ },
10715
10720
  size: "large"
10716
10721
  }
10717
10722
  ),
10718
- /* @__PURE__ */ jsx("div", { className: styles.passengerList, children: filteredPassengers.filter(
10719
- (item) => item.ageId === passengerAgeId
10720
- ).map((passenger, index) => /* @__PURE__ */ jsxs(
10721
- "div",
10722
- {
10723
- className: styles.passengerItem,
10724
- onClick: () => handleSelectPassenger(passenger),
10725
- role: "button",
10726
- tabIndex: 0,
10727
- onKeyDown: (e) => {
10728
- if (e.key === "Enter" || e.key === " ") {
10729
- e.preventDefault();
10730
- handleSelectPassenger(passenger);
10731
- }
10732
- },
10733
- children: [
10734
- /* @__PURE__ */ jsxs("div", { children: [
10735
- /* @__PURE__ */ jsxs(Subtitle2, { children: [
10736
- passenger.fullName,
10737
- " ",
10738
- passenger.isAccountOwner && /* @__PURE__ */ jsx(
10739
- Caption2Strong,
10740
- {
10741
- style: {
10742
- backgroundColor: "#F3F9FD",
10743
- border: `1px solid #A9D3F2`,
10744
- borderRadius: "1em",
10745
- display: "inline-block",
10746
- color: "#0078D4",
10747
- padding: ".4em .9em"
10748
- },
10749
- children: "Pemilik Akun"
10750
- }
10751
- )
10752
- ] }),
10753
- /* @__PURE__ */ jsx("br", {}),
10754
- /* @__PURE__ */ jsxs(Body1, { children: [
10755
- passenger.ageLabel,
10756
- " \xB7 ",
10757
- passenger.identityTypeCode,
10758
- " ",
10759
- passenger.identityId
10760
- ] })
10761
- ] }),
10762
- /* @__PURE__ */ jsx(
10763
- Button,
10764
- {
10765
- appearance: "transparent",
10766
- icon: /* @__PURE__ */ jsx(Icon, { icon: "fluent:chevron-right-24-regular" }),
10767
- onClick: (e) => {
10768
- e.preventDefault();
10769
- e.stopPropagation();
10770
- onEditPassenger(passenger);
10771
- },
10772
- "aria-label": mergedLabels.editPassengerAriaLabel
10723
+ /* @__PURE__ */ jsx("div", { className: styles.passengerList, children: [...passengers].sort((a, b) => {
10724
+ const isDifferentAgeA = a.ageId !== passengerAgeId;
10725
+ const isExcludedFromSearchA = searchQuery ? !a.fullName.toLowerCase().includes(searchQuery.toLowerCase()) : false;
10726
+ const isDisabledA = isDifferentAgeA || isExcludedFromSearchA;
10727
+ const isDifferentAgeB = b.ageId !== passengerAgeId;
10728
+ const isExcludedFromSearchB = searchQuery ? !b.fullName.toLowerCase().includes(searchQuery.toLowerCase()) : false;
10729
+ const isDisabledB = isDifferentAgeB || isExcludedFromSearchB;
10730
+ if (isDisabledA === isDisabledB) return 0;
10731
+ return isDisabledA ? 1 : -1;
10732
+ }).map((passenger, index) => {
10733
+ const isDifferentAge = passenger.ageId !== passengerAgeId;
10734
+ const isExcludedFromSearch = searchQuery ? !passenger.fullName.toLowerCase().includes(searchQuery.toLowerCase()) : false;
10735
+ const isDisabled = isDifferentAge || isExcludedFromSearch;
10736
+ return /* @__PURE__ */ jsxs(
10737
+ "div",
10738
+ {
10739
+ className: mergeClasses(
10740
+ styles.passengerItem,
10741
+ isDisabled && styles.passengerItemDisabled
10742
+ ),
10743
+ onClick: () => {
10744
+ if (!isDisabled) {
10745
+ handleSelectPassenger(passenger);
10773
10746
  }
10774
- )
10775
- ]
10776
- },
10777
- passenger.id || `passenger-${index}`
10778
- )) }),
10747
+ },
10748
+ role: "button",
10749
+ tabIndex: isDisabled ? -1 : 0,
10750
+ onKeyDown: (e) => {
10751
+ if (isDisabled) return;
10752
+ if (e.key === "Enter" || e.key === " ") {
10753
+ e.preventDefault();
10754
+ handleSelectPassenger(passenger);
10755
+ }
10756
+ },
10757
+ children: [
10758
+ /* @__PURE__ */ jsxs("div", { children: [
10759
+ /* @__PURE__ */ jsxs(Subtitle2, { children: [
10760
+ passenger.fullName,
10761
+ " ",
10762
+ passenger.isAccountOwner && /* @__PURE__ */ jsx(
10763
+ Caption2Strong,
10764
+ {
10765
+ style: {
10766
+ backgroundColor: "#F3F9FD",
10767
+ border: `1px solid #A9D3F2`,
10768
+ borderRadius: "1em",
10769
+ display: "inline-block",
10770
+ color: "#0078D4",
10771
+ padding: ".4em .9em"
10772
+ },
10773
+ children: "Pemilik Akun"
10774
+ }
10775
+ )
10776
+ ] }),
10777
+ /* @__PURE__ */ jsx("br", {}),
10778
+ /* @__PURE__ */ jsxs(Body1, { children: [
10779
+ passenger.ageLabel,
10780
+ " \xB7 ",
10781
+ passenger.identityTypeCode,
10782
+ " ",
10783
+ passenger.identityId
10784
+ ] })
10785
+ ] }),
10786
+ /* @__PURE__ */ jsx(
10787
+ Button,
10788
+ {
10789
+ appearance: "transparent",
10790
+ icon: /* @__PURE__ */ jsx(Icon, { icon: "fluent:chevron-right-24-regular" }),
10791
+ disabled: isDisabled,
10792
+ onClick: (e) => {
10793
+ e.preventDefault();
10794
+ e.stopPropagation();
10795
+ if (!isDisabled) {
10796
+ onEditPassenger(passenger);
10797
+ }
10798
+ },
10799
+ "aria-label": mergedLabels.editPassengerAriaLabel
10800
+ }
10801
+ )
10802
+ ]
10803
+ },
10804
+ passenger.id || `passenger-${index}`
10805
+ );
10806
+ }) }),
10779
10807
  /* @__PURE__ */ jsxs("div", { className: styles.actions, children: [
10780
10808
  /* @__PURE__ */ jsx(
10781
10809
  Button,
@@ -11138,7 +11166,8 @@ var ModalPassengerForm = ({
11138
11166
  cityOptions,
11139
11167
  idTypes,
11140
11168
  ticketClassOptions,
11141
- onScanComplete
11169
+ onScanComplete,
11170
+ isLoading
11142
11171
  }) => {
11143
11172
  const styles = useStyles24();
11144
11173
  const mergedLabels = { ...DEFAULT_LABELS23[language], ...labels };
@@ -11155,7 +11184,7 @@ var ModalPassengerForm = ({
11155
11184
  const [capturedImage, setCapturedImage] = useState(null);
11156
11185
  const [stream, setStream] = useState(null);
11157
11186
  const videoRef = useRef(null);
11158
- const { control, handleSubmit, reset, watch, setValue, trigger } = useForm({
11187
+ const { control, handleSubmit, reset, watch, setValue, trigger, formState: { isValid } } = useForm({
11159
11188
  mode: "all",
11160
11189
  defaultValues
11161
11190
  });
@@ -11884,6 +11913,8 @@ var ModalPassengerForm = ({
11884
11913
  size: "large",
11885
11914
  shape: "circular",
11886
11915
  type: "submit",
11916
+ disabled: !isValid || isLoading,
11917
+ icon: isLoading ? /* @__PURE__ */ jsx(Spinner, { size: "tiny" }) : void 0,
11887
11918
  children: mergedLabels.saveButton
11888
11919
  }
11889
11920
  ),