@umriss-ui/calculation 0.7.2 → 0.34.0
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/CHANGELOG.md +27 -2
- package/README.md +6 -1
- package/dist/calculation.css +1 -1
- package/dist/calculation.js +180 -179
- package/docs/llms-full.md +7 -13
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,39 @@
|
|
|
1
1
|
# Changes to `@umriss-ui/calculation`
|
|
2
2
|
|
|
3
3
|
This document describes what changes for **callers** of the package: exports,
|
|
4
|
-
props, behaviour.
|
|
5
|
-
repository's journal (`docs/journal.md`) and in the specs under `.scratch/`.
|
|
4
|
+
props, behaviour.
|
|
6
5
|
|
|
7
6
|
**The numbers.** The middle digit rises when something is added; the last one
|
|
8
7
|
when something is repaired. As long as the first digit is `0`, no number
|
|
9
8
|
promises compatibility — which is why whatever changes existing behaviour stands
|
|
10
9
|
under a heading "Changed" of its own, no matter which digit rose.
|
|
11
10
|
|
|
11
|
+
From 0.34.0 all five packages share one number: they are released together, and a package without a change of its own still gets a heading for it.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 0.34.0 – One number for all five packages (Oct. 2026)
|
|
16
|
+
|
|
17
|
+
From this version all five packages carry one number and are released
|
|
18
|
+
together. Needs `@umriss-ui/core` 0.34; the peer range is `^0.34.0`. No change
|
|
19
|
+
of its own.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 0.7.3 – Core 0.33.0 (Oct. 2026)
|
|
24
|
+
|
|
25
|
+
Needs `@umriss-ui/core` 0.33; the peer range moves to `^0.33.0`.
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- **The unit tests run against React 18.3.1 and 19 in CI**, and a calculation is rendered to a string with no `window` in a test (`tests-unit/ssr.test.tsx`).
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- **Every entry begins with `"use client";`.** The built file `dist/calculation.js` starts with the directive, then the stylesheet import, so a bundler that splits server from client code takes each as client code. The directive is written to the built entries only; the sources are unchanged.
|
|
34
|
+
|
|
35
|
+
- **Every export is a client component.** A hook called in a Server Component now fails with React's message about a client reference, not one about `useState`.
|
|
36
|
+
|
|
12
37
|
---
|
|
13
38
|
|
|
14
39
|
## 0.7.2 – Core 0.32.0 (Oct. 2026)
|
package/README.md
CHANGED
|
@@ -16,7 +16,12 @@ pnpm add @umriss-ui/calculation @umriss-ui/core
|
|
|
16
16
|
|
|
17
17
|
`@umriss-ui/core` is a **peer dependency**: the calculation takes its styling
|
|
18
18
|
regime, formats, wording, assessment and freshness from there. React 18 or 19
|
|
19
|
-
as a peer as well.
|
|
19
|
+
as a peer as well; the unit tests run against 18.3 and 19 in CI.
|
|
20
|
+
|
|
21
|
+
Every entry begins with `"use client"`, the directive a framework
|
|
22
|
+
with Server Components reads to treat a module as client code. No test runs
|
|
23
|
+
inside such a framework: the
|
|
24
|
+
calculation is rendered to a string in a test.
|
|
20
25
|
|
|
21
26
|
## Two forms, written as they are shown
|
|
22
27
|
|
package/dist/calculation.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer umriss.tokens,umriss.base,umriss.components;@layer umriss.base{._text_1krlf_23{font-family:var(--u-font-sans);font-size:var(--u-text-md);line-height:var(--u-leading-normal);color:var(--u-color-text);-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}@media(pointer:fine){._dense_1krlf_39{--u-control-height-sm: var(--u-control-height-xs)}}._ink_1krlf_50{--u-color-text: var(--u-color-bg);--u-color-text-secondary: color-mix(in srgb, var(--u-color-bg) 75%, transparent);--u-color-text-muted: color-mix(in srgb, var(--u-color-bg) 60%, transparent)}._extent_1krlf_76{--_chars: 20;--_extra: 0;--_tracking: 0px;--_chrome: 0px;min-inline-size:0;max-inline-size:100%;contain:inline-size;contain-intrinsic-inline-size:calc((var(--_chars) + var(--_extra)) * (1ch + var(--_tracking)) + var(--_chrome))}._field_1krlf_91{caret-color:var(--u-color-accent)}._scroll_1krlf_97{scrollbar-width:thin;scrollbar-color:color-mix(in srgb,var(--u-color-text) 25%,transparent) transparent}._scroll_1krlf_97::-webkit-scrollbar{width:10px;height:10px}._scroll_1krlf_97::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--u-color-text) 22%,transparent);border-radius:var(--u-radius-full);border:3px solid transparent;background-clip:content-box}._scroll_1krlf_97::-webkit-scrollbar-track{background:transparent}}@layer umriss.components{._ring_1krlf_126:focus-visible{outline:2px solid transparent;box-shadow:var(--u-focus-ring)}@media(pointer:coarse){._field_1krlf_91._field_1krlf_91,._fieldRoot_1krlf_146._fieldRoot_1krlf_146{font-size:16px}}._field_1krlf_91:-webkit-autofill,._field_1krlf_91:-webkit-autofill:hover,._field_1krlf_91:-webkit-autofill:focus{-webkit-box-shadow:inset 0 0 0 1000px var(--u-color-surface),0 0 0 1px var(--u-edge-color-strong);-webkit-text-fill-color:var(--u-color-text);caret-color:var(--u-color-accent)}}@layer umriss.components{._frame_is340_24,._frame_is340_24:before,._frame_is340_24:after{box-sizing:border-box}._calculation_is340_51,._calculation_is340_51:before,._calculation_is340_51:after{box-sizing:border-box}._line_is340_86,._line_is340_86:before,._line_is340_86:after{box-sizing:border-box}._assessment_is340_98,._assessment_is340_98:before,._assessment_is340_98:after{box-sizing:border-box}._disclosure_is340_107,._disclosure_is340_107:before,._disclosure_is340_107:after{box-sizing:border-box}._amount_is340_90,._amount_is340_90:before,._amount_is340_90:after{box-sizing:border-box}._list_is340_128,._list_is340_128:before,._list_is340_128:after{box-sizing:border-box}._item_is340_129,._item_is340_129:before,._item_is340_129:after{box-sizing:border-box}._derivation_is340_130,._derivation_is340_130:before,._derivation_is340_130:after{box-sizing:border-box}._labelCell_is340_90,._labelCell_is340_90:before,._labelCell_is340_90:after{box-sizing:border-box}._names_is340_90,._names_is340_90:before,._names_is340_90:after{box-sizing:border-box}._operator_is340_90,._operator_is340_90:before,._operator_is340_90:after{box-sizing:border-box}._unit_is340_90,._unit_is340_90:before,._unit_is340_90:after{box-sizing:border-box}._label_is340_90,._label_is340_90:before,._label_is340_90:after{box-sizing:border-box}._approximate_is340_345,._approximate_is340_345:before,._approximate_is340_345:after{box-sizing:border-box}._target_is340_102,._target_is340_102:before,._target_is340_102:after{box-sizing:border-box}._worst_is340_102,._worst_is340_102:before,._worst_is340_102:after{box-sizing:border-box}._head_is340_497,._head_is340_497:before,._head_is340_497:after{box-sizing:border-box}._headCell_is340_504,._headCell_is340_504:before,._headCell_is340_504:after{box-sizing:border-box}._headUnit_is340_517,._headUnit_is340_517:before,._headUnit_is340_517:after{box-sizing:border-box}._notes_is340_524,._notes_is340_524:before,._notes_is340_524:after{box-sizing:border-box}._freshness_is340_538,._freshness_is340_538:before,._freshness_is340_538:after{box-sizing:border-box}._headLabel_is340_568,._headLabel_is340_568:before,._headLabel_is340_568:after{box-sizing:border-box}._frame_is340_24{font-size:var(--u-text-sm);border-radius:var(--u-radius-md);corner-shape:squircle;background:var(--u-color-surface);outline:1px solid transparent;box-shadow:var(--u-edge);overflow-x:auto;overflow-y:hidden;--disclosure-size: 20px;--disclosure-gap: var(--u-space-2);--line-pad: var(--u-space-2);--line-gap: var(--u-space-1);container-type:inline-size;width:100%}._calculation_is340_51{display:grid;grid-template-columns:fit-content(22rem) minmax(0,1fr) auto var(--figure-tracks, auto auto) auto;margin:0;padding:0;list-style:none}._frame_is340_24[data-compact]{--line-text: 18px;--line-pad: var(--u-space-1);--line-gap: calc(var(--u-space-1) / 2);font-size:var(--u-text-xs);line-height:var(--line-text)}@media(pointer:coarse){._frame_is340_24[data-compact]{--line-pad: var(--u-space-2);--line-gap: var(--u-space-1)}}._frame_is340_24[data-compact]:not([data-two-lines]) ._line_is340_86{grid-template-rows:minmax(calc(var(--line-text) + 2 * var(--line-pad)),auto)}._frame_is340_24[data-compact]:not([data-two-lines]) :is(._labelCell_is340_90,._names_is340_90,._operator_is340_90,._amount_is340_90,._unit_is340_90){padding-bottom:calc(var(--line-pad) - 1px)}._frame_is340_24[data-compact]:not([data-two-lines]) ._assessment_is340_98{padding-bottom:0}._frame_is340_24[data-compact]:not([data-two-lines]) ._assessment_is340_98>:not(._target_is340_102,._worst_is340_102){margin-block:-1px}._frame_is340_24[data-compact] ._disclosure_is340_107{margin-block:-1px}._frame_is340_24[data-compact] ._line_is340_86[data-kind=result]>._amount_is340_90{font-size:var(--u-text-sm);text-underline-offset:3px}._frame_is340_24[data-still]{--disclosure-size: 0px;--disclosure-gap: 0px}._frame_is340_24[data-still] ._disclosure_is340_107{display:none}._list_is340_128,._item_is340_129,._derivation_is340_130{display:grid;grid-template-columns:subgrid;grid-column:1 / -1;margin:0;padding:0;list-style:none}._derivation_is340_130[hidden]{display:none}._derivation_is340_130:not([hidden]){animation:_derivationIn_is340_1 var(--u-duration-fast) var(--u-ease-out)}@keyframes _derivationIn_is340_1{0%{opacity:0}}._item_is340_129{--fall: calc(var(--u-space-3) + var(--depth, 0) * var(--u-space-5) + var(--disclosure-size) / 2 - 1px)}._derivation_is340_130{position:relative}._derivation_is340_130:before{content:"";position:absolute;top:0;bottom:0;left:var(--fall);z-index:1;width:2px;background:var(--u-color-accent);pointer-events:none}:not(._derivation_is340_130)>._item_is340_129[data-open]>._line_is340_86:not([data-mark]),:not(._derivation_is340_130)>._item_is340_129>._derivation_is340_130{background-color:var(--u-color-surface-sunken)}._derivation_is340_130 ._line_is340_86{border-top-color:transparent}._line_is340_86{position:relative;display:grid;grid-template-columns:subgrid;grid-column:1 / -1;align-items:baseline;border-top:1px solid var(--u-hairline)}._calculation_is340_51>._item_is340_129:first-child>._line_is340_86:first-child,._calculation_is340_51>._item_is340_129:first-child>._list_is340_128>._item_is340_129:first-child>._line_is340_86{border-top-color:transparent}._line_is340_86[data-foldable]{cursor:pointer}._line_is340_86[data-mark]{background:color-mix(in srgb,var(--u-color-accent-subtle) 50%,transparent)}._line_is340_86[data-mark=use]{background:var(--u-color-accent-subtle)}._labelCell_is340_90,._names_is340_90,._operator_is340_90,._amount_is340_90,._unit_is340_90,._assessment_is340_98{grid-row:1;padding-top:var(--line-pad);padding-bottom:var(--line-pad)}._labelCell_is340_90{grid-column:1;display:flex;align-items:baseline;gap:var(--disclosure-gap);min-width:0;padding-left:calc(var(--u-space-3) + var(--depth, 0) * var(--u-space-5));padding-right:var(--u-space-5)}._label_is340_90{min-width:0;color:var(--u-color-text)}._line_is340_86[data-reference] ._label_is340_90{font-style:italic;color:var(--u-color-text-secondary)}._disclosure_is340_107{flex:none;align-self:center;display:inline-flex;align-items:center;justify-content:center;width:var(--disclosure-size);height:var(--disclosure-size);padding:0;border:none;border-radius:var(--u-radius-xs);corner-shape:squircle;background:none;color:var(--u-color-text-muted)}button._disclosure_is340_107{box-sizing:border-box}button._disclosure_is340_107{cursor:pointer}button._disclosure_is340_107:hover,._line_is340_86[data-foldable]:hover button._disclosure_is340_107{box-sizing:border-box}button._disclosure_is340_107:hover,._line_is340_86[data-foldable]:hover button._disclosure_is340_107{background:var(--u-color-surface-sunken);color:var(--u-color-text)}button._disclosure_is340_107:active,._line_is340_86[data-foldable]:active button._disclosure_is340_107{box-sizing:border-box}button._disclosure_is340_107:active,._line_is340_86[data-foldable]:active button._disclosure_is340_107{background:var(--u-color-surface-pressed)}._item_is340_129[data-open]>._line_is340_86 button._disclosure_is340_107{box-sizing:border-box}._item_is340_129[data-open]>._line_is340_86 button._disclosure_is340_107{color:var(--u-color-accent)}button._disclosure_is340_107:focus-visible{box-sizing:border-box}button._disclosure_is340_107:focus-visible{outline:2px solid transparent;box-shadow:var(--u-focus-ring)}._disclosure_is340_107 svg{box-sizing:border-box}._disclosure_is340_107 svg{transition:transform var(--u-transition-path)}._disclosure_is340_107 svg[data-open]{box-sizing:border-box}._disclosure_is340_107 svg[data-open]{transform:rotate(90deg)}._names_is340_90{grid-column:2;min-width:0;overflow:hidden;padding-right:var(--u-space-4);white-space:nowrap;text-overflow:ellipsis;color:var(--u-color-text-secondary)}._operator_is340_90,._amount_is340_90,._unit_is340_90{font-family:var(--u-font-mono);font-variant-numeric:tabular-nums;font-feature-settings:"tnum" 1;white-space:nowrap}._operator_is340_90{grid-column:3;padding-right:var(--u-space-3);text-align:right;color:var(--u-color-text-secondary)}._amount_is340_90{grid-column:var(--column, 4);text-align:right;color:var(--u-color-text)}._amount_is340_90[data-verdict=unknown]{color:var(--u-color-text-secondary)}._approximate_is340_345{display:inline-block;margin-right:var(--u-space-1);color:var(--u-color-text-secondary);cursor:help}._unit_is340_90{grid-column:var(--column, 5);padding-left:var(--u-space-1);padding-right:var(--u-space-3);color:var(--u-color-text-secondary)}._assessment_is340_98{grid-column:var(--assessment-column, 6);display:flex;align-items:baseline;justify-content:flex-end;gap:var(--u-space-2);padding-right:var(--u-space-3);white-space:nowrap}._assessment_is340_98:empty{padding-right:0}._target_is340_102,._worst_is340_102{font-size:var(--u-text-xs);color:var(--u-color-text-secondary)}._worst_is340_102:before{content:"● "}._worst_is340_102[data-verdict=unknown]:before{color:var(--u-color-text-muted)}._worst_is340_102[data-verdict=warning]:before{color:var(--u-color-warning)}._worst_is340_102[data-verdict=alarm]:before{color:var(--u-color-danger-text)}._line_is340_86[data-inner]>._amount_is340_90{color:var(--u-color-text-secondary)}._line_is340_86[data-kind=interim] ._label_is340_90,._line_is340_86[data-kind=interim]>._amount_is340_90{font-weight:var(--u-weight-medium)}._line_is340_86[data-emphasis=strong] ._label_is340_90,._line_is340_86[data-emphasis=strong]>._amount_is340_90{font-weight:var(--u-weight-semibold);color:var(--u-color-text)}._line_is340_86[data-emphasis=muted] ._label_is340_90,._line_is340_86[data-emphasis=muted]>._amount_is340_90{color:var(--u-color-text-secondary)}._line_is340_86[data-inner][data-emphasis=muted] ._label_is340_90,._line_is340_86[data-inner][data-emphasis=muted]>._amount_is340_90{color:var(--u-color-text-muted)}._line_is340_86[data-rule],._derivation_is340_130 ._line_is340_86[data-rule]{border-top:1px solid var(--u-color-text-secondary)}._line_is340_86[data-kind=interim]:before{content:"";grid-row:1;grid-column:3 / var(--figures-end, 6);align-self:start;border-top:1px solid var(--u-color-text-secondary);pointer-events:none}._line_is340_86[data-closing] ._label_is340_90{font-weight:var(--u-weight-medium);color:var(--u-color-text-secondary)}._line_is340_86[data-closing]:before{content:"";grid-row:1;grid-column:3 / var(--figures-end, 6);align-self:start;border-top:1px solid var(--u-color-text-muted);pointer-events:none}._line_is340_86[data-kind=result]{border-top:1px solid var(--u-edge-color-strong)}._line_is340_86[data-kind=result]:not([data-mark]){background:var(--u-color-surface-sunken)}._line_is340_86[data-kind=result] ._label_is340_90{font-weight:var(--u-weight-semibold)}._line_is340_86[data-kind=result]>._amount_is340_90{font-size:var(--u-text-md);font-weight:var(--u-weight-semibold)}._line_is340_86[data-kind=result]>._amount_is340_90:not([data-verdict=unknown]){text-decoration-line:underline;text-decoration-style:double;text-underline-offset:5px}._amount_is340_90[data-later]{padding-left:var(--u-space-6)}._head_is340_497{display:grid;grid-template-columns:subgrid;grid-column:1 / -1;align-items:end}._headCell_is340_504{grid-row:1;grid-column:var(--column);display:flex;flex-direction:column;align-items:flex-end;padding:var(--line-pad) 0 var(--u-space-1);font-size:var(--u-text-xs);font-weight:var(--u-weight-medium);color:var(--u-color-text-secondary);white-space:nowrap}._headUnit_is340_517{font-family:var(--u-font-mono);font-weight:var(--u-weight-regular)}._notes_is340_524{grid-row:2;grid-column:1 / 3;display:flex;flex-wrap:wrap;align-items:center;column-gap:var(--u-space-3);margin-top:calc(-1 * var(--line-gap));padding:0 var(--u-space-4) var(--line-pad) calc(var(--u-space-3) + var(--depth, 0) * var(--u-space-5) + var(--disclosure-size) + var(--disclosure-gap));font-size:var(--u-text-xs);color:var(--u-color-text-secondary)}._freshness_is340_538[data-freshness=stale]{color:var(--u-color-warning)}._freshness_is340_538[data-freshness=lost]{color:var(--u-color-danger-text);font-weight:var(--u-weight-medium)}@container (max-width: 34rem){._calculation_is340_51{grid-template-columns:minmax(0,1fr) 0 auto var(--figure-tracks, auto auto) 0}._amount_is340_90[data-later]{padding-left:var(--u-space-2)}._frame_is340_24[data-metrics] ._unit_is340_90:not([data-last]){padding-right:var(--u-space-2)}._headCell_is340_504[data-unit] ._headLabel_is340_568,._names_is340_90{display:none}._labelCell_is340_90{padding-right:var(--u-space-3)}._assessment_is340_98:not(:empty){grid-area:2 / 1 / 3 / -1;justify-content:flex-start;flex-wrap:wrap;min-width:0;overflow:hidden;padding:0 var(--u-space-3) var(--line-pad) calc(var(--u-space-3) + var(--depth, 0) * var(--u-space-5) + var(--disclosure-size) + var(--disclosure-gap));white-space:normal}._frame_is340_24[data-compact]:not([data-two-lines]) ._assessment_is340_98:not(:empty){padding-bottom:var(--line-pad)}._frame_is340_24[data-compact]:not([data-two-lines]) ._assessment_is340_98:not(:empty)>:not(._target_is340_102,._worst_is340_102){margin-block:0}._notes_is340_524{grid-row:3;grid-column:1 / -1}}._frame_is340_24[data-two-lines] ._labelCell_is340_90{grid-column:1 / -1;padding-bottom:0}._frame_is340_24[data-two-lines] ._names_is340_90{display:none}._frame_is340_24[data-two-lines] ._line_is340_86>._operator_is340_90,._frame_is340_24[data-two-lines] ._line_is340_86>._amount_is340_90,._frame_is340_24[data-two-lines] ._line_is340_86>._unit_is340_90{grid-row:2;padding-top:var(--line-gap)}._frame_is340_24[data-two-lines] ._line_is340_86[data-kind=interim]:before,._frame_is340_24[data-two-lines] ._line_is340_86[data-closing]:before{grid-row:2}._frame_is340_24[data-two-lines] ._assessment_is340_98:not(:empty){grid-area:3 / 1 / 4 / -1;justify-content:flex-start;flex-wrap:wrap;min-width:0;overflow:hidden;padding:0 var(--u-space-3) var(--line-pad) calc(var(--u-space-3) + var(--depth, 0) * var(--u-space-5) + var(--disclosure-size) + var(--disclosure-gap));white-space:normal}._frame_is340_24[data-two-lines] ._notes_is340_524{grid-row:4;grid-column:1 / -1}@media(prefers-reduced-motion:reduce){._disclosure_is340_107 svg{transition:none}._derivation_is340_130:not([hidden]){animation:none}}@media(forced-colors:active){._line_is340_86[data-mark]{outline:1px solid Highlight;outline-offset:-1px}._line_is340_86[data-mark=use]{outline-width:2px;outline-offset:-2px}._derivation_is340_130:before{background:CanvasText}._line_is340_86[data-emphasis=muted] ._label_is340_90,._line_is340_86[data-emphasis=muted]>._amount_is340_90{color:GrayText}}}
|
|
1
|
+
@layer umriss.tokens,umriss.base,umriss.components;@layer umriss.base{._text_18806_22{font-family:var(--u-font-sans);font-size:var(--u-text-md);line-height:var(--u-leading-normal);color:var(--u-color-text);-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}@media(pointer:fine){._dense_18806_38{--u-control-height-sm: var(--u-control-height-xs)}}._ink_18806_49{--u-color-text: var(--u-color-bg);--u-color-text-secondary: color-mix(in srgb, var(--u-color-bg) 75%, transparent);--u-color-text-muted: color-mix(in srgb, var(--u-color-bg) 60%, transparent)}._extent_18806_75{--_chars: 20;--_extra: 0;--_tracking: 0px;--_chrome: 0px;min-inline-size:0;max-inline-size:100%;contain:inline-size;contain-intrinsic-inline-size:calc((var(--_chars) + var(--_extra)) * (1ch + var(--_tracking)) + var(--_chrome))}._field_18806_90{caret-color:var(--u-color-accent)}._scroll_18806_96{scrollbar-width:thin;scrollbar-color:color-mix(in srgb,var(--u-color-text) 25%,transparent) transparent}._scroll_18806_96::-webkit-scrollbar{width:10px;height:10px}._scroll_18806_96::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--u-color-text) 22%,transparent);border-radius:var(--u-radius-full);border:3px solid transparent;background-clip:content-box}._scroll_18806_96::-webkit-scrollbar-track{background:transparent}}@layer umriss.components{._ring_18806_125:focus-visible{outline:2px solid transparent;box-shadow:var(--u-focus-ring)}@media(pointer:coarse){._field_18806_90._field_18806_90,._fieldRoot_18806_145._fieldRoot_18806_145{font-size:16px}}._field_18806_90:-webkit-autofill,._field_18806_90:-webkit-autofill:hover,._field_18806_90:-webkit-autofill:focus{-webkit-box-shadow:inset 0 0 0 1000px var(--u-color-surface),0 0 0 1px var(--u-edge-color-strong);-webkit-text-fill-color:var(--u-color-text);caret-color:var(--u-color-accent)}}@layer umriss.components{._frame_abb5t_24,._frame_abb5t_24:before,._frame_abb5t_24:after{box-sizing:border-box}._calculation_abb5t_51,._calculation_abb5t_51:before,._calculation_abb5t_51:after{box-sizing:border-box}._line_abb5t_86,._line_abb5t_86:before,._line_abb5t_86:after{box-sizing:border-box}._assessment_abb5t_98,._assessment_abb5t_98:before,._assessment_abb5t_98:after{box-sizing:border-box}._disclosure_abb5t_107,._disclosure_abb5t_107:before,._disclosure_abb5t_107:after{box-sizing:border-box}._amount_abb5t_90,._amount_abb5t_90:before,._amount_abb5t_90:after{box-sizing:border-box}._list_abb5t_128,._list_abb5t_128:before,._list_abb5t_128:after{box-sizing:border-box}._item_abb5t_129,._item_abb5t_129:before,._item_abb5t_129:after{box-sizing:border-box}._derivation_abb5t_130,._derivation_abb5t_130:before,._derivation_abb5t_130:after{box-sizing:border-box}._labelCell_abb5t_90,._labelCell_abb5t_90:before,._labelCell_abb5t_90:after{box-sizing:border-box}._names_abb5t_90,._names_abb5t_90:before,._names_abb5t_90:after{box-sizing:border-box}._operator_abb5t_90,._operator_abb5t_90:before,._operator_abb5t_90:after{box-sizing:border-box}._unit_abb5t_90,._unit_abb5t_90:before,._unit_abb5t_90:after{box-sizing:border-box}._label_abb5t_90,._label_abb5t_90:before,._label_abb5t_90:after{box-sizing:border-box}._approximate_abb5t_345,._approximate_abb5t_345:before,._approximate_abb5t_345:after{box-sizing:border-box}._target_abb5t_102,._target_abb5t_102:before,._target_abb5t_102:after{box-sizing:border-box}._worst_abb5t_102,._worst_abb5t_102:before,._worst_abb5t_102:after{box-sizing:border-box}._head_abb5t_497,._head_abb5t_497:before,._head_abb5t_497:after{box-sizing:border-box}._headCell_abb5t_504,._headCell_abb5t_504:before,._headCell_abb5t_504:after{box-sizing:border-box}._headUnit_abb5t_517,._headUnit_abb5t_517:before,._headUnit_abb5t_517:after{box-sizing:border-box}._notes_abb5t_524,._notes_abb5t_524:before,._notes_abb5t_524:after{box-sizing:border-box}._freshness_abb5t_538,._freshness_abb5t_538:before,._freshness_abb5t_538:after{box-sizing:border-box}._headLabel_abb5t_568,._headLabel_abb5t_568:before,._headLabel_abb5t_568:after{box-sizing:border-box}._frame_abb5t_24{font-size:var(--u-text-sm);border-radius:var(--u-radius-md);corner-shape:squircle;background:var(--u-color-surface);outline:1px solid transparent;box-shadow:var(--u-edge);overflow-x:auto;overflow-y:hidden;--disclosure-size: 20px;--disclosure-gap: var(--u-space-2);--line-pad: var(--u-space-2);--line-gap: var(--u-space-1);container-type:inline-size;width:100%}._calculation_abb5t_51{display:grid;grid-template-columns:fit-content(22rem) minmax(0,1fr) auto var(--figure-tracks, auto auto) auto;margin:0;padding:0;list-style:none}._frame_abb5t_24[data-compact]{--line-text: 18px;--line-pad: var(--u-space-1);--line-gap: calc(var(--u-space-1) / 2);font-size:var(--u-text-xs);line-height:var(--line-text)}@media(pointer:coarse){._frame_abb5t_24[data-compact]{--line-pad: var(--u-space-2);--line-gap: var(--u-space-1)}}._frame_abb5t_24[data-compact]:not([data-two-lines]) ._line_abb5t_86{grid-template-rows:minmax(calc(var(--line-text) + 2 * var(--line-pad)),auto)}._frame_abb5t_24[data-compact]:not([data-two-lines]) :is(._labelCell_abb5t_90,._names_abb5t_90,._operator_abb5t_90,._amount_abb5t_90,._unit_abb5t_90){padding-bottom:calc(var(--line-pad) - 1px)}._frame_abb5t_24[data-compact]:not([data-two-lines]) ._assessment_abb5t_98{padding-bottom:0}._frame_abb5t_24[data-compact]:not([data-two-lines]) ._assessment_abb5t_98>:not(._target_abb5t_102,._worst_abb5t_102){margin-block:-1px}._frame_abb5t_24[data-compact] ._disclosure_abb5t_107{margin-block:-1px}._frame_abb5t_24[data-compact] ._line_abb5t_86[data-kind=result]>._amount_abb5t_90{font-size:var(--u-text-sm);text-underline-offset:3px}._frame_abb5t_24[data-still]{--disclosure-size: 0px;--disclosure-gap: 0px}._frame_abb5t_24[data-still] ._disclosure_abb5t_107{display:none}._list_abb5t_128,._item_abb5t_129,._derivation_abb5t_130{display:grid;grid-template-columns:subgrid;grid-column:1 / -1;margin:0;padding:0;list-style:none}._derivation_abb5t_130[hidden]{display:none}._derivation_abb5t_130:not([hidden]){animation:_derivationIn_abb5t_1 var(--u-duration-fast) var(--u-ease-out)}@keyframes _derivationIn_abb5t_1{0%{opacity:0}}._item_abb5t_129{--fall: calc(var(--u-space-3) + var(--depth, 0) * var(--u-space-5) + var(--disclosure-size) / 2 - 1px)}._derivation_abb5t_130{position:relative}._derivation_abb5t_130:before{content:"";position:absolute;top:0;bottom:0;left:var(--fall);z-index:1;width:2px;background:var(--u-color-accent);pointer-events:none}:not(._derivation_abb5t_130)>._item_abb5t_129[data-open]>._line_abb5t_86:not([data-mark]),:not(._derivation_abb5t_130)>._item_abb5t_129>._derivation_abb5t_130{background-color:var(--u-color-surface-sunken)}._derivation_abb5t_130 ._line_abb5t_86{border-top-color:transparent}._line_abb5t_86{position:relative;display:grid;grid-template-columns:subgrid;grid-column:1 / -1;align-items:baseline;border-top:1px solid var(--u-hairline)}._calculation_abb5t_51>._item_abb5t_129:first-child>._line_abb5t_86:first-child,._calculation_abb5t_51>._item_abb5t_129:first-child>._list_abb5t_128>._item_abb5t_129:first-child>._line_abb5t_86{border-top-color:transparent}._line_abb5t_86[data-foldable]{cursor:pointer}._line_abb5t_86[data-mark]{background:color-mix(in srgb,var(--u-color-accent-subtle) 50%,transparent)}._line_abb5t_86[data-mark=use]{background:var(--u-color-accent-subtle)}._labelCell_abb5t_90,._names_abb5t_90,._operator_abb5t_90,._amount_abb5t_90,._unit_abb5t_90,._assessment_abb5t_98{grid-row:1;padding-top:var(--line-pad);padding-bottom:var(--line-pad)}._labelCell_abb5t_90{grid-column:1;display:flex;align-items:baseline;gap:var(--disclosure-gap);min-width:0;padding-left:calc(var(--u-space-3) + var(--depth, 0) * var(--u-space-5));padding-right:var(--u-space-5)}._label_abb5t_90{min-width:0;color:var(--u-color-text)}._line_abb5t_86[data-reference] ._label_abb5t_90{font-style:italic;color:var(--u-color-text-secondary)}._disclosure_abb5t_107{flex:none;align-self:center;display:inline-flex;align-items:center;justify-content:center;width:var(--disclosure-size);height:var(--disclosure-size);padding:0;border:none;border-radius:var(--u-radius-xs);corner-shape:squircle;background:none;color:var(--u-color-text-muted)}button._disclosure_abb5t_107{box-sizing:border-box}button._disclosure_abb5t_107{cursor:pointer}button._disclosure_abb5t_107:hover,._line_abb5t_86[data-foldable]:hover button._disclosure_abb5t_107{box-sizing:border-box}button._disclosure_abb5t_107:hover,._line_abb5t_86[data-foldable]:hover button._disclosure_abb5t_107{background:var(--u-color-surface-sunken);color:var(--u-color-text)}button._disclosure_abb5t_107:active,._line_abb5t_86[data-foldable]:active button._disclosure_abb5t_107{box-sizing:border-box}button._disclosure_abb5t_107:active,._line_abb5t_86[data-foldable]:active button._disclosure_abb5t_107{background:var(--u-color-surface-pressed)}._item_abb5t_129[data-open]>._line_abb5t_86 button._disclosure_abb5t_107{box-sizing:border-box}._item_abb5t_129[data-open]>._line_abb5t_86 button._disclosure_abb5t_107{color:var(--u-color-accent)}button._disclosure_abb5t_107:focus-visible{box-sizing:border-box}button._disclosure_abb5t_107:focus-visible{outline:2px solid transparent;box-shadow:var(--u-focus-ring)}._disclosure_abb5t_107 svg{box-sizing:border-box}._disclosure_abb5t_107 svg{transition:transform var(--u-transition-path)}._disclosure_abb5t_107 svg[data-open]{box-sizing:border-box}._disclosure_abb5t_107 svg[data-open]{transform:rotate(90deg)}._names_abb5t_90{grid-column:2;min-width:0;overflow:hidden;padding-right:var(--u-space-4);white-space:nowrap;text-overflow:ellipsis;color:var(--u-color-text-secondary)}._operator_abb5t_90,._amount_abb5t_90,._unit_abb5t_90{font-family:var(--u-font-mono);font-variant-numeric:tabular-nums;font-feature-settings:"tnum" 1;white-space:nowrap}._operator_abb5t_90{grid-column:3;padding-right:var(--u-space-3);text-align:right;color:var(--u-color-text-secondary)}._amount_abb5t_90{grid-column:var(--column, 4);text-align:right;color:var(--u-color-text)}._amount_abb5t_90[data-verdict=unknown]{color:var(--u-color-text-secondary)}._approximate_abb5t_345{display:inline-block;margin-right:var(--u-space-1);color:var(--u-color-text-secondary);cursor:help}._unit_abb5t_90{grid-column:var(--column, 5);padding-left:var(--u-space-1);padding-right:var(--u-space-3);color:var(--u-color-text-secondary)}._assessment_abb5t_98{grid-column:var(--assessment-column, 6);display:flex;align-items:baseline;justify-content:flex-end;gap:var(--u-space-2);padding-right:var(--u-space-3);white-space:nowrap}._assessment_abb5t_98:empty{padding-right:0}._target_abb5t_102,._worst_abb5t_102{font-size:var(--u-text-xs);color:var(--u-color-text-secondary)}._worst_abb5t_102:before{content:"● "}._worst_abb5t_102[data-verdict=unknown]:before{color:var(--u-color-text-muted)}._worst_abb5t_102[data-verdict=warning]:before{color:var(--u-color-warning)}._worst_abb5t_102[data-verdict=alarm]:before{color:var(--u-color-danger-text)}._line_abb5t_86[data-inner]>._amount_abb5t_90{color:var(--u-color-text-secondary)}._line_abb5t_86[data-kind=interim] ._label_abb5t_90,._line_abb5t_86[data-kind=interim]>._amount_abb5t_90{font-weight:var(--u-weight-medium)}._line_abb5t_86[data-emphasis=strong] ._label_abb5t_90,._line_abb5t_86[data-emphasis=strong]>._amount_abb5t_90{font-weight:var(--u-weight-semibold);color:var(--u-color-text)}._line_abb5t_86[data-emphasis=muted] ._label_abb5t_90,._line_abb5t_86[data-emphasis=muted]>._amount_abb5t_90{color:var(--u-color-text-secondary)}._line_abb5t_86[data-inner][data-emphasis=muted] ._label_abb5t_90,._line_abb5t_86[data-inner][data-emphasis=muted]>._amount_abb5t_90{color:var(--u-color-text-muted)}._line_abb5t_86[data-rule],._derivation_abb5t_130 ._line_abb5t_86[data-rule]{border-top:1px solid var(--u-color-text-secondary)}._line_abb5t_86[data-kind=interim]:before{content:"";grid-row:1;grid-column:3 / var(--figures-end, 6);align-self:start;border-top:1px solid var(--u-color-text-secondary);pointer-events:none}._line_abb5t_86[data-closing] ._label_abb5t_90{font-weight:var(--u-weight-medium);color:var(--u-color-text-secondary)}._line_abb5t_86[data-closing]:before{content:"";grid-row:1;grid-column:3 / var(--figures-end, 6);align-self:start;border-top:1px solid var(--u-color-text-muted);pointer-events:none}._line_abb5t_86[data-kind=result]{border-top:1px solid var(--u-edge-color-strong)}._line_abb5t_86[data-kind=result]:not([data-mark]){background:var(--u-color-surface-sunken)}._line_abb5t_86[data-kind=result] ._label_abb5t_90{font-weight:var(--u-weight-semibold)}._line_abb5t_86[data-kind=result]>._amount_abb5t_90{font-size:var(--u-text-md);font-weight:var(--u-weight-semibold)}._line_abb5t_86[data-kind=result]>._amount_abb5t_90:not([data-verdict=unknown]){text-decoration-line:underline;text-decoration-style:double;text-underline-offset:5px}._amount_abb5t_90[data-later]{padding-left:var(--u-space-6)}._head_abb5t_497{display:grid;grid-template-columns:subgrid;grid-column:1 / -1;align-items:end}._headCell_abb5t_504{grid-row:1;grid-column:var(--column);display:flex;flex-direction:column;align-items:flex-end;padding:var(--line-pad) 0 var(--u-space-1);font-size:var(--u-text-xs);font-weight:var(--u-weight-medium);color:var(--u-color-text-secondary);white-space:nowrap}._headUnit_abb5t_517{font-family:var(--u-font-mono);font-weight:var(--u-weight-regular)}._notes_abb5t_524{grid-row:2;grid-column:1 / 3;display:flex;flex-wrap:wrap;align-items:center;column-gap:var(--u-space-3);margin-top:calc(-1 * var(--line-gap));padding:0 var(--u-space-4) var(--line-pad) calc(var(--u-space-3) + var(--depth, 0) * var(--u-space-5) + var(--disclosure-size) + var(--disclosure-gap));font-size:var(--u-text-xs);color:var(--u-color-text-secondary)}._freshness_abb5t_538[data-freshness=stale]{color:var(--u-color-warning)}._freshness_abb5t_538[data-freshness=lost]{color:var(--u-color-danger-text);font-weight:var(--u-weight-medium)}@container (max-width: 34rem){._calculation_abb5t_51{grid-template-columns:minmax(0,1fr) 0 auto var(--figure-tracks, auto auto) 0}._amount_abb5t_90[data-later]{padding-left:var(--u-space-2)}._frame_abb5t_24[data-metrics] ._unit_abb5t_90:not([data-last]){padding-right:var(--u-space-2)}._headCell_abb5t_504[data-unit] ._headLabel_abb5t_568,._names_abb5t_90{display:none}._labelCell_abb5t_90{padding-right:var(--u-space-3)}._assessment_abb5t_98:not(:empty){grid-area:2 / 1 / 3 / -1;justify-content:flex-start;flex-wrap:wrap;min-width:0;overflow:hidden;padding:0 var(--u-space-3) var(--line-pad) calc(var(--u-space-3) + var(--depth, 0) * var(--u-space-5) + var(--disclosure-size) + var(--disclosure-gap));white-space:normal}._frame_abb5t_24[data-compact]:not([data-two-lines]) ._assessment_abb5t_98:not(:empty){padding-bottom:var(--line-pad)}._frame_abb5t_24[data-compact]:not([data-two-lines]) ._assessment_abb5t_98:not(:empty)>:not(._target_abb5t_102,._worst_abb5t_102){margin-block:0}._notes_abb5t_524{grid-row:3;grid-column:1 / -1}}._frame_abb5t_24[data-two-lines] ._labelCell_abb5t_90{grid-column:1 / -1;padding-bottom:0}._frame_abb5t_24[data-two-lines] ._names_abb5t_90{display:none}._frame_abb5t_24[data-two-lines] ._line_abb5t_86>._operator_abb5t_90,._frame_abb5t_24[data-two-lines] ._line_abb5t_86>._amount_abb5t_90,._frame_abb5t_24[data-two-lines] ._line_abb5t_86>._unit_abb5t_90{grid-row:2;padding-top:var(--line-gap)}._frame_abb5t_24[data-two-lines] ._line_abb5t_86[data-kind=interim]:before,._frame_abb5t_24[data-two-lines] ._line_abb5t_86[data-closing]:before{grid-row:2}._frame_abb5t_24[data-two-lines] ._assessment_abb5t_98:not(:empty){grid-area:3 / 1 / 4 / -1;justify-content:flex-start;flex-wrap:wrap;min-width:0;overflow:hidden;padding:0 var(--u-space-3) var(--line-pad) calc(var(--u-space-3) + var(--depth, 0) * var(--u-space-5) + var(--disclosure-size) + var(--disclosure-gap));white-space:normal}._frame_abb5t_24[data-two-lines] ._notes_abb5t_524{grid-row:4;grid-column:1 / -1}@media(prefers-reduced-motion:reduce){._disclosure_abb5t_107 svg{transition:none}._derivation_abb5t_130:not([hidden]){animation:none}}@media(forced-colors:active){._line_abb5t_86[data-mark]{outline:1px solid Highlight;outline-offset:-1px}._line_abb5t_86[data-mark=use]{outline-width:2px;outline-offset:-2px}._derivation_abb5t_130:before{background:CanvasText}._line_abb5t_86[data-emphasis=muted] ._label_abb5t_90,._line_abb5t_86[data-emphasis=muted]>._amount_abb5t_90{color:GrayText}}}
|
package/dist/calculation.js
CHANGED
|
@@ -1,72 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import "./calculation.css";
|
|
2
|
-
import { jsx as
|
|
3
|
+
import { jsx as g, jsxs as R } from "react/jsx-runtime";
|
|
3
4
|
import { Children as ke, isValidElement as K, Fragment as Me, useId as Te, useState as re, useRef as Ee, useCallback as Ae, useLayoutEffect as Re, useEffect as De } from "react";
|
|
4
|
-
import { assess as Ie, verdictWeight as
|
|
5
|
+
import { assess as Ie, verdictWeight as se, useDensityFor as Pe, useFormats as Oe, useWording as Se, VisuallyHidden as je, AngleGlyph as Be, Badge as le, useFreshness as Le, Tooltip as Fe } from "@umriss-ui/core";
|
|
5
6
|
function We(t) {
|
|
6
7
|
return t.decimals !== void 0 ? t.decimals : t.format === "percent" ? 1 : t.given ? void 0 : 2;
|
|
7
8
|
}
|
|
8
9
|
function Ue(t, e) {
|
|
9
10
|
return e === void 0 ? t : Math.sign(t) * Number(Math.abs(t).toFixed(e)) || 0;
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
+
function ae(t, e) {
|
|
12
13
|
return Ue(t.format === "percent" ? e * 100 : e, We(t));
|
|
13
14
|
}
|
|
14
15
|
const Qe = (t, e) => t.format === "percent" ? e / 100 : e;
|
|
15
|
-
function
|
|
16
|
-
const [
|
|
16
|
+
function be(t, e, p) {
|
|
17
|
+
const [s, ...i] = e;
|
|
17
18
|
switch (t) {
|
|
18
19
|
case "sum":
|
|
19
20
|
return e.reduce((n, c, S) => p[S] ? n - c : n + c, 0);
|
|
20
21
|
case "difference":
|
|
21
|
-
return i.reduce((n, c) => n - c,
|
|
22
|
+
return i.reduce((n, c) => n - c, s);
|
|
22
23
|
case "product":
|
|
23
|
-
return i.reduce((n, c) => n * c,
|
|
24
|
+
return i.reduce((n, c) => n * c, s);
|
|
24
25
|
case "quotient":
|
|
25
|
-
return
|
|
26
|
+
return s / i[0];
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
|
-
const
|
|
29
|
+
const ge = (t, e) => e === void 0 || t !== void 0 && se(t) >= se(e) ? t : e;
|
|
29
30
|
function Ve(t) {
|
|
30
|
-
const e = /* @__PURE__ */ new Map(), p = (
|
|
31
|
+
const e = /* @__PURE__ */ new Map(), p = (s) => {
|
|
31
32
|
var r, u, $;
|
|
32
|
-
const i = e.get(
|
|
33
|
+
const i = e.get(s);
|
|
33
34
|
if (i) return i;
|
|
34
|
-
const n = t.quantities.get(
|
|
35
|
+
const n = t.quantities.get(s);
|
|
35
36
|
let c = null, S, l = !1, y;
|
|
36
37
|
if (n.given) {
|
|
37
|
-
const
|
|
38
|
-
typeof
|
|
38
|
+
const a = n.given.value;
|
|
39
|
+
typeof a == "number" && Number.isFinite(a) ? c = a : S = { kind: "missing", label: n.label };
|
|
39
40
|
} else {
|
|
40
|
-
const
|
|
41
|
-
for (const { operand: v, verdict: k, worst: M } of
|
|
42
|
-
const x = v.reference ? k :
|
|
43
|
-
y =
|
|
41
|
+
const a = n.operands.map((v) => ({ operand: v, ...p(v.key) }));
|
|
42
|
+
for (const { operand: v, verdict: k, worst: M } of a) {
|
|
43
|
+
const x = v.reference ? k : ge(k, M);
|
|
44
|
+
y = ge(y, x);
|
|
44
45
|
}
|
|
45
|
-
S = (r =
|
|
46
|
-
const w =
|
|
46
|
+
S = (r = a.find((v) => v.absence)) == null ? void 0 : r.absence;
|
|
47
|
+
const w = a[1];
|
|
47
48
|
if (!S && n.operator === "quotient" && w.value === 0 && (S = { kind: "zero", label: t.quantities.get(w.operand.key).label }), !S) {
|
|
48
49
|
const v = n.operands.map((M) => M.negated === !0);
|
|
49
|
-
c =
|
|
50
|
-
const k =
|
|
50
|
+
c = be(n.operator, a.map((M) => M.value), v);
|
|
51
|
+
const k = be(
|
|
51
52
|
n.operator,
|
|
52
|
-
|
|
53
|
+
a.map((M) => Qe(t.quantities.get(M.operand.key), M.shown)),
|
|
53
54
|
v
|
|
54
55
|
);
|
|
55
|
-
l =
|
|
56
|
+
l = ae(n, k) !== ae(n, c);
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
const A = { target: n.target, limits: n.limits }, L = n.target !== void 0 || (((u = n.limits) == null ? void 0 : u.length) ?? 0) > 0 ? Ie(c, A) : void 0, V = ((($ = n.limits) == null ? void 0 : $.length) ?? 0) > 0 ? L.verdict : c === null ? "unknown" : void 0, F = {
|
|
59
60
|
value: c,
|
|
60
61
|
absence: S,
|
|
61
|
-
shown: c === null ? null :
|
|
62
|
+
shown: c === null ? null : ae(n, c),
|
|
62
63
|
approximate: l,
|
|
63
64
|
assessment: L,
|
|
64
65
|
verdict: V,
|
|
65
66
|
worst: y
|
|
66
67
|
};
|
|
67
|
-
return e.set(
|
|
68
|
+
return e.set(s, F), F;
|
|
68
69
|
};
|
|
69
|
-
for (const
|
|
70
|
+
for (const s of t.quantities.keys()) p(s);
|
|
70
71
|
return e;
|
|
71
72
|
}
|
|
72
73
|
const ze = () => null, Ge = () => null, He = () => null, Ke = () => null, Ye = () => null, $e = () => null, Je = () => null, Ze = () => null, Xe = () => null, et = () => null, tt = () => null, ce = () => null, nt = /* @__PURE__ */ new Map([
|
|
@@ -84,7 +85,7 @@ const ze = () => null, Ge = () => null, He = () => null, Ke = () => null, Ye = (
|
|
|
84
85
|
[Xe, { name: "Minus", operator: "sum", negated: !0 }],
|
|
85
86
|
[et, { name: "Times", operator: "product" }],
|
|
86
87
|
[tt, { name: "DividedBy", operator: "quotient" }]
|
|
87
|
-
]), de = "<Given>, <Sum>, <Difference>, <Product>, <Quotient> or <Chain>", ye = "a calculation with metrics only adds and subtracts - <Sum>, <Difference>, <Plus>, <Minus>.",
|
|
88
|
+
]), de = "<Given>, <Sum>, <Difference>, <Product>, <Quotient> or <Chain>", ye = "a calculation with metrics only adds and subtracts - <Sum>, <Difference>, <Plus>, <Minus>.", at = ["unit", "format", "decimals"];
|
|
88
89
|
function O(t) {
|
|
89
90
|
throw new Error(`@umriss-ui/calculation: ${t}`);
|
|
90
91
|
}
|
|
@@ -99,7 +100,7 @@ function ne(t) {
|
|
|
99
100
|
return typeof e == "string" ? `<${e}>` : `<${e.displayName ?? e.name ?? "anonymous"}>`;
|
|
100
101
|
}
|
|
101
102
|
const fe = (t, e, p) => `${t}/${K(e) && e.key || p}`;
|
|
102
|
-
function
|
|
103
|
+
function ot(t, e) {
|
|
103
104
|
const p = ee(t);
|
|
104
105
|
if (p.length !== 1 && O(`<Calculation> takes exactly one child, the result; it was given ${p.length}.`), e !== void 0) {
|
|
105
106
|
e.length === 0 && O("<Calculation>: metrics is empty; leave it out for a calculation with one number per quantity.");
|
|
@@ -107,103 +108,103 @@ function at(t, e) {
|
|
|
107
108
|
for (const { id: u } of e)
|
|
108
109
|
r.has(u) && O(`<Calculation>: the metric id "${u}" is used twice.`), r.add(u);
|
|
109
110
|
}
|
|
110
|
-
const
|
|
111
|
+
const s = e == null ? void 0 : e.map((r) => `"${r.id}"`).join(", "), i = (r, u) => {
|
|
111
112
|
const $ = typeof r == "object" && r !== null;
|
|
112
113
|
if (e === void 0) {
|
|
113
114
|
$ && O(`${u}: value is an object by metric, but the calculation has no metrics.`);
|
|
114
115
|
return;
|
|
115
116
|
}
|
|
116
|
-
$ || O(`${u}: with metrics, value is an object with a number for each metric - ${
|
|
117
|
-
for (const { id:
|
|
118
|
-
|
|
119
|
-
for (const
|
|
120
|
-
e.some((w) => w.id ===
|
|
117
|
+
$ || O(`${u}: with metrics, value is an object with a number for each metric - ${s}.`);
|
|
118
|
+
for (const { id: a } of e)
|
|
119
|
+
a in r || O(`${u}: value has no number for the metric "${a}"; write null where it is absent. The metrics: ${s}.`);
|
|
120
|
+
for (const a of Object.keys(r))
|
|
121
|
+
e.some((w) => w.id === a) || O(`${u}: value has a number for "${a}", which is no metric. The metrics: ${s}.`);
|
|
121
122
|
}, n = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), S = [], l = (r, u, $) => {
|
|
122
|
-
const { id:
|
|
123
|
+
const { id: a, ...w } = u;
|
|
123
124
|
if (e !== void 0) {
|
|
124
|
-
for (const k of
|
|
125
|
+
for (const k of at)
|
|
125
126
|
u[k] !== void 0 && O(`${$}: ${k} belongs to the metric once the calculation has metrics, not to a quantity.`);
|
|
126
127
|
(u.target !== void 0 || u.limits !== void 0) && O(`${$}: target and limits are not assessed in a calculation with metrics.`);
|
|
127
128
|
}
|
|
128
|
-
|
|
129
|
-
const v = { ...w, key: r, id:
|
|
129
|
+
a !== void 0 && (c.has(a) && O(`${$}: the id "${a}" is used twice.`), c.set(a, r));
|
|
130
|
+
const v = { ...w, key: r, id: a, operands: [] };
|
|
130
131
|
return n.set(r, v), v;
|
|
131
132
|
}, y = (r, u, $) => {
|
|
132
133
|
if (K(r) && r.type === $e) {
|
|
133
|
-
const
|
|
134
|
-
return S.push({ operand:
|
|
134
|
+
const a = { key: "", reference: !0 };
|
|
135
|
+
return S.push({ operand: a, to: r.props.to, where: $ }), a;
|
|
135
136
|
}
|
|
136
137
|
return { key: A(r, u, $), reference: !1 };
|
|
137
138
|
}, A = (r, u, $) => {
|
|
138
139
|
if ((!K(r) || r.type === $e || ue.has(r.type) || r.type === ce) && O(`${$}: ${ne(r)} cannot stand here; a quantity must be ${de}.`), r.type === Je) return L(r.props.children, u, $);
|
|
139
|
-
const
|
|
140
|
-
r.type !== ze &&
|
|
140
|
+
const a = nt.get(r.type);
|
|
141
|
+
r.type !== ze && a === void 0 && O(
|
|
141
142
|
`${$}: ${ne(r)} is not an element of the calculation. A calculation reads its children's props and cannot look inside a component of your own; write ${de} or <Ref> directly, or return them from .map.`
|
|
142
143
|
);
|
|
143
|
-
const { children: w, value: v, source: k, asOf: M, ages: x, ...D } = r.props,
|
|
144
|
-
e !== void 0 && (
|
|
145
|
-
const C = l(u, D,
|
|
146
|
-
if (
|
|
147
|
-
return i(v,
|
|
148
|
-
C.operator =
|
|
144
|
+
const { children: w, value: v, source: k, asOf: M, ages: x, ...D } = r.props, b = `${$} › ${D.label}`;
|
|
145
|
+
e !== void 0 && (a === "product" || a === "quotient") && O(`${b}: <${_e[a]}> - ${ye}`);
|
|
146
|
+
const C = l(u, D, b);
|
|
147
|
+
if (a === void 0)
|
|
148
|
+
return i(v, b), C.given = { value: v, source: k, asOf: M, ages: x }, u;
|
|
149
|
+
C.operator = a;
|
|
149
150
|
const _ = ee(w), N = _.length;
|
|
150
|
-
return (
|
|
151
|
-
`${
|
|
152
|
-
), C.operands = _.map((
|
|
151
|
+
return (a === "quotient" ? N !== 2 : a !== "sum" && N < 2) && O(
|
|
152
|
+
`${b}: <${_e[a]}> takes ${a === "quotient" ? "exactly two operands" : "two or more operands"}; it was given ${N}.`
|
|
153
|
+
), C.operands = _.map((o, d) => y(o, fe(u, o, d), b)), u;
|
|
153
154
|
}, L = (r, u, $) => {
|
|
154
|
-
const
|
|
155
|
-
(w === void 0 || K(w) && (ue.has(w.type) || w.type === ce)) && O(`${
|
|
156
|
-
let k = y(w, fe(u, w, 0),
|
|
157
|
-
return v.forEach((
|
|
158
|
-
const _ = fe(u,
|
|
159
|
-
if (K(
|
|
160
|
-
const U =
|
|
155
|
+
const a = `${$} › <Chain>`, [w, ...v] = ee(r);
|
|
156
|
+
(w === void 0 || K(w) && (ue.has(w.type) || w.type === ce)) && O(`${a}: a chain starts with a quantity that has no operator - ${de} or <Ref>.`);
|
|
157
|
+
let k = y(w, fe(u, w, 0), a), M = ne(w), x = [], D;
|
|
158
|
+
return v.forEach((b, C) => {
|
|
159
|
+
const _ = fe(u, b, C + 1);
|
|
160
|
+
if (K(b) && b.type === ce) {
|
|
161
|
+
const U = b.props, G = `${a} › ${U.label}`;
|
|
161
162
|
x.length === 0 && O(`${G}: an <Interim> needs an operand since the named value before it, ${M}.`);
|
|
162
163
|
const H = l(_, U, G);
|
|
163
164
|
H.interim = !0, H.operator = x[0].line.operator, H.operands = [k, ...x.map((te) => te.operand)], k = { key: _, reference: !1, previous: !0 }, M = `<Interim label="${U.label}">`, x = [], D = _;
|
|
164
165
|
return;
|
|
165
166
|
}
|
|
166
|
-
const N = K(
|
|
167
|
-
N === void 0 && O(`${
|
|
168
|
-
const
|
|
169
|
-
(
|
|
170
|
-
`${
|
|
167
|
+
const N = K(b) ? ue.get(b.type) : void 0;
|
|
168
|
+
N === void 0 && O(`${a}: ${ne(b)} needs an operator in a chain - <Plus>, <Minus>, <Times> or <DividedBy> - or is an <Interim>.`), e !== void 0 && N.operator !== "sum" && O(`${a}: <${N.name}> - ${ye}`);
|
|
169
|
+
const o = N.operator !== "sum", d = x.find((U) => U.line.operator !== "sum");
|
|
170
|
+
(o && x.length > 0 || d) && O(
|
|
171
|
+
`${a}: <${(d ?? { line: N }).line.name}> stands alone between two named values - directly after the first quantity or an <Interim>, and directly before an <Interim>.`
|
|
171
172
|
);
|
|
172
|
-
const { children: h, ...T } =
|
|
173
|
+
const { children: h, ...T } = b.props, f = ee(h), I = () => O(`${a}: <${N.name}> takes either a label and a value, or exactly one quantity as its child.`);
|
|
173
174
|
if (f.length > 0) {
|
|
174
175
|
(f.length > 1 || Object.values(T).some((G) => G !== void 0)) && I();
|
|
175
|
-
const U = y(f[0], _,
|
|
176
|
+
const U = y(f[0], _, a);
|
|
176
177
|
U.negated = N.negated, x.push({ operand: U, line: N });
|
|
177
178
|
return;
|
|
178
179
|
}
|
|
179
180
|
T.label === void 0 && I();
|
|
180
|
-
const { value: P, source: E, asOf: j, ages: Y, ...z } = T, B = `${
|
|
181
|
+
const { value: P, source: E, asOf: j, ages: Y, ...z } = T, B = `${a} › ${T.label}`, W = l(_, { ...z, label: T.label }, B);
|
|
181
182
|
i(P, B), W.given = { value: P, source: E, asOf: j, ages: Y }, x.push({ operand: { key: _, reference: !1, negated: N.negated }, line: N });
|
|
182
|
-
}), (x.length > 0 || D === void 0) && O(`${
|
|
183
|
+
}), (x.length > 0 || D === void 0) && O(`${a}: a chain ends with an <Interim>, which names its value.`), D;
|
|
183
184
|
}, V = A(p[0], "0", "<Calculation>"), F = n.get(V);
|
|
184
185
|
(F.emphasis !== void 0 || F.rule !== void 0) && O(`<Calculation> › ${F.label}: emphasis and rule do not stand on the Result, which is already the heaviest line.`);
|
|
185
186
|
for (const { operand: r, to: u, where: $ } of S) {
|
|
186
|
-
const
|
|
187
|
-
if (
|
|
187
|
+
const a = c.get(u);
|
|
188
|
+
if (a === void 0) {
|
|
188
189
|
const w = [...c.keys()].map((v) => `"${v}"`).join(", ");
|
|
189
190
|
O(`${$}: <Ref to="${u}"> names no quantity. ${w ? `The ids that exist: ${w}.` : "No quantity has an id."}`);
|
|
190
191
|
}
|
|
191
|
-
r.key =
|
|
192
|
+
r.key = a;
|
|
192
193
|
}
|
|
193
194
|
return it(n), { result: V, quantities: n, metrics: e };
|
|
194
195
|
}
|
|
195
|
-
function
|
|
196
|
+
function st(t) {
|
|
196
197
|
return t.metrics ? t.metrics.map((e) => {
|
|
197
198
|
const p = /* @__PURE__ */ new Map();
|
|
198
|
-
for (const [
|
|
199
|
+
for (const [s, i] of t.quantities) {
|
|
199
200
|
const n = i.given && { ...i.given, value: i.given.value[e.id] };
|
|
200
|
-
p.set(
|
|
201
|
+
p.set(s, { ...i, unit: e.unit, decimals: e.decimals, given: n });
|
|
201
202
|
}
|
|
202
203
|
return { result: t.result, quantities: p };
|
|
203
204
|
}) : [t];
|
|
204
205
|
}
|
|
205
206
|
function it(t) {
|
|
206
|
-
const e = /* @__PURE__ */ new Set(), p = [],
|
|
207
|
+
const e = /* @__PURE__ */ new Set(), p = [], s = (i) => {
|
|
207
208
|
if (e.has(i)) return;
|
|
208
209
|
const n = p.indexOf(i);
|
|
209
210
|
if (n !== -1) {
|
|
@@ -211,18 +212,18 @@ function it(t) {
|
|
|
211
212
|
O(`the calculation goes round in a circle through references: ${c.join(" → ")}.`);
|
|
212
213
|
}
|
|
213
214
|
p.push(i);
|
|
214
|
-
for (const c of t.get(i).operands)
|
|
215
|
+
for (const c of t.get(i).operands) s(c.key);
|
|
215
216
|
p.pop(), e.add(i);
|
|
216
217
|
};
|
|
217
|
-
for (const i of t.keys())
|
|
218
|
+
for (const i of t.keys()) s(i);
|
|
218
219
|
}
|
|
219
220
|
const we = 4;
|
|
220
221
|
function rt(t, e, p) {
|
|
221
|
-
const
|
|
222
|
-
if (
|
|
222
|
+
const s = t.operands[e];
|
|
223
|
+
if (s.previous) return;
|
|
223
224
|
const i = t.operator, n = e === 0;
|
|
224
225
|
if (i !== "sum" && i !== "difference") return n ? void 0 : { operator: i, negated: !1 };
|
|
225
|
-
const c = i === "difference" ? !n :
|
|
226
|
+
const c = i === "difference" ? !n : s.negated === !0, S = new Set(p.filter((y) => y !== null && y !== 0).map(Math.sign)), l = S.size === 1 ? { operator: "sum", negated: c !== S.has(-1), unsigned: !0 } : { operator: "sum", negated: c };
|
|
226
227
|
return n && !l.negated ? void 0 : l;
|
|
227
228
|
}
|
|
228
229
|
const lt = {
|
|
@@ -236,7 +237,7 @@ const lt = {
|
|
|
236
237
|
product: "calculationProductWord",
|
|
237
238
|
quotient: "calculationQuotientWord"
|
|
238
239
|
};
|
|
239
|
-
function
|
|
240
|
+
function oe(t, e) {
|
|
240
241
|
switch (t) {
|
|
241
242
|
case "alarm":
|
|
242
243
|
return e.verdictAlarm;
|
|
@@ -249,61 +250,61 @@ function ae(t, e) {
|
|
|
249
250
|
}
|
|
250
251
|
}
|
|
251
252
|
function ie(t, e, p) {
|
|
252
|
-
const
|
|
253
|
-
return p[(e ? ct : lt)[
|
|
253
|
+
const s = t.negated ? "difference" : t.operator;
|
|
254
|
+
return p[(e ? ct : lt)[s]];
|
|
254
255
|
}
|
|
255
256
|
function ut(t, e) {
|
|
256
257
|
return t.kind === "missing" ? e.calculationMissing(t.label) : e.calculationDivisionByZero(t.label);
|
|
257
258
|
}
|
|
258
|
-
function Ne(t, e, p,
|
|
259
|
-
const i = t.format === "percent" ?
|
|
259
|
+
function Ne(t, e, p, s) {
|
|
260
|
+
const i = t.format === "percent" ? s : t.unit, n = p.number(e, t.decimals);
|
|
260
261
|
return i ? `${n} ${i}` : n;
|
|
261
262
|
}
|
|
262
|
-
function dt(t, e, p,
|
|
263
|
+
function dt(t, e, p, s, i, n, c, S = () => {
|
|
263
264
|
}) {
|
|
264
|
-
const l = t.quantities.get(p), y = e.get(p), A = (
|
|
265
|
-
const
|
|
266
|
-
return
|
|
267
|
-
}, V = (
|
|
268
|
-
if (
|
|
265
|
+
const l = t.quantities.get(p), y = e.get(p), A = (b, C) => b.shown !== null && (C != null && C.unsigned) ? Math.abs(b.shown) : b.shown, L = (b, C, _, N) => {
|
|
266
|
+
const o = A(C, N);
|
|
267
|
+
return o === null ? _ ? n.verdictUnknown : n.statAbsentValue : Ne(b, o, i, _ ? n.calculationPercent : "%");
|
|
268
|
+
}, V = (b) => {
|
|
269
|
+
if (s || !l.operator) return {};
|
|
269
270
|
if (l.operands.length === 0) return { names: n.calculationNoOperands };
|
|
270
|
-
if (!
|
|
271
|
+
if (!b && l.operands.length > we)
|
|
271
272
|
return { names: n.calculationOperandCount(l.operands.length) };
|
|
272
|
-
const C = (_) => l.operands.map((N,
|
|
273
|
-
const d = t.quantities.get(N.key), h = S(
|
|
274
|
-
return h ? `${ie(h,
|
|
273
|
+
const C = (_) => l.operands.map((N, o) => {
|
|
274
|
+
const d = t.quantities.get(N.key), h = S(o);
|
|
275
|
+
return h ? `${ie(h, b, n)} ${_(d, h)}` : _(d);
|
|
275
276
|
}).join(" ");
|
|
276
277
|
return {
|
|
277
278
|
names: C((_) => _.label),
|
|
278
|
-
numbers: C((_, N) => L(_, e.get(_.key),
|
|
279
|
+
numbers: C((_, N) => L(_, e.get(_.key), b, N))
|
|
279
280
|
};
|
|
280
|
-
}, F = (
|
|
281
|
+
}, F = (b) => {
|
|
281
282
|
var N;
|
|
282
283
|
const C = (N = y.assessment) == null ? void 0 : N.deviation;
|
|
283
284
|
if (C === void 0 || l.target === void 0) return;
|
|
284
|
-
const _ = Ne(l,
|
|
285
|
+
const _ = Ne(l, ae(l, l.target), i, b ? n.calculationPercent : "%");
|
|
285
286
|
return C > 0 ? n.calculationAboveTarget(_) : C < 0 ? n.calculationBelowTarget(_) : n.calculationOnTarget(_);
|
|
286
|
-
}, r = V(!1).names, u = r === void 0 || l.operands.length === 0 || l.operands.length > we ? r : `= ${r}`, $ = V(!0),
|
|
287
|
+
}, r = V(!1).names, u = r === void 0 || l.operands.length === 0 || l.operands.length > we ? r : `= ${r}`, $ = V(!0), a = y.absence ? ut(y.absence, n) : void 0, w = ` ${n.calculationEquals} `, v = y.approximate ? `${n.calculationApproximately} ${L(l, y, !0, c)}` : L(l, y, !0, c), M = [
|
|
287
288
|
(c ? `${ie(c, !0, n)} ` : "") + l.label + w + [$.names, $.numbers, v].filter(Boolean).join(`,${w}`),
|
|
288
|
-
y.verdict !== void 0 && y.verdict !== "unknown" ?
|
|
289
|
+
y.verdict !== void 0 && y.verdict !== "unknown" ? oe(y.verdict, n) : void 0,
|
|
289
290
|
F(!0),
|
|
290
|
-
|
|
291
|
-
].filter(Boolean).join(", "), x = y.shown === null ? void 0 : l.format === "percent" ? "%" : l.unit, D = (
|
|
292
|
-
return { amount: D(A(y, c)), ownAmount: D(y.shown), unit: x, names: u, target: F(!1), reason:
|
|
291
|
+
a
|
|
292
|
+
].filter(Boolean).join(", "), x = y.shown === null ? void 0 : l.format === "percent" ? "%" : l.unit, D = (b) => b === null ? n.statAbsentValue : i.number(b, l.decimals);
|
|
293
|
+
return { amount: D(A(y, c)), ownAmount: D(y.shown), unit: x, names: u, target: F(!1), reason: a, sentence: M, spokenNames: $.names, spokenNumber: v };
|
|
293
294
|
}
|
|
294
|
-
function ft(t, e, p,
|
|
295
|
-
const n = i ? `${ie(i, !0,
|
|
295
|
+
function ft(t, e, p, s, i) {
|
|
296
|
+
const n = i ? `${ie(i, !0, s)} ` : "", c = e[0].spokenNames, S = n + t + (c === void 0 ? "" : ` ${s.calculationEquals} ${c}`), l = p.map(
|
|
296
297
|
(y, A) => [`${y.label} ${e[A].spokenNumber}`, e[A].reason].filter(Boolean).join(", ")
|
|
297
298
|
);
|
|
298
299
|
return `${S}: ${l.join("; ")}`;
|
|
299
300
|
}
|
|
300
|
-
const pt = "
|
|
301
|
+
const pt = "_frame_abb5t_24 _text_18806_22", mt = "_calculation_abb5t_51", ht = "_line_abb5t_86", vt = "_assessment_abb5t_98", bt = "_disclosure_abb5t_107", gt = "_amount_abb5t_90", $t = "_list_abb5t_128", _t = "_item_abb5t_129", yt = "_derivation_abb5t_130", wt = "_labelCell_abb5t_90", Nt = "_names_abb5t_90", Ot = "_operator_abb5t_90", St = "_unit_abb5t_90", Ct = "_label_abb5t_90", qt = "_approximate_abb5t_345", xt = "_target_abb5t_102", kt = "_worst_abb5t_102", Mt = "_head_abb5t_497", Tt = "_headCell_abb5t_504", Et = "_headUnit_abb5t_517", At = "_notes_abb5t_524", Rt = "_freshness_abb5t_538", Dt = "_headLabel_abb5t_568", m = {
|
|
301
302
|
frame: pt,
|
|
302
303
|
calculation: mt,
|
|
303
304
|
line: ht,
|
|
304
305
|
assessment: vt,
|
|
305
|
-
disclosure:
|
|
306
|
-
amount:
|
|
306
|
+
disclosure: bt,
|
|
307
|
+
amount: gt,
|
|
307
308
|
list: $t,
|
|
308
309
|
item: _t,
|
|
309
310
|
derivation: yt,
|
|
@@ -323,23 +324,23 @@ const pt = "_frame_is340_24 _text_1krlf_23", mt = "_calculation_is340_51", ht =
|
|
|
323
324
|
headLabel: Dt
|
|
324
325
|
}, It = 10, X = (t) => 4 + 2 * t, Pt = (t) => 5 + 2 * t, jt = { ok: "success", unknown: "neutral", warning: "warning", alarm: "danger" }, Bt = (...t) => t.filter(Boolean).join(" ");
|
|
325
326
|
function Lt({ asOf: t, ages: e }) {
|
|
326
|
-
const p = Oe(),
|
|
327
|
+
const p = Oe(), s = Se(), i = Le(t, e), n = i.freshness === "lost" ? s.freshnessDisconnected : i.freshness === "stale" ? s.freshnessStale : s.freshnessFresh;
|
|
327
328
|
return /* @__PURE__ */ R("span", { className: m.freshness, "data-freshness": i.freshness, children: [
|
|
328
329
|
n,
|
|
329
330
|
i.age !== null && ` · ${p.relative(i.age)}`
|
|
330
331
|
] });
|
|
331
332
|
}
|
|
332
|
-
function Qt({ children: t, className: e, style: p, metrics:
|
|
333
|
-
const c = Pe(i, "regular") === "compact", S = Oe(), l = Se(), y = Te(), A =
|
|
334
|
-
const
|
|
335
|
-
if (!
|
|
333
|
+
function Qt({ children: t, className: e, style: p, metrics: s, density: i, ...n }) {
|
|
334
|
+
const c = Pe(i, "regular") === "compact", S = Oe(), l = Se(), y = Te(), A = ot(t, s), L = st(A).map((o) => ({ view: o, results: Ve(o) })), [V, F] = re(() => /* @__PURE__ */ new Set()), [r, u] = re(null), $ = Ee(null), [a, w] = re(!1), v = (s == null ? void 0 : s.length) ?? 0, k = Ae(() => {
|
|
335
|
+
const o = $.current, d = o && v > 0 ? getComputedStyle(o.firstElementChild).gridTemplateColumns.split(" ").map(parseFloat) : [], h = X(v) - 1;
|
|
336
|
+
if (!o || d.length <= h || d.some((E) => !Number.isFinite(E))) {
|
|
336
337
|
w(!1);
|
|
337
338
|
return;
|
|
338
339
|
}
|
|
339
340
|
const T = d.slice(2, h).reduce((E, j) => E + j, 0);
|
|
340
341
|
let f = 0;
|
|
341
342
|
const I = document.createRange();
|
|
342
|
-
for (const E of
|
|
343
|
+
for (const E of o.querySelectorAll(`.${m.label}`)) {
|
|
343
344
|
I.selectNodeContents(E);
|
|
344
345
|
const j = [...I.getClientRects()].reduce((B, W) => B + W.width, 0);
|
|
345
346
|
if (j === 0) continue;
|
|
@@ -347,24 +348,24 @@ function Qt({ children: t, className: e, style: p, metrics: o, density: i, ...n
|
|
|
347
348
|
f = Math.max(f, z + j + parseFloat(getComputedStyle(Y).paddingRight));
|
|
348
349
|
}
|
|
349
350
|
const P = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
350
|
-
w(
|
|
351
|
+
w(o.clientWidth - T < Math.min(f, It * P));
|
|
351
352
|
}, [v]);
|
|
352
353
|
Re(() => k()), De(() => {
|
|
353
|
-
const
|
|
354
|
-
if (!
|
|
354
|
+
const o = $.current;
|
|
355
|
+
if (!o || v === 0) return;
|
|
355
356
|
const d = new ResizeObserver(() => k());
|
|
356
|
-
return d.observe(
|
|
357
|
+
return d.observe(o), () => d.disconnect();
|
|
357
358
|
}, [k, v]);
|
|
358
|
-
const M = (
|
|
359
|
+
const M = (o) => F((d) => {
|
|
359
360
|
const h = new Set(d);
|
|
360
|
-
return h.delete(
|
|
361
|
-
}), x = (
|
|
362
|
-
|
|
361
|
+
return h.delete(o) || h.add(o), h;
|
|
362
|
+
}), x = (o, d) => rt(
|
|
363
|
+
o,
|
|
363
364
|
d,
|
|
364
|
-
L.map(({ results: h }) => h.get(
|
|
365
|
+
L.map(({ results: h }) => h.get(o.operands[d].key).shown)
|
|
365
366
|
);
|
|
366
367
|
let D = !1;
|
|
367
|
-
const
|
|
368
|
+
const b = (o, d) => o.map(({ own: h, text: T }, f) => [
|
|
368
369
|
/* @__PURE__ */ R(
|
|
369
370
|
"span",
|
|
370
371
|
{
|
|
@@ -372,38 +373,38 @@ function Qt({ children: t, className: e, style: p, metrics: o, density: i, ...n
|
|
|
372
373
|
"aria-hidden": "true",
|
|
373
374
|
"data-verdict": h.verdict,
|
|
374
375
|
"data-later": f > 0 ? "" : void 0,
|
|
375
|
-
style:
|
|
376
|
+
style: s ? { "--column": X(f) } : void 0,
|
|
376
377
|
children: [
|
|
377
|
-
h.approximate && /* @__PURE__ */
|
|
378
|
+
h.approximate && /* @__PURE__ */ g(Fe, { content: l.calculationApproximateNote, children: /* @__PURE__ */ g("span", { className: m.approximate, children: "≈" }) }),
|
|
378
379
|
d ? T.ownAmount : T.amount
|
|
379
380
|
]
|
|
380
381
|
},
|
|
381
382
|
`amount-${f}`
|
|
382
383
|
),
|
|
383
|
-
/* @__PURE__ */
|
|
384
|
+
/* @__PURE__ */ g(
|
|
384
385
|
"span",
|
|
385
386
|
{
|
|
386
387
|
className: m.unit,
|
|
387
388
|
"aria-hidden": "true",
|
|
388
|
-
style:
|
|
389
|
-
"data-last":
|
|
390
|
-
children:
|
|
389
|
+
style: s ? { "--column": Pt(f) } : void 0,
|
|
390
|
+
"data-last": s && f === o.length - 1 ? "" : void 0,
|
|
391
|
+
children: s && !d ? void 0 : T.unit
|
|
391
392
|
},
|
|
392
393
|
`unit-${f}`
|
|
393
394
|
)
|
|
394
|
-
]), C = (
|
|
395
|
-
const f = A.quantities.get(
|
|
396
|
-
own: J.get(
|
|
397
|
-
text: dt(q, J,
|
|
398
|
-
})), { own: P, text: E } = I[0], j = f.operator !== void 0 && !d, Y =
|
|
395
|
+
]), C = (o, d) => r === null ? void 0 : o === r ? "use" : d === r ? "operand" : void 0, _ = (o, d, h, T) => {
|
|
396
|
+
const f = A.quantities.get(o), I = L.map(({ view: q, results: J }) => ({
|
|
397
|
+
own: J.get(o),
|
|
398
|
+
text: dt(q, J, o, d, S, l, h.position, (xe) => x(f, xe))
|
|
399
|
+
})), { own: P, text: E } = I[0], j = f.operator !== void 0 && !d, Y = o === A.result && !d, z = j && f.operands.length > 0 && (f.interim ? h.flat : Y), B = j && !z && f.operands.length > 0, W = B && V.has(o);
|
|
399
400
|
D || (D = B);
|
|
400
|
-
const U = `${y}-${
|
|
401
|
+
const U = `${y}-${o}`, G = { depth: z ? h.depth : h.depth + 1, flat: !1, parent: o }, H = j ? f.operands.find((q) => q.previous) : void 0, te = H && h.flat ? _(H.key, !1, { ...h, parent: o, position: void 0 }, `${T}-c`) : [], Ce = H && !h.flat ? _(H.key, !1, { ...G, flat: !0 }, `${T}-c`) : [], pe = j ? f.operands.map(
|
|
401
402
|
(q, J) => q.previous ? null : _(q.key, q.reference, { ...G, position: x(f, J) }, `${T}-${J}`)
|
|
402
|
-
) : [], Z = B && !W && P.worst !== void 0 &&
|
|
403
|
-
!d && f.explanation !== void 0 && /* @__PURE__ */
|
|
404
|
-
(Q == null ? void 0 : Q.source) !== void 0 && /* @__PURE__ */
|
|
405
|
-
(Q == null ? void 0 : Q.asOf) !== void 0 && (Q.ages !== void 0 ? /* @__PURE__ */
|
|
406
|
-
!d && f.aside !== void 0 && /* @__PURE__ */
|
|
403
|
+
) : [], Z = B && !W && P.worst !== void 0 && se(P.worst) > se(P.verdict ?? "ok") ? P.worst : void 0, Q = d ? void 0 : f.given, qe = h.position ? ie(h.position, !1, l) : void 0, me = [
|
|
404
|
+
!d && f.explanation !== void 0 && /* @__PURE__ */ g("span", { children: f.explanation }, "explanation"),
|
|
405
|
+
(Q == null ? void 0 : Q.source) !== void 0 && /* @__PURE__ */ g("span", { children: l.calculationSource(Q.source) }, "source"),
|
|
406
|
+
(Q == null ? void 0 : Q.asOf) !== void 0 && (Q.ages !== void 0 ? /* @__PURE__ */ g(Lt, { asOf: Q.asOf, ages: Q.ages }, "asOf") : /* @__PURE__ */ g("span", { children: l.asOfAgo(S.dateTime(new Date(Q.asOf), !1)) }, "asOf")),
|
|
407
|
+
!d && f.aside !== void 0 && /* @__PURE__ */ g("span", { children: f.aside }, "aside")
|
|
407
408
|
].filter(Boolean), he = Y ? "result" : f.interim && !d && h.flat ? "interim" : void 0, ve = /* @__PURE__ */ R(
|
|
408
409
|
"div",
|
|
409
410
|
{
|
|
@@ -415,23 +416,23 @@ function Qt({ children: t, className: e, style: p, metrics: o, density: i, ...n
|
|
|
415
416
|
"data-reference": d ? "" : void 0,
|
|
416
417
|
"data-emphasis": d ? void 0 : f.emphasis,
|
|
417
418
|
"data-rule": !d && f.rule ? "" : void 0,
|
|
418
|
-
"data-mark": C(
|
|
419
|
-
onPointerEnter: () => u(
|
|
419
|
+
"data-mark": C(o, h.parent),
|
|
420
|
+
onPointerEnter: () => u(o),
|
|
420
421
|
onPointerLeave: () => u(null),
|
|
421
|
-
onFocus: () => u(
|
|
422
|
+
onFocus: () => u(o),
|
|
422
423
|
onBlur: () => u(null),
|
|
423
424
|
onClick: B ? () => {
|
|
424
425
|
var q;
|
|
425
|
-
(q = window.getSelection()) != null && q.toString() || M(
|
|
426
|
+
(q = window.getSelection()) != null && q.toString() || M(o);
|
|
426
427
|
} : void 0,
|
|
427
428
|
children: [
|
|
428
|
-
/* @__PURE__ */
|
|
429
|
-
|
|
429
|
+
/* @__PURE__ */ g(je, { children: [
|
|
430
|
+
s ? ft(f.label, I.map((q) => q.text), s, l, h.position) : E.sentence,
|
|
430
431
|
I.some((q) => q.own.approximate) && l.calculationApproximateNote,
|
|
431
|
-
Z !== void 0 && l.calculationWorstInside(
|
|
432
|
+
Z !== void 0 && l.calculationWorstInside(oe(Z, l))
|
|
432
433
|
].filter(Boolean).join(". ") }),
|
|
433
434
|
/* @__PURE__ */ R("span", { className: m.labelCell, children: [
|
|
434
|
-
B ? /* @__PURE__ */
|
|
435
|
+
B ? /* @__PURE__ */ g(
|
|
435
436
|
"button",
|
|
436
437
|
{
|
|
437
438
|
type: "button",
|
|
@@ -439,34 +440,34 @@ function Qt({ children: t, className: e, style: p, metrics: o, density: i, ...n
|
|
|
439
440
|
"aria-expanded": W,
|
|
440
441
|
"aria-controls": U,
|
|
441
442
|
"aria-label": (W ? l.calculationHideDerivation : l.calculationShowDerivation)(f.label),
|
|
442
|
-
children: /* @__PURE__ */
|
|
443
|
+
children: /* @__PURE__ */ g(Be, { "data-open": W ? "" : void 0 })
|
|
443
444
|
}
|
|
444
|
-
) : /* @__PURE__ */
|
|
445
|
-
/* @__PURE__ */
|
|
445
|
+
) : /* @__PURE__ */ g("span", { className: m.disclosure, "aria-hidden": "true" }),
|
|
446
|
+
/* @__PURE__ */ g("span", { className: m.label, "aria-hidden": "true", children: f.label })
|
|
446
447
|
] }),
|
|
447
|
-
/* @__PURE__ */
|
|
448
|
-
/* @__PURE__ */
|
|
449
|
-
|
|
448
|
+
/* @__PURE__ */ g("span", { className: m.names, "aria-hidden": "true", children: j && !z && !W ? E.names : void 0 }),
|
|
449
|
+
/* @__PURE__ */ g("span", { className: m.operator, "aria-hidden": "true", children: qe }),
|
|
450
|
+
b(I, he !== void 0),
|
|
450
451
|
/* @__PURE__ */ R("span", { className: m.assessment, "aria-hidden": "true", children: [
|
|
451
|
-
|
|
452
|
+
s ? (
|
|
452
453
|
/* Short: which metric. The sentence carries the full reason. */
|
|
453
|
-
|
|
454
|
-
(q, J) => I[J].own.absence && /* @__PURE__ */
|
|
454
|
+
s.map(
|
|
455
|
+
(q, J) => I[J].own.absence && /* @__PURE__ */ g(le, { children: l.calculationMissing(q.unit ?? q.label) }, q.id)
|
|
455
456
|
)
|
|
456
|
-
) : E.reason !== void 0 ? /* @__PURE__ */
|
|
457
|
-
E.target !== void 0 && /* @__PURE__ */
|
|
458
|
-
Z !== void 0 && /* @__PURE__ */
|
|
457
|
+
) : E.reason !== void 0 ? /* @__PURE__ */ g(le, { children: E.reason }) : P.verdict !== void 0 && /* @__PURE__ */ g(le, { tone: jt[P.verdict], children: oe(P.verdict, l) }),
|
|
458
|
+
E.target !== void 0 && /* @__PURE__ */ g("span", { className: m.target, children: E.target }),
|
|
459
|
+
Z !== void 0 && /* @__PURE__ */ g("span", { className: m.worst, "data-verdict": Z, children: l.calculationWorstInside(oe(Z, l)) })
|
|
459
460
|
] }),
|
|
460
461
|
me.length > 0 && /* A click here - on a link in the aside, on a sparkline - is the
|
|
461
462
|
caller's, not a fold. */
|
|
462
|
-
/* @__PURE__ */
|
|
463
|
+
/* @__PURE__ */ g("span", { className: m.notes, onClick: (q) => q.stopPropagation(), children: me })
|
|
463
464
|
]
|
|
464
465
|
}
|
|
465
466
|
);
|
|
466
467
|
return z ? [
|
|
467
468
|
...te,
|
|
468
469
|
/* @__PURE__ */ R("li", { className: m.item, children: [
|
|
469
|
-
/* @__PURE__ */
|
|
470
|
+
/* @__PURE__ */ g("ul", { className: m.list, children: pe }),
|
|
470
471
|
ve
|
|
471
472
|
] }, T)
|
|
472
473
|
] : [
|
|
@@ -476,25 +477,25 @@ function Qt({ children: t, className: e, style: p, metrics: o, density: i, ...n
|
|
|
476
477
|
B && /* @__PURE__ */ R("ul", { id: U, className: m.derivation, hidden: !W, children: [
|
|
477
478
|
Ce,
|
|
478
479
|
pe,
|
|
479
|
-
/* @__PURE__ */
|
|
480
|
+
/* @__PURE__ */ g("li", { className: m.item, "aria-hidden": "true", children: /* @__PURE__ */ R(
|
|
480
481
|
"div",
|
|
481
482
|
{
|
|
482
483
|
className: m.line,
|
|
483
484
|
style: { "--depth": G.depth },
|
|
484
485
|
"data-inner": "",
|
|
485
486
|
"data-closing": "",
|
|
486
|
-
"data-mark": r ===
|
|
487
|
+
"data-mark": r === o ? "use" : void 0,
|
|
487
488
|
children: [
|
|
488
489
|
/* @__PURE__ */ R("span", { className: m.labelCell, children: [
|
|
489
|
-
/* @__PURE__ */
|
|
490
|
+
/* @__PURE__ */ g("span", { className: m.disclosure }),
|
|
490
491
|
/* @__PURE__ */ R("span", { className: m.label, children: [
|
|
491
492
|
"= ",
|
|
492
493
|
f.label
|
|
493
494
|
] })
|
|
494
495
|
] }),
|
|
495
|
-
/* @__PURE__ */
|
|
496
|
-
/* @__PURE__ */
|
|
497
|
-
|
|
496
|
+
/* @__PURE__ */ g("span", { className: m.names }),
|
|
497
|
+
/* @__PURE__ */ g("span", { className: m.operator }),
|
|
498
|
+
b(I, !0)
|
|
498
499
|
]
|
|
499
500
|
}
|
|
500
501
|
) })
|
|
@@ -505,36 +506,36 @@ function Qt({ children: t, className: e, style: p, metrics: o, density: i, ...n
|
|
|
505
506
|
return (
|
|
506
507
|
/* The frame is the surface and the container the layout measures itself
|
|
507
508
|
against; the list inside it is the statement. */
|
|
508
|
-
/* @__PURE__ */
|
|
509
|
+
/* @__PURE__ */ g(
|
|
509
510
|
"div",
|
|
510
511
|
{
|
|
511
512
|
ref: $,
|
|
512
513
|
className: Bt(m.frame, e),
|
|
513
|
-
style:
|
|
514
|
+
style: s ? {
|
|
514
515
|
"--figure-tracks": Array(v * 2).fill("auto").join(" "),
|
|
515
516
|
"--figures-end": X(v),
|
|
516
517
|
"--assessment-column": X(v),
|
|
517
518
|
...p
|
|
518
519
|
} : p,
|
|
519
520
|
"data-still": D ? void 0 : "",
|
|
520
|
-
"data-metrics":
|
|
521
|
-
"data-two-lines":
|
|
521
|
+
"data-metrics": s ? v : void 0,
|
|
522
|
+
"data-two-lines": a ? "" : void 0,
|
|
522
523
|
"data-compact": c ? "" : void 0,
|
|
523
524
|
children: /* @__PURE__ */ R("ul", { className: m.calculation, ...n, children: [
|
|
524
|
-
|
|
525
|
+
s && /* The head names each metric and its unit above its column. Every
|
|
525
526
|
row's sentence names them too, so the head is for the eye. */
|
|
526
|
-
/* @__PURE__ */
|
|
527
|
+
/* @__PURE__ */ g("li", { className: m.item, "aria-hidden": "true", children: /* @__PURE__ */ g("div", { className: m.head, children: s.map((o, d) => /* @__PURE__ */ R(
|
|
527
528
|
"span",
|
|
528
529
|
{
|
|
529
530
|
className: m.headCell,
|
|
530
|
-
"data-unit":
|
|
531
|
+
"data-unit": o.unit === void 0 ? void 0 : "",
|
|
531
532
|
style: { "--column": X(d) },
|
|
532
533
|
children: [
|
|
533
|
-
/* @__PURE__ */
|
|
534
|
-
|
|
534
|
+
/* @__PURE__ */ g("span", { className: m.headLabel, children: o.label }),
|
|
535
|
+
o.unit !== void 0 && /* @__PURE__ */ g("span", { className: m.headUnit, children: o.unit })
|
|
535
536
|
]
|
|
536
537
|
},
|
|
537
|
-
|
|
538
|
+
o.id
|
|
538
539
|
)) }) }),
|
|
539
540
|
N
|
|
540
541
|
] })
|
package/docs/llms-full.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @umriss-ui/calculation 0.
|
|
1
|
+
# @umriss-ui/calculation 0.34.0
|
|
2
2
|
|
|
3
3
|
> React calculation view for data-dense applications - a derivation written as it is shown, evaluated by the library, folded and read line by line.
|
|
4
4
|
|
|
@@ -1819,8 +1819,7 @@ A bound: a value, a side, a severity.
|
|
|
1819
1819
|
|
|
1820
1820
|
No tolerance band as input. A band is derived - two limits of equal
|
|
1821
1821
|
severity on opposite sides enclose one - and as an input type it would
|
|
1822
|
-
force a `null` on one edge in the one-sided case.
|
|
1823
|
-
case, not the exception.
|
|
1822
|
+
force a `null` on one edge in the one-sided case.
|
|
1824
1823
|
|
|
1825
1824
|
| Prop | Type | Default | Description |
|
|
1826
1825
|
|---|---|---|---|
|
|
@@ -1843,8 +1842,7 @@ type Side = "upper" | "lower";
|
|
|
1843
1842
|
From `@umriss-ui/core`.
|
|
1844
1843
|
|
|
1845
1844
|
How seriously a violation weighs: one severity that advises and one that
|
|
1846
|
-
calls for action. Exactly two
|
|
1847
|
-
the screen, and five colours are noise. For a third distinction one sets a
|
|
1845
|
+
calls for action. Exactly two; for a third distinction one sets a
|
|
1848
1846
|
second limit.
|
|
1849
1847
|
|
|
1850
1848
|
```ts
|
|
@@ -2172,8 +2170,7 @@ A bound: a value, a side, a severity.
|
|
|
2172
2170
|
|
|
2173
2171
|
No tolerance band as input. A band is derived - two limits of equal
|
|
2174
2172
|
severity on opposite sides enclose one - and as an input type it would
|
|
2175
|
-
force a `null` on one edge in the one-sided case.
|
|
2176
|
-
case, not the exception.
|
|
2173
|
+
force a `null` on one edge in the one-sided case.
|
|
2177
2174
|
|
|
2178
2175
|
| Prop | Type | Default | Description |
|
|
2179
2176
|
|---|---|---|---|
|
|
@@ -2196,8 +2193,7 @@ type Side = "upper" | "lower";
|
|
|
2196
2193
|
From `@umriss-ui/core`.
|
|
2197
2194
|
|
|
2198
2195
|
How seriously a violation weighs: one severity that advises and one that
|
|
2199
|
-
calls for action. Exactly two
|
|
2200
|
-
the screen, and five colours are noise. For a third distinction one sets a
|
|
2196
|
+
calls for action. Exactly two; for a third distinction one sets a
|
|
2201
2197
|
second limit.
|
|
2202
2198
|
|
|
2203
2199
|
```ts
|
|
@@ -2808,8 +2804,7 @@ A bound: a value, a side, a severity.
|
|
|
2808
2804
|
|
|
2809
2805
|
No tolerance band as input. A band is derived - two limits of equal
|
|
2810
2806
|
severity on opposite sides enclose one - and as an input type it would
|
|
2811
|
-
force a `null` on one edge in the one-sided case.
|
|
2812
|
-
case, not the exception.
|
|
2807
|
+
force a `null` on one edge in the one-sided case.
|
|
2813
2808
|
|
|
2814
2809
|
| Prop | Type | Default | Description |
|
|
2815
2810
|
|---|---|---|---|
|
|
@@ -2832,8 +2827,7 @@ type Side = "upper" | "lower";
|
|
|
2832
2827
|
From `@umriss-ui/core`.
|
|
2833
2828
|
|
|
2834
2829
|
How seriously a violation weighs: one severity that advises and one that
|
|
2835
|
-
calls for action. Exactly two
|
|
2836
|
-
the screen, and five colours are noise. For a third distinction one sets a
|
|
2830
|
+
calls for action. Exactly two; for a third distinction one sets a
|
|
2837
2831
|
second limit.
|
|
2838
2832
|
|
|
2839
2833
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umriss-ui/calculation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "React calculation view for data-dense applications - a derivation written as it is shown, evaluated by the library, folded and read line by line.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Roman Händler",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": ">=18",
|
|
49
49
|
"react-dom": ">=18",
|
|
50
|
-
"@umriss-ui/core": "^0.
|
|
50
|
+
"@umriss-ui/core": "^0.34.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@fontsource/geist-mono": "^5.3.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"typescript": "^5.6.3",
|
|
62
62
|
"vite": "^6.0.0",
|
|
63
63
|
"vite-plugin-dts": "^4.3.0",
|
|
64
|
-
"@umriss-ui/core": "0.
|
|
64
|
+
"@umriss-ui/core": "0.34.0",
|
|
65
65
|
"@umriss-ui/demo": "0.0.0"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
@@ -71,8 +71,9 @@
|
|
|
71
71
|
"build": "vite build",
|
|
72
72
|
"prebuild:demo": "pnpm run props",
|
|
73
73
|
"build:demo": "vite build --config vite.demo.config.ts",
|
|
74
|
-
"pretypecheck": "pnpm run props",
|
|
75
74
|
"typecheck": "tsc --noEmit",
|
|
75
|
+
"typecheck:demo": "pnpm run props && tsc --noEmit -p tsconfig.demo.json",
|
|
76
|
+
"check:site": "pnpm run props -- --check",
|
|
76
77
|
"preview:demo": "vite preview --config vite.demo.config.ts --port 4177 --strictPort",
|
|
77
78
|
"test:unit": "vitest run",
|
|
78
79
|
"check:dist": "node --disable-warning=ExperimentalWarning --experimental-strip-types ../../scripts/check-dist.ts calculation.js calculation.css"
|