@lotics/ui 46.8.0 → 46.8.2
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/docs/catalog.md +21 -5
- package/examples/tpl_money.tsx +36 -15
- package/package.json +1 -1
- package/src/charge_lines.tsx +19 -12
package/docs/catalog.md
CHANGED
|
@@ -199,7 +199,10 @@ notion of adjustments or of three sides.
|
|
|
199
199
|
- **The total is the sum of what is on screen.** Never a figure computed off a different array: a
|
|
200
200
|
total that is not the sum of something visible is the one figure a reader cannot check.
|
|
201
201
|
- **The row's verb sits in a fixed slot**, so the money column does not shift between a row that
|
|
202
|
-
can be removed and one that cannot. `locked` turns the editors into values for a settled charge
|
|
202
|
+
can be removed and one that cannot. `locked` turns the editors into values for a settled charge
|
|
203
|
+
and silences EVERY verb on the band — the row's own and both money verbs. A verb on a figure
|
|
204
|
+
nobody can change is a control with nothing behind it, and a disabled one that merely repeats
|
|
205
|
+
the value beside it prints the same number twice on one line.
|
|
203
206
|
- **Below its fork width** the name takes its own line and the arithmetic sits under it — a
|
|
204
207
|
two-line row ON PURPOSE, measured on the band's own container because it lives in drawers as
|
|
205
208
|
often as on pages. The arithmetic RIGHT-ALIGNS to the band there: laid out from the left it
|
|
@@ -1388,11 +1391,24 @@ source (`src/<module>.tsx`/`.ts`) is the API reference.
|
|
|
1388
1391
|
and not interchangeable with it: a ledger has nothing to type into and this has no notion of
|
|
1389
1392
|
adjustments. A charge is ONE line — `quantity`/`unitPrice` derive the amount and the amount is
|
|
1390
1393
|
never typed; leave both out and the `amount` itself becomes the editor (`amountActions` puts a
|
|
1391
|
-
list price one tap away, `unitPriceActions` a rate).
|
|
1392
|
-
it
|
|
1393
|
-
|
|
1394
|
+
list price one tap away, `unitPriceActions` a rate). **A verb is named for the ACT, never for the
|
|
1395
|
+
value it would set** — label one with the target figure and every row already at that figure
|
|
1396
|
+
prints the same number twice in a row (three times, once the derived amount agrees), which is the
|
|
1397
|
+
normal state wherever the figures are pre-filled from the same source the verb applies. A fixed
|
|
1398
|
+
label also keeps its width equal across rows, which is what the pass-unconditionally rule exists
|
|
1399
|
+
to protect; put the figure in the accessible name if it is worth announcing. **A money verb renders
|
|
1400
|
+
INSIDE the field it acts on**, on that control's own surface — an `InlineButton` is an inner
|
|
1401
|
+
button and is never a thing standing on its own beside the control it belongs to. As a sibling it
|
|
1402
|
+
also takes its width out of the NAME's column, which is how a charge called "Vệ sinh bến bãi"
|
|
1403
|
+
renders as "Vệ sinh b…". The row's own verb (`action`, usually removal) is the exception that
|
|
1404
|
+
proves it: it belongs to the ROW rather than to any one figure, so it sits in a slot of its own,
|
|
1405
|
+
held open on every row so the money column cannot move between them.
|
|
1406
|
+
**And before reaching for a verb at all, ask whether the value is simply the field's DEFAULT** —
|
|
1407
|
+
a tariff, a list price, the figure a line is created with. Then there is no verb: the field
|
|
1408
|
+
already holds it, and clearing the field restores it. A button that re-applies what the field
|
|
1409
|
+
would hold anyway is a control for a state the reader cannot reach. `extra` carries a second control belonging
|
|
1394
1410
|
to the charge (how it was paid); `warning` names a problem on the line that has it; `locked`
|
|
1395
|
-
turns the editors into values for a settled band; `empty` speaks for a record nobody has priced
|
|
1411
|
+
turns the editors into values for a settled band and draws no verb of any kind; `empty` speaks for a record nobody has priced
|
|
1396
1412
|
yet. `formatMoney` is the BAND's, so two lines cannot disagree about a currency, and the `total`
|
|
1397
1413
|
you pass must be the sum of the lines on screen. Below its fork width the row takes two lines
|
|
1398
1414
|
with the arithmetic right-aligned to the band — see § "Money you are PRICING" for the full
|
package/examples/tpl_money.tsx
CHANGED
|
@@ -411,14 +411,19 @@ export function TplMoney() {
|
|
|
411
411
|
unitPrice={l.unitPrice}
|
|
412
412
|
onQuantityChange={(v) => patchLine(l.key, { quantity: v })}
|
|
413
413
|
onUnitPriceChange={(v) => patchLine(l.key, { unitPrice: v })}
|
|
414
|
-
/*
|
|
415
|
-
|
|
414
|
+
/* The rate card's ceiling, one tap, ON the field it fills — an
|
|
415
|
+
InlineButton is an inner button and never stands on its own beside
|
|
416
|
+
the control it acts on.
|
|
417
|
+
Named for the ACT, with the figure in the accessible name: a verb
|
|
418
|
+
labelled with the value it would set prints that value twice on
|
|
419
|
+
every row already holding it.
|
|
420
|
+
Unconditional + `disabled`, never conditional: a verb passed only when it
|
|
416
421
|
has work makes the field narrower on the rows that carry it, so those rows
|
|
417
422
|
stop sharing this money column with the rest. */
|
|
418
423
|
unitPriceActions={
|
|
419
424
|
<InlineButton
|
|
420
|
-
title=
|
|
421
|
-
accessibilityLabel=
|
|
425
|
+
title="Ceiling"
|
|
426
|
+
accessibilityLabel={`Apply the ceiling rate of ${money(CEILING_RATE)}`}
|
|
422
427
|
disabled={l.key !== "runs" || l.unitPrice === CEILING_RATE}
|
|
423
428
|
onPress={() => patchLine(l.key, { unitPrice: CEILING_RATE })}
|
|
424
429
|
/>
|
|
@@ -714,14 +719,9 @@ export function TplMoney() {
|
|
|
714
719
|
placeholder="—"
|
|
715
720
|
accessibilityLabel={`Amount for ${c.label}`}
|
|
716
721
|
/* The list price, one tap, ON the field it fills —
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
is a form row whose value column grows, so a verb
|
|
721
|
-
on the field's own surface moves nothing. In a
|
|
722
|
-
right-aligned money COLUMN it would eat the
|
|
723
|
-
field's width and slide the figure off the
|
|
724
|
-
column its neighbours are on. */
|
|
722
|
+
the same placement `ChargeLines` uses, because a
|
|
723
|
+
verb belongs to the control it acts on wherever
|
|
724
|
+
that control sits. */
|
|
725
725
|
actions={
|
|
726
726
|
<InlineButton
|
|
727
727
|
title={money(c.standard)}
|
|
@@ -953,13 +953,34 @@ export function TplMoney() {
|
|
|
953
953
|
stops. The section beat and the heading are what separate them. */}
|
|
954
954
|
<Section>
|
|
955
955
|
<SectionHeading>
|
|
956
|
-
<SectionHeadingTitle description="Locked turns the editors into values once the money is collected — the band stops being a form and becomes the record of what was charged
|
|
956
|
+
<SectionHeadingTitle description="Locked turns the editors into values once the money is collected — the band stops being a form and becomes the record of what was charged. Every verb goes with them: a caller keeps passing the same props, and the band draws none of them.">
|
|
957
957
|
Settled
|
|
958
958
|
</SectionHeadingTitle>
|
|
959
959
|
</SectionHeading>
|
|
960
|
+
{/* The verbs are passed EXACTLY as the editable band passes them, which
|
|
961
|
+
is what a real caller does — the same JSX renders a charge before and
|
|
962
|
+
after the money is collected. The BAND is what decides they are not
|
|
963
|
+
drawn, so this section is also the check on that: a verb surviving
|
|
964
|
+
here is a control acting on a figure nobody can change, and a
|
|
965
|
+
disabled one repeating the value beside it prints the same number
|
|
966
|
+
twice on one line. */}
|
|
960
967
|
<ChargeLines totalLabel="Collected" total={190_000} formatMoney={money}>
|
|
961
|
-
<ChargeLine
|
|
962
|
-
|
|
968
|
+
<ChargeLine
|
|
969
|
+
label="Delivery runs"
|
|
970
|
+
quantity={40}
|
|
971
|
+
unitPrice={4_000}
|
|
972
|
+
locked
|
|
973
|
+
unitPriceActions={<InlineButton title={money(CEILING_RATE)} accessibilityLabel="Apply the ceiling rate" disabled onPress={() => {}} />}
|
|
974
|
+
action={<IconButton icon="x" size="sm" color="danger" tooltip="Remove this charge" onPress={() => {}} />}
|
|
975
|
+
/>
|
|
976
|
+
<ChargeLine
|
|
977
|
+
label="Site cleaning"
|
|
978
|
+
quantity={1}
|
|
979
|
+
unitPrice={30_000}
|
|
980
|
+
locked
|
|
981
|
+
unitPriceActions={<InlineButton title={money(CEILING_RATE)} accessibilityLabel="Apply the ceiling rate" disabled onPress={() => {}} />}
|
|
982
|
+
action={<IconButton icon="x" size="sm" color="danger" tooltip="Remove this charge" onPress={() => {}} />}
|
|
983
|
+
/>
|
|
963
984
|
</ChargeLines>
|
|
964
985
|
</Section>
|
|
965
986
|
|
package/package.json
CHANGED
package/src/charge_lines.tsx
CHANGED
|
@@ -103,7 +103,10 @@ export interface ChargeLineProps {
|
|
|
103
103
|
/** The row's own verb, usually removal. Rendered in a fixed slot so the money
|
|
104
104
|
* column does not move between a row that has one and a row that does not. */
|
|
105
105
|
action?: ReactNode;
|
|
106
|
-
/** Read-only band: editors become values, and
|
|
106
|
+
/** Read-only band: editors become values, and NO verb is drawn — not the row's
|
|
107
|
+
* action and not either money verb. A verb on a figure nobody can change is a
|
|
108
|
+
* control with nothing behind it, and a disabled one that merely repeats the
|
|
109
|
+
* value beside it prints the same number twice. */
|
|
107
110
|
locked?: boolean;
|
|
108
111
|
}
|
|
109
112
|
|
|
@@ -243,16 +246,16 @@ export function ChargeLine(props: ChargeLineProps) {
|
|
|
243
246
|
placeholder="—"
|
|
244
247
|
align="right"
|
|
245
248
|
accessibilityLabel={words.unitPrice(label)}
|
|
249
|
+
/* INSIDE the field, on its own surface — an InlineButton is an inner
|
|
250
|
+
button, never a thing standing on its own beside the control it
|
|
251
|
+
acts on. Rendered as a sibling it also takes its width out of the
|
|
252
|
+
NAME's column, which is how a charge called "Vệ sinh bến bãi" came
|
|
253
|
+
to render as "Vệ sinh b...". */
|
|
254
|
+
actions={unitPriceActions}
|
|
246
255
|
/>
|
|
247
256
|
)}
|
|
248
257
|
</View>
|
|
249
258
|
)}
|
|
250
|
-
{/* BESIDE the price field, never inside it: a verb inside eats the field's
|
|
251
|
-
width, so the figure slides left and a row carrying a one-tap rate stops
|
|
252
|
-
sharing this column with a row that has none. Width is the verb's own —
|
|
253
|
-
the contract is that a caller passes it on every row and DISABLES it
|
|
254
|
-
where it has nothing to do, which is what keeps the rows equal. */}
|
|
255
|
-
{!priced ? null : unitPriceActions}
|
|
256
259
|
{/* The amount ENDS the expression it derives from. Put it on a second
|
|
257
260
|
line and the reader parses left to right, then jumps back to find the
|
|
258
261
|
answer — and it lands in no column, so the total below closes nothing. */}
|
|
@@ -270,13 +273,11 @@ export function ChargeLine(props: ChargeLineProps) {
|
|
|
270
273
|
placeholder="—"
|
|
271
274
|
align="right"
|
|
272
275
|
accessibilityLabel={words.amount(label)}
|
|
276
|
+
/* The flat line's twin, and INSIDE its field for the same reason. */
|
|
277
|
+
actions={amountActions}
|
|
273
278
|
/>
|
|
274
279
|
)}
|
|
275
280
|
</View>
|
|
276
|
-
{/* The flat line's twin of `unitPriceActions`, on the figure a flat line
|
|
277
|
-
actually edits — its amount. Same contract: pass it on every row and
|
|
278
|
-
disable it where it has nothing to do. */}
|
|
279
|
-
{priced ? null : amountActions}
|
|
280
281
|
{/* Held open whether or not this row has a verb, so the money column does
|
|
281
282
|
not shift between a row that can be removed and one that cannot. */}
|
|
282
283
|
<View style={styles.actionSlot}>{locked ? null : action}</View>
|
|
@@ -316,7 +317,13 @@ export function ChargeLine(props: ChargeLineProps) {
|
|
|
316
317
|
<View>
|
|
317
318
|
<View style={styles.row}>
|
|
318
319
|
<View style={styles.grow}>
|
|
319
|
-
|
|
320
|
+
{/* The name may take a SECOND line rather than lose a word. The fork
|
|
321
|
+
threshold is measured on the band, but what actually runs out is the
|
|
322
|
+
room LEFT for the name — and a money verb takes another slice of it,
|
|
323
|
+
so a band can sit comfortably above the fork width and still have
|
|
324
|
+
under 100px for a charge called "Vệ sinh bến bãi". Capped at two so a
|
|
325
|
+
pathological name cannot push the arithmetic down the page. */}
|
|
326
|
+
<Text size="sm" numberOfLines={2}>
|
|
320
327
|
{label}
|
|
321
328
|
</Text>
|
|
322
329
|
{props.extra ? <View style={styles.extra}>{props.extra}</View> : null}
|