@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.mjs CHANGED
@@ -278,7 +278,8 @@ var sharedColors = {
278
278
  "Shared_Green_Primary": "#107c10",
279
279
  "Shared_Lilac_Primary": "#b146c2",
280
280
  "Shared_Lilac_Tint_40": "#e6bfed",
281
- "Shared_Lilac_Tint_60": "#fcf6fd"};
281
+ "Shared_Lilac_Tint_60": "#fcf6fd",
282
+ "Shared_Secondary_Primary": "#5C9F38"};
282
283
  var foundationColors = {
283
284
  "Foundation_Danger_error": "#FD3A3A"
284
285
  };
@@ -12788,6 +12789,10 @@ var DEFAULT_LABELS26 = {
12788
12789
  industryTypeOthersLabel: "Jenis Industri Lainnya",
12789
12790
  industryTypeOthersPlaceholder: "Masukkan Jenis Industri",
12790
12791
  cargoCategoryLabel: "Kategori Muatan",
12792
+ estimatedLooseCargoLabel: "Estimasi Berat Barang Lepas",
12793
+ estimatedLooseCargoWeightPlaceholder: "Masukkan Berat (Ton)",
12794
+ estimatedLooseCargoQuantityLabel: "Jumlah Karung",
12795
+ estimatedLooseCargoUnitLabel: "Karung",
12791
12796
  deleteCargoButton: "Hapus Muatan",
12792
12797
  addCargoButton: "Tambah Muatan",
12793
12798
  loadTypeOptions: {
@@ -12844,6 +12849,10 @@ var DEFAULT_LABELS26 = {
12844
12849
  industryTypeOthersLabel: "Other Industry Type",
12845
12850
  industryTypeOthersPlaceholder: "Enter Industry Type",
12846
12851
  cargoCategoryLabel: "Cargo Category",
12852
+ estimatedLooseCargoLabel: "Estimated Loose Cargo Weight",
12853
+ estimatedLooseCargoWeightPlaceholder: "Enter Weight (Ton)",
12854
+ estimatedLooseCargoQuantityLabel: "Number of Bags",
12855
+ estimatedLooseCargoUnitLabel: "Bags",
12847
12856
  deleteCargoButton: "Delete Cargo",
12848
12857
  addCargoButton: "Add Cargo",
12849
12858
  loadTypeOptions: {
@@ -12932,6 +12941,18 @@ var CardVehicleOwnerForm = ({
12932
12941
  const styles = useStyles27();
12933
12942
  const mergedLabels = { ...DEFAULT_LABELS26[language], ...labels };
12934
12943
  const formValues = watch();
12944
+ const [defaultOpenCargoItems, setOpenCargoItems] = React.useState(/* @__PURE__ */ new Set());
12945
+ useEffect(() => {
12946
+ const allOpenItems = /* @__PURE__ */ new Set();
12947
+ owners.forEach((owner) => {
12948
+ owner.cargoItems?.forEach((cargo) => {
12949
+ if (cargo._isAccordionOpen) {
12950
+ allOpenItems.add(`cargo-${cargo.id}`);
12951
+ }
12952
+ });
12953
+ });
12954
+ setOpenCargoItems(allOpenItems);
12955
+ }, [owners]);
12935
12956
  useEffect(() => {
12936
12957
  console.log("[CardVehicleOwnerForm] Form values changed:", formValues);
12937
12958
  }, [formValues]);
@@ -13428,9 +13449,18 @@ var CardVehicleOwnerForm = ({
13428
13449
  Accordion,
13429
13450
  {
13430
13451
  collapsible: true,
13431
- defaultOpenItems: owner.cargoItems?.map(
13432
- (cargo) => `cargo-${cargo.id}`
13433
- ) || [],
13452
+ defaultOpenItems: Array.from(defaultOpenCargoItems),
13453
+ onToggle: (e, data) => {
13454
+ const newOpenItems = new Set(data.openItems);
13455
+ setOpenCargoItems(newOpenItems);
13456
+ const updatedCargoItems = owner.cargoItems?.map((cargo) => ({
13457
+ ...cargo,
13458
+ _isAccordionOpen: newOpenItems.has(`cargo-${cargo.id}`)
13459
+ }));
13460
+ onUpdateOwner(owner.id, {
13461
+ cargoItems: updatedCargoItems
13462
+ });
13463
+ },
13434
13464
  multiple: true,
13435
13465
  children: owner.cargoItems?.map((cargo, cargoIndex) => {
13436
13466
  const watchCommodity = watch(
@@ -13442,6 +13472,9 @@ var CardVehicleOwnerForm = ({
13442
13472
  const watchIndustryType = watch(
13443
13473
  `owners.${index}.cargo.${cargoIndex}.industryType`
13444
13474
  );
13475
+ const watchQuantity = watch(
13476
+ `owners.${index}.cargo.${cargoIndex}.quantity`
13477
+ );
13445
13478
  let _loadTypeOptions = [];
13446
13479
  if (watchCommodity && loadTypeOptionsByCommodityId[watchCommodity]) {
13447
13480
  _loadTypeOptions = loadTypeOptionsByCommodityId[watchCommodity];
@@ -13451,6 +13484,9 @@ var CardVehicleOwnerForm = ({
13451
13484
  label: `${lt.name}${lt.unit?.name ? ` (${lt.unit.name})` : ""}`
13452
13485
  }));
13453
13486
  }
13487
+ const _selectedLoadType = loadTypes.find(
13488
+ (loadType) => loadType.id.toString() === watchLoadType
13489
+ );
13454
13490
  const isLoadTypeOther = _loadTypeOptions.find(
13455
13491
  (lt) => lt.value.toString() === String(watchLoadType)
13456
13492
  )?.label.startsWith(
@@ -13470,19 +13506,65 @@ var CardVehicleOwnerForm = ({
13470
13506
  {
13471
13507
  className: styles.accordionHeader,
13472
13508
  expandIconPosition: "end",
13473
- children: /* @__PURE__ */ jsx(
13509
+ children: /* @__PURE__ */ jsxs(
13474
13510
  "div",
13475
13511
  {
13476
13512
  style: {
13477
13513
  display: "flex",
13478
- justifyContent: "space-between",
13479
- alignItems: "center",
13480
- width: "100%"
13514
+ flexDirection: "column",
13515
+ width: "100%",
13516
+ gap: "0.5rem"
13481
13517
  },
13482
- children: /* @__PURE__ */ jsx(Body1Strong, { children: mergedLabels.cargoItemTitle.replace(
13483
- "{index}",
13484
- (cargoIndex + 1).toString()
13485
- ) })
13518
+ children: [
13519
+ /* @__PURE__ */ jsx(Body1Strong, { children: mergedLabels.cargoItemTitle.replace(
13520
+ "{index}",
13521
+ (cargoIndex + 1).toString()
13522
+ ) }),
13523
+ _selectedLoadType && !cargo._isAccordionOpen && /* @__PURE__ */ jsxs(
13524
+ "div",
13525
+ {
13526
+ style: {
13527
+ display: "flex",
13528
+ justifyContent: "space-between",
13529
+ alignItems: "center",
13530
+ width: "100%"
13531
+ },
13532
+ children: [
13533
+ /* @__PURE__ */ jsxs(Body1Strong, { children: [
13534
+ _selectedLoadType.name,
13535
+ " \u2022",
13536
+ " ",
13537
+ watchQuantity,
13538
+ "x",
13539
+ " ",
13540
+ _selectedLoadType.unit?.name,
13541
+ " \u2022",
13542
+ " ",
13543
+ _selectedLoadType.formattedPrice
13544
+ ] }),
13545
+ /* @__PURE__ */ jsx(
13546
+ Body1Stronger,
13547
+ {
13548
+ style: {
13549
+ color: sharedColors["Shared_Secondary_Primary"]
13550
+ },
13551
+ children: new Intl.NumberFormat("id-ID", {
13552
+ style: "currency",
13553
+ currency: "IDR",
13554
+ minimumFractionDigits: 0
13555
+ }).format(
13556
+ Number(
13557
+ getValues(
13558
+ `owners.${index}.cargo.${cargoIndex}.quantity`
13559
+ ) || 0
13560
+ ) * (_selectedLoadType.price || 0)
13561
+ )
13562
+ }
13563
+ )
13564
+ ]
13565
+ }
13566
+ )
13567
+ ]
13486
13568
  }
13487
13569
  )
13488
13570
  }
@@ -13718,13 +13800,48 @@ var CardVehicleOwnerForm = ({
13718
13800
  )
13719
13801
  ] })
13720
13802
  ] }),
13803
+ /* @__PURE__ */ jsxs(Row, { children: [
13804
+ /* @__PURE__ */ jsx(Col, { lg: 12, children: /* @__PURE__ */ jsx(Body1, { className: styles.label, children: mergedLabels.estimatedLooseCargoLabel }) }),
13805
+ /* @__PURE__ */ jsx(Col, { md: 12, children: /* @__PURE__ */ jsx(
13806
+ InputDynamic_default,
13807
+ {
13808
+ control,
13809
+ disabled,
13810
+ name: `owners.${index}.cargo.${cargoIndex}.cargoWeight`,
13811
+ placeholder: mergedLabels.estimatedLooseCargoWeightPlaceholder,
13812
+ size: "large",
13813
+ type: "number",
13814
+ step: "1",
13815
+ onChange: (val) => {
13816
+ setValue(
13817
+ `owners.${index}.cargo.${cargoIndex}.cargoWeight`,
13818
+ val ? Number(val) : 0
13819
+ );
13820
+ const updatedCargoItems = owner.cargoItems?.map(
13821
+ (c, cIdx) => cIdx === cargoIndex ? {
13822
+ ...c,
13823
+ estimatedLooseCargoWeight: val ? Number(val) : 0
13824
+ } : c
13825
+ );
13826
+ onUpdateOwner(owner.id, {
13827
+ cargoItems: updatedCargoItems
13828
+ });
13829
+ },
13830
+ contentAfter: /* @__PURE__ */ jsx(
13831
+ "div",
13832
+ {
13833
+ style: {
13834
+ paddingRight: "12px",
13835
+ color: tokens.colorNeutralForeground1,
13836
+ fontSize: tokens.fontSizeBase300
13837
+ },
13838
+ children: "Ton"
13839
+ }
13840
+ )
13841
+ }
13842
+ ) })
13843
+ ] }),
13721
13844
  (() => {
13722
- const type = watch(
13723
- `owners.${index}.cargo.${cargoIndex}.loadType`
13724
- );
13725
- const _selectedLoadType = loadTypes.find(
13726
- (loadType) => loadType.id.toString() === type
13727
- );
13728
13845
  if (!_selectedLoadType) return null;
13729
13846
  return /* @__PURE__ */ jsxs(Row, { children: [
13730
13847
  /* @__PURE__ */ jsxs(Col, { md: 12, children: [
@@ -13909,11 +14026,11 @@ var CardVehicleOwnerForm = ({
13909
14026
  paddingRight: "8px"
13910
14027
  },
13911
14028
  children: (() => {
13912
- const type2 = watch(
14029
+ const type = watch(
13913
14030
  `owners.${index}.cargo.${cargoIndex}.loadType`
13914
14031
  );
13915
14032
  const selectedLoadType2 = loadTypes.find(
13916
- (loadType) => loadType.id.toString() === type2
14033
+ (loadType) => loadType.id.toString() === type
13917
14034
  );
13918
14035
  return selectedLoadType2?.unit?.name;
13919
14036
  })()
@@ -13930,22 +14047,45 @@ var CardVehicleOwnerForm = ({
13930
14047
  Body2,
13931
14048
  {
13932
14049
  style: { marginTop: "0.5rem" },
13933
- children: (() => {
13934
- return new Intl.NumberFormat(
13935
- "id-ID",
14050
+ children: /* @__PURE__ */ jsxs(Row, { children: [
14051
+ /* @__PURE__ */ jsx(Col, { xl: 6, children: /* @__PURE__ */ jsxs(Body1Strong, { children: [
14052
+ _selectedLoadType.name,
14053
+ " \u2022",
14054
+ " ",
14055
+ watchQuantity,
14056
+ "x",
14057
+ " ",
14058
+ _selectedLoadType.unit?.name,
14059
+ " ",
14060
+ "\u2022",
14061
+ " ",
14062
+ _selectedLoadType.formattedPrice
14063
+ ] }) }),
14064
+ /* @__PURE__ */ jsx(
14065
+ Col,
13936
14066
  {
13937
- style: "currency",
13938
- currency: "IDR",
13939
- minimumFractionDigits: 0
14067
+ xl: 6,
14068
+ style: {
14069
+ color: sharedColors["Shared_Secondary_Primary"],
14070
+ textAlign: "right"
14071
+ },
14072
+ children: /* @__PURE__ */ jsx(Body1Stronger, { children: new Intl.NumberFormat(
14073
+ "id-ID",
14074
+ {
14075
+ style: "currency",
14076
+ currency: "IDR",
14077
+ minimumFractionDigits: 0
14078
+ }
14079
+ ).format(
14080
+ Number(
14081
+ getValues(
14082
+ `owners.${index}.cargo.${cargoIndex}.quantity`
14083
+ ) || 0
14084
+ ) * (_selectedLoadType.price || 0)
14085
+ ) })
13940
14086
  }
13941
- ).format(
13942
- Number(
13943
- getValues(
13944
- `owners.${index}.cargo.${cargoIndex}.quantity`
13945
- ) || 0
13946
- ) * (_selectedLoadType?.price || 0)
13947
- );
13948
- })()
14087
+ )
14088
+ ] })
13949
14089
  }
13950
14090
  )
13951
14091
  ] })