@vritti/quantum-ui 0.6.9 → 0.6.11
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/Avatar.js +5 -5
- package/dist/Badge2.js +86 -11
- package/dist/Badge2.js.map +1 -1
- package/dist/ChartFrame.js +4 -1
- package/dist/ChartFrame.js.map +1 -1
- package/dist/Checkbox2.js +5 -5
- package/dist/CurrencyFieldFilter.js +60 -34
- package/dist/CurrencyFieldFilter.js.map +1 -1
- package/dist/Dialog.js +1 -1
- package/dist/DropdownMenu.js +6 -1
- package/dist/DropdownMenu.js.map +1 -1
- package/dist/IconSelect.js +2302 -2324
- package/dist/IconSelect.js.map +1 -1
- package/dist/Input.js +1 -1
- package/dist/Input.js.map +1 -1
- package/dist/Label.js +1 -1
- package/dist/OTPField.js +2 -2
- package/dist/OTPField.js.map +1 -1
- package/dist/PhoneField.js +2 -2
- package/dist/PhoneField.js.map +1 -1
- package/dist/Progress.js +2 -2
- package/dist/QuantityField.js +437 -105
- package/dist/QuantityField.js.map +1 -1
- package/dist/RadioGroup.js +7 -7
- package/dist/Select.js +92 -4
- package/dist/Select.js.map +1 -1
- package/dist/Sidebar.js +1 -1
- package/dist/SingleSelect.js +1 -1
- package/dist/SingleSelect.js.map +1 -1
- package/dist/Sonner.js +1 -1
- package/dist/Spinner.js +8 -2
- package/dist/Spinner.js.map +1 -1
- package/dist/Switch.js +5 -5
- package/dist/TabsSkeleton.js +2 -2
- package/dist/TextArea.js +1 -1
- package/dist/TextArea.js.map +1 -1
- package/dist/TextField.js +29 -27
- package/dist/TextField.js.map +1 -1
- package/dist/Toggle.js +1 -1
- package/dist/assets/quantum-ui.css +473 -171
- package/dist/bindFilters.js +14 -1
- package/dist/bindFilters.js.map +1 -1
- package/dist/components/ContextBar.js.map +1 -1
- package/dist/components/QuantityField.js +1 -1
- package/dist/components/RichTextEditor.js +1 -1
- package/dist/components/TreeView.js +4 -4
- package/dist/currencyCode.js +1520 -0
- package/dist/currencyCode.js.map +1 -0
- package/dist/dropdown-menu.js +9 -9
- package/dist/image-component.js +1 -1
- package/dist/index.js +2 -2
- package/dist/index10.js +37 -1499
- package/dist/index10.js.map +1 -1
- package/dist/index11.js +503 -28
- package/dist/index11.js.map +1 -1
- package/dist/index12.js +230 -454
- package/dist/index12.js.map +1 -1
- package/dist/index13.js +1073 -213
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +20 -1139
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +14 -20
- package/dist/index15.js.map +1 -1
- package/dist/index16.js +173 -19
- package/dist/index16.js.map +1 -1
- package/dist/index17.js +173 -168
- package/dist/index17.js.map +1 -1
- package/dist/index18.js +201 -171
- package/dist/index18.js.map +1 -1
- package/dist/index19.js +190 -186
- package/dist/index19.js.map +1 -1
- package/dist/index20.js +204 -202
- package/dist/index20.js.map +1 -1
- package/dist/index21.js +68 -209
- package/dist/index21.js.map +1 -1
- package/dist/index22.js +1128 -70
- package/dist/index22.js.map +1 -1
- package/dist/index23.js +4 -1133
- package/dist/index23.js.map +1 -1
- package/dist/index24.js +232 -4
- package/dist/index24.js.map +1 -1
- package/dist/index25.js +1100 -207
- package/dist/index25.js.map +1 -1
- package/dist/index26.js +2469 -1023
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +35 -2569
- package/dist/index27.js.map +1 -1
- package/dist/index28.js +308 -36
- package/dist/index28.js.map +1 -1
- package/dist/index29.js +7 -307
- package/dist/index29.js.map +1 -1
- package/dist/index30.js +30 -8
- package/dist/index30.js.map +1 -1
- package/dist/index31.js +59 -29
- package/dist/index31.js.map +1 -1
- package/dist/index32.js +10 -59
- package/dist/index32.js.map +1 -1
- package/dist/index33.js +35347 -9
- package/dist/index33.js.map +1 -1
- package/dist/index34.js +72 -35342
- package/dist/index34.js.map +1 -1
- package/dist/index35.js +187 -72
- package/dist/index35.js.map +1 -1
- package/dist/index5.js +4 -4
- package/dist/index9.js +1 -1
- package/dist/lib/components/ContextBar/useContextState.d.ts +7 -1
- package/dist/lib/components/ContextBar/useContextState.d.ts.map +1 -1
- package/dist/lib/components/CurrencyField/CurrencyField.d.ts +8 -4
- package/dist/lib/components/CurrencyField/CurrencyField.d.ts.map +1 -1
- package/dist/lib/components/CurrencyField/CurrencyFieldFilter.d.ts +3 -2
- package/dist/lib/components/CurrencyField/CurrencyFieldFilter.d.ts.map +1 -1
- package/dist/lib/components/DataTable/DataTable.d.ts.map +1 -1
- package/dist/lib/components/DataTable/components/DataTablePagination.d.ts.map +1 -1
- package/dist/lib/components/DataTable/components/DataTableSelectionBar.d.ts +3 -2
- package/dist/lib/components/DataTable/components/DataTableSelectionBar.d.ts.map +1 -1
- package/dist/lib/components/DataTable/hooks/useDataTable.d.ts +4 -1
- package/dist/lib/components/DataTable/hooks/useDataTable.d.ts.map +1 -1
- package/dist/lib/components/DataTable/index.d.ts +1 -1
- package/dist/lib/components/DataTable/index.d.ts.map +1 -1
- package/dist/lib/components/DataTable/types.d.ts +13 -1
- package/dist/lib/components/DataTable/types.d.ts.map +1 -1
- package/dist/lib/components/DataTable/utils.d.ts +2 -2
- package/dist/lib/components/DataTable/utils.d.ts.map +1 -1
- package/dist/lib/components/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/lib/components/DropdownMenu/types.d.ts +2 -0
- package/dist/lib/components/DropdownMenu/types.d.ts.map +1 -1
- package/dist/lib/components/Field/numberConstraints.d.ts +19 -0
- package/dist/lib/components/Field/numberConstraints.d.ts.map +1 -0
- package/dist/lib/components/PhoneField/PhoneField.d.ts.map +1 -1
- package/dist/lib/components/QuantityField/QuantityField.d.ts +11 -1
- package/dist/lib/components/QuantityField/QuantityField.d.ts.map +1 -1
- package/dist/lib/components/QuantityField/index.d.ts +1 -1
- package/dist/lib/components/QuantityField/index.d.ts.map +1 -1
- package/dist/lib/components/QuantityField/quantity.d.ts +14 -0
- package/dist/lib/components/QuantityField/quantity.d.ts.map +1 -1
- package/dist/lib/components/Select/Select.d.ts +3 -0
- package/dist/lib/components/Select/Select.d.ts.map +1 -1
- package/dist/lib/components/Select/hooks/useSelect.d.ts +2 -0
- package/dist/lib/components/Select/hooks/useSelect.d.ts.map +1 -1
- package/dist/lib/components/TextField/TextField.d.ts.map +1 -1
- package/dist/lib/hooks/useWorkspaceCurrency.d.ts +2 -1
- package/dist/lib/hooks/useWorkspaceCurrency.d.ts.map +1 -1
- package/dist/lib/types/conditions.d.ts +2 -1
- package/dist/lib/types/conditions.d.ts.map +1 -1
- package/dist/lib/{components/DataTable/components → utils}/bindFilters.d.ts +2 -1
- package/dist/lib/utils/bindFilters.d.ts.map +1 -0
- package/dist/lib/utils/currency.d.ts +7 -5
- package/dist/lib/utils/currency.d.ts.map +1 -1
- package/dist/lib/utils/currencyCode.d.ts +14 -0
- package/dist/lib/utils/currencyCode.d.ts.map +1 -0
- package/dist/lib/utils/format.d.ts +7 -5
- package/dist/lib/utils/format.d.ts.map +1 -1
- package/dist/lib/utils/money.d.ts +5 -4
- package/dist/lib/utils/money.d.ts.map +1 -1
- package/dist/lib/utils/store.d.ts +3 -0
- package/dist/lib/utils/store.d.ts.map +1 -0
- package/dist/lib/utils/zod.d.ts +3 -1
- package/dist/lib/utils/zod.d.ts.map +1 -1
- package/dist/numberConstraints.js +68 -0
- package/dist/numberConstraints.js.map +1 -0
- package/dist/popover.js +5 -2
- package/dist/popover.js.map +1 -1
- package/dist/react.js +45 -0
- package/dist/react.js.map +1 -0
- package/dist/ruler.js +27 -0
- package/dist/ruler.js.map +1 -0
- package/dist/select2.js +2 -2
- package/dist/select2.js.map +1 -1
- package/dist/separator2.js +1 -1
- package/dist/shadcn/shadcnBadge/Badge.d.ts +5 -2
- package/dist/shadcn/shadcnBadge/Badge.d.ts.map +1 -1
- package/dist/shadcn/shadcnChart/Chart.d.ts.map +1 -1
- package/dist/shadcn/shadcnPopover/index.d.ts +1 -1
- package/dist/shadcn/shadcnPopover/index.d.ts.map +1 -1
- package/dist/shadcn/shadcnPopover/popover.d.ts +2 -1
- package/dist/shadcn/shadcnPopover/popover.d.ts.map +1 -1
- package/dist/tooltip2.js +1 -1
- package/dist/useContextState.js +39 -6
- package/dist/useContextState.js.map +1 -1
- package/dist/useDataTable.js +148 -64
- package/dist/useDataTable.js.map +1 -1
- package/dist/useWorkspaceCurrency.js.map +1 -1
- package/dist/utils/currency.js +3 -14
- package/dist/utils/currency.js.map +1 -1
- package/dist/utils/format.js +14 -6
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/money.js +5 -3
- package/dist/utils/money.js.map +1 -1
- package/dist/utils/motion.js +2 -2
- package/dist/utils/store.js +67 -0
- package/dist/utils/store.js.map +1 -0
- package/dist/utils/zod.js +10 -7
- package/dist/utils/zod.js.map +1 -1
- package/dist/value.js +1 -1
- package/package.json +5 -1
- package/dist/Spinner2.js +0 -10
- package/dist/Spinner2.js.map +0 -1
- package/dist/index36.js +0 -199
- package/dist/index36.js.map +0 -1
- package/dist/lib/components/DataTable/components/bindFilters.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuantityField.js","sources":["../lib/components/QuantityField/quantity.ts","../lib/components/QuantityField/QuantityField.tsx"],"sourcesContent":["import Decimal from '../../utils/decimal';\n\nexport type QuantityUnit = {\n id: string;\n name: string;\n symbol: string;\n // Exact ratio to the primary unit: `primaryUomQty` primary units = `uomQty` of this unit (strip: 10 = 1; primary: 1 = 1)\n primaryUomQty: number;\n uomQty: number;\n};\n\nconst PRIMARY_DECIMALS = 3;\nconst UNIT_DECIMALS = 6;\nconst QUANTITY_PLACEHOLDER = /\\{\\{qty:(-?[\\d.]+)\\}\\}/g;\n\nexport const PRIMARY_UNIT_PLACEHOLDER = '{{primaryUnit}}';\n\n// Parses a typed amount into a Decimal, or null when it is empty or not a finite number\nfunction parseAmount(amount: string): Decimal | null {\n const text = amount.trim();\n if (text === '' || !Number.isFinite(Number(text))) return null;\n return new Decimal(text);\n}\n\n// Converts an amount typed in `unit` to the primary unit, rounded to 3 dp; empty or invalid text gives undefined\nexport function toPrimaryQty(amount: string, unit: QuantityUnit): number | undefined {\n const parsed = parseAmount(amount);\n if (!parsed) return undefined;\n return parsed.times(unit.primaryUomQty).div(unit.uomQty).toDecimalPlaces(PRIMARY_DECIMALS).toNumber();\n}\n\n// Expresses a primary-unit quantity as text in `unit`, without trailing zeros; a missing quantity gives ''\nexport function fromPrimaryQty(primaryQty: number | null | undefined, unit: QuantityUnit): string {\n if (primaryQty == null || !Number.isFinite(primaryQty)) return '';\n return new Decimal(primaryQty).times(unit.uomQty).div(unit.primaryUomQty).toDecimalPlaces(UNIT_DECIMALS).toFixed();\n}\n\n// Names a primary-unit quantity in a validation message; QuantityField shows it in the unit being entered\nexport function quantityPlaceholder(primaryQty: number): string {\n return `{{qty:${primaryQty}}}`;\n}\n\n// Writes a validation message's quantities in the unit being entered and its primary-unit placeholder as that unit\nexport function resolveQuantityMessage(\n message: string,\n unit: QuantityUnit,\n primaryUnit: QuantityUnit,\n formatNumber: (value: number) => string,\n): string {\n return message\n .replace(\n QUANTITY_PLACEHOLDER,\n (_, qty: string) => `${formatNumber(Number(fromPrimaryQty(Number(qty), unit)))} ${unit.symbol}`,\n )\n .split(PRIMARY_UNIT_PLACEHOLDER)\n .join(primaryUnit.symbol);\n}\n","import { ChevronDown } from 'lucide-react';\nimport React from 'react';\nimport { Field, FieldContent, FieldDescription, FieldError, FieldLabel } from '../../../shadcn/shadcnField';\nimport { Spinner } from '../../../shadcn/shadcnSpinner';\nimport { cn } from '../../../shadcn/utils';\nimport { formatNumber } from '../../utils/format';\nimport { getLocale } from '../../utils/locale';\nimport { Select, type SelectOption, type SelectValue } from '../Select';\nimport { fromPrimaryQty, type QuantityUnit, resolveQuantityMessage, toPrimaryQty } from './quantity';\n\nexport interface QuantityFieldProps {\n name?: string;\n units: QuantityUnit[];\n primaryUnitId: string;\n defaultUnitId?: string;\n value?: number | null;\n onChange?: (primaryQty: number | null | undefined) => void;\n onBlur?: () => void;\n nullable?: boolean;\n label?: string;\n description?: string;\n placeholder?: string;\n error?: string;\n disabled?: boolean;\n required?: boolean;\n loading?: boolean;\n className?: string;\n}\n\nconst AMOUNT_PATTERN = /^-?\\d*\\.?\\d*$/;\n\n// Formats a number for the field's hint and messages in the user's locale\nfunction formatAmount(value: number): string {\n return String(formatNumber(value, { localeTag: getLocale() ?? 'en-US' }).primary);\n}\n\n// Quantity input typed in any of an item's units, starting in the default unit; the value is the amount in the primary\n// unit, null when emptied where nullable, and quantities named in its error are shown in the unit being entered\nexport const QuantityField = React.forwardRef<HTMLInputElement, QuantityFieldProps>(\n (\n {\n units,\n primaryUnitId,\n defaultUnitId,\n value,\n onChange,\n onBlur,\n nullable,\n label,\n description,\n placeholder,\n error,\n disabled,\n required,\n loading,\n className,\n },\n ref,\n ) => {\n const fieldId = React.useId();\n const [pickedUnitId, setPickedUnitId] = React.useState<string>();\n const [text, setText] = React.useState('');\n // The primary quantity and unit the text stands for; a value matching both came from this field\n const shown = React.useRef<{ qty: number | undefined; unitId: string } | null>(null);\n\n const unit =\n units.find((option) => option.id === pickedUnitId) ??\n units.find((option) => option.id === defaultUnitId) ??\n units.find((option) => option.id === primaryUnitId);\n const primaryUnit = units.find((option) => option.id === primaryUnitId);\n const isDisabled = !!disabled || !!loading || !unit;\n const options = React.useMemo<SelectOption[]>(\n () => units.map((option) => ({ value: option.id, label: option.symbol, description: option.name })),\n [units],\n );\n\n // A value set from outside (reset, setValue, edit defaults) or a unit arriving late rewrites the text\n React.useEffect(() => {\n if (!unit) return;\n const qty = value ?? undefined;\n if (shown.current && shown.current.qty === qty && shown.current.unitId === unit.id) return;\n shown.current = { qty, unitId: unit.id };\n setText(fromPrimaryQty(qty, unit));\n }, [value, unit]);\n\n // Records what the text now stands for and reports the primary quantity when it changed\n const emit = (nextText: string, nextUnit: QuantityUnit) => {\n const qty = toPrimaryQty(nextText, nextUnit);\n const previous = shown.current?.qty;\n shown.current = { qty, unitId: nextUnit.id };\n if (qty !== previous) onChange?.(qty === undefined && nullable ? null : qty);\n };\n\n // Keeps the typed amount when it reads as a number and reports it in the primary unit\n const handleTextChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (!AMOUNT_PATTERN.test(event.target.value)) return;\n setText(event.target.value);\n if (unit) emit(event.target.value, unit);\n };\n\n // Reads the typed amount in the picked unit instead\n const handleUnitChange = (next: SelectValue) => {\n const nextUnit = units.find((option) => option.id === next);\n if (!nextUnit) return;\n setPickedUnitId(nextUnit.id);\n emit(text, nextUnit);\n };\n\n const showHint = !!unit && !!primaryUnit && unit.id !== primaryUnit.id && value != null;\n const message =\n error && unit && primaryUnit ? resolveQuantityMessage(error, unit, primaryUnit, formatAmount) : error;\n const describedBy =\n [\n showHint && `${fieldId}-hint`,\n description && !message && `${fieldId}-description`,\n message && `${fieldId}-error`,\n ]\n .filter(Boolean)\n .join(' ') || undefined;\n\n return (\n <Field data-disabled={isDisabled}>\n {label && <FieldLabel htmlFor={fieldId}>{label}</FieldLabel>}\n <FieldContent>\n <div\n className={cn(\n 'flex h-9 w-full items-stretch rounded-md border border-input bg-transparent shadow-xs transition-[color,box-shadow] dark:bg-input/30',\n 'focus-within:border-ring focus-within:ring-1 focus-within:ring-ring/50',\n isDisabled && 'cursor-not-allowed opacity-50',\n message && 'border-destructive focus-within:ring-destructive/20 dark:focus-within:ring-destructive/40',\n className,\n )}\n >\n <input\n ref={ref}\n id={fieldId}\n type=\"text\"\n inputMode=\"decimal\"\n autoComplete=\"off\"\n value={text}\n onChange={handleTextChange}\n onBlur={onBlur}\n disabled={isDisabled}\n required={required}\n placeholder={placeholder}\n aria-invalid={!!message}\n aria-busy={loading || undefined}\n aria-describedby={describedBy}\n className=\"min-w-0 flex-1 bg-transparent px-3 py-1 text-sm tabular-nums outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed\"\n />\n <div className=\"flex w-28 shrink-0 items-stretch border-l border-input\">\n <Select\n options={options}\n value={unit?.id ?? null}\n onChange={handleUnitChange}\n disabled={isDisabled}\n clearable={false}\n label=\"\"\n contentClassName=\"min-w-40\"\n anchor={({ selectedOption, open, disabled: anchorDisabled }) => (\n <button\n type=\"button\"\n disabled={anchorDisabled}\n aria-label=\"Unit\"\n aria-expanded={open}\n className=\"flex h-full w-full items-center justify-between gap-1 rounded-r-md px-3 text-sm font-medium text-foreground outline-none hover:bg-accent/50 focus-visible:bg-accent/50 disabled:cursor-not-allowed\"\n >\n {loading ? (\n <Spinner className=\"size-3.5 text-muted-foreground\" />\n ) : (\n <span className=\"truncate\">{selectedOption?.label ?? unit?.symbol ?? '—'}</span>\n )}\n <ChevronDown\n className={cn(\n 'size-3.5 shrink-0 text-muted-foreground transition-transform',\n open && 'rotate-180',\n )}\n />\n </button>\n )}\n />\n </div>\n </div>\n {showHint && (\n <p id={`${fieldId}-hint`} aria-live=\"polite\" className=\"text-xs tabular-nums text-muted-foreground\">\n = {formatAmount(value)} {primaryUnit.symbol}\n </p>\n )}\n {description && !message && <FieldDescription id={`${fieldId}-description`}>{description}</FieldDescription>}\n {message && <FieldError id={`${fieldId}-error`}>{message}</FieldError>}\n </FieldContent>\n </Field>\n );\n },\n);\nQuantityField.displayName = 'QuantityField';\n"],"names":["React"],"mappings":";;;;;;;;;;;AAWA,MAAM,gBAAA,GAAmB,CAAA;AACzB,MAAM,aAAA,GAAgB,CAAA;AACtB,MAAM,oBAAA,GAAuB,yBAAA;AAEtB,MAAM,wBAAA,GAA2B;AAGxC,SAAS,YAAY,MAAA,EAAgC;AACnD,EAAA,MAAM,IAAA,GAAO,OAAO,IAAA,EAAK;AACzB,EAAA,IAAI,IAAA,KAAS,MAAM,CAAC,MAAA,CAAO,SAAS,MAAA,CAAO,IAAI,CAAC,CAAA,EAAG,OAAO,IAAA;AAC1D,EAAA,OAAO,IAAI,QAAQ,IAAI,CAAA;AACzB;AAGO,SAAS,YAAA,CAAa,QAAgB,IAAA,EAAwC;AACnF,EAAA,MAAM,MAAA,GAAS,YAAY,MAAM,CAAA;AACjC,EAAA,IAAI,CAAC,QAAQ,OAAO,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A,EAAU,UAAA,EAAY,QAAA,EAAA,cAAA,EAAgB,KAAA,IAAS,IAAA,EAAM,UAAU,GAAA,EAAI,CAAA;AAAA,wCAE3E,GAAA;AAAA,0BAAC,WAAA;AAAA,0BAAA;AAAA,4BACC,SAAA,EAAW,EAAA;AAAA,8BACT,8DAAA;AAAA,8BACA,IAAA,IAAQ;AAAA;AACV;AAAA;AACF;AAAA;AAAA;AACF;AAAA,eAEJ,EACF;AAAA;AAAA;AAAA,SACF;AAAA,QACC,QAAA,oBACC,IAAA,CAAC,GAAA,EAAA,EAAE,EAAA,EAAI,CAAA,EAAG,OAAO,CAAA,KAAA,CAAA,EAAS,WAAA,EAAU,QAAA,EAAS,SAAA,EAAU,4CAAA,EAA6C,QAAA,EAAA;AAAA,UAAA,IAAA;AAAA,UAC/F,aAAa,KAAK,CAAA;AAAA,UAAE,GAAA;AAAA,UAAE,WAAA,CAAY;AAAA,SAAA,EACvC,CAAA;AAAA,QAED,WAAA,IAAe,CAAC,OAAA,oBAAW,GAAA,CAAC,oBAAiB,EAAA,EAAI,CAAA,EAAG,OAAO,CAAA,YAAA,CAAA,EAAiB,QAAA,EAAA,WAAA,EAAY,CAAA;AAAA,QACxF,2BAAW,GAAA,CAAC,UAAA,EAAA,EAAW,IAAI,CAAA,EAAG,OAAO,UAAW,QAAA,EAAA,OAAA,EAAQ;AAAA,OAAA,EAC3D;AAAA,KAAA,EACF,CAAA;AAAA,EAEJ;AACF;AACA,aAAA,CAAc,WAAA,GAAc,eAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"QuantityField.js","sources":["../lib/components/QuantityField/quantity.ts","../lib/components/QuantityField/QuantityField.tsx"],"sourcesContent":["import Decimal from '../../utils/decimal';\nimport type { DisplayQuantity } from '../../utils/format';\n\nexport type QuantityUnit = {\n id: string;\n name: string;\n symbol: string;\n // Exact ratio to the primary unit: `primaryUomQty` primary units = `uomQty` of this unit (strip: 10 = 1; primary: 1 = 1)\n primaryUomQty: number;\n uomQty: number;\n // Whether the unit is one of the item's own pack conversions (box, strip) rather than a unit of its primary unit's\n // family (L, kg); a unit that doesn't say counts as a pack\n isPack?: boolean;\n};\n\nconst PRIMARY_DECIMALS = 3;\nconst UNIT_DECIMALS = 6;\nconst QUANTITY_PLACEHOLDER = /\\{\\{qty:(-?[\\d.]+)\\}\\}/g;\n\nexport const PRIMARY_UNIT_PLACEHOLDER = '{{primaryUnit}}';\n\n// Parses a typed amount into a Decimal, or null when it is empty or not a finite number\nfunction parseAmount(amount: string): Decimal | null {\n const text = amount.trim();\n if (text === '' || !Number.isFinite(Number(text))) return null;\n return new Decimal(text);\n}\n\n// Converts an amount typed in `unit` to the primary unit, rounded to 3 dp; empty or invalid text gives undefined\nexport function toPrimaryQty(amount: string, unit: QuantityUnit): number | undefined {\n const parsed = parseAmount(amount);\n if (!parsed) return undefined;\n return parsed.times(unit.primaryUomQty).div(unit.uomQty).toDecimalPlaces(PRIMARY_DECIMALS).toNumber();\n}\n\n// Expresses a primary-unit quantity as text in `unit`, without trailing zeros; a missing quantity gives ''\nexport function fromPrimaryQty(primaryQty: number | null | undefined, unit: QuantityUnit): string {\n if (primaryQty == null || !Number.isFinite(primaryQty)) return '';\n return new Decimal(primaryQty).times(unit.uomQty).div(unit.primaryUomQty).toDecimalPlaces(UNIT_DECIMALS).toFixed();\n}\n\n// One unit's share of a quantity: how many of `unit` it takes\nexport type QuantityPiece = { unit: QuantityUnit; amount: Decimal };\n\n// Primary units in one of `unit` (strip of 10: 10; a pack of 5 tab sold as 2: 2.5)\nexport function unitSize(unit: QuantityUnit): Decimal {\n return new Decimal(unit.primaryUomQty).div(unit.uomQty);\n}\n\n// A pack is one of the item's own conversions (box, strip); a unit of the primary unit's family (L, kg) is not, and\n// never takes a share of a breakdown. Units that don't say are packs\nfunction isPackUnit(unit: QuantityUnit, primaryUnitId: string): boolean {\n return unit.id !== primaryUnitId && unit.isPack !== false;\n}\n\n// The units a quantity read in `anchor` breaks down through: the anchor, then — when cascading — every smaller pack\n// that fits evenly into the one above it, largest first; the primary unit takes the rest\nfunction packLadder(anchor: QuantityUnit, units: QuantityUnit[], primaryUnitId: string, cascade: boolean) {\n const ladder = [anchor];\n if (!cascade) return ladder;\n const smaller = units\n .filter((unit) => isPackUnit(unit, primaryUnitId) && unit.id !== anchor.id)\n .filter((unit) => unitSize(unit).lt(unitSize(anchor)) && unitSize(unit).gt(1))\n .sort((a, b) => unitSize(b).cmp(unitSize(a)));\n for (const unit of smaller) {\n if (\n unitSize(ladder[ladder.length - 1])\n .mod(unitSize(unit))\n .isZero()\n )\n ladder.push(unit);\n }\n return ladder;\n}\n\n// Splits a primary quantity as it reads in the anchor unit. A pack anchor takes whole packs — then, when cascading, whole\n// units of every smaller pack that fits evenly into the one above (952 tab in boxes: 9 box, 5 strip, 2 tab) — and the\n// primary unit takes what is left, decimals included. A family unit (L, kg) reads as one exact figure\nexport function breakDownQty(\n primaryQty: number,\n units: QuantityUnit[],\n anchorUnitId: string,\n primaryUnitId: string,\n cascade = false,\n): QuantityPiece[] {\n const primary = units.find((unit) => unit.id === primaryUnitId);\n if (!primary || !Number.isFinite(primaryQty)) return [];\n const anchor = units.find((unit) => unit.id === anchorUnitId) ?? primary;\n const total = new Decimal(primaryQty);\n if (anchor.id !== primary.id && !isPackUnit(anchor, primaryUnitId)) {\n return [{ unit: anchor, amount: total.div(unitSize(anchor)).toDecimalPlaces(PRIMARY_DECIMALS) }];\n }\n const pieces: QuantityPiece[] = [];\n let left = total;\n if (anchor.id !== primary.id) {\n for (const unit of packLadder(anchor, units, primaryUnitId, cascade)) {\n const amount = left.div(unitSize(unit)).floor();\n pieces.push({ unit, amount });\n left = left.minus(amount.times(unitSize(unit)));\n }\n }\n pieces.push({ unit: primary, amount: left.toDecimalPlaces(PRIMARY_DECIMALS) });\n return pieces;\n}\n\n// The units the breakdown panel takes entries in, largest first: the primary unit, every pack, and the anchor when it is\n// a family unit\nexport function entryUnits(units: QuantityUnit[], primaryUnitId: string, anchorUnitId: string | undefined) {\n return units\n .filter((unit) => unit.id === primaryUnitId || unit.id === anchorUnitId || isPackUnit(unit, primaryUnitId))\n .sort((a, b) => unitSize(b).cmp(unitSize(a)));\n}\n\n// Whether a unit's entry may have decimals: the primary unit and its family units, when the primary unit allows them\nexport function takesDecimals(unit: QuantityUnit, primaryUnitId: string, allowDecimal: boolean): boolean {\n return allowDecimal && !isPackUnit(unit, primaryUnitId);\n}\n\n// A primary quantity as the server reads it in the item's display unit, for quantities it hasn't seen yet (levels being\n// typed): the exact figure, whole display units and the primary units left over, and — for a pack — the breakdown,\n// through every smaller pack when cascading. Null until the primary unit is among the units\nexport function toDisplayQuantity(\n primaryQty: number,\n units: QuantityUnit[],\n primaryUnitId: string,\n displayUnitId: string,\n cascade = false,\n): Required<DisplayQuantity> | null {\n const primary = units.find((unit) => unit.id === primaryUnitId);\n if (!primary || !Number.isFinite(primaryQty)) return null;\n const display = units.find((unit) => unit.id === displayUnitId) ?? primary;\n const size = unitSize(display);\n const total = new Decimal(primaryQty);\n const whole = total.div(size).trunc();\n const isPack = isPackUnit(display, primaryUnitId);\n const breakdown =\n isPack && primaryQty >= 0\n ? breakDownQty(primaryQty, units, display.id, primaryUnitId, cascade)\n .filter((piece) => !piece.amount.isZero())\n .map((piece) => ({ qty: piece.amount.toNumber(), symbol: piece.unit.symbol }))\n : [];\n return {\n primaryUomQty: primaryQty,\n displayUomQty: total.div(size).toDecimalPlaces(PRIMARY_DECIMALS).toNumber(),\n wholeDisplayUomQty: whole.toNumber(),\n remainderPrimaryUomQty: total.minus(whole.times(size)).toDecimalPlaces(PRIMARY_DECIMALS).toNumber(),\n displayUomSymbol: display.symbol,\n primaryUomSymbol: primary.symbol,\n isPack,\n breakdown,\n };\n}\n\n// Adds up the amounts typed per unit into the primary unit, rounded to 3 dp; nothing typed gives undefined\nexport function sumParts(parts: Record<string, string>, units: QuantityUnit[]): number | undefined {\n let total: Decimal | null = null;\n for (const unit of units) {\n const amount = parseAmount(parts[unit.id] ?? '');\n if (amount) total = (total ?? new Decimal(0)).plus(amount.times(unitSize(unit)));\n }\n return total?.toDecimalPlaces(PRIMARY_DECIMALS).toNumber();\n}\n\n// The amounts per unit a primary quantity is entered as: its breakdown in a pack anchor, zero shares left out, or all of\n// it in the primary unit when the anchor is a family unit; nothing at all reads as 0 in the unit it is entered in\nexport function partsOfQty(\n primaryQty: number | null | undefined,\n units: QuantityUnit[],\n anchorUnitId: string,\n primaryUnitId: string,\n cascade = false,\n): Record<string, string> {\n if (primaryQty == null) return {};\n const anchor = units.find((unit) => unit.id === anchorUnitId);\n const enteredIn = anchor && isPackUnit(anchor, primaryUnitId) ? anchorUnitId : primaryUnitId;\n const parts = breakDownQty(primaryQty, units, enteredIn, primaryUnitId, cascade).filter(\n (piece) => !piece.amount.isZero(),\n );\n if (parts.length === 0) return { [enteredIn]: '0' };\n return Object.fromEntries(parts.map((piece) => [piece.unit.id, piece.amount.toFixed()]));\n}\n\n// Names a primary-unit quantity in a validation message; QuantityField shows it in the unit being entered\nexport function quantityPlaceholder(primaryQty: number): string {\n return `{{qty:${primaryQty}}}`;\n}\n\n// Writes a validation message's quantities in the unit being entered and its primary-unit placeholder as that unit\nexport function resolveQuantityMessage(\n message: string,\n unit: QuantityUnit,\n primaryUnit: QuantityUnit,\n formatNumber: (value: number) => string,\n): string {\n return message\n .replace(\n QUANTITY_PLACEHOLDER,\n (_, qty: string) => `${formatNumber(Number(fromPrimaryQty(Number(qty), unit)))} ${unit.symbol}`,\n )\n .split(PRIMARY_UNIT_PLACEHOLDER)\n .join(primaryUnit.symbol);\n}\n","import { ChevronDown, Ruler } from 'lucide-react';\nimport React from 'react';\nimport { Field, FieldContent, FieldDescription, FieldError, FieldLabel } from '../../../shadcn/shadcnField';\nimport { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from '../../../shadcn/shadcnPopover';\nimport { Spinner } from '../../../shadcn/shadcnSpinner';\nimport { cn } from '../../../shadcn/utils';\nimport { formatNumber } from '../../utils/format';\nimport { getLocale } from '../../utils/locale';\nimport { Button } from '../Button';\nimport { BoundAfterValue, boundWords, isOutOfBounds, NumberFieldLabelRow } from '../Field/numberConstraints';\nimport { Select, type SelectOption, type SelectValue } from '../Select';\nimport {\n breakDownQty,\n entryUnits,\n fromPrimaryQty,\n partsOfQty,\n type QuantityUnit,\n resolveQuantityMessage,\n sumParts,\n takesDecimals,\n unitSize,\n} from './quantity';\n\nexport interface QuantityFieldProps {\n name?: string;\n units: QuantityUnit[];\n primaryUnitId: string;\n // The unit the field reads in until another is picked — usually the item's display unit\n defaultUnitId?: string;\n // The unit the field reads in, when the caller owns it (a PO line in the supplier's unit)\n anchorUnitId?: string;\n onAnchorUnitChange?: (unitId: string) => void;\n // The only units it may read in (a supplier's selling units); the rest are still entered through the breakdown. Every\n // unit without it\n anchorUnitIds?: string[];\n // Whether the primary unit (and its family units, L or kg) takes decimals; packs are entered in whole numbers\n allowDecimal?: boolean;\n // Read through every pack between the anchor and the primary unit (9 box + 5 strip + 2 tab) instead of the anchor and\n // the primary units left over (9 box + 52 tab) — the item's own setting\n cascade?: boolean;\n // Table-cell density: tighter padding and the breakdown without \"+\" (\"9 box 5 strip 2 tab\")\n compact?: boolean;\n value?: number | null;\n onChange?: (primaryQty: number | null | undefined) => void;\n onBlur?: () => void;\n nullable?: boolean;\n label?: string;\n description?: string;\n placeholder?: string;\n error?: string;\n disabled?: boolean;\n required?: boolean;\n loading?: boolean;\n className?: string;\n // The bounds the quantity keeps, in the primary unit; read in words right after the value, in the unit the field reads\n // in (\"of 4\", \"min 2\", \"2 to 4\"). The form's schema enforces them\n min?: number;\n max?: number;\n // Above zero, and never zero; shown as rule chips on the label row, with \"Int\" while the unit the field reads in takes\n // whole numbers only\n positive?: boolean;\n nonZero?: boolean;\n}\n\nconst WHOLE_PATTERN = /^\\d*$/;\nconst DECIMAL_PATTERN = /^\\d*\\.?\\d{0,3}$/;\nconst DIGIT_KEY = /^\\d$/;\n\n// Formats a number for the field's reading and messages in the user's locale\nfunction formatAmount(value: number): string {\n return String(formatNumber(value, { localeTag: getLocale() ?? 'en-US' }).primary);\n}\n\n// Quantity of an item in any mix of its units. While the quantity reads as a whole number of its anchor unit (or is\n// empty) it is typed straight into the field, in that unit; once it breaks down through smaller units (\"9 box + 5 strip\n// + 2 tab\") the field shows that reading, and clicking it — or arrow down in the input — opens a panel with one input\n// per unit. The unit at the end changes the unit it reads in. An item with a single unit is a plain input. The value is\n// the sum in the primary unit, null when emptied where nullable\nexport const QuantityField = React.forwardRef<HTMLElement, QuantityFieldProps>(\n (\n {\n units,\n primaryUnitId,\n defaultUnitId,\n anchorUnitId,\n onAnchorUnitChange,\n anchorUnitIds,\n allowDecimal = false,\n cascade = false,\n compact,\n value,\n onChange,\n onBlur,\n nullable,\n label,\n description,\n placeholder = 'Qty',\n error,\n disabled,\n required,\n loading,\n className,\n min,\n max,\n positive,\n nonZero,\n },\n ref,\n ) => {\n const fieldId = React.useId();\n const [pickedUnitId, setPickedUnitId] = React.useState<string>();\n const [parts, setParts] = React.useState<Record<string, string>>({});\n const [open, setOpen] = React.useState(false);\n // The primary quantity the typed parts stand for; a value matching it came from this field\n const shown = React.useRef<{ qty: number | undefined } | null>(null);\n const focusTarget = React.useRef<HTMLButtonElement | HTMLInputElement | null>(null);\n const fieldBox = React.useRef<HTMLDivElement>(null);\n const panel = React.useRef<HTMLDivElement>(null);\n const rowInputs = React.useRef(new Map<string, HTMLInputElement>());\n React.useImperativeHandle(ref, () => focusTarget.current as HTMLElement);\n\n const primaryUnit = units.find((unit) => unit.id === primaryUnitId);\n const anchorUnits = React.useMemo(\n () => (anchorUnitIds ? units.filter((unit) => anchorUnitIds.includes(unit.id)) : units),\n [units, anchorUnitIds],\n );\n const anchor =\n anchorUnits.find((unit) => unit.id === (anchorUnitId ?? pickedUnitId)) ??\n anchorUnits.find((unit) => unit.id === defaultUnitId) ??\n anchorUnits.find((unit) => unit.id === primaryUnitId) ??\n anchorUnits[0];\n const singleUnit = units.length === 1 && !!primaryUnit;\n const isDisabled = !!disabled || !!loading || !anchor;\n // The units it may read in, largest first like the panel's rows\n const options = React.useMemo<SelectOption[]>(\n () =>\n [...anchorUnits]\n .sort((a, b) => unitSize(b).cmp(unitSize(a)))\n .map((unit) => ({ value: unit.id, label: unit.symbol, description: unit.name })),\n [anchorUnits],\n );\n // The panel's rows, largest first: the packs, the primary unit, and the anchor when it is a family unit (L, kg)\n const ladder = React.useMemo(() => entryUnits(units, primaryUnitId, anchor?.id), [units, primaryUnitId, anchor]);\n\n // A value set from outside (reset, setValue, edit defaults) or units arriving late re-enter it as its breakdown\n React.useEffect(() => {\n if (!primaryUnit || !anchor) return;\n const qty = value ?? undefined;\n if (shown.current && shown.current.qty === qty) return;\n shown.current = { qty };\n setParts(partsOfQty(qty, units, anchor.id, primaryUnit.id, cascade));\n }, [value, units, anchor, primaryUnit, cascade]);\n\n // Keeps the typed parts and reports their sum in the primary unit when it changed\n const commit = (next: Record<string, string>) => {\n setParts(next);\n const qty = sumParts(next, units);\n const previous = shown.current?.qty;\n shown.current = { qty };\n if (qty !== previous) onChange?.(qty === undefined && nullable ? null : qty);\n };\n\n // Takes a unit's typed amount when it reads as one: whole packs, decimals only where the primary unit allows them\n const enter = (unit: QuantityUnit, text: string) => {\n const pattern = takesDecimals(unit, primaryUnitId, allowDecimal) ? DECIMAL_PATTERN : WHOLE_PATTERN;\n if (!pattern.test(text)) return;\n commit({ ...parts, [unit.id]: text });\n };\n\n // Reads the quantity in the picked unit instead\n const handleAnchorChange = (next: SelectValue) => {\n const unit = units.find((option) => option.id === next);\n if (!unit) return;\n setPickedUnitId(unit.id);\n onAnchorUnitChange?.(unit.id);\n };\n\n // Puts the cursor at the end of a unit's row in the panel\n const focusRow = (unitId: string | undefined) => {\n const input = unitId ? rowInputs.current.get(unitId) : undefined;\n if (!input) return;\n input.focus();\n input.setSelectionRange(input.value.length, input.value.length);\n };\n\n // Leaving the typed amount for the unit picker or the panel is still entering the quantity: the panel closing reports\n // the blur instead\n const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n const next = event.relatedTarget;\n if (next && (fieldBox.current?.contains(next) || panel.current?.contains(next))) return;\n onBlur?.();\n };\n\n const handleOpenChange = (next: boolean) => {\n setOpen(next);\n if (!next) onBlur?.();\n };\n\n // A digit typed on the reading opens the panel with it in the anchor unit's row; arrow down just opens it\n const handleReadingKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (!anchor) return;\n if (DIGIT_KEY.test(event.key)) {\n event.preventDefault();\n const typed = Object.values(parts).filter((amount) => amount !== '' && Number(amount) !== 0).length;\n if (typed <= 1) commit({ [anchor.id]: event.key });\n setOpen(true);\n } else if (event.key === 'ArrowDown') {\n event.preventDefault();\n setOpen(true);\n }\n };\n\n // Enter and the arrows move between the rows; Enter on the last row closes the panel\n const handleRowKeyDown = (event: React.KeyboardEvent<HTMLInputElement>, index: number) => {\n if (event.key !== 'Enter' && event.key !== 'ArrowDown' && event.key !== 'ArrowUp') return;\n event.preventDefault();\n const next = ladder[index + (event.key === 'ArrowUp' ? -1 : 1)];\n if (next) focusRow(next.id);\n else if (event.key === 'Enter') handleOpenChange(false);\n };\n\n const total = sumParts(parts, units);\n const pieces =\n total === undefined || !anchor || !primaryUnit\n ? []\n : breakDownQty(total, units, anchor.id, primaryUnit.id, cascade);\n const shownPieces = pieces.filter((piece) => !piece.amount.isZero());\n const reading =\n total === undefined || !anchor\n ? null\n : shownPieces.length === 0\n ? `0 ${anchor.symbol}`\n : shownPieces\n .map((piece) => `${formatAmount(piece.amount.toNumber())} ${piece.unit.symbol}`)\n .join(compact ? ' ' : ' + ');\n\n // Whether the quantity reads in the anchor unit alone, so it can be typed straight into the field\n const inAnchorAlone =\n !!anchor && (shownPieces.length === 0 || (shownPieces.length === 1 && shownPieces[0].unit.id === anchor.id));\n // What the field's own input shows: the anchor amount as typed while it is the only part, else the total re-read in\n // the anchor unit (after the unit is changed, or a value arrives from outside)\n const typedOnly = !!anchor && Object.keys(parts).every((unitId) => unitId === anchor.id || !parts[unitId]);\n const anchorText = !anchor ? '' : typedOnly ? (parts[anchor.id] ?? '') : fromPrimaryQty(total, anchor);\n\n // Takes the quantity typed straight into the field as the whole of it, in the anchor unit\n const enterInAnchor = (text: string) => {\n if (!anchor) return;\n const pattern = takesDecimals(anchor, primaryUnitId, allowDecimal) ? DECIMAL_PATTERN : WHOLE_PATTERN;\n if (!pattern.test(text)) return;\n commit({ [anchor.id]: text });\n };\n\n // Arrow down in the input opens the panel, to enter the quantity through several units\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key !== 'ArrowDown') return;\n event.preventDefault();\n setOpen(true);\n };\n\n // A bound as it reads after the value: the bare amount while it is a whole amount of the anchor unit, named beside the\n // value by the unit picker, else the anchor unit and the smaller ones it breaks down through, each with its symbol\n const boundReading = (qty: number) => {\n if (!anchor || !primaryUnit) return formatAmount(qty);\n const boundPieces = breakDownQty(qty, units, anchor.id, primaryUnit.id, cascade).filter(\n (piece) => !piece.amount.isZero(),\n );\n if (boundPieces.length === 0) return formatAmount(0);\n if (boundPieces.length === 1 && boundPieces[0].unit.id === anchor.id) {\n return formatAmount(boundPieces[0].amount.toNumber());\n }\n return boundPieces.map((piece) => `${formatAmount(piece.amount.toNumber())} ${piece.unit.symbol}`).join(' + ');\n };\n const bound = boundWords(\n min === undefined ? undefined : boundReading(min),\n max === undefined ? undefined : boundReading(max),\n );\n const outOfBounds = isOutOfBounds(total, min, max);\n // Whether the unit the field reads in takes whole numbers only, the Int rule on the label row\n const wholeOnly = anchor ? !takesDecimals(anchor, primaryUnitId, allowDecimal) : !allowDecimal;\n const inputBound = (text: string) =>\n bound ? (\n <BoundAfterValue\n text={text || placeholder}\n bound={bound}\n outOfBounds={outOfBounds}\n className={cn('text-sm tabular-nums', compact ? 'pl-2.5' : 'pl-3')}\n />\n ) : null;\n\n const message =\n error && anchor && primaryUnit ? resolveQuantityMessage(error, anchor, primaryUnit, formatAmount) : error;\n const describedBy =\n [description && !message && `${fieldId}-description`, message && `${fieldId}-error`].filter(Boolean).join(' ') ||\n undefined;\n const boxClass = cn(\n 'relative flex h-9 w-full items-stretch rounded-md border border-input shadow-xs transition-[color,box-shadow] bg-input/30',\n 'focus-within:border-ring focus-within:ring-1 focus-within:ring-ring/50',\n open && 'border-ring ring-1 ring-ring/50',\n isDisabled && 'cursor-not-allowed opacity-50',\n message &&\n 'border-destructive ring-destructive/20 dark:ring-destructive/40 focus-within:border-destructive focus-within:ring-destructive/20 dark:focus-within:ring-destructive/40',\n className,\n );\n\n return (\n <Field data-disabled={isDisabled}>\n {label && (\n <NumberFieldLabelRow integer={wholeOnly} positive={positive} nonZero={nonZero}>\n <FieldLabel htmlFor={fieldId}>{label}</FieldLabel>\n </NumberFieldLabelRow>\n )}\n <FieldContent>\n {singleUnit ? (\n <div className={boxClass}>\n <input\n ref={(node) => {\n focusTarget.current = node;\n }}\n id={fieldId}\n type=\"text\"\n inputMode={allowDecimal ? 'decimal' : 'numeric'}\n autoComplete=\"off\"\n value={parts[primaryUnit.id] ?? ''}\n onChange={(event) => enter(primaryUnit, event.target.value)}\n onBlur={onBlur}\n disabled={isDisabled}\n required={required}\n placeholder={placeholder}\n aria-invalid={!!message}\n aria-describedby={describedBy}\n className={cn(\n 'min-w-0 flex-1 bg-transparent py-1 text-sm tabular-nums outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed',\n compact ? 'px-2.5' : 'px-3',\n )}\n />\n {inputBound(parts[primaryUnit.id] ?? '')}\n <span\n className={cn(\n 'flex shrink-0 items-center rounded-r-md border-l border-input bg-muted/60 text-sm font-medium text-muted-foreground',\n compact ? 'px-2' : 'px-3',\n )}\n >\n {primaryUnit.symbol}\n </span>\n </div>\n ) : (\n <Popover open={open} onOpenChange={handleOpenChange}>\n <PopoverAnchor asChild>\n <div ref={fieldBox} className={boxClass}>\n {inAnchorAlone && anchor ? (\n <input\n ref={(node) => {\n focusTarget.current = node;\n }}\n id={fieldId}\n type=\"text\"\n inputMode={takesDecimals(anchor, primaryUnitId, allowDecimal) ? 'decimal' : 'numeric'}\n autoComplete=\"off\"\n value={anchorText}\n onChange={(event) => enterInAnchor(event.target.value)}\n onKeyDown={handleInputKeyDown}\n onBlur={handleInputBlur}\n disabled={isDisabled}\n required={required}\n placeholder={placeholder}\n aria-invalid={!!message}\n aria-busy={loading || undefined}\n aria-describedby={describedBy}\n className={cn(\n 'min-w-0 flex-1 rounded-l-md bg-transparent py-1 text-sm tabular-nums outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed',\n compact ? 'px-2.5' : 'px-3',\n )}\n />\n ) : null}\n {inAnchorAlone && anchor ? inputBound(anchorText) : null}\n {inAnchorAlone && anchor ? (\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n disabled={isDisabled}\n aria-label=\"Enter the quantity by unit\"\n title=\"Enter by unit (or arrow down)\"\n className={cn(\n 'flex shrink-0 items-center text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground disabled:cursor-not-allowed',\n compact ? 'px-1.5' : 'px-2',\n open && 'text-foreground',\n )}\n >\n <Ruler className=\"size-3.5\" />\n </button>\n </PopoverTrigger>\n ) : (\n <PopoverTrigger asChild>\n <button\n ref={(node) => {\n focusTarget.current = node;\n }}\n id={fieldId}\n type=\"button\"\n disabled={isDisabled}\n title={reading ?? undefined}\n onKeyDown={handleReadingKeyDown}\n aria-invalid={!!message}\n aria-busy={loading || undefined}\n aria-describedby={describedBy}\n className={cn(\n 'flex min-w-0 flex-1 items-center rounded-l-md text-left text-sm tabular-nums outline-none disabled:cursor-not-allowed',\n compact ? 'px-2.5' : 'px-3',\n )}\n >\n <span className={cn('min-w-0 truncate', !reading && 'text-muted-foreground')}>\n {reading ?? placeholder}\n </span>\n {bound && (\n <span\n aria-hidden\n className={cn(\n 'ml-1.5 shrink-0 text-xs text-muted-foreground',\n outOfBounds && 'text-destructive',\n )}\n >\n {bound}\n </span>\n )}\n </button>\n </PopoverTrigger>\n )}\n <div className=\"flex shrink-0 items-stretch border-l border-input\">\n <Select\n options={options}\n value={anchor?.id ?? null}\n onChange={handleAnchorChange}\n disabled={isDisabled}\n clearable={false}\n label=\"\"\n contentClassName=\"min-w-40\"\n anchor={({ selectedOption, open: unitsOpen, disabled: anchorDisabled }) => (\n <button\n type=\"button\"\n disabled={anchorDisabled}\n aria-label=\"Read the quantity in\"\n aria-expanded={unitsOpen}\n className={cn(\n 'flex h-full items-center gap-1 rounded-r-md text-sm font-medium text-foreground outline-none hover:bg-accent/50 focus-visible:bg-accent/50 disabled:cursor-not-allowed',\n compact ? 'px-2' : 'px-3',\n )}\n >\n {loading ? (\n <Spinner className=\"size-3.5 text-muted-foreground\" />\n ) : (\n <span className=\"truncate\">{selectedOption?.label ?? anchor?.symbol ?? '—'}</span>\n )}\n <ChevronDown\n className={cn(\n 'size-3.5 shrink-0 text-muted-foreground transition-transform',\n unitsOpen && 'rotate-180',\n )}\n />\n </button>\n )}\n />\n </div>\n </div>\n </PopoverAnchor>\n <PopoverContent\n ref={panel}\n align=\"start\"\n className=\"w-72 p-3\"\n aria-label=\"Quantity by unit\"\n onOpenAutoFocus={(event) => {\n event.preventDefault();\n focusRow(anchor?.id);\n }}\n >\n <p className=\"mb-2 text-xs font-medium tracking-wider text-muted-foreground uppercase\">\n Quantity by unit\n </p>\n <div className=\"flex flex-col gap-1.5\">\n {ladder.map((unit, index) => {\n const decimal = takesDecimals(unit, primaryUnitId, allowDecimal);\n const size = unitSize(unit);\n return (\n <label key={unit.id} className=\"flex items-center gap-2\">\n <span className=\"w-14 truncate text-sm font-medium\">{unit.symbol}</span>\n <input\n ref={(node) => {\n if (node) rowInputs.current.set(unit.id, node);\n else rowInputs.current.delete(unit.id);\n }}\n type=\"text\"\n inputMode={decimal ? 'decimal' : 'numeric'}\n autoComplete=\"off\"\n value={parts[unit.id] ?? ''}\n placeholder=\"0\"\n onChange={(event) => enter(unit, event.target.value)}\n onKeyDown={(event) => handleRowKeyDown(event, index)}\n className=\"h-8 min-w-0 flex-1 rounded-md border border-input px-2 text-sm tabular-nums shadow-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 bg-input/30\"\n />\n <span className=\"w-20 shrink-0 truncate text-right text-xs text-muted-foreground tabular-nums\">\n {unit.id === primaryUnitId || !primaryUnit\n ? ''\n : `×${formatAmount(size.toNumber())} ${primaryUnit.symbol}`}\n </span>\n </label>\n );\n })}\n </div>\n <div className=\"mt-3 flex items-center justify-between border-t pt-2.5\">\n <span className=\"text-sm tabular-nums\">\n <span className=\"text-muted-foreground\">=</span>{' '}\n <span className=\"font-medium\">\n {total === undefined || !primaryUnit ? '—' : `${formatAmount(total)} ${primaryUnit.symbol}`}\n </span>\n </span>\n <div className=\"flex gap-1.5\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"xs\"\n onClick={() => {\n commit({});\n focusRow(anchor?.id);\n }}\n >\n Clear\n </Button>\n <Button type=\"button\" size=\"xs\" onClick={() => handleOpenChange(false)}>\n Done\n </Button>\n </div>\n </div>\n </PopoverContent>\n </Popover>\n )}\n {description && !message && <FieldDescription id={`${fieldId}-description`}>{description}</FieldDescription>}\n {message && <FieldError id={`${fieldId}-error`}>{message}</FieldError>}\n </FieldContent>\n </Field>\n );\n },\n);\nQuantityField.displayName = 'QuantityField';\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,gBAAA,GAAmB,CAAA;AACzB,MAAM,aAAA,GAAgB,CAAA;AACtB,MAAM,oBAAA,GAAuB,yBAAA;AAEtB,MAAM,wBAAA,GAA2B;AAGxC,SAAS,YAAY,MAAA,EAAgC;AACnD,EAAA,MAAM,IAAA,GAAO,OAAO,IAAA,EAAK;AACzB,EAAA,IAAI,IAAA,KAAS,MAAM,CAAC,MAAA,CAAO,SAAS,MAAA,CAAO,IAAI,CAAC,CAAA,EAAG,OAAO,IAAA;AAC1D,EAAA,OAAO,IAAI,QAAQ,IAAI,CAAA;AACzB;AAGO,SAAS,YAAA,CAAa,QAAgB,IAAA,EAAwC;AACnF,EAAA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b,0BAAA,MAAA,CAAO,EAAE,CAAA;AACT,0BAAA,QAAA,CAAS,QAAQ,EAAE,CAAA;AAAA,wBACrB,CAAA;AAAA,wBACD,QAAA,EAAA;AAAA;AAAA,qBAED;AAAA,oCACA,GAAA,CAAC,MAAA,EAAA,EAAO,IAAA,EAAK,QAAA,EAAS,IAAA,EAAK,IAAA,EAAK,OAAA,EAAS,MAAM,gBAAA,CAAiB,KAAK,CAAA,EAAG,QAAA,EAAA,MAAA,EAExE;AAAA,mBAAA,EACF;AAAA,iBAAA,EACF;AAAA;AAAA;AAAA;AACF,SAAA,EACF,CAAA;AAAA,QAED,WAAA,IAAe,CAAC,OAAA,oBAAW,GAAA,CAAC,oBAAiB,EAAA,EAAI,CAAA,EAAG,OAAO,CAAA,YAAA,CAAA,EAAiB,QAAA,EAAA,WAAA,EAAY,CAAA;AAAA,QACxF,2BAAW,GAAA,CAAC,UAAA,EAAA,EAAW,IAAI,CAAA,EAAG,OAAO,UAAW,QAAA,EAAA,OAAA,EAAQ;AAAA,OAAA,EAC3D;AAAA,KAAA,EACF,CAAA;AAAA,EAEJ;AACF;AACA,aAAA,CAAc,WAAA,GAAc,eAAA;;;;"}
|
package/dist/RadioGroup.js
CHANGED
|
@@ -5,13 +5,13 @@ import { h as FieldSet, f as FieldLegend, b as FieldDescription, c as FieldError
|
|
|
5
5
|
import { c as cn } from './utils.js';
|
|
6
6
|
import { w as withDisabledTip } from './disabledTip.js';
|
|
7
7
|
import { c as usePermission, b as PermissionLockIcon, l as lockedTip } from './PermissionGate.js';
|
|
8
|
-
import { u as useControllableState, P as Primitive, c as composeEventHandlers } from './
|
|
9
|
-
import { u as useComposedRefs } from './
|
|
10
|
-
import { c as createContextScope, P as Presence } from './
|
|
11
|
-
import { R as Root, c as createRovingFocusGroupScope, I as Item } from './
|
|
12
|
-
import { u as useDirection } from './
|
|
13
|
-
import { u as useSize } from './
|
|
14
|
-
import { u as usePrevious } from './
|
|
8
|
+
import { u as useControllableState, P as Primitive, c as composeEventHandlers } from './index18.js';
|
|
9
|
+
import { u as useComposedRefs } from './index10.js';
|
|
10
|
+
import { c as createContextScope, P as Presence } from './index19.js';
|
|
11
|
+
import { R as Root, c as createRovingFocusGroupScope, I as Item } from './index20.js';
|
|
12
|
+
import { u as useDirection } from './index21.js';
|
|
13
|
+
import { u as useSize } from './index26.js';
|
|
14
|
+
import { u as usePrevious } from './index32.js';
|
|
15
15
|
|
|
16
16
|
var RADIO_NAME = "Radio";
|
|
17
17
|
var [createRadioContext, createRadioScope] = createContextScope(RADIO_NAME);
|
package/dist/Select.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { memo, forwardRef, useState, useMemo, useRef, useId, useCallback, useEffect } from 'react';
|
|
3
|
+
import { b as bindFilters, a as boundFilterNames } from './bindFilters.js';
|
|
4
|
+
import { a as withChange } from './conditions.js';
|
|
3
5
|
import { c as usePermission, l as lockedTip, b as PermissionLockIcon } from './PermissionGate.js';
|
|
4
6
|
import { c as cn } from './utils.js';
|
|
5
7
|
import { w as withDisabledTip } from './disabledTip.js';
|
|
@@ -13,7 +15,7 @@ import { C as ChevronDown } from './chevron-down.js';
|
|
|
13
15
|
import { B as Badge } from './Badge2.js';
|
|
14
16
|
import { X } from './x.js';
|
|
15
17
|
import { useQuery, keepPreviousData, useInfiniteQuery, useQueryClient } from '@tanstack/react-query';
|
|
16
|
-
import { u as useInView } from './
|
|
18
|
+
import { u as useInView } from './index16.js';
|
|
17
19
|
import { axios } from './utils/axios.js';
|
|
18
20
|
|
|
19
21
|
function MultiSelectRoot({ open, onOpenChange, disabled, children }) {
|
|
@@ -33,7 +35,7 @@ const MultiSelectTrigger = forwardRef(
|
|
|
33
35
|
"aria-controls": listboxId,
|
|
34
36
|
disabled,
|
|
35
37
|
className: cn(
|
|
36
|
-
"border-input data-placeholder:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive
|
|
38
|
+
"border-input data-placeholder:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive bg-input/30 hover:bg-input/50 flex w-full items-center justify-between gap-2 rounded-md border px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
|
|
37
39
|
"min-h-9",
|
|
38
40
|
className
|
|
39
41
|
),
|
|
@@ -699,6 +701,10 @@ function useSelect({
|
|
|
699
701
|
}
|
|
700
702
|
return Array.from(uniqueByValue.values());
|
|
701
703
|
}, [resolvedSelected, data, debouncedSearch, resolveValues]);
|
|
704
|
+
const heldOptions = useMemo(() => {
|
|
705
|
+
const hasSettledLookup = isResolveSuccess && !isResolveFetching && !isResolvePlaceholder;
|
|
706
|
+
return hasSettledLookup ? resolvedSelected?.options ?? [] : void 0;
|
|
707
|
+
}, [isResolveSuccess, isResolveFetching, isResolvePlaceholder, resolvedSelected]);
|
|
702
708
|
const fetchedGroups = data?.pages[0]?.groups ?? staticGroups ?? [];
|
|
703
709
|
const hasSearchResultsData = (data?.pages.length ?? 0) > 0;
|
|
704
710
|
const { ref: sentinelRef, inView } = useInView();
|
|
@@ -719,6 +725,7 @@ function useSelect({
|
|
|
719
725
|
searching: false,
|
|
720
726
|
missingValues: NO_VALUES,
|
|
721
727
|
checkingValues: false,
|
|
728
|
+
paramsKey,
|
|
722
729
|
setSearchQuery,
|
|
723
730
|
sentinelRef: NOOP_REF
|
|
724
731
|
};
|
|
@@ -734,14 +741,51 @@ function useSelect({
|
|
|
734
741
|
searching: searchQuery !== debouncedSearch || isFetching && !isFetchingNextPage,
|
|
735
742
|
missingValues,
|
|
736
743
|
checkingValues,
|
|
744
|
+
heldOptions,
|
|
745
|
+
paramsKey,
|
|
737
746
|
setSearchQuery,
|
|
738
747
|
sentinelRef
|
|
739
748
|
};
|
|
740
749
|
}
|
|
741
750
|
|
|
751
|
+
const NO_CONDITIONS = [];
|
|
752
|
+
const NO_OPTIONS = [];
|
|
753
|
+
const NO_FIELDS = /* @__PURE__ */ new Set();
|
|
754
|
+
function withContextParams(params, conditions, headerFields) {
|
|
755
|
+
const entries = conditions.flatMap((condition) => {
|
|
756
|
+
if (!headerFields.has(condition.field)) return [];
|
|
757
|
+
const { value } = condition;
|
|
758
|
+
if (Array.isArray(value)) return value.length > 0 ? [[condition.field, value.join(",")]] : [];
|
|
759
|
+
if (typeof value === "string" || typeof value === "number") return value === "" ? [] : [[condition.field, value]];
|
|
760
|
+
return [];
|
|
761
|
+
});
|
|
762
|
+
return entries.length > 0 ? { ...params, ...Object.fromEntries(entries) } : params;
|
|
763
|
+
}
|
|
742
764
|
const Select = forwardRef((props, ref) => {
|
|
743
|
-
const {
|
|
765
|
+
const {
|
|
766
|
+
multiple,
|
|
767
|
+
optionsEndpoint,
|
|
768
|
+
searchDebounceMs,
|
|
769
|
+
limit,
|
|
770
|
+
fieldKeys,
|
|
771
|
+
params,
|
|
772
|
+
onOpenChange,
|
|
773
|
+
context,
|
|
774
|
+
onSelectionRefresh,
|
|
775
|
+
...rest
|
|
776
|
+
} = props;
|
|
744
777
|
const [open, setOpen] = useState(false);
|
|
778
|
+
const [ownConditions, setOwnConditions] = useState(NO_CONDITIONS);
|
|
779
|
+
const conditions = context?.context ?? ownConditions;
|
|
780
|
+
const setCondition = context?.setContext ?? ((field, condition) => setOwnConditions((current) => withChange(current, field, condition, [])));
|
|
781
|
+
const header = rest.header == null ? rest.header : bindFilters(rest.header, {
|
|
782
|
+
conditions,
|
|
783
|
+
onChange: setCondition,
|
|
784
|
+
keepControlled: true,
|
|
785
|
+
required: context?.required,
|
|
786
|
+
loading: context ? !context.isLoaded : false,
|
|
787
|
+
onFieldSettling: context?.markFieldSettling
|
|
788
|
+
});
|
|
745
789
|
const { granted } = usePermission(rest.permission);
|
|
746
790
|
const selectData = useSelect({
|
|
747
791
|
options: rest.options,
|
|
@@ -750,12 +794,54 @@ const Select = forwardRef((props, ref) => {
|
|
|
750
794
|
searchDebounceMs,
|
|
751
795
|
limit,
|
|
752
796
|
fieldKeys,
|
|
753
|
-
params
|
|
797
|
+
params: withContextParams(
|
|
798
|
+
params,
|
|
799
|
+
conditions,
|
|
800
|
+
rest.header == null ? NO_FIELDS : boundFilterNames(rest.header, { keepControlled: true })
|
|
801
|
+
),
|
|
754
802
|
selectedValues: rest.value != null ? Array.isArray(rest.value) ? rest.value : [rest.value] : void 0,
|
|
755
803
|
enabled: open,
|
|
756
804
|
open
|
|
757
805
|
});
|
|
758
806
|
const isAsync = !!optionsEndpoint;
|
|
807
|
+
const heldValues = useMemo(
|
|
808
|
+
() => rest.value == null ? [] : (Array.isArray(rest.value) ? rest.value : [rest.value]).map(String),
|
|
809
|
+
[rest.value]
|
|
810
|
+
);
|
|
811
|
+
const heldKey = heldValues.join(",");
|
|
812
|
+
const reportOptions = context?.setSelectedOptions;
|
|
813
|
+
const reportedOptions = useRef(context?.selectedOptions ?? NO_OPTIONS);
|
|
814
|
+
reportedOptions.current = context?.selectedOptions ?? NO_OPTIONS;
|
|
815
|
+
useEffect(() => {
|
|
816
|
+
if (heldKey === "") reportOptions?.(NO_OPTIONS);
|
|
817
|
+
}, [heldKey, reportOptions]);
|
|
818
|
+
const lookedUp = useRef(null);
|
|
819
|
+
const { heldOptions, paramsKey } = selectData;
|
|
820
|
+
useEffect(() => {
|
|
821
|
+
if (!onSelectionRefresh && !reportOptions || heldValues.length === 0 || !heldOptions) return;
|
|
822
|
+
const previous = lookedUp.current;
|
|
823
|
+
if (previous?.valuesKey === heldKey && previous.paramsKey === paramsKey) return;
|
|
824
|
+
lookedUp.current = { valuesKey: heldKey, paramsKey };
|
|
825
|
+
const optionOf = (options, value) => options.find((option) => String(option.value) === value);
|
|
826
|
+
reportOptions?.(
|
|
827
|
+
heldValues.flatMap((value) => {
|
|
828
|
+
const option = optionOf(heldOptions, value) ?? optionOf(reportedOptions.current, value);
|
|
829
|
+
return option ? [option] : [];
|
|
830
|
+
})
|
|
831
|
+
);
|
|
832
|
+
if (previous?.valuesKey === heldKey && !multiple)
|
|
833
|
+
onSelectionRefresh?.(optionOf(heldOptions, heldValues[0]) ?? null);
|
|
834
|
+
}, [onSelectionRefresh, reportOptions, multiple, heldValues, heldKey, heldOptions, paramsKey]);
|
|
835
|
+
const reportingHandlers = reportOptions ? {
|
|
836
|
+
onOptionSelect: (option) => {
|
|
837
|
+
reportOptions(option ? [option] : NO_OPTIONS);
|
|
838
|
+
rest.onOptionSelect?.(option);
|
|
839
|
+
},
|
|
840
|
+
onOptionsSelect: (options) => {
|
|
841
|
+
reportOptions(options);
|
|
842
|
+
rest.onOptionsSelect?.(options);
|
|
843
|
+
}
|
|
844
|
+
} : {};
|
|
759
845
|
const asyncState = isAsync ? {
|
|
760
846
|
loading: selectData.loading,
|
|
761
847
|
loadingMore: selectData.loadingMore,
|
|
@@ -767,6 +853,8 @@ const Select = forwardRef((props, ref) => {
|
|
|
767
853
|
} : void 0;
|
|
768
854
|
const childProps = {
|
|
769
855
|
...rest,
|
|
856
|
+
...reportingHandlers,
|
|
857
|
+
header,
|
|
770
858
|
options: selectData.options,
|
|
771
859
|
groups: selectData.groups,
|
|
772
860
|
asyncState
|