Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
77c9143
docs: add headless widgets design docs
r0b1n Oct 30, 2026
f7ca492
build(combobox-web): add mobx, mobx-kit and brandi, run jest in stric…
r0b1n Oct 29, 2026
a06d55f
refactor(combobox-web): make the selector store observable with mobx
r0b1n Oct 29, 2026
9522aee
refactor(combobox-web): replace the forced re-render with a snapshot …
r0b1n Oct 29, 2026
7b8b35f
docs(combobox-web): record migration step 1 as an openspec change
r0b1n Oct 29, 2026
b2b03ab
feat(combobox-web): add the combobox core, its container and view model
r0b1n Oct 30, 2026
d2c70b8
refactor(combobox-web): drop the deprecated search-term callback
r0b1n Oct 30, 2026
62a5061
docs(combobox-web): record migration step 2 as an openspec change
r0b1n Oct 30, 2026
fe85ea9
feat(combobox-web): own the open state, input text and highlight in t…
r0b1n Nov 2, 2026
26b7500
refactor(combobox-web): extract the behavior and popover hooks from t…
r0b1n Nov 2, 2026
5eb29cb
docs(combobox-web): record migration step 3 as an openspec change
r0b1n Nov 2, 2026
d70b902
refactor(combobox-web): derive the selectors from the props gate
r0b1n Nov 2, 2026
d56c80a
docs(combobox-web): record the selector gate as an openspec change
r0b1n Nov 2, 2026
815a852
docs(combobox-web): record the green e2e run for the selector gate
r0b1n Nov 2, 2026
9e0dedf
refactor(combobox-web): classes map, data attributes and caption mark…
r0b1n Nov 2, 2026
03e47d5
docs(combobox-web): record the classes map as an openspec change
r0b1n Nov 2, 2026
7f5b2cd
docs(combobox-web): keep the openspec changes free of personal names
r0b1n Nov 2, 2026
1c86371
docs(combobox-web): record the green e2e run for the classes map
r0b1n Nov 2, 2026
47d23ba
refactor(combobox-web): split the atlas view into parts with classes …
r0b1n Nov 2, 2026
42b6621
docs(combobox-web): record the parts split as an openspec change
r0b1n Nov 2, 2026
84f99d1
docs(combobox-web): record the green e2e run for the parts split
r0b1n Nov 3, 2026
41f823d
feat(combobox-web): compose the a11y status message in the core
r0b1n Nov 3, 2026
502e313
fix(combobox-web): mark the multi-select listbox as multiselectable
r0b1n Nov 3, 2026
5449d80
test(combobox-web): add the view conformance suite and run the atlas …
r0b1n Nov 3, 2026
2ae8f8b
feat(combobox-web): add a bare sandbox view and run it through the co…
r0b1n Nov 3, 2026
ed9a780
docs(combobox-web): record the second view and the conformance suite …
r0b1n Nov 3, 2026
24d36b2
feat(combobox-web): split the view model into the widget envelope and…
r0b1n Nov 5, 2026
a7aedf9
feat(combobox-web): render a view from the app project when the widge…
r0b1n Nov 5, 2026
6077410
refactor(combobox-web): move the core and the atlas view into kit pac…
r0b1n Nov 5, 2026
f2066b9
docs(combobox-web): record the package move as an openspec change
r0b1n Nov 5, 2026
89adc89
refactor(combobox-web): always render the atlas view
r0b1n Nov 6, 2026
f0181e2
fix(combobox-web): load the full first page on open after a lazy boun…
r0b1n Nov 10, 2026
9549143
refactor(combobox-web): keep the released status message and markup f…
r0b1n Nov 10, 2026
1b4f3bc
docs(combobox-web): record the parity release as an openspec change
r0b1n Nov 10, 2026
82708cc
fix(combobox-web): show the placeholder during the first datasource l…
r0b1n Nov 10, 2026
2faea04
docs(combobox-web): record the first-load placeholder and the selecti…
r0b1n Nov 10, 2026
b913cd2
build(combobox-web): share mobx with the other widgets
r0b1n Nov 24, 2026
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
504 changes: 504 additions & 0 deletions docs/design/headless-combobox.md

