Skip to content

HF-122: Replace Employee Table demos with Invoice Calculator#28

Closed
marcin-kordas-hoc wants to merge 3 commits into3.2.xfrom
feature/hf-122-invoice-calculator
Closed

HF-122: Replace Employee Table demos with Invoice Calculator#28
marcin-kordas-hoc wants to merge 3 commits into3.2.xfrom
feature/hf-122-invoice-calculator

Conversation

@marcin-kordas-hoc
Copy link
Copy Markdown

Summary

Replace all four framework demos (React, Angular, Vue, Svelte) from Employee Table to Invoice Calculator — a simpler, more focused demo using only buildFromArray, getSheetValues, and setCellContents.

Commits

  1. 2a49300 — Replace Employee Table demos with Invoice Calculator (45 files, +599/-1195)
  2. 73bf9ee — NaN guards, cleanup (hf.destroy()), type accuracy
  3. f2e19f4 — Align milligram usage, styling, and SHEET_ID naming

Related

Test plan

  • npm ci and npm run build in each demo directory
  • Open each demo on Stackblitz and verify Invoice Calculator renders and recalculates on input change

The previous demos (Employee Table with named expressions, helper
files, and 5 employee rows) were too complex to serve as a learning
reference for developers onboarding to HyperFormula in each framework.
They mixed substantial business logic and HyperFormula features the
reader doesn't yet need, forcing them to sift through unrelated code
to find the integration pattern.

The new Invoice Calculator demo is a small, self-contained interactive
app with three editable items and live subtotal/tax/total calculations.
It exercises the full edit → recalculate → display loop while focusing
each framework implementation on its idiomatic integration pattern:

- React: useRef for the HyperFormula instance, useEffect for lifecycle
- Angular: @Injectable service with OnDestroy and ngModel two-way binding
- Vue 3: markRaw around HyperFormula, ref for derived data
- Svelte: reactive let with direct reassignment on update

Replaces the docs' Stackblitz examples referenced from the Integration
with React/Angular/Vue/Svelte guides.
- Vue and Svelte demos now guard against NaN values before calling
  setCellContents, matching the existing behavior in React and Angular.
  Without this, a partial input like "-" or "." would propagate NaN
  through the formula results.
- Vue uses onUnmounted and Svelte uses onDestroy to call hf.destroy()
  on component teardown, consistent with React's useEffect cleanup
  and Angular's OnDestroy.
- Angular's ngModelChange handlers now accept number | null (the actual
  type emitted by ngModel on an input[type=number]) instead of string,
  so the type signatures match runtime behavior.
- Vue now imports milligram in main.ts so its base table and input
  styles match the other demos (React imports it in index.tsx, Angular
  loads it via angular.json, Svelte via app.html).
- Trimmed duplicate scoped styles from Vue and Svelte: rules that
  milligram already provides (border-collapse, th/td padding, th
  background, input borders) are removed; only the invoice-specific
  layout and summary row styling remains.
- Added a SHEET_ID = 0 constant to React, Vue, and Svelte to match
  Angular. This makes it explicit which sheet each call operates on.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant