@cssints/apg-specs 0.0.0-stage → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +65 -2
- package/dist/apg/accordion.bridge.d.mts +35 -0
- package/dist/apg/accordion.bridge.mjs +326 -0
- package/dist/apg/accordion.model.json +8397 -0
- package/dist/apg/alert.bridge.d.mts +22 -0
- package/dist/apg/alert.bridge.mjs +86 -0
- package/dist/apg/alert.model.json +871 -0
- package/dist/apg/alertdialog.bridge.d.mts +21 -0
- package/dist/apg/alertdialog.bridge.mjs +221 -0
- package/dist/apg/alertdialog.model.json +5232 -0
- package/dist/apg/breadcrumb.bridge.d.mts +26 -0
- package/dist/apg/breadcrumb.bridge.mjs +120 -0
- package/dist/apg/breadcrumb.model.json +574 -0
- package/dist/apg/button.bridge.d.mts +35 -0
- package/dist/apg/button.bridge.mjs +208 -0
- package/dist/apg/button.model.json +5814 -0
- package/dist/apg/carousel.bridge.d.mts +44 -0
- package/dist/apg/carousel.bridge.mjs +262 -0
- package/dist/apg/carousel.model.json +8963 -0
- package/dist/apg/checkbox-group.bridge.d.mts +25 -0
- package/dist/apg/checkbox-group.bridge.mjs +276 -0
- package/dist/apg/checkbox-group.model.json +3863 -0
- package/dist/apg/checkbox.bridge.d.mts +34 -0
- package/dist/apg/checkbox.bridge.mjs +253 -0
- package/dist/apg/checkbox.model.json +3158 -0
- package/dist/apg/combobox-autocomplete.bridge.d.mts +14 -0
- package/dist/apg/combobox-autocomplete.bridge.mjs +326 -0
- package/dist/apg/combobox-autocomplete.model.json +11586 -0
- package/dist/apg/combobox-dialog.bridge.d.mts +17 -0
- package/dist/apg/combobox-dialog.bridge.mjs +250 -0
- package/dist/apg/combobox-dialog.model.json +8981 -0
- package/dist/apg/combobox-grid.bridge.d.mts +17 -0
- package/dist/apg/combobox-grid.bridge.mjs +227 -0
- package/dist/apg/combobox-grid.model.json +8554 -0
- package/dist/apg/combobox-select-only.bridge.d.mts +24 -0
- package/dist/apg/combobox-select-only.bridge.mjs +304 -0
- package/dist/apg/combobox-select-only.model.json +7846 -0
- package/dist/apg/combobox-tree.bridge.d.mts +17 -0
- package/dist/apg/combobox-tree.bridge.mjs +211 -0
- package/dist/apg/combobox-tree.model.json +9345 -0
- package/dist/apg/dialog-modal.bridge.d.mts +35 -0
- package/dist/apg/dialog-modal.bridge.mjs +186 -0
- package/dist/apg/dialog-modal.model.json +7580 -0
- package/dist/apg/disclosure.bridge.d.mts +25 -0
- package/dist/apg/disclosure.bridge.mjs +202 -0
- package/dist/apg/disclosure.model.json +4703 -0
- package/dist/apg/feed.bridge.d.mts +31 -0
- package/dist/apg/feed.bridge.mjs +246 -0
- package/dist/apg/feed.model.json +4523 -0
- package/dist/apg/grid-selection.bridge.d.mts +13 -0
- package/dist/apg/grid-selection.bridge.mjs +160 -0
- package/dist/apg/grid-selection.model.json +6974 -0
- package/dist/apg/grid-sort.bridge.d.mts +12 -0
- package/dist/apg/grid-sort.bridge.mjs +138 -0
- package/dist/apg/grid-sort.model.json +3799 -0
- package/dist/apg/grid.bridge.d.mts +54 -0
- package/dist/apg/grid.bridge.mjs +441 -0
- package/dist/apg/grid.model.json +3802 -0
- package/dist/apg/link.bridge.d.mts +24 -0
- package/dist/apg/link.bridge.mjs +126 -0
- package/dist/apg/link.model.json +694 -0
- package/dist/apg/listbox-multi.bridge.d.mts +10 -0
- package/dist/apg/listbox-multi.bridge.mjs +261 -0
- package/dist/apg/listbox-multi.model.json +10893 -0
- package/dist/apg/listbox-rearrangeable.bridge.d.mts +20 -0
- package/dist/apg/listbox-rearrangeable.bridge.mjs +237 -0
- package/dist/apg/listbox-rearrangeable.model.json +17592 -0
- package/dist/apg/listbox-shared.d.mts +58 -0
- package/dist/apg/listbox-shared.mjs +171 -0
- package/dist/apg/listbox-single.bridge.d.mts +10 -0
- package/dist/apg/listbox-single.bridge.mjs +196 -0
- package/dist/apg/listbox-single.model.json +8024 -0
- package/dist/apg/listbox-typeahead.bridge.d.mts +10 -0
- package/dist/apg/listbox-typeahead.bridge.mjs +153 -0
- package/dist/apg/listbox-typeahead.model.json +5615 -0
- package/dist/apg/menu-button.bridge.d.mts +29 -0
- package/dist/apg/menu-button.bridge.mjs +259 -0
- package/dist/apg/menu-button.model.json +5706 -0
- package/dist/apg/menu-checkable.bridge.d.mts +25 -0
- package/dist/apg/menu-checkable.bridge.mjs +226 -0
- package/dist/apg/menu-checkable.model.json +4277 -0
- package/dist/apg/menu-menubar.bridge.d.mts +27 -0
- package/dist/apg/menu-menubar.bridge.mjs +273 -0
- package/dist/apg/menu-menubar.model.json +9540 -0
- package/dist/apg/meter.bridge.d.mts +28 -0
- package/dist/apg/meter.bridge.mjs +159 -0
- package/dist/apg/meter.model.json +1185 -0
- package/dist/apg/player.bridge.d.mts +24 -0
- package/dist/apg/player.bridge.mjs +342 -0
- package/dist/apg/player.model.json +11013 -0
- package/dist/apg/radio.bridge.d.mts +35 -0
- package/dist/apg/radio.bridge.mjs +371 -0
- package/dist/apg/radio.model.json +5011 -0
- package/dist/apg/slider-multithumb.bridge.d.mts +34 -0
- package/dist/apg/slider-multithumb.bridge.mjs +365 -0
- package/dist/apg/slider-multithumb.model.json +5774 -0
- package/dist/apg/slider.bridge.d.mts +54 -0
- package/dist/apg/slider.bridge.mjs +359 -0
- package/dist/apg/slider.model.json +4881 -0
- package/dist/apg/spinbutton.bridge.d.mts +41 -0
- package/dist/apg/spinbutton.bridge.mjs +327 -0
- package/dist/apg/spinbutton.model.json +7571 -0
- package/dist/apg/switch.bridge.d.mts +30 -0
- package/dist/apg/switch.bridge.mjs +243 -0
- package/dist/apg/switch.model.json +3159 -0
- package/dist/apg/tabs.bridge.d.mts +41 -0
- package/dist/apg/tabs.bridge.mjs +294 -0
- package/dist/apg/tabs.model.json +7659 -0
- package/dist/apg/timeline.bridge.d.mts +36 -0
- package/dist/apg/timeline.bridge.mjs +265 -0
- package/dist/apg/timeline.model.json +6189 -0
- package/dist/apg/toolbar.bridge.d.mts +25 -0
- package/dist/apg/toolbar.bridge.mjs +307 -0
- package/dist/apg/toolbar.model.json +6616 -0
- package/dist/apg/tooltip.bridge.d.mts +36 -0
- package/dist/apg/tooltip.bridge.mjs +208 -0
- package/dist/apg/tooltip.model.json +8295 -0
- package/dist/apg/treegrid.bridge.d.mts +28 -0
- package/dist/apg/treegrid.bridge.mjs +311 -0
- package/dist/apg/treegrid.model.json +17358 -0
- package/dist/apg/treeview.bridge.d.mts +26 -0
- package/dist/apg/treeview.bridge.mjs +396 -0
- package/dist/apg/treeview.model.json +13745 -0
- package/dist/apg/windowsplitter.bridge.d.mts +36 -0
- package/dist/apg/windowsplitter.bridge.mjs +242 -0
- package/dist/apg/windowsplitter.model.json +6253 -0
- package/dist/canvas/camera.model.json +6568 -0
- package/dist/canvas/canvas.bridge.d.mts +190 -0
- package/dist/canvas/canvas.bridge.mjs +729 -0
- package/dist/canvas/pointer.model.json +17095 -0
- package/dist/scenario.d.mts +233 -0
- package/dist/scenario.mjs +313 -0
- package/package.json +57 -4
- package/scenarios/apg/README.md +221 -0
- package/scenarios/apg/accordion.base-ui.json +1005 -0
- package/scenarios/apg/accordion.react-aria.json +929 -0
- package/scenarios/apg/alert.base-ui.json +81 -0
- package/scenarios/apg/alert.react-aria.json +98 -0
- package/scenarios/apg/alertdialog.base-ui.json +331 -0
- package/scenarios/apg/alertdialog.react-aria.json +225 -0
- package/scenarios/apg/breadcrumb.react-aria.json +312 -0
- package/scenarios/apg/button.ariakit.json +136 -0
- package/scenarios/apg/button.base-ui.json +747 -0
- package/scenarios/apg/button.react-aria.json +443 -0
- package/scenarios/apg/carousel.apg.json +909 -0
- package/scenarios/apg/checkbox.ariakit.json +299 -0
- package/scenarios/apg/checkbox.base-ui.json +1126 -0
- package/scenarios/apg/checkbox.react-aria.json +518 -0
- package/scenarios/apg/combobox.ariakit.json +945 -0
- package/scenarios/apg/combobox.base-ui.json +2444 -0
- package/scenarios/apg/combobox.react-aria.json +845 -0
- package/scenarios/apg/dialog-modal.ariakit.json +1102 -0
- package/scenarios/apg/dialog-modal.base-ui.json +775 -0
- package/scenarios/apg/dialog-modal.react-aria.json +638 -0
- package/scenarios/apg/disclosure.apg.json +349 -0
- package/scenarios/apg/disclosure.ariakit.json +163 -0
- package/scenarios/apg/disclosure.base-ui.json +451 -0
- package/scenarios/apg/disclosure.react-aria.json +643 -0
- package/scenarios/apg/feed.apg.json +442 -0
- package/scenarios/apg/grid.ariakit.json +197 -0
- package/scenarios/apg/grid.base-ui.json +720 -0
- package/scenarios/apg/grid.react-aria.json +969 -0
- package/scenarios/apg/landmarks.ariakit.json +93 -0
- package/scenarios/apg/landmarks.react-aria.json +330 -0
- package/scenarios/apg/link.ariakit.json +83 -0
- package/scenarios/apg/link.base-ui.json +88 -0
- package/scenarios/apg/link.react-aria.json +186 -0
- package/scenarios/apg/listbox.ariakit.json +78 -0
- package/scenarios/apg/listbox.base-ui.json +163 -0
- package/scenarios/apg/listbox.react-aria.json +1118 -0
- package/scenarios/apg/menu-button.ariakit.json +924 -0
- package/scenarios/apg/menu-button.base-ui.json +1155 -0
- package/scenarios/apg/menu-button.react-aria.json +1080 -0
- package/scenarios/apg/menubar.ariakit.json +758 -0
- package/scenarios/apg/menubar.base-ui.json +673 -0
- package/scenarios/apg/meter.base-ui.json +243 -0
- package/scenarios/apg/meter.react-aria.json +201 -0
- package/scenarios/apg/radio.ariakit.json +459 -0
- package/scenarios/apg/radio.base-ui.json +581 -0
- package/scenarios/apg/radio.react-aria.json +576 -0
- package/scenarios/apg/slider-multithumb.base-ui.json +316 -0
- package/scenarios/apg/slider-multithumb.react-aria.json +363 -0
- package/scenarios/apg/slider.base-ui.json +544 -0
- package/scenarios/apg/slider.react-aria.json +456 -0
- package/scenarios/apg/spinbutton.base-ui.json +1688 -0
- package/scenarios/apg/spinbutton.react-aria.json +426 -0
- package/scenarios/apg/switch.base-ui.json +456 -0
- package/scenarios/apg/switch.react-aria.json +303 -0
- package/scenarios/apg/table.ariakit.json +65 -0
- package/scenarios/apg/table.react-aria.json +221 -0
- package/scenarios/apg/tabs.ariakit.json +329 -0
- package/scenarios/apg/tabs.base-ui.json +875 -0
- package/scenarios/apg/tabs.react-aria.json +644 -0
- package/scenarios/apg/toolbar.ariakit.json +595 -0
- package/scenarios/apg/toolbar.base-ui.json +1189 -0
- package/scenarios/apg/toolbar.react-aria.json +383 -0
- package/scenarios/apg/tooltip.ariakit.json +441 -0
- package/scenarios/apg/tooltip.base-ui.json +411 -0
- package/scenarios/apg/tooltip.react-aria.json +454 -0
- package/scenarios/apg/treegrid.apg.json +2558 -0
- package/scenarios/apg/treegrid.react-aria.json +5094 -0
- package/scenarios/apg/treeview.apg.json +928 -0
- package/scenarios/apg/windowsplitter.apg.json +557 -0
- package/scenarios/canvas/README.md +69 -0
- package/scenarios/canvas/camera.contract.json +237 -0
- package/scenarios/canvas/camera.excalidraw.json +57 -0
- package/scenarios/canvas/marquee.excalidraw.json +122 -0
- package/scenarios/canvas/pan.excalidraw.json +46 -0
- package/scenarios/canvas/pointer.contract.json +528 -0
- package/scenarios/parts.json +291 -0
- package/shared/aria.qnt +186 -0
- package/shared/details-group.qnt +50 -0
- package/shared/focusgroup.qnt +152 -0
- package/shared/invokers.qnt +81 -0
- package/shared/popover.qnt +71 -0
- package/specs/apg/STATIC.md +103 -0
- package/specs/apg/accordion.qnt +578 -0
- package/specs/apg/alert.qnt +131 -0
- package/specs/apg/alertdialog.qnt +455 -0
- package/specs/apg/breadcrumb.qnt +88 -0
- package/specs/apg/button.qnt +445 -0
- package/specs/apg/carousel.qnt +732 -0
- package/specs/apg/checkbox-group.qnt +388 -0
- package/specs/apg/checkbox.qnt +394 -0
- package/specs/apg/combobox-autocomplete.qnt +764 -0
- package/specs/apg/combobox-dialog.qnt +627 -0
- package/specs/apg/combobox-grid.qnt +632 -0
- package/specs/apg/combobox-select-only.qnt +626 -0
- package/specs/apg/combobox-tree.qnt +633 -0
- package/specs/apg/dialog-modal.qnt +499 -0
- package/specs/apg/disclosure.qnt +309 -0
- package/specs/apg/feed.qnt +485 -0
- package/specs/apg/grid-selection.qnt +512 -0
- package/specs/apg/grid-sort.qnt +330 -0
- package/specs/apg/grid.qnt +360 -0
- package/specs/apg/link.qnt +119 -0
- package/specs/apg/listbox-multi.qnt +799 -0
- package/specs/apg/listbox-rearrangeable.qnt +801 -0
- package/specs/apg/listbox-single.qnt +511 -0
- package/specs/apg/listbox-typeahead.qnt +396 -0
- package/specs/apg/menu-button.qnt +363 -0
- package/specs/apg/menu-checkable.qnt +304 -0
- package/specs/apg/menu-menubar.qnt +531 -0
- package/specs/apg/meter.qnt +129 -0
- package/specs/apg/player.qnt +1081 -0
- package/specs/apg/radio.qnt +394 -0
- package/specs/apg/slider-multithumb.qnt +441 -0
- package/specs/apg/slider.qnt +396 -0
- package/specs/apg/spinbutton.qnt +494 -0
- package/specs/apg/switch.qnt +389 -0
- package/specs/apg/tabs.qnt +412 -0
- package/specs/apg/timeline.qnt +612 -0
- package/specs/apg/toolbar.qnt +364 -0
- package/specs/apg/tooltip.qnt +553 -0
- package/specs/apg/treegrid.qnt +983 -0
- package/specs/apg/treeview.qnt +1004 -0
- package/specs/apg/windowsplitter.qnt +487 -0
- package/specs/canvas/camera.qnt +407 -0
- package/specs/canvas/pointer.qnt +841 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ActionStep, Probe, ScenarioConfig, SpecBridge } from "../scenario.mjs";
|
|
2
|
+
//#region src/apg/button.bridge.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Scenario `config` -> what both targets are mounted with. `toggle` (or a
|
|
5
|
+
* `pressed`/`defaultPressed` value) makes it a toggle button; `disabled` uses
|
|
6
|
+
* `aria-disabled` (the button stays focusable, per the APG text).
|
|
7
|
+
*
|
|
8
|
+
* `pressed` (base-ui) and `isSelected` (react-aria) are the controlled value
|
|
9
|
+
* with a host that answers every request (a click commits, an outside write
|
|
10
|
+
* lands); `defaultPressed` is an uncontrolled seed; `value` pins the value so
|
|
11
|
+
* every request is rejected.
|
|
12
|
+
*/
|
|
13
|
+
export interface ButtonConfig {
|
|
14
|
+
readonly toggle: boolean;
|
|
15
|
+
readonly pressed: boolean;
|
|
16
|
+
readonly disabled: boolean;
|
|
17
|
+
readonly controlled: boolean;
|
|
18
|
+
/** Controlled only: the host writes every request's intent back as the value. */
|
|
19
|
+
readonly accepts: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare const buttonConfig: (config: ScenarioConfig) => ButtonConfig;
|
|
22
|
+
/** react-aria calls the toggle callback `onChange`; base-ui `onPressedChange`. */
|
|
23
|
+
export declare const canonicalEvent: (name: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Button vocabulary <-> `specs/apg/button.qnt`. Parts: `button`. `click` is a
|
|
26
|
+
* pointer down + up; `key` focuses first (as a user would) then presses. The
|
|
27
|
+
* spec's `set_disabled`/`set_toggle` take the new value, so an absolute `set`
|
|
28
|
+
* step maps directly. A toggle's activation is a request the host may ignore;
|
|
29
|
+
* `setValue` is the host writing the controlled value.
|
|
30
|
+
*/
|
|
31
|
+
export declare const buttonBridge: SpecBridge;
|
|
32
|
+
/** The user-level steps a differential walk draws from. */
|
|
33
|
+
export declare const buttonSteps: ReadonlyArray<ActionStep>;
|
|
34
|
+
export declare const buttonProbe: Probe;
|
|
35
|
+
//#endregion
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { Unsupported } from "../scenario.mjs";
|
|
2
|
+
//#region src/apg/button.bridge.ts
|
|
3
|
+
const specEvent = (tag, params = {}) => ({
|
|
4
|
+
_tag: tag,
|
|
5
|
+
...params
|
|
6
|
+
});
|
|
7
|
+
const NEUTRAL_KEYS = /* @__PURE__ */ new Set([
|
|
8
|
+
"part",
|
|
9
|
+
"type",
|
|
10
|
+
"nativeButton"
|
|
11
|
+
]);
|
|
12
|
+
const buttonConfig = (config) => {
|
|
13
|
+
let toggle = false;
|
|
14
|
+
let pressed = false;
|
|
15
|
+
let disabled = false;
|
|
16
|
+
let controlled = false;
|
|
17
|
+
let pinned = false;
|
|
18
|
+
for (const [key, value] of Object.entries(config)) if (key === "toggle" || key === "isToggle") toggle = value === true;
|
|
19
|
+
else if (key === "pressed" || key === "isSelected") {
|
|
20
|
+
pressed = value === true;
|
|
21
|
+
toggle = true;
|
|
22
|
+
controlled = true;
|
|
23
|
+
} else if (key === "defaultPressed") {
|
|
24
|
+
pressed = value === true;
|
|
25
|
+
toggle = true;
|
|
26
|
+
} else if (key === "value" && typeof value === "boolean") {
|
|
27
|
+
pressed = value;
|
|
28
|
+
toggle = true;
|
|
29
|
+
controlled = true;
|
|
30
|
+
pinned = true;
|
|
31
|
+
} else if (key === "disabled" || key === "isDisabled") disabled = value === true;
|
|
32
|
+
else if (key === "controlled") controlled ||= value === true;
|
|
33
|
+
else if (!NEUTRAL_KEYS.has(key)) throw new Unsupported(`config ${key}=${JSON.stringify(value)}`);
|
|
34
|
+
return {
|
|
35
|
+
toggle,
|
|
36
|
+
pressed,
|
|
37
|
+
disabled,
|
|
38
|
+
controlled,
|
|
39
|
+
accepts: controlled && !pinned
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const partOf = (target) => (target ?? "button").replace(/:0$/, "");
|
|
43
|
+
/** react-aria calls the toggle callback `onChange`; base-ui `onPressedChange`. */
|
|
44
|
+
const canonicalEvent = (name) => name === "onChange" ? "onPressedChange" : name;
|
|
45
|
+
const keyTag = (key) => {
|
|
46
|
+
switch (key) {
|
|
47
|
+
case "Enter": return "Enter";
|
|
48
|
+
case " ":
|
|
49
|
+
case "Space": return "Space";
|
|
50
|
+
default: return;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const programmatic = (step) => {
|
|
54
|
+
switch (step.prop) {
|
|
55
|
+
case "disabled":
|
|
56
|
+
case "isDisabled": return [specEvent("set_disabled", { value: step.value === true })];
|
|
57
|
+
case "toggle":
|
|
58
|
+
case "isToggle": return [specEvent("set_toggle", { value: step.value === true })];
|
|
59
|
+
case "pressed":
|
|
60
|
+
case "isSelected":
|
|
61
|
+
case "value": return [specEvent("setValue", { v: step.value === true })];
|
|
62
|
+
case "hostToggle": return [specEvent("hostToggle")];
|
|
63
|
+
default: throw new Unsupported(`prop ${step.prop ?? ""}`);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const setEvents = (set) => {
|
|
67
|
+
const events = [];
|
|
68
|
+
for (const [key, value] of Object.entries(set)) if (key === "disabled" || key === "isDisabled") events.push(specEvent("set_disabled", { value: value === true }));
|
|
69
|
+
else if (key === "toggle" || key === "isToggle") events.push(specEvent("set_toggle", { value: value === true }));
|
|
70
|
+
else if (key === "pressed" || key === "isSelected" || key === "value") events.push(specEvent("setValue", { v: value === true }));
|
|
71
|
+
else throw new Unsupported(`set ${key}=${JSON.stringify(value)}`);
|
|
72
|
+
return events;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Button vocabulary <-> `specs/apg/button.qnt`. Parts: `button`. `click` is a
|
|
76
|
+
* pointer down + up; `key` focuses first (as a user would) then presses. The
|
|
77
|
+
* spec's `set_disabled`/`set_toggle` take the new value, so an absolute `set`
|
|
78
|
+
* step maps directly. A toggle's activation is a request the host may ignore;
|
|
79
|
+
* `setValue` is the host writing the controlled value.
|
|
80
|
+
*/
|
|
81
|
+
const buttonBridge = {
|
|
82
|
+
setup: (config) => {
|
|
83
|
+
const { toggle, pressed, disabled, controlled, accepts } = buttonConfig(config);
|
|
84
|
+
return [
|
|
85
|
+
...toggle ? [specEvent("set_toggle", { value: true })] : [],
|
|
86
|
+
...toggle && pressed ? [specEvent("seed", { v: true })] : [],
|
|
87
|
+
...controlled ? [specEvent("control")] : [],
|
|
88
|
+
...controlled && accepts ? [specEvent("acceptRequests")] : [],
|
|
89
|
+
...disabled ? [specEvent("set_disabled", { value: true })] : []
|
|
90
|
+
];
|
|
91
|
+
},
|
|
92
|
+
event: (step) => {
|
|
93
|
+
switch (step.event) {
|
|
94
|
+
case "focus":
|
|
95
|
+
if (partOf(step.target) !== "button") throw new Unsupported(`focus on ${step.target ?? ""}`);
|
|
96
|
+
return [specEvent("focus")];
|
|
97
|
+
case "blur": return [specEvent("blur")];
|
|
98
|
+
case "click":
|
|
99
|
+
if (partOf(step.target) !== "button") throw new Unsupported(`click on ${step.target ?? ""}`);
|
|
100
|
+
return [specEvent("pointer_down"), specEvent("pointer_up")];
|
|
101
|
+
case "pointerdown": return [specEvent("pointer_down")];
|
|
102
|
+
case "pointerup": return [specEvent("pointer_up")];
|
|
103
|
+
case "pointercancel": return [specEvent("pointer_cancel")];
|
|
104
|
+
case "key": {
|
|
105
|
+
if (partOf(step.target) !== "button") throw new Unsupported(`key on ${step.target ?? ""}`);
|
|
106
|
+
const tag = keyTag(step.key);
|
|
107
|
+
if (tag === void 0) throw new Unsupported(`key ${step.key ?? ""}`);
|
|
108
|
+
if (step.phase === "up") return [specEvent("key_up", { key: tag })];
|
|
109
|
+
if (step.phase === "down") return [specEvent("focus"), specEvent("key_down", { key: tag })];
|
|
110
|
+
return [
|
|
111
|
+
specEvent("focus"),
|
|
112
|
+
specEvent("key_down", { key: tag }),
|
|
113
|
+
specEvent("key_up", { key: tag })
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
case "hover":
|
|
117
|
+
case "unhover": return [];
|
|
118
|
+
case "prop": return step.set === void 0 ? programmatic(step) : setEvents(step.set);
|
|
119
|
+
default: throw new Unsupported(`event ${step.event}`);
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
stepFields: ["set", "phase"],
|
|
123
|
+
eventName: canonicalEvent,
|
|
124
|
+
focus: (state) => state["focused"] === true ? "button" : null,
|
|
125
|
+
attr: (state, target, name) => {
|
|
126
|
+
if (partOf(target) !== "button") throw new Unsupported(`attribute ${name} on ${target}`);
|
|
127
|
+
if (name === "role") return "button";
|
|
128
|
+
if (name === "aria-pressed") {
|
|
129
|
+
if (state["isToggle"] !== true) return null;
|
|
130
|
+
return state["pressed"] === true ? "true" : "false";
|
|
131
|
+
}
|
|
132
|
+
if (name === "aria-disabled") return state["disabled"] === true ? "true" : null;
|
|
133
|
+
throw new Unsupported(`attribute ${name} on ${target}`);
|
|
134
|
+
},
|
|
135
|
+
visible: () => [],
|
|
136
|
+
events: (before, after) => before["requests"] === after["requests"] ? [] : [["onPressedChange", after["requested"] === true]]
|
|
137
|
+
};
|
|
138
|
+
/** The user-level steps a differential walk draws from. */
|
|
139
|
+
const buttonSteps = [
|
|
140
|
+
{
|
|
141
|
+
event: "focus",
|
|
142
|
+
target: "button"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
event: "blur",
|
|
146
|
+
target: "button"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
event: "click",
|
|
150
|
+
target: "button"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
event: "key",
|
|
154
|
+
key: "Enter",
|
|
155
|
+
target: "button"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
event: "key",
|
|
159
|
+
key: " ",
|
|
160
|
+
target: "button"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
event: "key",
|
|
164
|
+
key: " ",
|
|
165
|
+
phase: "down",
|
|
166
|
+
target: "button"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
event: "key",
|
|
170
|
+
key: " ",
|
|
171
|
+
phase: "up",
|
|
172
|
+
target: "button"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
event: "prop",
|
|
176
|
+
prop: "disabled",
|
|
177
|
+
value: true
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
event: "prop",
|
|
181
|
+
prop: "disabled",
|
|
182
|
+
value: false
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
event: "prop",
|
|
186
|
+
prop: "pressed",
|
|
187
|
+
value: true
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
event: "prop",
|
|
191
|
+
prop: "pressed",
|
|
192
|
+
value: false
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
event: "prop",
|
|
196
|
+
prop: "hostToggle"
|
|
197
|
+
}
|
|
198
|
+
];
|
|
199
|
+
const buttonProbe = {
|
|
200
|
+
attrs: [
|
|
201
|
+
["button", "role"],
|
|
202
|
+
["button", "aria-pressed"],
|
|
203
|
+
["button", "aria-disabled"]
|
|
204
|
+
],
|
|
205
|
+
events: ["onPressedChange"]
|
|
206
|
+
};
|
|
207
|
+
//#endregion
|
|
208
|
+
export { buttonBridge, buttonConfig, buttonProbe, buttonSteps, canonicalEvent };
|