@thenamespace/ens-components 1.1.2 → 1.1.3

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.ts CHANGED
@@ -194,13 +194,15 @@ interface SubnameMintFormProps {
194
194
  label?: string;
195
195
  isTestnet?: boolean;
196
196
  avatarUploadDomain?: string;
197
+ title?: string;
198
+ subtitle?: string;
197
199
  onCancel?: () => void;
198
200
  onSuccess?: (data: MintSuccessData) => void;
199
201
  onSubnameMinted?: (data: SubnameMintedData) => void;
200
202
  txConfirmations?: number;
201
203
  onConnectWallet?: () => void;
202
204
  }
203
- declare const SubnameMintForm: ({ parentName, label, isTestnet, avatarUploadDomain, onCancel, onSuccess, onSubnameMinted, txConfirmations, onConnectWallet, }: SubnameMintFormProps) => react_jsx_runtime.JSX.Element;
205
+ declare const SubnameMintForm: ({ parentName, label, isTestnet, avatarUploadDomain, title, subtitle, onCancel, onSuccess, onSubnameMinted, txConfirmations, onConnectWallet, }: SubnameMintFormProps) => react_jsx_runtime.JSX.Element;
204
206
 
205
207
  interface OffchainSubnameCreatedData {
206
208
  label: string;
@@ -280,7 +282,7 @@ interface TextProps extends React__default.HTMLAttributes<HTMLSpanElement> {
280
282
  }
281
283
  declare const Text: React__default.FC<TextProps>;
282
284
 
283
- type IconName = "person" | "x" | "search" | "square-user" | "globe" | "pin" | "box" | "book" | "map-pin" | "mail" | "discord" | "github" | "telegram" | "youtube" | "image" | "circle-person" | "twitter" | "circle-alert" | "check-circle" | "check" | "alert-triangle" | "info" | "x-circle" | "rotate-circle" | "logout" | "edit" | "copy" | "clock" | "plus" | "image" | "xSocial" | "chevron-up" | "chevron-down" | "chevron-left";
285
+ type IconName = "person" | "x" | "search" | "square-user" | "globe" | "pin" | "box" | "book" | "map-pin" | "mail" | "discord" | "github" | "telegram" | "youtube" | "image" | "circle-person" | "twitter" | "circle-alert" | "check-circle" | "check" | "alert-triangle" | "info" | "x-circle" | "rotate-circle" | "logout" | "edit" | "copy" | "clock" | "plus" | "image" | "xSocial" | "chevron-up" | "chevron-down" | "chevron-left" | "circle-help";
284
286
  interface IconProps {
285
287
  name: IconName;
286
288
  color?: string;
package/dist/index.js CHANGED
@@ -309,7 +309,7 @@ const createLucideIcon = (iconName, iconNode) => {
309
309
  */
310
310
 
311
311
 
312
- const __iconNode$q = [
312
+ const __iconNode$r = [
313
313
  [
314
314
  "path",
315
315
  {
@@ -318,7 +318,7 @@ const __iconNode$q = [
318
318
  }
319
319
  ]
320
320
  ];
321
- const Book = createLucideIcon("book", __iconNode$q);
321
+ const Book = createLucideIcon("book", __iconNode$r);
322
322
 
323
323
  /**
324
324
  * @license lucide-react v0.563.0 - ISC
@@ -328,7 +328,7 @@ const Book = createLucideIcon("book", __iconNode$q);
328
328
  */
329
329
 
330
330
 
331
- const __iconNode$p = [
331
+ const __iconNode$q = [
332
332
  [
333
333
  "path",
334
334
  {
@@ -339,7 +339,7 @@ const __iconNode$p = [
339
339
  ["path", { d: "m3.3 7 8.7 5 8.7-5", key: "g66t2b" }],
340
340
  ["path", { d: "M12 22V12", key: "d0xqtd" }]
341
341
  ];
342
- const Box = createLucideIcon("box", __iconNode$p);
342
+ const Box = createLucideIcon("box", __iconNode$q);
343
343
 
344
344
  /**
345
345
  * @license lucide-react v0.563.0 - ISC
@@ -349,8 +349,8 @@ const Box = createLucideIcon("box", __iconNode$p);
349
349
  */
350
350
 
351
351
 
352
- const __iconNode$o = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
353
- const Check = createLucideIcon("check", __iconNode$o);
352
+ const __iconNode$p = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
353
+ const Check = createLucideIcon("check", __iconNode$p);
354
354
 
355
355
  /**
356
356
  * @license lucide-react v0.563.0 - ISC
@@ -360,8 +360,8 @@ const Check = createLucideIcon("check", __iconNode$o);
360
360
  */
361
361
 
362
362
 
363
- const __iconNode$n = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
364
- const ChevronDown = createLucideIcon("chevron-down", __iconNode$n);
363
+ const __iconNode$o = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
364
+ const ChevronDown = createLucideIcon("chevron-down", __iconNode$o);
365
365
 
366
366
  /**
367
367
  * @license lucide-react v0.563.0 - ISC
@@ -371,8 +371,8 @@ const ChevronDown = createLucideIcon("chevron-down", __iconNode$n);
371
371
  */
372
372
 
373
373
 
374
- const __iconNode$m = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
375
- const ChevronLeft = createLucideIcon("chevron-left", __iconNode$m);
374
+ const __iconNode$n = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
375
+ const ChevronLeft = createLucideIcon("chevron-left", __iconNode$n);
376
376
 
377
377
  /**
378
378
  * @license lucide-react v0.563.0 - ISC
@@ -382,8 +382,8 @@ const ChevronLeft = createLucideIcon("chevron-left", __iconNode$m);
382
382
  */
383
383
 
384
384
 
385
- const __iconNode$l = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]];
386
- const ChevronUp = createLucideIcon("chevron-up", __iconNode$l);
385
+ const __iconNode$m = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]];
386
+ const ChevronUp = createLucideIcon("chevron-up", __iconNode$m);
387
387
 
388
388
  /**
389
389
  * @license lucide-react v0.563.0 - ISC
@@ -393,12 +393,12 @@ const ChevronUp = createLucideIcon("chevron-up", __iconNode$l);
393
393
  */
394
394
 
395
395
 
396
- const __iconNode$k = [
396
+ const __iconNode$l = [
397
397
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
398
398
  ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
399
399
  ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
400
400
  ];
401
- const CircleAlert = createLucideIcon("circle-alert", __iconNode$k);
401
+ const CircleAlert = createLucideIcon("circle-alert", __iconNode$l);
402
402
 
403
403
  /**
404
404
  * @license lucide-react v0.563.0 - ISC
@@ -408,11 +408,11 @@ const CircleAlert = createLucideIcon("circle-alert", __iconNode$k);
408
408
  */
409
409
 
410
410
 
411
- const __iconNode$j = [
411
+ const __iconNode$k = [
412
412
  ["path", { d: "M21.801 10A10 10 0 1 1 17 3.335", key: "yps3ct" }],
413
413
  ["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }]
414
414
  ];
415
- const CircleCheckBig = createLucideIcon("circle-check-big", __iconNode$j);
415
+ const CircleCheckBig = createLucideIcon("circle-check-big", __iconNode$k);
416
416
 
417
417
  /**
418
418
  * @license lucide-react v0.563.0 - ISC
@@ -422,7 +422,7 @@ const CircleCheckBig = createLucideIcon("circle-check-big", __iconNode$j);
422
422
  */
423
423
 
424
424
 
425
- const __iconNode$i = [
425
+ const __iconNode$j = [
426
426
  ["path", { d: "M12 2a10 10 0 0 1 7.38 16.75", key: "175t95" }],
427
427
  ["path", { d: "M12 8v8", key: "napkw2" }],
428
428
  ["path", { d: "M16 12H8", key: "1fr5h0" }],
@@ -431,7 +431,22 @@ const __iconNode$i = [
431
431
  ["path", { d: "M4.636 5.235a10 10 0 0 1 .891-.857", key: "1szpfk" }],
432
432
  ["path", { d: "M8.644 21.42a10 10 0 0 0 7.631-.38", key: "9yhvd4" }]
433
433
  ];
434
- const CircleFadingPlus = createLucideIcon("circle-fading-plus", __iconNode$i);
434
+ const CircleFadingPlus = createLucideIcon("circle-fading-plus", __iconNode$j);
435
+
436
+ /**
437
+ * @license lucide-react v0.563.0 - ISC
438
+ *
439
+ * This source code is licensed under the ISC license.
440
+ * See the LICENSE file in the root directory of this source tree.
441
+ */
442
+
443
+
444
+ const __iconNode$i = [
445
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
446
+ ["path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3", key: "1u773s" }],
447
+ ["path", { d: "M12 17h.01", key: "p32p05" }]
448
+ ];
449
+ const CircleQuestionMark = createLucideIcon("circle-question-mark", __iconNode$i);
435
450
 
436
451
  /**
437
452
  * @license lucide-react v0.563.0 - ISC
@@ -864,7 +879,8 @@ const icons$1 = {
864
879
  xSocial: XIcon,
865
880
  "chevron-up": ChevronUp,
866
881
  "chevron-down": ChevronDown,
867
- "chevron-left": ChevronLeft
882
+ "chevron-left": ChevronLeft,
883
+ "circle-help": CircleQuestionMark
868
884
  };
869
885
  const Icon = ({
870
886
  name,
@@ -11882,6 +11898,8 @@ const PricingDisplay = ({
11882
11898
  ] });
11883
11899
  };
11884
11900
 
11901
+ const SUPPORTED_KEY_SET = new Set(supportedTexts.map((t) => t.key));
11902
+ const genDraftId = () => `${Date.now()}-${Math.random()}`;
11885
11903
  const TextRecords = ({
11886
11904
  texts,
11887
11905
  onTextsChanged,
@@ -11899,7 +11917,64 @@ const TextRecords = ({
11899
11917
  return map;
11900
11918
  }, [texts]);
11901
11919
  const [lastAddedKey, setLastAddedKey] = useState(null);
11920
+ const [customDrafts, setCustomDrafts] = useState([]);
11902
11921
  const inputRefs = useRef({});
11922
+ const draftKeys = useMemo(
11923
+ () => new Set(customDrafts.map((d) => d.key).filter(Boolean)),
11924
+ [customDrafts]
11925
+ );
11926
+ const committedCustomTexts = useMemo(
11927
+ () => texts.filter((t) => !SUPPORTED_KEY_SET.has(t.key) && !draftKeys.has(t.key)),
11928
+ [texts, draftKeys]
11929
+ );
11930
+ const isValidDraftKey = (key, draftId) => {
11931
+ if (!key.trim()) return false;
11932
+ if (SUPPORTED_KEY_SET.has(key)) return false;
11933
+ if (committedCustomTexts.some((t) => t.key === key)) return false;
11934
+ if (customDrafts.some((d) => d.id !== draftId && d.key === key)) return false;
11935
+ return true;
11936
+ };
11937
+ const handleAddCustomDraft = () => {
11938
+ setCustomDrafts((prev) => [...prev, { id: genDraftId(), key: "", value: "" }]);
11939
+ };
11940
+ const handleCustomDraftKeyChange = (draftId, newKey) => {
11941
+ const draft = customDrafts.find((d) => d.id === draftId);
11942
+ const oldKey = draft.key;
11943
+ const updatedDrafts = customDrafts.map(
11944
+ (d) => d.id === draftId ? { ...d, key: newKey } : d
11945
+ );
11946
+ setCustomDrafts(updatedDrafts);
11947
+ let newTexts = oldKey ? texts.filter((t) => t.key !== oldKey) : [...texts];
11948
+ const isValid = newKey.trim() && !SUPPORTED_KEY_SET.has(newKey) && !newTexts.filter((t) => !SUPPORTED_KEY_SET.has(t.key)).some((t) => t.key === newKey) && updatedDrafts.filter((d) => d.id !== draftId).every((d) => d.key !== newKey);
11949
+ if (isValid) {
11950
+ newTexts = [...newTexts, { key: newKey, value: draft.value }];
11951
+ }
11952
+ onTextsChanged(newTexts);
11953
+ };
11954
+ const handleCustomDraftValueChange = (draftId, newValue) => {
11955
+ const draft = customDrafts.find((d) => d.id === draftId);
11956
+ setCustomDrafts(
11957
+ (prev) => prev.map((d) => d.id === draftId ? { ...d, value: newValue } : d)
11958
+ );
11959
+ if (draft.key && texts.some((t) => t.key === draft.key)) {
11960
+ onTextsChanged(
11961
+ texts.map((t) => t.key === draft.key ? { ...t, value: newValue } : t)
11962
+ );
11963
+ }
11964
+ };
11965
+ const handleRemoveCustomDraft = (draftId) => {
11966
+ const draft = customDrafts.find((d) => d.id === draftId);
11967
+ setCustomDrafts((prev) => prev.filter((d) => d.id !== draftId));
11968
+ if (draft.key && texts.some((t) => t.key === draft.key)) {
11969
+ onTextsChanged(texts.filter((t) => t.key !== draft.key));
11970
+ }
11971
+ };
11972
+ const handleCommittedCustomValueChange = (key, value) => {
11973
+ onTextsChanged(texts.map((t) => t.key === key ? { ...t, value } : t));
11974
+ };
11975
+ const handleRemoveCommittedCustom = (key) => {
11976
+ onTextsChanged(texts.filter((t) => t.key !== key));
11977
+ };
11903
11978
  useEffect(() => {
11904
11979
  if (lastAddedKey && inputRefs.current[lastAddedKey]) {
11905
11980
  inputRefs.current[lastAddedKey]?.scrollIntoView({
@@ -11966,7 +12041,9 @@ const TextRecords = ({
11966
12041
  (record) => filterSuggestions(record) && shownTextCategory.includes(record.category)
11967
12042
  );
11968
12043
  }, [searchFilter]);
11969
- if (filteredItems.length === 0) {
12044
+ const isGeneralCategory = category === TextRecordCategory.General;
12045
+ const hasCustomContent = isGeneralCategory && (committedCustomTexts.length > 0 || customDrafts.length > 0);
12046
+ if (filteredItems.length === 0 && !hasCustomContent) {
11970
12047
  return /* @__PURE__ */ jsx(Fragment, {});
11971
12048
  }
11972
12049
  return /* @__PURE__ */ jsxs("div", { className: "ns-text-records", children: [
@@ -12032,19 +12109,92 @@ const TextRecords = ({
12032
12109
  )
12033
12110
  ] }, record.key);
12034
12111
  }),
12035
- /* @__PURE__ */ jsx("div", { className: "row g-2", children: filteredItems.filter(
12036
- (record) => existingTextsMap[record.key] === void 0 && record.category !== TextRecordCategory.Image && filterSuggestions(record)
12037
- ).map((record) => /* @__PURE__ */ jsx("div", { className: "col col-lg-3 col-sm-6 col-6", children: /* @__PURE__ */ jsxs(
12038
- "div",
12039
- {
12040
- className: "ns-text-suggestion",
12041
- onClick: () => handleTextAdded(record.key),
12042
- children: [
12043
- /* @__PURE__ */ jsx(Icon, { size: 18, color: "grey", name: record.icon }),
12044
- /* @__PURE__ */ jsx(Text, { className: "ns-mt-1", size: "xs", weight: "medium", children: record.label })
12045
- ]
12046
- }
12047
- ) }, record.key)) })
12112
+ isGeneralCategory && committedCustomTexts.map((custom) => /* @__PURE__ */ jsxs("div", { style: { marginBottom: 10 }, children: [
12113
+ /* @__PURE__ */ jsx(
12114
+ Text,
12115
+ {
12116
+ style: { marginBottom: "4px" },
12117
+ color: "grey",
12118
+ size: "xs",
12119
+ weight: "medium",
12120
+ children: custom.key
12121
+ }
12122
+ ),
12123
+ /* @__PURE__ */ jsxs("div", { style: { width: "100%" }, className: "d-flex align-items-center", children: [
12124
+ /* @__PURE__ */ jsx(
12125
+ Input,
12126
+ {
12127
+ style: { width: "100%" },
12128
+ onChange: (e) => handleCommittedCustomValueChange(custom.key, e.target.value),
12129
+ prefix: /* @__PURE__ */ jsx(Icon, { name: "edit", size: 18, color: "grey" }),
12130
+ value: custom.value,
12131
+ placeholder: "Value"
12132
+ }
12133
+ ),
12134
+ /* @__PURE__ */ jsx(
12135
+ "div",
12136
+ {
12137
+ onClick: () => handleRemoveCommittedCustom(custom.key),
12138
+ className: "ns-close-icon ns-ms-1",
12139
+ children: /* @__PURE__ */ jsx(Icon, { name: "x", size: 18 })
12140
+ }
12141
+ )
12142
+ ] })
12143
+ ] }, custom.key)),
12144
+ isGeneralCategory && customDrafts.map((draft) => {
12145
+ const keyIsInvalid = draft.key.trim().length > 0 && !isValidDraftKey(draft.key, draft.id);
12146
+ return /* @__PURE__ */ jsxs("div", { style: { marginBottom: 10 }, children: [
12147
+ /* @__PURE__ */ jsxs("div", { className: "d-flex align-items-center", style: { gap: 6 }, children: [
12148
+ /* @__PURE__ */ jsx(
12149
+ Input,
12150
+ {
12151
+ style: { flex: 1 },
12152
+ value: draft.key,
12153
+ onChange: (e) => handleCustomDraftKeyChange(draft.id, e.target.value),
12154
+ placeholder: "Key (e.g. custom.record)",
12155
+ error: keyIsInvalid
12156
+ }
12157
+ ),
12158
+ /* @__PURE__ */ jsx(
12159
+ Input,
12160
+ {
12161
+ style: { flex: 1 },
12162
+ value: draft.value,
12163
+ onChange: (e) => handleCustomDraftValueChange(draft.id, e.target.value),
12164
+ placeholder: "Value"
12165
+ }
12166
+ ),
12167
+ /* @__PURE__ */ jsx(
12168
+ "div",
12169
+ {
12170
+ onClick: () => handleRemoveCustomDraft(draft.id),
12171
+ className: "ns-close-icon",
12172
+ children: /* @__PURE__ */ jsx(Icon, { name: "x", size: 18 })
12173
+ }
12174
+ )
12175
+ ] }),
12176
+ keyIsInvalid && /* @__PURE__ */ jsx(Text, { size: "xs", color: "grey", style: { marginTop: 4 }, children: "Key is reserved or already in use" })
12177
+ ] }, draft.id);
12178
+ }),
12179
+ /* @__PURE__ */ jsxs("div", { className: "row g-2", children: [
12180
+ filteredItems.filter(
12181
+ (record) => existingTextsMap[record.key] === void 0 && record.category !== TextRecordCategory.Image && filterSuggestions(record)
12182
+ ).map((record) => /* @__PURE__ */ jsx("div", { className: "col col-lg-3 col-sm-6 col-6", children: /* @__PURE__ */ jsxs(
12183
+ "div",
12184
+ {
12185
+ className: "ns-text-suggestion",
12186
+ onClick: () => handleTextAdded(record.key),
12187
+ children: [
12188
+ /* @__PURE__ */ jsx(Icon, { size: 18, color: "grey", name: record.icon }),
12189
+ /* @__PURE__ */ jsx(Text, { className: "ns-mt-1", size: "xs", weight: "medium", children: record.label })
12190
+ ]
12191
+ }
12192
+ ) }, record.key)),
12193
+ isGeneralCategory && /* @__PURE__ */ jsx("div", { className: "col col-lg-3 col-sm-6 col-6", children: /* @__PURE__ */ jsxs("div", { className: "ns-text-suggestion", onClick: handleAddCustomDraft, children: [
12194
+ /* @__PURE__ */ jsx(Icon, { size: 18, color: "grey", name: "circle-help" }),
12195
+ /* @__PURE__ */ jsx(Text, { className: "ns-mt-1", size: "xs", weight: "medium", children: "Custom" })
12196
+ ] }) })
12197
+ ] })
12048
12198
  ] });
12049
12199
  };
12050
12200
 
@@ -92207,6 +92357,8 @@ const SubnameMintForm = ({
92207
92357
  label,
92208
92358
  isTestnet,
92209
92359
  avatarUploadDomain,
92360
+ title,
92361
+ subtitle,
92210
92362
  onCancel,
92211
92363
  onSuccess,
92212
92364
  onSubnameMinted,
@@ -92277,6 +92429,8 @@ const SubnameMintForm = ({
92277
92429
  isL2: initState.isL2,
92278
92430
  isExpirable: initState.isExpirable || false,
92279
92431
  avatarUploadDomain,
92432
+ title,
92433
+ subtitle,
92280
92434
  onCancel,
92281
92435
  onSuccess,
92282
92436
  onSubnameMinted,
@@ -92300,6 +92454,8 @@ const SubnameMintFormContent = ({
92300
92454
  isL2,
92301
92455
  isExpirable = false,
92302
92456
  avatarUploadDomain,
92457
+ title,
92458
+ subtitle,
92303
92459
  onCancel,
92304
92460
  onSuccess,
92305
92461
  onSubnameMinted,
@@ -92733,7 +92889,10 @@ const SubnameMintFormContent = ({
92733
92889
  );
92734
92890
  }
92735
92891
  return /* @__PURE__ */ jsxs("div", { style: { padding: 15 }, children: [
92736
- /* @__PURE__ */ jsx(Text, { className: "ns-text-center", weight: "bold", children: "Get Your Web3 Username" }),
92892
+ /* @__PURE__ */ jsxs("div", { className: "ns-text-center mb-3", children: [
92893
+ /* @__PURE__ */ jsx(Text, { weight: "bold", size: "lg", children: title || "Get Your Web3 Username" }),
92894
+ subtitle && /* @__PURE__ */ jsx(Text, { color: "grey", size: "sm", className: "mt-1", children: subtitle })
92895
+ ] }),
92737
92896
  /* @__PURE__ */ jsx("div", { className: "mt-3", children: /* @__PURE__ */ jsx(
92738
92897
  NameAvailabilityInput,
92739
92898
  {
@@ -92826,13 +92985,13 @@ const SuccessScreen = ({ fullSubname, isUpdateMode, onContinue }) => {
92826
92985
  const FormHeader = ({ isUpdateMode, label, parentName, showFullName, title, subtitle }) => {
92827
92986
  const defaultTitle = isUpdateMode ? "Update subname" : "Create subname";
92828
92987
  return /* @__PURE__ */ jsxs("div", { className: "ns-text-center mb-3", children: [
92829
- /* @__PURE__ */ jsx(Text, { size: "sm", color: "grey", className: "mb-1", children: title ?? defaultTitle }),
92988
+ /* @__PURE__ */ jsx(Text, { size: "lg", weight: "bold", className: "mb-1", children: title ?? defaultTitle }),
92830
92989
  showFullName && /* @__PURE__ */ jsxs(Text, { size: "lg", weight: "bold", children: [
92831
92990
  label,
92832
92991
  ".",
92833
92992
  parentName
92834
92993
  ] }),
92835
- subtitle && /* @__PURE__ */ jsx(Text, { size: "xs", color: "grey", className: "mt-1", children: subtitle })
92994
+ subtitle && /* @__PURE__ */ jsx(Text, { size: "sm", color: "grey", className: "mt-1", children: subtitle })
92836
92995
  ] });
92837
92996
  };
92838
92997