@lukso/transaction-view-core 0.5.0-dev.5916302 → 0.5.0-dev.a98e9bc

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.cts CHANGED
@@ -133,6 +133,7 @@ declare class AssetCard extends CoreLitElement {
133
133
  standard: string | undefined;
134
134
  /** Function icon name */
135
135
  functionIcon: string;
136
+ size: 'small' | 'medium' | 'large';
136
137
  showInfoButton: boolean;
137
138
  showCreator: boolean;
138
139
  private displayDetails;
@@ -154,7 +155,6 @@ declare class AssetCard extends CoreLitElement {
154
155
  private _renderAssets;
155
156
  private _renderStandards;
156
157
  private _renderTokenDetails;
157
- private _formattedAmount;
158
158
  private renderFormattedTokenIdBadge;
159
159
  render(): lit.TemplateResult<1>;
160
160
  }
package/dist/index.d.ts CHANGED
@@ -133,6 +133,7 @@ declare class AssetCard extends CoreLitElement {
133
133
  standard: string | undefined;
134
134
  /** Function icon name */
135
135
  functionIcon: string;
136
+ size: 'small' | 'medium' | 'large';
136
137
  showInfoButton: boolean;
137
138
  showCreator: boolean;
138
139
  private displayDetails;
@@ -154,7 +155,6 @@ declare class AssetCard extends CoreLitElement {
154
155
  private _renderAssets;
155
156
  private _renderStandards;
156
157
  private _renderTokenDetails;
157
- private _formattedAmount;
158
158
  private renderFormattedTokenIdBadge;
159
159
  render(): lit.TemplateResult<1>;
160
160
  }
package/dist/index.js CHANGED
@@ -1995,8 +1995,6 @@ import { useAddressResolver as useAddressResolver4 } from "@lukso/transaction-vi
1995
1995
  import { html as html11 } from "lit";
1996
1996
  import { property as property11, state as state4 } from "lit/decorators.js";
1997
1997
  import { when } from "lit/directives/when.js";
1998
-
1999
- // src/utils.ts
2000
1998
  function formatUnits(value, decimals = 18) {
2001
1999
  const divisor = 10n ** BigInt(decimals);
2002
2000
  const quotient = value / divisor;
@@ -2008,30 +2006,6 @@ function formatUnits(value, decimals = 18) {
2008
2006
  const trimmed = remainderStr.replace(/0+$/, "");
2009
2007
  return `${quotient}.${trimmed}`;
2010
2008
  }
2011
- function isBigIntString(str) {
2012
- const trimmed = str.trim();
2013
- if (trimmed.endsWith("n"))
2014
- return /^[0-9]+n$/.test(trimmed) || /^0x[0-9a-fA-F]+n$/.test(trimmed);
2015
- return /^[0-9]+$/.test(trimmed) || /^0x[0-9a-fA-F]+$/.test(trimmed);
2016
- }
2017
- function parseBigInt(value) {
2018
- if (!value) return void 0;
2019
- if (typeof value === "bigint") return value;
2020
- if (typeof value === "number") {
2021
- if (!Number.isInteger(value)) return void 0;
2022
- return BigInt(value);
2023
- }
2024
- const trimmed = value.trim();
2025
- const cleaned = trimmed.endsWith("n") ? trimmed.slice(0, -1) : trimmed;
2026
- if (!isBigIntString(cleaned)) return void 0;
2027
- try {
2028
- return BigInt(cleaned);
2029
- } catch {
2030
- return void 0;
2031
- }
2032
- }
2033
-
2034
- // src/shared/value-view.ts
2035
2009
  var ValueView = class extends CoreLitElement {
2036
2010
  constructor() {
2037
2011
  super(...arguments);
@@ -2264,7 +2238,7 @@ var ValueView = class extends CoreLitElement {
2264
2238
  `;
2265
2239
  if (effectiveType === "currency") {
2266
2240
  const { numeric, symbol } = this.getCurrencyParts();
2267
- if (this.label) {
2241
+ if (this.label && this.label.trim() !== "") {
2268
2242
  headerText = this.label;
2269
2243
  contentTemplate = html11`
2270
2244
  <span class="inline-block overflow-hidden text-ellipsis whitespace-nowrap min-w-0 ${this.getNumericClass()}">${numeric}</span>
@@ -2975,10 +2949,22 @@ import { Task as Task6 } from "@lit/task";
2975
2949
  import {
2976
2950
  useAddressResolver as useAddressResolver6
2977
2951
  } from "@lukso/transaction-view-headless";
2952
+ function formatUnits2(value, decimals = 18) {
2953
+ const divisor = 10n ** BigInt(decimals);
2954
+ const quotient = value / divisor;
2955
+ const remainder = value % divisor;
2956
+ if (remainder === 0n) {
2957
+ return quotient.toString();
2958
+ }
2959
+ const remainderStr = remainder.toString().padStart(decimals, "0");
2960
+ const trimmed = remainderStr.replace(/0+$/, "");
2961
+ return `${quotient}.${trimmed}`;
2962
+ }
2978
2963
  var AssetCard = class extends CoreLitElement {
2979
2964
  constructor() {
2980
2965
  super(...arguments);
2981
2966
  this.functionIcon = "code-outline";
2967
+ this.size = "medium";
2982
2968
  this.showInfoButton = true;
2983
2969
  this.showCreator = true;
2984
2970
  this.displayDetails = false;
@@ -3105,7 +3091,7 @@ var AssetCard = class extends CoreLitElement {
3105
3091
  const formattedTokenId = this._resolvedData?.formattedTokenId;
3106
3092
  const displayTokenId = formattedTokenId ? `${formattedTokenId}` : "";
3107
3093
  if (displayTokenId) return displayTokenId;
3108
- return this.tokenId ? `${parseInt(this.tokenId, 16)}` : void 0;
3094
+ return this.tokenId && !this._resolvedData?.isCollection ? `${parseInt(this.tokenId, 16)}` : void 0;
3109
3095
  }
3110
3096
  _renderTokenId() {
3111
3097
  const displayTokenId = this.displayedTokenId;
@@ -3163,7 +3149,6 @@ var AssetCard = class extends CoreLitElement {
3163
3149
  _renderImages() {
3164
3150
  const images = this._resolvedData?.images || [];
3165
3151
  if (images.length === 0) return "";
3166
- if (!this.address) return "";
3167
3152
  return html14`
3168
3153
  <image-list
3169
3154
  address=${this.address}
@@ -3176,7 +3161,6 @@ var AssetCard = class extends CoreLitElement {
3176
3161
  _renderAssets() {
3177
3162
  const assets = this._resolvedData?.assets || [];
3178
3163
  if (assets.length === 0) return "";
3179
- if (!this.address) return "";
3180
3164
  return html14`
3181
3165
  <div class="section">
3182
3166
  <div class="section-title">Assets</div>
@@ -3192,11 +3176,11 @@ var AssetCard = class extends CoreLitElement {
3192
3176
  return html14`
3193
3177
  <div class="flex justify-between items-center my-4">
3194
3178
  <function-name-view
3195
- label=${this.functionName || "Execute"}
3196
- size="small"
3197
- icon=${this.functionIcon ? this.functionIcon : "code-outline"}
3179
+ label=${this.functionName}
3180
+ size="small"
3181
+ icon=${this.functionIcon ? this.functionIcon : "code-outline"}
3198
3182
  ></function-name-view>
3199
- <function-name-view label=${this._resolvedData?.standard ?? "Unknown"} size="small"></function-name-view>
3183
+ <function-name-view label=${this._resolvedData?.standard} size="small"></function-name-view>
3200
3184
  </div>
3201
3185
  `;
3202
3186
  }
@@ -3215,14 +3199,6 @@ var AssetCard = class extends CoreLitElement {
3215
3199
  </div>
3216
3200
  `;
3217
3201
  }
3218
- _formattedAmount() {
3219
- const data = this._resolutionTask.value;
3220
- const amt = this.amount;
3221
- if (amt === void 0 || amt === null || amt === "") return void 0;
3222
- const bigintAmount = parseBigInt(amt);
3223
- if (bigintAmount === void 0) return void 0;
3224
- return formatUnits(bigintAmount, data?.decimals);
3225
- }
3226
3202
  renderFormattedTokenIdBadge() {
3227
3203
  if (!this.displayedTokenId) return "";
3228
3204
  return html14`
@@ -3233,61 +3209,51 @@ var AssetCard = class extends CoreLitElement {
3233
3209
  return html14`
3234
3210
  <div >
3235
3211
  ${this._renderStandards()}
3236
- <div class="mt-6 flex-col">
3237
- <div class="flex items-center justify-center gap-4">
3238
- <div class="flex justify-end w-[48%]">
3239
- <div class="border relative border-neutral-90 rounded-xl">
3240
- ${this.renderFormattedTokenIdBadge()}
3241
- <div class="p-2 relative">
3242
- ${when3(
3243
- this.address,
3244
- () => html14`
3245
- <icon-view
3246
- address=${this.address ?? ""}
3247
- size="2x-large"
3248
- .showName=${false}
3249
- ></icon-view>
3250
- `
3251
- )}
3252
- </div>
3253
- <div style="height: 1px;" class="bg-neutral-90 w-full"></div>
3254
- <div class="px-2">
3255
- ${this._renderAddressSection()}
3256
- </div>
3212
+ <div class="mt-6 flex-col">
3213
+ <div class="flex items-center justify-center gap-4">
3214
+ <div class="flex justify-end w-[48%]">
3215
+ <div class="border relative border-neutral-90 rounded-xl">
3216
+ ${this.renderFormattedTokenIdBadge()}
3217
+ <div class="p-2 relative">
3218
+ <icon-view
3219
+ address="${this.address}"
3220
+ size="2x-large"
3221
+ .showName=${false}
3222
+ ></icon-view>
3223
+ </div>
3224
+ <div style="height: 1px;" class="bg-neutral-90 w-full"></div>
3225
+ <div class="px-2">
3226
+ ${this._renderAddressSection()}
3257
3227
  </div>
3258
3228
  </div>
3229
+ </div>
3259
3230
 
3260
- <div class="flex flex-col gap-1 w-[51%]">
3261
- <div class="text-[14px] font-bold text-neutral-20">
3262
- ${this._resolvedData?.lsp4TokenName || "UNKNOWN"}
3263
- </div>
3264
- <div class="text-[17px] font-semibold text-neutral-20">
3265
- ${when3(
3266
- this.amount,
3267
- () => html14`
3268
- <span class="">${this._formattedAmount() ?? ""}</span>
3269
- <span class="ml-1 text-neutral-60 max-w-[60px] whitespace-nowrap overflow-hidden text-ellipsis text-[14px] font-semibold">${this._resolvedData?.lsp4TokenSymbol || ""}</span>
3270
- `,
3271
- () => html14`${this._resolvedData?.lsp4TokenSymbol || ""}`
3272
- )}
3273
- </div>
3274
-
3231
+ <div class="flex flex-col gap-1 w-[51%]">
3232
+ <div class="text-[14px] font-bold text-neutral-20">
3233
+ ${this._resolvedData?.lsp4TokenName || "UNKNOWN"}
3234
+ </div>
3235
+ <div class="text-[17px] font-semibold text-neutral-20">
3275
3236
  ${when3(
3276
3237
  this.amount,
3277
3238
  () => html14`
3278
- <span class="">${formatUnits(BigInt(this.amount || 0), this._resolvedData?.decimals)}</span>
3239
+ <span class="">${formatUnits2(BigInt(this.amount || 0), this._resolvedData?.decimals)}</span>
3279
3240
  <span class="ml-1 text-neutral-60 max-w-[60px] whitespace-nowrap overflow-hidden text-ellipsis text-[14px] font-semibold">${this._resolvedData?.lsp4TokenSymbol || ""}</span>
3280
3241
  `,
3281
3242
  () => html14`${this._resolvedData?.lsp4TokenSymbol || ""}`
3282
3243
  )}
3283
- <div class="mt-4">
3284
- ${when3(this.showCreator, () => this._renderCreatorSection())}
3285
- </div>
3244
+ </div>
3245
+
3246
+ ${when3(
3247
+ this.displayedTokenId,
3248
+ () => html14`<div class="text-[14px] font-medium text-neutral-60"><span class="font-bold">#${this.displayedTokenId}</span></div>`
3249
+ )}
3250
+ <div class="mt-4">
3251
+ ${when3(this.showCreator, () => this._renderCreatorSection())}
3286
3252
  </div>
3287
3253
  </div>
3288
- <div class="border-neutral-90 pt-2">
3289
- ${this._renderTokenDetails()}
3290
- </div>
3254
+ </div>
3255
+ <div class="border-neutral-90 pt-2">
3256
+ ${this._renderTokenDetails()}
3291
3257
  </div>
3292
3258
  </div>
3293
3259
  `;
@@ -3311,6 +3277,9 @@ __decorateClass([
3311
3277
  __decorateClass([
3312
3278
  property14({ type: String, attribute: "function-icon" })
3313
3279
  ], AssetCard.prototype, "functionIcon", 2);
3280
+ __decorateClass([
3281
+ property14({ type: String })
3282
+ ], AssetCard.prototype, "size", 2);
3314
3283
  __decorateClass([
3315
3284
  property14({ type: Boolean, attribute: "show-info-button" })
3316
3285
  ], AssetCard.prototype, "showInfoButton", 2);