Skip to content

Commit 02324a7

Browse files
authored
Add documentation and examples for POS form component events and slots (#3374)
Resolves [2025-10 Docs][Followup component audit] ChoiceList shop/issues-retail#18638 [2025-10 Docs][Followup component audit] DateField shop/issues-retail#18640 [2025-10 Docs][Followup component audit] DatePicker shop/issues-retail#18641 [2025-10 Docs][Followup component audit] DateSpinner shop/issues-retail#18642 [2025-10 Docs][Followup component audit] EmailField shop/issues-retail#18644 [2025-10 Docs][Followup component audit] NumberField shop/issues-retail#18649 [2025-10 Docs][Followup component audit] SearchField shop/issues-retail#18653 [2025-10 Docs][Followup component audit] TextField shop/issues-retail#18658 [2025-10 Docs][Followup component audit] TimeField shop/issues-retail#18660 [2025-10 Docs][Followup component audit] TimePicker shop/issues-retail#18661 ### Background This PR enhances the documentation for POS UI Extension form components by adding JSDoc comments for event handlers and providing usage examples. ### Solution - Added detailed JSDoc comments to all event handlers (onChange, onInput, onFocus, onBlur) across form components - Standardized the order of event handlers to be consistent across all components - Added code examples demonstrating event handling patterns for each component - Clarified the purpose of accessory slots with better descriptions - Added examples showing how to use command system with date/time pickers These improvements make it easier for developers to understand when different events fire and how to properly handle them in their extensions. ### 🎩 Companion PR: https://app.graphite.dev/github/pr/Shopify/shopify-dev/63109 - Verified documentation renders correctly with new JSDoc comments ### Checklist - [x] I have 🎩'd these changes - [x] I have updated relevant documentation
2 parents c52890f + b1f786a commit 02324a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+805
-142
lines changed

packages/ui-extensions/src/surfaces/point-of-sale/components.d.ts

Lines changed: 169 additions & 72 deletions
Large diffs are not rendered by default.

packages/ui-extensions/src/surfaces/point-of-sale/components/ChoiceList.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ export interface CallbackEvent<T extends keyof HTMLElementTagNameMap> {
3939
declare const tagName = 's-choice-list';
4040
export interface ChoiceListJSXProps
4141
extends Pick<ChoiceListProps, 'values' | 'multiple'> {
42-
onChange?: ((event: CallbackEvent<typeof tagName>) => void) | null;
42+
/** Function called when the user changes a choice. Fires simultaneously with onChange. */
4343
onInput?: ((event: CallbackEvent<typeof tagName>) => void) | null;
44+
/** Function called when the user changes a choice. Fires simultaneously with onInput. */
45+
onChange?: ((event: CallbackEvent<typeof tagName>) => void) | null;
4446
children?: ComponentChildren;
4547
}
4648
declare global {

packages/ui-extensions/src/surfaces/point-of-sale/components/ChoiceList/ChoiceList.doc.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const data: ReferenceEntityTemplateSchema = {
1515
},
1616
{
1717
title: 'Events',
18-
description: '',
18+
description:
19+
'Learn more about registering [events](/docs/api/pos-ui-extensions/using-polaris-components#events)',
1920
type: 'ChoiceListEvents',
2021
},
2122
{
@@ -40,6 +41,35 @@ const data: ReferenceEntityTemplateSchema = {
4041
},
4142
},
4243
related: [],
44+
examples: {
45+
description: 'ChoiceList usage patterns',
46+
examples: [
47+
{
48+
description: 'Enable multiple selection mode with controlled values',
49+
codeblock: {
50+
title: 'Multiple selection',
51+
tabs: [
52+
{
53+
code: './examples/multiple-selection.jsx',
54+
language: 'jsx',
55+
},
56+
],
57+
},
58+
},
59+
{
60+
description: 'Handle onChange and onInput events.',
61+
codeblock: {
62+
title: 'Event handling',
63+
tabs: [
64+
{
65+
code: './examples/event-handling.jsx',
66+
language: 'jsx',
67+
},
68+
],
69+
},
70+
},
71+
],
72+
},
4373
};
4474

4575
export default data;

packages/ui-extensions/src/surfaces/point-of-sale/components/ChoiceList/examples/default.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
<s-choice value="m">Medium</s-choice>
44
<s-choice value="l">Large</s-choice>
55
<s-choice value="xl">Extra large</s-choice>
6-
</s-choice-list>
6+
</s-choice-list>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<s-choice-list
2+
onChange={(event) => console.log('onChange:', event.target.values)}
3+
onInput={(event) => console.log('onInput:', event.target.values)}
4+
>
5+
<s-choice value="option1">Option 1</s-choice>
6+
<s-choice value="option2" disabled>Option 2 (disabled)</s-choice>
7+
<s-choice value="option3">Option 3</s-choice>
8+
</s-choice-list>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<s-choice-list
2+
multiple
3+
values={['small', 'medium']}
4+
onChange={(event) => console.log('Selected:', event.target.values)}
5+
>
6+
<s-choice value="small">Small</s-choice>
7+
<s-choice value="medium">Medium</s-choice>
8+
<s-choice value="large">Large</s-choice>
9+
</s-choice-list>

packages/ui-extensions/src/surfaces/point-of-sale/components/DateField.d.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
/* eslint-disable import-x/namespace */
99
// eslint-disable-next-line @typescript-eslint/triple-slash-reference, spaced-comment
1010
/// <reference lib="DOM" />
11-
import type {
12-
DateFieldProps,
13-
Key,
14-
Ref,
15-
ComponentChild,
16-
} from './components-shared.d.ts';
11+
import type {DateFieldProps, Key, Ref} from './components-shared.d.ts';
1712

1813
export type ComponentChildren = any;
1914
/**
@@ -47,11 +42,14 @@ export interface DateFieldJSXProps
4742
DateFieldProps,
4843
'label' | 'details' | 'value' | 'disabled' | 'error'
4944
> {
45+
/** Function called when the user makes any changes in the field. */
5046
onInput?: ((event: CallbackEvent<typeof tagName>) => void) | null;
51-
onFocus?: ((event: CallbackEvent<typeof tagName>) => void) | null;
52-
onBlur?: ((event: CallbackEvent<typeof tagName>) => void) | null;
47+
/** Function called after editing completes (typically on blur). */
5348
onChange?: ((event: CallbackEvent<typeof tagName>) => void) | null;
54-
accessory?: ComponentChild;
49+
/** Function called when the element loses focus. */
50+
onBlur?: ((event: CallbackEvent<typeof tagName>) => void) | null;
51+
/** Function called when the element receives focus. */
52+
onFocus?: ((event: CallbackEvent<typeof tagName>) => void) | null;
5553
}
5654
declare global {
5755
interface HTMLElementTagNameMap {

packages/ui-extensions/src/surfaces/point-of-sale/components/DateField/DateField.doc.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@ const data: ReferenceEntityTemplateSchema = {
1313
description: '',
1414
type: 'DateField',
1515
},
16-
{
17-
title: 'Slots',
18-
description: '',
19-
type: 'DateFieldSlots',
20-
},
2116
{
2217
title: 'Events',
23-
description: '',
18+
description:
19+
'Learn more about registering [events](/docs/api/pos-ui-extensions/using-polaris-components#events)',
2420
type: 'DateFieldEvents',
2521
},
2622
],
@@ -39,6 +35,23 @@ const data: ReferenceEntityTemplateSchema = {
3935
},
4036
},
4137
related: [],
38+
examples: {
39+
description: 'DateField usage patterns',
40+
examples: [
41+
{
42+
description: 'Handle date input events',
43+
codeblock: {
44+
title: 'Event handling',
45+
tabs: [
46+
{
47+
code: './examples/event-handling.jsx',
48+
language: 'jsx',
49+
},
50+
],
51+
},
52+
},
53+
],
54+
},
4255
};
4356

