@fluid-app/portal-sdk 0.1.302 → 0.1.303

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.
@@ -14,7 +14,7 @@ import { a as AddressFormDialog, c as PaymentIcon, f as ConfirmActionDialog, h a
14
14
  import { createContext, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
15
15
  import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
16
16
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
17
- import { AlertCircle, CalendarDays, CalendarIcon, ChevronDown, ChevronLeft, ChevronRight, ImageOff, Pause, Play, Repeat, RotateCcw, SkipForward, XCircle } from "lucide-react";
17
+ import { AlertCircle, CalendarDays, CalendarIcon, ChevronDown, ChevronLeft, ChevronRight, ImageOff, Minus, Pause, Play, Plus, Repeat, RotateCcw, SkipForward, XCircle } from "lucide-react";
18
18
  import { clsx } from "clsx";
19
19
  import { twMerge } from "tailwind-merge";
20
20
  //#region ../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/getDefaultOptions.js
@@ -2693,6 +2693,8 @@ const subscriptionsDomain = createDomainTranslations({
2693
2693
  no_image: "No image",
2694
2694
  quantity_label: "Quantity",
2695
2695
  quantity_aria: "Quantity",
2696
+ decrease_quantity_aria: "Decrease quantity",
2697
+ increase_quantity_aria: "Increase quantity",
2696
2698
  subtotal: "Subtotal",
2697
2699
  discount: "Discount",
2698
2700
  total_label: "Total",
@@ -4148,7 +4150,7 @@ function SubscriptionDetailSkeleton() {
4148
4150
  })]
4149
4151
  });
4150
4152
  }
