diff --git a/PROJECT.md b/PROJECT.md index 7a9c274f..f9085486 100644 --- a/PROJECT.md +++ b/PROJECT.md @@ -7,8 +7,8 @@ it goes here. ## Where to work -`feature/temporal-migration`, in this repository's main checkout (`~/daxir/react-native-components`), is the one -source of truth (owner, 2026-10-07). Branch from it and merge back into it; keep no long-lived +`main`, in this repository's main checkout (`~/daxir/react-native-components`), is the one +source of truth (owner, 2026-10-15: trunk-based development). Branch from it and merge back into it; keep no long-lived worktree. The authority is fleet-management `docs/canonical-trunk.md`. @@ -43,7 +43,6 @@ change would break a consumer, stop and ask (§9). ``` packages/components/src/ index.js THE public API — the single barrel. Nothing is public unless exported here. - portable.js the web-safe subset of the barrel (C-35), for web hosts — see "Portable entry" styles.js shared style objects built from MD3LightTheme tokens tones.js status tones (success/warning/danger/neutral/info) -> theme roles + icons consts.js shared constants (LAYOUT_MODE, …) @@ -65,9 +64,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. It is the + package's only entry (see "One 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()`. @@ -147,7 +145,7 @@ Since **0.4.0** (C-25): i18next as a resource bundle, so `react-i18next` readers see it. `%{}` interpolates as everywhere. - **`currentLocale()`** is exported by both twins; `format.js` reads it. It used to read `i18n-js` directly, so on the web every date was formatted in `en`. -- `merge` (deep merge of nested catalogues) is exported from the barrel and the portable entry. +- `merge` (deep merge of nested catalogues) is exported from the barrel. `Localization.web.js` is the web twin, and as of 0.2.0 it really is one: same loader, same `%{}` placeholder syntax (i18next's default `{{}}` would have shown narration placeholders raw), same @@ -180,29 +178,27 @@ the components take the result and paint it. `file:` until 0.2.0 is published, then `^0.2.0`. `Order/__tests__/d50.test.js` keeps every legacy reference contained inside it and fails if one appears anywhere else — or if that file stops being the legacy table. -## Portable entry (C-35) and partner components (K-22) — 0.4.0-dev - -`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, -SegmentedButtonGroup, ActionGroup, SideNav, TouchableRippleWrapper, TN*, `ButtonWrapper`, -`PhotoGalleryDisplay`, `styles`, `LAYOUT_MODE`, a `Form` subset (PersonInfo, VehicleInfo, -BusinessInfo, DriverInfo, EmailPassword, SecretInputText), `StripeForm.AccountBank`, Localization (`localized`, -`setI18nConfig`, `registerFlatCatalog`, `currentLocale`, `merge`), the formatters, the Order and Partner view -models, the K-22 components and the generic web-host UI (next section). `ImagePicker` is **not** portable (picker, permissions, draggable list): a web host shows -photos with `PhotoGalleryDisplay` and the app injects the picker. - -- `packages/components/__tests__/portableEntry.test.js` walks its static import graph the way a web - bundler does (`.web.js` first) and fails if a native-only module becomes reachable (react-native-config, - dotenv, localize, image picker, action sheet, permissions, geolocation, gesture handler, reanimated, - draggable list, mapbox, bottom sheets, centrifuge) — or the package's own name, which drags the barrel in. +## One entry (0.6.0) and partner components (K-22) + +The package has **one entry**, `index.js` (the barrel), as React Native and its web toolchains expect (owner, +2026-11-07). `lib/portable`, the web-safe subset served from C-35 (0.4.0) to 0.5.5, was removed in 0.6.0: 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. +How the barrel runs on the web: + +- **Web differences live in `.web.js` twins** inside this package (`Config`, `Localization`, `MapboxGLWrapper`, + `OptionPicker/OptionSheet`); a web bundler resolves them first. +- **Native modules a web bundle cannot load are the host's web stubs** (CustomerApp `web-stubs/`: + `react-native-config`, the map wrapper's override, `navigator.geolocation`), applied only on the web. - **`Config.web.js`**: on the web the host calls `configureComponents({ IMAGEKIT_URL, … })` once before rendering. Native `Config.js` exports the same function (merge, no behaviour change). - **Never import this package by its published name from inside it**, and import `../ScreenWrapper` (the index that attaches `.Section`/`.Container`), not `../ScreenWrapper/ScreenWrapper`. - `OptionPicker/OptionSheet.js` is the native action sheet; `OptionSheet.web.js` is a Paper modal with the same `show()`/`hide()` ref, which is what lets `Form.BusinessInfo` load on the web. -- `lib/*` deep imports keep working; there is deliberately no `exports` map yet. +- `lib/*` deep imports keep working; there is deliberately no `exports` map yet. Hosts import the package itself. +- Two of its libraries, the phone input and the places autocomplete, import the package back by name. A host's jest + mock that spreads the real barrel runs again while the barrel loads (CustomerApp `src/testUtils/actualModuleWith.js` + shows the way around it). K-22 components (APIs frozen in `CustomerApp/admin-web/docs/ARCHITECTURE.md` §5), RN primitives + Paper, themed through `useTheme()` so a host's theme applies: @@ -215,7 +211,7 @@ themed through `useTheme()` so a host's theme applies: - `Timeline` — `history` and `steps`. - Document requirements (contract request #117, 0.5.4), fed by a `getMyStatus` checklist item, so no host keeps a document type of its own: - - `Partner/DocumentRequirementCard` (portable) — a Paper `Card` composed as Paper composes one: the title is + - `Partner/DocumentRequirementCard` — a Paper `Card` composed as Paper composes one: the title is `requirementTitle(item)` (the rule's name for the market, else the catalogue's), `subtitle` is the host's, then, in its `Card.Content`, `covers` (the photos taken and not sent, in order, each `{ uri, label }` with the name a screen reader says), `note` and the rule's explanation, and `actions` @@ -225,7 +221,7 @@ themed through `useTheme()` so a host's theme applies: `aria-live`) that stays mounted, so a screen reader announces each next step. `Card.Actions` gets, through its `style`, `flexWrap` and a `spacing.x2` row gap (it does not wrap by itself; its alignment and padding stay), and its buttons are keyed by position, as `Card.Actions` itself tells them apart (a label changes as photos are taken). - - `Partner/DocumentCovers` (portable, not exported) — the card's photos: one is a `Card.Cover`; more are a + - `Partner/DocumentCovers` (not exported) — the card's photos: one is a `Card.Cover`; more are a Material 3 hero carousel (a horizontal `ScrollView`: `snapToInterval` on the phone, `pagingEnabled`'s CSS scroll snap on the web; items `spacing.x2` apart, the next peeking `spacing.x14`, Material's 8 dp and 56 dp), or all whole side by side where the measured width fits them at Material's largest large item (twice the cover's height, which @@ -236,12 +232,12 @@ themed through `useTheme()` so a host's theme applies: the safe-area insets; the internal `SheetHeader` with its `global.close`) on that page, with the document's sides (the covers' labels) when there are two. testIDs: `-covers`, `-carousel`, `-cover-`, `-viewer`, `-viewer-header-close`, `-viewer-document`. - - `Partner/DocumentVersionList` (portable) — `item.versions` as `ListRow`s from `documentVersionRows`; they open + - `Partner/DocumentVersionList` — `item.versions` as `ListRow`s from `documentVersionRows`; they open nothing, so no chevron. A row's description: when it was sent, the scan's catalogue label while the scan is not `SCAN_STATUS.CLEAN` (pending, and partner 0.2.54's infected, never spelled here), the details code's label, and `documentExpiresOn` («Expires Nov 23, 2026»): `expires_at` is a calendar day, formatted by `formatDateTime` in UTC so no reader's zone moves it. `documentExpires` stays for the app's older list. - - `Partner/DocumentCaptureCard` (barrel only: the picker is native) — the card with the way to send it, as + - `Partner/DocumentCaptureCard` (native: the picker) — the card with the way to send it, as `item.capture` says (`pages` 1, or 2 = the front then the back). Controlled: `{ item, subtitle?, pages = [], onPagesChange(pages), onSend(), isSending = false, testID = 'document-requirement' }` — the host owns the pages (the picker's assets, in order) and clears them only once its send succeeded, so a failed send keeps them; the @@ -270,7 +266,7 @@ themed through `useTheme()` so a host's theme applies: `documentExpiresOn`) live in `Translations/*.json`, in the catalogue's «Agregar»; the stories (`Partner/DocumentRequirement.stories.js`) use the local circuit's real items, and render the capture card itself with `pages` for the photo states. -- `Partner/viewModel.js` (barrel/portable: `PartnerViewModel`, because `statusLabel` is the Order one): +- `Partner/viewModel.js` (barrel: `PartnerViewModel`, because `statusLabel` is the Order one): the key is the package's `statusLabelKey(group, value)` resolved with `localized`; a value outside the vocabulary, or a key the registered catalogue lacks, renders the raw value. Each kind's group is read from the package's `LABEL_GROUPS` (never spelled here). `TONE_BY_KIND` and `INTENT_PRESENTATION` stay @@ -285,6 +281,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 @@ -320,13 +321,13 @@ does not render are ignored, and the forms' own required messages are unchanged. makes, models }` (each `Array<{ value, label }>`, labelled by the host) plus `vehicleType`, `makeId`, `modelId`, `licensePlateRegion` and `vin`, it renders the market schema in canon §9.15's order (type → year → make → model, color, plate, plate region, optional VIN) with `Form/FormSelectField.js` (an outlined input that -opens a Paper `Menu`, portable). A make or model pick reports its id and its name (`makeId` + `make`); with no +opens a Paper `Menu`, web-safe). A make or model pick reports its id and its name (`makeId` + `make`); with no `makes`/`models` (no catalogue slice for that type and year) they stay typed text. Without `catalog` the form is the tree it always was, pinned by `legacyRendering.test.js` (`Form.VehicleInfo (vehicle form)`, captured from `admin-app` @ 516446e). `PhotoGalleryDisplay({ photoUrls, title?, emptyLabel?, highlighted?, size?, testID? })` -(`ImagePicker/PhotoGalleryDisplay.js`, barrel and portable): **resolved** URIs, never rewritten; a horizontal +(`ImagePicker/PhotoGalleryDisplay.js`): **resolved** URIs, never rewritten; a horizontal strip of RN `Image`s, each labelled «Photo i of n» (`global.photoOf`); `global.noPhotos` when empty or all blank; `title` defaults to `photos` (`null` hides it); `highlighted` adds the «Changed» line. testIDs: `` (the strip), `.photo.`, `.empty`; `testID` defaults to `photo-gallery`. @@ -367,7 +368,7 @@ re-renders the existing consumers' props (CustomerApp's `drawerSideNav` and `Inv ## Generic UI for web hosts — 0.4.0-dev The partner console's generic UI (`CustomerApp/admin-web/src/ui`) lives here now, for the console and the -AdminApp port alike. Every piece is in the barrel **and** `portable.js`, one folder per component, JS, themed +AdminApp port alike. Every piece is in the barrel, one folder per component, JS, themed through `useTheme()` (a host theme's roles apply) and built on Paper components **as they are**: no hand-made copy of a Paper component, even to work around a web accessibility quirk — those are recorded below as Paper fork items. Labels come by props, with `global.*` defaults of this library's catalogue (never `partner.*`). @@ -513,14 +514,13 @@ consumers must have this package inside their Metro/Babel transform path. Conseq `@jmstechnologiesinc/react-native-paper`, `@react-navigation/elements`, `@jmstechnologiesinc/order`, `@jmstechnologiesinc/order-narration` and `@jmstechnologiesinc/partner` — the last pinned **exactly** (canon R4; also a devDependency), because the view model and its tests read its vocabulary, and - both the barrel and the portable entry import `Partner/viewModel`. The harness links the main checkout's + the barrel imports `Partner/viewModel`. The harness links the main checkout's root `node_modules`, which does not carry it; in a worktree it is unpacked into `packages/components/node_modules` (`npm pack @jmstechnologiesinc/partner@` + extract), where Jest resolves it with no `moduleNameMapper`. The barrel additionally expects the host to provide what the app already has (`centrifuge`, `react-native-gesture-handler`, `react-native-reanimated`, - `react-native-vector-icons`, …); the portable entry needs only `react-native-safe-area-context`, - `react-native-vector-icons`, `color`, `@jmstechnologiesinc/commons`/`vendor`/`react-native-size-matters` and, on - the web, `i18next`, `i18next-browser-languagedetector` and `react-i18next`. All of them are now declared + `react-native-vector-icons`, …) and, on the web, `i18next`, `i18next-browser-languagedetector` and + `react-i18next`. All of them are now declared as peers (C-35, 2026-10-03): every package `lib/` imports, at the range CustomerApp declares (so the main host never conflicts). The commented-out `expo-blur` and `showcase-template` are not. `partner` is a peer at **^0.2.33** (0.4.3, owner 2026-10-04: an exact pin refused every contract patch the app installs, B-8) and a diff --git a/packages/components/__tests__/components.test.js b/packages/components/__tests__/components.test.js index 485a65d6..13c9c9dd 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/__tests__/portableEntry.test.js b/packages/components/__tests__/portableEntry.test.js deleted file mode 100644 index 668b2b49..00000000 --- a/packages/components/__tests__/portableEntry.test.js +++ /dev/null @@ -1,255 +0,0 @@ -'use strict'; - -/* C-35 — THE PORTABLE ENTRY LOADS ON THE WEB WITHOUT STUBS. - * - * A web bundler resolves a module's `.web.js` twin before the module itself. - * This walks the STATIC import graph of `src/portable.js` the same way and - * fails if any module on the list below becomes reachable: each one either - * throws when a web bundle evaluates it (a TurboModule react-native-web does not - * provide) or needs a Babel plugin a host bundler does not run. The graph is - * this package's own source; a bare import is checked by package name and not - * followed. - */ - -const fs = require('fs'); -const path = require('path'); -const { parse } = require('@babel/parser'); - -const SRC = path.resolve(__dirname, '../src'); -const ENTRY = path.join(SRC, 'portable.js'); - -const FORBIDDEN = [ - 'react-native-config', - 'react-native-dotenv', - 'react-native-localize', - 'react-native-image-picker', - 'react-native-actions-sheet', - 'react-native-permissions', - 'react-native-geolocation-service', - 'react-native-gesture-handler', - 'react-native-reanimated', - 'react-native-draggable-flatlist', - '@rnmapbox/maps', - 'mapbox-gl', - 'react-map-gl', - '@gorhom/bottom-sheet', - '@jmstechnologiesinc/bottom-sheet', - 'centrifuge', - // Importing the package by its own name drags the whole barrel back in. - '@jmstechnologiesinc/react-native-components', -]; - -const packageOf = (specifier) => { - const parts = specifier.split('/'); - return specifier.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0]; -}; - -const resolveRelative = (from, specifier) => { - const base = path.resolve(path.dirname(from), specifier); - const candidates = [ - `${base}.web.js`, - `${base}.js`, - path.join(base, 'index.web.js'), - path.join(base, 'index.js'), - base, - ]; - const found = candidates.find((file) => fs.existsSync(file) && fs.statSync(file).isFile()); - if (!found) throw new Error(`cannot resolve ${specifier} from ${path.relative(SRC, from)}`); - return found; -}; - -const specifiersOf = (file) => { - const ast = parse(fs.readFileSync(file, 'utf8'), { sourceType: 'module', plugins: ['jsx'] }); - const found = []; - const visit = (node) => { - if (!node || typeof node.type !== 'string') return; - if ( - (node.type === 'ImportDeclaration' || - node.type === 'ExportNamedDeclaration' || - node.type === 'ExportAllDeclaration') && - node.source - ) { - found.push(node.source.value); - } - if ( - node.type === 'CallExpression' && - ((node.callee.type === 'Identifier' && node.callee.name === 'require') || node.callee.type === 'Import') && - node.arguments[0]?.type === 'StringLiteral' - ) { - found.push(node.arguments[0].value); - } - for (const value of Object.values(node)) { - if (Array.isArray(value)) value.forEach(visit); - else if (value && typeof value === 'object' && value.type) visit(value); - } - }; - visit(ast.program); - return found; -}; - -// file -> [the chain of files that reached it], so a failure names its path. -const walk = () => { - const reached = new Map([[ENTRY, [ENTRY]]]); - const packages = new Map(); - const queue = [ENTRY]; - while (queue.length) { - const file = queue.shift(); - if (!file.endsWith('.js')) continue; - for (const specifier of specifiersOf(file)) { - if (specifier.startsWith('.')) { - const target = resolveRelative(file, specifier); - if (!reached.has(target)) { - reached.set(target, [...reached.get(file), target]); - queue.push(target); - } - } else if (!packages.has(packageOf(specifier))) { - packages.set(packageOf(specifier), reached.get(file)); - } - } - } - return { reached, packages }; -}; - -const { reached, packages } = walk(); -const relative = (file) => path.relative(SRC, file); - -describe('the portable entry (C-35)', () => { - it.each(FORBIDDEN)('never reaches %s', (name) => { - const chain = packages.get(name); - expect(chain ? `${name} via ${chain.map(relative).join(' -> ')}` : null).toBeNull(); - }); - - it('takes the web twins, as a web bundler would', () => { - const files = [...reached.keys()].map(relative); - expect(files).toEqual( - expect.arrayContaining([ - 'Config.web.js', - 'Localization/Localization.web.js', - 'OptionPicker/OptionSheet.web.js', - ]) - ); - expect(files).not.toContain('Config.js'); - expect(files).not.toContain('Localization/Localization.js'); - expect(files).not.toContain('index.js'); - // The display-only gallery is portable; the picker namespace is not. - expect(files).toContain('ImagePicker/PhotoGalleryDisplay.js'); - expect(files).not.toContain('ImagePicker/ImagePickerAvatar.js'); - expect(files).not.toContain('ImagePicker/ImagePicker.js'); - expect(files).not.toContain('ImagePicker/PhotoGallery.js'); - // The address rows are portable; the map picker and geolocation behind the Geoposition index are not. - expect(files).toContain('Geoposition/RecentLocations.js'); - expect(files).not.toContain('Geoposition/index.js'); - expect(files).not.toContain('Geoposition/MapPicker/index.js'); - }); - - it('loads under Jest and serves what the web host imports', () => { - const portable = require('../src/portable'); - const expected = [ - 'List', - 'ScreenWrapper', - 'ChipList', - 'Tabs', - 'SegmentedButtonGroup', - 'ActionGroup', - 'SideNav', - 'TouchableRippleWrapper', - 'TNActivityIndicator', - 'TNEmptyStateView', - 'styles', - 'LAYOUT_MODE', - 'configureComponents', - 'Form', - 'StripeForm', - 'localized', - 'setI18nConfig', - 'registerFlatCatalog', - 'currentLocale', - 'merge', - 'formatDateTime', - 'formatTime', - 'formatRelativeTime', - 'orderViewModel', - 'statusLabel', - 'PartnerViewModel', - 'StatusChip', - 'SlaChip', - 'DocumentViewer', - 'ZOOM', - 'DecisionDialog', - 'useModalFocus', - 'Timeline', - 'ButtonWrapper', - 'PhotoGalleryDisplay', - // The console's generic UI, moved here (0.4.0-dev). - 'LAYOUT', - 'PANE', - 'SIZE_CLASS', - 'SUPPORTING_MODE', - 'paneMetrics', - 'sizeClassOf', - 'tokenScale', - 'useWindowSizeClass', - 'paneArrangement', - 'usePaneContext', - 'PaneLayout', - 'Pane', - 'PaneHeader', - 'PaneFooter', - 'BottomSheet', - 'SectionCard', - 'KeyValueList', - 'ListRow', - 'iconSlot', - 'nodeSlot', - 'MutedText', - 'EmptyState', - 'LoadingState', - 'ErrorState', - 'DataTableView', - 'SORT_DIRECTION', - 'sortRows', - 'CodeBlock', - 'NoteField', - 'CheckboxListField', - 'FilterChips', - 'StatusBanner', - 'ChangedHelperText', - 'FieldErrorText', - 'FieldErrorList', - 'useNow', - 'valueText', - 'formatCalendarDate', - 'parseCalendarDate', - 'formatDateInput', - 'parseDateInput', - 'parseDay', - 'isBlankDay', - // The account projection's views (Payouts, Addresses). - 'Accounting', - 'LOCATION_LIST_ITEM', - 'LOCATION_LIST_ITEM_MAPPING', - 'interpunctLocationListItemDescription', - 'LocationListItem', - 'RecentLocations', - ]; - expect(expected.filter((name) => portable[name] === undefined)).toEqual([]); - // Not public: nothing used them (the rail is `SideNav variant="rail"`, the app's snackbar is its own) or they - // are the scaffold's own pieces (the side sheet and the sheets' header). - const retired = [ - 'SideSheet', - 'SheetHeader', - 'NavigationRail', - 'SnackbarProvider', - 'useSnackbar', - 'RadioGroupField', - 'AvatarDisplay', - ]; - expect(retired.filter((name) => portable[name] !== undefined)).toEqual([]); - expect(Object.keys(portable.Form).sort()).toEqual( - ['BusinessInfo', 'DriverInfo', 'EmailPassword', 'PersonInfo', 'SecretInputText', 'VehicleInfo'].sort() - ); - expect(Object.keys(portable.StripeForm).sort()).toEqual(['AccountBank', 'PaymentFrequency']); - expect(typeof portable.ScreenWrapper.Section).toBe('function'); - expect(typeof portable.Tabs.Bar).toBe('function'); - }); -}); diff --git a/packages/components/package-lock.json b/packages/components/package-lock.json index 050c8300..f9312ac8 100644 --- a/packages/components/package-lock.json +++ b/packages/components/package-lock.json @@ -1,12 +1,12 @@ { "name": "@jmstechnologiesinc/react-native-components", - "version": "0.5.5", + "version": "0.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@jmstechnologiesinc/react-native-components", - "version": "0.5.5", + "version": "0.6.0", "license": "ISC", "devDependencies": { "@jmstechnologiesinc/partner": "0.2.54", diff --git a/packages/components/package.json b/packages/components/package.json index b228be14..4641419b 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,6 @@ { "name": "@jmstechnologiesinc/react-native-components", - "version": "0.5.5", + "version": "0.6.0", "description": "Biblioteca de componentes de interfaz compartida por las aplicaciones de Daxir.", "author": "yerloveraaa ", "homepage": "https://github.com/jmstechnologiesinc/react-native-components#readme", @@ -35,7 +35,7 @@ "@jmstechnologiesinc/cart": "^0.1.2", "@jmstechnologiesinc/commons": "^0.1.5", "@jmstechnologiesinc/order": "^0.6.0", - "@jmstechnologiesinc/order-narration": "^0.0.9", + "@jmstechnologiesinc/order-narration": "^0.0.10", "@jmstechnologiesinc/partner": "^0.2.54", "@jmstechnologiesinc/react-native-google-places-autocomplete": "^2.4.14", "@jmstechnologiesinc/react-native-image-blur-loading": "^1.2.5", diff --git a/packages/components/src/ButtonWrapper/__tests__/ButtonWrapper.test.js b/packages/components/src/ButtonWrapper/__tests__/ButtonWrapper.test.js index abfeed64..d6547ea7 100644 --- a/packages/components/src/ButtonWrapper/__tests__/ButtonWrapper.test.js +++ b/packages/components/src/ButtonWrapper/__tests__/ButtonWrapper.test.js @@ -1,11 +1,10 @@ -// C-35 — `ButtonWrapper` is Paper only, so the portable entry serves it. +// C-35 — `ButtonWrapper` is Paper only. import React from 'react'; import renderer, { act } from 'react-test-renderer'; import { MD3LightTheme, Provider } from '@jmstechnologiesinc/react-native-paper'; import ButtonWrapper from '../ButtonWrapper'; -import { ButtonWrapper as PortableButtonWrapper } from '../../portable'; jest.useFakeTimers(); @@ -30,10 +29,6 @@ afterEach(() => { const buttonOf = (tree) => tree.root.findAll((node) => node.props.accessibilityRole === 'button')[0]; describe('ButtonWrapper', () => { - it('is the same component in the portable entry', () => { - expect(PortableButtonWrapper).toBe(ButtonWrapper); - }); - it('renders its title and calls onPress', () => { const onPress = jest.fn(); const tree = render(); diff --git a/packages/components/src/Form/Form.stories.js b/packages/components/src/Form/Form.stories.js index 1c0c25bb..1f3848ee 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 0c10caff..6944b12d 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/Layout/index.js b/packages/components/src/Layout/index.js index a1d2176e..8af1ecc0 100644 --- a/packages/components/src/Layout/index.js +++ b/packages/components/src/Layout/index.js @@ -1,7 +1,7 @@ // The MD3 pane system: window size classes, the collapse table, the pane // scaffold and its pieces, and the bottom sheet a host opens itself. The side // sheet and the sheets' header are the scaffold's own (PaneLayout, BottomSheet); -// the rail is `SideNav variant="rail"`. Portable +// the rail is `SideNav variant="rail"`. Web-safe // (react-native-web without stubs) and themed through `useTheme()`; every size // is a token of the theme in use (`metrics.js`). export { diff --git a/packages/components/src/List/ListItemChip.js b/packages/components/src/List/ListItemChip.js index cbfd7336..7ecd277f 100644 --- a/packages/components/src/List/ListItemChip.js +++ b/packages/components/src/List/ListItemChip.js @@ -6,7 +6,6 @@ import { ITEM_TYPE_ICON_MAPPING, ITEM_TYPE } from '@jmstechnologiesinc/commons'; import { makeLinkingCall } from '../utils'; const ListItemChip = (chip) => { - console.log(JSON.stringify(chip, null, 2)); switch (chip.type) { case ITEM_TYPE.call: return ( @@ -22,10 +21,13 @@ const ListItemChip = (chip) => { break; default: return ( + // It SHOWS a value and is not pressable, so it is announced as text, not as a button (Paper's default + // role for a chip), as StatusChip does. {chip.formattedValue} diff --git a/packages/components/src/List/__tests__/ListItemChip.test.js b/packages/components/src/List/__tests__/ListItemChip.test.js new file mode 100644 index 00000000..f2d2b331 --- /dev/null +++ b/packages/components/src/List/__tests__/ListItemChip.test.js @@ -0,0 +1,59 @@ +import React from 'react'; +import renderer, { act } from 'react-test-renderer'; + +import { Chip, MD3LightTheme, Provider } from '@jmstechnologiesinc/react-native-paper'; +import { ITEM_TYPE, ITEM_TYPE_ICON_MAPPING } from '@jmstechnologiesinc/commons'; + +import ListItemChip from '../ListItemChip'; + +const mounted = []; + +const render = (element) => { + let tree; + act(() => { + tree = renderer.create({element}); + }); + mounted.push(tree); + return tree; +}; + +afterEach(() => { + act(() => { + mounted.splice(0).forEach((tree) => tree.unmount()); + }); + jest.restoreAllMocks(); +}); + +const chipOf = (tree) => tree.root.findByType(Chip); + +describe('ListItemChip', () => { + it('draws a needAttention chip flat with its icon, and any other type outlined', () => { + const attention = chipOf(render()); + expect(attention.props.mode).toBe('flat'); + expect(attention.props.icon).toBe(ITEM_TYPE_ICON_MAPPING[ITEM_TYPE.needAttention]); + expect(attention.props.children).toBe('Overdue'); + + const plain = chipOf(render()); + expect(plain.props.mode).toBe('outlined'); + expect(plain.props.icon).toBeUndefined(); + expect(plain.props.onPress).toBeUndefined(); + }); + + it('announces a chip that only shows a value as text, and keeps the call chip a button', () => { + expect(chipOf(render()).props.accessibilityRole).toBe('text'); + + const call = chipOf( + render() + ); + expect(call.props.onPress).toEqual(expect.any(Function)); + expect(call.props.accessibilityRole).toBeUndefined(); + }); + + // A list renders one chip per row on every render: the chip itself must write nothing to the console. + it('writes nothing to the console when it renders', () => { + const log = jest.spyOn(console, 'log').mockImplementation(() => {}); + render(); + render(); + expect(log).not.toHaveBeenCalled(); + }); +}); diff --git a/packages/components/src/Partner/DocumentCaptureCard.js b/packages/components/src/Partner/DocumentCaptureCard.js index d13610a8..ca89ecea 100644 --- a/packages/components/src/Partner/DocumentCaptureCard.js +++ b/packages/components/src/Partner/DocumentCaptureCard.js @@ -30,7 +30,7 @@ const DOCUMENT_CAPTURE_OPTIONS = Object.freeze({ * card's covers (both sides in a carousel, owner 2026-11-04), and «Send to review» sends them once every page is * there. The card only sends (owner, 2026-11-04): it says nothing of where the requirement stands, which its versions * and its row in the lists say. The photo sheet is the library's picker, opened by the card's own button - * (`variant="sheet"`). Not portable: the picker is native. + * (`variant="sheet"`). Native: the picker. * * Controlled: the host owns `pages` (the picker's assets, in order) and gets each change through * `onPagesChange(pages)`. «Send to review» calls `onSend()`; the card never clears the pages itself, so a send that diff --git a/packages/components/src/index.js b/packages/components/src/index.js index 578027ed..691026a8 100644 --- a/packages/components/src/index.js +++ b/packages/components/src/index.js @@ -46,7 +46,7 @@ export { default as SwipeToDelete } from './SwipeToDelete/SwipeToDelete'; export { default as SideNav } from './SideNav/SideNav'; export { default as Swipeable } from './SwipeToDelete/SwipeToDelete'; export { default as ButtonWrapper } from './ButtonWrapper/ButtonWrapper'; -// C-35 — the display-only gallery (resolved URIs, no picker); also in `portable.js`. +// C-35 — the display-only gallery (resolved URIs, no picker). export { default as PhotoGalleryDisplay } from './ImagePicker/PhotoGalleryDisplay'; export { makeLinkingCall, @@ -77,23 +77,26 @@ export { merge } from './Localization/catalog'; export { formatDateTime, formatTime, formatRelativeTime } from './Localization/format'; export { localizedAuthError } from './Localization/authErrors'; -// K-22 — also served by `portable.js`, the entry a web host imports. +// K-22 — the partner components. export { default as StatusChip, SlaChip, LabelChip } from './Partner/StatusChip'; export { default as RuleClauseList } from './Partner/RuleClauseList'; export { default as DocumentRequirementCard } from './Partner/DocumentRequirementCard'; export { default as DocumentVersionList } from './Partner/DocumentVersionList'; -// Contract request #117: the card with its capture; native (the photo picker), so not in portable.js. +// Contract request #117: the card with its capture (native: the photo picker). 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. +export { useModalFocus } from './useModalFocus'; export { default as Timeline } from './Timeline/Timeline'; export { default as StateFlow } from './StateFlow/StateFlow'; export { STATUS_TONES, toneColors } from './tones'; // The generic UI of a web host (the partner console, the admin app), moved // here from the console: the MD3 pane system, data display and feedback, -// fields and utilities. Portable, themed through `useTheme()`, labels by props -// with `global.*` defaults. Also served by `portable.js`. +// fields and utilities. Themed through `useTheme()`, labels by props with +// `global.*` defaults. export { BOTTOM_SHEET_MAX_HEIGHT, LAYOUT, diff --git a/packages/components/src/portable.js b/packages/components/src/portable.js deleted file mode 100644 index 28033742..00000000 --- a/packages/components/src/portable.js +++ /dev/null @@ -1,158 +0,0 @@ -// C-35 — THE PORTABLE ENTRY: what loads on the web with no stubs. -// -// The barrel (`index.js`) reaches maps, geolocation, permissions, the image -// picker, action and bottom sheets, gesture and animation libraries and the -// real-time client, none of which a web bundle can load. A web host — the -// partner console, the presentational views it borrows from the app (canon -// §17.6) — imports `lib/portable` instead and gets only what runs on -// react-native-web. `__tests__/portableEntry.test.js` walks this file's import -// graph the way a web bundler does (`.web.js` first) and fails if a native-only -// module becomes reachable. -// -// On the web the host configures the library at runtime with -// `configureComponents` (see `Config.web.js`) and registers the partner -// catalogue with `registerFlatCatalog`. -import * as List from './List/List'; -import * as Tabs from './Tabs/Tabs'; -import * as ActionGroup from './ActionGroup/ActionGroup'; -import * as PartnerViewModel from './Partner/viewModel'; -import FormPersonInfo from './Form/FormPersonInfo'; -import FormVehicleInfo from './Form/FormVehicleInfo'; -import FormBusinessInfo from './Form/FormBusinessInfo'; -import FormDriverInfo from './Form/FormDriverInfo'; -import FormEmailPassword from './Form/FormEmailPassword'; -import SecretInputText from './Form/SecretInputText'; -import StripeFormAccountBank from './StripeForm/StripeFormAccountBank'; -import StripeFormPaymentFrequency from './StripeForm/StripeFormPaymentFrequency'; - -// The forms the web needs (canon §17.4, §17.6); `DriverInfo` shows a driver's -// answers read-only in the admin app. `Form.PhoneNumber` stays in the barrel -// because its phone-input library imports this package's barrel back; the -// others are not used by any partner view. -const Form = Object.freeze({ - PersonInfo: FormPersonInfo, - VehicleInfo: FormVehicleInfo, - BusinessInfo: FormBusinessInfo, - DriverInfo: FormDriverInfo, - EmailPassword: FormEmailPassword, - SecretInputText, -}); - -// `PaymentFrequency` shows a payout interval (read-only in the console's -// payouts section). -const StripeForm = Object.freeze({ - AccountBank: StripeFormAccountBank, - PaymentFrequency: StripeFormPaymentFrequency, -}); - -export { List, Tabs, ActionGroup, Form, StripeForm, PartnerViewModel }; - -export { default as styles } from './styles'; -export { LAYOUT_MODE } from './consts'; -export { configureComponents } from './Config'; - -export { default as ScreenWrapper } from './ScreenWrapper'; -export { default as ChipList } from './ChipList/ChipList'; -export { default as SegmentedButtonGroup } from './SegmentedButtonGroup/SegmentedButtonGroup'; -export { default as SideNav } from './SideNav/SideNav'; -export { default as TouchableRippleWrapper } from './TouchableRippleWrapper/TouchableRippleWrapper'; -export { default as TNActivityIndicator } from './truly-native/TNActivityIndicator'; -export { default as TNEmptyStateView } from './truly-native/TNEmptyStateView'; -// Paper only: the app's «add» text button. -export { default as ButtonWrapper } from './ButtonWrapper/ButtonWrapper'; -// The photos of a gallery, display only. `ImagePicker` itself (picker, -// permissions, draggable list) stays native: the host injects it. -export { default as PhotoGalleryDisplay } from './ImagePicker/PhotoGalleryDisplay'; - -export { localized, setI18nConfig, registerFlatCatalog, currentLocale } from './Localization/Localization'; -export { merge } from './Localization/catalog'; -export { formatDateTime, formatTime, formatRelativeTime } from './Localization/format'; - -export { orderViewModel, fromDescriptor, statusLabel } from './Order/viewModel'; - -// K-22 -export { default as StatusChip, SlaChip, LabelChip } from './Partner/StatusChip'; -export { default as RuleClauseList } from './Partner/RuleClauseList'; -// Contract request #117: a document requirement and its versions, read-only (the capture card is native). -export { default as DocumentRequirementCard } from './Partner/DocumentRequirementCard'; -export { default as DocumentVersionList } from './Partner/DocumentVersionList'; -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); DecisionDialog uses it, and a host's own sheets -// and dialogs share it. A no-op off the web. -export { useModalFocus } from './useModalFocus'; -export { default as Timeline } from './Timeline/Timeline'; -export { default as StateFlow } from './StateFlow/StateFlow'; -export { STATUS_TONES, toneColors } from './tones'; - -// The generic UI of a web host (the partner console, the admin app), moved -// here from the console: the MD3 pane system, data display and feedback, -// fields and utilities. Portable, themed through `useTheme()`, labels by props -// with `global.*` defaults. Also served by `portable.js`. -export { - BOTTOM_SHEET_MAX_HEIGHT, - LAYOUT, - PANE, - SIZE_CLASS, - SIZE_CLASS_BREAKPOINTS, - SUPPORTING_MODE, - paneMetrics, - sizeClassOf, - tokenScale, - usePaneMetrics, - useWindowSizeClass, - paneArrangement, - usePaneContext, - PaneLayout, - ListDetail, - fitsListDetail, - Breadcrumbs, - Pane, - PaneHeader, - PaneFooter, - footerButtons, - BottomSheet, -} from './Layout'; -export { default as SectionCard } from './SectionCard/SectionCard'; -export { default as KeyValueList } from './KeyValueList/KeyValueList'; -export { default as ListRow } from './ListRow/ListRow'; -export { default as ChipRow } from './ChipRow/ChipRow'; -export { iconSlot, nodeSlot } from './ListRow/listSlots'; -export { default as MutedText } from './MutedText/MutedText'; -export { EmptyState, LoadingState, ErrorState } from './States/States'; -export { default as DataTableView, SORT_DIRECTION, SORT_MODE, sortRows, nextSort } from './DataTableView/DataTableView'; -export { default as DataTableList } from './DataTableView/DataTableList'; -export { default as CodeBlock, codeText } from './CodeBlock/CodeBlock'; -export { default as NoteField } from './NoteField/NoteField'; -export { default as CheckboxListField } from './CheckboxListField/CheckboxListField'; -export { default as FilterChips } from './FilterChips/FilterChips'; -export { default as StatusBanner } from './StatusBanner/StatusBanner'; -// A filter chip whose single choice opens in a menu (the partner directory's filters, 2026-10-09). -export { default as MenuFilterChip } from './MenuFilterChip/MenuFilterChip'; -export { ChangedHelperText, FieldErrorText, FieldErrorList } from './Form/FormField'; -export { useNow } from './useNow'; -export { valueText, EMPTY_VALUE } from './valueText'; -export { - DATE_PATTERN, - DATE_TIME_PATTERN, - formatCalendarDate, - formatDateInput, - parseCalendarDate, - parseDateInput, - isBlankDay, - parseDay, -} from './DateInput'; - -// The account projection's views (Payouts, Addresses; ACCOUNT-PROJECTION.md): -// the balance breakdown and the address rows the app already draws. Paper and -// the catalogue only. `RecentLocations` comes from its own file, never from the -// `Geoposition` index, which reaches the native map picker and geolocation. -export { default as Accounting } from './Accounting/Accounting'; -export { - LOCATION_LIST_ITEM, - LOCATION_LIST_ITEM_MAPPING, - interpunctLocationListItemDescription, - LocationListItem, -} from './LocationListItem/LocationListItem'; -export { default as RecentLocations } from './Geoposition/RecentLocations';