From bf527d499bb6a90378d13094282368c360b9d290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Thu, 26 Nov 2026 03:39:06 +0100 Subject: [PATCH 01/11] fix(pivot): the version hint also recognises pivotkit-server's new params answer pivotkit-server answers params where no source takes any with NO_PARAMS_TEXT ("this server has no source that takes params"). The hint matched only the older "no key \"params\"", so the new answer got none. A test covers both texts. Refs #132 Co-Authored-By: Claude Opus 5.5 --- modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md | 7 +++++++ .../Private/New-UDPivotServerError.ps1 | 5 +++-- tests/powershell/PivotReport.Tests.ps1 | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md b/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md index 218b57d..ba9571e 100644 --- a/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md +++ b/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to PowerShellUniversal.Component.Pivot. Format: ## [Unreleased] +### Fixed + +- `Invoke-UDPivotReport -Engine Rest -Parameter` names the server version it needs also for the + answer newer pivotkit-servers give when none of their sources takes parameters ("this server has + no source that takes params"), as for the older `no key "params"` + ([#132](https://github.com/eizedev/powershell-universal-components/issues/132)). + ### Changed - The component passes the React hooks lint rules, which are now errors in CI: the latest props diff --git a/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotServerError.ps1 b/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotServerError.ps1 index d88dcce..876c812 100644 --- a/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotServerError.ps1 +++ b/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotServerError.ps1 @@ -44,8 +44,9 @@ function New-UDPivotServerError { else { 'The data is too large for the server: send fewer rows or columns, or let the operator configure a source for it and use -Source.' }) } # pivotkit-server 0.1.1 knows neither data in the request nor params; its answer reads like a - # fault in the request (#129). 0.2.0 answers params the same way when none of its sources takes any. - if ($status -eq 400 -and $code -eq 'INVALID_INPUT' -and $p.Detail -match 'no key "(data|params)"') { + # fault in the request (#129). 0.2.0 answers params the same way when none of its sources takes + # any; later versions say so in words, recognised by "takes params" (NO_PARAMS_TEXT, #132). + if ($status -eq 400 -and $code -eq 'INVALID_INPUT' -and $p.Detail -match 'no key "(data|params)"|(takes params)') { $message += [Environment]::NewLine + $(if ($Matches[1] -eq 'data') { '-Data needs pivotkit-server 0.2.0 or later; an older server renders only -Source.' } else { '-Parameter needs a source with parameters on pivotkit-server 0.2.0 or later.' }) } diff --git a/tests/powershell/PivotReport.Tests.ps1 b/tests/powershell/PivotReport.Tests.ps1 index 576e88d..6d32d9b 100644 --- a/tests/powershell/PivotReport.Tests.ps1 +++ b/tests/powershell/PivotReport.Tests.ps1 @@ -596,6 +596,11 @@ Describe 'Invoke-UDPivotReport -Engine Rest (a stand-in pivotkit-server)' { $caught = $null try { Invoke-UDPivotReport @rest -Token 'static-token-0123456789' -Source 'vms' -Parameter @{ customer = 'acme' } -View $view } catch { $caught = $_ } $caught.Exception.Message | Should -BeLike '*INVALID_INPUT (400): input has no key "params"*-Parameter needs a source with parameters on pivotkit-server 0.2.0 or later*' + # newer servers say it in words (NO_PARAMS_TEXT of pivotkit-server's sources/input.js, #132) + $mock.Render.Enqueue(@{ Status = 400; Body = '{"type":"https://pivotkit.eize.dev/reference/rest/#error-invalid-input","title":"Invalid input","status":400,"code":"INVALID_INPUT","detail":"this server has no source that takes params; leave params out (GET /sources lists the sources)"}' }) + $caught = $null + try { Invoke-UDPivotReport @rest -Token 'static-token-0123456789' -Source 'vms' -Parameter @{ customer = 'acme' } -View $view } catch { $caught = $_ } + $caught.Exception.Message | Should -BeLike '*INVALID_INPUT (400): this server has no source that takes params*-Parameter needs a source with parameters on pivotkit-server 0.2.0 or later*' # another invalid input, and data refused by the server's policy, get no version hint $mock.Render.Enqueue(@{ Status = 400; Body = '{"type":"x","title":"Invalid input","status":400,"code":"INVALID_INPUT","detail":"view.rows[0] must be a string"}' }) $caught = $null From ae4701acc355950feba77c1a67a769e229165c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Thu, 26 Nov 2026 03:41:32 +0100 Subject: [PATCH 02/11] feat(pivot): Invoke-UDPivotReport -Engine Rest takes -Locale, -Numbers and -FlatHeader pivotkit-server 0.3.0's render routes take locale, numbers and flatHeader. The REST engine refused all three; it now writes them into the body when they are given, so both engines write the same CSV and JSON. Without them nothing is sent, so older servers still render; their answer to the new keys names the version they need. -TimeZone stays with -Engine Node: the server has no such input. Refs #135 Co-Authored-By: Claude Opus 5.5 --- docs/pivot/reports-server.md | 2 +- docs/pivot/reports.md | 24 ++++++++------- .../CHANGELOG.md | 8 +++++ .../Private/Assert-UDPivotReportEngine.ps1 | 2 +- .../Private/Invoke-UDPivotRestReport.ps1 | 9 ++++-- .../Private/New-UDPivotRenderBody.ps1 | 17 +++++++++-- .../Private/New-UDPivotServerError.ps1 | 7 +++-- .../Public/Invoke-UDPivotReport.ps1 | 17 ++++++----- tests/powershell/PivotReport.Tests.ps1 | 30 +++++++++++++++++-- 9 files changed, 87 insertions(+), 29 deletions(-) diff --git a/docs/pivot/reports-server.md b/docs/pivot/reports-server.md index 5e9d61c..0ca5591 100644 --- a/docs/pivot/reports-server.md +++ b/docs/pivot/reports-server.md @@ -26,7 +26,7 @@ data you send. `-DataName` names the data, `-DataAsOf` says when it is from (sen arrived). `-Data` (and with it `-DataName` and `-DataAsOf`) and `-Parameter` need pivotkit-server 0.2.0 or -later. +later; `-Locale`, `-Numbers` and `-FlatHeader` ([Reports without a browser](reports.md#two-engines)) 0.3.0 or later. The token comes from the server's operator, who makes it with `pivotkit-server token new`; keep it in a PSU secret. pivotkit-server refuses a static token that is easy to guess diff --git a/docs/pivot/reports.md b/docs/pivot/reports.md index a6fec5d..befebb1 100644 --- a/docs/pivot/reports.md +++ b/docs/pivot/reports.md @@ -34,15 +34,26 @@ file's bytes, for an endpoint's answer or a mail attachment. | Runs | pivotkit's command line on the PSU server | a pivotkit-server somewhere else | | Needs | Node 24 or later and `npm install --global pivotkit-cli` (0.2.1 or later) on the PSU server | a pivotkit-server, its address and a token or OAuth client ([which server](reports-server.md#rest-a-pivotkit-server)) | | Data | `-Data`, written to a temporary folder of its own (mode 0700 on Linux and macOS; on Windows it inherits the ACL of the user's TEMP folder), removed afterwards | `-Data`, sent in the request; or `-Source`, a source the server's operator configured | -| Language, time zone | `-Locale`, `-TimeZone` | the server's | +| Language, time zone | `-Locale`, `-TimeZone` | `-Locale`; the time zone is the server's | | HTML print template | `-Template` | the server's source decides | -| Numbers and header of CSV and JSON | `-Numbers Shown` rounds to the decimals the view shows, `-FlatHeader` writes one CSV header row | the server's | | Result | the file | the file, or a link that expires (`-AsLink`) | Both take `-View` (a hashtable, JSON text or a view file) or `-Layout` (the view by field names), and both check the view against the data first: a view with errors writes nothing, and the error lists what pivotkit found (the field it did not find, the name it probably meant). +A CSV or JSON file holds every number with full precision. `-Numbers Shown` rounds each number to the +decimals the view shows; `-Numbers Full` is the default. `-FlatHeader` gives a CSV file one header +row instead of one per column field; each column names its labels joined with " / ". `-Locale` sets +the language and number format of a view that names none (a CSV in `de-DE` uses `;` and the decimal +comma). Both engines write the same file from them. `-Numbers` and `-FlatHeader` need pivotkit-cli +0.5.0 or later, and all three need pivotkit-server 0.3.0 or later; the function refuses `-Numbers` and +`-FlatHeader` for another format. + +```powershell +Invoke-UDPivotReport -Engine Node -Data $tickets -View $view -OutFile ./tickets.csv -Numbers Shown -FlatHeader -Locale de-DE +``` + ```powershell Invoke-UDPivotReport -Engine Node -Data $tickets -Format html -Title 'Lead time per month' -Layout @{ rows = 'Created' @@ -77,15 +88,6 @@ stream. `-TimeoutSec` (default 120) stops a run that takes longer. A job that is `pivotkit-<32 hex characters>` in the temporary folder of the account PSU runs as; remove such folders now and then. -A CSV or JSON file holds every number with full precision. `-Numbers Shown` rounds each number to the -decimals the view shows, as pivotkit-server writes them; `-Numbers Full` is the default. `-FlatHeader` -gives a CSV file one header row instead of one per column field; each column names its labels joined -with " / ". Both need pivotkit-cli 0.5.0 or later, and the function refuses them for another format. - -```powershell -Invoke-UDPivotReport -Engine Node -Data $tickets -View $view -OutFile ./tickets.csv -Numbers Shown -FlatHeader -``` - An HTML report takes a print template of your own with `-Template`, for your company's look and metadata. It goes with `-Format html` only (or an `-OutFile` that ends in `.html`): diff --git a/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md b/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md index ba9571e..a48773c 100644 --- a/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md +++ b/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to PowerShellUniversal.Component.Pivot. Format: ## [Unreleased] +### Added + +- `Invoke-UDPivotReport -Engine Rest` takes `-Locale`, `-Numbers` and `-FlatHeader` and passes them + to pivotkit-server's render routes as `locale`, `numbers` and `flatHeader`, so both engines write + the same CSV and JSON. They need pivotkit-server 0.3.0 or later; an older server's answer names + that version. `-TimeZone` stays with `-Engine Node` + ([#135](https://github.com/eizedev/powershell-universal-components/issues/135)). + ### Fixed - `Invoke-UDPivotReport -Engine Rest -Parameter` names the server version it needs also for the diff --git a/modules/PowerShellUniversal.Component.Pivot/Private/Assert-UDPivotReportEngine.ps1 b/modules/PowerShellUniversal.Component.Pivot/Private/Assert-UDPivotReportEngine.ps1 index 5ccd8ad..bbbe748 100644 --- a/modules/PowerShellUniversal.Component.Pivot/Private/Assert-UDPivotReportEngine.ps1 +++ b/modules/PowerShellUniversal.Component.Pivot/Private/Assert-UDPivotReportEngine.ps1 @@ -22,7 +22,7 @@ function Assert-UDPivotReportEngine { if (-not $Bound.ContainsKey('Data')) { throw '-Engine Node needs -Data: the command line runs over the rows you give.' } return } - $wrong = & $given 'CliPath', 'Locale', 'TimeZone', 'Numbers', 'FlatHeader' + $wrong = & $given 'CliPath', 'TimeZone' if ($wrong.Count) { throw ('{0}: only with -Engine Node (pivotkit-server uses its own).' -f ($wrong -join ', ')) } if ($Bound['Template']) { throw '-Template: only with -Engine Node. With -Engine Rest the server''s source decides the template (sources..template in its configuration).' } } diff --git a/modules/PowerShellUniversal.Component.Pivot/Private/Invoke-UDPivotRestReport.ps1 b/modules/PowerShellUniversal.Component.Pivot/Private/Invoke-UDPivotRestReport.ps1 index 76837bc..83be602 100644 --- a/modules/PowerShellUniversal.Component.Pivot/Private/Invoke-UDPivotRestReport.ps1 +++ b/modules/PowerShellUniversal.Component.Pivot/Private/Invoke-UDPivotRestReport.ps1 @@ -4,7 +4,8 @@ function Invoke-UDPivotRestReport { Renders a report with pivotkit-server (Invoke-UDPivotReport -Engine Rest): the file's bytes, or with -AsLink a link to the report the server keeps. .PARAMETER Bound - Invoke-UDPivotReport's $PSBoundParameters: Data, Source, Parameter, DataName, DataAsOf and Uri. + Invoke-UDPivotReport's $PSBoundParameters: Data, Source, Parameter, DataName, DataAsOf, Locale, + Numbers, FlatHeader and Uri. .PARAMETER Report The result of Get-UDPivotReportInput. .PARAMETER Kind @@ -34,7 +35,11 @@ function Invoke-UDPivotRestReport { [switch]$AsLink ) # splatted: a $(...) around -Data would enumerate a DataTable into its rows - $bodyArgs = @{ Source = [string]$Bound['Source']; Parameter = $Bound['Parameter']; Layout = $Report.Layout; Format = $Kind; Title = $Report.Title; DataName = [string]$Bound['DataName']; DataAsOf = $Bound['DataAsOf'] } + $bodyArgs = @{ + Source = [string]$Bound['Source']; Parameter = $Bound['Parameter']; Layout = $Report.Layout; Format = $Kind; Title = $Report.Title + DataName = [string]$Bound['DataName']; DataAsOf = $Bound['DataAsOf'] + Locale = [string]$Bound['Locale']; Numbers = [string]$Bound['Numbers']; FlatHeader = [bool]$Bound['FlatHeader'] + } if ($Bound.ContainsKey('Data')) { $bodyArgs['Data'] = $Bound['Data']; $bodyArgs['MaxBytes'] = $MaxBytes } if ($Report.ViewFile) { $bodyArgs['View'] = $Report.ViewFile.View } if ($AsLink) { diff --git a/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotRenderBody.ps1 b/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotRenderBody.ps1 index aa6c8f6..7e942a0 100644 --- a/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotRenderBody.ps1 +++ b/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotRenderBody.ps1 @@ -3,8 +3,8 @@ function New-UDPivotRenderBody { .SYNOPSIS The input of pivotkit-server's render_view as UTF-8 JSON, the rows written straight into it. .DESCRIPTION - source, then data (columns, rows, rowCount, name, asOf) or params, then view or layout, format and - title. The rows go through Write-UDPivotReportTable: no copy of them as objects or as one JSON + source, then data (columns, rows, rowCount, name, asOf) or params, then view or layout, format, + title, locale, numbers and flatHeader. The rows go through Write-UDPivotReportTable: no copy of them as objects or as one JSON string, and past -MaxBytes it stops with PivotDataTooLarge before the rest is converted. .PARAMETER Data The rows, or $null with -Source. @@ -24,6 +24,12 @@ function New-UDPivotRenderBody { What the data is. .PARAMETER DataAsOf When the data is from. + .PARAMETER Locale + The report's language and number format, for a view that names none. + .PARAMETER Numbers + csv and json: Shown or Full, sent in lower case. + .PARAMETER FlatHeader + csv: one header row. .PARAMETER MaxBytes The most bytes of the body; 0 for no cap. .PARAMETER Save @@ -47,6 +53,9 @@ function New-UDPivotRenderBody { [string]$Title, [string]$DataName, [Nullable[datetime]]$DataAsOf, + [string]$Locale, + [string]$Numbers, + [switch]$FlatHeader, [long]$MaxBytes = 0, [switch]$Save ) @@ -69,6 +78,10 @@ function New-UDPivotRenderBody { else { $writer.WritePropertyName('layout'); $writer.WriteRawValue((ConvertTo-Json -InputObject $Layout -Depth 32 -Compress -WarningAction SilentlyContinue)) } $writer.WriteString('format', $Format) if ($Title) { $writer.WriteString('title', $Title) } + # left out unless given: the server's defaults, and a server older than 0.3.0 still renders + if ($Locale) { $writer.WriteString('locale', $Locale) } + if ($Numbers) { $writer.WriteString('numbers', $Numbers.ToLowerInvariant()) } + if ($FlatHeader) { $writer.WriteBoolean('flatHeader', $true) } if ($Save) { $writer.WriteBoolean('save', $true) } $writer.WriteEndObject() $writer.Flush() diff --git a/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotServerError.ps1 b/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotServerError.ps1 index 876c812..5f33f06 100644 --- a/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotServerError.ps1 +++ b/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotServerError.ps1 @@ -6,8 +6,8 @@ function New-UDPivotServerError { .DESCRIPTION The message holds the code, the status, the detail, the findings, when to try again, a hint for the known cases (401, 403 INSUFFICIENT_SCOPE, 413 by its code, the 400 of a server too old for - -Data or -Parameter) and the request id. Exception.Data holds Status, Code, Title, Detail, - RetryAfter, Retryable and RequestId. The error ids: PivotTokenRefused (401, 403 + -Data, -Parameter, -Locale, -Numbers or -FlatHeader) and the request id. Exception.Data holds + Status, Code, Title, Detail, RetryAfter, Retryable and RequestId. The error ids: PivotTokenRefused (401, 403 INSUFFICIENT_SCOPE), PivotDataTooLarge (413), PivotViewHasErrors (422), PivotServerError (anything else). With -RowsRoute, by the rows route's codes: PivotRowsNotAllowed (403 NOT_ALLOWED), PivotNoData (404 SOURCE_NOT_FOUND, DATA_NOT_AVAILABLE), PivotServerBusy (429 @@ -50,6 +50,9 @@ function New-UDPivotServerError { $message += [Environment]::NewLine + $(if ($Matches[1] -eq 'data') { '-Data needs pivotkit-server 0.2.0 or later; an older server renders only -Source.' } else { '-Parameter needs a source with parameters on pivotkit-server 0.2.0 or later.' }) } + elseif ($status -eq 400 -and $code -eq 'INVALID_INPUT' -and $p.Detail -match 'no key "(locale|numbers|flatHeader)"') { + $message += [Environment]::NewLine + '-Locale, -Numbers and -FlatHeader need pivotkit-server 0.3.0 or later.' + } $scopeMissing = $status -eq 403 -and $code -eq 'INSUFFICIENT_SCOPE' if ($scopeMissing -and $RowsRoute) { $message += [Environment]::NewLine + 'The person''s token lacks a scope the server needs (rest.requiredScopes and the source''s scopes): let PSU''s OpenID Connect sign-in ask the provider for it, and make sure the provider puts it into the access token.' } elseif ($scopeMissing) { $message += [Environment]::NewLine + 'The token lacks a scope the server needs: ask the token endpoint for it with -Scope (the scope the operator set in rest.requiredScopes, for example pivotkit:rest), and make sure the OAuth provider grants it to this client.' } diff --git a/modules/PowerShellUniversal.Component.Pivot/Public/Invoke-UDPivotReport.ps1 b/modules/PowerShellUniversal.Component.Pivot/Public/Invoke-UDPivotReport.ps1 index e25abd3..892ca47 100644 --- a/modules/PowerShellUniversal.Component.Pivot/Public/Invoke-UDPivotReport.ps1 +++ b/modules/PowerShellUniversal.Component.Pivot/Public/Invoke-UDPivotReport.ps1 @@ -19,8 +19,8 @@ function Invoke-UDPivotReport { The server's operator turns this on per caller (a profile with data: true, or policy.data) and caps the body (rest.data.maxBytes, default 10 MiB). With -Source instead of -Data the report runs over a source the operator configured (the caller needs results: true). -Data and - -Parameter need pivotkit-server 0.2.0 or later; pivotkit-server 0.1.1 renders -Source without - parameters, and the error of its answer to -Data or -Parameter says so. Sign-in: a static + -Parameter need pivotkit-server 0.2.0 or later, -Locale, -Numbers and -FlatHeader 0.3.0 or + later; the error of an older server's answer to them says so. Sign-in: a static token (-Token), or OAuth client credentials (-Credential with -TokenUri), the access token kept per runspace until shortly before it expires and fetched again once after a 401. Only https, or http to this machine; redirects are not followed; neither the token nor the client secret is @@ -70,7 +70,8 @@ function Invoke-UDPivotReport { -Engine Node: the pivotkit program, or pivotkit-cli's bin/pivotkit.js. Default: pivotkit on the PATH. .PARAMETER Locale - -Engine Node: numbers, dates and the report's words (de-DE writes German ones). Default en-US. + Numbers, dates and the report's words (de-DE writes German ones) for a view that names no + language of its own. Default: en-US with -Engine Node, the server's with -Engine Rest. .PARAMETER TimeZone -Engine Node: the zone of the data's dates (IANA, default UTC). .PARAMETER Uri @@ -112,12 +113,12 @@ function Invoke-UDPivotReport { as --template. pivotkit trusts a template like code: give a file of your own, never one from a reader. With -Engine Rest the server's source decides the template, so it is refused there. .PARAMETER Numbers - -Engine Node with -Format csv or json: Full writes every number with full precision (the command - line's default), Shown rounds it to the decimals the view shows, as pivotkit-server writes them. - Needs pivotkit-cli 0.5.0 or later. + -Format csv or json: Full writes every number with full precision (the default of both + engines), Shown rounds it to the decimals the view shows. Needs pivotkit-cli 0.5.0 or later + (-Engine Node) or pivotkit-server 0.3.0 or later (-Engine Rest). .PARAMETER FlatHeader - -Engine Node with -Format csv: one header row instead of one per column field; each column - names its labels joined with " / ". Needs pivotkit-cli 0.5.0 or later. + -Format csv: one header row instead of one per column field; each column names its labels + joined with " / ". Needs pivotkit-cli 0.5.0 or pivotkit-server 0.3.0 or later. .PARAMETER AsLink -Engine Rest: the server saves the report and the function returns its download link instead of the file (POST /views/render with save: true): a PivotReportLink with Url, ExpiresAt (UTC; empty diff --git a/tests/powershell/PivotReport.Tests.ps1 b/tests/powershell/PivotReport.Tests.ps1 index 6d32d9b..dc87616 100644 --- a/tests/powershell/PivotReport.Tests.ps1 +++ b/tests/powershell/PivotReport.Tests.ps1 @@ -237,7 +237,7 @@ Describe 'Invoke-UDPivotReport: what goes with which engine' { It 'refuses parameters of the other engine and missing inputs, before anything runs' { { Invoke-UDPivotReport -Engine Node -Data $rows -View $view -Uri 'https://x.example/api/v1' } | Should -Throw '*-Uri: only with -Engine Rest*' { Invoke-UDPivotReport -Engine Node -View $view } | Should -Throw '*-Engine Node needs -Data*' - { Invoke-UDPivotReport -Engine Rest -Uri 'https://x.example/api/v1' -Token 't' -Data $rows -View $view -Locale de-DE } | Should -Throw '*-Locale: only with -Engine Node*' + { Invoke-UDPivotReport -Engine Rest -Uri 'https://x.example/api/v1' -Token 't' -Data $rows -View $view -TimeZone 'Europe/Berlin' } | Should -Throw '*-TimeZone: only with -Engine Node*' { Invoke-UDPivotReport -Engine Rest -Token 't' -Data $rows -View $view } | Should -Throw '*needs -Uri*' { Invoke-UDPivotReport -Engine Rest -Uri 'https://x.example/api/v1' -Token 't' -View $view } | Should -Throw '*either -Data*or -Source*' { Invoke-UDPivotReport -Engine Rest -Uri 'https://x.example/api/v1' -Token 't' -Data $rows -Source 'sales' -View $view } | Should -Throw '*either -Data*or -Source*' @@ -433,7 +433,8 @@ Describe 'Invoke-UDPivotReport -Engine Node (a stand-in command line)' { @((Get-Record).args | Where-Object { $_ -like '--numbers*' -or $_ -eq '--flat-header' }).Count | Should -Be 0 { Invoke-UDPivotReport -Engine Node -CliPath $fakeCli -Data $rows -View $view -Format xlsx -Numbers Shown } | Should -Throw '*-Numbers*csv*json*' { Invoke-UDPivotReport -Engine Node -CliPath $fakeCli -Data $rows -View $view -Format json -FlatHeader } | Should -Throw '*-FlatHeader*csv*' - { Invoke-UDPivotReport -Engine Rest -Uri 'https://reports.example.com/api/v1' -Token 't' -Data $rows -View $view -Format csv -Numbers Shown } | Should -Throw '*-Numbers*-Engine Node*' + { Invoke-UDPivotReport -Engine Rest -Uri 'https://reports.example.com/api/v1' -Token 't' -Data $rows -View $view -Format xlsx -Numbers Shown } | Should -Throw '*-Numbers*csv*json*' + { Invoke-UDPivotReport -Engine Rest -Uri 'https://reports.example.com/api/v1' -Token 't' -Data $rows -View $view -Format json -FlatHeader } | Should -Throw '*-FlatHeader*csv*' } It 'runs render with the view file, the data and the options; returns the bytes; removes its folder' { @@ -574,6 +575,31 @@ Describe 'Invoke-UDPivotReport -Engine Rest (a stand-in pivotkit-server)' { $sent.view.rows | Should -Be @('Team') } + It '-Locale, -Numbers and -FlatHeader go into the body as pivotkit-server reads them, on both routes, and only when given (#135)' { + $null = Invoke-UDPivotReport @rest -Token 'static-token-0123456789' -Data $rows -View $view -Format csv -Locale de-DE -Numbers Shown -FlatHeader + $sent = (@(Get-Log)[0]).Body | ConvertFrom-Json -Depth 16 + $sent.locale | Should -Be 'de-DE' + $sent.numbers | Should -BeExactly 'shown' + $sent.flatHeader | Should -BeTrue + $null = Invoke-UDPivotReport @rest -Token 'static-token-0123456789' -Source 'sales' -View $view -Format json -Numbers Full -AsLink + $log = @(Get-Log) + $log[0].Path | Should -Be '/api/v1/views/render' + $sent = $log[0].Body | ConvertFrom-Json -Depth 16 + $sent.numbers | Should -BeExactly 'full' + $sent.PSObject.Properties.Name | Should -Not -Contain 'flatHeader' + # without them nothing is sent: the server's defaults, and older servers still work + $null = Invoke-UDPivotReport @rest -Token 'static-token-0123456789' -Data $rows -View $view -Format csv + $sent = (@(Get-Log)[0]).Body | ConvertFrom-Json -Depth 16 + foreach ($name in 'locale', 'numbers', 'flatHeader') { $sent.PSObject.Properties.Name | Should -Not -Contain $name } + } + + It 'a server too old for -Locale, -Numbers or -FlatHeader: the error names the version they need (#135)' { + $mock.Render.Enqueue(@{ Status = 400; Body = '{"type":"https://pivotkit.eize.dev/reference/rest/#error-invalid-input","title":"Invalid input","status":400,"code":"INVALID_INPUT","detail":"input has no key \"numbers\""}' }) + $caught = $null + try { Invoke-UDPivotReport @rest -Token 'static-token-0123456789' -Data $rows -View $view -Format csv -Numbers Shown } catch { $caught = $_ } + $caught.Exception.Message | Should -BeLike '*input has no key "numbers"*-Locale, -Numbers and -FlatHeader need pivotkit-server 0.3.0 or later*' + } + It 'a SecureString token, a configured source with parameters, a layout' { $null = Invoke-UDPivotReport @rest -Token ([System.Net.NetworkCredential]::new('', 'static-token-0123456789').SecurePassword) -Source 'vms' -Parameter @{ customer = 'acme' } -Layout @{ rows = 'Team' } $sent = (@(Get-Log)[0]).Body | ConvertFrom-Json -Depth 16 From c3e01da0408ef14273f8a84c5b2d90d793dbf2a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Thu, 26 Nov 2026 03:47:50 +0100 Subject: [PATCH 03/11] feat(pivot): theme properties for pivotkit's zone colours and chip controls The bridge maps pivotkit's zone tokens (--pk-zone-rows, -columns, -values, -filters, -tint, -tint-base), --pk-control-icon, --pk-sort-arrow, --pk-field-hover and --pk-chart-reference, each with a --psu-pivot-* property per light and dark mode. Without an app's value they keep pivotkit's colours (repeated as --psu-default-zone-*) or its derivation. The field type icons follow pivotkit's new neutral default, the muted text; --psu-pivot-type-* still sets them. The themes page lists every new property; a unit test checks the mapping and the zone colours' contrast on PSU's surfaces, a live spec reads the tokens per PSU mode. Co-Authored-By: Claude Opus 5.5 --- docs/pivot/themes.md | 70 ++++++++--------- .../CHANGELOG.md | 9 +++ .../Components/psu.css | 48 ++++++++---- tests/browser/psu-pivot.spec.mjs | 29 ++++++- tests/js/pivot.test.js | 75 +++++++++++++++---- 5 files changed, 162 insertions(+), 69 deletions(-) diff --git a/docs/pivot/themes.md b/docs/pivot/themes.md index 0702009..3f9a597 100644 --- a/docs/pivot/themes.md +++ b/docs/pivot/themes.md @@ -50,16 +50,12 @@ the report a value of its own; a `--psu-pivot-*` property wins over its `--psu-c } ``` -The first block is the light mode, the second the dark one. Each mode needs its own values: a -property set only in `:root` applies to both modes, and a dark text colour from the light block would -be unreadable on the dark report. Each block names two selectors: `:root` and `:root[data-theme="dark"]` -for the ECharts charts, which follow the page, and `.ud-pivot-report [data-pk-theme="light"]` and -`[data-pk-theme="dark"]` for the theme the report shows. The second pair matters for the exports. -The Excel export is light (black text in Excel). The HTML report carries both modes: light for paper -and a light screen, dark for a reader whose screen is dark. The report reads each mode's colours by -showing that theme for a moment. With the page's selectors alone, it would inherit the page's current -mode both times and write that mode's values into the file. Colours are hex or `rgb()`/`rgba()`: the report's chart hands the -series colours to ECharts, which does not read every CSS colour syntax. +The first block is the light mode, the second the dark one. `:root` and `:root[data-theme="dark"]` serve +the ECharts charts, which follow the page; `.ud-pivot-report [data-pk-theme="light"]` and +`[data-pk-theme="dark"]` serve the theme the report shows. The exports need the second pair: the report +reads each mode's colours by showing that theme for a moment, and with the page's selectors alone it +would write the page's current mode both times. Colours are hex or `rgb()`/`rgba()`: the report's chart +hands the series colours to ECharts, which does not read every CSS colour syntax. ## Adding the stylesheet to an app @@ -74,21 +70,20 @@ New-PSUPublishedFolder -RequestPath '/assets' -Path 'C:\ProgramData\UniversalAut New-UDApp -Title 'Reports' -Stylesheets @('/assets/corporate.css') -Pages @( ... ) ``` -For a single page, or to try values out, a `' ``` -The properties apply to every chart and report of the page, so this site shows no live example of them. - ## Properties The series colours (`--psu-chart-1` ... `--psu-chart-8`) and the accent (`--psu-chart-accent` or `--psu-pivot-accent`) carry a corporate design: the highlight, drop zone, note, tab and button colours -follow from the accent, and without one they keep PSU's values. The `--psu-pivot-*` properties in the -table set what only the report has or give it a value of its own. Set `--psu-pivot-accent-text` whenever the accent is light in the light mode -or dark in the dark mode: the default text on the accent is white in light mode and near-black in dark. +follow from the accent, and without one they keep PSU's values. Set `--psu-pivot-accent-text` whenever +the accent is light in the light mode or dark in the dark mode: the default text on the accent is white +in light mode and near-black in dark.
Every property: what it falls back to when unset, and its default without a corporate stylesheet @@ -123,10 +118,17 @@ or dark in the dark mode: the default text on the accent is white in light mode | `--psu-pivot-scale-low` | `--psu-pivot-heat-low` | colour scale of a value without colours of its own, lowest | `#eaf1fb` | `#1d2735` | | `--psu-pivot-scale-mid` | - | colour scale of a value, middle: set, the scale has three colours | none | none | | `--psu-pivot-scale-high` | `--psu-pivot-heat-high` | colour scale of a value without colours of its own, highest | `#2a78d6` | `#3987e5` | -| `--psu-pivot-type-string` | - | the icon of a text field and its pill in the empty report | `#6250d6` | `#a99dff` | -| `--psu-pivot-type-number` | - | the icon of a number field and its pill | `#1a7f5a` | `#5fd3a3` | -| `--psu-pivot-type-date` | - | the icon of a date field and its pill | `#b5560b` | `#f2a65a` | -| `--psu-pivot-type-boolean` | - | the icon of a yes/no field and its pill | `#a3367a` | `#f08cc6` | +| `--psu-pivot-type-string`, `--psu-pivot-type-number`, `--psu-pivot-type-date`, `--psu-pivot-type-boolean` | `--psu-pivot-muted`, `--psu-chart-muted` | the icon of a text, number, date or yes/no field and its pill in the empty report | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | +| `--psu-pivot-zone-rows` | - | the Rows zone: its icons, its marks in the field list, its fields' names in the table's header | `#1d5fcc` | `#8db4ff` | +| `--psu-pivot-zone-columns` | - | the Columns zone, the same parts | `#a85a00` | `#f2b559` | +| `--psu-pivot-zone-values` | - | the Values zone, the same parts, also on the grand total | `#0b785c` | `#5fd6ac` | +| `--psu-pivot-zone-filters` | `--psu-pivot-muted`, `--psu-chart-muted` | the Filters zone, the same parts | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | +| `--psu-pivot-zone-tint` | - | how much of its zone's colour a chip's fill takes | `16%` | `16%` | +| `--psu-pivot-zone-tint-base` | `--psu-pivot-surface` | what a chip's fill mixes the zone's colour into | `#ffffff` | `#121212` | +| `--psu-pivot-control-icon` | `--psu-pivot-muted`, `--psu-chart-muted` | a chip's grip, menu arrow and remove button | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | +| `--psu-pivot-sort-arrow` | `--psu-pivot-text`, `--psu-chart-text` | the sort arrow of the sorted field | `rgba(0, 0, 0, 0.87)` | `rgba(255, 255, 255, 0.87)` | +| `--psu-pivot-field-hover` | `--psu-pivot-surface` | a field in the field list on hover | `#ffffff` | `#121212` | +| `--psu-pivot-chart-reference` | `--psu-pivot-muted`, `--psu-chart-muted` | the chart's reference lines that belong to no series | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | | `--psu-pivot-tab-bg` | - | a tab not shown (Table, Chart): its background | `transparent` | `transparent` | | `--psu-pivot-tab-text` | `--psu-pivot-muted`, `--psu-chart-muted` | a tab not shown: its text | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | | `--psu-pivot-tab-selected-bg` | `--psu-pivot-surface` | the tab shown: its background | `#ffffff` | `#121212` | @@ -149,13 +151,13 @@ or dark in the dark mode: the default text on the accent is white in light mode
-The report's chart has eight series colours: `--psu-chart-9` ... `--psu-chart-12` colour only ECharts -charts. `--psu-chart-tooltip`, `--psu-chart-tooltip-border` and `--psu-chart-font-size` are ECharts -only as well; the report's tooltips use `--psu-pivot-surface-raised`. +The report's chart has eight series colours. `--psu-chart-9` ... `--psu-chart-12`, `--psu-chart-tooltip`, +`--psu-chart-tooltip-border` and `--psu-chart-font-size` are ECharts only; the report's tooltips use +`--psu-pivot-surface-raised`. -The field type colours are pivotkit's own: a corporate palette sets them per mode, so each stays -readable on its mode's surface. Set the tab and button properties only where a part needs a colour of -its own. +Colour marks the zones, not the field types: the type icons are the muted text. The zone colours are +pivotkit's own; a corporate one needs 4.5:1 on `--psu-pivot-surface-2` (the values colour also on +`--psu-pivot-total-strong`) and 3:1 on its chips' fill. A colour scale a reader adds without picking colours runs from light to strong blue, the heatmap's colours: it says "more", not "good" or "bad", and the Excel export writes the same colours. For @@ -187,14 +189,12 @@ dark** follows the three properties above. ## Light and dark Excel and print are light also from a dark app; the HTML report is light on paper and on a light screen -and dark on a dark one. The report takes light or dark from PSU's `` and switches with the app's toggle, the -table and the chart at once, without a reload, and keeps the reader's view ([Views](views.md#the-start-view-view)); -undo and redo start over. The theme the report shows is `data-pk-theme="light"` or `"dark"` on its -root; the stylesheet above sets the values on it, so a report pinned with `-Theme Light` or -`-Theme Dark` takes the values of its own theme, also in an app of the other mode. Properties set only -on the page root (`:root`, `:root[data-theme="dark"]`) reach the report by inheritance in the page's -current mode; they are fine for a value that is the same in both modes. Set corners, font weights and -the font on `:root`: the admin panel of `-AdminRole` sits next to the report, outside its theme, and -takes `--psu-pivot-radius`, `--psu-pivot-radius-sm` and `--psu-pivot-weight-strong` from there. +and dark on a dark one. The report takes light or dark from PSU's `` and switches with the +app's toggle without a reload, keeping the reader's view ([Views](views.md#the-start-view-view)); undo +and redo start over. The theme it shows is `data-pk-theme="light"` or `"dark"` on its root, where the +stylesheet above sets the values, so a report pinned with `-Theme Light` or `-Theme Dark` takes its own +theme's values in either app mode. A property set only on `:root` reaches both modes: keep it to values +both share, as corners, font weights and the font. The admin panel of `-AdminRole` sits outside the +report's theme and takes `--psu-pivot-radius`, `--psu-pivot-radius-sm` and `--psu-pivot-weight-strong` from `:root`. Next: [Views](views.md), [Templates, view files and roles](templates.md), [Events, security and limits](events.md), [Reference](reference.md). diff --git a/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md b/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md index a48773c..26862ba 100644 --- a/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md +++ b/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md @@ -12,6 +12,12 @@ All notable changes to PowerShellUniversal.Component.Pivot. Format: the same CSV and JSON. They need pivotkit-server 0.3.0 or later; an older server's answer names that version. `-TimeZone` stays with `-Engine Node` ([#135](https://github.com/eizedev/powershell-universal-components/issues/135)). +- Theme properties for pivotkit's zone colours and chip controls: `--psu-pivot-zone-rows`, + `-zone-columns`, `-zone-values`, `-zone-filters`, `-zone-tint`, `-zone-tint-base`, + `--psu-pivot-control-icon`, `--psu-pivot-sort-arrow`, `--psu-pivot-field-hover` and + `--psu-pivot-chart-reference`, per light and dark mode, listed on the themes page. Without them + the report keeps pivotkit's values. The zone colours, the chip controls, the sort arrow and the + field hover take effect with pivotkit 0.11.0; the reference lines already with 0.10.0. ### Fixed @@ -22,6 +28,9 @@ All notable changes to PowerShellUniversal.Component.Pivot. Format: ### Changed +- The field type icons are the muted text without an app's `--psu-pivot-type-*`, as pivotkit's own + neutral default: colour marks the zones, not the field types. With pivotkit 0.10.0 this also + makes the empty report's field pills and the border of a value chip grey. - The component passes the React hooks lint rules, which are now errors in CI: the latest props for its event handlers are kept in a ref written in an effect, not during render ([#217](https://github.com/eizedev/powershell-universal-components/issues/217)). The reader's view, a loaded file, diff --git a/modules/PowerShellUniversal.Component.Pivot/Components/psu.css b/modules/PowerShellUniversal.Component.Pivot/Components/psu.css index c6d6985..9c105dd 100644 --- a/modules/PowerShellUniversal.Component.Pivot/Components/psu.css +++ b/modules/PowerShellUniversal.Component.Pivot/Components/psu.css @@ -25,8 +25,9 @@ * * The tabs and buttons (pivotkit-react) take --psu-pivot-tab-*, --psu-pivot-icon-button-*, * --psu-pivot-button-* and --psu-pivot-primary-*; without them they derive from the general tokens as - * pivotkit does, so they follow PSU. The zone frames follow --pk-border-strong. The field type colours - * take --psu-pivot-type-*; without them they keep pivotkit's own values, repeated below per mode. + * pivotkit does, so they follow PSU. The zone frames follow --pk-border-strong. The zones' colours take + * --psu-pivot-zone-*; without them they keep pivotkit's own values, repeated below per mode. The field + * type icons take --psu-pivot-type-*; without them they are the muted text, pivotkit's neutral default. * * pivotkit's shadows, scrims and its other semantic colours (danger, warning, the switch's knob) stay * pivotkit's: at their alpha the light shadows' blue tint does not show next to PSU's greys. @@ -56,6 +57,8 @@ --psu-default-tab-bg: transparent; /* how much of the primary button's fill stays on hover, mixed with the text colour (pivotkit's) */ --psu-default-mix-primary-hover: 88%; + /* how much of a zone's colour its fill takes (pivotkit's) */ + --psu-default-zone-tint: 16%; } /* ---- PSU's defaults, light ------------------------------------------------------------------- */ @@ -94,11 +97,10 @@ --psu-default-mix-soft: 12%; --psu-default-mix-drop: 18%; --psu-default-mix-note: 7%; - /* the field types' colours: pivotkit's (pivotkit-react's styles.css) */ - --psu-default-type-string: #6250d6; - --psu-default-type-number: #1a7f5a; - --psu-default-type-date: #b5560b; - --psu-default-type-boolean: #a3367a; + /* the zones' colours: pivotkit's (pivotkit-react's styles.css), 4.5:1 on PSU's zone section too */ + --psu-default-zone-rows: #1d5fcc; + --psu-default-zone-columns: #a85a00; + --psu-default-zone-values: #0b785c; } /* ---- PSU's defaults, dark -------------------------------------------------------------------- */ @@ -136,10 +138,9 @@ --psu-default-mix-soft: 18%; --psu-default-mix-drop: 32%; --psu-default-mix-note: 10%; - --psu-default-type-string: #a99dff; - --psu-default-type-number: #5fd3a3; - --psu-default-type-date: #f2a65a; - --psu-default-type-boolean: #f08cc6; + --psu-default-zone-rows: #8db4ff; + --psu-default-zone-columns: #f2b559; + --psu-default-zone-values: #5fd6ac; } /* ---- the bridge, one declaration per token for both modes ------------------------------------ */ @@ -206,11 +207,26 @@ --pk-weight-strong: var(--psu-pivot-weight-strong, var(--psu-default-weight-strong)); --pk-weight-bold: var(--psu-pivot-weight-bold, var(--psu-default-weight-bold)); - /* the field type icons and the empty state's pills */ - --pk-type-string: var(--psu-pivot-type-string, var(--psu-default-type-string)); - --pk-type-number: var(--psu-pivot-type-number, var(--psu-default-type-number)); - --pk-type-date: var(--psu-pivot-type-date, var(--psu-default-type-date)); - --pk-type-boolean: var(--psu-pivot-type-boolean, var(--psu-default-type-boolean)); + /* the field type icons and the empty state's pills: neutral as pivotkit's, so colour marks the zones */ + --pk-type-string: var(--psu-pivot-type-string, var(--pk-muted)); + --pk-type-number: var(--psu-pivot-type-number, var(--pk-muted)); + --pk-type-date: var(--psu-pivot-type-date, var(--pk-muted)); + --pk-type-boolean: var(--psu-pivot-type-boolean, var(--pk-muted)); + + /* each zone's colour (its icons, its marks in the field list, a field's name in the table's header) + and the fill of its chips and names: that share of the colour mixed into the base */ + --pk-zone-rows: var(--psu-pivot-zone-rows, var(--psu-default-zone-rows)); + --pk-zone-columns: var(--psu-pivot-zone-columns, var(--psu-default-zone-columns)); + --pk-zone-values: var(--psu-pivot-zone-values, var(--psu-default-zone-values)); + --pk-zone-filters: var(--psu-pivot-zone-filters, var(--pk-muted)); + --pk-zone-tint: var(--psu-pivot-zone-tint, var(--psu-default-zone-tint)); + --pk-zone-tint-base: var(--psu-pivot-zone-tint-base, var(--pk-surface)); + /* a chip's grip, menu arrow and x; the sort arrow of the sorted field; a field's hover in the list; + the chart's reference lines of no series. Without a value of the app, derived as pivotkit does */ + --pk-control-icon: var(--psu-pivot-control-icon, var(--pk-muted)); + --pk-sort-arrow: var(--psu-pivot-sort-arrow, var(--pk-text)); + --pk-field-hover: var(--psu-pivot-field-hover, var(--pk-surface)); + --pk-chart-reference: var(--psu-pivot-chart-reference, var(--pk-muted)); /* the tabs (Table, Chart) and the buttons; without a value of the app, derived as pivotkit does */ --pk-tab-bg: var(--psu-pivot-tab-bg, var(--psu-default-tab-bg)); diff --git a/tests/browser/psu-pivot.spec.mjs b/tests/browser/psu-pivot.spec.mjs index 364cc2d..0fa06c9 100644 --- a/tests/browser/psu-pivot.spec.mjs +++ b/tests/browser/psu-pivot.spec.mjs @@ -816,9 +816,9 @@ test.describe("pivot showcase on PSU", () => { const tab = report.locator('.pk-tab[aria-selected="true"]').first(); await expect(icon).toBeVisible(); await expect(tab).toBeVisible(); - // without the app's values: pivotkit's own type colour, and the shown tab in the accent (PSU's blue) + // without the app's values: the muted text, pivotkit's neutral type icons, and the shown tab in the accent (PSU's blue) await setTheme(page, "light"); - await expect(icon).toHaveCSS("color", "rgb(98, 80, 214)"); + await expect(icon).toHaveCSS("color", "rgba(0, 0, 0, 0.62)"); await expect(tab).toHaveCSS("color", "rgb(25, 118, 210)"); await page.addStyleTag({ content: ':root, .ud-pivot-report [data-pk-theme="light"] { --psu-pivot-type-string: #8a1538; --psu-pivot-tab-selected-text: #005500; } ' + @@ -832,6 +832,31 @@ test.describe("pivot showcase on PSU", () => { } }); + test("--psu-pivot-zone-* and the chip controls from the app's stylesheet reach pivotkit's zone tokens, per PSU mode (pivotkit#920)", async ({ page }) => { + await open(page, "tickets"); + const report = page.locator(REPORT); + const token = (name) => report.evaluate((e, n) => getComputedStyle(e).getPropertyValue(n).trim(), name); + // without the app's values: pivotkit's zone colours, as docs/pivot/themes.md lists them + const defaults = { light: ["#1d5fcc", "#a85a00", "#0b785c", "16%"], dark: ["#8db4ff", "#f2b559", "#5fd6ac", "16%"] }; + const names = ["--pk-zone-rows", "--pk-zone-columns", "--pk-zone-values", "--pk-zone-tint"]; + for (const mode of ["light", "dark"]) { + await setTheme(page, mode); + await expect(report).toHaveAttribute("data-pk-theme", mode); + for (const [k, name] of names.entries()) await expect.poll(() => token(name)).toBe(defaults[mode][k]); + await expect.poll(() => token("--pk-control-icon")).toBe(await token("--pk-muted")); + } + await page.addStyleTag({ + content: ':root, .ud-pivot-report [data-pk-theme="light"] { --psu-pivot-zone-rows: #003b6f; --psu-pivot-control-icon: #4a5263; } ' + + ':root[data-theme="dark"], .ud-pivot-report [data-pk-theme="dark"] { --psu-pivot-zone-rows: #6fa8dc; --psu-pivot-control-icon: #a9b1bf; }' + }); + for (const [mode, rows, control] of [["light", "#003b6f", "#4a5263"], ["dark", "#6fa8dc", "#a9b1bf"]]) { + await setTheme(page, mode); + await expect(report).toHaveAttribute("data-pk-theme", mode); + await expect.poll(() => token("--pk-zone-rows")).toBe(rows); + await expect.poll(() => token("--pk-control-icon")).toBe(control); + } + }); + test("a colour scale without colours is blue in PSU's light and dark mode; a dark app exports the light colours of the documented stylesheet", async ({ page }) => { // the start view with a colour scale on the count, as a reader adds it (no colours of its own), as a link const view = { rows: ["Team"], cols: ["Priority"], values: [{ field: "Ticket", agg: "count", conditional: { type: "colorScale" } }] }; diff --git a/tests/js/pivot.test.js b/tests/js/pivot.test.js index c3ceeba..70271b2 100644 --- a/tests/js/pivot.test.js +++ b/tests/js/pivot.test.js @@ -571,9 +571,9 @@ for (const mode of ["light", "dark"]) { } // pivotkit-react's own values (styles.css, the same in 0.8.1 and 0.9.0) for the tokens the bridge -// maps without changing them: the field types per mode, the tabs and buttons as pivotkit derives -// them. Where the module's packages are installed (CI's pivot step), the test reads them from the -// installed styles.css instead, so a new pivotkit version that changes one fails there. +// maps without changing them: the tabs and buttons as pivotkit derives them. Where the module's +// packages are installed (CI's pivot step), the test reads them from the installed styles.css +// instead, so a new pivotkit version that changes one fails there. const PK_ROOT = { "--pk-tab-bg": "transparent", "--pk-tab-text": "var(--pk-muted)", @@ -587,27 +587,70 @@ const PK_ROOT = { "--pk-primary-text": "var(--pk-accent-text)", "--pk-primary-hover-bg": "color-mix(in srgb, var(--pk-accent) 88%, var(--pk-text))", }; -const PK_TYPES = [ - { "--pk-type-string": "#6250d6", "--pk-type-number": "#1a7f5a", "--pk-type-date": "#b5560b", "--pk-type-boolean": "#a3367a" }, - { "--pk-type-string": "#a99dff", "--pk-type-number": "#5fd3a3", "--pk-type-date": "#f2a65a", "--pk-type-boolean": "#f08cc6" }, -]; const pkStylesUrl = new URL("../../modules/PowerShellUniversal.Component.Pivot/node_modules/pivotkit-react/dist/styles.css", import.meta.url); function pkDeclarations(index) { - if (!existsSync(pkStylesUrl)) return { ...(index ? {} : PK_ROOT), ...PK_TYPES[index] }; - // the first block that sets --pk-type-string is the light root, the second the dark one - const blocks = [...readFileSync(pkStylesUrl, "utf8").matchAll(/\{([^{}]*--pk-type-string[^{}]*)\}/g)].map((m) => m[1]); + if (!existsSync(pkStylesUrl)) return index ? {} : PK_ROOT; + // the first block that sets --pk-chart-1 is the light root, the second the dark one + const blocks = [...readFileSync(pkStylesUrl, "utf8").matchAll(/\{([^{}]*--pk-chart-1:[^{}]*)\}/g)].map((m) => m[1]); return Object.fromEntries([...blocks[index].matchAll(/(--pk-[a-z0-9-]+):\s*([^;]+);/g)].map((m) => [m[1], m[2].trim()])); } const PART_TOKENS = ["tab-bg", "tab-text", "tab-selected-bg", "tab-selected-text", "icon-button-text", "icon-button-hover-bg", "button-border", "button-border-hover", "primary-bg", "primary-text", "primary-hover-bg"]; +// pivotkit-react's tokens of the reworked field area and table header (eizedev/pivotkit#920), as +// pivotkit's main has them: the zone colours per mode, the rest derived from the general tokens, the +// type icons neutral. pivotkit-react 0.10 has none of them but the chart's reference lines; once the +// installed one has the zone colours, the test reads it instead. +const PK_ZONES = [ + { + "--pk-type-string": "var(--pk-muted)", + "--pk-type-number": "var(--pk-muted)", + "--pk-type-date": "var(--pk-muted)", + "--pk-type-boolean": "var(--pk-muted)", + "--pk-zone-rows": "#1d5fcc", + "--pk-zone-columns": "#a85a00", + "--pk-zone-values": "#0b785c", + "--pk-zone-filters": "var(--pk-muted)", + "--pk-zone-tint": "16%", + "--pk-zone-tint-base": "var(--pk-surface)", + "--pk-control-icon": "var(--pk-muted)", + "--pk-sort-arrow": "var(--pk-text)", + "--pk-field-hover": "var(--pk-surface)", + "--pk-chart-reference": "var(--pk-muted)", + }, + { "--pk-zone-rows": "#8db4ff", "--pk-zone-columns": "#f2b559", "--pk-zone-values": "#5fd6ac", "--pk-chart-reference": "var(--pk-muted)" }, +]; +const ZONE_TOKENS = Object.keys(PK_ZONES[0]); +const pkZones = (index) => (existsSync(pkStylesUrl) && pkDeclarations(0)["--pk-zone-rows"] ? pkDeclarations(index) : PK_ZONES[index]); + for (const [mode, index] of [["light", 0], ["dark", 1]]) { - test(`theme bridge (${mode}): the field type colours are pivotkit's without an app's value, --psu-pivot-type-* sets them (#137)`, () => { + test(`theme bridge (${mode}): zone colours, type icons, chip controls, sort arrow, field hover and reference lines are pivotkit's without an app's value, --psu-pivot-* sets each (#137, pivotkit#920)`, () => { + const t = tokensOf(mode); + const pk = { ...pkZones(0), ...(index ? pkZones(1) : {}) }; + // pivotkit's values, its derivations resolved over the bridge's general tokens + const general = Object.fromEntries(Object.entries(t).filter(([n]) => !ZONE_TOKENS.includes(n))); + for (const name of ZONE_TOKENS) { + assert.ok(pk[name], `pivotkit-react has ${name}`); + assert.equal(t[name], substitute(pk[name], {}, general, new Set()), `${name} as pivotkit has it`); + assert.equal(tokensOf(mode, { [name.replace("--pk-", "--psu-pivot-")]: "#123456" })[name], "#123456", name.replace("--pk-", "--psu-pivot-")); + } + // the type icons follow the muted text, also a corporate one + assert.equal(tokensOf(mode, { "--psu-chart-muted": "#4a5263" })["--pk-type-number"], "#4a5263"); + }); + + test(`theme bridge (${mode}): each zone colour 4.5:1 on PSU's zone section, the values colour also on the grand total's header; 3:1 on its own fill; the chip controls 3:1 on every fill`, () => { const t = tokensOf(mode); - const pk = pkDeclarations(index); - for (const type of ["string", "number", "date", "boolean"]) { - assert.ok(pk[`--pk-type-${type}`], `pivotkit sets --pk-type-${type} in ${mode}`); - assert.equal(t[`--pk-type-${type}`], pk[`--pk-type-${type}`], `--pk-type-${type} stays pivotkit's`); - assert.equal(tokensOf(mode, { [`--psu-pivot-type-${type}`]: "#003b6f" })[`--pk-type-${type}`], "#003b6f"); + const base = parseColor(t["--pk-zone-tint-base"]); + const share = Number.parseFloat(t["--pk-zone-tint"]) / 100; + for (const zone of ["rows", "columns", "values"]) { + const colour = parseColor(t[`--pk-zone-${zone}`]); + // the field names in the table's header take their zone's colour; only the values' names sit on the grand total + for (const surface of zone === "values" ? ["--pk-surface-2", "--pk-total-strong"] : ["--pk-surface-2"]) { + assert.ok(contrastRatio(colour, parseColor(t[surface])) >= 4.5, `${zone} on ${surface}`); + } + // the fill: an opaque mix of the zone's colour into the base (pivotkit-react's .pk-zone-fill) + const fill = `rgb(${colour.map((v, i) => Math.round(v * share + base[i] * (1 - share))).join(", ")})`; + assert.ok(contrastRatio(colour, parseColor(fill)) >= 3, `${zone} on its fill`); + assert.ok(contrastRatio(over(t["--pk-control-icon"], fill), parseColor(fill)) >= 3, `chip controls on the ${zone} fill`); } }); From 3a7629d8f4c6155705d48173a5d8cc52c158597f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Thu, 26 Nov 2026 03:52:53 +0100 Subject: [PATCH 04/11] test(pivot): one test for the server version hints, the call without the new options in the first The version hints for -Data, -Parameter and -Locale/-Numbers/-FlatHeader share one helper instead of a copied answer, call and catch per case. The check that a call without -Locale, -Numbers and -FlatHeader sends none of them moves into the first REST test, which makes that call already. Co-Authored-By: Claude Opus 5.5 --- tests/powershell/PivotReport.Tests.ps1 | 58 ++++++++++---------------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/tests/powershell/PivotReport.Tests.ps1 b/tests/powershell/PivotReport.Tests.ps1 index dc87616..fd12869 100644 --- a/tests/powershell/PivotReport.Tests.ps1 +++ b/tests/powershell/PivotReport.Tests.ps1 @@ -573,6 +573,8 @@ Describe 'Invoke-UDPivotReport -Engine Rest (a stand-in pivotkit-server)' { $sent.data.name | Should -Be 'Tickets' $log[0].Body | Should -BeLike '*"asOf":"2026-11-15T06:00:00Z"*' $sent.view.rows | Should -Be @('Team') + # without -Locale, -Numbers and -FlatHeader none is sent: the server's defaults, and older servers still work + foreach ($name in 'locale', 'numbers', 'flatHeader') { $sent.PSObject.Properties.Name | Should -Not -Contain $name } } It '-Locale, -Numbers and -FlatHeader go into the body as pivotkit-server reads them, on both routes, and only when given (#135)' { @@ -587,17 +589,6 @@ Describe 'Invoke-UDPivotReport -Engine Rest (a stand-in pivotkit-server)' { $sent = $log[0].Body | ConvertFrom-Json -Depth 16 $sent.numbers | Should -BeExactly 'full' $sent.PSObject.Properties.Name | Should -Not -Contain 'flatHeader' - # without them nothing is sent: the server's defaults, and older servers still work - $null = Invoke-UDPivotReport @rest -Token 'static-token-0123456789' -Data $rows -View $view -Format csv - $sent = (@(Get-Log)[0]).Body | ConvertFrom-Json -Depth 16 - foreach ($name in 'locale', 'numbers', 'flatHeader') { $sent.PSObject.Properties.Name | Should -Not -Contain $name } - } - - It 'a server too old for -Locale, -Numbers or -FlatHeader: the error names the version they need (#135)' { - $mock.Render.Enqueue(@{ Status = 400; Body = '{"type":"https://pivotkit.eize.dev/reference/rest/#error-invalid-input","title":"Invalid input","status":400,"code":"INVALID_INPUT","detail":"input has no key \"numbers\""}' }) - $caught = $null - try { Invoke-UDPivotReport @rest -Token 'static-token-0123456789' -Data $rows -View $view -Format csv -Numbers Shown } catch { $caught = $_ } - $caught.Exception.Message | Should -BeLike '*input has no key "numbers"*-Locale, -Numbers and -FlatHeader need pivotkit-server 0.3.0 or later*' } It 'a SecureString token, a configured source with parameters, a layout' { @@ -610,33 +601,30 @@ Describe 'Invoke-UDPivotReport -Engine Rest (a stand-in pivotkit-server)' { $sent.format | Should -Be 'xlsx' } - It 'a server that does not know -Data or -Parameter: the error names the server version they need (#129)' { - # the answers of pivotkit-server 0.1.1 to data in the request and to params; 0.2.0 answers - # params the same way when none of its sources declares parameters - $mock.Render.Enqueue(@{ Status = 400; Body = '{"type":"https://pivotkit.eize.dev/reference/rest/#error-invalid-input","title":"Invalid input","status":400,"code":"INVALID_INPUT","detail":"input has no key \"data\""}' }) - $caught = $null - try { Invoke-UDPivotReport @rest -Token 'static-token-0123456789' -Data $rows -View $view } catch { $caught = $_ } + It 'a server too old for a parameter: the error names the server version it needs (#129, #132, #135)' { + # pivotkit-server 0.1.1 knows neither data in the request nor params; 0.2.0 answers params the same + # way when none of its sources declares parameters, later versions in words (NO_PARAMS_TEXT of + # pivotkit-server's sources/input.js); before 0.3.0 it knows no locale, numbers or flatHeader + $errorOf = { + param([int]$Status, [string]$Code, [string]$Detail, [hashtable]$Call) + $mock.Render.Enqueue(@{ Status = $Status; Body = (@{ type = 'x'; title = 'x'; status = $Status; code = $Code; detail = $Detail } | ConvertTo-Json -Compress) }) + try { $null = Invoke-UDPivotReport @rest -Token 'static-token-0123456789' @Call } catch { $_ } + } + $data = @{ Data = $rows; View = $view } + $params = @{ Source = 'vms'; Parameter = @{ customer = 'acme' }; View = $view } + $caught = & $errorOf 400 'INVALID_INPUT' 'input has no key "data"' $data $caught.FullyQualifiedErrorId | Should -BeLike 'PivotServerError*' $caught.Exception.Message | Should -BeLike '*INVALID_INPUT (400): input has no key "data"*-Data needs pivotkit-server 0.2.0 or later*-Source*' - $mock.Render.Enqueue(@{ Status = 400; Body = '{"type":"https://pivotkit.eize.dev/reference/rest/#error-invalid-input","title":"Invalid input","status":400,"code":"INVALID_INPUT","detail":"input has no key \"params\""}' }) - $caught = $null - try { Invoke-UDPivotReport @rest -Token 'static-token-0123456789' -Source 'vms' -Parameter @{ customer = 'acme' } -View $view } catch { $caught = $_ } - $caught.Exception.Message | Should -BeLike '*INVALID_INPUT (400): input has no key "params"*-Parameter needs a source with parameters on pivotkit-server 0.2.0 or later*' - # newer servers say it in words (NO_PARAMS_TEXT of pivotkit-server's sources/input.js, #132) - $mock.Render.Enqueue(@{ Status = 400; Body = '{"type":"https://pivotkit.eize.dev/reference/rest/#error-invalid-input","title":"Invalid input","status":400,"code":"INVALID_INPUT","detail":"this server has no source that takes params; leave params out (GET /sources lists the sources)"}' }) - $caught = $null - try { Invoke-UDPivotReport @rest -Token 'static-token-0123456789' -Source 'vms' -Parameter @{ customer = 'acme' } -View $view } catch { $caught = $_ } - $caught.Exception.Message | Should -BeLike '*INVALID_INPUT (400): this server has no source that takes params*-Parameter needs a source with parameters on pivotkit-server 0.2.0 or later*' + (& $errorOf 400 'INVALID_INPUT' 'input has no key "params"' $params).Exception.Message | Should -BeLike '*INVALID_INPUT (400): input has no key "params"*-Parameter needs a source with parameters on pivotkit-server 0.2.0 or later*' + (& $errorOf 400 'INVALID_INPUT' 'this server has no source that takes params; leave params out (GET /sources lists the sources)' $params).Exception.Message | + Should -BeLike '*INVALID_INPUT (400): this server has no source that takes params*-Parameter needs a source with parameters on pivotkit-server 0.2.0 or later*' + (& $errorOf 400 'INVALID_INPUT' 'input has no key "numbers"' ($data + @{ Format = 'csv'; Numbers = 'Shown' })).Exception.Message | + Should -BeLike '*input has no key "numbers"*-Locale, -Numbers and -FlatHeader need pivotkit-server 0.3.0 or later*' # another invalid input, and data refused by the server's policy, get no version hint - $mock.Render.Enqueue(@{ Status = 400; Body = '{"type":"x","title":"Invalid input","status":400,"code":"INVALID_INPUT","detail":"view.rows[0] must be a string"}' }) - $caught = $null - try { Invoke-UDPivotReport @rest -Token 'static-token-0123456789' -Data $rows -View $view } catch { $caught = $_ } - $caught.Exception.Message | Should -Not -BeLike '*pivotkit-server 0.2.0*' - $mock.Render.Enqueue(@{ Status = 403; Body = '{"type":"x","title":"Not allowed","status":403,"code":"NOT_ALLOWED","detail":"this server takes no data sent in the request (the operator allows it per profile: data: true); use a source from GET /sources"}' }) - $caught = $null - try { Invoke-UDPivotReport @rest -Token 'static-token-0123456789' -Data $rows -View $view } catch { $caught = $_ } - $caught.Exception.Message | Should -BeLike '*NOT_ALLOWED (403)*data: true*' - $caught.Exception.Message | Should -Not -BeLike '*pivotkit-server 0.2.0*' + (& $errorOf 400 'INVALID_INPUT' 'view.rows[0] must be a string' $data).Exception.Message | Should -Not -BeLike '*pivotkit-server 0.*' + $message = (& $errorOf 403 'NOT_ALLOWED' 'this server takes no data sent in the request (the operator allows it per profile: data: true); use a source from GET /sources' $data).Exception.Message + $message | Should -BeLike '*NOT_ALLOWED (403)*data: true*' + $message | Should -Not -BeLike '*pivotkit-server 0.*' } It 'a 422 lists the findings and the request id; a 503 says when to try again; a redirect is not followed' { From 52d91fdfe45f17fd1784651cc8105b3f9b319b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Thu, 26 Nov 2026 03:56:24 +0100 Subject: [PATCH 05/11] docs(pivot): coming from UniversalDashboard.Pivot The pivot overview maps every parameter of New-UDPivot to New-UDPivotReport: the start view moves into -View, each aggregator and renderer name has its pivotkit counterpart or is named as having none. One report on the same rows, before and after; the module README links the section. Refs #121 Co-Authored-By: Claude Opus 5.5 --- docs/pivot/index.md | 45 +++++++++++++++++++ .../CHANGELOG.md | 4 ++ .../README.md | 1 + 3 files changed, 50 insertions(+) diff --git a/docs/pivot/index.md b/docs/pivot/index.md index 0140875..3e9df60 100644 --- a/docs/pivot/index.md +++ b/docs/pivot/index.md @@ -40,6 +40,7 @@ New-UDPivotReport -Id 'tickets' -Data (Invoke-Sqlcmd -Query 'SELECT * FROM Ticke | What readers get, and what the app decides for them | [Readers and your app](readers.md) | | What `-Data` takes, large data | [Data and loading](data.md) | | Every parameter | [Commands and parameters](reference.md) | +| Move an app from `New-UDPivot` | [Coming from UniversalDashboard.Pivot](#coming-from-universaldashboardpivot) | Readers drag fields from a searchable list into **Rows**, **Columns**, **Values** and **Filters** and get a table with totals or a chart, with date grouping, drill-down to the source rows, shared views and @@ -99,4 +100,48 @@ New-UDDynamic -Id 'tickets-report' -LoadingComponent { --8<-- "examples/pivot-report-in-german.md" +## Coming from UniversalDashboard.Pivot { #coming-from-universaldashboardpivot } + +`New-UDPivotReport` replaces `New-UDPivot` of [UniversalDashboard.Pivot](https://github.com/eizedev/UniversalDashboard.Pivot), +which wraps react-pivottable. Check the PowerShell and PSU versions on [Compatibility](../compatibility.md). +The start view moves from parameters into one `-View` ([Views](views.md#the-start-view-view)). The +same rows, before and after: + +```powershell +$data = @( + @{ Team = 'OPS'; Status = 'Open'; Priority = 'High'; Hours = 5 } + @{ Team = 'OPS'; Status = 'Closed'; Priority = 'Low'; Hours = 2 } + @{ Team = 'OPS'; Status = 'Closed'; Priority = 'High'; Hours = 4 } + @{ Team = 'DEV'; Status = 'Open'; Priority = 'High'; Hours = 8 } + @{ Team = 'DEV'; Status = 'Closed'; Priority = 'Medium'; Hours = 3 } + @{ Team = 'DEV'; Status = 'Open'; Priority = 'Low'; Hours = 6 } + @{ Team = 'QA'; Status = 'Open'; Priority = 'Medium'; Hours = 1 } + @{ Team = 'QA'; Status = 'Closed'; Priority = 'High'; Hours = 7 } +) +# before +New-UDPivot -Id 'tickets-before' -Data $data -Rows 'Team' -Cols 'Status' -Vals 'Hours' -AggregatorName 'Sum' -RowOrder 'value_z_to_a' -ValueFilter @{ Priority = @{ Low = $true } } +# after +New-UDPivotReport -Id 'tickets-after' -Data $data -View @{ + rows = @('Team') + cols = @('Status') + values = @(@{ field = 'Hours'; agg = 'sum' }) + filters = @(@{ field = 'Priority'; type = 'in'; items = @('Low'); not = $true; blanks = 'include' }) + sort = @(@{ field = 'Team'; by = 'value'; order = 'desc' }) +} +``` + +Both show the sum of hours without the Low tickets, the teams by their total, highest first: DEV 11, +OPS 9, QA 8. + +| `New-UDPivot` | `New-UDPivotReport` | +| --- | --- | +| `-Id`, `-Data` | `-Id`, `-Data`: also a script block, and a DataTable ([Data and loading](data.md)) | +| `-Rows`, `-Cols` | `rows`, `cols` in `-View` | +| `-Vals`, `-AggregatorName` | `values`, each with its field and `agg`. `Count` is `count` on a field: it counts the rows where the field has a value. `Count Unique Values`, `List Unique Values`: `countUnique`, `listUnique`. `Sum`, `Integer Sum`: `sum` (with `format = 'integer'`). `Average`, `Median`, `Minimum`, `Maximum`, `First`, `Last`: `average`, `median`, `min`, `max`, `first`, `last`. `Sample Variance`, `Sample Standard Deviation`: `var`, `stdev`. `Sum` or `Count as Fraction of Total`, `of Rows`, `of Columns`: `sum` or `count` with `showAs = @{ type = 'percentOfGrandTotal' }`, `'percentOfRowTotal'`, `'percentOfColumnTotal'`. No counterpart: `Sum over Sum`, `80% Upper Bound`, `80% Lower Bound`. | +| `-RendererName` | `Table`: the default. `Table Heatmap`: `conditional = @{ type = 'colorScale' }` on the value. `Grouped Column Chart`, `Stacked Column Chart`: `display = 'chart'; chart = @{ type = 'bar' }`, with `stacked = $true`; `Grouped Bar Chart`, `Stacked Bar Chart` add `horizontal = $true`. `Line Chart`, `Area Chart`: `type = 'line'`, `'area'`. `Exportable TSV`: the reader's export copies the table as tab-separated text. No counterpart: `Table Row Heatmap`, `Table Col Heatmap`, `Dot Chart`, `Scatter Chart`, `Multiple Pie Chart` (`type = 'pie'` draws one pie of the row totals). | +| `-RowOrder`, `-ColOrder` | `key_a_to_z`: the default. `value_a_to_z`, `value_z_to_a`: `sort = @(@{ field = 'Team'; by = 'value'; order = 'asc' })` or `'desc'`, per row or column field. | +| `-ValueFilter` | `filters`: the listed items with `type = 'in'; not = $true; blanks = 'include'` ([Filters](filters.md)). | +| `-HiddenAttributes` | No counterpart: leave the column out of the rows you pass to `-Data` (`Select-Object -ExcludeProperty` for objects), so it does not reach the browser either. | +| `-HiddenFromAggregators`, `-HiddenFromDragDrop`, `-MenuLimit`, `-UnusedOrientationCutoff` | No counterpart. | + Next: [Readers and your app](readers.md), [Data and loading](data.md), [Field names and descriptions](fields.md), [Themes and corporate design](themes.md), [Views](views.md), [Templates, view files and roles](templates.md), [Events, security and limits](events.md), [Reference](reference.md). diff --git a/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md b/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md index 26862ba..aabcb1e 100644 --- a/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md +++ b/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md @@ -18,6 +18,10 @@ All notable changes to PowerShellUniversal.Component.Pivot. Format: `--psu-pivot-chart-reference`, per light and dark mode, listed on the themes page. Without them the report keeps pivotkit's values. The zone colours, the chip controls, the sort arrow and the field hover take effect with pivotkit 0.11.0; the reference lines already with 0.10.0. +- The pivot overview's section "Coming from UniversalDashboard.Pivot" maps every parameter of + `New-UDPivot` to `New-UDPivotReport`, names those without a counterpart, and shows one report + before and after; the module README links it + ([#121](https://github.com/eizedev/powershell-universal-components/issues/121)). ### Fixed diff --git a/modules/PowerShellUniversal.Component.Pivot/README.md b/modules/PowerShellUniversal.Component.Pivot/README.md index 1809c57..c7fa4d2 100644 --- a/modules/PowerShellUniversal.Component.Pivot/README.md +++ b/modules/PowerShellUniversal.Component.Pivot/README.md @@ -53,6 +53,7 @@ is a showcase app in one line (`New-UDPivotShowcase`). - [Reports without a browser](https://powershell-universal-components.eize.dev/pivot/reports/): `Invoke-UDPivotReport`; [from a pivotkit-server](https://powershell-universal-components.eize.dev/pivot/reports-server/) with `Get-UDPivotSource` - [Themes and corporate design](https://powershell-universal-components.eize.dev/pivot/themes/), shared with the ECharts module - [Reference](https://powershell-universal-components.eize.dev/pivot/reference/): every parameter +- [Coming from UniversalDashboard.Pivot](https://powershell-universal-components.eize.dev/pivot/#coming-from-universaldashboardpivot): `New-UDPivot`'s parameters in `New-UDPivotReport` ## Security notes From 00ca6c02868835873d51d553c572c1bd5fa02c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:04:51 +0100 Subject: [PATCH 06/11] test(pivot): accept the version-hint and render-input tests in the growth baseline PivotReport.Tests.ps1 grows by 16 code lines for the #132 and #135 tests, after folding the version hints into one helper. The file was over its limit before; splitting it is a change of its own. Co-Authored-By: Claude Opus 5.5 --- build/growth-baseline.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/growth-baseline.json b/build/growth-baseline.json index 51f67d3..4c5cae4 100644 --- a/build/growth-baseline.json +++ b/build/growth-baseline.json @@ -3,7 +3,7 @@ "pages": { "README.md": [110] }, - "totalLines": 5202 + "totalLines": 5252 }, "javascript": { "complexity": { @@ -26,7 +26,7 @@ "modules/PowerShellUniversal.Component.ECharts.Demo/Apps/Showcase.ps1": [1330], "modules/PowerShellUniversal.Component.Pivot.Demo/Apps/Showcase.ps1": [305], "tests/powershell/Pivot.Tests.ps1": [521], - "tests/powershell/PivotReport.Tests.ps1": [1391], + "tests/powershell/PivotReport.Tests.ps1": [1407], "tests/powershell/PivotTemplates.Tests.ps1": [729] }, "functions": { From 713658ecbe7be3fa3921ccf86b51bcc7528cddbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:18:19 +0100 Subject: [PATCH 07/11] fix(pivot): a server whose sources take no params gets its own hint, not a version A current pivotkit-server answers -Parameter with "this server has no source that takes params" when none of its sources declares parameters. That server is new enough, so the hint now says to leave -Parameter out or use a source that declares them (Get-UDPivotSource lists them). The older "no key \"params\"" keeps the 0.2.0 hint. The test asserts each text's hint and that the new one names no version; that assertion is the one code line the baseline takes in. Refs #132 Co-Authored-By: Claude Opus 5.5 --- build/growth-baseline.json | 2 +- .../PowerShellUniversal.Component.Pivot/CHANGELOG.md | 7 ++++--- .../Private/New-UDPivotServerError.ps1 | 8 ++++++-- tests/powershell/PivotReport.Tests.ps1 | 11 ++++++----- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/build/growth-baseline.json b/build/growth-baseline.json index 4c5cae4..1daed17 100644 --- a/build/growth-baseline.json +++ b/build/growth-baseline.json @@ -26,7 +26,7 @@ "modules/PowerShellUniversal.Component.ECharts.Demo/Apps/Showcase.ps1": [1330], "modules/PowerShellUniversal.Component.Pivot.Demo/Apps/Showcase.ps1": [305], "tests/powershell/Pivot.Tests.ps1": [521], - "tests/powershell/PivotReport.Tests.ps1": [1407], + "tests/powershell/PivotReport.Tests.ps1": [1408], "tests/powershell/PivotTemplates.Tests.ps1": [729] }, "functions": { diff --git a/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md b/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md index aabcb1e..d571d64 100644 --- a/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md +++ b/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md @@ -25,9 +25,10 @@ All notable changes to PowerShellUniversal.Component.Pivot. Format: ### Fixed -- `Invoke-UDPivotReport -Engine Rest -Parameter` names the server version it needs also for the - answer newer pivotkit-servers give when none of their sources takes parameters ("this server has - no source that takes params"), as for the older `no key "params"` +- `Invoke-UDPivotReport -Engine Rest -Parameter` explains the answer current pivotkit-servers give + when none of their sources takes parameters ("this server has no source that takes params"): + leave `-Parameter` out, or use a source that declares them. The older `no key "params"` still + names pivotkit-server 0.2.0 ([#132](https://github.com/eizedev/powershell-universal-components/issues/132)). ### Changed diff --git a/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotServerError.ps1 b/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotServerError.ps1 index 5f33f06..ae0b0b6 100644 --- a/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotServerError.ps1 +++ b/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotServerError.ps1 @@ -45,11 +45,15 @@ function New-UDPivotServerError { } # pivotkit-server 0.1.1 knows neither data in the request nor params; its answer reads like a # fault in the request (#129). 0.2.0 answers params the same way when none of its sources takes - # any; later versions say so in words, recognised by "takes params" (NO_PARAMS_TEXT, #132). - if ($status -eq 400 -and $code -eq 'INVALID_INPUT' -and $p.Detail -match 'no key "(data|params)"|(takes params)') { + # any; later versions say that in words, recognised by "takes params" (NO_PARAMS_TEXT, #132): + # that server is new enough, only its sources take no parameters. + if ($status -eq 400 -and $code -eq 'INVALID_INPUT' -and $p.Detail -match 'no key "(data|params)"') { $message += [Environment]::NewLine + $(if ($Matches[1] -eq 'data') { '-Data needs pivotkit-server 0.2.0 or later; an older server renders only -Source.' } else { '-Parameter needs a source with parameters on pivotkit-server 0.2.0 or later.' }) } + elseif ($status -eq 400 -and $code -eq 'INVALID_INPUT' -and $p.Detail -match 'takes params') { + $message += [Environment]::NewLine + 'No source on this server takes parameters: leave -Parameter out, or use a source that declares them (Get-UDPivotSource lists them).' + } elseif ($status -eq 400 -and $code -eq 'INVALID_INPUT' -and $p.Detail -match 'no key "(locale|numbers|flatHeader)"') { $message += [Environment]::NewLine + '-Locale, -Numbers and -FlatHeader need pivotkit-server 0.3.0 or later.' } diff --git a/tests/powershell/PivotReport.Tests.ps1 b/tests/powershell/PivotReport.Tests.ps1 index fd12869..fa2c418 100644 --- a/tests/powershell/PivotReport.Tests.ps1 +++ b/tests/powershell/PivotReport.Tests.ps1 @@ -601,10 +601,9 @@ Describe 'Invoke-UDPivotReport -Engine Rest (a stand-in pivotkit-server)' { $sent.format | Should -Be 'xlsx' } - It 'a server too old for a parameter: the error names the server version it needs (#129, #132, #135)' { + It 'a server too old for a parameter: the error names the server version it needs; one without sources that take params says so (#129, #132, #135)' { # pivotkit-server 0.1.1 knows neither data in the request nor params; 0.2.0 answers params the same - # way when none of its sources declares parameters, later versions in words (NO_PARAMS_TEXT of - # pivotkit-server's sources/input.js); before 0.3.0 it knows no locale, numbers or flatHeader + # way when none of its sources declares parameters; before 0.3.0 it knows no locale, numbers or flatHeader $errorOf = { param([int]$Status, [string]$Code, [string]$Detail, [hashtable]$Call) $mock.Render.Enqueue(@{ Status = $Status; Body = (@{ type = 'x'; title = 'x'; status = $Status; code = $Code; detail = $Detail } | ConvertTo-Json -Compress) }) @@ -616,8 +615,10 @@ Describe 'Invoke-UDPivotReport -Engine Rest (a stand-in pivotkit-server)' { $caught.FullyQualifiedErrorId | Should -BeLike 'PivotServerError*' $caught.Exception.Message | Should -BeLike '*INVALID_INPUT (400): input has no key "data"*-Data needs pivotkit-server 0.2.0 or later*-Source*' (& $errorOf 400 'INVALID_INPUT' 'input has no key "params"' $params).Exception.Message | Should -BeLike '*INVALID_INPUT (400): input has no key "params"*-Parameter needs a source with parameters on pivotkit-server 0.2.0 or later*' - (& $errorOf 400 'INVALID_INPUT' 'this server has no source that takes params; leave params out (GET /sources lists the sources)' $params).Exception.Message | - Should -BeLike '*INVALID_INPUT (400): this server has no source that takes params*-Parameter needs a source with parameters on pivotkit-server 0.2.0 or later*' + # a current server that says it in words is new enough: the hint is about its sources, not its version + $message = (& $errorOf 400 'INVALID_INPUT' 'this server has no source that takes params; leave params out (GET /sources lists the sources)' $params).Exception.Message + $message | Should -BeLike '*INVALID_INPUT (400): this server has no source that takes params*No source on this server takes parameters: leave -Parameter out*Get-UDPivotSource*' + $message | Should -Not -BeLike '*pivotkit-server 0.*' (& $errorOf 400 'INVALID_INPUT' 'input has no key "numbers"' ($data + @{ Format = 'csv'; Numbers = 'Shown' })).Exception.Message | Should -BeLike '*input has no key "numbers"*-Locale, -Numbers and -FlatHeader need pivotkit-server 0.3.0 or later*' # another invalid input, and data refused by the server's policy, get no version hint From bc735e66d0aa506ee1eddeae9935594fe71648cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:22:11 +0100 Subject: [PATCH 08/11] docs(pivot): theme properties on their own page, with the zone rows' pivotkit minimum - The property table moves from the themes page (200 lines, its limit) to docs/pivot/theme-properties.md, listed under Pivot > Reference. Its intro says that the rows from --psu-pivot-zone-rows to --psu-pivot-field-hover take effect with pivotkit 0.11.0 or later; the chart reference already works with 0.10. - The themes page and the CHANGELOG show how to get the coloured type icons back: set the four --psu-pivot-type-* properties per mode. - The --psu-pivot-radius-sm row says that 4px is PSU's own corner and what it covers: buttons, chips, the field list and its hover, a field's name in the table, and pivotkit's smaller corners derived from it. - The CHANGELOG's #135 entry says "with the same -Locale and server settings". - The docs test and the browser spec read the rows from the new page. Co-Authored-By: Claude Opus 5.5 --- docs/pivot/theme-properties.md | 79 +++++++++++++++++++ docs/pivot/themes.md | 79 +++---------------- .../CHANGELOG.md | 12 ++- tests/browser/psu-pivot.spec.mjs | 2 +- tests/js/pivot.test.js | 7 +- zensical.toml | 1 + 6 files changed, 102 insertions(+), 78 deletions(-) create mode 100644 docs/pivot/theme-properties.md diff --git a/docs/pivot/theme-properties.md b/docs/pivot/theme-properties.md new file mode 100644 index 0000000..c1c8078 --- /dev/null +++ b/docs/pivot/theme-properties.md @@ -0,0 +1,79 @@ +--- +title: Pivot theme properties +description: "Every CSS custom property New-UDPivotReport reads from the app's stylesheet: what it falls back to when unset, what it sets in the report, and its default in light and dark mode." +--- + +# Theme properties + +The properties an app's stylesheet sets for the report, per light and dark mode, as +[Themes and corporate design](themes.md) shows. A property without a value falls back to the next one +in its row; without any, the report keeps the default of its mode. The rows from +`--psu-pivot-zone-rows` to `--psu-pivot-field-hover` take effect with pivotkit 0.11.0 or later in the +module; with an older pivotkit they set nothing. + +| Property | Falls back to | What it sets in the report | Light | Dark | +| --- | --- | --- | --- | --- | +| `--psu-chart-1` ... `--psu-chart-8` | - | series colours of the report's chart, by position; positions without a property keep theirs | pivotkit's palette | pivotkit's palette | +| `--psu-pivot-text` | `--psu-chart-text` | text | `rgba(0, 0, 0, 0.87)` | `rgba(255, 255, 255, 0.87)` | +| `--psu-pivot-muted` | `--psu-chart-muted` | secondary text, chart labels | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | +| `--psu-pivot-border` | `--psu-chart-axis` | borders of buttons, chips, panels and menus; the chart's axis line, unless an app sets one of the next row | `#e0e0e0` | `#2e2e2e` | +| `--psu-pivot-chart-axis` | `--psu-chart-axis` | the chart's axis line, apart from the table's lines | as `--psu-pivot-border` | as `--psu-pivot-border` | +| `--psu-pivot-grid` | `--psu-chart-grid` | lines between table cells, chart grid lines | `#eeeeee` | `#232323` | +| `--psu-pivot-accent` | `--psu-chart-accent` | primary buttons, badges, links, opened menus | `#1976d2` | `#90caf9` | +| `--psu-pivot-accent-text` | - | text on the accent | `#ffffff` | `#0b1a2a` | +| `--psu-pivot-focus` | `--psu-pivot-accent`, `--psu-chart-accent` | keyboard focus ring | `#1976d2` | `#90caf9` | +| `--psu-pivot-accent-soft` | 12 % (dark 18 %) of the corporate accent over the surface | badges, opened buttons, focused inputs | `#e3effb` | `#1b2a38` | +| `--psu-pivot-drop` | 18 % (dark 32 %) of the corporate accent over the surface | a zone while a field is dragged over it | `#d6e7f9` | `#1e3a55` | +| `--psu-pivot-note` | 7 % (dark 10 %) of the corporate accent over the surface | notes and hints | `#eef5fc` | `#16212c` | +| `--psu-pivot-surface` | - | background of the report and of the zones | `#ffffff` | `#121212` | +| `--psu-pivot-surface-2` | - | the zones' section, table headers, the field list's panel | `#f5f6f8` | `#1a1a1a` | +| `--psu-pivot-surface-3` | - | hovered controls, the Table/Chart switch | `#eaecef` | `#262626` | +| `--psu-pivot-surface-raised` | - | menus, popovers, the drill-down table, chart tooltips | `#ffffff` | `#1f1f1f` | +| `--psu-pivot-border-strong` | - | frame of a zone, hovered buttons and chips, the switch track, the grand-total line, scroll bars | `#c4c4c4` | `#474747` | +| `--psu-pivot-drop-border` | - | edge of a zone while a field is dragged | `#8a8a8a` | `#7a7a7a` | +| `--psu-pivot-input-border` | - | edge of a text field or a select in a menu | `#808080` | `#858585` | +| `--psu-pivot-rule` | - | line between a menu's groups | `#808080` | `#858585` | +| `--psu-pivot-total` | - | subtotals | `#f5f6f8` | `#1a1a1a` | +| `--psu-pivot-total-strong` | - | the grand total | `#eaecef` | `#242424` | +| `--psu-pivot-heat-low` | - | heatmap chart, lowest value | `#eaf1fb` | `#1d2735` | +| `--psu-pivot-heat-high` | - | heatmap chart, highest value | `#2a78d6` | `#3987e5` | +| `--psu-pivot-chart-other` | - | the grey slice "Other (n)" a pie or donut without a legend puts its smallest slices into; without a value, in the light theme the muted text, in the dark a fixed grey | `rgba(0, 0, 0, 0.62)` | `#6b7280` | +| `--psu-pivot-scale-low` | `--psu-pivot-heat-low` | colour scale of a value without colours of its own, lowest | `#eaf1fb` | `#1d2735` | +| `--psu-pivot-scale-mid` | - | colour scale of a value, middle: set, the scale has three colours | none | none | +| `--psu-pivot-scale-high` | `--psu-pivot-heat-high` | colour scale of a value without colours of its own, highest | `#2a78d6` | `#3987e5` | +| `--psu-pivot-type-string`, `--psu-pivot-type-number`, `--psu-pivot-type-date`, `--psu-pivot-type-boolean` | `--psu-pivot-muted`, `--psu-chart-muted` | the icon of a text, number, date or yes/no field and its pill in the empty report | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | +| `--psu-pivot-zone-rows` | - | the Rows zone: its icons, its marks in the field list, its fields' names in the table's header | `#1d5fcc` | `#8db4ff` | +| `--psu-pivot-zone-columns` | - | the Columns zone, the same parts | `#a85a00` | `#f2b559` | +| `--psu-pivot-zone-values` | - | the Values zone, the same parts, also on the grand total | `#0b785c` | `#5fd6ac` | +| `--psu-pivot-zone-filters` | `--psu-pivot-muted`, `--psu-chart-muted` | the Filters zone, the same parts | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | +| `--psu-pivot-zone-tint` | - | how much of its zone's colour a chip's fill takes | `16%` | `16%` | +| `--psu-pivot-zone-tint-base` | `--psu-pivot-surface` | what a chip's fill mixes the zone's colour into | `#ffffff` | `#121212` | +| `--psu-pivot-control-icon` | `--psu-pivot-muted`, `--psu-chart-muted` | a chip's grip, menu arrow and remove button | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | +| `--psu-pivot-sort-arrow` | `--psu-pivot-text`, `--psu-chart-text` | the sort arrow of the sorted field | `rgba(0, 0, 0, 0.87)` | `rgba(255, 255, 255, 0.87)` | +| `--psu-pivot-field-hover` | `--psu-pivot-surface` | a field in the field list on hover | `#ffffff` | `#121212` | +| `--psu-pivot-chart-reference` | `--psu-pivot-muted`, `--psu-chart-muted` | the chart's reference lines that belong to no series | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | +| `--psu-pivot-tab-bg` | - | a tab not shown (Table, Chart): its background | `transparent` | `transparent` | +| `--psu-pivot-tab-text` | `--psu-pivot-muted`, `--psu-chart-muted` | a tab not shown: its text | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | +| `--psu-pivot-tab-selected-bg` | `--psu-pivot-surface` | the tab shown: its background | `#ffffff` | `#121212` | +| `--psu-pivot-tab-selected-text` | `--psu-pivot-accent`, `--psu-chart-accent` | the tab shown: its text | `#1976d2` | `#90caf9` | +| `--psu-pivot-icon-button-text` | `--psu-pivot-muted`, `--psu-chart-muted` | a button with only an icon (a field's menu, Close, folding the field list): the icon | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | +| `--psu-pivot-icon-button-hover-bg` | `--psu-pivot-surface-3` | such a button on hover and while its menu is open | `#eaecef` | `#262626` | +| `--psu-pivot-button-border` | `--psu-pivot-border`, `--psu-chart-axis` | the frame of a button (the toolbar's, Table settings, Enlarge, Full screen) | `#e0e0e0` | `#2e2e2e` | +| `--psu-pivot-button-border-hover` | `--psu-pivot-border-strong` | the frame of a button on hover | `#c4c4c4` | `#474747` | +| `--psu-pivot-primary-bg` | `--psu-pivot-accent`, `--psu-chart-accent` | the main action of a dialog (Apply, Save, Load): its fill and frame | `#1976d2` | `#90caf9` | +| `--psu-pivot-primary-text` | `--psu-pivot-accent-text` | the main action's text | `#ffffff` | `#0b1a2a` | +| `--psu-pivot-primary-hover-bg` | - | the main action's fill on hover | 88 % of its fill, mixed with the text colour | 88 % of its fill, mixed with the text colour | +| `--psu-pivot-radius` | - | corner radius of the report, panels, zones and popovers | `8px` | `8px` | +| `--psu-pivot-radius-sm` | - | corner radius of buttons, chips, notes, the fields in the field list and their hover, and a field's name in the table's header; pivotkit's smaller corners (links, a chip's grip, badges, a field's type icon) follow it. `4px` is PSU's own corner; pivotkit's is `7px` | `4px` | `4px` | +| `--psu-pivot-font` | - | font family | the page's font | the page's font | +| `--psu-pivot-font-size` | - | base text size | `max(14px, 1em)` | `max(14px, 1em)` | +| `--psu-pivot-weight-normal` | - | plain text inside a bolder part (hints, table cells) | `400` | `400` | +| `--psu-pivot-weight-medium` | - | light emphasis (row labels, segmented buttons) | `500` | `500` | +| `--psu-pivot-weight-strong` | - | titles, field chips, buttons, subtotals, the admin panel's titles | `600` | `600` | +| `--psu-pivot-weight-bold` | - | grand totals, step numbers | `700` | `700` | + +The report's chart has eight series colours. `--psu-chart-9` ... `--psu-chart-12`, `--psu-chart-tooltip`, +`--psu-chart-tooltip-border` and `--psu-chart-font-size` are ECharts only; the report's tooltips use +`--psu-pivot-surface-raised`. + +Next: [Themes and corporate design](themes.md), [Commands and parameters](reference.md). diff --git a/docs/pivot/themes.md b/docs/pivot/themes.md index 3f9a597..0ad8607 100644 --- a/docs/pivot/themes.md +++ b/docs/pivot/themes.md @@ -85,79 +85,18 @@ follow from the accent, and without one they keep PSU's values. Set `--psu-pivot the accent is light in the light mode or dark in the dark mode: the default text on the accent is white in light mode and near-black in dark. -
-Every property: what it falls back to when unset, and its default without a corporate stylesheet - -| Property | Falls back to | What it sets in the report | Light | Dark | -| --- | --- | --- | --- | --- | -| `--psu-chart-1` ... `--psu-chart-8` | - | series colours of the report's chart, by position; positions without a property keep theirs | pivotkit's palette | pivotkit's palette | -| `--psu-pivot-text` | `--psu-chart-text` | text | `rgba(0, 0, 0, 0.87)` | `rgba(255, 255, 255, 0.87)` | -| `--psu-pivot-muted` | `--psu-chart-muted` | secondary text, chart labels | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | -| `--psu-pivot-border` | `--psu-chart-axis` | borders of buttons, chips, panels and menus; the chart's axis line, unless an app sets one of the next row | `#e0e0e0` | `#2e2e2e` | -| `--psu-pivot-chart-axis` | `--psu-chart-axis` | the chart's axis line, apart from the table's lines | as `--psu-pivot-border` | as `--psu-pivot-border` | -| `--psu-pivot-grid` | `--psu-chart-grid` | lines between table cells, chart grid lines | `#eeeeee` | `#232323` | -| `--psu-pivot-accent` | `--psu-chart-accent` | primary buttons, badges, links, opened menus | `#1976d2` | `#90caf9` | -| `--psu-pivot-accent-text` | - | text on the accent | `#ffffff` | `#0b1a2a` | -| `--psu-pivot-focus` | `--psu-pivot-accent`, `--psu-chart-accent` | keyboard focus ring | `#1976d2` | `#90caf9` | -| `--psu-pivot-accent-soft` | 12 % (dark 18 %) of the corporate accent over the surface | badges, opened buttons, focused inputs | `#e3effb` | `#1b2a38` | -| `--psu-pivot-drop` | 18 % (dark 32 %) of the corporate accent over the surface | a zone while a field is dragged over it | `#d6e7f9` | `#1e3a55` | -| `--psu-pivot-note` | 7 % (dark 10 %) of the corporate accent over the surface | notes and hints | `#eef5fc` | `#16212c` | -| `--psu-pivot-surface` | - | background of the report and of the zones | `#ffffff` | `#121212` | -| `--psu-pivot-surface-2` | - | the zones' section, table headers, the field list's panel | `#f5f6f8` | `#1a1a1a` | -| `--psu-pivot-surface-3` | - | hovered controls, the Table/Chart switch | `#eaecef` | `#262626` | -| `--psu-pivot-surface-raised` | - | menus, popovers, the drill-down table, chart tooltips | `#ffffff` | `#1f1f1f` | -| `--psu-pivot-border-strong` | - | frame of a zone, hovered buttons and chips, the switch track, the grand-total line, scroll bars | `#c4c4c4` | `#474747` | -| `--psu-pivot-drop-border` | - | edge of a zone while a field is dragged | `#8a8a8a` | `#7a7a7a` | -| `--psu-pivot-input-border` | - | edge of a text field or a select in a menu | `#808080` | `#858585` | -| `--psu-pivot-rule` | - | line between a menu's groups | `#808080` | `#858585` | -| `--psu-pivot-total` | - | subtotals | `#f5f6f8` | `#1a1a1a` | -| `--psu-pivot-total-strong` | - | the grand total | `#eaecef` | `#242424` | -| `--psu-pivot-heat-low` | - | heatmap chart, lowest value | `#eaf1fb` | `#1d2735` | -| `--psu-pivot-heat-high` | - | heatmap chart, highest value | `#2a78d6` | `#3987e5` | -| `--psu-pivot-chart-other` | - | the grey slice "Other (n)" a pie or donut without a legend puts its smallest slices into; without a value, in the light theme the muted text, in the dark a fixed grey | `rgba(0, 0, 0, 0.62)` | `#6b7280` | -| `--psu-pivot-scale-low` | `--psu-pivot-heat-low` | colour scale of a value without colours of its own, lowest | `#eaf1fb` | `#1d2735` | -| `--psu-pivot-scale-mid` | - | colour scale of a value, middle: set, the scale has three colours | none | none | -| `--psu-pivot-scale-high` | `--psu-pivot-heat-high` | colour scale of a value without colours of its own, highest | `#2a78d6` | `#3987e5` | -| `--psu-pivot-type-string`, `--psu-pivot-type-number`, `--psu-pivot-type-date`, `--psu-pivot-type-boolean` | `--psu-pivot-muted`, `--psu-chart-muted` | the icon of a text, number, date or yes/no field and its pill in the empty report | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | -| `--psu-pivot-zone-rows` | - | the Rows zone: its icons, its marks in the field list, its fields' names in the table's header | `#1d5fcc` | `#8db4ff` | -| `--psu-pivot-zone-columns` | - | the Columns zone, the same parts | `#a85a00` | `#f2b559` | -| `--psu-pivot-zone-values` | - | the Values zone, the same parts, also on the grand total | `#0b785c` | `#5fd6ac` | -| `--psu-pivot-zone-filters` | `--psu-pivot-muted`, `--psu-chart-muted` | the Filters zone, the same parts | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | -| `--psu-pivot-zone-tint` | - | how much of its zone's colour a chip's fill takes | `16%` | `16%` | -| `--psu-pivot-zone-tint-base` | `--psu-pivot-surface` | what a chip's fill mixes the zone's colour into | `#ffffff` | `#121212` | -| `--psu-pivot-control-icon` | `--psu-pivot-muted`, `--psu-chart-muted` | a chip's grip, menu arrow and remove button | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | -| `--psu-pivot-sort-arrow` | `--psu-pivot-text`, `--psu-chart-text` | the sort arrow of the sorted field | `rgba(0, 0, 0, 0.87)` | `rgba(255, 255, 255, 0.87)` | -| `--psu-pivot-field-hover` | `--psu-pivot-surface` | a field in the field list on hover | `#ffffff` | `#121212` | -| `--psu-pivot-chart-reference` | `--psu-pivot-muted`, `--psu-chart-muted` | the chart's reference lines that belong to no series | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | -| `--psu-pivot-tab-bg` | - | a tab not shown (Table, Chart): its background | `transparent` | `transparent` | -| `--psu-pivot-tab-text` | `--psu-pivot-muted`, `--psu-chart-muted` | a tab not shown: its text | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | -| `--psu-pivot-tab-selected-bg` | `--psu-pivot-surface` | the tab shown: its background | `#ffffff` | `#121212` | -| `--psu-pivot-tab-selected-text` | `--psu-pivot-accent`, `--psu-chart-accent` | the tab shown: its text | `#1976d2` | `#90caf9` | -| `--psu-pivot-icon-button-text` | `--psu-pivot-muted`, `--psu-chart-muted` | a button with only an icon (a field's menu, Close, folding the field list): the icon | `rgba(0, 0, 0, 0.62)` | `rgba(255, 255, 255, 0.64)` | -| `--psu-pivot-icon-button-hover-bg` | `--psu-pivot-surface-3` | such a button on hover and while its menu is open | `#eaecef` | `#262626` | -| `--psu-pivot-button-border` | `--psu-pivot-border`, `--psu-chart-axis` | the frame of a button (the toolbar's, Table settings, Enlarge, Full screen) | `#e0e0e0` | `#2e2e2e` | -| `--psu-pivot-button-border-hover` | `--psu-pivot-border-strong` | the frame of a button on hover | `#c4c4c4` | `#474747` | -| `--psu-pivot-primary-bg` | `--psu-pivot-accent`, `--psu-chart-accent` | the main action of a dialog (Apply, Save, Load): its fill and frame | `#1976d2` | `#90caf9` | -| `--psu-pivot-primary-text` | `--psu-pivot-accent-text` | the main action's text | `#ffffff` | `#0b1a2a` | -| `--psu-pivot-primary-hover-bg` | - | the main action's fill on hover | 88 % of its fill, mixed with the text colour | 88 % of its fill, mixed with the text colour | -| `--psu-pivot-radius` | - | corner radius of the report, panels, zones and popovers | `8px` | `8px` | -| `--psu-pivot-radius-sm` | - | corner radius of buttons, fields and notes | `4px` | `4px` | -| `--psu-pivot-font` | - | font family | the page's font | the page's font | -| `--psu-pivot-font-size` | - | base text size | `max(14px, 1em)` | `max(14px, 1em)` | -| `--psu-pivot-weight-normal` | - | plain text inside a bolder part (hints, table cells) | `400` | `400` | -| `--psu-pivot-weight-medium` | - | light emphasis (row labels, segmented buttons) | `500` | `500` | -| `--psu-pivot-weight-strong` | - | titles, field chips, buttons, subtotals, the admin panel's titles | `600` | `600` | -| `--psu-pivot-weight-bold` | - | grand totals, step numbers | `700` | `700` | - -
- -The report's chart has eight series colours. `--psu-chart-9` ... `--psu-chart-12`, `--psu-chart-tooltip`, -`--psu-chart-tooltip-border` and `--psu-chart-font-size` are ECharts only; the report's tooltips use -`--psu-pivot-surface-raised`. +Every property, what it falls back to when unset and its default without a corporate stylesheet: +[Theme properties](theme-properties.md). Colour marks the zones, not the field types: the type icons are the muted text. The zone colours are pivotkit's own; a corporate one needs 4.5:1 on `--psu-pivot-surface-2` (the values colour also on -`--psu-pivot-total-strong`) and 3:1 on its chips' fill. +`--psu-pivot-total-strong`) and 3:1 on its chips' fill. For coloured type icons, as the report had +before, set the four type properties per mode: + +```css +:root, .ud-pivot-report [data-pk-theme="light"] { --psu-pivot-type-string: #6250d6; --psu-pivot-type-number: #1a7f5a; --psu-pivot-type-date: #b5560b; --psu-pivot-type-boolean: #a3367a; } +:root[data-theme="dark"], .ud-pivot-report [data-pk-theme="dark"] { --psu-pivot-type-string: #a99dff; --psu-pivot-type-number: #5fd3a3; --psu-pivot-type-date: #f2a65a; --psu-pivot-type-boolean: #f08cc6; } +``` A colour scale a reader adds without picking colours runs from light to strong blue, the heatmap's colours: it says "more", not "good" or "bad", and the Excel export writes the same colours. For diff --git a/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md b/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md index d571d64..9a60bed 100644 --- a/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md +++ b/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md @@ -8,14 +8,15 @@ All notable changes to PowerShellUniversal.Component.Pivot. Format: ### Added - `Invoke-UDPivotReport -Engine Rest` takes `-Locale`, `-Numbers` and `-FlatHeader` and passes them - to pivotkit-server's render routes as `locale`, `numbers` and `flatHeader`, so both engines write - the same CSV and JSON. They need pivotkit-server 0.3.0 or later; an older server's answer names + to pivotkit-server's render routes as `locale`, `numbers` and `flatHeader`, so with the same + `-Locale` and server settings both engines write the same CSV and JSON. They need pivotkit-server 0.3.0 or later; an older server's answer names that version. `-TimeZone` stays with `-Engine Node` ([#135](https://github.com/eizedev/powershell-universal-components/issues/135)). - Theme properties for pivotkit's zone colours and chip controls: `--psu-pivot-zone-rows`, `-zone-columns`, `-zone-values`, `-zone-filters`, `-zone-tint`, `-zone-tint-base`, `--psu-pivot-control-icon`, `--psu-pivot-sort-arrow`, `--psu-pivot-field-hover` and - `--psu-pivot-chart-reference`, per light and dark mode, listed on the themes page. Without them + `--psu-pivot-chart-reference`, per light and dark mode, listed on the new Theme properties page + with every other property. Without them the report keeps pivotkit's values. The zone colours, the chip controls, the sort arrow and the field hover take effect with pivotkit 0.11.0; the reference lines already with 0.10.0. - The pivot overview's section "Coming from UniversalDashboard.Pivot" maps every parameter of @@ -35,7 +36,10 @@ All notable changes to PowerShellUniversal.Component.Pivot. Format: - The field type icons are the muted text without an app's `--psu-pivot-type-*`, as pivotkit's own neutral default: colour marks the zones, not the field types. With pivotkit 0.10.0 this also - makes the empty report's field pills and the border of a value chip grey. + makes the empty report's field pills and the border of a value chip grey. For the earlier + colours, set the four type properties per mode, for example + `:root { --psu-pivot-type-string: #6250d6; --psu-pivot-type-number: #1a7f5a; --psu-pivot-type-date: #b5560b; --psu-pivot-type-boolean: #a3367a; }`; + the themes page has the light and dark values. - The component passes the React hooks lint rules, which are now errors in CI: the latest props for its event handlers are kept in a ref written in an effect, not during render ([#217](https://github.com/eizedev/powershell-universal-components/issues/217)). The reader's view, a loaded file, diff --git a/tests/browser/psu-pivot.spec.mjs b/tests/browser/psu-pivot.spec.mjs index 0fa06c9..bb061cf 100644 --- a/tests/browser/psu-pivot.spec.mjs +++ b/tests/browser/psu-pivot.spec.mjs @@ -836,7 +836,7 @@ test.describe("pivot showcase on PSU", () => { await open(page, "tickets"); const report = page.locator(REPORT); const token = (name) => report.evaluate((e, n) => getComputedStyle(e).getPropertyValue(n).trim(), name); - // without the app's values: pivotkit's zone colours, as docs/pivot/themes.md lists them + // without the app's values: pivotkit's zone colours, as docs/pivot/theme-properties.md lists them const defaults = { light: ["#1d5fcc", "#a85a00", "#0b785c", "16%"], dark: ["#8db4ff", "#f2b559", "#5fd6ac", "16%"] }; const names = ["--pk-zone-rows", "--pk-zone-columns", "--pk-zone-values", "--pk-zone-tint"]; for (const mode of ["light", "dark"]) { diff --git a/tests/js/pivot.test.js b/tests/js/pivot.test.js index 70271b2..695e98b 100644 --- a/tests/js/pivot.test.js +++ b/tests/js/pivot.test.js @@ -419,6 +419,7 @@ test("stored view: blocked, full or broken storage is ignored", () => { const css = readFileSync(new URL("../../modules/PowerShellUniversal.Component.Pivot/Components/psu.css", import.meta.url), "utf8"); const themesDoc = readFileSync(new URL("../../docs/pivot/themes.md", import.meta.url), "utf8"); +const themePropertiesDoc = readFileSync(new URL("../../docs/pivot/theme-properties.md", import.meta.url), "utf8"); const WRAPPER = ".ud-pivot-report"; const LIGHT = ".ud-pivot-report .pk-root"; const DARK = '.ud-pivot-report .pk-root[data-pk-theme="dark"]'; @@ -484,9 +485,9 @@ const tokensOf = (mode, page = {}) => { // the properties an app may set: every --psu-pivot-* and --psu-chart-* the bridge reads const publicNames = () => [...new Set([...css.replace(/\/\*[\s\S]*?\*\//g, "").matchAll(/var\((--psu-(?:pivot|chart)-[a-z0-9-]+)/g)].map((m) => m[1]))].sort(); -// the table in docs/pivot/themes.md: property, falls back to, what it sets, light, dark +// the table in docs/pivot/theme-properties.md: property, falls back to, what it sets, light, dark function docRows() { - return themesDoc.split("\n").filter((l) => l.startsWith("| `--psu-")).map((line) => { + return themePropertiesDoc.split("\n").filter((l) => l.startsWith("| `--psu-")).map((line) => { const cells = line.split("|").slice(1, -1).map((c) => c.trim()); let names = [...cells[0].matchAll(/`(--psu-[a-z0-9-]+)`/g)].map((m) => m[1]); const range = /^`--psu-([a-z]+)-(\d+)` \.\.\. `--psu-\1-(\d+)`$/.exec(cells[0]); @@ -715,7 +716,7 @@ test("theme bridge: dark values go on pivotkit's data-pk-theme, never on the pag } }); -test("theme bridge: docs/pivot/themes.md lists every property the bridge reads, with its fallbacks and defaults", () => { +test("theme bridge: docs/pivot/theme-properties.md lists every property the bridge reads, with its fallbacks and defaults", () => { const rows = docRows(); assert.deepEqual([...new Set(rows.flatMap((r) => [...r.names, ...r.fallbacks]))].sort(), publicNames()); for (const row of rows) { diff --git a/zensical.toml b/zensical.toml index eabbbf4..780da66 100644 --- a/zensical.toml +++ b/zensical.toml @@ -90,6 +90,7 @@ nav = [ ] }, { "Reference" = [ { "Commands and parameters" = "pivot/reference.md" }, + { "Theme properties" = "pivot/theme-properties.md" }, { "Errors" = "pivot/errors.md" }, ] }, ] }, From 433b021b4077104bb256000349899e8c1e919918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:24:04 +0100 Subject: [PATCH 09/11] docs(pivot): coming from UniversalDashboard.Pivot on its own page - The section moves from the pivot overview to docs/pivot/coming-from-ud-pivot.md, listed under Pivot > Start. The overview's "You want | Where" row and the module README link the page. - The page states the requirements: PowerShell 7.4 or later (the old module also ran on Windows PowerShell 5.1) and PSU 2026.2 or 2026.3, as Compatibility lists them. - The aggregators and renderers get one row per group instead of one long cell each; -Data says "also a DataTable", and the stacked charts read chart = @{ type = 'bar'; stacked = $true }. - reports.md and the CHANGELOG say that both engines write the same file with the same -Locale and server settings. - New-UDPivotRenderBody's help description is wrapped. Refs #121 Co-Authored-By: Claude Opus 5.5 --- docs/pivot/coming-from-ud-pivot.md | 89 +++++++++++++++++++ docs/pivot/index.md | 46 +--------- docs/pivot/reports.md | 6 +- .../CHANGELOG.md | 11 +-- .../Private/New-UDPivotRenderBody.ps1 | 5 +- .../README.md | 2 +- zensical.toml | 1 + 7 files changed, 104 insertions(+), 56 deletions(-) create mode 100644 docs/pivot/coming-from-ud-pivot.md diff --git a/docs/pivot/coming-from-ud-pivot.md b/docs/pivot/coming-from-ud-pivot.md new file mode 100644 index 0000000..e2b68fc --- /dev/null +++ b/docs/pivot/coming-from-ud-pivot.md @@ -0,0 +1,89 @@ +--- +title: Coming from UniversalDashboard.Pivot +description: "Move an app from New-UDPivot of UniversalDashboard.Pivot to New-UDPivotReport: what each parameter becomes, and one report before and after." +--- + +# Coming from UniversalDashboard.Pivot + +`New-UDPivotReport` replaces `New-UDPivot` of [UniversalDashboard.Pivot](https://github.com/eizedev/UniversalDashboard.Pivot), +which wraps react-pivottable. + +## Requirements + +- PowerShell 7.4 or later, in the PSU environment the app runs in. UniversalDashboard.Pivot also ran + on Windows PowerShell 5.1; this module does not load there. +- PowerShell Universal 2026.2 or 2026.3, tested with 2026.2.5 and 2026.3.4. + +[Compatibility](../compatibility.md) has the details and how each version is tested. + +## One report before and after + +The start view moves from parameters into one `-View` ([Views](views.md#the-start-view-view)). The +same rows, before and after: + +```powershell +$data = @( + @{ Team = 'OPS'; Status = 'Open'; Priority = 'High'; Hours = 5 } + @{ Team = 'OPS'; Status = 'Closed'; Priority = 'Low'; Hours = 2 } + @{ Team = 'OPS'; Status = 'Closed'; Priority = 'High'; Hours = 4 } + @{ Team = 'DEV'; Status = 'Open'; Priority = 'High'; Hours = 8 } + @{ Team = 'DEV'; Status = 'Closed'; Priority = 'Medium'; Hours = 3 } + @{ Team = 'DEV'; Status = 'Open'; Priority = 'Low'; Hours = 6 } + @{ Team = 'QA'; Status = 'Open'; Priority = 'Medium'; Hours = 1 } + @{ Team = 'QA'; Status = 'Closed'; Priority = 'High'; Hours = 7 } +) +# before +New-UDPivot -Id 'tickets-before' -Data $data -Rows 'Team' -Cols 'Status' -Vals 'Hours' -AggregatorName 'Sum' -RowOrder 'value_z_to_a' -ValueFilter @{ Priority = @{ Low = $true } } +# after +New-UDPivotReport -Id 'tickets-after' -Data $data -View @{ + rows = @('Team') + cols = @('Status') + values = @(@{ field = 'Hours'; agg = 'sum' }) + filters = @(@{ field = 'Priority'; type = 'in'; items = @('Low'); not = $true; blanks = 'include' }) + sort = @(@{ field = 'Team'; by = 'value'; order = 'desc' }) +} +``` + +Both show the sum of hours without the Low tickets, the teams by their total, highest first: DEV 11, +OPS 9, QA 8. + +## Parameters + +| `New-UDPivot` | `New-UDPivotReport` | +| --- | --- | +| `-Id`, `-Data` | `-Id`, `-Data`: also a DataTable ([Data and loading](data.md)) | +| `-Rows`, `-Cols` | `rows`, `cols` in `-View` | +| `-RowOrder`, `-ColOrder` | `key_a_to_z`: the default. `value_a_to_z`, `value_z_to_a`: `sort = @(@{ field = 'Team'; by = 'value'; order = 'asc' })` or `'desc'`, per row or column field. | +| `-ValueFilter` | `filters`: the listed items with `type = 'in'; not = $true; blanks = 'include'` ([Filters](filters.md)). | +| `-HiddenAttributes` | No counterpart: leave the column out of the rows you pass to `-Data` (`Select-Object -ExcludeProperty` for objects), so it does not reach the browser either. | +| `-HiddenFromAggregators`, `-HiddenFromDragDrop`, `-MenuLimit`, `-UnusedOrientationCutoff` | No counterpart. | + +## Aggregators + +`-Vals` and `-AggregatorName` become `values` in `-View`, each with its field and `agg`. + +| `-AggregatorName` | `agg` in `values` | +| --- | --- | +| `Count` | `count` on a field: it counts the rows where the field has a value. | +| `Count Unique Values`, `List Unique Values` | `countUnique`, `listUnique` | +| `Sum`, `Integer Sum` | `sum`; for `Integer Sum` with `format = 'integer'` | +| `Average`, `Median`, `Minimum`, `Maximum`, `First`, `Last` | `average`, `median`, `min`, `max`, `first`, `last` | +| `Sample Variance`, `Sample Standard Deviation` | `var`, `stdev` | +| `Sum as Fraction of Total`, `of Rows`, `of Columns`; the same for `Count` | `sum` or `count` with `showAs = @{ type = 'percentOfGrandTotal' }`, `'percentOfRowTotal'`, `'percentOfColumnTotal'` | +| `Sum over Sum`, `80% Upper Bound`, `80% Lower Bound` | No counterpart. | + +## Renderers + +`-RendererName` becomes the value's `conditional` or the view's `display` and `chart`. + +| `-RendererName` | In `-View` | +| --- | --- | +| `Table` | The default. | +| `Table Heatmap` | `conditional = @{ type = 'colorScale' }` on the value | +| `Grouped Column Chart`, `Stacked Column Chart` | `display = 'chart'; chart = @{ type = 'bar' }`; for stacked columns `chart = @{ type = 'bar'; stacked = $true }` | +| `Grouped Bar Chart`, `Stacked Bar Chart` | the same as the column charts, with `horizontal = $true` in `chart` | +| `Line Chart`, `Area Chart` | `display = 'chart'; chart = @{ type = 'line' }`, or `type = 'area'` | +| `Exportable TSV` | The reader's export copies the table as tab-separated text. | +| `Table Row Heatmap`, `Table Col Heatmap`, `Dot Chart`, `Scatter Chart`, `Multiple Pie Chart` | No counterpart. `type = 'pie'` draws one pie of the row totals. | + +Next: [Views](views.md), [Data and loading](data.md), [Overview](index.md). diff --git a/docs/pivot/index.md b/docs/pivot/index.md index 3e9df60..74933a6 100644 --- a/docs/pivot/index.md +++ b/docs/pivot/index.md @@ -40,7 +40,7 @@ New-UDPivotReport -Id 'tickets' -Data (Invoke-Sqlcmd -Query 'SELECT * FROM Ticke | What readers get, and what the app decides for them | [Readers and your app](readers.md) | | What `-Data` takes, large data | [Data and loading](data.md) | | Every parameter | [Commands and parameters](reference.md) | -| Move an app from `New-UDPivot` | [Coming from UniversalDashboard.Pivot](#coming-from-universaldashboardpivot) | +| Move an app from `New-UDPivot` | [Coming from UniversalDashboard.Pivot](coming-from-ud-pivot.md) | Readers drag fields from a searchable list into **Rows**, **Columns**, **Values** and **Filters** and get a table with totals or a chart, with date grouping, drill-down to the source rows, shared views and @@ -100,48 +100,4 @@ New-UDDynamic -Id 'tickets-report' -LoadingComponent { --8<-- "examples/pivot-report-in-german.md" -## Coming from UniversalDashboard.Pivot { #coming-from-universaldashboardpivot } - -`New-UDPivotReport` replaces `New-UDPivot` of [UniversalDashboard.Pivot](https://github.com/eizedev/UniversalDashboard.Pivot), -which wraps react-pivottable. Check the PowerShell and PSU versions on [Compatibility](../compatibility.md). -The start view moves from parameters into one `-View` ([Views](views.md#the-start-view-view)). The -same rows, before and after: - -```powershell -$data = @( - @{ Team = 'OPS'; Status = 'Open'; Priority = 'High'; Hours = 5 } - @{ Team = 'OPS'; Status = 'Closed'; Priority = 'Low'; Hours = 2 } - @{ Team = 'OPS'; Status = 'Closed'; Priority = 'High'; Hours = 4 } - @{ Team = 'DEV'; Status = 'Open'; Priority = 'High'; Hours = 8 } - @{ Team = 'DEV'; Status = 'Closed'; Priority = 'Medium'; Hours = 3 } - @{ Team = 'DEV'; Status = 'Open'; Priority = 'Low'; Hours = 6 } - @{ Team = 'QA'; Status = 'Open'; Priority = 'Medium'; Hours = 1 } - @{ Team = 'QA'; Status = 'Closed'; Priority = 'High'; Hours = 7 } -) -# before -New-UDPivot -Id 'tickets-before' -Data $data -Rows 'Team' -Cols 'Status' -Vals 'Hours' -AggregatorName 'Sum' -RowOrder 'value_z_to_a' -ValueFilter @{ Priority = @{ Low = $true } } -# after -New-UDPivotReport -Id 'tickets-after' -Data $data -View @{ - rows = @('Team') - cols = @('Status') - values = @(@{ field = 'Hours'; agg = 'sum' }) - filters = @(@{ field = 'Priority'; type = 'in'; items = @('Low'); not = $true; blanks = 'include' }) - sort = @(@{ field = 'Team'; by = 'value'; order = 'desc' }) -} -``` - -Both show the sum of hours without the Low tickets, the teams by their total, highest first: DEV 11, -OPS 9, QA 8. - -| `New-UDPivot` | `New-UDPivotReport` | -| --- | --- | -| `-Id`, `-Data` | `-Id`, `-Data`: also a script block, and a DataTable ([Data and loading](data.md)) | -| `-Rows`, `-Cols` | `rows`, `cols` in `-View` | -| `-Vals`, `-AggregatorName` | `values`, each with its field and `agg`. `Count` is `count` on a field: it counts the rows where the field has a value. `Count Unique Values`, `List Unique Values`: `countUnique`, `listUnique`. `Sum`, `Integer Sum`: `sum` (with `format = 'integer'`). `Average`, `Median`, `Minimum`, `Maximum`, `First`, `Last`: `average`, `median`, `min`, `max`, `first`, `last`. `Sample Variance`, `Sample Standard Deviation`: `var`, `stdev`. `Sum` or `Count as Fraction of Total`, `of Rows`, `of Columns`: `sum` or `count` with `showAs = @{ type = 'percentOfGrandTotal' }`, `'percentOfRowTotal'`, `'percentOfColumnTotal'`. No counterpart: `Sum over Sum`, `80% Upper Bound`, `80% Lower Bound`. | -| `-RendererName` | `Table`: the default. `Table Heatmap`: `conditional = @{ type = 'colorScale' }` on the value. `Grouped Column Chart`, `Stacked Column Chart`: `display = 'chart'; chart = @{ type = 'bar' }`, with `stacked = $true`; `Grouped Bar Chart`, `Stacked Bar Chart` add `horizontal = $true`. `Line Chart`, `Area Chart`: `type = 'line'`, `'area'`. `Exportable TSV`: the reader's export copies the table as tab-separated text. No counterpart: `Table Row Heatmap`, `Table Col Heatmap`, `Dot Chart`, `Scatter Chart`, `Multiple Pie Chart` (`type = 'pie'` draws one pie of the row totals). | -| `-RowOrder`, `-ColOrder` | `key_a_to_z`: the default. `value_a_to_z`, `value_z_to_a`: `sort = @(@{ field = 'Team'; by = 'value'; order = 'asc' })` or `'desc'`, per row or column field. | -| `-ValueFilter` | `filters`: the listed items with `type = 'in'; not = $true; blanks = 'include'` ([Filters](filters.md)). | -| `-HiddenAttributes` | No counterpart: leave the column out of the rows you pass to `-Data` (`Select-Object -ExcludeProperty` for objects), so it does not reach the browser either. | -| `-HiddenFromAggregators`, `-HiddenFromDragDrop`, `-MenuLimit`, `-UnusedOrientationCutoff` | No counterpart. | - Next: [Readers and your app](readers.md), [Data and loading](data.md), [Field names and descriptions](fields.md), [Themes and corporate design](themes.md), [Views](views.md), [Templates, view files and roles](templates.md), [Events, security and limits](events.md), [Reference](reference.md). diff --git a/docs/pivot/reports.md b/docs/pivot/reports.md index befebb1..7c87e19 100644 --- a/docs/pivot/reports.md +++ b/docs/pivot/reports.md @@ -46,9 +46,9 @@ A CSV or JSON file holds every number with full precision. `-Numbers Shown` roun decimals the view shows; `-Numbers Full` is the default. `-FlatHeader` gives a CSV file one header row instead of one per column field; each column names its labels joined with " / ". `-Locale` sets the language and number format of a view that names none (a CSV in `de-DE` uses `;` and the decimal -comma). Both engines write the same file from them. `-Numbers` and `-FlatHeader` need pivotkit-cli -0.5.0 or later, and all three need pivotkit-server 0.3.0 or later; the function refuses `-Numbers` and -`-FlatHeader` for another format. +comma). With the same `-Locale` and server settings, both engines write the same file. `-Numbers` and +`-FlatHeader` need pivotkit-cli 0.5.0 or later, and all three need pivotkit-server 0.3.0 or later; +the function refuses `-Numbers` and `-FlatHeader` for another format. ```powershell Invoke-UDPivotReport -Engine Node -Data $tickets -View $view -OutFile ./tickets.csv -Numbers Shown -FlatHeader -Locale de-DE diff --git a/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md b/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md index 9a60bed..7c9f7a8 100644 --- a/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md +++ b/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md @@ -9,8 +9,8 @@ All notable changes to PowerShellUniversal.Component.Pivot. Format: - `Invoke-UDPivotReport -Engine Rest` takes `-Locale`, `-Numbers` and `-FlatHeader` and passes them to pivotkit-server's render routes as `locale`, `numbers` and `flatHeader`, so with the same - `-Locale` and server settings both engines write the same CSV and JSON. They need pivotkit-server 0.3.0 or later; an older server's answer names - that version. `-TimeZone` stays with `-Engine Node` + `-Locale` and server settings both engines write the same CSV and JSON. They need pivotkit-server + 0.3.0 or later; an older server's answer names that version. `-TimeZone` stays with `-Engine Node` ([#135](https://github.com/eizedev/powershell-universal-components/issues/135)). - Theme properties for pivotkit's zone colours and chip controls: `--psu-pivot-zone-rows`, `-zone-columns`, `-zone-values`, `-zone-filters`, `-zone-tint`, `-zone-tint-base`, @@ -19,9 +19,10 @@ All notable changes to PowerShellUniversal.Component.Pivot. Format: with every other property. Without them the report keeps pivotkit's values. The zone colours, the chip controls, the sort arrow and the field hover take effect with pivotkit 0.11.0; the reference lines already with 0.10.0. -- The pivot overview's section "Coming from UniversalDashboard.Pivot" maps every parameter of - `New-UDPivot` to `New-UDPivotReport`, names those without a counterpart, and shows one report - before and after; the module README links it +- The page "Coming from UniversalDashboard.Pivot" maps every parameter, aggregator and renderer of + `New-UDPivot` to `New-UDPivotReport`, names those without a counterpart, states the PowerShell and + PSU versions, and shows one report before and after; the pivot overview and the module README + link it ([#121](https://github.com/eizedev/powershell-universal-components/issues/121)). ### Fixed diff --git a/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotRenderBody.ps1 b/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotRenderBody.ps1 index 7e942a0..8995858 100644 --- a/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotRenderBody.ps1 +++ b/modules/PowerShellUniversal.Component.Pivot/Private/New-UDPivotRenderBody.ps1 @@ -4,8 +4,9 @@ function New-UDPivotRenderBody { The input of pivotkit-server's render_view as UTF-8 JSON, the rows written straight into it. .DESCRIPTION source, then data (columns, rows, rowCount, name, asOf) or params, then view or layout, format, - title, locale, numbers and flatHeader. The rows go through Write-UDPivotReportTable: no copy of them as objects or as one JSON - string, and past -MaxBytes it stops with PivotDataTooLarge before the rest is converted. + title, locale, numbers and flatHeader. The rows go through Write-UDPivotReportTable: no copy of + them as objects or as one JSON string, and past -MaxBytes it stops with PivotDataTooLarge before + the rest is converted. .PARAMETER Data The rows, or $null with -Source. .PARAMETER Source diff --git a/modules/PowerShellUniversal.Component.Pivot/README.md b/modules/PowerShellUniversal.Component.Pivot/README.md index c7fa4d2..d9f4e08 100644 --- a/modules/PowerShellUniversal.Component.Pivot/README.md +++ b/modules/PowerShellUniversal.Component.Pivot/README.md @@ -53,7 +53,7 @@ is a showcase app in one line (`New-UDPivotShowcase`). - [Reports without a browser](https://powershell-universal-components.eize.dev/pivot/reports/): `Invoke-UDPivotReport`; [from a pivotkit-server](https://powershell-universal-components.eize.dev/pivot/reports-server/) with `Get-UDPivotSource` - [Themes and corporate design](https://powershell-universal-components.eize.dev/pivot/themes/), shared with the ECharts module - [Reference](https://powershell-universal-components.eize.dev/pivot/reference/): every parameter -- [Coming from UniversalDashboard.Pivot](https://powershell-universal-components.eize.dev/pivot/#coming-from-universaldashboardpivot): `New-UDPivot`'s parameters in `New-UDPivotReport` +- [Coming from UniversalDashboard.Pivot](https://powershell-universal-components.eize.dev/pivot/coming-from-ud-pivot/): `New-UDPivot`'s parameters in `New-UDPivotReport` ## Security notes diff --git a/zensical.toml b/zensical.toml index 780da66..0b02e02 100644 --- a/zensical.toml +++ b/zensical.toml @@ -63,6 +63,7 @@ nav = [ { "Overview" = "pivot/index.md" }, { "Readers and your app" = "pivot/readers.md" }, { "Showcase app (demo)" = "pivot/demo.md" }, + { "Coming from UniversalDashboard.Pivot" = "pivot/coming-from-ud-pivot.md" }, ] }, { "Build a report" = [ { "Data and loading" = "pivot/data.md" }, From 529eb0d9eae7340e09b891bfd97fae38539e7363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:25:12 +0100 Subject: [PATCH 10/11] chore(pivot): docs total in the growth baseline counts only this change's pages The baseline had 5202 lines; this change adds 111 (measured page by page against the base commit): the new pages coming-from-ud-pivot.md (89) and theme-properties.md (79), the "Coming from" row and two report lines on the overview and reports.md (+3), and the README link (+1), less the 61 lines the property table took out of themes.md. 5202 + 111 = 5313. The 2 lines main already had over its baseline stay outside it; the measured total is 5315. Co-Authored-By: Claude Opus 5.5 --- build/growth-baseline.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/growth-baseline.json b/build/growth-baseline.json index 1daed17..0152bf9 100644 --- a/build/growth-baseline.json +++ b/build/growth-baseline.json @@ -3,7 +3,7 @@ "pages": { "README.md": [110] }, - "totalLines": 5252 + "totalLines": 5313 }, "javascript": { "complexity": { From c8b4f4e7abba5f5a956a0fb9bcf1bb099835ff1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:31:19 +0100 Subject: [PATCH 11/11] docs(pivot): mark the 0.11-only theme rows and point to both modes' type colours Co-Authored-By: Claude Opus 5.5 --- docs/pivot/theme-properties.md | 5 +++-- docs/pivot/themes.md | 4 ++-- modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md | 5 ++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/pivot/theme-properties.md b/docs/pivot/theme-properties.md index c1c8078..6719211 100644 --- a/docs/pivot/theme-properties.md +++ b/docs/pivot/theme-properties.md @@ -9,7 +9,8 @@ The properties an app's stylesheet sets for the report, per light and dark mode, [Themes and corporate design](themes.md) shows. A property without a value falls back to the next one in its row; without any, the report keeps the default of its mode. The rows from `--psu-pivot-zone-rows` to `--psu-pivot-field-hover` take effect with pivotkit 0.11.0 or later in the -module; with an older pivotkit they set nothing. +module; with an older pivotkit they set nothing. `--psu-pivot-chart-reference`, after them, needs no +minimum. | Property | Falls back to | What it sets in the report | Light | Dark | | --- | --- | --- | --- | --- | @@ -64,7 +65,7 @@ module; with an older pivotkit they set nothing. | `--psu-pivot-primary-text` | `--psu-pivot-accent-text` | the main action's text | `#ffffff` | `#0b1a2a` | | `--psu-pivot-primary-hover-bg` | - | the main action's fill on hover | 88 % of its fill, mixed with the text colour | 88 % of its fill, mixed with the text colour | | `--psu-pivot-radius` | - | corner radius of the report, panels, zones and popovers | `8px` | `8px` | -| `--psu-pivot-radius-sm` | - | corner radius of buttons, chips, notes, the fields in the field list and their hover, and a field's name in the table's header; pivotkit's smaller corners (links, a chip's grip, badges, a field's type icon) follow it. `4px` is PSU's own corner; pivotkit's is `7px` | `4px` | `4px` | +| `--psu-pivot-radius-sm` | - | corner radius of buttons, chips, notes, the fields in the field list and their hover, and a field's name in the table's header; pivotkit's smaller corners (links, a chip's grip, badges, a field's type icon) follow it. `4px` is PSU's own corner; pivotkit's is `7px`. Chips and the table's field names follow it with pivotkit 0.11.0 or later | `4px` | `4px` | | `--psu-pivot-font` | - | font family | the page's font | the page's font | | `--psu-pivot-font-size` | - | base text size | `max(14px, 1em)` | `max(14px, 1em)` | | `--psu-pivot-weight-normal` | - | plain text inside a bolder part (hints, table cells) | `400` | `400` | diff --git a/docs/pivot/themes.md b/docs/pivot/themes.md index 0ad8607..fca7399 100644 --- a/docs/pivot/themes.md +++ b/docs/pivot/themes.md @@ -88,8 +88,8 @@ in light mode and near-black in dark. Every property, what it falls back to when unset and its default without a corporate stylesheet: [Theme properties](theme-properties.md). -Colour marks the zones, not the field types: the type icons are the muted text. The zone colours are -pivotkit's own; a corporate one needs 4.5:1 on `--psu-pivot-surface-2` (the values colour also on +With pivotkit 0.11.0 or later in the module, colour marks the zones, not the field types: the type +icons are the muted text. The zone colours are pivotkit's own; a corporate one needs 4.5:1 on `--psu-pivot-surface-2` (the values colour also on `--psu-pivot-total-strong`) and 3:1 on its chips' fill. For coloured type icons, as the report had before, set the four type properties per mode: diff --git a/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md b/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md index 7c9f7a8..06f741b 100644 --- a/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md +++ b/modules/PowerShellUniversal.Component.Pivot/CHANGELOG.md @@ -38,9 +38,8 @@ All notable changes to PowerShellUniversal.Component.Pivot. Format: - The field type icons are the muted text without an app's `--psu-pivot-type-*`, as pivotkit's own neutral default: colour marks the zones, not the field types. With pivotkit 0.10.0 this also makes the empty report's field pills and the border of a value chip grey. For the earlier - colours, set the four type properties per mode, for example - `:root { --psu-pivot-type-string: #6250d6; --psu-pivot-type-number: #1a7f5a; --psu-pivot-type-date: #b5560b; --psu-pivot-type-boolean: #a3367a; }`; - the themes page has the light and dark values. + colours, set the four `--psu-pivot-type-*` properties per mode; the themes page has the light + and dark values. - The component passes the React hooks lint rules, which are now errors in CI: the latest props for its event handlers are kept in a ref written in an effect, not during render ([#217](https://github.com/eizedev/powershell-universal-components/issues/217)). The reader's view, a loaded file,