@asdp/ferryui 0.1.22-dev.10844 → 0.1.22-dev.10923

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
@@ -4,7 +4,7 @@ import React, { forwardRef, useState, useRef, useEffect, useCallback, useMemo, F
4
4
  import { ArrowDownloadRegular, Dismiss24Regular, DismissRegular, SubtractRegular, AddRegular, DeleteRegular, InfoRegular, SearchRegular, ChevronDownRegular, ArrowRightRegular } from '@fluentui/react-icons';
5
5
  import { Container, Row, Col, Visible } from 'react-grid-system';
6
6
  import { Icon } from '@iconify/react';
7
- import { Controller, useForm, useWatch, useFieldArray } from 'react-hook-form';
7
+ import { Controller, useForm, useWatch } from 'react-hook-form';
8
8
  import PhoneInputComponent from 'react-phone-input-2';
9
9
  import Select from 'react-select';
10
10
  import { Calendar } from '@fluentui/react-calendar-compat';
@@ -12927,6 +12927,35 @@ var useStyles27 = makeStyles({
12927
12927
  }
12928
12928
  }
12929
12929
  });
12930
+ function OwnerWeightSync({
12931
+ setValue,
12932
+ onUpdateOwner,
12933
+ getValues,
12934
+ control,
12935
+ owner,
12936
+ ownerIndex
12937
+ }) {
12938
+ const cargoWeights = useWatch({
12939
+ control,
12940
+ name: (owner.cargoItems || []).map(
12941
+ (_, cargoIndex) => `owners.${ownerIndex}.cargo.${cargoIndex}.cargoWeight`
12942
+ )
12943
+ });
12944
+ const total = cargoWeights?.reduce(
12945
+ (sum, w) => sum + (Number(w) || 0),
12946
+ 0
12947
+ ) ?? 0;
12948
+ const current = Number(getValues(`owners.${ownerIndex}.estimatedWeight`)) || 0;
12949
+ useEffect(() => {
12950
+ if (current !== total) {
12951
+ setValue(`owners.${ownerIndex}.estimatedWeight`, total);
12952
+ onUpdateOwner(owner.id, {
12953
+ estimatedWeight: total
12954
+ });
12955
+ }
12956
+ }, [current, ownerIndex, total]);
12957
+ return null;
12958
+ }
12930
12959
  var CardVehicleOwnerForm = ({
12931
12960
  owners,
12932
12961
  hasLoad,
@@ -12971,38 +13000,6 @@ var CardVehicleOwnerForm = ({
12971
13000
  });
12972
13001
  setOpenCargoItems(allOpenItems);
12973
13002
  }, [owners]);
