diff --git a/bestax-mcp/data/catalog.json b/bestax-mcp/data/catalog.json index b24818cf9..34ed326bb 100644 --- a/bestax-mcp/data/catalog.json +++ b/bestax-mcp/data/catalog.json @@ -371,7 +371,7 @@ "import": "import { DateInput } from '@allxsmith/bestax-bulma';", "compound": false, "propCount": 52, - "exampleCount": 37 + "exampleCount": 38 }, { "name": "DateTimeInput", @@ -382,7 +382,7 @@ "import": "import { DateTimeInput } from '@allxsmith/bestax-bulma';", "compound": false, "propCount": 62, - "exampleCount": 39 + "exampleCount": 40 }, { "name": "Delete", @@ -1297,6 +1297,7 @@ "--bulma-dateinput-cell-today-color": "DateTimeInput", "--bulma-dateinput-day-name-color": "DateTimeInput", "--bulma-dateinput-day-name-size": "DateTimeInput", + "--bulma-dateinput-focus-ring-color": "DateTimeInput", "--bulma-dateinput-header-padding": "DateTimeInput", "--bulma-dateinput-min-width": "DateTimeInput", "--bulma-dateinput-nav-button-size": "DateTimeInput", diff --git a/bestax-mcp/data/components/DateInput.json b/bestax-mcp/data/components/DateInput.json index 82fd249c3..4e4a3fd80 100644 --- a/bestax-mcp/data/components/DateInput.json +++ b/bestax-mcp/data/components/DateInput.json @@ -129,6 +129,10 @@ "title": "Colors", "code": "\n \n \n \n \n \n" }, + { + "title": "Colors", + "code": "function example() {\n // The 1st of this month (the 2nd when today is the 1st), so the selected\n // date and today's date both show.\n const picked = new Date();\n picked.setDate(picked.getDate() === 1 ? 2 : 1);\n return (\n \n \n \n \n \n \n \n \n \n \n \n );\n}" + }, { "title": "States", "code": "\n \n \n \n" @@ -522,7 +526,7 @@ "name": "color", "type": "'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger'", "default": null, - "description": "Bulma color modifier.", + "description": "Bulma color modifier for the input, also carried by the calendar, where it colors the selected date. Today's date and the keyboard focus ring take the color's `-on-scheme` variant, which Bulma adjusts to contrast with the background, so pale colors stay readable; that makes `'primary'` a shade off the unset calendar, which uses plain `primary` for both. Unset, the calendar uses its `--bulma-dateinput-*` variables, which follow `primary` by default.", "required": false, "inherited": true, "deprecated": false @@ -736,6 +740,12 @@ "default": "var(--bulma-primary)", "scope": "element" }, + { + "css": "--bulma-dateinput-focus-ring-color", + "sass": "$dateinput-focus-ring-color", + "default": "var(--bulma-primary)", + "scope": "element" + }, { "css": "--bulma-dateinput-cell-disabled-color", "sass": "$dateinput-cell-disabled-color", diff --git a/bestax-mcp/data/components/DateTimeInput.json b/bestax-mcp/data/components/DateTimeInput.json index 377d6ff32..e1fce98eb 100644 --- a/bestax-mcp/data/components/DateTimeInput.json +++ b/bestax-mcp/data/components/DateTimeInput.json @@ -125,6 +125,10 @@ "title": "Colors", "code": "\n \n \n \n \n \n" }, + { + "title": "Colors", + "code": "" + }, { "title": "States", "code": "\n \n \n \n" @@ -530,7 +534,7 @@ "name": "color", "type": "'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger'", "default": null, - "description": "Bulma color modifier for the input, also carried by the time wheels, where it colors the selection band and the keyboard focus ring. Unset, the wheels use `--bulma-timeinput-wheel-selected-bg`, which defaults to `primary`. The calendar does not take it.", + "description": "Bulma color modifier for the input, also carried by the calendar and the time wheels, where it colors the selected date and the selection band. Today's date and the calendar's keyboard focus ring take the color's `-on-scheme` variant, which Bulma adjusts to contrast with the background, so pale colors stay readable; that makes `'primary'` a shade off the unset calendar, which uses plain `primary` for them. A focused wheel's ring is drawn inside the band in the color's `-invert`, like the selected value, so it shows on the fill. Unset, they use their `--bulma-dateinput-*` and `--bulma-timeinput-wheel-*` variables, which follow `primary` by default. The footer's time pill and Done button stay `primary` either way.", "required": false, "inherited": true, "deprecated": false @@ -816,6 +820,12 @@ "default": "var(--bulma-primary)", "scope": "element" }, + { + "css": "--bulma-dateinput-focus-ring-color", + "sass": "$dateinput-focus-ring-color", + "default": "var(--bulma-primary)", + "scope": "element" + }, { "css": "--bulma-dateinput-cell-disabled-color", "sass": "$dateinput-cell-disabled-color", @@ -969,7 +979,7 @@ { "css": "--bulma-timeinput-wheel-bg", "sass": "$timeinput-wheel-bg", - "default": "var(--bulma-scheme-main)", + "default": "transparent", "scope": "element" }, { diff --git a/bestax-mcp/data/components/TimeInput.json b/bestax-mcp/data/components/TimeInput.json index e35bce244..bd66626af 100644 --- a/bestax-mcp/data/components/TimeInput.json +++ b/bestax-mcp/data/components/TimeInput.json @@ -542,7 +542,7 @@ "name": "color", "type": "'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger'", "default": null, - "description": "Bulma color modifier for the input, also carried by the wheels, where it colors the selection band and the keyboard focus ring. Unset, the wheels use `--bulma-timeinput-wheel-selected-bg`, which defaults to `primary`.", + "description": "Bulma color modifier for the input, also carried by the wheels, where it colors the selection band. A focused wheel's keyboard focus ring is drawn inside the band in the color's `-invert`, like the selected value, so it shows on the fill. Unset, the wheels use `--bulma-timeinput-wheel-selected-bg`, which defaults to `primary`.", "required": false, "inherited": true, "deprecated": false @@ -795,7 +795,7 @@ { "css": "--bulma-timeinput-wheel-bg", "sass": "$timeinput-wheel-bg", - "default": "var(--bulma-scheme-main)", + "default": "transparent", "scope": "element" }, { diff --git a/bestax-mcp/data/skills.json b/bestax-mcp/data/skills.json index bef17fba8..404075045 100644 --- a/bestax-mcp/data/skills.json +++ b/bestax-mcp/data/skills.json @@ -176,7 +176,7 @@ { "id": "css-variables", "file": "references/css-variables.md", - "bytes": 26899 + "bytes": 27061 }, { "id": "themeable-components", diff --git a/bulma-ui/src/form/DateInput.stories.tsx b/bulma-ui/src/form/DateInput.stories.tsx index 818522c12..84a7de795 100644 --- a/bulma-ui/src/form/DateInput.stories.tsx +++ b/bulma-ui/src/form/DateInput.stories.tsx @@ -95,6 +95,39 @@ export const Colors: Story = { ), }; +export const InlineColors: Story = { + render: () => { + // The 1st of this month (the 2nd when today is the 1st), so the selected + // date and today's date both show. + const picked = new Date(); + picked.setDate(picked.getDate() === 1 ? 2 : 1); + return ( + + {( + ['primary', 'link', 'info', 'success', 'warning', 'danger'] as const + ).map(color => ( + + + + ))} + + ); + }, + parameters: { + docs: { + description: { + story: + "Rendered inline so the calendar is visible without opening the popover: `color` tints the selected date, today's date and, for keyboard users, the focus ring. Tab into the grid to see the ring.", + }, + }, + }, +}; + export const States: Story = { render: () => ( diff --git a/bulma-ui/src/form/DateInputBase.tsx b/bulma-ui/src/form/DateInputBase.tsx index 169ec0a94..5a6a212f7 100644 --- a/bulma-ui/src/form/DateInputBase.tsx +++ b/bulma-ui/src/form/DateInputBase.tsx @@ -101,7 +101,15 @@ export interface DateInputBaseProps position?: PickerPosition; /** Render the popover into `document.body` via portal. */ appendToBody?: boolean; - /** Bulma color modifier. */ + /** + * Bulma color modifier for the input, also carried by the calendar, where it + * colors the selected date. Today's date and the keyboard focus ring take + * the color's `-on-scheme` variant, which Bulma adjusts to contrast with the + * background, so pale colors stay readable; that makes `'primary'` a shade + * off the unset calendar, which uses plain `primary` for both. Unset, the + * calendar uses its `--bulma-dateinput-*` variables, which follow `primary` + * by default. + */ color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger'; /** Size variant. */ size?: 'small' | 'medium' | 'large'; diff --git a/bulma-ui/src/form/DateTimeInput.stories.tsx b/bulma-ui/src/form/DateTimeInput.stories.tsx index 377b21fe8..6ef2cc900 100644 --- a/bulma-ui/src/form/DateTimeInput.stories.tsx +++ b/bulma-ui/src/form/DateTimeInput.stories.tsx @@ -250,6 +250,33 @@ export const Colors: Story = { ), }; +export const InlineColors: Story = { + render: () => ( + + {( + ['primary', 'link', 'info', 'success', 'warning', 'danger'] as const + ).map(color => ( + + + + ))} + + ), + parameters: { + docs: { + description: { + story: + "Rendered inline so the panel is visible without opening the popover: `color` tints the calendar and, once the time row is opened, the wheels. The footer's time pill and Done button stay `primary`.", + }, + }, + }, +}; + export const States: Story = { render: () => ( diff --git a/bulma-ui/src/form/DateTimeInputBase.tsx b/bulma-ui/src/form/DateTimeInputBase.tsx index 195b9cbb4..f7b762914 100644 --- a/bulma-ui/src/form/DateTimeInputBase.tsx +++ b/bulma-ui/src/form/DateTimeInputBase.tsx @@ -134,10 +134,17 @@ export interface DateTimeInputBaseProps /** Render the popover into `document.body` via portal. */ appendToBody?: boolean; /** - * Bulma color modifier for the input, also carried by the time wheels, where - * it colors the selection band and the keyboard focus ring. Unset, the - * wheels use `--bulma-timeinput-wheel-selected-bg`, which defaults to - * `primary`. The calendar does not take it. + * Bulma color modifier for the input, also carried by the calendar and the + * time wheels, where it colors the selected date and the selection band. + * Today's date and the calendar's keyboard focus ring take the color's + * `-on-scheme` variant, which Bulma adjusts to contrast with the background, + * so pale colors stay readable; that makes `'primary'` a shade off the unset + * calendar, which uses plain `primary` for them. A focused wheel's ring is + * drawn inside the band in the color's `-invert`, like the selected value, + * so it shows on the fill. Unset, they use their + * `--bulma-dateinput-*` and `--bulma-timeinput-wheel-*` variables, which + * follow `primary` by default. The footer's time pill and Done button stay + * `primary` either way. */ color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger'; /** Size variant. */ diff --git a/bulma-ui/src/form/TimeInput.stories.tsx b/bulma-ui/src/form/TimeInput.stories.tsx index 9d6d91805..6051dc0b3 100644 --- a/bulma-ui/src/form/TimeInput.stories.tsx +++ b/bulma-ui/src/form/TimeInput.stories.tsx @@ -661,7 +661,7 @@ export const InlineColors: Story = { docs: { description: { story: - 'Rendered inline so the wheels are visible without opening the popover: `color` tints the selection band and, for keyboard users, the focus ring. Tab into a wheel to see the ring.', + 'Rendered inline so the wheels are visible without opening the popover: `color` tints the selection band. Tab into a wheel to see its focus ring, drawn inside the band.', }, }, }, diff --git a/bulma-ui/src/form/TimeInputBase.tsx b/bulma-ui/src/form/TimeInputBase.tsx index 3d8726c9b..f44af2648 100644 --- a/bulma-ui/src/form/TimeInputBase.tsx +++ b/bulma-ui/src/form/TimeInputBase.tsx @@ -125,8 +125,10 @@ export interface TimeInputBaseProps appendToBody?: boolean; /** * Bulma color modifier for the input, also carried by the wheels, where it - * colors the selection band and the keyboard focus ring. Unset, the wheels - * use `--bulma-timeinput-wheel-selected-bg`, which defaults to `primary`. + * colors the selection band. A focused wheel's keyboard focus ring is drawn + * inside the band in the color's `-invert`, like the selected value, so it + * shows on the fill. Unset, the wheels use + * `--bulma-timeinput-wheel-selected-bg`, which defaults to `primary`. */ color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger'; /** Size variant. */ diff --git a/bulma-ui/src/form/__tests__/DateInput.styles.test.tsx b/bulma-ui/src/form/__tests__/DateInput.styles.test.tsx new file mode 100644 index 000000000..20d1e8b67 --- /dev/null +++ b/bulma-ui/src/form/__tests__/DateInput.styles.test.tsx @@ -0,0 +1,212 @@ +// The calendar put `is-` on its root for as long as DateInput and +// DateTimeInput passed `color` in, and no rule read it. A class reaching the +// DOM proves nothing about the stylesheet, so these compile the real SCSS and +// check what it does, the way TimeInput.styles.test.tsx does for the wheels. +import * as sass from 'sass'; +import path from 'path'; +import type { ReactElement } from 'react'; +import { render } from '@testing-library/react'; +import { DateInput } from '../DateInput'; +import { DateTimeInput } from '../DateTimeInput'; +import { ConfigProvider } from '../../helpers/Config'; + +const SCSS = path.resolve(__dirname, '../../scss'); +const NODE_MODULES = path.resolve(__dirname, '../../../../node_modules'); +const OPTIONS = { + loadPaths: [SCSS, NODE_MODULES], + quietDeps: true, + logger: sass.Logger.silent, +}; + +const compile = (file: string) => + sass.compile(path.resolve(SCSS, file), OPTIONS).css; + +const colors = [ + 'primary', + 'link', + 'info', + 'success', + 'warning', + 'danger', +] as const; +type Color = (typeof colors)[number]; + +/** + * The variables a colour re-points, and what each should read for it. Today's + * tint and the ring sit on the calendar's surface, so they take the + * `-on-scheme` variant, which Bulma adjusts until it contrasts with + * `scheme-main`: plain `warning` or `info` is too faint there on a light + * surface. + */ +const accents = (color: string) => ({ + '--bulma-dateinput-cell-selected-bg': `var(--bulma-${color})`, + '--bulma-dateinput-cell-selected-color': `var(--bulma-${color}-invert)`, + '--bulma-dateinput-cell-today-color': `var(--bulma-${color}-on-scheme)`, + '--bulma-dateinput-focus-ring-color': `var(--bulma-${color}-on-scheme)`, +}); + +/** What an uncoloured calendar reads: plain `primary` for today and the ring. */ +const defaults = { + ...accents('primary'), + '--bulma-dateinput-cell-today-color': 'var(--bulma-primary)', + '--bulma-dateinput-focus-ring-color': 'var(--bulma-primary)', +}; + +/** The accent variables as the calendar root computes them. */ +function computedAccents(root: HTMLElement) { + const style = getComputedStyle(root); + return Object.fromEntries( + Object.keys(accents('primary')).map(name => [ + name, + style.getPropertyValue(name).trim(), + ]) + ); +} + +/** The calendar root, which is where `is-` lands. */ +function calendarRoot(container: HTMLElement, prefix = '') { + const root = container.querySelector(`.${prefix}dateinput`); + if (!root) throw new Error(`no .${prefix}dateinput rendered`); + return root; +} + +const sheets: HTMLStyleElement[] = []; +const inject = (css: string) => { + const el = document.createElement('style'); + el.textContent = css; + document.head.appendChild(el); + sheets.push(el); + return el; +}; + +let sheet: CSSStyleSheet; + +beforeAll(() => { + sheet = inject(compile('form/_dateinput.scss')).sheet as CSSStyleSheet; +}); + +afterAll(() => { + for (const el of sheets) el.remove(); +}); + +const pickers: [string, (color?: Color) => ReactElement][] = [ + ['DateInput', color => ], + ['DateTimeInput', color => ], +]; + +describe.each(pickers)('%s calendar colour styles', (_name, picker) => { + it.each(colors)( + 'points the selection, today and the focus ring at %s', + color => { + const { container } = render(picker(color)); + expect(computedAccents(calendarRoot(container))).toEqual(accents(color)); + } + ); + + it('leaves an uncoloured calendar on the primary defaults', () => { + const { container } = render(picker()); + expect(computedAccents(calendarRoot(container))).toEqual(defaults); + }); +}); + +describe('calendar colour styles under a class prefix', () => { + it('matches the prefixed modifier the calendar emits', () => { + inject( + sass.compileString( + `@use 'bulma/sass/utilities/initial-variables' with ($class-prefix: 'bestax-'); + @use 'form/dateinput';`, + OPTIONS + ).css + ); + const { container } = render( + + + + ); + const root = calendarRoot(container, 'bestax-'); + expect(root).toHaveClass('bestax-is-danger'); + expect(computedAccents(root)).toEqual(accents('danger')); + }); +}); + +/** Every custom property a style rule in the sheet sets. */ +function setProperties(rules: CSSRuleList): string[] { + const names = new Set(); + for (const rule of Array.from(rules)) { + if (!(rule instanceof CSSStyleRule)) continue; + for (let i = 0; i < rule.style.length; i++) { + const name = rule.style[i]; + if (name.startsWith('--')) names.add(name); + } + } + return [...names]; +} + +/** Every top-level style rule whose selector is a keyboard focus state. */ +function focusRules(rules: CSSRuleList): CSSStyleRule[] { + return Array.from(rules).filter( + (rule): rule is CSSStyleRule => + rule instanceof CSSStyleRule && + rule.selectorText.includes(':focus-visible') + ); +} + +/** The colour a rule gives its outline, from the longhand or the shorthand. */ +const ringOf = (rule: CSSStyleRule) => + rule.style.getPropertyValue('outline-color') || + rule.style.getPropertyValue('outline'); + +describe('calendar focus rings', () => { + it('reads a calendar variable for every ring', () => { + // A ring that names a colour itself, `scheme-main` included, stays that + // colour whatever `color` does to the surface or the fill under it. + const rules = focusRules(sheet.cssRules); + expect(rules.length).toBeGreaterThan(0); + for (const rule of rules) { + expect([rule.selectorText, ringOf(rule)]).toEqual([ + rule.selectorText, + expect.stringMatching(/var\(--bulma-dateinput-/), + ]); + } + }); + + it.each(['dateinput-cell', 'dateinput-year-cell'])( + 'gives a selected %s the selected value colour for its ring', + cls => { + // That ring is inset into the selection fill, which follows `color`, + // and the selected value's colour is the one chosen to contrast with + // it. The focused year is always the selected one. + const rule = focusRules(sheet.cssRules).find( + r => r.selectorText === `.${cls}.is-selected:focus-visible` + ); + expect(rule && ringOf(rule)).toBe( + 'var(--bulma-dateinput-cell-selected-color)' + ); + } + ); +}); + +describe('calendar variables', () => { + it('registers only variables that some rule reads', () => { + const set = setProperties(sheet.cssRules); + expect(set).toContain('--bulma-dateinput-focus-ring-color'); + + const shipped = compile('bestax.scss'); + const unread = set.filter( + name => !new RegExp(`var\\(\\s*${name}\\s*[,)]`).test(shipped) + ); + expect(unread).toEqual([]); + }); + + it('reads no Bulma colour directly outside a variable', () => { + // A declaration that names a colour itself stays that colour whatever + // `color` says, which is how the focus rings stayed primary. Custom + // properties are where the colours are meant to be named. + const direct = new RegExp(`var\\(--bulma-(?:${colors.join('|')})\\b`); + const offenders = compile('form/_dateinput.scss') + .split('\n') + .map(line => line.trim()) + .filter(line => !line.startsWith('--') && direct.test(line)); + expect(offenders).toEqual([]); + }); +}); diff --git a/bulma-ui/src/form/__tests__/TimeInput.styles.test.tsx b/bulma-ui/src/form/__tests__/TimeInput.styles.test.tsx index 6e32ce9d0..05f2a8a4c 100644 --- a/bulma-ui/src/form/__tests__/TimeInput.styles.test.tsx +++ b/bulma-ui/src/form/__tests__/TimeInput.styles.test.tsx @@ -68,23 +68,143 @@ describe('TimeInput wheel colour styles', () => { }); }); +/** Every top-level style rule whose selector is a keyboard focus state. */ +function focusRules(sheet: CSSStyleSheet): CSSStyleRule[] { + return Array.from(sheet.cssRules).filter( + (rule): rule is CSSStyleRule => + rule instanceof CSSStyleRule && + rule.selectorText.includes(':focus-visible') + ); +} + +describe('TimeInput focus ring', () => { + // The wheel carries a mask, and the mask clips everything outside the + // wheel's border box, so an outline on the wheel itself (which sits outside + // it) never paints. The ring goes inset on the band, which the mask leaves + // whole. + it('puts no ring on the masked wheel itself', () => { + const own = focusRules(styleEl.sheet as CSSStyleSheet).filter( + r => r.selectorText === '.timeinput-wheel:focus-visible' + ); + for (const rule of own) { + expect(rule.style.getPropertyValue('outline')).toBe(''); + expect(rule.style.getPropertyValue('outline-style')).toBe(''); + } + }); + + it('draws it inset on the band in the selected value colour', () => { + // It sits on the selection fill, which follows `color`, and the selected + // value's colour is the one chosen to contrast with that fill. + const band = focusRules(styleEl.sheet as CSSStyleSheet).find( + r => + r.selectorText === + '.timeinput-wheel:focus-visible .timeinput-wheel-band' + ); + expect(band?.style.getPropertyValue('outline')).toBe( + '2px solid var(--bulma-timeinput-wheel-selected-color)' + ); + expect(band?.style.getPropertyValue('outline-offset')).toBe('-2px'); + }); +}); + +/** Every custom property the style rules in a list set, media blocks skipped. */ +function customProperties(rules: CSSRuleList): string[] { + const names = new Set(); + for (const rule of Array.from(rules)) { + if (!(rule instanceof CSSStyleRule)) continue; + for (let i = 0; i < rule.style.length; i++) { + const name = rule.style[i]; + if (name.startsWith('--')) names.add(name); + } + } + return [...names]; +} + /** Every custom property a `(max-width: …)` media block in the sheet sets. */ function mobileCustomProperties(sheet: CSSStyleSheet): string[] { const names = new Set(); for (const rule of Array.from(sheet.cssRules)) { if (!(rule instanceof CSSMediaRule)) continue; if (!/max-width/.test(rule.media.mediaText)) continue; - for (const inner of Array.from(rule.cssRules)) { - if (!(inner instanceof CSSStyleRule)) continue; - for (let i = 0; i < inner.style.length; i++) { - const name = inner.style[i]; - if (name.startsWith('--')) names.add(name); + for (const name of customProperties(rule.cssRules)) names.add(name); + } + return [...names]; +} + +/** The names no `var()` in the shipped stylesheet reads. */ +let shipped: string | undefined; +function unread(names: string[]): string[] { + shipped ??= compile('bestax.scss'); + const css = shipped; + return names.filter( + name => !new RegExp(`var\\(\\s*${name}\\s*[,)]`).test(css) + ); +} + +describe('TimeInput variables', () => { + // A registered variable nothing reads is a theming knob that turns nothing, + // which is where the wheel background and hover fill sat. The item height + // is left that way on purpose: the wheels position items from a height the + // component passes them, and dropping the Sass variable would break a theme + // that sets it. So it is named here, and has to stay unread to stay named. + const UNREAD = ['--bulma-timeinput-wheel-item-height']; + + it('registers only variables that some rule reads', () => { + const registered = customProperties( + (styleEl.sheet as CSSStyleSheet).cssRules + ); + expect(registered).toEqual(expect.arrayContaining(UNREAD)); + expect(unread(registered)).toEqual(UNREAD); + }); + + it('leaves the wheel background transparent by default', () => { + // The wheel sits on the popover, the inline frame or DateTimeInput's time + // card, each with a background variable of its own. Any other default + // would paint over whichever of those a theme had changed. + const { container } = render(); + const root = container.querySelector('.timeinput'); + expect(root).not.toBeNull(); + expect( + getComputedStyle(root as HTMLElement) + .getPropertyValue('--bulma-timeinput-wheel-bg') + .trim() + ).toBe('transparent'); + }); +}); + +/** Where each rule that paints the hover fill sits: a media query, or none. */ +function hoverFillContexts(rules: CSSRuleList, media = ''): string[] { + const found: string[] = []; + for (const rule of Array.from(rules)) { + if (rule instanceof CSSMediaRule) { + found.push(...hoverFillContexts(rule.cssRules, rule.media.mediaText)); + } else if (rule instanceof CSSStyleRule) { + for (let i = 0; i < rule.style.length; i++) { + const name = rule.style[i]; + if (name.startsWith('--')) continue; + if ( + rule.style + .getPropertyValue(name) + .includes('var(--bulma-timeinput-wheel-hover-bg)') + ) { + found.push(media || '(top level)'); + } } } } - return [...names]; + return found; } +describe('TimeInput hover fill', () => { + // A touch browser can leave `:hover` on the last item a finger lifted from, + // and a drag leaves that item off the band, so an ungated fill sticks there. + it('fills a hovered item only where the pointer can hover', () => { + expect( + hoverFillContexts((styleEl.sheet as CSSStyleSheet).cssRules) + ).toEqual(['(hover: hover)']); + }); +}); + describe('TimeInput mobile overrides', () => { // The small-viewport block adjusts the wheels and the popover by setting // custom properties. Setting one that no rule reads changes nothing, so @@ -92,11 +212,6 @@ describe('TimeInput mobile overrides', () => { it('sets only custom properties that some rule reads', () => { const set = mobileCustomProperties(styleEl.sheet as CSSStyleSheet); expect(set.length).toBeGreaterThan(0); - - const shipped = compile('bestax.scss'); - const unread = set.filter( - name => !new RegExp(`var\\(\\s*${name}\\s*[,)]`).test(shipped) - ); - expect(unread).toEqual([]); + expect(unread(set)).toEqual([]); }); }); diff --git a/bulma-ui/src/scss/form/_dateinput.scss b/bulma-ui/src/scss/form/_dateinput.scss index a6cbb8a03..779afb763 100644 --- a/bulma-ui/src/scss/form/_dateinput.scss +++ b/bulma-ui/src/scss/form/_dateinput.scss @@ -9,6 +9,7 @@ $dateinput-cell-hover-bg: hsla(0, 0%, 50%, 0.13) !default; $dateinput-cell-selected-bg: cv.getVar('primary') !default; $dateinput-cell-selected-color: cv.getVar('primary-invert') !default; $dateinput-cell-today-color: cv.getVar('primary') !default; +$dateinput-focus-ring-color: cv.getVar('primary') !default; $dateinput-cell-disabled-color: cv.getVar('text-weak') !default; $dateinput-cell-other-month-color: cv.getVar('text-weak') !default; $dateinput-header-padding: 0.5rem 0 !default; @@ -27,6 +28,7 @@ $dateinput-nav-button-size: 1.75rem !default; 'dateinput-cell-selected-bg': #{$dateinput-cell-selected-bg}, 'dateinput-cell-selected-color': #{$dateinput-cell-selected-color}, 'dateinput-cell-today-color': #{$dateinput-cell-today-color}, + 'dateinput-focus-ring-color': #{$dateinput-focus-ring-color}, 'dateinput-cell-disabled-color': #{$dateinput-cell-disabled-color}, 'dateinput-cell-other-month-color': #{$dateinput-cell-other-month-color}, 'dateinput-header-padding': #{$dateinput-header-padding}, @@ -80,7 +82,7 @@ $dateinput-nav-button-size: 1.75rem !default; background-color: cv.getVar('dateinput-cell-hover-bg'); } &:focus-visible { - outline: 2px solid cv.getVar('primary'); + outline: 2px solid cv.getVar('dateinput-focus-ring-color'); outline-offset: 2px; } } @@ -121,7 +123,7 @@ $dateinput-nav-button-size: 1.75rem !default; background-color: cv.getVar('dateinput-cell-hover-bg'); } &:focus-visible { - outline: 2px solid cv.getVar('primary'); + outline: 2px solid cv.getVar('dateinput-focus-ring-color'); outline-offset: 1px; } &:disabled { @@ -172,7 +174,7 @@ $dateinput-nav-button-size: 1.75rem !default; &:hover:not(:disabled):not(.#{iv.$class-prefix}is-selected) { background-color: cv.getVar('dateinput-cell-hover-bg'); } - // Hover for the selected cell: darken the primary fill rather than + // Hover for the selected cell: darken the selection fill rather than // replacing it, so the selection stays visible under the cursor while // still giving interactive feedback. &.#{iv.$class-prefix}is-selected:hover:not(:disabled) { @@ -183,10 +185,10 @@ $dateinput-nav-button-size: 1.75rem !default; ); } // Inset focus ring so it can't bleed into an adjacent selected cell's - // primary fill (the grid gap is only 2px). Outline respects the cell's + // fill (the grid gap is only 2px). Outline respects the cell's // border-radius in modern browsers. &:focus-visible { - outline: 2px solid cv.getVar('primary'); + outline: 2px solid cv.getVar('dateinput-focus-ring-color'); outline-offset: -2px; } // Today: tinted bold text (no ring), so it doesn't collide visually with @@ -199,10 +201,11 @@ $dateinput-nav-button-size: 1.75rem !default; background-color: cv.getVar('dateinput-cell-selected-bg'); color: cv.getVar('dateinput-cell-selected-color'); } - // When focus lands on the selected cell, swap the ring to scheme-main so - // it stays visible against the primary-colored fill. + // On the selected cell the inset ring sits on the selection fill, so it + // takes the selected value's colour, which is chosen to contrast with that + // fill whatever colour it is. &.#{iv.$class-prefix}is-selected:focus-visible { - outline-color: cv.getVar('scheme-main'); + outline-color: cv.getVar('dateinput-cell-selected-color'); } &.#{iv.$class-prefix}is-other-month { color: cv.getVar('dateinput-cell-other-month-color'); @@ -250,7 +253,7 @@ $dateinput-nav-button-size: 1.75rem !default; ); } &:focus-visible { - outline: 2px solid cv.getVar('primary'); + outline: 2px solid cv.getVar('dateinput-focus-ring-color'); outline-offset: -2px; } &.#{iv.$class-prefix}is-today { @@ -261,8 +264,10 @@ $dateinput-nav-button-size: 1.75rem !default; background-color: cv.getVar('dateinput-cell-selected-bg'); color: cv.getVar('dateinput-cell-selected-color'); } + // The focused year is always the selected one, so this is the ring a + // keyboard user sees in the year view; it contrasts with the fill as above. &.#{iv.$class-prefix}is-selected:focus-visible { - outline-color: cv.getVar('scheme-main'); + outline-color: cv.getVar('dateinput-cell-selected-color'); } &:disabled { color: cv.getVar('dateinput-cell-disabled-color'); @@ -271,6 +276,27 @@ $dateinput-nav-button-size: 1.75rem !default; } } +// Colour variants. `color` lands on the calendar root as `is-`, and +// the root re-points its accent variables at that colour: the selection fill +// paired with its `-invert` for the selected value. Today's tint and the focus +// ring sit on the calendar's surface rather than on a fill, so they take the +// colour's `-on-scheme` variant, which Bulma darkens or lightens until it +// contrasts with `scheme-main`; plain `warning` or `info` text on a light +// surface is too faint to read. Every rule that paints an accent reads one of +// these, so they follow without rules of their own. +@each $name in 'primary', 'link', 'info', 'success', 'warning', 'danger' { + .#{iv.$class-prefix}dateinput.#{iv.$class-prefix}is-#{$name} { + @include cv.register-vars( + ( + 'dateinput-cell-selected-bg': #{cv.getVar($name)}, + 'dateinput-cell-selected-color': #{cv.getVar('#{$name}-invert')}, + 'dateinput-cell-today-color': #{cv.getVar('#{$name}-on-scheme')}, + 'dateinput-focus-ring-color': #{cv.getVar('#{$name}-on-scheme')}, + ) + ); + } +} + .#{iv.$class-prefix}dateinput.#{iv.$class-prefix}is-small .#{iv.$class-prefix}dateinput-cell { width: 1.75rem; diff --git a/bulma-ui/src/scss/form/_timeinput.scss b/bulma-ui/src/scss/form/_timeinput.scss index 27d018ea8..6ac838999 100644 --- a/bulma-ui/src/scss/form/_timeinput.scss +++ b/bulma-ui/src/scss/form/_timeinput.scss @@ -2,11 +2,20 @@ @use 'bulma/sass/utilities/css-variables' as cv; $timeinput-wheel-width: 3rem !default; +// Registered, and read by nothing: the wheels position every item from its +// height in script, so the component passes the height to them itself (taller +// on small viewports) rather than reading a CSS length. Kept so a theme that +// sets it still compiles. $timeinput-wheel-item-height: 2rem !default; $timeinput-wheel-gap: 0.4rem !default; -$timeinput-wheel-bg: cv.getVar('scheme-main') !default; +// Transparent, so the drum shows the surface it sits on: the popover, the +// inline frame or DateTimeInput's time card, each of which has a background +// variable of its own that a painted default would cover. +$timeinput-wheel-bg: transparent !default; $timeinput-wheel-color: cv.getVar('text') !default; $timeinput-wheel-dim-color: cv.getVar('text-weak') !default; +// The calendar's cell hover, so both halves of a DateTimeInput answer the +// pointer alike, on light and dark schemes. $timeinput-wheel-hover-bg: hsla(0, 0%, 50%, 0.13) !default; $timeinput-wheel-selected-bg: cv.getVar('primary') !default; $timeinput-wheel-selected-color: cv.getVar('primary-invert') !default; @@ -80,6 +89,7 @@ $timeinput-footer-padding: 0.5rem 0 0 !default; .#{iv.$class-prefix}timeinput-wheel { position: relative; width: cv.getVar('timeinput-wheel-width'); + background-color: cv.getVar('timeinput-wheel-bg'); outline: none; overflow: hidden; touch-action: none; @@ -114,11 +124,14 @@ $timeinput-footer-padding: 0.5rem 0 0 !default; // pinning a ring to the selected item caused a broken-outline artefact // whenever position was mid-flight (item offset from band). // - // The ring reads the band's colour, so a coloured wheel keeps one accent. - &:focus-visible { - outline: 2px solid cv.getVar('timeinput-wheel-selected-bg'); - outline-offset: 2px; - border-radius: cv.getVar('timeinput-wheel-radius'); + // The ring is drawn inset on the band. An outline on the wheel itself sits + // outside its border box, and the mask above clips everything there, so it + // never painted. On the band it sits on the selection fill, so it takes the + // selected value's colour, which contrasts with that fill whatever colour + // the band is. + &:focus-visible .#{iv.$class-prefix}timeinput-wheel-band { + outline: 2px solid cv.getVar('timeinput-wheel-selected-color'); + outline-offset: -2px; } &.#{iv.$class-prefix}is-dragging .#{iv.$class-prefix}timeinput-wheel-item { @@ -153,6 +166,14 @@ $timeinput-footer-padding: 0.5rem 0 0 !default; &:hover:not(:disabled):not(.#{iv.$class-prefix}is-selected) { color: cv.getVar('timeinput-wheel-color'); + + // Only where the pointer can hover: a touch browser can leave `:hover` on + // the last item a finger lifted from, and a drag leaves that item off the + // band, where the fill would stick. The fill is not in the transition list + // above, so it snaps on and off the way the calendar cells' hover does. + @media (hover: hover) { + background-color: cv.getVar('timeinput-wheel-hover-bg'); + } } // The selected item (whichever is currently centred over the band) is @@ -254,9 +275,9 @@ $timeinput-footer-padding: 0.5rem 0 0 !default; } // Mobile (small viewport): bigger touch targets, larger numbers, more iOS-native -// feel. Item *height* is set inline by JS and bumped from 40px to 48px on small -// viewports by TimeInputBase; the rules below adjust everything that's CSS-only -// (font size, wheel width, gap, separator, mask intensity). +// feel. Item *height* is set inline by JS, and made taller on small viewports by +// the component; the rules below adjust everything that's CSS-only (font size, +// wheel width, gap, separator, mask intensity). @media (max-width: 768px) { // Registered through `cv.register-vars` like the defaults above, so the // overrides land on the names the rules read. diff --git a/docs/docs/api/form/datetime/dateinput.md b/docs/docs/api/form/datetime/dateinput.md index c827dbcdc..e2d27f963 100644 --- a/docs/docs/api/form/datetime/dateinput.md +++ b/docs/docs/api/form/datetime/dateinput.md @@ -629,6 +629,35 @@ If any of these matter, pass `mobileNative={false}` to force the custom calendar ``` +**Inline:** the calendar carries the color too, on the selected date, today's date and the keyboard focus ring, and rendered inline it shows without opening a popover. + +```tsx live +function example() { + // The 1st of this month (the 2nd when today is the 1st), so the selected + // date and today's date both show. + const picked = new Date(); + picked.setDate(picked.getDate() === 1 ? 2 : 1); + return ( + + + + + + + + + + + + ); +} +``` + --- ### States @@ -827,66 +856,66 @@ Use `inline` instead of the popover when you have vertical room to spare — boo -| Prop | Type | Default | Description | -| ------------------- | -------------------------------------------------------------------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `label` | `React.ReactNode` | — | Field label (component auto-wraps in a `Field` if not already inside). Automatically associated with the input via `htmlFor` — uses your `id` when provided, otherwise a generated one. Not wired in `inline` mode (no visible input to label) and dropped inside an outer `Field`. | -| `labelSize` | `'small'` \| `'normal'` \| `'medium'` \| `'large'` | — | Size for the label. | -| `labelProps` | `React.LabelHTMLAttributes & { [key: string]: unknown; }` | — | Props for the label element. An explicit `htmlFor` here overrides the automatic association (no id is generated then). | -| `horizontal` | `boolean` | `false` | Render the field with horizontal layout. | -| `iconLeft` | `IconProps` \| `React.ReactNode` | — | Icon props for the left icon. | -| `iconRight` | `IconProps` \| `React.ReactNode` | — | Icon props for the right icon. | -| `iconRightName` | `string` | — | Shortcut for the right icon name. | -| `iconLeftSize` | `'small'` \| `'medium'` \| `'large'` | — | Shortcut for left icon size. | -| `iconRightSize` | `'small'` \| `'medium'` \| `'large'` | — | Shortcut for right icon size. | -| `hasIconsLeft` | `boolean` | `false` | Force the left icon container. | -| `hasIconsRight` | `boolean` | `false` | Force the right icon container. | -| `isLoading` | `boolean` | `false` | Show a loading indicator on the control. | -| `isExpanded` | `boolean` | `false` | Expand the control to fill its container. | -| `controlSize` | `'small'` \| `'medium'` \| `'large'` | — | Size of the wrapping Control. | -| `message` | `React.ReactNode` | — | Help/validation text below the input. | -| `messageColor` | `'primary'` \| `'link'` \| `'info'` \| `'success'` \| `'warning'` \| `'danger'` | — | Color modifier for the help message. | -| `fieldClassName` | `string` | — | Additional CSS classes for the Field wrapper. | -| `controlClassName` | `string` | — | Additional CSS classes for the Control wrapper. | -| `value` | `Date` \| `null` | — | Controlled selected date. | -| `defaultValue` | `Date` \| `null` | — | Initial date for uncontrolled usage. | -| `onChange` | `(d: Date \| null) => void` | — | Fired when the value changes. | -| `onOpen` | `() => void` | — | Fired when the popover opens. | -| `onClose` | `() => void` | — | Fired when the popover closes. | -| `min` | `Date` | — | Earliest selectable date. | -| `max` | `Date` | — | Latest selectable date. | -| `disabled` | `boolean` | `false` | Disable the input. | -| `readOnly` | `boolean` | `false` | Make the input read-only. | -| `placeholder` | `string` | — | Placeholder text for the input. | -| `format` | `Intl.DateTimeFormatOptions` \| `string` | `'YYYY-MM-DD'` | Token format string or `Intl.DateTimeFormat` options. Default `'YYYY-MM-DD'`. | -| `parse` | `(s: string) => Date \| null` | — | Custom parser (use when `format` is `Intl.DateTimeFormatOptions`). | -| `locale` | `string` | — | BCP-47 locale tag for day/month names and Intl formatting. | -| `inline` | `boolean` | `false` | Render the calendar inline (no popover). | -| `mobileNative` | `boolean` \| `'auto'` | `'auto'` | Use `` on coarse-pointer + small-viewport devices. | -| `editable` | `boolean` | `true` | Allow segmented keyboard typing in the input (type the date directly, auto-advancing across segments). `false` makes the field picker-only. | -| `popover` | `boolean` | `true` | Whether the calendar popover exists. `false` makes the field input-only (segmented typing, no popover). | -| `openOnFocus` | `boolean` | `true` | Open the popover when the input is focused. | -| `closeOnSelect` | `boolean` | `true` | Close the popover after a date is selected. | -| `position` | `'bottom-left'` \| `'bottom-right'` \| `'top-left'` \| `'top-right'` \| `'auto'` | `'bottom-left'` | Popover anchor position relative to the input. | -| `appendToBody` | `boolean` | `false` | Render the popover into `document.body` via portal. | -| `color` | `'primary'` \| `'link'` \| `'info'` \| `'success'` \| `'warning'` \| `'danger'` | — | Bulma color modifier. | -| `size` | `'small'` \| `'medium'` \| `'large'` | — | Size variant. | -| `isRounded` | `boolean` | `false` | Render the input with rounded corners. | -| `shouldDisableDate` | `(d: Date) => boolean` | — | Predicate to disable specific dates (e.g. weekends). Blocked dates are also rejected during manual typing. | -| `unselectableDates` | `Date[]` | — | Convenience array of disabled dates; merged with `shouldDisableDate`. Matched by calendar day and also rejected during manual typing. | -| `firstDayOfWeek` | `0` \| `1` \| `2` \| `3` \| `4` \| `5` \| `6` | `0` | Day the week starts on (0 = Sunday). | -| `dayNames` | `string[]` | — | Override the 7 day-name labels (in calendar order, post-rotation). | -| `monthNames` | `string[]` | — | Override the 12 month-name labels. | -| `nearbyMonthDays` | `boolean` | `true` | Show dimmed dates from adjacent months in the grid. | -| `iconLeftName` | `string` | `'calendar'` | Decorative left icon glyph for the wrapping `Control` (shown by default). Set `''` to hide. | -| `triggerIcon` | `boolean` | `true` | Show a clickable launcher button on the right that toggles the popover. Default `true`. | -| `triggerIconName` | `string` | `'chevron-down'` | Glyph for the right launcher button. | -| `labels` | `PickerLabels` | — | Optional translatable string overrides (ARIA labels, button text). | -| `name` | `string` | — | Form field name. Forwarded to a hidden ISO-formatted input. | -| `form` | `string` | — | Form id the input belongs to. | -| `required` | `boolean` | `false` | Marks the input as required. | -| `className` | `string` | — | Additional CSS classes for the input. | -| `ref` | `React.Ref` | — | Forwarded to the underlying ``. | -| `...` | All standard `` attributes and Bulma helper props | — | See [Helper Props](../../helpers/usebulmaclasses.md) | +| Prop | Type | Default | Description | +| ------------------- | -------------------------------------------------------------------------------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `label` | `React.ReactNode` | — | Field label (component auto-wraps in a `Field` if not already inside). Automatically associated with the input via `htmlFor` — uses your `id` when provided, otherwise a generated one. Not wired in `inline` mode (no visible input to label) and dropped inside an outer `Field`. | +| `labelSize` | `'small'` \| `'normal'` \| `'medium'` \| `'large'` | — | Size for the label. | +| `labelProps` | `React.LabelHTMLAttributes & { [key: string]: unknown; }` | — | Props for the label element. An explicit `htmlFor` here overrides the automatic association (no id is generated then). | +| `horizontal` | `boolean` | `false` | Render the field with horizontal layout. | +| `iconLeft` | `IconProps` \| `React.ReactNode` | — | Icon props for the left icon. | +| `iconRight` | `IconProps` \| `React.ReactNode` | — | Icon props for the right icon. | +| `iconRightName` | `string` | — | Shortcut for the right icon name. | +| `iconLeftSize` | `'small'` \| `'medium'` \| `'large'` | — | Shortcut for left icon size. | +| `iconRightSize` | `'small'` \| `'medium'` \| `'large'` | — | Shortcut for right icon size. | +| `hasIconsLeft` | `boolean` | `false` | Force the left icon container. | +| `hasIconsRight` | `boolean` | `false` | Force the right icon container. | +| `isLoading` | `boolean` | `false` | Show a loading indicator on the control. | +| `isExpanded` | `boolean` | `false` | Expand the control to fill its container. | +| `controlSize` | `'small'` \| `'medium'` \| `'large'` | — | Size of the wrapping Control. | +| `message` | `React.ReactNode` | — | Help/validation text below the input. | +| `messageColor` | `'primary'` \| `'link'` \| `'info'` \| `'success'` \| `'warning'` \| `'danger'` | — | Color modifier for the help message. | +| `fieldClassName` | `string` | — | Additional CSS classes for the Field wrapper. | +| `controlClassName` | `string` | — | Additional CSS classes for the Control wrapper. | +| `value` | `Date` \| `null` | — | Controlled selected date. | +| `defaultValue` | `Date` \| `null` | — | Initial date for uncontrolled usage. | +| `onChange` | `(d: Date \| null) => void` | — | Fired when the value changes. | +| `onOpen` | `() => void` | — | Fired when the popover opens. | +| `onClose` | `() => void` | — | Fired when the popover closes. | +| `min` | `Date` | — | Earliest selectable date. | +| `max` | `Date` | — | Latest selectable date. | +| `disabled` | `boolean` | `false` | Disable the input. | +| `readOnly` | `boolean` | `false` | Make the input read-only. | +| `placeholder` | `string` | — | Placeholder text for the input. | +| `format` | `Intl.DateTimeFormatOptions` \| `string` | `'YYYY-MM-DD'` | Token format string or `Intl.DateTimeFormat` options. Default `'YYYY-MM-DD'`. | +| `parse` | `(s: string) => Date \| null` | — | Custom parser (use when `format` is `Intl.DateTimeFormatOptions`). | +| `locale` | `string` | — | BCP-47 locale tag for day/month names and Intl formatting. | +| `inline` | `boolean` | `false` | Render the calendar inline (no popover). | +| `mobileNative` | `boolean` \| `'auto'` | `'auto'` | Use `` on coarse-pointer + small-viewport devices. | +| `editable` | `boolean` | `true` | Allow segmented keyboard typing in the input (type the date directly, auto-advancing across segments). `false` makes the field picker-only. | +| `popover` | `boolean` | `true` | Whether the calendar popover exists. `false` makes the field input-only (segmented typing, no popover). | +| `openOnFocus` | `boolean` | `true` | Open the popover when the input is focused. | +| `closeOnSelect` | `boolean` | `true` | Close the popover after a date is selected. | +| `position` | `'bottom-left'` \| `'bottom-right'` \| `'top-left'` \| `'top-right'` \| `'auto'` | `'bottom-left'` | Popover anchor position relative to the input. | +| `appendToBody` | `boolean` | `false` | Render the popover into `document.body` via portal. | +| `color` | `'primary'` \| `'link'` \| `'info'` \| `'success'` \| `'warning'` \| `'danger'` | — | Bulma color modifier for the input, also carried by the calendar, where it colors the selected date. Today's date and the keyboard focus ring take the color's `-on-scheme` variant, which Bulma adjusts to contrast with the background, so pale colors stay readable; that makes `'primary'` a shade off the unset calendar, which uses plain `primary` for both. Unset, the calendar uses its `--bulma-dateinput-*` variables, which follow `primary` by default. | +| `size` | `'small'` \| `'medium'` \| `'large'` | — | Size variant. | +| `isRounded` | `boolean` | `false` | Render the input with rounded corners. | +| `shouldDisableDate` | `(d: Date) => boolean` | — | Predicate to disable specific dates (e.g. weekends). Blocked dates are also rejected during manual typing. | +| `unselectableDates` | `Date[]` | — | Convenience array of disabled dates; merged with `shouldDisableDate`. Matched by calendar day and also rejected during manual typing. | +| `firstDayOfWeek` | `0` \| `1` \| `2` \| `3` \| `4` \| `5` \| `6` | `0` | Day the week starts on (0 = Sunday). | +| `dayNames` | `string[]` | — | Override the 7 day-name labels (in calendar order, post-rotation). | +| `monthNames` | `string[]` | — | Override the 12 month-name labels. | +| `nearbyMonthDays` | `boolean` | `true` | Show dimmed dates from adjacent months in the grid. | +| `iconLeftName` | `string` | `'calendar'` | Decorative left icon glyph for the wrapping `Control` (shown by default). Set `''` to hide. | +| `triggerIcon` | `boolean` | `true` | Show a clickable launcher button on the right that toggles the popover. Default `true`. | +| `triggerIconName` | `string` | `'chevron-down'` | Glyph for the right launcher button. | +| `labels` | `PickerLabels` | — | Optional translatable string overrides (ARIA labels, button text). | +| `name` | `string` | — | Form field name. Forwarded to a hidden ISO-formatted input. | +| `form` | `string` | — | Form id the input belongs to. | +| `required` | `boolean` | `false` | Marks the input as required. | +| `className` | `string` | — | Additional CSS classes for the input. | +| `ref` | `React.Ref` | — | Forwarded to the underlying ``. | +| `...` | All standard `` attributes and Bulma helper props | — | See [Helper Props](../../helpers/usebulmaclasses.md) | @@ -908,6 +937,7 @@ Use `inline` instead of the popover when you have vertical room to spare — boo | `--bulma-dateinput-cell-selected-bg` ‡ | `$dateinput-cell-selected-bg` | `var(--bulma-primary)` | | `--bulma-dateinput-cell-selected-color` ‡ | `$dateinput-cell-selected-color` | `var(--bulma-primary-invert)` | | `--bulma-dateinput-cell-today-color` ‡ | `$dateinput-cell-today-color` | `var(--bulma-primary)` | +| `--bulma-dateinput-focus-ring-color` ‡ | `$dateinput-focus-ring-color` | `var(--bulma-primary)` | | `--bulma-dateinput-cell-disabled-color` ‡ | `$dateinput-cell-disabled-color` | `var(--bulma-text-weak)` | | `--bulma-dateinput-cell-other-month-color` ‡ | `$dateinput-cell-other-month-color` | `var(--bulma-text-weak)` | | `--bulma-dateinput-header-padding` ‡ | `$dateinput-header-padding` | `0.5rem 0` | diff --git a/docs/docs/api/form/datetime/datetimeinput.md b/docs/docs/api/form/datetime/datetimeinput.md index 12587a419..c09f29df7 100644 --- a/docs/docs/api/form/datetime/datetimeinput.md +++ b/docs/docs/api/form/datetime/datetimeinput.md @@ -575,6 +575,12 @@ The OS-native pickers always use the device's system locale, so these examples s ``` +**Inline:** rendered inline, the panel shows the color without opening a popover. The calendar takes it on the selected date, today's date and its keyboard focus ring; open the time row and the wheels take it on their selection band. The footer's time pill and Done button stay `primary`. + +```tsx live + +``` + --- ### States @@ -831,74 +837,74 @@ The DateTimeInput prop set is the union of [DateInput](./dateinput.md) and [Time -| Prop | Type | Default | Description | -| ------------------- | -------------------------------------------------------------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `label` | `React.ReactNode` | — | Field label. Automatically associated with the input via `htmlFor` — uses your `id` when provided, otherwise a generated one. Not wired in `inline` mode (no visible input to label) and dropped inside an outer `Field`. | -| `labelSize` | `'small'` \| `'normal'` \| `'medium'` \| `'large'` | — | Size for the label. | -| `labelProps` | `React.LabelHTMLAttributes & { [key: string]: unknown; }` | — | Props for the label element. An explicit `htmlFor` here overrides the automatic association (no id is generated then). | -| `horizontal` | `boolean` | `false` | Render the field with horizontal layout. | -| `iconLeft` | `IconProps` \| `React.ReactNode` | — | Icon props for the left icon. | -| `iconRight` | `IconProps` \| `React.ReactNode` | — | Icon props for the right icon. | -| `iconRightName` | `string` | — | Shortcut for the right icon name. | -| `iconLeftSize` | `'small'` \| `'medium'` \| `'large'` | — | Shortcut for left icon size. | -| `iconRightSize` | `'small'` \| `'medium'` \| `'large'` | — | Shortcut for right icon size. | -| `hasIconsLeft` | `boolean` | `false` | Force the left icon container. | -| `hasIconsRight` | `boolean` | `false` | Force the right icon container. | -| `isLoading` | `boolean` | `false` | Show a loading indicator on the control. | -| `isExpanded` | `boolean` | `false` | Expand the control to fill its container. | -| `controlSize` | `'small'` \| `'medium'` \| `'large'` | — | Size of the wrapping Control. | -| `message` | `React.ReactNode` | — | Help/validation text below the input. | -| `messageColor` | `'primary'` \| `'link'` \| `'info'` \| `'success'` \| `'warning'` \| `'danger'` | — | Message color. | -| `fieldClassName` | `string` | — | Additional CSS classes for the Field wrapper. | -| `controlClassName` | `string` | — | Additional CSS classes for the Control wrapper. | -| `value` | `Date` \| `null` | — | Controlled selected date-time. | -| `defaultValue` | `Date` \| `null` | — | Initial value for uncontrolled usage. | -| `onChange` | `(d: Date \| null) => void` | — | Fired when either the date or time portion changes. | -| `onOpen` | `() => void` | — | Fired when the popover opens. | -| `onClose` | `() => void` | — | Fired when the popover closes. | -| `min` | `Date` | — | Lower bound for the combined date-time. | -| `max` | `Date` | — | Upper bound for the combined date-time. | -| `disabled` | `boolean` | `false` | Disable the input. | -| `readOnly` | `boolean` | `false` | Read-only input. | -| `placeholder` | `string` | — | Placeholder text. | -| `format` | `Intl.DateTimeFormatOptions` \| `string` | `'YYYY-MM-DD HH:mm'` | Token format string or `Intl.DateTimeFormat` options. Default `'YYYY-MM-DD HH:mm'`. | -| `parse` | `(s: string) => Date \| null` | — | Custom parser. | -| `locale` | `string` | — | BCP-47 locale tag. | -| `inline` | `boolean` | `false` | Render the panel inline (no popover). | -| `mobileNative` | `boolean` \| `'auto'` | `'auto'` | Use `` on coarse-pointer devices. | -| `editable` | `boolean` | `true` | Allow segmented keyboard typing (type the date-time directly across all segments). `false` makes the field picker-only. | -| `popover` | `boolean` | `true` | Whether the calendar + time popover exists. `false` makes the field input-only (segmented typing with no popover). Default `true`. | -| `openOnFocus` | `boolean` | `true` | Open the popover on focus. Default `true`. | -| `closeOnSelect` | `boolean` | `false` | Off by default — users typically tweak both halves before committing. | -| `position` | `'bottom-left'` \| `'bottom-right'` \| `'top-left'` \| `'top-right'` \| `'auto'` | `'bottom-left'` | Popover anchor position. | -| `appendToBody` | `boolean` | `false` | Render the popover into `document.body` via portal. | -| `color` | `'primary'` \| `'link'` \| `'info'` \| `'success'` \| `'warning'` \| `'danger'` | — | Bulma color modifier for the input, also carried by the time wheels, where it colors the selection band and the keyboard focus ring. Unset, the wheels use `--bulma-timeinput-wheel-selected-bg`, which defaults to `primary`. The calendar does not take it. | -| `size` | `'small'` \| `'medium'` \| `'large'` | — | Size variant. | -| `isRounded` | `boolean` | `false` | Rounded input corners. | -| `shouldDisableDate` | `(d: Date) => boolean` | — | Disable specific dates. Blocked dates are also rejected during manual typing (the predicate receives the full candidate date-time — prefer day-based checks). | -| `unselectableDates` | `Date[]` | — | Convenience array of disabled dates, matched by calendar day; also rejected by manual typing. | -| `firstDayOfWeek` | `0` \| `1` \| `2` \| `3` \| `4` \| `5` \| `6` | `0` | Day the calendar week starts on. | -| `dayNames` | `string[]` | — | Override the 7 day-name labels. | -| `monthNames` | `string[]` | — | Override the 12 month-name labels. | -| `nearbyMonthDays` | `boolean` | `true` | Show dimmed dates from adjacent months. | -| `hourFormat` | `'12'` \| `'24'` | `'24'` | Time format. | -| `enableSeconds` | `boolean` | `false` | Show seconds column. Note: iOS Safari's native datetime-local picker UI does not include a seconds wheel; pass `mobileNative={false}` if you need one on iOS. | -| `incrementHours` | `number` | `1` | Hour step. | -| `incrementMinutes` | `number` | `1` | Step between minute-wheel values (`1` = every minute, iOS-style). | -| `incrementSeconds` | `number` | `1` | Step between second-wheel values (only with `enableSeconds`). | -| `unselectableTimes` | `(d: Date) => boolean` | — | Block specific times. Blocked times are also rejected during manual typing. | -| `iconLeftName` | `string` | `'calendar-alt'` | Decorative left icon glyph for the wrapping `Control` (shown by default). Set `''` to hide. | -| `triggerIcon` | `boolean` | `true` | Show a clickable launcher button on the right that toggles the popover. Default `true`. | -| `triggerIconName` | `string` | `'chevron-down'` | Glyph for the right launcher button. | -| `audioTick` | `boolean` | `false` | Play a short audible tick on each time-wheel crossing. Default `false`. | -| `haptics` | `boolean` | `false` | Auto-route tactile feedback per wheel tick (vibrate on Android, audio thunk on iOS). Default `false`. | -| `labels` | `PickerLabels` | — | Optional translatable string overrides. | -| `className` | `string` | — | Additional CSS classes. | -| `ref` | `React.Ref` | — | Forwarded to the underlying element. | -| `name` | `string` | — | Form field name. | -| `form` | `string` | — | Optional id of the form the input belongs to. | -| `required` | `boolean` | `false` | Marks the field as required for native HTML form validation. | -| `...` | All standard `` attributes and Bulma helper props | — | See [Helper Props](../../helpers/usebulmaclasses.md) | +| Prop | Type | Default | Description | +| ------------------- | -------------------------------------------------------------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `label` | `React.ReactNode` | — | Field label. Automatically associated with the input via `htmlFor` — uses your `id` when provided, otherwise a generated one. Not wired in `inline` mode (no visible input to label) and dropped inside an outer `Field`. | +| `labelSize` | `'small'` \| `'normal'` \| `'medium'` \| `'large'` | — | Size for the label. | +| `labelProps` | `React.LabelHTMLAttributes & { [key: string]: unknown; }` | — | Props for the label element. An explicit `htmlFor` here overrides the automatic association (no id is generated then). | +| `horizontal` | `boolean` | `false` | Render the field with horizontal layout. | +| `iconLeft` | `IconProps` \| `React.ReactNode` | — | Icon props for the left icon. | +| `iconRight` | `IconProps` \| `React.ReactNode` | — | Icon props for the right icon. | +| `iconRightName` | `string` | — | Shortcut for the right icon name. | +| `iconLeftSize` | `'small'` \| `'medium'` \| `'large'` | — | Shortcut for left icon size. | +| `iconRightSize` | `'small'` \| `'medium'` \| `'large'` | — | Shortcut for right icon size. | +| `hasIconsLeft` | `boolean` | `false` | Force the left icon container. | +| `hasIconsRight` | `boolean` | `false` | Force the right icon container. | +| `isLoading` | `boolean` | `false` | Show a loading indicator on the control. | +| `isExpanded` | `boolean` | `false` | Expand the control to fill its container. | +| `controlSize` | `'small'` \| `'medium'` \| `'large'` | — | Size of the wrapping Control. | +| `message` | `React.ReactNode` | — | Help/validation text below the input. | +| `messageColor` | `'primary'` \| `'link'` \| `'info'` \| `'success'` \| `'warning'` \| `'danger'` | — | Message color. | +| `fieldClassName` | `string` | — | Additional CSS classes for the Field wrapper. | +| `controlClassName` | `string` | — | Additional CSS classes for the Control wrapper. | +| `value` | `Date` \| `null` | — | Controlled selected date-time. | +| `defaultValue` | `Date` \| `null` | — | Initial value for uncontrolled usage. | +| `onChange` | `(d: Date \| null) => void` | — | Fired when either the date or time portion changes. | +| `onOpen` | `() => void` | — | Fired when the popover opens. | +| `onClose` | `() => void` | — | Fired when the popover closes. | +| `min` | `Date` | — | Lower bound for the combined date-time. | +| `max` | `Date` | — | Upper bound for the combined date-time. | +| `disabled` | `boolean` | `false` | Disable the input. | +| `readOnly` | `boolean` | `false` | Read-only input. | +| `placeholder` | `string` | — | Placeholder text. | +| `format` | `Intl.DateTimeFormatOptions` \| `string` | `'YYYY-MM-DD HH:mm'` | Token format string or `Intl.DateTimeFormat` options. Default `'YYYY-MM-DD HH:mm'`. | +| `parse` | `(s: string) => Date \| null` | — | Custom parser. | +| `locale` | `string` | — | BCP-47 locale tag. | +| `inline` | `boolean` | `false` | Render the panel inline (no popover). | +| `mobileNative` | `boolean` \| `'auto'` | `'auto'` | Use `` on coarse-pointer devices. | +| `editable` | `boolean` | `true` | Allow segmented keyboard typing (type the date-time directly across all segments). `false` makes the field picker-only. | +| `popover` | `boolean` | `true` | Whether the calendar + time popover exists. `false` makes the field input-only (segmented typing with no popover). Default `true`. | +| `openOnFocus` | `boolean` | `true` | Open the popover on focus. Default `true`. | +| `closeOnSelect` | `boolean` | `false` | Off by default — users typically tweak both halves before committing. | +| `position` | `'bottom-left'` \| `'bottom-right'` \| `'top-left'` \| `'top-right'` \| `'auto'` | `'bottom-left'` | Popover anchor position. | +| `appendToBody` | `boolean` | `false` | Render the popover into `document.body` via portal. | +| `color` | `'primary'` \| `'link'` \| `'info'` \| `'success'` \| `'warning'` \| `'danger'` | — | Bulma color modifier for the input, also carried by the calendar and the time wheels, where it colors the selected date and the selection band. Today's date and the calendar's keyboard focus ring take the color's `-on-scheme` variant, which Bulma adjusts to contrast with the background, so pale colors stay readable; that makes `'primary'` a shade off the unset calendar, which uses plain `primary` for them. A focused wheel's ring is drawn inside the band in the color's `-invert`, like the selected value, so it shows on the fill. Unset, they use their `--bulma-dateinput-*` and `--bulma-timeinput-wheel-*` variables, which follow `primary` by default. The footer's time pill and Done button stay `primary` either way. | +| `size` | `'small'` \| `'medium'` \| `'large'` | — | Size variant. | +| `isRounded` | `boolean` | `false` | Rounded input corners. | +| `shouldDisableDate` | `(d: Date) => boolean` | — | Disable specific dates. Blocked dates are also rejected during manual typing (the predicate receives the full candidate date-time — prefer day-based checks). | +| `unselectableDates` | `Date[]` | — | Convenience array of disabled dates, matched by calendar day; also rejected by manual typing. | +| `firstDayOfWeek` | `0` \| `1` \| `2` \| `3` \| `4` \| `5` \| `6` | `0` | Day the calendar week starts on. | +| `dayNames` | `string[]` | — | Override the 7 day-name labels. | +| `monthNames` | `string[]` | — | Override the 12 month-name labels. | +| `nearbyMonthDays` | `boolean` | `true` | Show dimmed dates from adjacent months. | +| `hourFormat` | `'12'` \| `'24'` | `'24'` | Time format. | +| `enableSeconds` | `boolean` | `false` | Show seconds column. Note: iOS Safari's native datetime-local picker UI does not include a seconds wheel; pass `mobileNative={false}` if you need one on iOS. | +| `incrementHours` | `number` | `1` | Hour step. | +| `incrementMinutes` | `number` | `1` | Step between minute-wheel values (`1` = every minute, iOS-style). | +| `incrementSeconds` | `number` | `1` | Step between second-wheel values (only with `enableSeconds`). | +| `unselectableTimes` | `(d: Date) => boolean` | — | Block specific times. Blocked times are also rejected during manual typing. | +| `iconLeftName` | `string` | `'calendar-alt'` | Decorative left icon glyph for the wrapping `Control` (shown by default). Set `''` to hide. | +| `triggerIcon` | `boolean` | `true` | Show a clickable launcher button on the right that toggles the popover. Default `true`. | +| `triggerIconName` | `string` | `'chevron-down'` | Glyph for the right launcher button. | +| `audioTick` | `boolean` | `false` | Play a short audible tick on each time-wheel crossing. Default `false`. | +| `haptics` | `boolean` | `false` | Auto-route tactile feedback per wheel tick (vibrate on Android, audio thunk on iOS). Default `false`. | +| `labels` | `PickerLabels` | — | Optional translatable string overrides. | +| `className` | `string` | — | Additional CSS classes. | +| `ref` | `React.Ref` | — | Forwarded to the underlying element. | +| `name` | `string` | — | Form field name. | +| `form` | `string` | — | Optional id of the form the input belongs to. | +| `required` | `boolean` | `false` | Marks the field as required for native HTML form validation. | +| `...` | All standard `` attributes and Bulma helper props | — | See [Helper Props](../../helpers/usebulmaclasses.md) | @@ -922,6 +928,7 @@ When you pass an explicit token `format`, **that format is the source of truth f | `--bulma-dateinput-cell-selected-bg` ‡ | `$dateinput-cell-selected-bg` | `var(--bulma-primary)` | | `--bulma-dateinput-cell-selected-color` ‡ | `$dateinput-cell-selected-color` | `var(--bulma-primary-invert)` | | `--bulma-dateinput-cell-today-color` ‡ | `$dateinput-cell-today-color` | `var(--bulma-primary)` | +| `--bulma-dateinput-focus-ring-color` ‡ | `$dateinput-focus-ring-color` | `var(--bulma-primary)` | | `--bulma-dateinput-cell-disabled-color` ‡ | `$dateinput-cell-disabled-color` | `var(--bulma-text-weak)` | | `--bulma-dateinput-cell-other-month-color` ‡ | `$dateinput-cell-other-month-color` | `var(--bulma-text-weak)` | | `--bulma-dateinput-header-padding` ‡ | `$dateinput-header-padding` | `0.5rem 0` | @@ -947,7 +954,7 @@ When you pass an explicit token `format`, **that format is the source of truth f | `--bulma-timeinput-wheel-width` ‡ | `$timeinput-wheel-width` | `3rem` | | `--bulma-timeinput-wheel-item-height` ‡ | `$timeinput-wheel-item-height` | `2rem` | | `--bulma-timeinput-wheel-gap` ‡ | `$timeinput-wheel-gap` | `0.4rem` | -| `--bulma-timeinput-wheel-bg` ‡ | `$timeinput-wheel-bg` | `var(--bulma-scheme-main)` | +| `--bulma-timeinput-wheel-bg` ‡ | `$timeinput-wheel-bg` | `transparent` | | `--bulma-timeinput-wheel-color` ‡ | `$timeinput-wheel-color` | `var(--bulma-text)` | | `--bulma-timeinput-wheel-dim-color` ‡ | `$timeinput-wheel-dim-color` | `var(--bulma-text-weak)` | | `--bulma-timeinput-wheel-hover-bg` ‡ | `$timeinput-wheel-hover-bg` | `hsla(0, 0%, 50%, 0.13)` | @@ -992,3 +999,5 @@ When you pass an explicit token `format`, **that format is the source of truth f ‡ declared on a constituent element: values set via `className`, the `style` prop, or an ancestor are only inherited and lose — target the declaring element in your CSS. + +**Item height:** `--bulma-timeinput-wheel-item-height` (`$timeinput-wheel-item-height`) is registered, and nothing reads it. The component sets each wheel item's height inline, taller on small viewports, because the wheels position their items from that height in script. It stays registered so a Sass build that configures it keeps compiling. diff --git a/docs/docs/api/form/datetime/timeinput.md b/docs/docs/api/form/datetime/timeinput.md index 4e569fdab..c403feb95 100644 --- a/docs/docs/api/form/datetime/timeinput.md +++ b/docs/docs/api/form/datetime/timeinput.md @@ -984,68 +984,68 @@ Combine `incrementMinutes={5}` (or `15`/`30`) with `min` and `max` to build a ti -| Prop | Type | Default | Description | -| ------------------- | -------------------------------------------------------------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `label` | `React.ReactNode` | — | Field label. Automatically associated with the input via `htmlFor` — uses your `id` when provided, otherwise a generated one. Not wired in `inline` mode (no visible input to label) and dropped inside an outer `Field`. | -| `labelSize` | `'small'` \| `'normal'` \| `'medium'` \| `'large'` | — | Size for the label. | -| `labelProps` | `React.LabelHTMLAttributes & { [key: string]: unknown; }` | — | Props for the label element. An explicit `htmlFor` here overrides the automatic association (no id is generated then). | -| `horizontal` | `boolean` | `false` | Render the field with horizontal layout. | -| `iconLeft` | `IconProps` \| `React.ReactNode` | — | Icon props for the left icon. | -| `iconRight` | `IconProps` \| `React.ReactNode` | — | Icon props for the right icon. | -| `iconRightName` | `string` | — | Shortcut for the right icon name. | -| `iconLeftSize` | `'small'` \| `'medium'` \| `'large'` | — | Shortcut for left icon size. | -| `iconRightSize` | `'small'` \| `'medium'` \| `'large'` | — | Shortcut for right icon size. | -| `hasIconsLeft` | `boolean` | `false` | Force the left icon container. | -| `hasIconsRight` | `boolean` | `false` | Force the right icon container. | -| `isLoading` | `boolean` | `false` | Show a loading indicator on the control. | -| `isExpanded` | `boolean` | `false` | Expand the control to fill its container. | -| `controlSize` | `'small'` \| `'medium'` \| `'large'` | — | Size of the wrapping Control. | -| `message` | `React.ReactNode` | — | Help/validation text below the input. | -| `messageColor` | `'primary'` \| `'link'` \| `'info'` \| `'success'` \| `'warning'` \| `'danger'` | — | Color modifier for the help message. | -| `fieldClassName` | `string` | — | Additional CSS classes for the Field wrapper. | -| `controlClassName` | `string` | — | Additional CSS classes for the Control wrapper. | -| `value` | `Date` \| `null` | — | Controlled selected time (date portion is preserved). | -| `defaultValue` | `Date` \| `null` | — | Initial value for uncontrolled usage. | -| `onChange` | `(d: Date \| null) => void` | — | Fired when the value changes. | -| `onOpen` | `() => void` | — | Fired when the popover opens. | -| `onClose` | `() => void` | — | Fired when the popover closes. | -| `min` | `Date` | — | Earliest selectable time. | -| `max` | `Date` | — | Latest selectable time. | -| `disabled` | `boolean` | `false` | Disable the input. | -| `readOnly` | `boolean` | `false` | Make the input read-only. | -| `placeholder` | `string` | — | Placeholder text for the input. | -| `format` | `Intl.DateTimeFormatOptions` \| `string` | `(see below)` | Token format string or `Intl.DateTimeFormat` options. | -| `parse` | `(s: string) => Date \| null` | — | Custom parser. | -| `locale` | `string` | — | BCP-47 locale tag for Intl formatting. | -| `inline` | `boolean` | `false` | Render the spinner inline (no popover). | -| `mobileNative` | `boolean` \| `'auto'` | `'auto'` | Use `` on coarse-pointer + small-viewport devices. | -| `editable` | `boolean` | `true` | Allow segmented keyboard typing in the input (type the time directly, auto-advancing across segments). `false` makes the field picker-only. | -| `popover` | `boolean` | `true` | Whether the spinner popover exists. `false` makes the field input-only (segmented typing, no popover). | -| `openOnFocus` | `boolean` | `true` | Open the popover when the input is focused. | -| `closeOnSelect` | `boolean` | `false` | Close the popover after a time is selected (off by default). | -| `position` | `'bottom-left'` \| `'bottom-right'` \| `'top-left'` \| `'top-right'` \| `'auto'` | `'bottom-left'` | Popover anchor position relative to the input. | -| `appendToBody` | `boolean` | `false` | Render the popover into `document.body` via portal. | -| `color` | `'primary'` \| `'link'` \| `'info'` \| `'success'` \| `'warning'` \| `'danger'` | — | Bulma color modifier for the input, also carried by the wheels, where it colors the selection band and the keyboard focus ring. Unset, the wheels use `--bulma-timeinput-wheel-selected-bg`, which defaults to `primary`. | -| `size` | `'small'` \| `'medium'` \| `'large'` | — | Size variant. | -| `isRounded` | `boolean` | `false` | Render the input with rounded corners. | -| `hourFormat` | `'12'` \| `'24'` | `'24'` | Hour format. `'12'` shows an AM/PM toggle. | -| `enableSeconds` | `boolean` | `false` | Show a seconds column. Note: iOS Safari's native time picker UI does not include a seconds wheel; pass `mobileNative={false}` if you need one on iOS. | -| `incrementHours` | `number` | `1` | Hour step for the spinner. | -| `incrementMinutes` | `number` | `1` | Minute step. Combine with `min`/`max` for slot-style pickers. | -| `incrementSeconds` | `number` | `1` | Second step. Default `1`. | -| `unselectableTimes` | `(d: Date) => boolean` | — | Predicate returning `true` for times that should be skipped. Blocked times are also rejected during manual typing. | -| `iconLeftName` | `string` | `'clock'` | Decorative left icon glyph for the wrapping `Control` (shown by default). Set `''` to hide. | -| `triggerIcon` | `boolean` | `true` | Show a clickable launcher button on the right that toggles the popover. Default `true`. | -| `triggerIconName` | `string` | `'chevron-down'` | Glyph for the right launcher button. | -| `labels` | `PickerLabels` | — | Optional translatable string overrides. | -| `audioTick` | `boolean` | `false` | Play a short audible click on each wheel-item crossing. Substitute for haptic feedback on iOS Safari (which has no web haptic API as of May 2026); on Android, `navigator.vibrate(5)` fires automatically regardless. | -| `haptics` | `boolean` | `false` | Auto-route platform-appropriate feedback: vibrate on Android (already happening), audio thunk on iOS (where vibrate is unavailable). One switch instead of platform-sniffing on the consumer side. `audioTick={true}` always wins. | -| `name` | `string` | — | Form field name. | -| `form` | `string` | — | Form id the input belongs to. | -| `required` | `boolean` | `false` | Marks the input as required. | -| `className` | `string` | — | Additional CSS classes for the input. | -| `ref` | `React.Ref` | — | Forwarded to the underlying ``. | -| `...` | All standard `` attributes and Bulma helper props | — | See [Helper Props](../../helpers/usebulmaclasses.md) | +| Prop | Type | Default | Description | +| ------------------- | -------------------------------------------------------------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `label` | `React.ReactNode` | — | Field label. Automatically associated with the input via `htmlFor` — uses your `id` when provided, otherwise a generated one. Not wired in `inline` mode (no visible input to label) and dropped inside an outer `Field`. | +| `labelSize` | `'small'` \| `'normal'` \| `'medium'` \| `'large'` | — | Size for the label. | +| `labelProps` | `React.LabelHTMLAttributes & { [key: string]: unknown; }` | — | Props for the label element. An explicit `htmlFor` here overrides the automatic association (no id is generated then). | +| `horizontal` | `boolean` | `false` | Render the field with horizontal layout. | +| `iconLeft` | `IconProps` \| `React.ReactNode` | — | Icon props for the left icon. | +| `iconRight` | `IconProps` \| `React.ReactNode` | — | Icon props for the right icon. | +| `iconRightName` | `string` | — | Shortcut for the right icon name. | +| `iconLeftSize` | `'small'` \| `'medium'` \| `'large'` | — | Shortcut for left icon size. | +| `iconRightSize` | `'small'` \| `'medium'` \| `'large'` | — | Shortcut for right icon size. | +| `hasIconsLeft` | `boolean` | `false` | Force the left icon container. | +| `hasIconsRight` | `boolean` | `false` | Force the right icon container. | +| `isLoading` | `boolean` | `false` | Show a loading indicator on the control. | +| `isExpanded` | `boolean` | `false` | Expand the control to fill its container. | +| `controlSize` | `'small'` \| `'medium'` \| `'large'` | — | Size of the wrapping Control. | +| `message` | `React.ReactNode` | — | Help/validation text below the input. | +| `messageColor` | `'primary'` \| `'link'` \| `'info'` \| `'success'` \| `'warning'` \| `'danger'` | — | Color modifier for the help message. | +| `fieldClassName` | `string` | — | Additional CSS classes for the Field wrapper. | +| `controlClassName` | `string` | — | Additional CSS classes for the Control wrapper. | +| `value` | `Date` \| `null` | — | Controlled selected time (date portion is preserved). | +| `defaultValue` | `Date` \| `null` | — | Initial value for uncontrolled usage. | +| `onChange` | `(d: Date \| null) => void` | — | Fired when the value changes. | +| `onOpen` | `() => void` | — | Fired when the popover opens. | +| `onClose` | `() => void` | — | Fired when the popover closes. | +| `min` | `Date` | — | Earliest selectable time. | +| `max` | `Date` | — | Latest selectable time. | +| `disabled` | `boolean` | `false` | Disable the input. | +| `readOnly` | `boolean` | `false` | Make the input read-only. | +| `placeholder` | `string` | — | Placeholder text for the input. | +| `format` | `Intl.DateTimeFormatOptions` \| `string` | `(see below)` | Token format string or `Intl.DateTimeFormat` options. | +| `parse` | `(s: string) => Date \| null` | — | Custom parser. | +| `locale` | `string` | — | BCP-47 locale tag for Intl formatting. | +| `inline` | `boolean` | `false` | Render the spinner inline (no popover). | +| `mobileNative` | `boolean` \| `'auto'` | `'auto'` | Use `` on coarse-pointer + small-viewport devices. | +| `editable` | `boolean` | `true` | Allow segmented keyboard typing in the input (type the time directly, auto-advancing across segments). `false` makes the field picker-only. | +| `popover` | `boolean` | `true` | Whether the spinner popover exists. `false` makes the field input-only (segmented typing, no popover). | +| `openOnFocus` | `boolean` | `true` | Open the popover when the input is focused. | +| `closeOnSelect` | `boolean` | `false` | Close the popover after a time is selected (off by default). | +| `position` | `'bottom-left'` \| `'bottom-right'` \| `'top-left'` \| `'top-right'` \| `'auto'` | `'bottom-left'` | Popover anchor position relative to the input. | +| `appendToBody` | `boolean` | `false` | Render the popover into `document.body` via portal. | +| `color` | `'primary'` \| `'link'` \| `'info'` \| `'success'` \| `'warning'` \| `'danger'` | — | Bulma color modifier for the input, also carried by the wheels, where it colors the selection band. A focused wheel's keyboard focus ring is drawn inside the band in the color's `-invert`, like the selected value, so it shows on the fill. Unset, the wheels use `--bulma-timeinput-wheel-selected-bg`, which defaults to `primary`. | +| `size` | `'small'` \| `'medium'` \| `'large'` | — | Size variant. | +| `isRounded` | `boolean` | `false` | Render the input with rounded corners. | +| `hourFormat` | `'12'` \| `'24'` | `'24'` | Hour format. `'12'` shows an AM/PM toggle. | +| `enableSeconds` | `boolean` | `false` | Show a seconds column. Note: iOS Safari's native time picker UI does not include a seconds wheel; pass `mobileNative={false}` if you need one on iOS. | +| `incrementHours` | `number` | `1` | Hour step for the spinner. | +| `incrementMinutes` | `number` | `1` | Minute step. Combine with `min`/`max` for slot-style pickers. | +| `incrementSeconds` | `number` | `1` | Second step. Default `1`. | +| `unselectableTimes` | `(d: Date) => boolean` | — | Predicate returning `true` for times that should be skipped. Blocked times are also rejected during manual typing. | +| `iconLeftName` | `string` | `'clock'` | Decorative left icon glyph for the wrapping `Control` (shown by default). Set `''` to hide. | +| `triggerIcon` | `boolean` | `true` | Show a clickable launcher button on the right that toggles the popover. Default `true`. | +| `triggerIconName` | `string` | `'chevron-down'` | Glyph for the right launcher button. | +| `labels` | `PickerLabels` | — | Optional translatable string overrides. | +| `audioTick` | `boolean` | `false` | Play a short audible click on each wheel-item crossing. Substitute for haptic feedback on iOS Safari (which has no web haptic API as of May 2026); on Android, `navigator.vibrate(5)` fires automatically regardless. | +| `haptics` | `boolean` | `false` | Auto-route platform-appropriate feedback: vibrate on Android (already happening), audio thunk on iOS (where vibrate is unavailable). One switch instead of platform-sniffing on the consumer side. `audioTick={true}` always wins. | +| `name` | `string` | — | Form field name. | +| `form` | `string` | — | Form id the input belongs to. | +| `required` | `boolean` | `false` | Marks the input as required. | +| `className` | `string` | — | Additional CSS classes for the input. | +| `ref` | `React.Ref` | — | Forwarded to the underlying ``. | +| `...` | All standard `` attributes and Bulma helper props | — | See [Helper Props](../../helpers/usebulmaclasses.md) | @@ -1074,7 +1074,7 @@ When you pass an explicit token `format`, **that format is the source of truth f | `--bulma-timeinput-wheel-width` ‡ | `$timeinput-wheel-width` | `3rem` | | `--bulma-timeinput-wheel-item-height` ‡ | `$timeinput-wheel-item-height` | `2rem` | | `--bulma-timeinput-wheel-gap` ‡ | `$timeinput-wheel-gap` | `0.4rem` | -| `--bulma-timeinput-wheel-bg` ‡ | `$timeinput-wheel-bg` | `var(--bulma-scheme-main)` | +| `--bulma-timeinput-wheel-bg` ‡ | `$timeinput-wheel-bg` | `transparent` | | `--bulma-timeinput-wheel-color` ‡ | `$timeinput-wheel-color` | `var(--bulma-text)` | | `--bulma-timeinput-wheel-dim-color` ‡ | `$timeinput-wheel-dim-color` | `var(--bulma-text-weak)` | | `--bulma-timeinput-wheel-hover-bg` ‡ | `$timeinput-wheel-hover-bg` | `hsla(0, 0%, 50%, 0.13)` | @@ -1119,3 +1119,5 @@ When you pass an explicit token `format`, **that format is the source of truth f ‡ declared on a constituent element: values set via `className`, the `style` prop, or an ancestor are only inherited and lose — target the declaring element in your CSS. + +**Item height:** `--bulma-timeinput-wheel-item-height` (`$timeinput-wheel-item-height`) is registered, and nothing reads it. The component sets each wheel item's height inline, taller on small viewports, because the wheels position their items from that height in script. It stays registered so a Sass build that configures it keeps compiling. diff --git a/scripts/color-tuple-css.test.mjs b/scripts/color-tuple-css.test.mjs index ef03f5dfb..d6910ea58 100644 --- a/scripts/color-tuple-css.test.mjs +++ b/scripts/color-tuple-css.test.mjs @@ -33,11 +33,11 @@ * the shape of the defect that started this. Several do emit it without * warning and are invisible here. Narrowing `color` to a CSS-backed union does * not make that safe, because the union says nothing about the element the - * class lands on: the time wheels put `is-` on an element with no - * colour rule until #701, and that element now has a case of its own below. - * Grep the emission rather than trusting a list here. Closing the gap wants - * the library to say which components warn, rather than a test guessing from - * source. + * class lands on: the time wheels until #701, and the calendar for longer, put + * `is-` on an element with no colour rule, and each of those elements + * now has a case of its own below. Grep the emission rather than trusting a + * list here. Closing the gap wants the library to say which components warn, + * rather than a test guessing from source. * * `codeOnly` is a textual strip, with the limit that implies: a comment * opener inside a string literal removes real code along with itself — `//` @@ -78,7 +78,7 @@ const DEPRECATIONS = join( 'helpers', 'colorDeprecations.ts' ); -const TIME_WHEELS = join(SRC, 'form', '_pickerInternals', 'TimeWheels.tsx'); +const PICKER_INTERNALS = join(SRC, 'form', '_pickerInternals'); /** * The stylesheet, or an actionable failure. @@ -2652,49 +2652,64 @@ describe('the colour tuples agree with the shipped stylesheet', () => { }); /** - * The colours the time wheels' own `color` prop accepts. + * The colours a picker internal's own `color` prop accepts. * - * Read from the wheel rather than from the components that feed it, because - * the wheel is where the class lands and every feeder has to pass a value - * this type admits, so one read covers `TimeInput`, `DateTimeInput` and any - * later caller without a list of them here. + * Read from the internal rather than from the components that feed it, + * because the internal is where the class lands and every feeder has to pass + * a value this type admits, so one read covers `TimeInput`, `DateInput`, + * `DateTimeInput` and any later caller without a list of them here. */ -function timeWheelColors() { - const source = codeOnly(readFileSync(TIME_WHEELS, 'utf8')); - const props = /export interface TimeWheelsProps\s*\{([\s\S]*?)\n\}/.exec( - source - ); - const color = props && /\bcolor\?:\s*([^;]+);/.exec(props[1]); +function acceptedColors(file, props) { + const source = codeOnly(readFileSync(file, 'utf8')); + const body = new RegExp( + `export interface ${props}\\s*\\{([\\s\\S]*?)\\n\\}` + ).exec(source); + const color = body && /\bcolor\?:\s*([^;]+);/.exec(body[1]); assert.ok( color, - `could not find \`TimeWheelsProps.color\` in ${TIME_WHEELS}, so the ` + - 'wheel colours cannot be read. Fix the pattern in the same change ' + - 'that moved it.' + `could not find \`${props}.color\` in ${file}, so its colours cannot ` + + 'be read. Fix the pattern in the same change that moved it.' ); const values = [...color[1].matchAll(QUOTED)].map(m => m[2]); assert.ok( values.length > 0, - '`TimeWheelsProps.color` named no literal colour, so the check below ' + - 'would pass on nothing. A union spelled through an alias hides its ' + - 'literals from this read.' + `\`${props}.color\` named no literal colour, so the check below would ` + + 'pass on nothing. A union spelled through an alias hides its literals ' + + 'from this read.' ); return values; } -describe('the time wheels style every colour they accept', () => { - // Nothing on the wheels calls `warnUnstyledColor`, so the comparison above - // never reaches them, and `is-` sat dead on every wheel until #701. - // The wheel rule is asked for directly instead. - it('ships a `.timeinput-wheel.is-` rule for each', () => { - const css = stylesheet(); - for (const color of timeWheelColors()) { - assert.ok( - shipsClass(css, `timeinput-wheel.is-${color}`), - `the time wheels accept \`color="${color}"\` and put ` + - `\`is-${color}\` on each wheel, and the stylesheet has no ` + - `\`.timeinput-wheel.is-${color}\` rule, so the value renders ` + - 'nothing. The colour loop in `_timeinput.scss` needs it.' - ); - } - }); +// Nothing on these calls `warnUnstyledColor`, so the comparison above never +// reaches them, and each put `is-` on an element no rule styled: the +// wheels until #701, the calendar for longer. The rule for the element the +// class lands on is asked for directly instead. +describe('the picker internals style every colour they accept', () => { + for (const { file, props, root, partial } of [ + { + file: join(PICKER_INTERNALS, 'TimeWheels.tsx'), + props: 'TimeWheelsProps', + root: 'timeinput-wheel', + partial: '_timeinput.scss', + }, + { + file: join(PICKER_INTERNALS, 'Calendar.tsx'), + props: 'CalendarProps', + root: 'dateinput', + partial: '_dateinput.scss', + }, + ]) { + it(`ships a \`.${root}.is-\` rule for each in \`${props}.color\``, () => { + const css = stylesheet(); + for (const color of acceptedColors(file, props)) { + assert.ok( + shipsClass(css, `${root}.is-${color}`), + `\`${props}.color\` admits "${color}", which lands as ` + + `\`is-${color}\` on \`.${root}\`, and the stylesheet has no ` + + `\`.${root}.is-${color}\` rule, so the value renders nothing. ` + + `The colour loop in \`${partial}\` needs it.` + ); + } + }); + } }); diff --git a/skills/bestax-theming/references/css-variables.md b/skills/bestax-theming/references/css-variables.md index b8c818877..0786d8916 100644 --- a/skills/bestax-theming/references/css-variables.md +++ b/skills/bestax-theming/references/css-variables.md @@ -232,8 +232,9 @@ own-selector override rule applies. `--bulma-dateinput-cell-radius`, `--bulma-dateinput-cell-selected-bg`, `--bulma-dateinput-cell-selected-color`, `--bulma-dateinput-cell-size`, `--bulma-dateinput-cell-today-color`, `--bulma-dateinput-day-name-color`, -`--bulma-dateinput-day-name-size`, `--bulma-dateinput-header-padding`, -`--bulma-dateinput-min-width`, `--bulma-dateinput-nav-button-size` +`--bulma-dateinput-day-name-size`, `--bulma-dateinput-focus-ring-color`, +`--bulma-dateinput-header-padding`, `--bulma-dateinput-min-width`, +`--bulma-dateinput-nav-button-size` ### DateTimeInput @@ -385,6 +386,9 @@ Declared on the compound `.button.link-button` — see the compound-selector exc `--bulma-timeinput-wheel-radius`, `--bulma-timeinput-wheel-selected-bg`, `--bulma-timeinput-wheel-selected-color`, `--bulma-timeinput-wheel-width` +`--bulma-timeinput-wheel-item-height` is registered but has no effect: the component sets each +wheel item's height inline. + ### Toast `--bulma-toast-action-hover-opacity`, `--bulma-toast-action-radius`,