@asdp/ferryui 0.1.22-dev.10685 → 0.1.22-dev.10693

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.d.mts CHANGED
@@ -2986,6 +2986,7 @@ interface CargoItem {
2986
2986
  quantity: number;
2987
2987
  industryType: string;
2988
2988
  cargoCategory: string;
2989
+ _isAccordionOpen: boolean;
2989
2990
  }
2990
2991
  interface VehicleOwner {
2991
2992
  id: number;
@@ -3151,6 +3152,10 @@ interface CardVehicleOwnerFormLabels {
3151
3152
  industryTypeOthersLabel: string;
3152
3153
  industryTypeOthersPlaceholder: string;
3153
3154
  cargoCategoryLabel: string;
3155
+ estimatedLooseCargoLabel: string;
3156
+ estimatedLooseCargoWeightPlaceholder: string;
3157
+ estimatedLooseCargoQuantityLabel: string;
3158
+ estimatedLooseCargoUnitLabel: string;
3154
3159
  deleteCargoButton: string;
3155
3160
  addCargoButton: string;
3156
3161
  loadTypeOptions: {
package/dist/index.d.ts CHANGED
@@ -2986,6 +2986,7 @@ interface CargoItem {
2986
2986
  quantity: number;
2987
2987
  industryType: string;
2988
2988
  cargoCategory: string;
2989
+ _isAccordionOpen: boolean;
2989
2990
  }
2990
2991
  interface VehicleOwner {
2991
2992
  id: number;
@@ -3151,6 +3152,10 @@ interface CardVehicleOwnerFormLabels {
3151
3152
  industryTypeOthersLabel: string;
3152
3153
  industryTypeOthersPlaceholder: string;
3153
3154
  cargoCategoryLabel: string;
3155
+ estimatedLooseCargoLabel: string;
3156
+ estimatedLooseCargoWeightPlaceholder: string;
3157
+ estimatedLooseCargoQuantityLabel: string;
3158
+ estimatedLooseCargoUnitLabel: string;
3154
3159
  deleteCargoButton: string;
3155
3160
  addCargoButton: string;
3156
3161
  loadTypeOptions: {
package/dist/index.js CHANGED
@@ -287,7 +287,8 @@ var sharedColors = {
287
287
  "Shared_Green_Primary": "#107c10",
288
288
  "Shared_Lilac_Primary": "#b146c2",
289
289
  "Shared_Lilac_Tint_40": "#e6bfed",
290
- "Shared_Lilac_Tint_60": "#fcf6fd"};
290
+ "Shared_Lilac_Tint_60": "#fcf6fd",
291
+ "Shared_Secondary_Primary": "#5C9F38"};
291
292
  var foundationColors = {
292
293
  "Foundation_Danger_error": "#FD3A3A"
293
294
  };
@@ -12797,6 +12798,10 @@ var DEFAULT_LABELS26 = {
12797
12798
  industryTypeOthersLabel: "Jenis Industri Lainnya",
12798
12799
  industryTypeOthersPlaceholder: "Masukkan Jenis Industri",
12799
12800
  cargoCategoryLabel: "Kategori Muatan",
12801
+ estimatedLooseCargoLabel: "Estimasi Berat Barang Lepas",
12802
+ estimatedLooseCargoWeightPlaceholder: "Masukkan Berat (Ton)",
12803
+ estimatedLooseCargoQuantityLabel: "Jumlah Karung",
12804
+ estimatedLooseCargoUnitLabel: "Karung",
12800
12805
  deleteCargoButton: "Hapus Muatan",
12801
12806
  addCargoButton: "Tambah Muatan",
12802
12807
  loadTypeOptions: {
@@ -12853,6 +12858,10 @@ var DEFAULT_LABELS26 = {
12853
12858
  industryTypeOthersLabel: "Other Industry Type",
12854
12859
  industryTypeOthersPlaceholder: "Enter Industry Type",
12855
12860
  cargoCategoryLabel: "Cargo Category",
12861
+ estimatedLooseCargoLabel: "Estimated Loose Cargo Weight",
12862
+ estimatedLooseCargoWeightPlaceholder: "Enter Weight (Ton)",
12863
+ estimatedLooseCargoQuantityLabel: "Number of Bags",
12864
+ estimatedLooseCargoUnitLabel: "Bags",
12856
12865
  deleteCargoButton: "Delete Cargo",
12857
12866
  addCargoButton: "Add Cargo",
12858
12867
  loadTypeOptions: {
@@ -12941,6 +12950,18 @@ var CardVehicleOwnerForm = ({
12941
12950
  const styles = useStyles27();
12942
12951
  const mergedLabels = { ...DEFAULT_LABELS26[language], ...labels };
12943
12952
  const formValues = watch();
12953
+ const [defaultOpenCargoItems, setOpenCargoItems] = React__default.default.useState(/* @__PURE__ */ new Set());
12954
+ React.useEffect(() => {
12955
+ const allOpenItems = /* @__PURE__ */ new Set();
12956
+ owners.forEach((owner) => {
12957
+ owner.cargoItems?.forEach((cargo) => {
12958
+ if (cargo._isAccordionOpen) {
12959
+ allOpenItems.add(`cargo-${cargo.id}`);
12960
+ }
12961
+ });
12962
+ });
12963
+ setOpenCargoItems(allOpenItems);
12964
+ }, [owners]);
12944
12965
  React.useEffect(() => {
12945
12966
  console.log("[CardVehicleOwnerForm] Form values changed:", formValues);
12946
12967
  }, [formValues]);
@@ -13437,9 +13458,18 @@ var CardVehicleOwnerForm = ({
13437
13458
  reactComponents.Accordion,
13438
13459
  {
13439
13460
  collapsible: true,
13440
- defaultOpenItems: owner.cargoItems?.map(
13441
- (cargo) => `cargo-${cargo.id}`
13442
- ) || [],
13461
+ defaultOpenItems: Array.from(defaultOpenCargoItems),
13462
+ onToggle: (e, data) => {
13463
+ const newOpenItems = new Set(data.openItems);
13464
+ setOpenCargoItems(newOpenItems);
13465
+ const updatedCargoItems = owner.cargoItems?.map((cargo) => ({
13466
+ ...cargo,
13467
+ _isAccordionOpen: newOpenItems.has(`cargo-${cargo.id}`)
13468
+ }));
13469
+ onUpdateOwner(owner.id, {
13470
+ cargoItems: updatedCargoItems
13471
+ });
13472
+ },
13443
13473
  multiple: true,
13444
13474
  children: owner.cargoItems?.map((cargo, cargoIndex) => {
13445
13475
  const watchCommodity = watch(
@@ -13451,6 +13481,9 @@ var CardVehicleOwnerForm = ({
13451
13481
  const watchIndustryType = watch(
13452
13482
  `owners.${index}.cargo.${cargoIndex}.industryType`
13453
13483
  );
13484
+ const watchQuantity = watch(
13485
+ `owners.${index}.cargo.${cargoIndex}.quantity`
13486
+ );
13454
13487
  let _loadTypeOptions = [];
13455
13488
  if (watchCommodity && loadTypeOptionsByCommodityId[watchCommodity]) {
13456
13489
  _loadTypeOptions = loadTypeOptionsByCommodityId[watchCommodity];
@@ -13460,6 +13493,9 @@ var CardVehicleOwnerForm = ({
13460
13493
  label: `${lt.name}${lt.unit?.name ? ` (${lt.unit.name})` : ""}`
13461
13494
  }));
13462
13495
  }
13496
+ const _selectedLoadType = loadTypes.find(
13497
+ (loadType) => loadType.id.toString() === watchLoadType
13498
+ );
13463
13499
  const isLoadTypeOther = _loadTypeOptions.find(
13464
13500
  (lt) => lt.value.toString() === String(watchLoadType)
13465
13501
  )?.label.startsWith(
@@ -13479,19 +13515,65 @@ var CardVehicleOwnerForm = ({
13479
13515
  {
13480
13516
  className: styles.accordionHeader,
13481
13517
  expandIconPosition: "end",
13482
- children: /* @__PURE__ */ jsxRuntime.jsx(
13518
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
13483
13519
  "div",
13484
13520
  {
13485
13521
  style: {
13486
13522
  display: "flex",
13487
- justifyContent: "space-between",
13488
- alignItems: "center",
13489
- width: "100%"
13523
+ flexDirection: "column",
13524
+ width: "100%",
13525
+ gap: "0.5rem"
13490
13526
  },
13491
- children: /* @__PURE__ */ jsxRuntime.jsx(reactComponents.Body1Strong, { children: mergedLabels.cargoItemTitle.replace(
13492
- "{index}",
13493
- (cargoIndex + 1).toString()
13494
- ) })
13527
+ children: [
13528
+ /* @__PURE__ */ jsxRuntime.jsx(reactComponents.Body1Strong, { children: mergedLabels.cargoItemTitle.replace(
13529
+ "{index}",
13530
+ (cargoIndex + 1).toString()
13531
+ ) }),
13532
+ _selectedLoadType && !cargo._isAccordionOpen && /* @__PURE__ */ jsxRuntime.jsxs(
13533
+ "div",
13534
+ {
13535
+ style: {
13536
+ display: "flex",
13537
+ justifyContent: "space-between",
13538
+ alignItems: "center",
13539
+ width: "100%"
13540
+ },
13541
+ children: [
13542
+ /* @__PURE__ */ jsxRuntime.jsxs(reactComponents.Body1Strong, { children: [
13543
+ _selectedLoadType.name,
13544
+ " \u2022",
13545
+ " ",
13546
+ watchQuantity,
13547
+ "x",
13548
+ " ",
13549
+ _selectedLoadType.unit?.name,
13550
+ " \u2022",
13551
+ " ",
13552
+ _selectedLoadType.formattedPrice
13553
+ ] }),
13554
+ /* @__PURE__ */ jsxRuntime.jsx(
13555
+ reactComponents.Body1Stronger,
13556
+ {
13557
+ style: {
13558
+ color: sharedColors["Shared_Secondary_Primary"]
13559
+ },
13560
+ children: new Intl.NumberFormat("id-ID", {
13561
+ style: "currency",
13562
+ currency: "IDR",
13563
+ minimumFractionDigits: 0
13564
+ }).format(
13565
+ Number(
13566
+ getValues(
13567
+ `owners.${index}.cargo.${cargoIndex}.quantity`
13568
+ ) || 0
13569
+ ) * (_selectedLoadType.price || 0)
13570
+ )
13571
+ }
13572
+ )
13573
+ ]
13574
+ }
13575
+ )
13576
+ ]
13495
13577
  }
13496
13578
  )
13497
13579
  }
@@ -13727,13 +13809,48 @@ var CardVehicleOwnerForm = ({
13727
13809
  )
13728
13810
  ] })
13729
13811
  ] }),
13812
+ /* @__PURE__ */ jsxRuntime.jsxs(reactGridSystem.Row, { children: [
13813
+ /* @__PURE__ */ jsxRuntime.jsx(reactGridSystem.Col, { lg: 12, children: /* @__PURE__ */ jsxRuntime.jsx(reactComponents.Body1, { className: styles.label, children: mergedLabels.estimatedLooseCargoLabel }) }),
13814
+ /* @__PURE__ */ jsxRuntime.jsx(reactGridSystem.Col, { md: 12, children: /* @__PURE__ */ jsxRuntime.jsx(
13815
+ InputDynamic_default,
13816
+ {
13817
+ control,
13818
+ disabled,
13819
+ name: `owners.${index}.cargo.${cargoIndex}.cargoWeight`,
13820
+ placeholder: mergedLabels.estimatedLooseCargoWeightPlaceholder,
13821
+ size: "large",
13822
+ type: "number",
13823
+ step: "1",
13824
+ onChange: (val) => {
13825
+ setValue(
13826
+ `owners.${index}.cargo.${cargoIndex}.cargoWeight`,
13827
+ val ? Number(val) : 0
13828
+ );
13829
+ const updatedCargoItems = owner.cargoItems?.map(
13830
+ (c, cIdx) => cIdx === cargoIndex ? {
13831
+ ...c,
13832
+ estimatedLooseCargoWeight: val ? Number(val) : 0
13833
+ } : c
13834
+ );
13835
+ onUpdateOwner(owner.id, {
13836
+ cargoItems: updatedCargoItems
13837
+ });
13838
+ },
13839
+ contentAfter: /* @__PURE__ */ jsxRuntime.jsx(
13840
+ "div",
13841
+ {
13842
+ style: {
13843
+ paddingRight: "12px",
13844
+ color: reactComponents.tokens.colorNeutralForeground1,
13845
+ fontSize: reactComponents.tokens.fontSizeBase300
13846
+ },
13847
+ children: "Ton"
13848
+ }
13849
+ )
13850
+ }
13851
+ ) })
13852
+ ] }),
13730
13853
  (() => {
13731
- const type = watch(
13732
- `owners.${index}.cargo.${cargoIndex}.loadType`
13733
- );
13734
- const _selectedLoadType = loadTypes.find(
13735
- (loadType) => loadType.id.toString() === type
13736
- );
13737
13854
  if (!_selectedLoadType) return null;
13738
13855
  return /* @__PURE__ */ jsxRuntime.jsxs(reactGridSystem.Row, { children: [
13739
13856
  /* @__PURE__ */ jsxRuntime.jsxs(reactGridSystem.Col, { md: 12, children: [
@@ -13918,11 +14035,11 @@ var CardVehicleOwnerForm = ({
13918
14035
  paddingRight: "8px"
13919
14036
  },
13920
14037
  children: (() => {
13921
- const type2 = watch(
14038
+ const type = watch(
13922
14039
  `owners.${index}.cargo.${cargoIndex}.loadType`
13923
14040
  );
13924
14041
  const selectedLoadType2 = loadTypes.find(
13925
- (loadType) => loadType.id.toString() === type2
14042
+ (loadType) => loadType.id.toString() === type
13926
14043
  );
13927
14044
  return selectedLoadType2?.unit?.name;
13928
14045
  })()
@@ -13939,22 +14056,45 @@ var CardVehicleOwnerForm = ({
13939
14056
  reactComponents.Body2,
13940
14057
  {
13941
14058
  style: { marginTop: "0.5rem" },
13942
- children: (() => {
13943
- return new Intl.NumberFormat(
13944
- "id-ID",
14059
+ children: /* @__PURE__ */ jsxRuntime.jsxs(reactGridSystem.Row, { children: [
14060
+ /* @__PURE__ */ jsxRuntime.jsx(reactGridSystem.Col, { xl: 6, children: /* @__PURE__ */ jsxRuntime.jsxs(reactComponents.Body1Strong, { children: [
14061
+ _selectedLoadType.name,
14062
+ " \u2022",
14063
+ " ",
14064
+ watchQuantity,
14065
+ "x",
14066
+ " ",
14067
+ _selectedLoadType.unit?.name,
14068
+ " ",
14069
+ "\u2022",
14070
+ " ",
14071
+ _selectedLoadType.formattedPrice
14072
+ ] }) }),
14073
+ /* @__PURE__ */ jsxRuntime.jsx(
14074
+ reactGridSystem.Col,
13945
14075
  {
13946
- style: "currency",
13947
- currency: "IDR",
13948
- minimumFractionDigits: 0
14076
+ xl: 6,
14077
+ style: {
14078
+ color: sharedColors["Shared_Secondary_Primary"],
14079
+ textAlign: "right"
14080
+ },
14081
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactComponents.Body1Stronger, { children: new Intl.NumberFormat(
14082
+ "id-ID",
14083
+ {
14084
+ style: "currency",
14085
+ currency: "IDR",
14086
+ minimumFractionDigits: 0
14087
+ }
14088
+ ).format(
14089
+ Number(
14090
+ getValues(
14091
+ `owners.${index}.cargo.${cargoIndex}.quantity`
14092
+ ) || 0
14093
+ ) * (_selectedLoadType.price || 0)
14094
+ ) })
13949
14095
  }
13950
- ).format(
13951
- Number(
13952
- getValues(
13953
- `owners.${index}.cargo.${cargoIndex}.quantity`
13954
- ) || 0
13955
- ) * (_selectedLoadType?.price || 0)
13956
- );
13957
- })()
14096
+ )
14097
+ ] })
13958
14098
  }
13959
14099
  )
13960
14100
  ] })