@loafmarkets/ui 0.1.6 → 0.1.7
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 +37 -1
- package/dist/index.d.ts +37 -1
- package/dist/index.js +388 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +388 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5628,7 +5628,394 @@ var PropertySubheader = o.forwardRef(
|
|
|
5628
5628
|
}
|
|
5629
5629
|
);
|
|
5630
5630
|
PropertySubheader.displayName = "PropertySubheader";
|
|
5631
|
+
var PropertyCompareBar = o.forwardRef(
|
|
5632
|
+
({
|
|
5633
|
+
className,
|
|
5634
|
+
addresses,
|
|
5635
|
+
selectedAddressId,
|
|
5636
|
+
onSelectAddress,
|
|
5637
|
+
propertyValue,
|
|
5638
|
+
propertyValueVariant = "classic",
|
|
5639
|
+
price,
|
|
5640
|
+
...props
|
|
5641
|
+
}, ref) => {
|
|
5642
|
+
const normalizedAddresses = o.useMemo(() => {
|
|
5643
|
+
return addresses.map(
|
|
5644
|
+
(option) => typeof option === "string" ? { id: option, label: option } : option
|
|
5645
|
+
);
|
|
5646
|
+
}, [addresses]);
|
|
5647
|
+
const hasAddresses = normalizedAddresses.length > 0;
|
|
5648
|
+
const firstAddressId = normalizedAddresses[0]?.id;
|
|
5649
|
+
const isControlled = selectedAddressId !== void 0;
|
|
5650
|
+
const [internalSelectedId, setInternalSelectedId] = o.useState(
|
|
5651
|
+
() => isControlled ? void 0 : firstAddressId
|
|
5652
|
+
);
|
|
5653
|
+
const resolvedSelectedId = isControlled ? selectedAddressId : internalSelectedId;
|
|
5654
|
+
o.useEffect(() => {
|
|
5655
|
+
if (!isControlled) {
|
|
5656
|
+
setInternalSelectedId((current) => {
|
|
5657
|
+
if (current != null && normalizedAddresses.some((option) => option.id === current)) {
|
|
5658
|
+
return current;
|
|
5659
|
+
}
|
|
5660
|
+
return firstAddressId;
|
|
5661
|
+
});
|
|
5662
|
+
}
|
|
5663
|
+
}, [firstAddressId, isControlled, normalizedAddresses]);
|
|
5664
|
+
const selectedOption = normalizedAddresses.find((option) => option.id === resolvedSelectedId) ?? normalizedAddresses[0];
|
|
5665
|
+
const [isDropdownOpen, setIsDropdownOpen] = o.useState(false);
|
|
5666
|
+
const dropdownRef = o.useRef(null);
|
|
5667
|
+
o.useEffect(() => {
|
|
5668
|
+
if (!isDropdownOpen) return;
|
|
5669
|
+
const handleClick = (event) => {
|
|
5670
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
5671
|
+
setIsDropdownOpen(false);
|
|
5672
|
+
}
|
|
5673
|
+
};
|
|
5674
|
+
const handleKey = (event) => {
|
|
5675
|
+
if (event.key === "Escape") {
|
|
5676
|
+
setIsDropdownOpen(false);
|
|
5677
|
+
}
|
|
5678
|
+
};
|
|
5679
|
+
document.addEventListener("mousedown", handleClick);
|
|
5680
|
+
document.addEventListener("keydown", handleKey);
|
|
5681
|
+
return () => {
|
|
5682
|
+
document.removeEventListener("mousedown", handleClick);
|
|
5683
|
+
document.removeEventListener("keydown", handleKey);
|
|
5684
|
+
};
|
|
5685
|
+
}, [isDropdownOpen]);
|
|
5686
|
+
const handleAddressSelect = (addressId) => {
|
|
5687
|
+
if (!isControlled) {
|
|
5688
|
+
setInternalSelectedId(addressId);
|
|
5689
|
+
}
|
|
5690
|
+
onSelectAddress?.(addressId);
|
|
5691
|
+
setIsDropdownOpen(false);
|
|
5692
|
+
};
|
|
5693
|
+
const propertyValueLabel = propertyValue?.label ?? "Property Value";
|
|
5694
|
+
const propertyValueCurrency = propertyValue?.currencySymbol ?? "$";
|
|
5695
|
+
const propertyValueFormat = propertyValue?.formatOptions ?? {
|
|
5696
|
+
minimumFractionDigits: 2,
|
|
5697
|
+
maximumFractionDigits: 2
|
|
5698
|
+
};
|
|
5699
|
+
const formattedPropertyValue = propertyValue == null ? null : `${propertyValueCurrency}${propertyValue.value.toLocaleString(
|
|
5700
|
+
void 0,
|
|
5701
|
+
propertyValueFormat
|
|
5702
|
+
)}`;
|
|
5703
|
+
const formattedPropertyChange = propertyValue?.change == null ? null : `${propertyValue.change >= 0 ? "+" : "-"}${propertyValueCurrency}${Math.abs(
|
|
5704
|
+
propertyValue.change
|
|
5705
|
+
).toLocaleString(void 0, propertyValueFormat)}`;
|
|
5706
|
+
const priceCurrency = price?.currencySymbol ?? "$";
|
|
5707
|
+
const priceFormat = price?.formatOptions ?? { minimumFractionDigits: 2, maximumFractionDigits: 2 };
|
|
5708
|
+
const pricePercentFormat = price?.percentFormatOptions ?? { minimumFractionDigits: 2, maximumFractionDigits: 2 };
|
|
5709
|
+
const formattedPriceValue = price == null ? null : `${priceCurrency}${price.value.toLocaleString(void 0, priceFormat)}`;
|
|
5710
|
+
const formattedPriceChange = price?.change == null ? null : `${price.change >= 0 ? "+" : "-"}${priceCurrency}${Math.abs(price.change).toLocaleString(
|
|
5711
|
+
void 0,
|
|
5712
|
+
priceFormat
|
|
5713
|
+
)}`;
|
|
5714
|
+
const formattedPricePercent = price?.changePercent == null ? null : `${price.changePercent >= 0 ? "+" : "-"}${Math.abs(price.changePercent).toLocaleString(
|
|
5715
|
+
void 0,
|
|
5716
|
+
pricePercentFormat
|
|
5717
|
+
)}%`;
|
|
5718
|
+
const priceContent = formattedPriceValue && propertyValueVariant === "pill" ? /* @__PURE__ */ jsxs(PriceBlock2, { $variant: propertyValueVariant, children: [
|
|
5719
|
+
/* @__PURE__ */ jsx(PriceAmount, { children: formattedPriceValue }),
|
|
5720
|
+
formattedPriceChange || formattedPricePercent ? /* @__PURE__ */ jsxs(
|
|
5721
|
+
PriceChange,
|
|
5722
|
+
{
|
|
5723
|
+
$isPositive: price?.change != null ? price.change >= 0 : price?.changePercent != null ? price.changePercent >= 0 : void 0,
|
|
5724
|
+
children: [
|
|
5725
|
+
formattedPriceChange ? /* @__PURE__ */ jsx("span", { children: formattedPriceChange }) : null,
|
|
5726
|
+
formattedPricePercent ? /* @__PURE__ */ jsx("span", { children: formattedPricePercent }) : null
|
|
5727
|
+
]
|
|
5728
|
+
}
|
|
5729
|
+
) : null
|
|
5730
|
+
] }) : null;
|
|
5731
|
+
const propertyValueContent = formattedPropertyValue ? /* @__PURE__ */ jsxs(PropertyValueBlock, { $variant: propertyValueVariant, children: [
|
|
5732
|
+
/* @__PURE__ */ jsx(PropertyValueLabel, { children: propertyValueLabel }),
|
|
5733
|
+
/* @__PURE__ */ jsx(PropertyValueAmount, { children: formattedPropertyValue }),
|
|
5734
|
+
formattedPropertyChange ? /* @__PURE__ */ jsx(PropertyValueChange, { $isPositive: propertyValue?.change != null ? propertyValue.change >= 0 : void 0, children: formattedPropertyChange }) : null
|
|
5735
|
+
] }) : null;
|
|
5736
|
+
return /* @__PURE__ */ jsxs(PropertySelectorContainer, { ref, className, $variant: propertyValueVariant, ...props, children: [
|
|
5737
|
+
/* @__PURE__ */ jsxs(PropertySelector, { ref: dropdownRef, onClick: () => hasAddresses && setIsDropdownOpen((prev2) => !prev2), children: [
|
|
5738
|
+
/* @__PURE__ */ jsxs(PropertyAddress, { children: [
|
|
5739
|
+
selectedOption ? selectedOption.label : hasAddresses ? "Select address" : "No addresses available",
|
|
5740
|
+
/* @__PURE__ */ jsx(
|
|
5741
|
+
"svg",
|
|
5742
|
+
{
|
|
5743
|
+
className: "dropdown-icon",
|
|
5744
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5745
|
+
width: "20",
|
|
5746
|
+
height: "20",
|
|
5747
|
+
viewBox: "0 0 24 24",
|
|
5748
|
+
fill: "currentColor",
|
|
5749
|
+
style: { transform: isDropdownOpen ? "rotate(180deg)" : void 0 },
|
|
5750
|
+
children: /* @__PURE__ */ jsx("path", { d: "M7 10l5 5 5-5H7z" })
|
|
5751
|
+
}
|
|
5752
|
+
)
|
|
5753
|
+
] }),
|
|
5754
|
+
/* @__PURE__ */ jsx(PropertySelectorDropdown, { $isOpen: isDropdownOpen && hasAddresses, children: normalizedAddresses.map((option) => /* @__PURE__ */ jsx(
|
|
5755
|
+
PropertySelectorOption,
|
|
5756
|
+
{
|
|
5757
|
+
onClick: (event) => {
|
|
5758
|
+
event.stopPropagation();
|
|
5759
|
+
handleAddressSelect(option.id);
|
|
5760
|
+
},
|
|
5761
|
+
children: /* @__PURE__ */ jsx(PropertySelectorName, { children: option.label })
|
|
5762
|
+
},
|
|
5763
|
+
option.id
|
|
5764
|
+
)) })
|
|
5765
|
+
] }),
|
|
5766
|
+
propertyValueVariant === "pill" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5767
|
+
priceContent,
|
|
5768
|
+
propertyValueContent
|
|
5769
|
+
] }) : propertyValueContent
|
|
5770
|
+
] });
|
|
5771
|
+
}
|
|
5772
|
+
);
|
|
5773
|
+
PropertyCompareBar.displayName = "PropertyCompareBar";
|
|
5774
|
+
var PropertySelectorContainer = at.div`
|
|
5775
|
+
display: flex;
|
|
5776
|
+
align-items: center;
|
|
5777
|
+
justify-content: space-between;
|
|
5778
|
+
padding: 1rem 1.5rem;
|
|
5779
|
+
background-color: ${({ $variant }) => $variant === "pill" ? "#0f0f0f" : "rgba(30, 32, 38, 0.95)"};
|
|
5780
|
+
border: ${({ $variant }) => $variant === "pill" ? "1px solid rgba(255, 255, 255, 0.15)" : "none"};
|
|
5781
|
+
border-radius: 8px;
|
|
5782
|
+
margin-bottom: 1.5rem;
|
|
5783
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
5784
|
+
color: var(--color-text, #f8f9fa);
|
|
5785
|
+
font-family: var(--font-family, "Inter", sans-serif);
|
|
5786
|
+
|
|
5787
|
+
@media (max-width: 1024px) {
|
|
5788
|
+
padding: 0.75rem 1rem;
|
|
5789
|
+
margin-bottom: 0.75rem;
|
|
5790
|
+
}
|
|
5791
|
+
|
|
5792
|
+
@media (max-width: 768px) {
|
|
5793
|
+
border-radius: 0;
|
|
5794
|
+
margin-top: 0;
|
|
5795
|
+
padding-top: 0.5rem;
|
|
5796
|
+
}
|
|
5797
|
+
|
|
5798
|
+
@media (max-width: 600px) {
|
|
5799
|
+
width: 100%;
|
|
5800
|
+
|
|
5801
|
+
${({ $variant }) => $variant === "pill" ? rt`
|
|
5802
|
+
display: grid;
|
|
5803
|
+
grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr) minmax(0, 1fr);
|
|
5804
|
+
gap: 0.35rem;
|
|
5805
|
+
align-items: center;
|
|
5806
|
+
|
|
5807
|
+
> *:nth-child(1) {
|
|
5808
|
+
width: 100%;
|
|
5809
|
+
}
|
|
5810
|
+
|
|
5811
|
+
> *:nth-child(2) {
|
|
5812
|
+
justify-self: center;
|
|
5813
|
+
width: 100%;
|
|
5814
|
+
}
|
|
5815
|
+
|
|
5816
|
+
> *:nth-child(3) {
|
|
5817
|
+
justify-self: end;
|
|
5818
|
+
text-align: right;
|
|
5819
|
+
}
|
|
5820
|
+
` : rt`
|
|
5821
|
+
flex-direction: row;
|
|
5822
|
+
align-items: center;
|
|
5823
|
+
justify-content: space-between;
|
|
5824
|
+
gap: 0.5rem;
|
|
5825
|
+
`};
|
|
5826
|
+
}
|
|
5827
|
+
`;
|
|
5828
|
+
var PropertySelector = at.div`
|
|
5829
|
+
position: relative;
|
|
5830
|
+
display: flex;
|
|
5831
|
+
align-items: center;
|
|
5832
|
+
cursor: pointer;
|
|
5833
|
+
padding: 0.5rem 0;
|
|
5834
|
+
flex: 1;
|
|
5835
|
+
|
|
5836
|
+
&:hover {
|
|
5837
|
+
.dropdown-icon {
|
|
5838
|
+
transform: translateY(2px);
|
|
5839
|
+
}
|
|
5840
|
+
}
|
|
5841
|
+
`;
|
|
5842
|
+
var PropertyAddress = at.div`
|
|
5843
|
+
font-size: 1.125rem;
|
|
5844
|
+
font-weight: 600;
|
|
5845
|
+
display: flex;
|
|
5846
|
+
align-items: center;
|
|
5847
|
+
gap: 0.5rem;
|
|
5848
|
+
color: inherit;
|
|
5849
|
+
|
|
5850
|
+
svg {
|
|
5851
|
+
transition: transform 0.2s;
|
|
5852
|
+
}
|
|
5853
|
+
|
|
5854
|
+
@media (max-width: 600px) {
|
|
5855
|
+
flex-direction: column;
|
|
5856
|
+
align-items: flex-start;
|
|
5857
|
+
gap: 0.2rem;
|
|
5858
|
+
font-size: 1rem;
|
|
5859
|
+
line-height: 1.2;
|
|
5860
|
+
white-space: normal;
|
|
5861
|
+
}
|
|
5862
|
+
`;
|
|
5863
|
+
var PropertySelectorDropdown = at.div`
|
|
5864
|
+
position: absolute;
|
|
5865
|
+
top: 100%;
|
|
5866
|
+
left: 0;
|
|
5867
|
+
width: 100%;
|
|
5868
|
+
max-width: 400px;
|
|
5869
|
+
background-color: var(--color-card, #1f232b);
|
|
5870
|
+
border-radius: 8px;
|
|
5871
|
+
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
|
|
5872
|
+
z-index: 100;
|
|
5873
|
+
overflow: hidden;
|
|
5874
|
+
display: ${(props) => props.$isOpen ? "block" : "none"};
|
|
5875
|
+
`;
|
|
5876
|
+
var PropertySelectorOption = at.div`
|
|
5877
|
+
padding: 0.75rem 1rem;
|
|
5878
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
|
5879
|
+
cursor: pointer;
|
|
5880
|
+
transition: background-color 0.2s;
|
|
5881
|
+
|
|
5882
|
+
&:hover {
|
|
5883
|
+
background-color: rgba(255, 255, 255, 0.05);
|
|
5884
|
+
}
|
|
5885
|
+
|
|
5886
|
+
&:last-child {
|
|
5887
|
+
border-bottom: none;
|
|
5888
|
+
}
|
|
5889
|
+
`;
|
|
5890
|
+
var PropertySelectorName = at.div`
|
|
5891
|
+
font-weight: 600;
|
|
5892
|
+
`;
|
|
5893
|
+
var PropertyValueBlock = at.div`
|
|
5894
|
+
display: flex;
|
|
5895
|
+
align-items: center;
|
|
5896
|
+
gap: 0.5rem;
|
|
5897
|
+
margin-left: 1rem;
|
|
5898
|
+
white-space: nowrap;
|
|
5899
|
+
|
|
5900
|
+
${({ $variant }) => $variant === "card" && rt`
|
|
5901
|
+
margin-left: auto;
|
|
5902
|
+
flex-direction: row;
|
|
5903
|
+
align-items: center;
|
|
5904
|
+
min-width: 220px;
|
|
5905
|
+
border: none;
|
|
5906
|
+
background: rgba(30, 32, 38, 0.95);
|
|
5907
|
+
border-radius: 14px;
|
|
5908
|
+
padding: 0.9rem 1.25rem;
|
|
5909
|
+
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
|
|
5910
|
+
gap: 0.85rem;
|
|
5911
|
+
justify-content: flex-end;
|
|
5912
|
+
|
|
5913
|
+
@media (max-width: 600px) {
|
|
5914
|
+
margin: 0;
|
|
5915
|
+
width: auto;
|
|
5916
|
+
min-width: 0;
|
|
5917
|
+
flex-direction: column;
|
|
5918
|
+
align-items: flex-end;
|
|
5919
|
+
gap: 0.125rem;
|
|
5920
|
+
padding: 0;
|
|
5921
|
+
background: transparent;
|
|
5922
|
+
border-radius: 0;
|
|
5923
|
+
box-shadow: none;
|
|
5924
|
+
}
|
|
5925
|
+
`}
|
|
5926
|
+
|
|
5927
|
+
${({ $variant }) => $variant === "pill" && rt`
|
|
5928
|
+
margin-left: auto;
|
|
5929
|
+
margin-right: 1rem;
|
|
5930
|
+
background: #191919;
|
|
5931
|
+
border-radius: 8px;
|
|
5932
|
+
border: 1px solid rgba(255, 255, 255, 0.05);
|
|
5933
|
+
padding: 0.5rem 1rem;
|
|
5934
|
+
gap: 1rem;
|
|
5935
|
+
align-items: center;
|
|
5936
|
+
|
|
5937
|
+
@media (max-width: 600px) {
|
|
5938
|
+
margin: 0;
|
|
5939
|
+
width: 100%;
|
|
5940
|
+
min-width: 0;
|
|
5941
|
+
flex-direction: column;
|
|
5942
|
+
align-items: flex-end;
|
|
5943
|
+
text-align: right;
|
|
5944
|
+
gap: 0.2rem;
|
|
5945
|
+
padding: 0;
|
|
5946
|
+
background: transparent;
|
|
5947
|
+
border-radius: 0;
|
|
5948
|
+
border: none;
|
|
5949
|
+
white-space: normal;
|
|
5950
|
+
}
|
|
5951
|
+
`}
|
|
5952
|
+
|
|
5953
|
+
@media (max-width: 600px) {
|
|
5954
|
+
margin: 0;
|
|
5955
|
+
flex-direction: column;
|
|
5956
|
+
align-items: flex-end;
|
|
5957
|
+
gap: 0.2rem;
|
|
5958
|
+
white-space: normal;
|
|
5959
|
+
}
|
|
5960
|
+
`;
|
|
5961
|
+
var PropertyValueLabel = at.span`
|
|
5962
|
+
font-size: 0.7rem;
|
|
5963
|
+
color: var(--color-text-secondary, rgba(255, 255, 255, 0.6));
|
|
5964
|
+
text-transform: uppercase;
|
|
5965
|
+
letter-spacing: 0.5px;
|
|
5966
|
+
|
|
5967
|
+
@media (max-width: 600px) {
|
|
5968
|
+
font-size: 0.6rem;
|
|
5969
|
+
letter-spacing: 0.4px;
|
|
5970
|
+
}
|
|
5971
|
+
`;
|
|
5972
|
+
var PropertyValueAmount = at.span`
|
|
5973
|
+
font-size: 1.1rem;
|
|
5974
|
+
font-weight: 600;
|
|
5975
|
+
color: #fff;
|
|
5976
|
+
|
|
5977
|
+
@media (max-width: 600px) {
|
|
5978
|
+
font-size: 0.95rem;
|
|
5979
|
+
}
|
|
5980
|
+
`;
|
|
5981
|
+
var PropertyValueChange = at.span`
|
|
5982
|
+
font-size: 0.75rem;
|
|
5983
|
+
font-weight: 500;
|
|
5984
|
+
color: ${(props) => props.$isPositive == null ? "var(--color-text-secondary, rgba(255, 255, 255, 0.6))" : props.$isPositive ? "var(--color-positive, #0ecb81)" : "var(--color-negative, #f6465d)"};
|
|
5985
|
+
|
|
5986
|
+
@media (max-width: 600px) {
|
|
5987
|
+
font-size: 0.65rem;
|
|
5988
|
+
}
|
|
5989
|
+
`;
|
|
5990
|
+
var PriceBlock2 = at.div`
|
|
5991
|
+
display: none;
|
|
5992
|
+
|
|
5993
|
+
${({ $variant }) => $variant === "pill" && rt`
|
|
5994
|
+
@media (max-width: 600px) {
|
|
5995
|
+
display: flex;
|
|
5996
|
+
flex: none;
|
|
5997
|
+
flex-direction: column;
|
|
5998
|
+
align-items: center;
|
|
5999
|
+
justify-content: center;
|
|
6000
|
+
gap: 0.15rem;
|
|
6001
|
+
width: 100%;
|
|
6002
|
+
}
|
|
6003
|
+
`}
|
|
6004
|
+
`;
|
|
6005
|
+
var PriceAmount = at.span`
|
|
6006
|
+
font-size: 1.6rem;
|
|
6007
|
+
font-weight: 600;
|
|
6008
|
+
color: #fff;
|
|
6009
|
+
letter-spacing: 0.2px;
|
|
6010
|
+
`;
|
|
6011
|
+
var PriceChange = at.span`
|
|
6012
|
+
font-size: 0.85rem;
|
|
6013
|
+
font-weight: 500;
|
|
6014
|
+
display: inline-flex;
|
|
6015
|
+
gap: 0.35rem;
|
|
6016
|
+
color: ${(props) => props.$isPositive == null ? "var(--color-text-secondary, rgba(255, 255, 255, 0.6))" : props.$isPositive ? "var(--color-positive, #0ecb81)" : "var(--color-negative, #f6465d)"};
|
|
6017
|
+
`;
|
|
5631
6018
|
|
|
5632
|
-
export { Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, HousePositionSlider, HousePositionSliderMobile, LoafLiquidityBadge, MobileTradeNav, Orderbook, PortfolioSummary, PriceChart, PropertyHeroHeader, PropertyNewsUpdates, PropertySubheader, PropertyTour, TradeConfirmationModal, TradingSlider, YourOrders, badgeVariants, buttonVariants };
|
|
6019
|
+
export { Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, HousePositionSlider, HousePositionSliderMobile, LoafLiquidityBadge, MobileTradeNav, Orderbook, PortfolioSummary, PriceChart, PropertyCompareBar, PropertyHeroHeader, PropertyNewsUpdates, PropertySubheader, PropertyTour, TradeConfirmationModal, TradingSlider, YourOrders, badgeVariants, buttonVariants };
|
|
5633
6020
|
//# sourceMappingURL=index.mjs.map
|
|
5634
6021
|
//# sourceMappingURL=index.mjs.map
|