Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/admin-component-type-drift.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/ui-extensions': minor
---

Regenerate the Admin per-component types so they match the components as shipped. Around 35 components gain properties that existed in the implementation but were missing from the types, including the whole of `DatePicker` (`allow`, `allowDays`, `defaultValue`, `defaultView`, `disallow`, `disallowDays`, `value`, `view`, `visibleMonths`), typography properties on `Text`, `Paragraph`, and `Heading` (`fontSize`, `fontWeight`, `fontVariantNumeric`), `Banner`'s `heading` and `dismissible`, `Button`'s `variant` and `accessibilityLabel`, and `ColorPicker`'s `alpha`, `value`, and `defaultValue`.
5 changes: 5 additions & 0 deletions .changeset/admin-number-empty-state-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/ui-extensions': minor
---

Add Admin `Number` and `EmptyState` types. `Number` exposes the `tone`, `color`, `fontSize`, and `fontWeight` properties; `EmptyState` exposes the `heading` property and the `graphic`, `subheading`, `primaryAction`, and `secondaryActions` slots.
5 changes: 5 additions & 0 deletions .changeset/admin-section-header-slots.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/ui-extensions': minor
---

Added `subheading` property and the `primaryAction`, `secondaryActions`, `graphic`, `accessory`, and `supplemental` slots to Admin `Section`.
168 changes: 61 additions & 107 deletions packages/ui-extensions/src/surfaces/admin/components/AdminAction.d.ts
Original file line number Diff line number Diff line change
@@ -1,151 +1,105 @@
/** VERSION: 1.25.0 **/
/** VERSION: 2.23.0 **/
/* eslint-disable import/extensions */

/* eslint-disable @typescript-eslint/no-namespace */

// eslint-disable-next-line @typescript-eslint/triple-slash-reference, spaced-comment
/// <reference lib="DOM" />
import type {ComponentChildren, AdminActionProps$1} from './shared.d.ts';
import type {
ComponentChildren,
AdminActionProps$1,
PreactCustomElement,
RenderImpl,
} from './shared.d.ts';
import * as preact$1 from 'preact';
import {ReactNode, RefAttributes} from 'react';

/**
* The properties for the admin action component. These properties configure the heading and loading state of the admin action extension interface.
* Configure the following properties on the admin action component.
* @publicDocs
*/
export interface AdminActionProps
extends Pick<AdminActionProps$1, 'heading' | 'loading'> {}
extends Pick<AdminActionProps$1, 'heading' | 'loading'> {
/**
* Whether the action is in a loading state, such as during initial page load or when the action is being opened.
* When `true`, the action is in an inert state that prevents user interaction.
*
* @default false
*/
loading: AdminActionProps$1['loading'];
}

declare const tagName = 's-admin-action';
export type ReactIntrinsicElementChildren<PreactProps extends object> =
'children' extends keyof PreactProps
? {
children?: ReactNode;
}
: Record<never, never>;
export type ReactIntrinsicElementProps<
PreactProps extends object,
ElementType,
> = Omit<PreactProps, 'children' | 'key' | 'ref' | 'slot'> &
ReactIntrinsicElementChildren<PreactProps> &
RefAttributes<ElementType> & {
slot?: Lowercase<string>;
};
export type ReactIntrinsicElements = {
[Tag in Exclude<
Extract<keyof preact$1.createElement.JSX.IntrinsicElements, `s-${string}`>,
`s-test-${string}`
>]: ReactIntrinsicElementProps<
preact$1.createElement.JSX.IntrinsicElements[Tag],
Tag extends keyof HTMLElementTagNameMap
? HTMLElementTagNameMap[Tag]
: HTMLElement
>;
};
declare module 'react' {
namespace JSX {
interface IntrinsicElements extends ReactIntrinsicElements {}
}
}

/**
* The JSX props for the admin action component. These properties extend `AdminActionProps` with slots for primary and secondary action buttons that merchants can interact with.
* @publicDocs
*/
declare const tagName = 's-admin-action';
export interface AdminActionJSXProps
extends Partial<AdminActionProps>,
Pick<AdminActionProps$1, 'id'> {
/**
* The primary action button or link to display in the admin action area. This is the main call-to-action that appears prominently in the interface. Typically uses a button component with `variant="primary"` to complete or advance the workflow.
* The main action button or link displayed in the admin action modal.
* This represents the primary or most important action that users can take in this modal context, typically displayed with high visual prominence.
*/
primaryAction: ComponentChildren;
/**
* The secondary action buttons or links to display in the admin action area. These are supporting actions like cancel, back, or alternative operations. Typically uses button components with `variant="secondary"` or `variant="tertiary"`.
* Additional action buttons or links displayed in the admin action modal.
* These provide alternative or supporting actions, visually de-emphasized compared to the primary action to establish clear hierarchy.
*/
secondaryActions: ComponentChildren;
}