Large diffs are not rendered by default.

412 changes: 412 additions & 0 deletions docs/design/headless-widgets.md

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions packages/kits/combobox-kit/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# @mendix/combobox-kit

The headless combo box: `combobox-web` is a thin host over this package. Read
`docs/design/headless-widgets.md` and `docs/design/headless-combobox.md` first.

## Entries

- `.` (`src/main.ts`): the contract. `ComboboxViewModel` and its types, `useComboboxCore(props)`
for a host, `createComboboxContainer`, the envelope and input facet re-exported from
`@mendix/widget-kit`.
- `./atlas`: the Atlas View (`ComboboxView` with `classes` and `parts`), the parts, the class map,
`useComboboxBehavior` (downshift, controlled) and `useComboboxPopover` (floating-ui). A View that
does not use them never imports this entry.
- `./conformance`: `describeComboboxConformance(name, View)`, the Jest + RTL suite every View must pass.
- `./preview`: what the Studio Pro editor preview needs.

## Layout

- `src/core/`: `ComboboxCore`, the brandi container, config, props gate, services, the view model builder.
- `src/helpers/`: the selectors and providers per data source family, the Core's internal model.
- `src/preview/`: the selectors the editor preview uses.
- `src/hooks/`, `src/atlas/`: the Atlas View and its hooks.
- `src/typings/ComboboxProps.ts`: a copy of the typings `combobox-web` generates from `Combobox.xml`;
a spec fails when the two drift. Regenerate in the widget, then copy.

## Rules

- The Core knows nothing about HTML. The ViewModel is plain data and stable commands.
- The Atlas stylesheet lives in `combobox-web` (`src/ui/Combobox.scss`): the MPK ships the CSS.
- Run `pnpm run build` here before `pnpm run test` in `combobox-web`; the widget consumes `dist`.
7 changes: 7 additions & 0 deletions packages/kits/combobox-kit/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import config from "@mendix/eslint-config-web-widgets/widget-ts.mjs";

export default [
...config,
// A copy of the typings combobox-web generates from Combobox.xml; a spec keeps it byte-for-byte equal.
{ ignores: ["src/typings/ComboboxProps.ts"] }
];
7 changes: 7 additions & 0 deletions packages/kits/combobox-kit/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { join } = require("path");
const baseConfig = require("@mendix/pluggable-widgets-tools/test-config/jest.config.js");

module.exports = {
...baseConfig,
setupFilesAfterEnv: [...baseConfig.setupFilesAfterEnv, join(__dirname, "jest.setup.ts")]
};
24 changes: 24 additions & 0 deletions packages/kits/combobox-kit/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { configure } from "mobx";

// Every observable mutation must go through an action. MobX only warns about violations, so the
// warning is turned into a failure here; in Studio Pro the same mistake shows up as stale UI.
configure({ enforceActions: "always" });

const warn = console.warn;
console.warn = (...args: unknown[]): void => {
if (typeof args[0] === "string" && args[0].startsWith("[MobX]")) {
throw new Error(args[0]);
}
warn(...args);
};