4151
- function QuantityInput({ inputId, quantity, isUpdatingQuantity, onQuantityChange, quantityAriaLabel }) {
4153
+ function QuantityInput({ inputId, quantity, maxQuantity, isUpdatingQuantity, onQuantityChange, quantityAriaLabel, decrementAriaLabel, incrementAriaLabel }) {
4152
4154
  const inputRef = useRef(null);
4153
4155
  const [inputValue, setInputValue] = useState(String(quantity));
4154
4156
  const focusEntryQuantityRef = useRef(quantity);
@@ -4171,41 +4173,79 @@ function QuantityInput({ inputId, quantity, isUpdatingQuantity, onQuantityChange
4171
4173
  focusEntryQuantityRef.current = next;
4172
4174
  }, 500);
4173
4175
  };
4174
- return /* @__PURE__ */ jsx(Input, {
4175
- ref: inputRef,
4176
- id: inputId,
4177
- type: "number",
4178
- min: 1,
4179
- step: 1,
4180
- value: inputValue,
4181
- onFocus: () => {
4182
- focusEntryQuantityRef.current = quantity;
4183
- },
4184
- onChange: (e) => {
4185
- const raw = e.target.value;
4186
- setInputValue(raw);
4187
- if (raw === "") {
4188
- if (commitTimerRef.current) clearTimeout(commitTimerRef.current);
4189
- return;
4190
- }
4191
- const next = parseInt(raw, 10);
4192
- if (Number.isFinite(next) && next > 0) scheduleCommit(next);
4193
- },
4194
- onBlur: () => {
4195
- if (commitTimerRef.current) clearTimeout(commitTimerRef.current);
4196
- const parsed = parseInt(inputValue, 10);
4197
- if (Number.isFinite(parsed) && parsed > 0) {
4198
- if (parsed !== quantity) onQuantityChange(parsed);
4199
- focusEntryQuantityRef.current = parsed;
4200
- } else {
4201
- const restore = focusEntryQuantityRef.current;
4202
- setInputValue(String(restore));
4203
- if (restore !== quantity) onQuantityChange(restore);
4204
- }
4205
- },
4206
- readOnly: isUpdatingQuantity,
4207
- className: cn$1("border-border bg-background h-10 w-16 border text-center", isUpdatingQuantity && "opacity-60"),
4208
- "aria-label": quantityAriaLabel
4176
+ const parsedInput = parseInt(inputValue, 10);
4177
+ const currentValue = Number.isFinite(parsedInput) && parsedInput > 0 ? parsedInput : quantity;
4178
+ const decrementDisabled = isUpdatingQuantity || currentValue <= 1;
4179
+ const incrementDisabled = isUpdatingQuantity || maxQuantity != null && currentValue >= maxQuantity;
4180
+ const clampToBounds = (n) => maxQuantity != null ? Math.min(maxQuantity, Math.max(1, n)) : Math.max(1, n);
4181
+ const stepBy = (delta) => {
4182
+ const clamped = clampToBounds(currentValue + delta);
4183
+ if (clamped === currentValue) return;
4184
+ setInputValue(String(clamped));
4185
+ scheduleCommit(clamped);
4186
+ };
4187
+ const stepperButtonClass = cn$1("text-muted-foreground hover:text-foreground hover:bg-muted flex h-7 w-7 shrink-0 items-center justify-center rounded-full shadow-xs disabled:cursor-not-allowed");
4188
+ return /* @__PURE__ */ jsxs("div", {
4189
+ className: cn$1("border-border bg-background focus-within:border-ring focus-within:ring-ring/50 flex h-7.5 items-center justify-between rounded-2xl border focus-within:ring-[3px]", isUpdatingQuantity && "opacity-60"),
4190
+ children: [
4191
+ /* @__PURE__ */ jsx("button", {
4192
+ type: "button",
4193
+ onClick: () => stepBy(-1),
4194
+ disabled: decrementDisabled,
4195
+ "aria-label": decrementAriaLabel,
4196
+ "aria-controls": inputId,
4197
+ className: cn$1(stepperButtonClass, decrementDisabled && "opacity-40"),
4198
+ children: /* @__PURE__ */ jsx(Minus, { className: "h-3 w-3" })
4199
+ }),
4200
+ /* @__PURE__ */ jsx(Input, {
4201
+ ref: inputRef,
4202
+ id: inputId,
4203
+ type: "number",
4204
+ min: 1,
4205
+ max: maxQuantity ?? void 0,
4206
+ step: 1,
4207
+ value: inputValue,
4208
+ onFocus: () => {
4209
+ focusEntryQuantityRef.current = currentValue;
4210
+ },
4211
+ onChange: (e) => {
4212
+ const raw = e.target.value;
4213
+ setInputValue(raw);
4214
+ if (raw === "") {
4215
+ if (commitTimerRef.current) clearTimeout(commitTimerRef.current);
4216
+ return;
4217
+ }
4218
+ const next = parseInt(raw, 10);
4219
+ if (Number.isFinite(next) && next > 0) scheduleCommit(clampToBounds(next));
4220
+ },
4221
+ onBlur: () => {
4222
+ if (commitTimerRef.current) clearTimeout(commitTimerRef.current);
4223
+ const parsed = parseInt(inputValue, 10);
4224
+ if (Number.isFinite(parsed) && parsed > 0) {
4225
+ const clamped = clampToBounds(parsed);
4226
+ if (clamped !== parsed) setInputValue(String(clamped));
4227
+ if (clamped !== quantity) onQuantityChange(clamped);
4228
+ focusEntryQuantityRef.current = clamped;
4229
+ } else {
4230
+ const restore = focusEntryQuantityRef.current;
4231
+ setInputValue(String(restore));
4232
+ if (restore !== quantity) onQuantityChange(restore);
4233
+ }
4234
+ },
4235
+ readOnly: isUpdatingQuantity,
4236
+ className: "text-foreground h-7 w-10 rounded-none border-0 bg-transparent px-0 text-center text-xs font-semibold shadow-none [-moz-appearance:textfield] focus-visible:border-0 focus-visible:ring-0 md:text-xs [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
4237
+ "aria-label": quantityAriaLabel
4238
+ }),
4239
+ /* @__PURE__ */ jsx("button", {
4240
+ type: "button",
4241
+ onClick: () => stepBy(1),
4242
+ disabled: incrementDisabled,
4243
+ "aria-label": incrementAriaLabel,
4244
+ "aria-controls": inputId,
4245
+ className: cn$1(stepperButtonClass, incrementDisabled && "opacity-40"),
4246
+ children: /* @__PURE__ */ jsx(Plus, { className: "h-3 w-3" })
4247
+ })
4248
+ ]
4209
4249
  });
4210
4250
  }
4211
4251
  function SubscriptionItemsSection({ subscription, displayQuantity, displayNextBillDate, canEditQuantity = false, onQuantityChange, isUpdatingQuantity = false }) {
@@ -4314,9 +4354,12 @@ function SubscriptionItemsSection({ subscription, displayQuantity, displayNextBi
4314
4354
  }), /* @__PURE__ */ jsx(QuantityInput, {
4315
4355
  inputId: quantityInputId,
4316
4356
  quantity,
4357
+ maxQuantity: subscription.subscription_plan.max_quantity,
4317
4358
  isUpdatingQuantity,
4318
4359
  onQuantityChange,
4319
- quantityAriaLabel: t("quantity_aria")
4360
+ quantityAriaLabel: t("quantity_aria"),
4361
+ decrementAriaLabel: t("decrease_quantity_aria"),
4362
+ incrementAriaLabel: t("increase_quantity_aria")
4320
4363
  })]
4321
4364
  })]
4322
4365
  })
@@ -5699,4 +5742,4 @@ const subscriptionsScreenPropertySchema = {
5699
5742
  //#endregion
5700
5743
  export { SubscriptionsScreen_exports as n, subscriptionsScreenPropertySchema as r, SubscriptionsScreen as t };
5701
5744
 
5702
- //# sourceMappingURL=SubscriptionsScreen-CaDhBQSX.mjs.map
5745
+ //# sourceMappingURL=SubscriptionsScreen-CwtJ0PHm.mjs.map