Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions PROJECT.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ Bigger features are folders with an `index.js` and internal sub-components + hoo

1. `packages/components/src/<Name>/<Name>.js`
2. `packages/components/src/<Name>/<Name>.stories.js`
3. Export it from `packages/components/src/index.js` — otherwise it does not exist for consumers. If it
loads on the web without native modules, export it from `portable.js` too (the guard test will tell you
if it does not).
3. Export it from `packages/components/src/index.js` — otherwise it does not exist for consumers. Nothing new
goes into `portable.js`: it is deprecated since 0.5.5 and removed in 0.6.0 (see "Portable entry").
4. Add the folder's glob to `.storybook/main.ts` (see "Storybook" below — the web config is a
hand-maintained list, not a glob over `src/**`).
5. Any user-facing string goes into **both** `Translations/en.json` and `es.json` via `localized()`.
Expand Down Expand Up @@ -182,6 +181,12 @@ the components take the result and paint it.

## Portable entry (C-35) and partner components (K-22) — 0.4.0-dev

**Deprecated since 0.5.5, removed in 0.6.0** (owner, 2026-11-07). The web host it was made for (`admin-web`) is
gone, and since B-52 the console mounts the whole app and, with it, the barrel and its web stubs. One entry is the
standard: web differences live in `.web.js` twins, native modules in the host's web stubs. The barrel serves
everything this entry served (`ZOOM` and `useModalFocus` joined it in 0.5.5). `Form.BusinessInfo` asks the store
address with `AutoCompleteInput`, whose library imports the barrel back, so this entry no longer keeps it out.

`src/portable.js` (published as `lib/portable`) is what a **web host** imports: the partner console
(`CustomerApp/admin-web`) and the presentational views it borrows from the app. It re-exports only
modules that load on react-native-web **without stubs**: List, ScreenWrapper, ChipList, Tabs,
Expand Down Expand Up @@ -285,6 +290,11 @@ themed through `useTheme()` so a host's theme applies:
platform words there. A new partner component joins its `SCOPE`.
- Stories register the package catalogue (`registerFlatCatalog({ en: EN, es: ES })`), as a host does.

`Form.BusinessInfo`'s store address (0.5.5, owner 2026-11-07): while the form can be edited it is `AutoCompleteInput`
(Google's suggestions, as the driver's operating address: no GPS button, no «use my location» row), the picked
suggestion's `description` reported as `location` and its server errors listed under it (`FieldErrorText`). The
suggestions have no read-only state, so under `readOnly` or `isDisabled` the address stays the field it was.