// downshift checks in development that every getter of a hook in use is called and its ref applied,
// and only logs when it is not. The log is turned into a failure here; in the browser it floods the
// console on every render of the widget.
const error = console.error;
console.error = (...args: unknown[]): void => {
if (typeof args[0] === "string" && args[0].startsWith("downshift:")) {
throw new Error(args[0]);
}
error(...args);
};
62 changes: 62 additions & 0 deletions packages/kits/combobox-kit/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "@mendix/combobox-kit",
"version": "0.1.0",
"description": "Headless combo box: the core with the Mendix binding, the view model contract, the Atlas view with its behavior, popover, classes and parts, and the conformance suite.",
"copyright": "© Mendix Technology BV 2025. All rights reserved.",
"license": "Apache-2.0",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/mendix/web-widgets.git"
},
"type": "module",
"types": "./dist/main.d.ts",
"main": "./dist/main.js",
"files": [
"dist",
"!*.map"
],
"exports": {
".": "./dist/main.js",
"./*": "./dist/*.js"
},
"typesVersions": {
"*": {
"dist/main.d.ts": [
"dist/main.d.ts"
],
"*": [
"dist/*"
]
}
},
"scripts": {
"build": "tsc -p tsconfig.build.json",
"dev": "tsc -p tsconfig.build.json --watch",
"format": "prettier --write .",
"lint": "eslint src/ package.json",
"test": "jest"
},
"dependencies": {
"@floating-ui/react": "^0.26.27",
"@mendix/widget-kit": "workspace:*",
"@mendix/widget-plugin-component-kit": "workspace:*",
"@mendix/widget-plugin-grid": "workspace:*",
"@mendix/widget-plugin-mobx-kit": "workspace:*",
"@mendix/widget-plugin-platform": "workspace:*",
"brandi": "^5.0.0",
"classnames": "^2.5.1",
"downshift": "^7.6.2",
"match-sorter": "^8.1.0",
"mobx": "6.12.3"
},
"devDependencies": {
"@mendix/eslint-config-web-widgets": "workspace:*",
"@mendix/pluggable-widgets-tools": "*",
"@mendix/prettier-config-web-widgets": "workspace:*",
"@mendix/widget-plugin-test-utils": "workspace:*"
},
"optionalDependencies": {
"react": ">=18.0.0 <19.0.0"
}
}
12 changes: 12 additions & 0 deletions packages/kits/combobox-kit/src/atlas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export { ComboboxView } from "./atlas/ComboboxView";
export type { ComboboxViewProps } from "./atlas/ComboboxView";
export { comboboxClasses, defaultClasses } from "./atlas/classes";
export type { ComboboxClasses, ComboboxClassKey } from "./atlas/classes";
export { atlasParts } from "./atlas/parts";
export type { ComboboxParts } from "./atlas/parts";
export { UnavailablePlaceholder } from "./atlas/UnavailablePlaceholder";
export { useComboboxBehavior } from "./hooks/useComboboxBehavior";
export type { ComboboxBehavior } from "./hooks/useComboboxBehavior";
export { useComboboxPopover } from "./hooks/useComboboxPopover";
export type { ComboboxPopover } from "./hooks/useComboboxPopover";
export { useComboboxClasses } from "./hooks/useComboboxClasses";
23 changes: 23 additions & 0 deletions packages/kits/combobox-kit/src/atlas/Caption.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { createElement, MouseEvent, PropsWithChildren, ReactElement } from "react";
import { useComboboxClasses } from "../hooks/useComboboxClasses";

export interface CaptionProps extends PropsWithChildren {
/** Renders a `label` for this control instead of a `span`. */
htmlFor?: string;
onClick?: (e: MouseEvent) => void;
}

function preventDefault(e: MouseEvent): void {
e.preventDefault();
}

/** The plain caption of an option, a chip or the input area. */
export function Caption({ htmlFor, children, onClick }: CaptionProps): ReactElement {
const classes = useComboboxClasses();
return createElement(htmlFor == null ? "span" : "label", {
children,
className: classes.caption,
htmlFor,
onClick: onClick ?? (htmlFor ? preventDefault : undefined)
});
}
131 changes: 131 additions & 0 deletions packages/kits/combobox-kit/src/atlas/ComboboxView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import classNames from "classnames";
import { ReactElement, useMemo } from "react";
import { ComboboxClasses, defaultClasses } from "./classes";
import { legacy } from "./legacyModifiers";
import { atlasParts, ComboboxParts } from "./parts";
import { ComboboxViewModel } from "../core/ComboboxViewModel";
import { useComboboxBehavior } from "../hooks/useComboboxBehavior";
import { ComboboxClassesContext, useComboboxClasses } from "../hooks/useComboboxClasses";
import { useComboboxPopover } from "../hooks/useComboboxPopover";

