Tally UI

AddressEditor

AddressEditor edits an order's billing and shipping addresses as rows, with shipping Same as billing until the cashier uses a different address.

Import

import { AddressEditor, type AddressEditorValue } from '@tallyui/components';

Usage

const [addresses, setAddresses] = useState<AddressEditorValue>({});

<Dialog open={open} onOpenChange={setOpen}>
  <DialogContent>
    <ScrollView>
      <AddressEditor value={addresses} onChange={setAddresses} countries={countries} statesFor={statesFor} defaultCountry="GB" />
    </ScrollView>
  </DialogContent>
</Dialog>

Billing is an "Add Billing Address" button until the order has one; a new address starts in defaultCountry. Then it is a row: a one-line summary of the set parts (Address 1 to Country, joined with commas; with none, the name or company), Edit to open and close the parts beneath it, and Remove. The billing parts are AddressFields with Email.

With billing present, shipping is ShippingAddressFields, which reads its link to billing once at mount: key the editor by order or customer to read it again. With neither address, shipping has its own add button; with shipping but no billing, it is a row like billing's, with its own Remove and no Email.

The editor has no dialog of its own: the app places it in one, with a scrolling body.

Props

PropTypeDefaultDescription
value / onChangeAddressEditorValue / (next: AddressEditorValue) => voidrequired{ billing?, shipping? }, and every edit as the whole next value
countries / statesForas AddressFields---Passed to the parts
defaultCountrystring---The store's country; a new address starts with it
testIDstring'address-editor'Prefix for every testID

On this page