An open source design system that's fully customizable and agent ready
TypeScript
docs(cli): the coupon code block's field shows its focus look at once (#10649)
Christopher Chedeau670aada7fb90
diff --git a/.changeset/template-coupon-field-focus-at-once.md b/.changeset/template-coupon-field-focus-at-once.mdnew file mode 100644index 0000000000..e12596784b--- /dev/null+++ b/.changeset/template-coupon-field-focus-at-once.md@@ -0,0 +1,7 @@+---+'@astryxdesign/cli': patch+---++[docs] The `useInputStatusIcon — Coupon Code Status` example block's field applies `inputWrapperStyles.textField`. A field copied from it now shows its focus look at once when the primary pointer is coarse, as Core's text fields do.++@vjeuxdiff --git a/packages/cli/api/template/use-input-status-icon-hook-usage.test.tsx b/packages/cli/api/template/use-input-status-icon-hook-usage.test.tsxnew file mode 100644index 0000000000..c0b15e83e6--- /dev/null+++ b/packages/cli/api/template/use-input-status-icon-hook-usage.test.tsx@@ -0,0 +1,60 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.+// @vitest-environment jsdom++/**+ * The useInputStatusIcon example builds its own bordered field. It composes+ * Core's text field timing right after the shared field box. So a field+ * copied from it shows its focus look at once under a coarse pointer, as+ * Core's text fields do.+ */++import {act} from 'react';+import {createRoot, type Root} from 'react-dom/client';+import {afterEach, beforeEach, expect, it, vi} from 'vitest';+import {inputWrapperStyles} from '@astryxdesign/core/Field';+import UseInputStatusIconHookUsage from '../../assets/templates/blocks/components/Hooks/useInputStatusIconHookUsage';++// The node project does not compile StyleX. The mock keeps each props call's+// styles, so the test reads which styles the field composes.+const propsCalls = vi.hoisted(() => [] as unknown[][]);+vi.mock('@stylexjs/stylex', async importOriginal => ({+ ...(await importOriginal<object>()),+ create: <T,>(styles: T) => styles,+ props: (...styles: unknown[]) => {+ propsCalls.push(styles);+ return {};+ },+}));++(globalThis as {IS_REACT_ACT_ENVIRONMENT?: boolean}).IS_REACT_ACT_ENVIRONMENT =+ true;++let root: Root | null = null;+let container: HTMLElement;++beforeEach(() => {+ propsCalls.length = 0;+ container = document.createElement('div');+ document.body.append(container);+});++afterEach(() => {+ act(() => root?.unmount());+ root = null;+ container.remove();+});++it('composes the text field timing right after the shared field box', () => {+ act(() => {+ root = createRoot(container);+ root.render(<UseInputStatusIconHookUsage />);+ });+ const fieldCalls = propsCalls.filter(styles =>+ styles.includes(inputWrapperStyles.base),+ );+ expect(fieldCalls.length).toBeGreaterThan(0);+ for (const styles of fieldCalls) {+ const base = styles.indexOf(inputWrapperStyles.base);+ expect(styles[base + 1]).toBe(inputWrapperStyles.textField);+ }+});diff --git a/packages/cli/assets/templates/blocks/components/Hooks/useInputStatusIconHookUsage.tsx b/packages/cli/assets/templates/blocks/components/Hooks/useInputStatusIconHookUsage.tsxindex 3016febc63..e77d802aa4 100644--- a/packages/cli/assets/templates/blocks/components/Hooks/useInputStatusIconHookUsage.tsx+++ b/packages/cli/assets/templates/blocks/components/Hooks/useInputStatusIconHookUsage.tsx@@ -74,6 +74,7 @@ function CouponField({statusVariant}: {statusVariant: FieldStatusPlacement}) {<div{...stylex.props(inputWrapperStyles.base,+ inputWrapperStyles.textField,styles.field,status && inputStatusBorderStyles[status.type],)}>