Forms (C-25): `Form.PersonInfo`, `Form.VehicleInfo` and `Form.BusinessInfo` take `readOnly` and
`highlightFields: string[]` (the names the form reports to `inputActionHandler`), which outlines the field
in `primary` and adds a «Changed» helper line (colour alone is not a marker; on a disabled input, where Paper
Expand Down
3 changes: 2 additions & 1 deletion packages/components/__tests__/components.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ describe('el barril de componentes', () => {
});

it('sirve los nombres que sus consumidores importan', () => {
for (const name of ['List', 'Form', 'VendorList', 'CartList', 'styles']) {
// `ZOOM` and `useModalFocus`: the console's, which only `portable.js` served until 0.5.5.
for (const name of ['List', 'Form', 'VendorList', 'CartList', 'styles', 'ZOOM', 'useModalFocus']) {
expect(`${name}:${name in components}`).toBe(`${name}:true`);
}
});
Expand Down
10 changes: 4 additions & 6 deletions packages/components/src/Form/Form.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,14 @@ export const BusinessInfoHighlighted = () => (
/>
);

// The store sign-up's form: the app asks the address with Google's suggestions, so the form leaves its field out, as
// it leaves out the phone and the email.
export const BusinessInfoWithoutLocation = () => (
// A store as the console shows it (read-only): the address is a field. While the form can be edited, as above, the
// address is picked from Google's suggestions.
export const BusinessInfoReadOnly = () => (
<AuthForm.BusinessInfo
storeTitle={state.storeTitle}
location={state.storeAddress}
industries={[]}
showLocation={false}
showPhoneNumber={false}
showEmail={false}
readOnly
inputActionHandler={() => {}}
/>
);
Expand Down
25 changes: 20 additions & 5 deletions packages/components/src/Form/FormBusinessInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { HelperText, Divider, MD3LightTheme } from '@jmstechnologiesinc/react-na
import { VENDOR_INDUSTRIES_MAPPING, VENDOR_INDUSTRIES } from '@jmstechnologiesinc/vendor';

import ScreenWrapper from '../ScreenWrapper';
import AutoCompleteInput from '../AutoCompleteInput';
import { localized } from '../Localization/Localization';
import OptionPickerActionSheet from '../OptionPicker/OptionPickerActionSheet';

Expand Down Expand Up @@ -87,9 +88,6 @@ const FormBusinessInfo = ({
storeTitle,
location,
line2,
// A host that asks the store address with its own input (the app's Google suggestions, barrel only) hides this
// field, as the sign-up hides the phone and the email.
showLocation = true,
showWebsite = true,
showPhoneNumber = true,
showEmail = true,
Expand Down Expand Up @@ -141,7 +139,7 @@ const FormBusinessInfo = ({
onChangeText={(text) => inputActionHandler('description', text)}
/>
</ScreenWrapper.Section>
{showLocation ? (
{readOnly || disabled ? (
<ScreenWrapper.Section>
<FormField
mode="outlined"
Expand All @@ -156,7 +154,24 @@ const FormBusinessInfo = ({
onChangeText={(text) => inputActionHandler('location', text)}
/>
</ScreenWrapper.Section>
) : null}
) : (
<>
{/* Picked from Google's suggestions, as the driver's operating address is: the server places
it with the same geocoding and refuses one it cannot (owner, 2026-11-07). The suggestions
have no read-only state, so the console (readOnly) and a locked store (isDisabled) keep
the field. */}
<AutoCompleteInput
title="storeAddress"
icon="magnify"
value={location ?? ''}
predefinedPlaces={false}
showGps={false}
onPress={(place) => inputActionHandler('location', place.description ?? '')}
onClear={() => inputActionHandler('location', '')}
/>
<FieldErrorText field="location" errors={errors} />
</>
)}
<ScreenWrapper.Section>
<FormField
mode="outlined"
Expand Down
58 changes: 39 additions & 19 deletions packages/components/src/Form/__tests__/Form.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import renderer, { act } from 'react-test-renderer';

import { Chip, MD3LightTheme, Provider, TextInput } from '@jmstechnologiesinc/react-native-paper';

import AutoCompleteInput from '../../AutoCompleteInput';
import ButtonWrapper from '../../ButtonWrapper/ButtonWrapper';
import ChipList from '../../ChipList/ChipList';
import { localized, setI18nConfig } from '../../Localization/Localization';
import OptionSheet from '../../OptionPicker/OptionSheet';
// Each form by its own module, as the portable entry exposes them: `Form.js`
// also carries `PhoneNumber`, whose phone-input library imports this package's
// whole barrel back.
// Each form by its own module: `Form.js` also carries `PhoneNumber`, whose
// phone-input library imports this package's whole barrel back. (BusinessInfo
// reaches it too since 0.5.5, through the address suggestions' library.)
import BusinessInfo from '../FormBusinessInfo';
import PersonInfo from '../FormPersonInfo';
import VehicleInfo from '../FormVehicleInfo';
Expand Down Expand Up @@ -180,6 +181,29 @@ describe('Form.BusinessInfo', () => {
expect(drawnAs(render(<Form.BusinessInfo {...BUSINESS} isDisabled />), values)).toEqual(disabledLines(values));
});

// Owner, 2026-11-07: the store address is picked from Google's suggestions, as the driver's is.
it('asks the address with the suggestions while editable and reports the picked one as `location`', () => {
const changes = [];
const tree = render(
<Form.BusinessInfo {...BUSINESS} inputActionHandler={(field, value) => changes.push([field, value])} />
);
const search = tree.root.findByType(AutoCompleteInput);
expect(search.props.value).toBe('1 Main St');
act(() => search.props.onPress({ description: '2 Elm St, Boston, MA, USA' }));
act(() => search.props.onClear());
expect(changes).toEqual([
['location', '2 Elm St, Boston, MA, USA'],
['location', ''],
]);
});

it('keeps the address as its field, with no suggestions, under readOnly and under isDisabled', () => {
const readOnly = render(<Form.BusinessInfo {...BUSINESS} readOnly />);
const locked = render(<Form.BusinessInfo {...BUSINESS} isDisabled />);
expect(readOnly.root.findAllByType(AutoCompleteInput)).toHaveLength(0);
expect(locked.root.findAllByType(AutoCompleteInput)).toHaveLength(0);
});

it('shows the industries as plain chips under readOnly: nothing to pick, remove or open, nothing greyed out', () => {
const tree = render(<Form.BusinessInfo {...BUSINESS} industries={industries} readOnly />);
expect(tree.root.findAllByType(ButtonWrapper)).toHaveLength(0);
Expand Down Expand Up @@ -233,22 +257,6 @@ describe('Form.BusinessInfo', () => {
expect(hidden.root.findAll((node) => node.props.value === 'Casa Nostra LLC')).toHaveLength(0);
});

// The app asks the store address with Google's suggestions (barrel only) and hides this field, as it hides the
// phone and the email; the field's own errors are then the host's to show.
it('hides the store address under showLocation={false}, and keeps the other fields', () => {
const hidden = render(
<Form.BusinessInfo
{...BUSINESS}
showLocation={false}
errors={[{ field: 'location', code: 'operating_address_not_located' }]}
/>
);
expect(inputWithValue(hidden, '1 Main St')).toBeUndefined();
expect(hostOf(hidden, 'error.location')).toHaveLength(0);
expect(inputWithValue(hidden, 'Suite 2')).toBeDefined();
expect(inputWithValue(render(<Form.BusinessInfo {...BUSINESS} />), '1 Main St')).toBeDefined();
});

it('names the tax id on file (masked) instead of showing it', () => {
const tree = render(<Form.BusinessInfo {...BUSINESS} tin="" tinOnFile="•••••6789" />);
expect(JSON.stringify(tree.toJSON())).toContain('•••••6789');
Expand Down Expand Up @@ -321,6 +329,18 @@ describe('server errors on the forms', () => {
expect(inError(tree, 'Pasta')).toBe(false);
});

it('shows an error of the store address under its suggestions', () => {
const tree = render(
<Form.BusinessInfo
{...BUSINESS}
errors={[{ field: 'location', code: 'operating_address_not_located', message: 'Address not found' }]}
/>
);
const lines = hostOf(tree, 'error.location');
expect(lines).toHaveLength(1);
expect(textOf(lines[0])).toContain('Address not found');
});

it('ignores errors of fields the form does not render', () => {
const tree = render(
<Form.PersonInfo {...PERSON} showEmailInput={false} errors={[{ field: 'email', code: 'taken' }]} />
Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ export { default as DocumentRequirementCard } from './Partner/DocumentRequiremen
export { default as DocumentVersionList } from './Partner/DocumentVersionList';
// Contract request #117: the card with its capture; native (the photo picker), so not in portable.js.
export { default as DocumentCaptureCard } from './Partner/DocumentCaptureCard';
export { default as DocumentViewer } from './DocumentViewer/DocumentViewer';
export { default as DocumentViewer, ZOOM } from './DocumentViewer/DocumentViewer';
export { default as DecisionDialog } from './DecisionDialog/DecisionDialog';
// The web keyboard contract of a modal surface (focus in, Tab trap, Esc, focus back to the opener); a no-op off the
// web. Until 0.5.5 only `portable.js` served it and `ZOOM`.
export { useModalFocus } from './useModalFocus';
export { default as Timeline } from './Timeline/Timeline';
export { default as StateFlow } from './StateFlow/StateFlow';
export { STATUS_TONES, toneColors } from './tones';
Expand Down
5 changes: 5 additions & 0 deletions packages/components/src/portable.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// @deprecated since 0.5.5, removed in 0.6.0: import the package itself. The web hosts mount the whole app, and with
// it the barrel and their web stubs (CustomerApp B-52), so a second entry only splits the forms in two.
// `Form.BusinessInfo` now asks the store address with `AutoCompleteInput`, whose library imports the barrel back:
// this entry no longer keeps the barrel out (its guard's static walk does not follow into that library).
//
// C-35 — THE PORTABLE ENTRY: what loads on the web with no stubs.
//
// The barrel (`index.js`) reaches maps, geolocation, permissions, the image
Expand Down
Loading