myoperator-ui 0.0.161 → 0.0.163

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.
Files changed (2) hide show
  1. package/dist/index.js +136 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8206,7 +8206,7 @@ export type {
8206
8206
  },
8207
8207
  "payment-option-card": {
8208
8208
  name: "payment-option-card",
8209
- description: "A selectable payment method list with icons, titles, and descriptions",
8209
+ description: "A selectable payment method list with icons, titles, and descriptions. Includes a modal variant for overlay usage.",
8210
8210
  category: "custom",
8211
8211
  dependencies: [
8212
8212
  "clsx",
@@ -8214,7 +8214,8 @@ export type {
8214
8214
  "lucide-react"
8215
8215
  ],
8216
8216
  internalDependencies: [
8217
- "button"
8217
+ "button",
8218
+ "dialog"
8218
8219
  ],
8219
8220
  isMultiFile: true,
8220
8221
  directory: "payment-option-card",
@@ -8359,6 +8360,96 @@ export const PaymentOptionCard = React.forwardRef<
8359
8360
  );
8360
8361
 
8361
8362
  PaymentOptionCard.displayName = "PaymentOptionCard";
8363
+ `, prefix)
8364
+ },
8365
+ {
8366
+ name: "payment-option-card-modal.tsx",
8367
+ content: prefixTailwindClasses(`import * as React from "react";
8368
+ import {
8369
+ Dialog,
8370
+ DialogContent,
8371
+ DialogTitle,
8372
+ } from "../dialog";
8373
+ import { PaymentOptionCard } from "./payment-option-card";
8374
+ import type { PaymentOptionCardModalProps } from "./types";
8375
+
8376
+ /**
8377
+ * PaymentOptionCardModal wraps the PaymentOptionCard in a centered Dialog overlay.
8378
+ * Use this when you want to show payment method selection as a modal popup rather
8379
+ * than an inline card.
8380
+ *
8381
+ * @example
8382
+ * \`\`\`tsx
8383
+ * const [open, setOpen] = useState(false);
8384
+ *
8385
+ * <PaymentOptionCardModal
8386
+ * open={open}
8387
+ * onOpenChange={setOpen}
8388
+ * options={paymentOptions}
8389
+ * onOptionSelect={(id) => console.log(id)}
8390
+ * onCtaClick={() => { handlePayment(); setOpen(false); }}
8391
+ * />
8392
+ * \`\`\`
8393
+ */
8394
+ export const PaymentOptionCardModal = React.forwardRef<
8395
+ HTMLDivElement,
8396
+ PaymentOptionCardModalProps
8397
+ >(
8398
+ (
8399
+ {
8400
+ open,
8401
+ onOpenChange,
8402
+ title,
8403
+ subtitle,
8404
+ options,
8405
+ selectedOptionId,
8406
+ defaultSelectedOptionId,
8407
+ onOptionSelect,
8408
+ ctaText,
8409
+ onCtaClick,
8410
+ loading,
8411
+ disabled,
8412
+ className,
8413
+ },
8414
+ ref
8415
+ ) => {
8416
+ const handleClose = () => {
8417
+ onOpenChange(false);
8418
+ };
8419
+
8420
+ return (
8421
+ <Dialog open={open} onOpenChange={onOpenChange}>
8422
+ <DialogContent
8423
+ ref={ref}
8424
+ size="sm"
8425
+ hideCloseButton
8426
+ className="p-0 border-0 bg-transparent shadow-none"
8427
+ >
8428
+ {/* Visually hidden title for accessibility */}
8429
+ <DialogTitle className="sr-only">
8430
+ {title || "Select payment method"}
8431
+ </DialogTitle>
8432
+ <PaymentOptionCard
8433
+ title={title}
8434
+ subtitle={subtitle}
8435
+ options={options}
8436
+ selectedOptionId={selectedOptionId}
8437
+ defaultSelectedOptionId={defaultSelectedOptionId}
8438
+ onOptionSelect={onOptionSelect}
8439
+ ctaText={ctaText}
8440
+ onCtaClick={onCtaClick}
8441
+ onClose={handleClose}
8442
+ loading={loading}
8443
+ disabled={disabled}
8444
+ className={className}
8445
+ />
8446
+ </DialogContent>
8447
+ </Dialog>
8448
+ );
8449
+ }
8450
+ );
8451
+
8452
+ PaymentOptionCardModal.displayName = "PaymentOptionCardModal";
8362
8453
  `, prefix)
8363
8454
  },
8364
8455
  {
@@ -8408,12 +8499,30 @@ export interface PaymentOptionCardProps {
8408
8499
  /** Additional className for the root element */
8409
8500
  className?: string;
8410
8501
  }
8502
+
8503
+ /**
8504
+ * Props for the PaymentOptionCardModal component.
8505
+ * Extends the card props with Dialog open/close control, omitting \`onClose\`
8506
+ * which is handled internally by the modal.
8507
+ */
8508
+ export interface PaymentOptionCardModalProps
8509
+ extends Omit<PaymentOptionCardProps, "onClose"> {
8510
+ /** Whether the modal is open */
8511
+ open: boolean;
8512
+ /** Callback when modal should open or close */
8513
+ onOpenChange: (open: boolean) => void;
8514
+ }
8411
8515
  `, prefix)
