@fairmint/ui 0.2.3 → 0.2.4
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/components/form/EthereumAddressField/EthereumAddressField.d.ts +13 -0
- package/dist/components/form/EthereumAddressField/EthereumAddressField.d.ts.map +1 -0
- package/dist/components/generic/EditableSection/EditableSection.d.ts +43 -0
- package/dist/components/generic/EditableSection/EditableSection.d.ts.map +1 -0
- package/dist/fairmint-ui.cjs +112 -17
- package/dist/fairmint-ui.cjs.map +1 -1
- package/dist/fairmint-ui.js +112 -17
- package/dist/fairmint-ui.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/fairmint-ui.js
CHANGED
|
@@ -23733,6 +23733,46 @@ function EmailField({ error: error2, ...rest }) {
|
|
|
23733
23733
|
}
|
|
23734
23734
|
);
|
|
23735
23735
|
}
|
|
23736
|
+
function truncateAddress(address, chars = 4) {
|
|
23737
|
+
if (address.length <= chars * 2 + 2) return address;
|
|
23738
|
+
return `${address.slice(0, chars + 2)}...${address.slice(-chars)}`;
|
|
23739
|
+
}
|
|
23740
|
+
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
23741
|
+
const ETH_ADDRESS_RE = /^0x[a-fA-F0-9]{40}$/;
|
|
23742
|
+
function isEthereumAddress(value) {
|
|
23743
|
+
return ETH_ADDRESS_RE.test(value) && value.toLowerCase() !== ZERO_ADDRESS;
|
|
23744
|
+
}
|
|
23745
|
+
function validateEthereumAddress(value) {
|
|
23746
|
+
if (!ETH_ADDRESS_RE.test(value))
|
|
23747
|
+
return "Must be a valid Ethereum address (0x + 40 hex characters)";
|
|
23748
|
+
if (value.toLowerCase() === ZERO_ADDRESS) return "Cannot use the zero address";
|
|
23749
|
+
return null;
|
|
23750
|
+
}
|
|
23751
|
+
const ETHEREUM_ADDRESS_REGEX = ETH_ADDRESS_RE;
|
|
23752
|
+
const ZERO_ETHEREUM_ADDRESS = ZERO_ADDRESS;
|
|
23753
|
+
const ethereumAddressSchema = stringType().trim().regex(
|
|
23754
|
+
ETHEREUM_ADDRESS_REGEX,
|
|
23755
|
+
"Must be a valid Ethereum address (0x followed by 40 hex characters)"
|
|
23756
|
+
).refine(
|
|
23757
|
+
(v) => v.toLowerCase() !== ZERO_ETHEREUM_ADDRESS.toLowerCase(),
|
|
23758
|
+
"Cannot use the zero address"
|
|
23759
|
+
);
|
|
23760
|
+
function EthereumAddressField({ error: error2, ...rest }) {
|
|
23761
|
+
return /* @__PURE__ */ jsx(
|
|
23762
|
+
TextInput,
|
|
23763
|
+
{
|
|
23764
|
+
type: "text",
|
|
23765
|
+
label: rest.label ?? "Wallet Address",
|
|
23766
|
+
placeholder: rest.placeholder ?? "0x...",
|
|
23767
|
+
autoComplete: "off",
|
|
23768
|
+
inputMode: "text",
|
|
23769
|
+
spellCheck: false,
|
|
23770
|
+
styles: { input: { fontFamily: "monospace" } },
|
|
23771
|
+
error: error2,
|
|
23772
|
+
...rest
|
|
23773
|
+
}
|
|
23774
|
+
);
|
|
23775
|
+
}
|
|
23736
23776
|
function validateFormName(name) {
|
|
23737
23777
|
if (!/^[0-9a-zA-Z-]+$/.test(name)) {
|
|
23738
23778
|
throw new Error(
|
|
@@ -25077,6 +25117,75 @@ function DetailDrawer({
|
|
|
25077
25117
|
}
|
|
25078
25118
|
);
|
|
25079
25119
|
}
|
|
25120
|
+
function EditableSection({
|
|
25121
|
+
title,
|
|
25122
|
+
readView,
|
|
25123
|
+
onSave,
|
|
25124
|
+
onCancel,
|
|
25125
|
+
disabled = false,
|
|
25126
|
+
onSaveError,
|
|
25127
|
+
editIcon,
|
|
25128
|
+
saveLabel = "Save",
|
|
25129
|
+
cancelLabel = "Cancel",
|
|
25130
|
+
children
|
|
25131
|
+
}) {
|
|
25132
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
25133
|
+
const [isSaving, setIsSaving] = useState(false);
|
|
25134
|
+
useEffect(() => {
|
|
25135
|
+
if (disabled && isEditing) {
|
|
25136
|
+
onCancel?.();
|
|
25137
|
+
setIsEditing(false);
|
|
25138
|
+
}
|
|
25139
|
+
}, [disabled, isEditing, onCancel]);
|
|
25140
|
+
const handleEdit = () => setIsEditing(true);
|
|
25141
|
+
const handleSave = async () => {
|
|
25142
|
+
setIsSaving(true);
|
|
25143
|
+
try {
|
|
25144
|
+
await onSave();
|
|
25145
|
+
setIsEditing(false);
|
|
25146
|
+
} catch (err) {
|
|
25147
|
+
onSaveError?.(err);
|
|
25148
|
+
} finally {
|
|
25149
|
+
setIsSaving(false);
|
|
25150
|
+
}
|
|
25151
|
+
};
|
|
25152
|
+
const handleCancel = () => {
|
|
25153
|
+
onCancel?.();
|
|
25154
|
+
setIsEditing(false);
|
|
25155
|
+
};
|
|
25156
|
+
return /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
|
|
25157
|
+
(title || !disabled && !isEditing) && /* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "center", children: [
|
|
25158
|
+
title && /* @__PURE__ */ jsx(Text, { fw: 500, size: "sm", children: title }),
|
|
25159
|
+
!disabled && !isEditing && (editIcon ? /* @__PURE__ */ jsx(
|
|
25160
|
+
ActionIcon,
|
|
25161
|
+
{
|
|
25162
|
+
variant: "subtle",
|
|
25163
|
+
size: "sm",
|
|
25164
|
+
onClick: handleEdit,
|
|
25165
|
+
"aria-label": `Edit ${typeof title === "string" ? title : "section"}`,
|
|
25166
|
+
children: editIcon
|
|
25167
|
+
}
|
|
25168
|
+
) : /* @__PURE__ */ jsx(Button, { variant: "subtle", size: "xs", onClick: handleEdit, children: "Edit" }))
|
|
25169
|
+
] }),
|
|
25170
|
+
isEditing ? /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
|
|
25171
|
+
children,
|
|
25172
|
+
/* @__PURE__ */ jsxs(Group, { gap: "xs", justify: "flex-end", children: [
|
|
25173
|
+
/* @__PURE__ */ jsx(
|
|
25174
|
+
Button,
|
|
25175
|
+
{
|
|
25176
|
+
variant: "subtle",
|
|
25177
|
+
size: "xs",
|
|
25178
|
+
color: colors.neutral,
|
|
25179
|
+
onClick: handleCancel,
|
|
25180
|
+
disabled: isSaving,
|
|
25181
|
+
children: cancelLabel
|
|
25182
|
+
}
|
|
25183
|
+
),
|
|
25184
|
+
/* @__PURE__ */ jsx(Button, { size: "xs", onClick: handleSave, loading: isSaving, children: saveLabel })
|
|
25185
|
+
] })
|
|
25186
|
+
] }) : readView
|
|
25187
|
+
] });
|
|
25188
|
+
}
|
|
25080
25189
|
const DefaultChevronIcon = () => /* @__PURE__ */ jsx(
|
|
25081
25190
|
"svg",
|
|
25082
25191
|
{
|
|
@@ -25538,23 +25647,6 @@ function InvestorProfileCard({
|
|
|
25538
25647
|
children
|
|
25539
25648
|
] });
|
|
25540
25649
|
}
|
|
25541
|
-
function truncateAddress(address, chars = 4) {
|
|
25542
|
-
if (address.length <= chars * 2 + 2) return address;
|
|
25543
|
-
return `${address.slice(0, chars + 2)}...${address.slice(-chars)}`;
|
|
25544
|
-
}
|
|
25545
|
-
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
25546
|
-
const ETH_ADDRESS_RE = /^0x[a-fA-F0-9]{40}$/;
|
|
25547
|
-
function isEthereumAddress(value) {
|
|
25548
|
-
return ETH_ADDRESS_RE.test(value) && value.toLowerCase() !== ZERO_ADDRESS;
|
|
25549
|
-
}
|
|
25550
|
-
function validateEthereumAddress(value) {
|
|
25551
|
-
if (!ETH_ADDRESS_RE.test(value))
|
|
25552
|
-
return "Must be a valid Ethereum address (0x + 40 hex characters)";
|
|
25553
|
-
if (value.toLowerCase() === ZERO_ADDRESS) return "Cannot use the zero address";
|
|
25554
|
-
return null;
|
|
25555
|
-
}
|
|
25556
|
-
const ETHEREUM_ADDRESS_REGEX = ETH_ADDRESS_RE;
|
|
25557
|
-
const ZERO_ETHEREUM_ADDRESS = ZERO_ADDRESS;
|
|
25558
25650
|
const DEFAULT_TYPE_LABELS = {
|
|
25559
25651
|
fairmint: "Fairmint Wallet",
|
|
25560
25652
|
privy: "Fairmint Wallet",
|
|
@@ -25799,10 +25891,12 @@ export {
|
|
|
25799
25891
|
DocumentRow,
|
|
25800
25892
|
Drawer,
|
|
25801
25893
|
ETHEREUM_ADDRESS_REGEX,
|
|
25894
|
+
EditableSection,
|
|
25802
25895
|
EmailField,
|
|
25803
25896
|
EmptyState,
|
|
25804
25897
|
EquityGrantCard,
|
|
25805
25898
|
ErrorFallback,
|
|
25899
|
+
EthereumAddressField,
|
|
25806
25900
|
FairmintLogo,
|
|
25807
25901
|
FairmintProvider,
|
|
25808
25902
|
Flex,
|
|
@@ -25849,6 +25943,7 @@ export {
|
|
|
25849
25943
|
colors,
|
|
25850
25944
|
createZipSchema,
|
|
25851
25945
|
emailSchema,
|
|
25946
|
+
ethereumAddressSchema,
|
|
25852
25947
|
formatCurrency,
|
|
25853
25948
|
formatCurrencyPrecise,
|
|
25854
25949
|
formatDate,
|