12974
- function OwnerWeightSync({
12975
- owner,
12976
- ownerIndex
12977
- }) {
12978
- const { fields } = useFieldArray({
12979
- control,
12980
- name: `owners.${ownerIndex}.cargoItems`
12981
- });
12982
- console.log(140, fields);
12983
- const cargoWeights = useWatch({
12984
- control,
12985
- name: fields.map(
12986
- (_, cargoIndex) => `owners.${ownerIndex}.cargoItems.${cargoIndex}.cargoWeight`
12987
- )
12988
- });
12989
- console.log(149, cargoWeights);
12990
- useEffect(() => {
12991
- const total = cargoWeights?.reduce(
12992
- (sum, w) => sum + (Number(w) || 0),
12993
- 0
12994
- ) ?? 0;
12995
- const current = Number(getValues(`owners.${ownerIndex}.estimatedWeight`)) || 0;
12996
- console.log(160, current, total);
12997
- if (current !== total) {
12998
- setValue(`owners.${ownerIndex}.estimatedWeight`, total);
12999
- onUpdateOwner(owner.id, {
13000
- estimatedWeight: total
13001
- });
13002
- }
13003
- }, [cargoWeights, ownerIndex, setValue, getValues]);
13004
- return null;
13005
- }
13006
13003
  return /* @__PURE__ */ jsxs(Card, { className: styles.card, children: [
13007
13004
  /* @__PURE__ */ jsxs("div", { className: styles.header, children: [
13008
13005
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", flex: 1 }, children: [
@@ -13027,7 +13024,7 @@ var CardVehicleOwnerForm = ({
13027
13024
  defaultOpenItems: owners.map((o) => String(o.id)),
13028
13025
  multiple: true,
13029
13026
  children: owners.map((owner, ownerIndex) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
13030
- /* @__PURE__ */ jsx(OwnerWeightSync, { owner, ownerIndex }),
13027
+ /* @__PURE__ */ jsx(OwnerWeightSync, { owner, ownerIndex, control, setValue, onUpdateOwner, getValues }),
13031
13028
  /* @__PURE__ */ jsxs(
13032
13029
  AccordionItem,
13033
13030
  {
@@ -16536,6 +16533,17 @@ var useStyles38 = makeStyles({
16536
16533
  height: "40px",
16537
16534
  objectFit: "contain"
16538
16535
  },
16536
+ skeletonOption: {
16537
+ display: "flex",
16538
+ alignItems: "center",
16539
+ justifyContent: "space-between",
16540
+ width: "100%"
16541
+ },
16542
+ skeletonOptionLeft: {
16543
+ display: "flex",
16544
+ alignItems: "center",
16545
+ gap: tokens.spacingHorizontalL
16546
+ },
16539
16547
  card: {
16540
16548
  position: "relative",
16541
16549
  borderRadius: tokens.borderRadiusXLarge,
@@ -16552,13 +16560,53 @@ var CardPaymentMethodList = ({
16552
16560
  labels,
16553
16561
  methods,
16554
16562
  selectedValue,
16555
- onSelect
16563
+ onSelect,
16564
+ isLoading = false,
16565
+ skeletonCount = 3
16556
16566
  }) => {
16557
16567
  const styles = useStyles38();
16558
16568
  const mergedLabels = { ...DEFAULT_LABELS36[language], ...labels };
16559
16569
  return /* @__PURE__ */ jsx("div", { className: styles.card, children: /* @__PURE__ */ jsxs("div", { className: `${styles.container}`, children: [
16560
16570
  /* @__PURE__ */ jsx(Subtitle1, { children: mergedLabels.method }),
16561
- methods.map((category, index) => /* @__PURE__ */ jsxs("div", { children: [
16571
+ isLoading ? Array.from({ length: skeletonCount }).map((_, index) => /* @__PURE__ */ jsxs("div", { children: [
16572
+ index > 0 && /* @__PURE__ */ jsx("div", { className: styles.dividerContainer, children: /* @__PURE__ */ jsx(Divider, {}) }),
16573
+ /* @__PURE__ */ jsxs(Skeleton, { children: [
16574
+ /* @__PURE__ */ jsx(
16575
+ SkeletonItem,
16576
+ {
16577
+ style: {
16578
+ width: "60%",
16579
+ height: "20px",
16580
+ marginBottom: tokens.spacingVerticalXXL
16581
+ }
16582
+ }
16583
+ ),
16584
+ /* @__PURE__ */ jsxs("div", { className: styles.skeletonOption, children: [
16585
+ /* @__PURE__ */ jsxs("div", { className: styles.skeletonOptionLeft, children: [
16586
+ /* @__PURE__ */ jsx(
16587
+ SkeletonItem,
16588
+ {
16589
+ shape: "circle",
16590
+ style: { width: "40px", height: "40px" }
16591
+ }
16592
+ ),
16593
+ /* @__PURE__ */ jsx(
16594
+ SkeletonItem,
16595
+ {
16596
+ style: { width: "140px", height: "18px" }
16597
+ }
16598
+ )
16599
+ ] }),
16600
+ /* @__PURE__ */ jsx(
16601
+ SkeletonItem,
16602
+ {
16603
+ shape: "circle",
16604
+ style: { width: "20px", height: "20px" }
16605
+ }
16606
+ )
16607
+ ] })
16608
+ ] })
16609
+ ] }, `payment-method-skeleton-${index}`)) : methods.map((category, index) => /* @__PURE__ */ jsxs("div", { children: [
16562
16610
  index > 0 && /* @__PURE__ */ jsx("div", { className: styles.dividerContainer, children: /* @__PURE__ */ jsx(Divider, {}) }),
16563
16611
  /* @__PURE__ */ jsx(Accordion, { multiple: true, collapsible: true, children: /* @__PURE__ */ jsxs(AccordionItem, { value: category.value, children: [
16564
16612
  /* @__PURE__ */ jsx(
@@ -16642,6 +16690,17 @@ var useStyles39 = makeStyles({
16642
16690
  ),
16643
16691
  backgroundColor: tokens.colorNeutralBackground1,
16644
16692
  zIndex: 3
16693
+ },
16694
+ skeletonRow: {
16695
+ display: "flex",
16696
+ alignItems: "center",
16697
+ justifyContent: "space-between",
16698
+ width: "100%"
16699
+ },
16700
+ skeletonLeft: {
16701
+ display: "flex",
16702
+ alignItems: "center",
16703
+ gap: tokens.spacingHorizontalL
16645
16704
  }
16646
16705
  });
16647
16706
  var CardPaymentMethodFavorite = ({
@@ -16652,7 +16711,9 @@ var CardPaymentMethodFavorite = ({
16652
16711
  onSelect,
16653
16712
  onViewAllMethods,
16654
16713
  showWarning = true,
16655
- showViewAllButton = true
16714
+ showViewAllButton = true,
16715
+ isLoading = false,
16716
+ skeletonCount = 3
16656
16717
  }) => {
16657
16718
  const styles = useStyles39();
16658
16719
  const mergedLabels = { ...DEFAULT_LABELS37[language], ...labels };
@@ -16672,29 +16733,61 @@ var CardPaymentMethodFavorite = ({
16672
16733
  )
16673
16734
  }
16674
16735
  ),
16675
- /* @__PURE__ */ jsx(Row, { nogutter: true, style: { gap: tokens.spacingVerticalL }, children: methods.map((option) => /* @__PURE__ */ jsx(Col, { xs: 12, onClick: () => onSelect(option.value), style: { cursor: "pointer" }, children: /* @__PURE__ */ jsxs(Row, { justify: "between", children: [
16676
- /* @__PURE__ */ jsx(Col, { xs: "content", children: /* @__PURE__ */ jsx(
16677
- "img",
16678
- {
16679
- src: option.image,
16680
- alt: option.label,
16681
- className: styles.image
16682
- }
16683
- ) }),
16684
- /* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx(Subtitle2, { children: option.label }) }),
16685
- /* @__PURE__ */ jsx(Col, { xs: "content", children: /* @__PURE__ */ jsx(
16686
- Radio,
16736
+ isLoading ? /* @__PURE__ */ jsx(Skeleton, { children: /* @__PURE__ */ jsx(Row, { nogutter: true, style: { gap: tokens.spacingVerticalL }, children: Array.from({ length: skeletonCount }).map((_, index) => /* @__PURE__ */ jsx(Col, { xs: 12, children: /* @__PURE__ */ jsxs("div", { className: styles.skeletonRow, children: [
16737
+ /* @__PURE__ */ jsxs("div", { className: styles.skeletonLeft, children: [
16738
+ /* @__PURE__ */ jsx(
16739
+ SkeletonItem,
16740
+ {
16741
+ shape: "circle",
16742
+ style: { width: "40px", height: "40px" }
16743
+ }
16744
+ ),
16745
+ /* @__PURE__ */ jsx(
16746
+ SkeletonItem,
16747
+ {
16748
+ style: { width: "140px", height: "18px" }
16749
+ }
16750
+ )
16751
+ ] }),
16752
+ /* @__PURE__ */ jsx(
16753
+ SkeletonItem,
16687
16754
  {
16688
- checked: selectedValue === option.value,
16689
- onChange: () => onSelect(option.value),
16690
- value: option.value,
16691
- name: "payment-method-favorite",
16692
- disabled: option.disabled,
16693
- "aria-label": `${mergedLabels.selectAriaLabel} ${option.label}`
16755
+ shape: "circle",
16756
+ style: { width: "20px", height: "20px" }
16694
16757
  }
16695
- ) })
16696
- ] }) }, option.value)) }),
16697
- showViewAllButton && /* @__PURE__ */ jsx(
16758
+ )
16759
+ ] }) }, `payment-favorite-skeleton-${index}`)) }) }) : /* @__PURE__ */ jsx(Row, { nogutter: true, style: { gap: tokens.spacingVerticalL }, children: methods.map((option) => /* @__PURE__ */ jsx(
16760
+ Col,
16761
+ {
16762
+ xs: 12,
16763
+ onClick: () => onSelect(option.value),
16764
+ style: { cursor: "pointer" },
16765
+ children: /* @__PURE__ */ jsxs(Row, { justify: "between", children: [
16766
+ /* @__PURE__ */ jsx(Col, { xs: "content", children: /* @__PURE__ */ jsx(
16767
+ "img",
16768
+ {
16769
+ src: option.image,
16770
+ alt: option.label,
16771
+ className: styles.image
16772
+ }
16773
+ ) }),
16774
+ /* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx(Subtitle2, { children: option.label }) }),
16775
+ /* @__PURE__ */ jsx(Col, { xs: "content", children: /* @__PURE__ */ jsx(
16776
+ Radio,
16777
+ {
16778
+ checked: selectedValue === option.value,
16779
+ onChange: () => onSelect(option.value),
16780
+ value: option.value,
16781
+ name: "payment-method-favorite",
16782
+ disabled: option.disabled,
16783
+ "aria-label": `${mergedLabels.selectAriaLabel} ${option.label}`
16784
+ }
16785
+ ) })
16786
+ ] })
16787
+ },
16788
+ option.value
16789
+ )) }),
16790
+ showViewAllButton && !isLoading && /* @__PURE__ */ jsx(
16698
16791
  Button,
16699
16792
  {
16700
16793
  style: { width: "100%" },
@@ -16871,6 +16964,18 @@ var useStyles41 = makeStyles({
16871
16964
  tokens.spacingHorizontalM
16872
16965
  ),
16873
16966
  color: tokens.colorNeutralForeground4
16967
+ },
16968
+ skeletonCenter: {
16969
+ display: "flex",
16970
+ flexDirection: "column",
16971
+ alignItems: "center",
16972
+ gap: tokens.spacingHorizontalM
16973
+ },
16974
+ skeletonRow: {
16975
+ display: "flex",
16976
+ alignItems: "center",
16977
+ justifyContent: "center",
16978
+ gap: tokens.spacingHorizontalM
16874
16979
  }
16875
16980
  });
16876
16981
  var CardPaymentInfo = ({
@@ -16883,11 +16988,103 @@ var CardPaymentInfo = ({
16883
16988
  guides,
16884
16989
  onCopyVA,
16885
16990
  onCheckStatus,
16886
- onChangePayment
16991
+ onChangePayment,
16992
+ isLoading = false
16887
16993
  }) => {
16888
16994
  const styles = useStyles41();
16889
16995
  const mergedLabels = { ...DEFAULT_LABELS39[language], ...labels };
16890
- return /* @__PURE__ */ jsx("div", { className: styles.card, children: /* @__PURE__ */ jsxs("div", { className: styles.container, children: [
16996
+ return /* @__PURE__ */ jsx("div", { className: styles.card, children: /* @__PURE__ */ jsx("div", { className: styles.container, children: isLoading ? /* @__PURE__ */ jsxs(Skeleton, { children: [
16997
+ /* @__PURE__ */ jsxs("div", { className: styles.headerRow, children: [
16998
+ /* @__PURE__ */ jsx(SkeletonItem, { style: { width: "180px", height: "20px" } }),
16999
+ /* @__PURE__ */ jsx(SkeletonItem, { style: { width: "260px", height: "28px" } })
17000
+ ] }),
17001
+ /* @__PURE__ */ jsxs("div", { className: styles.infoCard, children: [
17002
+ /* @__PURE__ */ jsxs("div", { className: styles.codeCard, children: [
17003
+ /* @__PURE__ */ jsxs("div", { className: styles.skeletonRow, children: [
17004
+ /* @__PURE__ */ jsx(
17005
+ SkeletonItem,
17006
+ {
17007
+ shape: "circle",
17008
+ style: { width: "40px", height: "40px" }
17009
+ }
17010
+ ),
17011
+ /* @__PURE__ */ jsx(SkeletonItem, { style: { width: "160px", height: "20px" } })
17012
+ ] }),
17013
+ /* @__PURE__ */ jsxs("div", { className: styles.skeletonCenter, children: [
17014
+ /* @__PURE__ */ jsx(SkeletonItem, { style: { width: "260px", height: "36px" } }),
17015
+ /* @__PURE__ */ jsx(
17016
+ SkeletonItem,
17017
+ {
17018
+ style: {
17019
+ width: "80%",
17020
+ height: "40px",
17021
+ borderRadius: tokens.borderRadiusCircular
17022
+ }
17023
+ }
17024
+ )
17025
+ ] })
17026
+ ] }),
17027
+ /* @__PURE__ */ jsx(
17028
+ SkeletonItem,
17029
+ {
17030
+ style: {
17031
+ width: "100%",
17032
+ height: "40px",
17033
+ borderRadius: tokens.borderRadiusCircular
17034
+ }
17035
+ }
17036
+ ),
17037
+ /* @__PURE__ */ jsxs("div", { children: [
17038
+ /* @__PURE__ */ jsx(
17039
+ SkeletonItem,
17040
+ {
17041
+ style: {
17042
+ width: "120px",
17043
+ height: "18px",
17044
+ marginBottom: "8px"
17045
+ }
17046
+ }
17047
+ ),
17048
+ /* @__PURE__ */ jsx(
17049
+ SkeletonItem,
17050
+ {
17051
+ style: {
17052
+ width: "100%",
17053
+ height: "36px",
17054
+ borderRadius: tokens.borderRadius2XLarge
17055
+ }
17056
+ }
17057
+ )
17058
+ ] })
17059
+ ] }),
17060
+ /* @__PURE__ */ jsxs("div", { children: [
17061
+ /* @__PURE__ */ jsx(
17062
+ SkeletonItem,
17063
+ {
17064
+ style: {
17065
+ width: "75%",
17066
+ height: "18px",
17067
+ marginBottom: tokens.spacingVerticalM
17068
+ }
17069
+ }
17070
+ ),
17071
+ /* @__PURE__ */ jsx(
17072
+ SkeletonItem,
17073
+ {
17074
+ style: {
17075
+ width: "100%",
17076
+ height: "40px",
17077
+ borderRadius: tokens.borderRadiusCircular
17078
+ }
17079
+ }
17080
+ )
17081
+ ] }),
17082
+ /* @__PURE__ */ jsxs("div", { className: styles.infoCard, children: [
17083
+ /* @__PURE__ */ jsx(SkeletonItem, { style: { width: "55%", height: "20px" } }),
17084
+ /* @__PURE__ */ jsx(SkeletonItem, { style: { width: "100%", height: "16px" } }),
17085
+ /* @__PURE__ */ jsx(SkeletonItem, { style: { width: "85%", height: "16px" } })
17086
+ ] })
17087
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
16891
17088
  /* @__PURE__ */ jsxs("div", { className: styles.headerRow, children: [
16892
17089
  /* @__PURE__ */ jsx(Subtitle1, { children: mergedLabels.expiryPrefix }),
16893
17090
  /* @__PURE__ */ jsx(Title2, { className: styles.expiryTitle, children: expiryDate })
@@ -16940,7 +17137,16 @@ var CardPaymentInfo = ({
16940
17137
  )
16941
17138
  ] }),
16942
17139
  /* @__PURE__ */ jsxs("div", { children: [
16943
- /* @__PURE__ */ jsx("div", { style: { marginBottom: tokens.spacingVerticalM }, children: /* @__PURE__ */ jsx(Subtitle2, { style: { color: tokens.colorNeutralStrokeAccessible, fontWeight: fontWeight.Medium }, children: mergedLabels.checkStatusInfo }) }),
17140
+ /* @__PURE__ */ jsx("div", { style: { marginBottom: tokens.spacingVerticalM }, children: /* @__PURE__ */ jsx(
17141
+ Subtitle2,
17142
+ {
17143
+ style: {
17144
+ color: tokens.colorNeutralStrokeAccessible,
17145
+ fontWeight: fontWeight.Medium
17146
+ },
17147
+ children: mergedLabels.checkStatusInfo
17148
+ }
17149
+ ) }),
16944
17150
  /* @__PURE__ */ jsx(
16945
17151
  Button,
16946
17152
  {
@@ -16954,7 +17160,7 @@ var CardPaymentInfo = ({
16954
17160
  )
16955
17161
  ] }),
16956
17162
  /* @__PURE__ */ jsx(CardPaymentGuide, { guides, language })
16957
- ] }) });
17163
+ ] }) }) });
16958
17164
  };
16959
17165
 
16960
17166
  // src/components/CardStatusOrder/CardStatusOrder.constants.ts