From b67198ae7642ece22feadafa0ede90fd58a3bb63 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Mon, 2 Nov 2026 21:10:56 -0800 Subject: [PATCH] feat(lab): CircleCheckIndicator, the iOS multiple-selection circle iOS marks multiple selection with a circle: a table row's edit-mode control and a list's `.multiselect()` accessory, an empty ring that fills with a white checkmark. Astryx's only multiSelection indicator is the checkbox box, and rounding it gives neither the clear ring nor UIKit's checkmark. CircleCheckIndicator is a multiSelection-family indicator in Lab. A theme maps it to `checkbox`, and every CheckboxInput and CheckboxList draws it, keeping its checkbox semantics and focus ring. Its geometry is UIKit's, measured on iOS 26.2 at two text sizes and kept beside it; its colours are the theme's. Its mark fades over the theme duration on every pointer, and Reduce Motion makes that change instant. It paints its own round press: hover and a mouse press come through the row's scope marker, and a touch press from the image that only a CheckboxInput row hands down, so a mapped menu checkbox item paints its press once. In forced colors a system-coloured border draws the ring. It comes with a story, a CLI discover entry and a registry route. --- .../cli-discover-circle-check-indicator.md | 7 + .../stories/CircleCheckIndicator.stories.tsx | 105 ++++ internal/shadcn-registry/routes.lock.json | 5 + .../assets/discover/official-packages.json | 4 + .../CircleCheckIndicator.doc.mjs | 215 +++++++ .../CircleCheckIndicator.test.tsx | 134 +++++ .../CircleCheckIndicator.tsx | 248 ++++++++ ...CheckIndicator.interaction.browser.spec.ts | 567 ++++++++++++++++++ .../circleCheck.stylex.ts | 93 +++ .../CircleCheckIndicator/circleCheck.table.ts | 78 +++ .../CircleCheckIndicator/circleCheck.test.tsx | 188 ++++++ .../lab/src/CircleCheckIndicator/index.ts | 7 + packages/lab/src/index.ts | 4 + 13 files changed, 1655 insertions(+) create mode 100644 .changeset/cli-discover-circle-check-indicator.md create mode 100644 apps/storybook/stories/CircleCheckIndicator.stories.tsx create mode 100644 packages/lab/src/CircleCheckIndicator/CircleCheckIndicator.doc.mjs create mode 100644 packages/lab/src/CircleCheckIndicator/CircleCheckIndicator.test.tsx create mode 100644 packages/lab/src/CircleCheckIndicator/CircleCheckIndicator.tsx create mode 100644 packages/lab/src/CircleCheckIndicator/__tests__/CircleCheckIndicator.interaction.browser.spec.ts create mode 100644 packages/lab/src/CircleCheckIndicator/circleCheck.stylex.ts create mode 100644 packages/lab/src/CircleCheckIndicator/circleCheck.table.ts create mode 100644 packages/lab/src/CircleCheckIndicator/circleCheck.test.tsx create mode 100644 packages/lab/src/CircleCheckIndicator/index.ts diff --git a/.changeset/cli-discover-circle-check-indicator.md b/.changeset/cli-discover-circle-check-indicator.md new file mode 100644 index 0000000000000..54dd8fdef8513 --- /dev/null +++ b/.changeset/cli-discover-circle-check-indicator.md @@ -0,0 +1,7 @@ +--- +'@astryxdesign/cli': patch +--- + +[feat] `astryx discover` lists the experimental CircleCheckIndicator component from `@astryxdesign/lab`. + +@vjeux diff --git a/apps/storybook/stories/CircleCheckIndicator.stories.tsx b/apps/storybook/stories/CircleCheckIndicator.stories.tsx new file mode 100644 index 0000000000000..8b5eac6f82911 --- /dev/null +++ b/apps/storybook/stories/CircleCheckIndicator.stories.tsx @@ -0,0 +1,105 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. + +import type {Meta, StoryObj} from '@storybook/react'; +import {useState} from 'react'; +import {CircleCheckIndicator} from '@astryxdesign/lab/CircleCheckIndicator'; +import {CheckboxInput} from '@astryxdesign/core/CheckboxInput'; +import {CheckboxList, CheckboxListItem} from '@astryxdesign/core/CheckboxList'; +import {HStack, VStack} from '@astryxdesign/core/Layout'; +import {Text} from '@astryxdesign/core/Text'; +import {Theme, defineTheme} from '@astryxdesign/core/theme'; + +const meta: Meta = { + title: 'Lab/CircleCheckIndicator', + component: CircleCheckIndicator, + tags: ['autodocs'], + argTypes: { + state: { + control: 'inline-radio', + options: ['unchecked', 'checked', 'indeterminate'], + }, + size: {control: 'inline-radio', options: ['sm', 'md']}, + isDisabled: {control: 'boolean'}, + }, + args: {state: 'checked', size: 'md', isDisabled: false}, + parameters: { + docs: { + description: { + component: + 'The iOS multiple-selection circle. Decorative: map it to `checkbox` in a theme so CheckboxInput and CheckboxList draw it and keep their semantics.', + }, + }, + }, +}; + +export default meta; +type Story = StoryObj; + +export const Default: Story = {}; + +export const States: Story = { + render: () => ( + + {(['md', 'sm'] as const).map(size => ( + + + {size} + + + + + + + + ))} + + ), +}; + +const circleTheme = defineTheme({ + name: 'circle-check-indicator-demo', + indicators: {checkbox: CircleCheckIndicator}, +}); + +/** + * A theme maps the circle to `checkbox`: the list keeps its group, its + * checkboxes, its focus ring and its press, and draws circles. + */ +export const MappedCheckboxList: Story = { + render: function MappedCheckboxListStory(_args, context) { + const [value, setValue] = useState(['beach']); + return ( + + + + + + + + + ); + }, +}; + +export const MappedCheckboxInput: Story = { + render: function MappedCheckboxInputStory(_args, context) { + const [value, setValue] = useState(false); + return ( + + + + + + + + ); + }, +}; diff --git a/internal/shadcn-registry/routes.lock.json b/internal/shadcn-registry/routes.lock.json index 70936da26b23d..d934cfc0ca88d 100644 --- a/internal/shadcn-registry/routes.lock.json +++ b/internal/shadcn-registry/routes.lock.json @@ -567,6 +567,11 @@ "path": "components/lab/chat-unread-divider", "aliases": [] }, + { + "name": "component-lab-circle-check-indicator", + "path": "components/lab/circle-check-indicator", + "aliases": [] + }, { "name": "component-lab-circular-progress", "path": "components/lab/circular-progress", diff --git a/packages/cli/assets/discover/official-packages.json b/packages/cli/assets/discover/official-packages.json index 3a1276fa7dd9a..5999288565e85 100644 --- a/packages/cli/assets/discover/official-packages.json +++ b/packages/cli/assets/discover/official-packages.json @@ -100,6 +100,10 @@ "kind": "component", "name": "ChatUnreadDivider" }, + { + "kind": "component", + "name": "CircleCheckIndicator" + }, { "kind": "component", "name": "CircularProgress" diff --git a/packages/lab/src/CircleCheckIndicator/CircleCheckIndicator.doc.mjs b/packages/lab/src/CircleCheckIndicator/CircleCheckIndicator.doc.mjs new file mode 100644 index 0000000000000..b49313f6d1671 --- /dev/null +++ b/packages/lab/src/CircleCheckIndicator/CircleCheckIndicator.doc.mjs @@ -0,0 +1,215 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. + +/** @type {import('@astryxdesign/cli/authoring').ComponentDoc} */ +export const docs = { + name: 'CircleCheckIndicator', + displayName: 'Circle Check Indicator', + category: 'Form Controls', + keywords: [ + 'indicator', + 'checkbox', + 'circle', + 'check', + 'multiselect', + 'selection', + 'edit mode', + 'ios', + 'mark', + ], + description: + 'The iOS multiple-selection mark: an empty circle, a filled circle with a checkmark, or a filled circle with a bar for the partial state. A checkbox-family indicator: map it to `checkbox` with defineTheme({indicators}) and every CheckboxInput and CheckboxList draws it. Decorative (aria-hidden); the owning control keeps the input, role, accessible name, focus, and keyboard behavior. Its colors fade over the theme duration on every pointer and change at once under Reduce Motion.', + props: [ + { + name: 'state', + type: "'unchecked' | 'checked' | 'indeterminate'", + description: + 'Which state to draw. The unchecked circle is an empty ring, not nothing.', + required: true, + }, + { + name: 'size', + type: "'sm' | 'md'", + description: + 'Control size. The circle draws at UIKit’s diameters, 18px (sm) or 21.8px (md), centred in the host’s 20px or 24px slot.', + default: "'md'", + }, + { + name: 'isDisabled', + type: 'boolean', + description: + 'Draws the disabled look. Purely visual; the owning control keeps the disabled semantics.', + default: 'false', + }, + { + name: 'children', + type: 'ReactNode', + description: + 'Content drawn inside the circle instead of the mark, e.g. the loading Spinner CheckboxInput passes while a change is pending.', + }, + { + name: 'xstyle', + type: 'StyleXStyles', + description: + 'StyleX styles for layout customization (margins, positioning, sizing). Must be a stylex.create() value, not an inline style object like style={{}}.', + }, + ], + theming: { + targets: [ + { + className: 'astryx-circle-check-indicator', + visualProps: ['size', 'checked', 'disabled'], + }, + {className: 'astryx-circle-check-indicator-check', visualProps: ['size']}, + {className: 'astryx-circle-check-indicator-dash', visualProps: ['size']}, + ], + }, + usage: { + description: + 'Use it where iOS shows a selection circle: the rows of a list in edit mode, and multiple-choice sets whose product follows iOS. Map it to `checkbox` in a theme to change every checkbox at once, or render it in a row you lay out yourself.', + bestPractices: [ + { + guidance: true, + description: + 'Map it with defineTheme({indicators: {checkbox: CircleCheckIndicator}}) so CheckboxInput and CheckboxList keep their semantics and focus ring.', + }, + { + guidance: true, + description: + 'Map it only in a theme meant for iOS. It draws the circle on every platform, and Android marks multiple choice with a square box.', + }, + { + guidance: true, + description: + 'Keep a visible label beside it; the circle is decorative and announces nothing.', + }, + { + guidance: false, + description: + 'Use it for a single choice; a radio, or a checkmark on the chosen row, says "one of these".', + }, + { + guidance: false, + description: + 'Give it a role, a label or a tab stop; the owning control has those.', + }, + ], + }, +}; + +/** @type {import('@astryxdesign/cli/authoring').ComponentDoc} */ +export const docsZh = { + name: 'CircleCheckIndicator', + displayName: 'Circle Check Indicator', + description: + 'iOS 的多选标记:空心圆、带对勾的实心圆,或表示部分选中的带横线实心圆。属于复选框家族的指示器:通过 defineTheme({indicators}) 映射到 `checkbox` 后,所有 CheckboxInput 和 CheckboxList 都会绘制它。仅作装饰(aria-hidden);输入、角色、无障碍名称、焦点和键盘行为由所属控件负责。颜色在任何指针下都按主题时长渐变,开启减弱动态效果时立即切换。', + props: [ + { + name: 'state', + type: "'unchecked' | 'checked' | 'indeterminate'", + description: '要绘制的状态。未选中时是一个空心圆环,而不是什么都不画。', + required: true, + }, + { + name: 'size', + type: "'sm' | 'md'", + description: + '控件尺寸。圆圈按 UIKit 的直径绘制:sm 为 18px,md 为 21.8px,居中于宿主 20px 或 24px 的位置。', + default: "'md'", + }, + { + name: 'isDisabled', + type: 'boolean', + description: '绘制禁用外观。仅影响视觉;禁用语义由所属控件负责。', + default: 'false', + }, + { + name: 'children', + type: 'ReactNode', + description: + '绘制在圆内、替代标记的内容,例如 CheckboxInput 在变更进行中传入的加载 Spinner。', + }, + { + name: 'xstyle', + type: 'StyleXStyles', + description: + '用于布局自定义的 StyleX 样式(外边距、定位、尺寸)。必须是 stylex.create() 的值,而非内联样式对象如 style={{}}。', + }, + ], + theming: { + targets: [ + { + className: 'astryx-circle-check-indicator', + visualProps: ['size', 'checked', 'disabled'], + }, + {className: 'astryx-circle-check-indicator-check', visualProps: ['size']}, + {className: 'astryx-circle-check-indicator-dash', visualProps: ['size']}, + ], + }, + usage: { + description: + '用在 iOS 显示选择圆圈的地方:编辑模式下的列表行,以及遵循 iOS 的多选集合。在主题中将其映射到 `checkbox` 可一次替换所有复选框,也可以在自行布局的行中直接渲染。', + bestPractices: [ + { + guidance: true, + description: + '使用 defineTheme({indicators: {checkbox: CircleCheckIndicator}}) 映射,使 CheckboxInput 和 CheckboxList 保留其语义和焦点环。', + }, + { + guidance: true, + description: + '只在面向 iOS 的主题中映射它。它在所有平台上都绘制圆圈,而 Android 用方形复选框表示多选。', + }, + { + guidance: true, + description: '在旁边保留可见标签;圆圈仅作装饰,不会被朗读。', + }, + { + guidance: false, + description: '用于单选;单选按钮或所选行上的对勾表示“其中之一”。', + }, + { + guidance: false, + description: '为其添加角色、标签或 Tab 停靠点;这些属于所属控件。', + }, + ], + }, +}; + +/** @type {import('@astryxdesign/cli/authoring').ComponentTranslationDoc} */ +export const docsDense = { + description: + 'iOS multiselect circle: empty ring / filled circle + check / filled circle + bar. Checkbox-family indicator; map to `checkbox` via defineTheme({indicators}).', + usage: { + description: + 'For iOS-style selection circles: edit-mode list rows and multiple-choice sets. Map it to `checkbox` in a theme, or render it in your own row.', + bestPractices: [ + { + guidance: true, + description: + 'Map via defineTheme({indicators: {checkbox: CircleCheckIndicator}}); hosts keep semantics + focus ring.', + }, + { + guidance: true, + description: 'Keep a visible label; the circle is decorative.', + }, + { + guidance: false, + description: + 'Use for a single choice (radio or row checkmark instead).', + }, + { + guidance: false, + description: + 'Add role, label or tabIndex; the owning control has them.', + }, + ], + }, + propDescriptions: { + state: + "'unchecked' (empty ring) | 'checked' (check) | 'indeterminate' (bar).", + size: "'sm' an 18px circle | 'md' a 21.8px circle (in a 20px or 24px slot).", + isDisabled: 'Disabled look only; owner keeps semantics.', + children: 'Drawn inside the circle instead of the mark (e.g. Spinner).', + xstyle: 'StyleX layout styles; must be stylex.create() value.', + }, +}; diff --git a/packages/lab/src/CircleCheckIndicator/CircleCheckIndicator.test.tsx b/packages/lab/src/CircleCheckIndicator/CircleCheckIndicator.test.tsx new file mode 100644 index 0000000000000..a6da9e5dde43b --- /dev/null +++ b/packages/lab/src/CircleCheckIndicator/CircleCheckIndicator.test.tsx @@ -0,0 +1,134 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. + +/** + * @file CircleCheckIndicator.test.tsx + * @input vitest, Testing Library, CircleCheckIndicator, and core's + * CheckboxInput and CheckboxList with a theme that maps `checkbox` + * @output Unit tests for the theme target and its state attributes, and the + * mark drawn per state (a ring, a check, a bar). They also cover children + * that replace the mark, the decorative semantics and the theme mapping + * into core's checkbox hosts. + * @position Testing; validates CircleCheckIndicator.tsx. The touch clock is + * circleCheck.test.tsx; the real-engine proof is + * __tests__/CircleCheckIndicator.interaction.browser.spec.ts + * + * SYNC: When CircleCheckIndicator.tsx changes, update tests to match. + */ + +import {describe, expect, it} from 'vitest'; +import {render, screen, fireEvent} from '@testing-library/react'; +import {useState} from 'react'; +import {CheckboxInput} from '@astryxdesign/core/CheckboxInput'; +import {CheckboxList, CheckboxListItem} from '@astryxdesign/core/CheckboxList'; +import {Theme, defineTheme} from '@astryxdesign/core/theme'; +import {CircleCheckIndicator} from './CircleCheckIndicator'; + +const circleTheme = defineTheme({ + name: 'circle-check-test', + indicators: {checkbox: CircleCheckIndicator}, +}); + +/** The visible mark: whether the check and the bar display. */ +function marks(root: Element) { + const check = root.querySelector('.astryx-circle-check-indicator-check'); + const dash = root.querySelector('.astryx-circle-check-indicator-dash'); + if (check == null || dash == null) { + throw new Error('the mark elements are missing'); + } + return { + check: getComputedStyle(check).display !== 'none', + dash: getComputedStyle(dash).display !== 'none', + }; +} + +describe('CircleCheckIndicator', () => { + it('renders its theme target with state and size, decoratively', () => { + render(); + const circle = document.querySelector('.astryx-circle-check-indicator'); + expect(circle).toHaveAttribute('data-checked', 'checked'); + expect(circle).toHaveAttribute('data-size', 'sm'); + expect(circle).toHaveAttribute('aria-hidden', 'true'); + }); + + it('draws an empty ring unchecked, a check when checked, a bar when partial', () => { + const {rerender} = render(); + const circle = document.querySelector('.astryx-circle-check-indicator'); + if (circle == null) { + throw new Error('no circle'); + } + // The unchecked circle still renders: an indicator draws in every state. + expect(circle).not.toHaveAttribute('data-checked'); + expect(marks(circle)).toEqual({check: false, dash: false}); + rerender(); + expect(marks(circle)).toEqual({check: true, dash: false}); + rerender(); + expect(circle).toHaveAttribute('data-checked', 'indeterminate'); + expect(marks(circle)).toEqual({check: false, dash: true}); + }); + + it('reflects the disabled state for theme targeting', () => { + render(); + expect( + document.querySelector('.astryx-circle-check-indicator'), + ).toHaveAttribute('data-disabled', 'disabled'); + }); + + it('renders children instead of the mark', () => { + render( + + + , + ); + expect(screen.getByTestId('busy')).toBeInTheDocument(); + expect( + document.querySelector('.astryx-circle-check-indicator-check'), + ).toBeNull(); + }); + + it('stays aria-hidden even when a caller passes false', () => { + render(); + expect( + document.querySelector('.astryx-circle-check-indicator'), + ).toHaveAttribute('aria-hidden', 'true'); + }); +}); + +describe('CircleCheckIndicator mapped to `checkbox` by a theme', () => { + it('draws the circle in a CheckboxInput, which keeps the checkbox semantics', () => { + function Controlled() { + const [value, setValue] = useState(false); + return ( + + + + ); + } + render(); + const input = screen.getByRole('checkbox', {name: 'Select photo'}); + const circle = document.querySelector('.astryx-circle-check-indicator'); + expect(circle).toBeInTheDocument(); + expect(document.querySelector('.astryx-checkbox-indicator')).toBeNull(); + fireEvent.click(input); + expect(input).toBeChecked(); + expect(circle).toHaveAttribute('data-checked', 'checked'); + }); + + it('draws one circle per CheckboxList row', () => { + render( + + {}}> + + + + , + ); + const circles = document.querySelectorAll('.astryx-circle-check-indicator'); + expect(circles).toHaveLength(2); + expect(circles[0]).toHaveAttribute('data-checked', 'checked'); + expect(circles[1]).not.toHaveAttribute('data-checked'); + }); +}); diff --git a/packages/lab/src/CircleCheckIndicator/CircleCheckIndicator.tsx b/packages/lab/src/CircleCheckIndicator/CircleCheckIndicator.tsx new file mode 100644 index 0000000000000..28ef55097303a --- /dev/null +++ b/packages/lab/src/CircleCheckIndicator/CircleCheckIndicator.tsx @@ -0,0 +1,248 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. + +/** + * @file CircleCheckIndicator.tsx + * @input Indicator state props, the theme's colour and radius tokens, Core's + * indicator press marker, and the circle's styles (circleCheck.stylex.ts) + * @output Exports CircleCheckIndicator, the iOS multiple-selection mark + * @position Lab. A multiSelection-family indicator that a theme maps to + * `checkbox` + * + * SYNC: When modified, update CircleCheckIndicator.doc.mjs, + * CircleCheckIndicator.test.tsx, index.ts and the story. + */ + +import * as stylex from '@stylexjs/stylex'; +import type {IndicatorProps} from '@astryxdesign/core/Indicator'; +import {indicatorScope} from '@astryxdesign/core/Indicator/indicator.markers.stylex'; +import {indicatorPressScope} from '@astryxdesign/core/internal/indicatorPress.stylex'; +import {colorVars, radiusVars} from '@astryxdesign/core/theme/tokens.stylex'; +import {isRenderable, mergeProps, themeProps} from '@astryxdesign/core/utils'; +import { + circleCheckMotionStyles, + circleCheckSizeStyles, +} from './circleCheck.stylex'; + +const styles = stylex.create({ + circle: { + boxSizing: 'border-box', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + flexShrink: 0, + borderRadius: radiusVars['--radius-full'], + // Forced colors drops the inset-shadow ring, so a system-coloured border + // draws it there. + borderStyle: {default: 'none', '@media (forced-colors: active)': 'solid'}, + borderWidth: {default: 0, '@media (forced-colors: active)': '1px'}, + borderColor: { + default: 'transparent', + '@media (forced-colors: active)': 'CanvasText', + }, + }, + // The empty circle is a ring with a clear centre, as UIKit's is. A selected + // edit-mode row keeps its background behind the mark. + unchecked: { + boxShadow: { + default: `inset 0 0 0 var(--_circle-stroke) ${colorVars['--color-border-emphasized']}`, + [stylex.when.ancestor(':hover', indicatorScope)]: { + '@media (hover: hover)': `inset 0 0 0 var(--_circle-stroke) color-mix(in srgb, ${colorVars['--color-border-emphasized']}, ${colorVars['--color-tint-hover']} 20%)`, + }, + }, + backgroundColor: 'transparent', + }, + checked: { + // An inherit-shade loading spinner reads this colour as currentColor. + color: colorVars['--color-on-accent'], + boxShadow: 'none', + backgroundColor: { + default: colorVars['--color-accent'], + [stylex.when.ancestor(':hover', indicatorScope)]: { + '@media (hover: hover)': `color-mix(in srgb, ${colorVars['--color-accent']}, ${colorVars['--color-tint-hover']} 15%)`, + }, + }, + }, + disabled: { + opacity: 0.5, + }, + // The press paints on the circle itself. The host's rounded-square layer + // would tint past the circle, so the host leaves it off here. A touch + // press arrives as `--_indicator-press-image`, which only a CheckboxInput + // row declares, so a menu row's own press never paints twice. + ownPress: { + position: 'relative', + '::after': { + content: '""', + position: 'absolute', + inset: 0, + borderRadius: radiusVars['--radius-full'], + pointerEvents: 'none', + backgroundColor: { + default: 'transparent', + [stylex.when.ancestor(':active', indicatorScope)]: { + default: colorVars['--color-overlay-pressed'], + '@media (pointer: coarse)': 'transparent', + }, + }, + // The image paints under a coarse pointer only, as CheckboxInput's own + // layer does. A held pen on a fine-pointer page already draws the + // `:active` fill, and the image would paint a second press. StyleX puts + // a constant media key in a later priority layer than a literal one. So + // the key stays literal. + backgroundImage: { + default: null, + '@media (pointer: coarse)': 'var(--_indicator-press-image, none)', + }, + }, + }, + checkmark: { + display: 'none', + flexShrink: 0, + overflow: 'visible', + color: { + default: colorVars['--color-on-accent'], + // Forced colors flattens the fill to Canvas and may not force an SVG + // stroke drawn with currentColor. CanvasText keeps the check visible on + // it (WCAG 1.4.11). + '@media (forced-colors: active)': 'CanvasText', + }, + }, + checkmarkVisible: { + display: 'block', + }, + bar: { + display: 'none', + flexShrink: 0, + backgroundColor: { + default: colorVars['--color-on-accent'], + '@media (forced-colors: active)': 'CanvasText', + }, + borderRadius: radiusVars['--radius-full'], + }, + barVisible: { + display: 'block', + }, +}); + +const CIRCLE = { + sm: circleCheckSizeStyles.smCircle, + md: circleCheckSizeStyles.mdCircle, +} as const; +const CHECK = { + sm: circleCheckSizeStyles.smCheck, + md: circleCheckSizeStyles.mdCheck, +} as const; +const BAR = { + sm: circleCheckSizeStyles.smBar, + md: circleCheckSizeStyles.mdBar, +} as const; + +/** + * The iOS multiple-selection mark. It shows an empty circle when unchecked + * and a filled circle with a checkmark when checked. The partial state fills + * the circle with a bar. + * + * Decorative and non-interactive, like every indicator: it renders + * `aria-hidden` and owns no input, role, or focus behavior. Map it to + * `checkbox` in a theme, and every CheckboxInput and CheckboxList draws it. + * The owning control keeps its semantics and paints its focus ring on the + * circle. Its colours fade over the theme duration on every pointer, and + * change at once under Reduce Motion. It draws the circle everywhere, so + * map it only in a theme meant for iOS. + * + * @example + * ``` + * const theme = defineTheme({ + * name: 'circle-checks', + * indicators: {checkbox: CircleCheckIndicator}, + * }); + * ``` + */ +export function CircleCheckIndicator({ + state, + size = 'md', + isDisabled = false, + children, + ref, + className, + style, + xstyle, + ...rest +}: IndicatorProps<'multiSelection'>) { + const isChecked = state === 'checked'; + const isIndeterminate = state === 'indeterminate'; + const isFilled = isChecked || isIndeterminate; + + return ( +