export interface ComboboxViewProps {
vm: ComboboxViewModel;
/** Replaces the Atlas class of each given key; the other keys keep their Atlas class. */
classes?: Partial<ComboboxClasses>;
/** Replaces the Atlas part of each given key; the other parts stay. */
parts?: Partial<ComboboxParts>;
/** Editor preview only: render the menu inline and always open. */
keepMenuOpen?: boolean;
/** Extra class on the root element. */
className?: string;
}

/** The Atlas View: resolves the class map and the parts, then renders the composition. */
export function ComboboxView({
vm,
classes: classOverrides,
parts,
keepMenuOpen,
className
}: ComboboxViewProps): ReactElement {
const classes = useMemo(() => ({ ...defaultClasses, ...classOverrides }), [classOverrides]);

return (
<ComboboxClassesContext.Provider value={classes}>
<AtlasComposition vm={vm} parts={parts} keepMenuOpen={keepMenuOpen} className={className} />
</ComboboxClassesContext.Provider>
);
}

type CompositionProps = Omit<ComboboxViewProps, "classes">;

/** The composition of the parts: one tree for both modes, the chips and the select-all control multi-mode only. */
function AtlasComposition({ vm, parts, keepMenuOpen, className }: CompositionProps): ReactElement {
const classes = useComboboxClasses();
const P = { ...atlasParts, ...parts };
const behavior = useComboboxBehavior(vm);
const popover = useComboboxPopover(vm, { alwaysOpen: keepMenuOpen });

const multi = vm.mode === "multi";
const isOpen = vm.isOpen || keepMenuOpen === true;
const textOnly = vm.readOnly && vm.hints.readOnlyStyle === "text";
const withChips = multi && vm.hints.selectedItemsStyle === "boxes";
const customContentEverywhere = !multi && vm.hints.customContent === "everywhere";
const hasValue = multi ? vm.value !== null && vm.value.length > 0 : vm.value !== null;
const inputProps = behavior.getInputProps();

return (
<div className={classNames(classes.root, className)} {...behavior.getRootProps()}>
<P.InputContainer
vm={vm}
isOpen={isOpen}
toggleProps={behavior.getToggleProps()}
anchorRef={popover.setReference}
hasSelection={multi && vm.chips.length > 0}
>
<div
className={classNames(classes.selectedItems, {
[legacy.selectedItemsBoxes]: multi && withChips,
[legacy.selectedItemsText]: multi && !withChips,
[legacy.selectedItemsCustom]: customContentEverywhere
})}
data-style={multi ? vm.hints.selectedItemsStyle : undefined}
data-custom={customContentEverywhere || undefined}
>
{withChips &&
vm.chips.map((chip, index) => (
<P.Chip
key={chip.id}
vm={vm}
chip={chip}
index={index}
chipProps={behavior.getChipProps(index)}
removeProps={behavior.getChipRemoveProps(index)}
/>
))}
<input
className={classNames(classes.input, { [legacy.inputReadonly]: inputProps["data-readonly"] })}
{...inputProps}
/>
<P.Placeholder vm={vm} />
</div>
{!vm.readOnly && vm.clearable && hasValue && <P.Clear clearProps={behavior.getClearProps()} />}
{!textOnly && <P.Toggle vm={vm} isOpen={isOpen} />}
</P.InputContainer>
<P.Validation vm={vm} />
<P.Menu
isOpen={isOpen}
alwaysOpen={keepMenuOpen}
floatingRef={popover.setFloating}
floatingStyles={popover.styles}
menuProps={behavior.getMenuProps()}
header={
multi && vm.canSelectAll ? <P.SelectAll selectAllProps={behavior.getSelectAllProps()} /> : undefined
}
footer={vm.slots.menuFooter}
>
{isOpen &&
(vm.options.length === 0 && !vm.loading.isLoading ? (
<P.NoOptions vm={vm} />
) : (
vm.options.map((option, index) => {
const optionProps = behavior.getOptionProps(index);
return (
<P.Option
key={option.id}
vm={vm}
option={option}
index={index}
// The editor preview keeps its menu open and never shows a highlight.
optionProps={
keepMenuOpen ? { ...optionProps, "data-highlighted": undefined } : optionProps
}
/>
);
})
))}
<P.Loader vm={vm} isOpen={isOpen} />
</P.Menu>
</div>
);
}
30 changes: 30 additions & 0 deletions packages/kits/combobox-kit/src/atlas/OptionContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { ReactElement } from "react";
import { Caption } from "./Caption";
import { ComboboxHints, ComboboxOptionVM } from "../core/ComboboxViewModel";
import { useComboboxClasses } from "../hooks/useComboboxClasses";

