@stella-source/stellasource-dsl 1.3.1 → 1.4.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.
@@ -8,7 +8,7 @@ declare const _default: {
8
8
  control: {
9
9
  type: string;
10
10
  };
11
- options: PaymentStatusVariant[];
11
+ options: (PaymentStatusVariant | null)[];
12
12
  };
13
13
  };
14
14
  args: {
@@ -1,15 +1,15 @@
1
1
  export declare enum PaymentStatusVariant {
2
- PAYMENT_REQUIRED = "Payment Required",
3
- TERMS_APPLIED = "Terms Applied",
4
- PAYMENT_AUTHORIZED = "Payment Authorized",
5
- PAYMENT_PROCESSING = "Payment Processing",
6
- PAID = "Paid",
7
- PAYMENT_FAILED = "Payment Failed",
8
- CANCELED = "Canceled",
9
- PAYMENT_WINDOW_EXPIRED = "Payment Window Expired"
2
+ PAYMENT_PENDING = "PaymentPending",
3
+ TERMS_APPLIED = "TermsApplied",
4
+ PAYMENT_AUTHORIZED = "PaymentAuthorized",
5
+ PAYMENT_PROCESSING = "PaymentProcessing",
6
+ PAYMENT_SETTLED = "PaymentSettled",
7
+ PAYMENT_FAILED = "PaymentFailed",
8
+ PAYMENT_CANCELED = "PaymentCanceled",
9
+ PAYMENT_WINDOW_EXPIRED = "PaymentWindowExpired"
10
10
  }
11
11
  export interface PaymentStatusProps {
12
12
  id?: string;
13
13
  className?: string;
14
- variant: `${PaymentStatusVariant}`;
14
+ variant: `${PaymentStatusVariant}` | null;
15
15
  }
@@ -1,6 +1,6 @@
1
1
  import { HTMLAttributes } from "react";
2
2
  import { StellaIconDefinition } from "../../StellaIcon/types";
3
- import { TextFieldAlignments, TextFieldLeftCategory, TextFieldRightCategory } from "../types";
3
+ import { TextFieldAlignments } from "../types";
4
4
  export interface NumberInputProps {
5
5
  id: string;
6
6
  label: string;
@@ -23,8 +23,8 @@ export interface NumberInputProps {
23
23
  endIcon?: `${StellaIconDefinition}`;
24
24
  hasError?: boolean;
25
25
  textAlign?: `${TextFieldAlignments}`;
26
- leftCategory?: `${TextFieldLeftCategory}`;
27
- rightCategory?: `${TextFieldRightCategory}`;
26
+ leftCategory?: string;
27
+ rightCategory?: string;
28
28
  thousandSeparator?: boolean;
29
29
  decimalPlaces?: number;
30
30
  allowNegativeNumbers?: boolean;
@@ -4,21 +4,6 @@ export declare enum TextFieldAlignments {
4
4
  CENTER = "center",
5
5
  RIGHT = "right"
6
6
  }
7
- export declare enum TextFieldLeftCategory {
8
- US_CURRENCY = "$"
9
- }
10
- export declare enum TextFieldRightCategory {
11
- FEET = "ft",
12
- CENTIMETERS = "cm",
13
- INCHES = "in",
14
- FULL_INCHES = "inches",
15
- PERCENTAGE = "%",
16
- POUNDS_FEET = "lbs/ft",
17
- HUNDREDWEIGHT = "CWT",
18
- DPH = "$/hr",
19
- MINUTES = "min",
20
- HOURS = "hr"
21
- }
22
7
  export interface TextFieldContainerProps {
23
8
  children: React.ReactNode;
24
9
  id: string;
@@ -26,8 +11,8 @@ export interface TextFieldContainerProps {
26
11
  hideLabel?: boolean;
27
12
  disabled?: boolean;
28
13
  dataTestId?: string;
29
- rightCategory?: `${TextFieldRightCategory}`;
30
- leftCategory?: `${TextFieldLeftCategory}`;
14
+ rightCategory?: string;
15
+ leftCategory?: string;
31
16
  tooltipText?: string;
32
17
  isRequired?: boolean;
33
18
  helperText?: string;
@@ -14,13 +14,12 @@ import Table from "./components/Table/Table";
14
14
  import Pagination from "./components/Pagination/Pagination";
15
15
  import Sync from "./components/Sync/Sync";
16
16
  import TableUnitsAndTotals from "./components/TableUnitsAndTotals/TableUnitsAndTotals";
17
+ import PaymentStatus from "./components/PaymentStatus/PaymentStatus";
17
18
  /** Types */
18
19
  import { StellaButtonVariant } from "./components/StellaButton/types";
19
20
  /** Tokens */
20
21
  import { Styles } from "./shared/tokens";
21
22
  import "./shared/tokens/tokens.css";
22
- import PaymentStatus from "./components/PaymentStatus/PaymentStatus";
23
23
  /**Exports */
24
- export * from "./components/TableUnitsAndTotals/types";
25
24
  export type { StellaIconDefinition } from "./components/StellaIcon/types";
26
25
  export { Label, StellaButton, IconButton, Loader, HelperText, Tooltip, StellaIcon, TextInput, PasswordInput, NumberInput, Table, Pagination, Sync, TableUnitsAndTotals, StellaButtonVariant, PaymentStatus, Styles, };
@@ -17311,7 +17311,13 @@ const PasswordInput = ({ id, className, htmlProps, label, placeholder = "Enter P
17311
17311
  const formatDynamicNumbersWithCommas = (num, decimalPlaces) => {
17312
17312
  const onlyDigitNum = num.toString().replace(/[^\d.-]/g, "");
17313
17313
  const decimalEnding = onlyDigitNum.endsWith(".");
17314
- const decimalZero = onlyDigitNum.includes(".") && onlyDigitNum.endsWith("0");
17314
+ const zeroEnding = onlyDigitNum.includes(".") && onlyDigitNum.endsWith("0");
17315
+ let decimalTrailingZeros = "";
17316
+ if (zeroEnding) {
17317
+ const match = onlyDigitNum.match(/0+$/);
17318
+ decimalTrailingZeros = match ? match[0] : "";
17319
+ }
17320
+ const decimalZero = onlyDigitNum.endsWith(`.${decimalTrailingZeros.length > 0 ? decimalTrailingZeros : "0"}`);
17315
17321
  if (onlyDigitNum === "" || onlyDigitNum === "-" || onlyDigitNum === ".") {
17316
17322
  return onlyDigitNum;
17317
17323
  }
@@ -17322,7 +17328,7 @@ const formatDynamicNumbersWithCommas = (num, decimalPlaces) => {
17322
17328
  ? `${Number(onlyDigitNum).toLocaleString("en-US", {
17323
17329
  minimumFractionDigits: 0,
17324
17330
  maximumFractionDigits: decimalPlaces,
17325
- })}${decimalEnding ? "." : ""}${decimalZero ? "0" : ""}`
17331
+ })}${decimalEnding ? "." : ""}${decimalZero ? "." : ""}${zeroEnding ? `${decimalTrailingZeros}` : ""}`
17326
17332
  : "";
17327
17333
  };
17328
17334
 
@@ -21878,21 +21884,39 @@ const PaymentStatusLabel = styled.span `
21878
21884
  line-height: 20px;
21879
21885
  `;
21880
21886
 
21887
+ var PaymentStatusVariant;
21888
+ (function (PaymentStatusVariant) {
21889
+ PaymentStatusVariant["PAYMENT_PENDING"] = "PaymentPending";
21890
+ PaymentStatusVariant["TERMS_APPLIED"] = "TermsApplied";
21891
+ PaymentStatusVariant["PAYMENT_AUTHORIZED"] = "PaymentAuthorized";
21892
+ PaymentStatusVariant["PAYMENT_PROCESSING"] = "PaymentProcessing";
21893
+ PaymentStatusVariant["PAYMENT_SETTLED"] = "PaymentSettled";
21894
+ PaymentStatusVariant["PAYMENT_FAILED"] = "PaymentFailed";
21895
+ PaymentStatusVariant["PAYMENT_CANCELED"] = "PaymentCanceled";
21896
+ PaymentStatusVariant["PAYMENT_WINDOW_EXPIRED"] = "PaymentWindowExpired";
21897
+ })(PaymentStatusVariant || (PaymentStatusVariant = {}));
21898
+
21881
21899
  const STATUS_ICON_MAP = {
21882
- "Payment Required": "warning",
21883
- "Terms Applied": "check-square",
21884
- "Payment Authorized": "check-square",
21885
- "Payment Processing": "money",
21886
- Paid: "currency-dollar",
21887
- "Payment Failed": "x-circle",
21888
- Canceled: "empty",
21889
- "Payment Window Expired": "hourglass-simple-low",
21900
+ PaymentPending: "warning",
21901
+ TermsApplied: "check-square",
21902
+ PaymentAuthorized: "check-square",
21903
+ PaymentProcessing: "money",
21904
+ PaymentSettled: "currency-dollar",
21905
+ PaymentFailed: "x-circle",
21906
+ PaymentCanceled: "empty",
21907
+ PaymentWindowExpired: "hourglass-simple-low",
21890
21908
  };
21891
21909
  const PaymentStatus = ({ variant, id, className }) => {
21892
- const iconName = STATUS_ICON_MAP[variant];
21910
+ const iconName = variant ? STATUS_ICON_MAP[variant] : "";
21911
+ const labelWords = variant?.split(/(?=[A-Z])/);
21912
+ let label = labelWords ? labelWords.join(" ") : "--";
21913
+ if (variant === PaymentStatusVariant.PAYMENT_SETTLED)
21914
+ label = "Paid";
21915
+ if (variant === PaymentStatusVariant.PAYMENT_CANCELED)
21916
+ label = "Canceled";
21893
21917
  return (a__default.createElement(PaymentStatusComponent, { id: id, className: className },
21894
- a__default.createElement(PaymentStatusIcon, { iconName: iconName, size: 16 }),
21895
- a__default.createElement(PaymentStatusLabel, null, variant)));
21918
+ iconName ? a__default.createElement(PaymentStatusIcon, { iconName: iconName, size: 16 }) : "",
21919
+ a__default.createElement(PaymentStatusLabel, null, label)));
21896
21920
  };
21897
21921
 
21898
21922
  export { HelperText, IconButton, Label, Loader, NumberInput, Pagination, PasswordInput, PaymentStatus, StellaButton, StellaButtonVariant, StellaIcon, Styles, Sync, Table, TableUnitsAndTotals, TextInput, Tooltip };