4457
export default data;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<s-date-field
2+
label="Order date"
3+
value="2024-10-26"
4+
onInput={(event) => console.log('Input:', event.target.value)}
5+
onChange={(event) => console.log('Change:', event.target.value)}
6+
onFocus={(event) => console.log('Focused with:', event.target.value)}
7+
onBlur={(event) => console.log('Blurred with:', event.target.value)}
8+
/>

packages/ui-extensions/src/surfaces/point-of-sale/components/DatePicker.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@ export interface CallbackEvent<T extends keyof HTMLElementTagNameMap> {
3939
declare const tagName = 's-date-picker';
4040
export interface DatePickerJSXProps
4141
extends Pick<DatePickerProps, 'id' | 'value'> {
42+
/** Function called when the user selects a date from the picker. */
43+
onInput?: (event: CallbackEvent<typeof tagName>) => void | null;
44+
/** Function called when the user selects a date from the picker that is different to the current value. */
45+
onChange?: (event: CallbackEvent<typeof tagName>) => void | null;
46+
/** Function called when the date picker is dismissed. */
4247
onBlur?: (event: CallbackEvent<typeof tagName>) => void | null;
48+
/** Function called when the date picker is revealed. */
4349
onFocus?: (event: CallbackEvent<typeof tagName>) => void | null;
44-
onChange?: (event: CallbackEvent<typeof tagName>) => void | null;
45-
onInput?: (event: CallbackEvent<typeof tagName>) => void | null;
4650
}
4751
declare global {
4852
interface HTMLElementTagNameMap {

0 commit comments

Comments
 (0)