myoperator-ui 0.0.164 → 0.0.166
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.js +145 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2874,10 +2874,12 @@ export interface TableProps
|
|
|
2874
2874
|
VariantProps<typeof tableVariants> {
|
|
2875
2875
|
/** Remove outer border from the table */
|
|
2876
2876
|
withoutBorder?: boolean;
|
|
2877
|
+
/** Allow cell content to wrap to multiple lines. By default, content is kept on a single line with horizontal scroll. */
|
|
2878
|
+
wrapContent?: boolean;
|
|
2877
2879
|
}
|
|
2878
2880
|
|
|
2879
2881
|
const Table = React.forwardRef<HTMLTableElement, TableProps>(
|
|
2880
|
-
({ className, size, withoutBorder, ...props }, ref) => (
|
|
2882
|
+
({ className, size, withoutBorder, wrapContent, ...props }, ref) => (
|
|
2881
2883
|
<div
|
|
2882
2884
|
className={cn(
|
|
2883
2885
|
"relative w-full overflow-auto",
|
|
@@ -2886,7 +2888,11 @@ const Table = React.forwardRef<HTMLTableElement, TableProps>(
|
|
|
2886
2888
|
>
|
|
2887
2889
|
<table
|
|
2888
2890
|
ref={ref}
|
|
2889
|
-
className={cn(
|
|
2891
|
+
className={cn(
|
|
2892
|
+
tableVariants({ size }),
|
|
2893
|
+
!wrapContent && "[&_th]:whitespace-nowrap [&_td]:whitespace-nowrap",
|
|
2894
|
+
className
|
|
2895
|
+
)}
|
|
2890
2896
|
{...props}
|
|
2891
2897
|
/>
|
|
2892
2898
|
</div>
|
|
@@ -8737,7 +8743,7 @@ export type {
|
|
|
8737
8743
|
{
|
|
8738
8744
|
name: "wallet-topup.tsx",
|
|
8739
8745
|
content: prefixTailwindClasses(`import * as React from "react";
|
|
8740
|
-
import {
|
|
8746
|
+
import { Ticket } from "lucide-react";
|
|
8741
8747
|
import { cn } from "../../../lib/utils";
|
|
8742
8748
|
import { Button } from "../button";
|
|
8743
8749
|
import { Input } from "../input";
|
|
@@ -8760,7 +8766,11 @@ function normalizeAmountOption(option: number | AmountOption): AmountOption {
|
|
|
8760
8766
|
* Format currency amount with symbol
|
|
8761
8767
|
*/
|
|
8762
8768
|
function formatCurrency(amount: number, symbol: string = "\u20B9"): string {
|
|
8763
|
-
|
|
8769
|
+
const hasDecimals = amount % 1 !== 0;
|
|
8770
|
+
return \`\${symbol}\${amount.toLocaleString("en-IN", {
|
|
8771
|
+
minimumFractionDigits: hasDecimals ? 2 : 0,
|
|
8772
|
+
maximumFractionDigits: hasDecimals ? 2 : 0,
|
|
8773
|
+
})}\`;
|
|
8764
8774
|
}
|
|
8765
8775
|
|
|
8766
8776
|
/**
|
|
@@ -8792,6 +8802,13 @@ export const WalletTopup = React.forwardRef<HTMLDivElement, WalletTopupProps>(
|
|
|
8792
8802
|
customAmountPlaceholder = "Enter amount",
|
|
8793
8803
|
customAmountLabel = "Custom Amount",
|
|
8794
8804
|
currencySymbol = "\u20B9",
|
|
8805
|
+
taxAmount: taxAmountProp,
|
|
8806
|
+
taxCalculator,
|
|
8807
|
+
taxLabel = "Taxes (GST)",
|
|
8808
|
+
rechargeAmountLabel = "Recharge amount",
|
|
8809
|
+
outstandingAmount,
|
|
8810
|
+
outstandingLabel = "Outstanding",
|
|
8811
|
+
topupLabel = "Top-up",
|
|
8795
8812
|
showVoucherLink = true,
|
|
8796
8813
|
voucherLinkText = "Have an offline code or voucher?",
|
|
8797
8814
|
voucherIcon = <Ticket className="size-4" />,
|
|
@@ -8888,6 +8905,10 @@ export const WalletTopup = React.forwardRef<HTMLDivElement, WalletTopupProps>(
|
|
|
8888
8905
|
};
|
|
8889
8906
|
|
|
8890
8907
|
const normalizedAmounts = amounts.map(normalizeAmountOption);
|
|
8908
|
+
const displayAmounts =
|
|
8909
|
+
outstandingAmount && outstandingAmount > 0
|
|
8910
|
+
? [{ value: 0 } as AmountOption, ...normalizedAmounts]
|
|
8911
|
+
: normalizedAmounts;
|
|
8891
8912
|
|
|
8892
8913
|
const handleAmountSelect = (value: number) => {
|
|
8893
8914
|
const newValue = selectedValue === value ? null : value;
|
|
@@ -8919,19 +8940,39 @@ export const WalletTopup = React.forwardRef<HTMLDivElement, WalletTopupProps>(
|
|
|
8919
8940
|
};
|
|
8920
8941
|
|
|
8921
8942
|
// Determine the effective pay amount
|
|
8922
|
-
const
|
|
8923
|
-
selectedValue ?? (customValue ? Number(customValue) :
|
|
8943
|
+
const baseSelection =
|
|
8944
|
+
selectedValue ?? (customValue ? Number(customValue) : null);
|
|
8945
|
+
|
|
8946
|
+
// Effective recharge amount (includes outstanding if present)
|
|
8947
|
+
const effectiveRechargeAmount =
|
|
8948
|
+
baseSelection !== null
|
|
8949
|
+
? outstandingAmount
|
|
8950
|
+
? outstandingAmount + baseSelection
|
|
8951
|
+
: baseSelection
|
|
8952
|
+
: 0;
|
|
8953
|
+
|
|
8954
|
+
// Tax computation
|
|
8955
|
+
const hasTax = taxCalculator !== undefined || taxAmountProp !== undefined;
|
|
8956
|
+
const computedTax =
|
|
8957
|
+
effectiveRechargeAmount > 0
|
|
8958
|
+
? taxCalculator
|
|
8959
|
+
? taxCalculator(effectiveRechargeAmount)
|
|
8960
|
+
: (taxAmountProp ?? 0)
|
|
8961
|
+
: 0;
|
|
8962
|
+
|
|
8963
|
+
// Total payable (recharge + tax)
|
|
8964
|
+
const totalPayable = effectiveRechargeAmount + computedTax;
|
|
8924
8965
|
|
|
8925
8966
|
const handlePay = () => {
|
|
8926
|
-
if (
|
|
8927
|
-
onPay?.(
|
|
8967
|
+
if (totalPayable > 0) {
|
|
8968
|
+
onPay?.(totalPayable);
|
|
8928
8969
|
}
|
|
8929
8970
|
};
|
|
8930
8971
|
|
|
8931
8972
|
const buttonText =
|
|
8932
8973
|
ctaText ||
|
|
8933
|
-
(
|
|
8934
|
-
? \`Pay \${formatCurrency(
|
|
8974
|
+
(totalPayable > 0
|
|
8975
|
+
? \`Pay \${formatCurrency(totalPayable, currencySymbol)} now\`
|
|
8935
8976
|
: "Select an amount");
|
|
8936
8977
|
|
|
8937
8978
|
return (
|
|
@@ -8968,8 +9009,15 @@ export const WalletTopup = React.forwardRef<HTMLDivElement, WalletTopupProps>(
|
|
|
8968
9009
|
{amountSectionLabel}
|
|
8969
9010
|
</label>
|
|
8970
9011
|
<div className="grid grid-cols-2 gap-4">
|
|
8971
|
-
{
|
|
9012
|
+
{displayAmounts.map((option) => {
|
|
8972
9013
|
const isSelected = selectedValue === option.value;
|
|
9014
|
+
const hasOutstanding =
|
|
9015
|
+
outstandingAmount !== undefined &&
|
|
9016
|
+
outstandingAmount > 0;
|
|
9017
|
+
const totalForOption = hasOutstanding
|
|
9018
|
+
? outstandingAmount + option.value
|
|
9019
|
+
: option.value;
|
|
9020
|
+
|
|
8973
9021
|
return (
|
|
8974
9022
|
<button
|
|
8975
9023
|
key={option.value}
|
|
@@ -8978,18 +9026,53 @@ export const WalletTopup = React.forwardRef<HTMLDivElement, WalletTopupProps>(
|
|
|
8978
9026
|
aria-checked={isSelected}
|
|
8979
9027
|
onClick={() => handleAmountSelect(option.value)}
|
|
8980
9028
|
className={cn(
|
|
8981
|
-
"flex
|
|
9029
|
+
"flex px-4 rounded text-sm transition-all cursor-pointer",
|
|
9030
|
+
hasOutstanding
|
|
9031
|
+
? "flex-col items-start gap-0.5 h-auto py-3"
|
|
9032
|
+
: "items-center h-10 py-2.5",
|
|
8982
9033
|
isSelected
|
|
8983
|
-
? "border border-semantic-
|
|
9034
|
+
? "border border-[var(--semantic-brand)] shadow-sm"
|
|
8984
9035
|
: "border border-semantic-border-input hover:border-semantic-text-muted"
|
|
8985
9036
|
)}
|
|
8986
9037
|
>
|
|
8987
|
-
<span
|
|
8988
|
-
{
|
|
8989
|
-
|
|
9038
|
+
<span
|
|
9039
|
+
className={cn(
|
|
9040
|
+
isSelected
|
|
9041
|
+
? "text-semantic-primary"
|
|
9042
|
+
: "text-semantic-text-primary",
|
|
9043
|
+
hasOutstanding && "font-medium"
|
|
9044
|
+
)}
|
|
9045
|
+
>
|
|
9046
|
+
{hasOutstanding
|
|
9047
|
+
? formatCurrency(
|
|
9048
|
+
totalForOption,
|
|
9049
|
+
currencySymbol
|
|
9050
|
+
)
|
|
9051
|
+
: option.label ||
|
|
9052
|
+
formatCurrency(
|
|
9053
|
+
option.value,
|
|
9054
|
+
currencySymbol
|
|
9055
|
+
)}
|
|
8990
9056
|
</span>
|
|
8991
|
-
{
|
|
8992
|
-
|
|
9057
|
+
{hasOutstanding && (
|
|
9058
|
+
<>
|
|
9059
|
+
<span className="text-xs text-semantic-text-muted">
|
|
9060
|
+
{outstandingLabel}:{" "}
|
|
9061
|
+
{formatCurrency(
|
|
9062
|
+
outstandingAmount,
|
|
9063
|
+
currencySymbol
|
|
9064
|
+
)}
|
|
9065
|
+
</span>
|
|
9066
|
+
<span className="text-xs text-semantic-text-muted">
|
|
9067
|
+
{topupLabel}:{" "}
|
|
9068
|
+
{option.value > 0
|
|
9069
|
+
? formatCurrency(
|
|
9070
|
+
option.value,
|
|
9071
|
+
currencySymbol
|
|
9072
|
+
)
|
|
9073
|
+
: "-"}
|
|
9074
|
+
</span>
|
|
9075
|
+
</>
|
|
8993
9076
|
)}
|
|
8994
9077
|
</button>
|
|
8995
9078
|
);
|
|
@@ -9010,6 +9093,31 @@ export const WalletTopup = React.forwardRef<HTMLDivElement, WalletTopupProps>(
|
|
|
9010
9093
|
/>
|
|
9011
9094
|
</div>
|
|
9012
9095
|
|
|
9096
|
+
{/* Recharge Summary */}
|
|
9097
|
+
{hasTax && effectiveRechargeAmount > 0 && (
|
|
9098
|
+
<div className="flex flex-col gap-2 rounded-lg bg-[var(--semantic-warning-surface)] px-4 py-3">
|
|
9099
|
+
<div className="flex items-center justify-between text-sm">
|
|
9100
|
+
<span className="text-semantic-text-primary">
|
|
9101
|
+
{rechargeAmountLabel}
|
|
9102
|
+
</span>
|
|
9103
|
+
<span className="text-semantic-text-primary font-medium">
|
|
9104
|
+
{formatCurrency(
|
|
9105
|
+
effectiveRechargeAmount,
|
|
9106
|
+
currencySymbol
|
|
9107
|
+
)}
|
|
9108
|
+
</span>
|
|
9109
|
+
</div>
|
|
9110
|
+
<div className="flex items-center justify-between text-sm">
|
|
9111
|
+
<span className="text-semantic-text-muted">
|
|
9112
|
+
{taxLabel}
|
|
9113
|
+
</span>
|
|
9114
|
+
<span className="text-semantic-text-muted">
|
|
9115
|
+
{formatCurrency(computedTax, currencySymbol)}
|
|
9116
|
+
</span>
|
|
9117
|
+
</div>
|
|
9118
|
+
</div>
|
|
9119
|
+
)}
|
|
9120
|
+
|
|
9013
9121
|
{/* Voucher Link or Voucher Code Input */}
|
|
9014
9122
|
{showVoucherLink && !showVoucherInput && (
|
|
9015
9123
|
<button
|
|
@@ -9061,7 +9169,7 @@ export const WalletTopup = React.forwardRef<HTMLDivElement, WalletTopupProps>(
|
|
|
9061
9169
|
className="w-full"
|
|
9062
9170
|
onClick={handlePay}
|
|
9063
9171
|
loading={loading}
|
|
9064
|
-
disabled={disabled ||
|
|
9172
|
+
disabled={disabled || totalPayable <= 0}
|
|
9065
9173
|
>
|
|
9066
9174
|
{buttonText}
|
|
9067
9175
|
</Button>
|
|
@@ -9130,6 +9238,24 @@ export interface WalletTopupProps {
|
|
|
9130
9238
|
/** Currency symbol (default: "\u20B9") */
|
|
9131
9239
|
currencySymbol?: string;
|
|
9132
9240
|
|
|
9241
|
+
// Tax / Summary
|
|
9242
|
+
/** Static tax amount to display in the summary section */
|
|
9243
|
+
taxAmount?: number;
|
|
9244
|
+
/** Function to dynamically compute tax from the recharge amount. Takes priority over taxAmount. */
|
|
9245
|
+
taxCalculator?: (amount: number) => number;
|
|
9246
|
+
/** Label for the tax line in the summary (default: "Taxes (GST)") */
|
|
9247
|
+
taxLabel?: string;
|
|
9248
|
+
/** Label for the recharge amount line in the summary (default: "Recharge amount") */
|
|
9249
|
+
rechargeAmountLabel?: string;
|
|
9250
|
+
|
|
9251
|
+
// Outstanding balance
|
|
9252
|
+
/** Outstanding balance. When set, auto-prepends an outstanding-only option and shows breakdowns in each amount button. */
|
|
9253
|
+
outstandingAmount?: number;
|
|
9254
|
+
/** Label for the outstanding breakdown in amount buttons (default: "Outstanding") */
|
|
9255
|
+
outstandingLabel?: string;
|
|
9256
|
+
/** Label for the topup breakdown in amount buttons (default: "Top-up") */
|
|
9257
|
+
topupLabel?: string;
|
|
9258
|
+
|
|
9133
9259
|
// Voucher link
|
|
9134
9260
|
/** Whether to show the voucher/code link */
|
|
9135
9261
|
showVoucherLink?: boolean;
|