Skip to content

Add format options for number and date fields#57

Merged
priethor merged 7 commits into
mainfrom
priethor/add/field-formats
May 5, 2026
Merged

Add format options for number and date fields#57
priethor merged 7 commits into
mainfrom
priethor/add/field-formats

Conversation

@priethor

@priethor priethor commented May 5, 2026

Copy link
Copy Markdown
Collaborator

What

Closes #123

Adds formatting options for number and date fields.

Number fields can render as plain numbers, percentages, or currency, with a chosen decimal count. Date fields can choose the date layout and whether to show time.

The setting lives on the field, so the whole column updates together, survives reloads, and copies when the field is duplicated. Values render with Intl using the WordPress site locale.

Testing

  1. Add a Number field and try each format and decimal option.
  2. Add a Date & time field and try each date/time option.
  3. Reload and confirm the formatting sticks.
  4. Duplicate a formatted field and confirm the copy keeps the same settings.
  5. Run npm test and composer test.

Screenshot

image

priethor added 7 commits May 5, 2026 14:32
Threads parsed number_format and date_format through fieldMapping into
EditableCell, where formatNumberValue and formatDateValue produce the
display string via Intl. The site locale comes from
wp.date.getSettings() so a single site renders the same numbers and
dates for every viewer, the way dateI18n does on the public side.
The column header dropdown now has an Edit field item that opens a
Notion-style cascading panel: Number format / Decimal places for
numbers; Date format / Time for dates. Each row anchors its own
choice flyout, selections auto-save through core-data, and the panel
opens on hover with a grace timer so the cursor can travel from the
trigger to the panel without losing it. Menu groups are reorganized
to put property-config items at the top and column-lifecycle ones at
the bottom.
Existing number fields don't have number_format meta until someone
opens Edit field, but formatNumberValue was passing min/max fraction
digits of 0 to Intl whenever decimals weren't configured. That
silently rounded values like 1.25 to 1. Now we only set fraction
digits when the user explicitly picks one, and the Decimal places
menu has a Default option (the implicit state) so picking a number
format no longer auto-saves decimals: 0.
`date` fields have no time component: the value is stored as
YYYY-MM-DD, the inline editor strips time on commit, and the
renderer returns before consulting time options for date-only
values. Showing 12-hour / 24-hour controls for them saved a
setting that nothing could read.
A fresh datetime field with no saved date_format showed `Time: Off`
in the popover even though the cell rendered HH:MM, because
formatDateValue defaults `time` to true for datetime while
findTimeOption always returned Off when config.time was falsy. Pass
the field type into findTimeOption so it falls back to the same
default the renderer uses (12-hour for datetime, off for date).
@priethor priethor merged commit 6c7063f into main May 5, 2026
6 checks passed
@priethor priethor deleted the priethor/add/field-formats branch May 6, 2026 09:21
@priethor priethor added this to the 0.1.0 milestone May 28, 2026
@priethor priethor added type: enhancement Improvement to existing behavior. area: collections Fields, rows, views, DataViews, relations, rollups, formulas, and row properties. labels May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: collections Fields, rows, views, DataViews, relations, rollups, formulas, and row properties. type: enhancement Improvement to existing behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Format options for number and date fields

1 participant