8412
8516
  },
8413
8517
  {
8414
8518
  name: "index.ts",
8415
8519
  content: prefixTailwindClasses(`export { PaymentOptionCard } from "./payment-option-card";
8416
- export type { PaymentOptionCardProps, PaymentOption } from "./types";
8520
+ export { PaymentOptionCardModal } from "./payment-option-card-modal";
8521
+ export type {
8522
+ PaymentOptionCardProps,
8523
+ PaymentOptionCardModalProps,
8524
+ PaymentOption,
8525
+ } from "./types";
8417
8526
  `, prefix)
8418
8527
  }
8419
8528
  ]
@@ -8498,6 +8607,8 @@ export const WalletTopup = React.forwardRef<HTMLDivElement, WalletTopupProps>(
8498
8607
  voucherLinkText = "Have an offline code or voucher?",
8499
8608
  voucherIcon = <Ticket className="size-4" />,
8500
8609
  onVoucherClick,
8610
+ showVoucherInput: controlledShowVoucherInput,
8611
+ onShowVoucherInputChange,
8501
8612
  voucherCode: controlledVoucherCode,
8502
8613
  onVoucherCodeChange,
8503
8614
  voucherCodePlaceholder = "XXXX-XXXX-XXXX",
@@ -8530,8 +8641,15 @@ export const WalletTopup = React.forwardRef<HTMLDivElement, WalletTopupProps>(
8530
8641
  ? controlledCustomAmount
8531
8642
  : internalCustom;
8532
8643
 
8644
+ // Voucher input visibility (controlled/uncontrolled)
8645
+ const isVoucherInputControlled = controlledShowVoucherInput !== undefined;
8646
+ const [internalShowVoucherInput, setInternalShowVoucherInput] =
8647
+ React.useState(false);
8648
+ const showVoucherInput = isVoucherInputControlled
8649
+ ? controlledShowVoucherInput
8650
+ : internalShowVoucherInput;
8651
+
8533
8652
  // Voucher code input state
8534
- const [showVoucherInput, setShowVoucherInput] = React.useState(false);
8535
8653
  const isVoucherCodeControlled = controlledVoucherCode !== undefined;
8536
8654
  const [internalVoucherCode, setInternalVoucherCode] = React.useState("");
8537
8655
  const voucherCodeValue = isVoucherCodeControlled
@@ -8539,12 +8657,18 @@ export const WalletTopup = React.forwardRef<HTMLDivElement, WalletTopupProps>(
8539
8657
  : internalVoucherCode;
8540
8658
 
8541
8659
  const handleVoucherLinkClick = () => {
8542
- setShowVoucherInput(true);
8660
+ if (!isVoucherInputControlled) {
8661
+ setInternalShowVoucherInput(true);
8662
+ }
8663
+ onShowVoucherInputChange?.(true);
8543
8664
  onVoucherClick?.();
8544
8665
  };
8545
8666
 
8546
8667
  const handleVoucherCancel = () => {
8547
- setShowVoucherInput(false);
8668
+ if (!isVoucherInputControlled) {
8669
+ setInternalShowVoucherInput(false);
8670
+ }
8671
+ onShowVoucherInputChange?.(false);
8548
8672
  if (!isVoucherCodeControlled) {
8549
8673
  setInternalVoucherCode("");
8550
8674
  }
@@ -8827,6 +8951,12 @@ export interface WalletTopupProps {
8827
8951
  /** Callback when voucher link is clicked (also toggles inline code input) */
8828
8952
  onVoucherClick?: () => void;
8829
8953
 
8954
+ // Voucher input visibility
8955
+ /** Whether the voucher input is visible (controlled). When provided, the component won't toggle visibility internally. */
8956
+ showVoucherInput?: boolean;
8957
+ /** Callback when voucher input visibility changes (from link click or cancel) */
8958
+ onShowVoucherInputChange?: (show: boolean) => void;
8959
+
8830
8960
  // Voucher code input
8831
8961
  /** Voucher code value (controlled) */
8832
8962
  voucherCode?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myoperator-ui",
3
- "version": "0.0.161",
3
+ "version": "0.0.163",
4
4
  "description": "CLI for adding myOperator UI components to your project",
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",