export type ContentPlacement = "menu" | "input";

interface OptionContentProps {
option: ComboboxOptionVM;
placement: ContentPlacement;
customContent: ComboboxHints["customContent"];
/** A menu with checkboxes: the caption labels the option's checkbox. */
htmlFor?: string;
}

/**
* The custom content of an option where `hints.customContent` allows it for the placement, the
* plain caption otherwise. Placement is the View's decision; the Core only carries the content.
*/
export function OptionContent({ option, placement, customContent, htmlFor }: OptionContentProps): ReactElement {
const classes = useComboboxClasses();
const custom =
option.content !== undefined &&
(customContent === "everywhere" || (customContent === "menuOnly" && placement === "menu"));
return custom ? (
<div className={classes.customContent}>{option.content}</div>
) : (
<Caption htmlFor={htmlFor}>{option.caption}</Caption>
);
}
20 changes: 20 additions & 0 deletions packages/kits/combobox-kit/src/atlas/SkeletonLoader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import classNames from "classnames";
import { ReactElement } from "react";
import { legacy } from "./legacyModifiers";
import { useComboboxClasses } from "../hooks/useComboboxClasses";

type SkeletonLoaderProps = {
withCheckbox?: boolean;
};

export function SkeletonLoader({ withCheckbox = false }: SkeletonLoaderProps): ReactElement {
const classes = useComboboxClasses();
return (
<div className={classes.skeleton}>
{withCheckbox && (
<span className={classNames(classes.skeletonBar, legacy.skeletonSmall)} data-size="small" />
)}
<span className={classes.skeletonBar} />
</div>
);
}
24 changes: 24 additions & 0 deletions packages/kits/combobox-kit/src/atlas/SpinnerLoader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import classNames from "classnames";
import { ReactElement } from "react";
import { legacy } from "./legacyModifiers";
import { useComboboxClasses } from "../hooks/useComboboxClasses";

type SpinnerLoaderProps = {
size?: "small" | "medium";
withMargins?: boolean;
};

export function SpinnerLoader({ size = "medium", withMargins = false }: SpinnerLoaderProps): ReactElement {
const classes = useComboboxClasses();
return (
<div
className={classNames(classes.spinner, { [legacy.spinnerMargins]: withMargins })}
data-margins={withMargins || undefined}
>
<div
className={classNames(classes.spinnerIcon, { [legacy.spinnerSmall]: size === "small" })}
data-size={size === "small" ? "small" : undefined}
/>
</div>
);
}
13 changes: 13 additions & 0 deletions packages/kits/combobox-kit/src/atlas/UnavailablePlaceholder.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ReactElement } from "react";
import { DownArrow } from "./icons";

/** Rendered by the widget while it has no context yet. Not part of the View, so it keeps its own classes. */
export function UnavailablePlaceholder(): ReactElement {
return (
<div className="form-control widget-combobox-placeholder">
<div className="widget-combobox-placeholder-down-arrow">
<DownArrow />
</div>
</div>
);
}
Loading
Loading