@crediball/elements 0.9.0 → 0.10.0

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.
@@ -433,7 +433,7 @@ var CrediballPaywallElement = class extends CrediballElement {
433
433
  </button>`
434
434
  ).join("")}
435
435
  </div>` : ""}
436
- ${this.renderPromoCode()}
436
+ ${this.renderPromoCode(Boolean(pkgs?.hasActiveCheckoutPromotion))}
437
437
  <div class="list">
438
438
  ${packages.length ? packages.map(
439
439
  (p) => `
@@ -568,11 +568,14 @@ var CrediballPaywallElement = class extends CrediballElement {
568
568
  }
569
569
  });
570
570
  }
571
- /** HTML for the "Have a promo code?" toggle-open field. Gated on the
572
- * `allow-promo-code` attribute (off by default). Not validated client-side —
573
- * an invalid code simply doesn't grant a bonus when the top-up is processed. */
574
- renderPromoCode() {
575
- if (!this.hasAttribute("allow-promo-code")) return "";
571
+ /** HTML for the "Have a promo code?" toggle-open field. Shown automatically
572
+ * once the app has an active Checkout promotion (same as the custom-amount
573
+ * field auto-following the dashboard's custom-topup config) the
574
+ * `allow-promo-code` attribute is only needed to force it on before you've
575
+ * set one up. Not validated client-side — an invalid code simply doesn't
576
+ * grant a bonus when the top-up is processed. */
577
+ renderPromoCode(hasActiveCheckoutPromotion) {
578
+ if (!this.hasAttribute("allow-promo-code") && !hasActiveCheckoutPromotion) return "";
576
579
  const label = this.getAttribute("promo-code-label") ?? "Have a promo code?";
577
580
  if (!this.promoCodeOpen) {
578
581
  return `<div class="promo-code">
@@ -847,7 +847,7 @@ var Crediball = (() => {
847
847
  </button>`
848
848
  ).join("")}
849
849
  </div>` : ""}
850
- ${this.renderPromoCode()}
850
+ ${this.renderPromoCode(Boolean(pkgs?.hasActiveCheckoutPromotion))}
851
851
  <div class="list">
852
852
  ${packages.length ? packages.map(
853
853
  (p) => `
@@ -982,11 +982,14 @@ var Crediball = (() => {
982
982
  }
983
983
  });
984
984
  }
985
- /** HTML for the "Have a promo code?" toggle-open field. Gated on the
986
- * `allow-promo-code` attribute (off by default). Not validated client-side —
987
- * an invalid code simply doesn't grant a bonus when the top-up is processed. */
988
- renderPromoCode() {
989
- if (!this.hasAttribute("allow-promo-code")) return "";
985
+ /** HTML for the "Have a promo code?" toggle-open field. Shown automatically
986
+ * once the app has an active Checkout promotion (same as the custom-amount
987
+ * field auto-following the dashboard's custom-topup config) the
988
+ * `allow-promo-code` attribute is only needed to force it on before you've
989
+ * set one up. Not validated client-side — an invalid code simply doesn't
990
+ * grant a bonus when the top-up is processed. */
991
+ renderPromoCode(hasActiveCheckoutPromotion) {
992
+ if (!this.hasAttribute("allow-promo-code") && !hasActiveCheckoutPromotion) return "";
990
993
  const label = this.getAttribute("promo-code-label") ?? "Have a promo code?";
991
994
  if (!this.promoCodeOpen) {
992
995
  return `<div class="promo-code">
package/dist/index.d.ts CHANGED
@@ -123,9 +123,12 @@ declare class CrediballPaywallElement extends CrediballElement {
123
123
  open(): void;
124
124
  close(): void;
125
125
  protected render(): void;
126
- /** HTML for the "Have a promo code?" toggle-open field. Gated on the
127
- * `allow-promo-code` attribute (off by default). Not validated client-side —
128
- * an invalid code simply doesn't grant a bonus when the top-up is processed. */
126
+ /** HTML for the "Have a promo code?" toggle-open field. Shown automatically
127
+ * once the app has an active Checkout promotion (same as the custom-amount
128
+ * field auto-following the dashboard's custom-topup config) the
129
+ * `allow-promo-code` attribute is only needed to force it on before you've
130
+ * set one up. Not validated client-side — an invalid code simply doesn't
131
+ * grant a bonus when the top-up is processed. */
129
132
  private renderPromoCode;
130
133
  /** The current promo code input value (uppercased, trimmed), or undefined
131
134
  * when the field isn't shown/filled in. Read at click time — never re-render
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  CrediballReferralCardElement,
7
7
  CrediballTopUpButtonElement,
8
8
  CrediballUsageElement
9
- } from "./chunk-MLNG4RJB.js";
9
+ } from "./chunk-YP5JNDTD.js";
10
10
  export {
11
11
  CrediballBalanceElement,
12
12
  CrediballElement,
package/dist/register.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  CrediballReferralCardElement,
6
6
  CrediballTopUpButtonElement,
7
7
  CrediballUsageElement
8
- } from "./chunk-MLNG4RJB.js";
8
+ } from "./chunk-YP5JNDTD.js";
9
9
 
10
10
  // src/register.ts
11
11
  function define(name, ctor) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crediball/elements",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Framework-agnostic web components for showing Crediball credits inside your AI app.",
5
5
  "license": "MIT",
6
6
  "author": "Filippo Rezzadore <filipporezzadore@gmail.com>",
@@ -56,7 +56,7 @@
56
56
  "prepublishOnly": "npm run build"
57
57
  },
58
58
  "dependencies": {
59
- "@crediball/core": "^0.8.0"
59
+ "@crediball/core": "^0.9.0"
60
60
  },
61
61
  "devDependencies": {
62
62
  "tsup": "^8.3.5",