/**
* The CSS styles as a string, used for styling web components within their shadow DOM.
* @publicDocs
*/
export type Styles = string;
/**
* The implementation configuration for rendering a Preact component into a shadow root. Defines the render function that returns JSX elements and optional CSS styles to apply to the component's shadow DOM.
* @publicDocs
*/
export type RenderImpl = Omit<ShadowRootInit, 'mode'> & {
/**
* The render function that returns Preact/JSX elements to display in the component's shadow root.
*/
ShadowRoot: (element: any) => ComponentChildren;
/**
* The optional CSS styles to inject into the component's shadow DOM.
*/
styles?: Styles;
};
/**
* The properties of an activation event (such as a click or keyboard press) that describe which modifier keys and mouse buttons were involved. This is used to determine intended behavior like opening links in new tabs when Command/Control is pressed.
* @publicDocs
*/
export interface ActivationEventEsque {
/**
* Whether the Shift key was pressed during the activation event.
*/
shiftKey: boolean;
/**
* Whether the Meta key (Command on Mac, Windows key on Windows) was pressed during the activation event.
*/
metaKey: boolean;
/**
* Whether the Control key was pressed during the activation event.
*/
ctrlKey: boolean;
/**
* The mouse button that was pressed during the activation event. `0` for primary button (left click), `1` for auxiliary button (middle click), `2` for secondary button (right click).
*/
button: number;
}
/**
* The options for controlling how a synthetic click behaves. Allows passing modifier key states and button information from an original event to influence link behavior such as opening in new tabs or background tabs.
* @publicDocs
*/
export interface ClickOptions {
/**
* The activation event (such as a click or keyboard event) whose modifier key state and button information should influence the synthetic click behavior. For example, passing an event with `metaKey: true` will cause links to open in a new tab.
*/
sourceEvent?: ActivationEventEsque;
}
/**
* Base class for creating custom elements with Preact.
* While this class could be used in both Node and the browser, the constructor will only be used in the browser.
* So we give it a type of HTMLElement to avoid typing issues later where it's used, which will only happen in the browser.
*/
declare const BaseClass: typeof globalThis.HTMLElement;
declare abstract class PreactCustomElement extends BaseClass {
/** @private */
static get observedAttributes(): string[];
constructor({
styles,
ShadowRoot: renderFunction,
delegatesFocus,
...options
}: RenderImpl);

/** @private */
setAttribute(name: string, value: string): void;
/** @private */
attributeChangedCallback(name: string): void;
declare class PolarisCustomElement extends PreactCustomElement {
constructor(renderImpl: Omit<RenderImpl, 'globalShadowCSS'>);
/** @private */
connectedCallback(): void;
/** @private */
disconnectedCallback(): void;
/** @private */
adoptedCallback(): void;
/**
* Queue a run of the render function.
* You shouldn't need to call this manually - it should be handled by changes to @property values.
* @private
*/
queueRender(): void;
/**
* Like the standard `element.click()`, but you can influence the behavior with a `sourceEvent`.
*
* For example, if the `sourceEvent` was a middle click, or has particular keys held down,
* components will attempt to produce the desired behavior on links, such as opening the page in the background tab.
* @private
* @param options
*/
click({sourceEvent}?: ClickOptions): void;
}

/**
* The admin action custom element class that renders action controls in the Shopify admin interface. This component creates a standardized action area with a heading and slots for primary and secondary action buttons, used exclusively in admin action extensions.
* Configure the following properties on the admin action component.
* @publicDocs
*/
declare class AdminAction
extends PreactCustomElement
extends PolarisCustomElement
implements AdminActionProps
{
/**
* The heading text to display at the top of the action area. This title describes the action or task the merchant is performing. If not provided, the extension name is used as the heading.
* The text to use as the Action modal's title. If not provided, the name of the extension will be used.
*/
heading: string;

/**
* Whether the action extension is currently in a loading state, such as during initial data fetching or when opening the action. When `true`, the action area might display loading indicators and prevent user interaction until loading completes.
*
* @default false
* Whether the action is in a loading state, such as during initial page load or when the action is being opened. When `true`, the action might be in an inert state that prevents user interaction.
*/
loading: boolean;

constructor();
}
declare global {
Expand Down
129 changes: 22 additions & 107 deletions packages/ui-extensions/src/surfaces/admin/components/AdminBlock.d.ts
Original file line number Diff line number Diff line change
@@ -1,140 +1,55 @@
/** VERSION: 1.25.0 **/
/** VERSION: 2.23.0 **/
/* eslint-disable import/extensions */

/* eslint-disable @typescript-eslint/no-namespace */

// eslint-disable-next-line @typescript-eslint/triple-slash-reference, spaced-comment
/// <reference lib="DOM" />
import type {AdminBlockProps$1, ComponentChildren} from './shared.d.ts';
import type {
AdminBlockProps$1,
PreactCustomElement,
RenderImpl,
} from './shared.d.ts';

/**
* The properties for the admin block component. These properties configure the heading and collapsed summary of collapsible content blocks in the admin interface.
* Configure the following properties on the admin block component.
* @publicDocs
*/
export interface AdminBlockProps
extends Pick<AdminBlockProps$1, 'heading' | 'collapsedSummary'> {}

declare const tagName = 's-admin-block';

/**
* The JSX props for the admin block component. These properties extend `AdminBlockProps` with an optional `id` for element identification in JSX rendering.
* @publicDocs
*/
export interface AdminBlockJSXProps
extends Partial<AdminBlockProps>,
Pick<AdminBlockProps$1, 'id'> {}

/**
* The CSS styles as a string, used for styling web components within their shadow DOM.
* @publicDocs
*/
export type Styles = string;
/**
* The implementation configuration for rendering a Preact component into a shadow root. Defines the render function that returns JSX elements and optional CSS styles to apply to the component's shadow DOM.
* @publicDocs
*/
export type RenderImpl = Omit<ShadowRootInit, 'mode'> & {
/**
* The render function that returns Preact/JSX elements to display in the component's shadow root.
*/
ShadowRoot: (element: any) => ComponentChildren;
/**
* The optional CSS styles to inject into the component's shadow DOM.
*/
styles?: Styles;
};
/**
* The properties of an activation event (such as a click or keyboard press) that describe which modifier keys and mouse buttons were involved. This is used to determine intended behavior like opening links in new tabs when Command/Control is pressed.
* @publicDocs
*/
export interface ActivationEventEsque {
/**
* Whether the Shift key was pressed during the activation event.
*/
shiftKey: boolean;
extends Pick<AdminBlockProps$1, 'heading' | 'collapsedSummary'> {
/**
* Whether the Meta key (Command on Mac, Windows key on Windows) was pressed during the activation event.
* The text displayed as the block's title in the header. If not provided, the extension name will be used.
*/
metaKey: boolean;
heading: AdminBlockProps$1['heading'];
/**
* Whether the Control key was pressed during the activation event.
* The summary text displayed when the app block is collapsed. Summaries longer than 30 characters will be truncated.
*/
ctrlKey: boolean;
/**
* The mouse button that was pressed during the activation event. `0` for primary button (left click), `1` for auxiliary button (middle click), `2` for secondary button (right click).
*/
button: number;
collapsedSummary: AdminBlockProps$1['collapsedSummary'];
}
/**
* The options for controlling how a synthetic click behaves. Allows passing modifier key states and button information from an original event to influence link behavior such as opening in new tabs or background tabs.
* @publicDocs
*/
export interface ClickOptions {
/**
* The activation event (such as a click or keyboard event) whose modifier key state and button information should influence the synthetic click behavior. For example, passing an event with `metaKey: true` will cause links to open in a new tab.
*/
sourceEvent?: ActivationEventEsque;
}
/**
* Base class for creating custom elements with Preact.
* While this class could be used in both Node and the browser, the constructor will only be used in the browser.
* So we give it a type of HTMLElement to avoid typing issues later where it's used, which will only happen in the browser.
*/
declare const BaseClass: typeof globalThis.HTMLElement;
declare abstract class PreactCustomElement extends BaseClass {
/** @private */
static get observedAttributes(): string[];
constructor({
styles,
ShadowRoot: renderFunction,
delegatesFocus,
...options
}: RenderImpl);

/** @private */
setAttribute(name: string, value: string): void;
/** @private */
attributeChangedCallback(name: string): void;
declare const tagName = 's-admin-block';
export interface AdminBlockJSXProps
extends Partial<AdminBlockProps>,
Pick<AdminBlockProps$1, 'id'> {}

declare class PolarisCustomElement extends PreactCustomElement {
constructor(renderImpl: Omit<RenderImpl, 'globalShadowCSS'>);
/** @private */
connectedCallback(): void;
/** @private */
disconnectedCallback(): void;
/** @private */
adoptedCallback(): void;
/**
* Queue a run of the render function.
* You shouldn't need to call this manually - it should be handled by changes to @property values.
* @private
*/
queueRender(): void;
/**
* Like the standard `element.click()`, but you can influence the behavior with a `sourceEvent`.
*
* For example, if the `sourceEvent` was a middle click, or has particular keys held down,
* components will attempt to produce the desired behavior on links, such as opening the page in the background tab.
* @private
* @param options
*/
click({sourceEvent}?: ClickOptions): void;
}

/**
* The admin block custom element class that renders a collapsible content block in the Shopify admin interface. This component organizes content into expandable sections with headings and provides a summary when collapsed.
* Configure the following properties on the admin block component.
* @publicDocs
*/
declare class AdminBlock
extends PreactCustomElement
extends PolarisCustomElement
implements AdminBlockProps
{
/**
* The heading text to display at the top of the block. This title describes the content section the merchant is viewing. If not provided, no heading is displayed.
*/
heading: string;

/**
* The summary text to display when the block is collapsed. This provides merchants with a preview of the block's contents without expanding it. If not provided, no summary is displayed.
*/
collapsedSummary: string;

constructor();
}
declare global {
Expand Down
Loading
Loading