diff --git a/PROJECT.md b/PROJECT.md index 7a9c274..b629354 100644 --- a/PROJECT.md +++ b/PROJECT.md @@ -65,9 +65,8 @@ Bigger features are folders with an `index.js` and internal sub-components + hoo 1. `packages/components/src//.js` 2. `packages/components/src//.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()`. @@ -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, @@ -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 diff --git a/packages/components/__tests__/components.test.js b/packages/components/__tests__/components.test.js index 485a65d..13c9c9d 100644 --- a/packages/components/__tests__/components.test.js +++ b/packages/components/__tests__/components.test.js @@ -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`); } }); diff --git a/packages/components/src/Form/Form.stories.js b/packages/components/src/Form/Form.stories.js index 1c0c25b..1f3848e 100644 --- a/packages/components/src/Form/Form.stories.js +++ b/packages/components/src/Form/Form.stories.js @@ -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 = () => ( {}} /> ); diff --git a/packages/components/src/Form/FormBusinessInfo.js b/packages/components/src/Form/FormBusinessInfo.js index 0c10caf..6944b12 100644 --- a/packages/components/src/Form/FormBusinessInfo.js +++ b/packages/components/src/Form/FormBusinessInfo.js @@ -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'; @@ -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, @@ -141,7 +139,7 @@ const FormBusinessInfo = ({ onChangeText={(text) => inputActionHandler('description', text)} /> - {showLocation ? ( + {readOnly || disabled ? ( inputActionHandler('location', text)} /> - ) : 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. */} + inputActionHandler('location', place.description ?? '')} + onClear={() => inputActionHandler('location', '')} + /> + + + )} { expect(drawnAs(render(), 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( + 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(); + const locked = render(); + 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(); expect(tree.root.findAllByType(ButtonWrapper)).toHaveLength(0); @@ -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( - - ); - expect(inputWithValue(hidden, '1 Main St')).toBeUndefined(); - expect(hostOf(hidden, 'error.location')).toHaveLength(0); - expect(inputWithValue(hidden, 'Suite 2')).toBeDefined(); - expect(inputWithValue(render(), '1 Main St')).toBeDefined(); - }); - it('names the tax id on file (masked) instead of showing it', () => { const tree = render(); expect(JSON.stringify(tree.toJSON())).toContain('•••••6789'); @@ -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( + + ); + 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( diff --git a/packages/components/src/index.js b/packages/components/src/index.js index 578027e..322507e 100644 --- a/packages/components/src/index.js +++ b/packages/components/src/index.js @@ -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'; diff --git a/packages/components/src/portable.js b/packages/components/src/portable.js index 2803374..0706d90 100644 --- a/packages/components/src/portable.js +++ b/packages/components/src/portable.js @@ -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