@joralvmel/cosmos-core 0.2.0 → 0.3.0

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.
Files changed (57) hide show
  1. package/dist/catalog.d.ts +3 -3
  2. package/dist/catalog.d.ts.map +1 -1
  3. package/dist/catalog.js +14 -3
  4. package/dist/catalog.js.map +1 -1
  5. package/dist/codegen.d.ts +10 -0
  6. package/dist/codegen.d.ts.map +1 -1
  7. package/dist/codegen.js +191 -55
  8. package/dist/codegen.js.map +1 -1
  9. package/dist/headless/listbox.d.ts +9 -0
  10. package/dist/headless/listbox.d.ts.map +1 -0
  11. package/dist/headless/listbox.js +107 -0
  12. package/dist/headless/listbox.js.map +1 -0
  13. package/dist/headless/text-field.d.ts +25 -0
  14. package/dist/headless/text-field.d.ts.map +1 -0
  15. package/dist/headless/text-field.js +12 -0
  16. package/dist/headless/text-field.js.map +1 -0
  17. package/dist/index.d.ts +636 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +19 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/markdown.d.ts.map +1 -1
  22. package/dist/markdown.js +7 -3
  23. package/dist/markdown.js.map +1 -1
  24. package/dist/specs/icon-button.d.ts +136 -0
  25. package/dist/specs/icon-button.d.ts.map +1 -0
  26. package/dist/specs/icon-button.js +119 -0
  27. package/dist/specs/icon-button.js.map +1 -0
  28. package/dist/specs/icon-button.scenarios.d.ts +28 -0
  29. package/dist/specs/icon-button.scenarios.d.ts.map +1 -0
  30. package/dist/specs/icon-button.scenarios.js +95 -0
  31. package/dist/specs/icon-button.scenarios.js.map +1 -0
  32. package/dist/specs/listbox.d.ts +162 -0
  33. package/dist/specs/listbox.d.ts.map +1 -0
  34. package/dist/specs/listbox.js +144 -0
  35. package/dist/specs/listbox.js.map +1 -0
  36. package/dist/specs/listbox.scenarios.d.ts +37 -0
  37. package/dist/specs/listbox.scenarios.d.ts.map +1 -0
  38. package/dist/specs/listbox.scenarios.js +110 -0
  39. package/dist/specs/listbox.scenarios.js.map +1 -0
  40. package/dist/specs/popover.d.ts +213 -0
  41. package/dist/specs/popover.d.ts.map +1 -0
  42. package/dist/specs/popover.js +181 -0
  43. package/dist/specs/popover.js.map +1 -0
  44. package/dist/specs/popover.scenarios.d.ts +77 -0
  45. package/dist/specs/popover.scenarios.d.ts.map +1 -0
  46. package/dist/specs/popover.scenarios.js +368 -0
  47. package/dist/specs/popover.scenarios.js.map +1 -0
  48. package/dist/specs/text-field.d.ts +246 -0
  49. package/dist/specs/text-field.d.ts.map +1 -0
  50. package/dist/specs/text-field.js +229 -0
  51. package/dist/specs/text-field.js.map +1 -0
  52. package/dist/specs/text-field.scenarios.d.ts +49 -0
  53. package/dist/specs/text-field.scenarios.d.ts.map +1 -0
  54. package/dist/specs/text-field.scenarios.js +88 -0
  55. package/dist/specs/text-field.scenarios.js.map +1 -0
  56. package/llms.md +262 -0
  57. package/package.json +1 -1
@@ -0,0 +1,213 @@
1
+ /** Cause of a close request, not notification that the panel has closed. */
2
+ export type PopoverCloseReason = 'trigger' | 'escape' | 'outside' | 'action' | 'back' | 'close-button' | 'hover' | 'focus';
3
+ /**
4
+ * An opening proposal cannot be vetoed. Closing proposals can be vetoed synchronously.
5
+ * On web, detail.preventDefault() and the original CustomEvent.preventDefault() share
6
+ * cancellation state; React/Angular receive that original event. Native receives this detail.
7
+ * Returning false or canceling after dispatch has completed has no effect.
8
+ */
9
+ export type PopoverOpenChangeDetail = {
10
+ open: true;
11
+ reason: 'trigger' | 'hover' | 'focus';
12
+ } | {
13
+ open: false;
14
+ reason: PopoverCloseReason;
15
+ readonly defaultPrevented: boolean;
16
+ preventDefault(): void;
17
+ };
18
+ /** Requested physical side of the trigger; alignment uses the current writing direction. */
19
+ export type PopoverSide = 'top' | 'right' | 'bottom' | 'left';
20
+ export type PopoverAlign = 'start' | 'center' | 'end';
21
+ /**
22
+ * Imperative action-close surface: the web element, React ref, Angular component instance
23
+ * and native ref expose requestClose(). It proposes reason "action" only while open.
24
+ * It does not force controlled state, bypass cancellation or emit a committed-close event.
25
+ */
26
+ export interface PopoverHandle {
27
+ requestClose(): void;
28
+ }
29
+ /**
30
+ * Generic non-modal anchored content. There is no generic APG Popover pattern; the HTML
31
+ * Popover specification is a reference, not a requirement to use its native auto behavior.
32
+ *
33
+ * | State | Autonomous | Controlled | Event |
34
+ * | --- | --- | --- | --- |
35
+ * | open | Initialized once from defaultOpen; commits uncanceled proposals | Supplied open, including false, stays unchanged until the owner updates it | openChange proposes the next value |
36
+ *
37
+ * | Event | DOM | React | Angular | Native |
38
+ * | --- | --- | --- | --- | --- |
39
+ * | openChange | cosm-open-change | onOpenChange | openChange | onOpenChange |
40
+ *
41
+ * Web events bubble and are composed; only closing proposals are cancelable. Cancellation
42
+ * precedes autonomous commit. Owners must also honor a canceled controlled proposal.
43
+ * Owner prop updates never emit proposals and cannot be vetoed. A refused/canceled close
44
+ * never hides the panel or moves focus. Focus effects wait for an actual state transition.
45
+ * A controlled acceptance may restore focus only for its latest uncanceled close proposal;
46
+ * a later proposal supersedes it. Unsolicited prop closure does not restore focus.
47
+ *
48
+ * Consumers supply one keyboard-operable trigger and the panel content (web named trigger
49
+ * slot/default slot; native trigger content/children). Expose committed expanded state on
50
+ * the trigger (aria-expanded/accessibilityState.expanded); preserve its accessible name.
51
+ * Do not add a panel role, aria-modal, aria-haspopup, a focus trap or menu keyboard behavior.
52
+ * Content semantics/naming belong to the consumer. Closed content is hidden from focus and
53
+ * accessibility. Enter/Space use the trigger's ordinary activation, never duplicate it.
54
+ *
55
+ * Escape already handled by a child does not dismiss. Outside means a press outside both
56
+ * trigger and panel, including their descendants; never consume that target's interaction,
57
+ * even when closure is canceled. Focus leaving by Tab alone does not close the panel.
58
+ * Escape is supported on web and React Native Web, not by native Android or iOS hardware
59
+ * keyboards. Android Back requests reason "back" while open, consumes that Back even if vetoed, and
60
+ * does not navigate behind the panel. A canceled predictive Back gesture does not request
61
+ * closure. Back has no effect on other platforms. Guaranteed nested-overlay ordering is
62
+ * excluded.
63
+ *
64
+ * requestClose() is an imperative method, not a prop/event; see PopoverHandle.
65
+ * Hover mode adds pointer/focus opening on web (including React Native Web), never removes
66
+ * press activation, never steals focus on hover/focus opening, and keeps content reachable
67
+ * across the gap. Leaving both trigger and panel requests closure after 150ms unless focus
68
+ * remains inside. Escape/close-button dismissal suppresses reopening until pointer and focus
69
+ * leave. Android/iOS use press activation. No tooltip semantics are inferred.
70
+ * The optional close control uses IconButton and an individual Lucide X (ADR 0005).
71
+ * Arrow follows the actual side and trigger center, hiding when corners or collisions prevent
72
+ * a correct pointer. Gap measures free space to its tip (or panel edge without an arrow).
73
+ * No animation, named sizes or tones are added.
74
+ */
75
+ export declare const popoverContract: {
76
+ readonly name: "popover";
77
+ readonly tag: "cosm-popover";
78
+ readonly description: "Non-modal content anchored to a consumer trigger, with cancelable close requests and no imposed panel semantics.";
79
+ readonly role: "";
80
+ readonly pattern: "https://html.spec.whatwg.org/multipage/popover.html";
81
+ readonly props: {
82
+ readonly open: {
83
+ readonly type: "boolean";
84
+ readonly default: false;
85
+ readonly reflect: true;
86
+ readonly description: "Committed visibility. Supplying this prop, including false, controls state; its metadata default does not establish a binding.";
87
+ };
88
+ readonly defaultOpen: {
89
+ readonly type: "boolean";
90
+ readonly default: false;
91
+ readonly description: "Initial autonomous visibility only; ignored when open is supplied. Later updates do not reset state.";
92
+ };
93
+ readonly triggerMode: {
94
+ readonly type: "enum";
95
+ readonly values: readonly ["press", "hover"];
96
+ readonly default: "press";
97
+ readonly description: "Hover adds pointer and keyboard-focus opening on web and React Native Web, while keeping press activation. Android/iOS use press. Does not change panel semantics.";
98
+ };
99
+ readonly closable: {
100
+ readonly type: "boolean";
101
+ readonly default: false;
102
+ readonly description: "Shows a built-in IconButton with an X. Requests a cancelable close with reason close-button.";
103
+ };
104
+ readonly closeLabel: {
105
+ readonly type: "string";
106
+ readonly default: "Close";
107
+ readonly description: "Localized accessible name of the close button. Must be non-empty when closable is true.";
108
+ };
109
+ readonly gap: {
110
+ readonly type: "number";
111
+ readonly default: 8;
112
+ readonly description: "Non-negative finite distance from trigger to panel, or to the arrow tip. CSS pixels on web, logical units on native. Viewport/safe-area collision handling takes priority.";
113
+ };
114
+ readonly arrow: {
115
+ readonly type: "boolean";
116
+ readonly default: false;
117
+ readonly description: "Shows a decorative triangular pointer (16 wide, 8 deep), following the actual side, panel background and border. Hidden if it cannot point to the trigger without crossing a corner or viewport edge.";
118
+ };
119
+ readonly closeOnEscape: {
120
+ readonly type: "boolean";
121
+ readonly default: true;
122
+ readonly description: "Requests closure on unhandled Escape on web and React Native Web. Native Android and iOS hardware Escape is not supported.";
123
+ };
124
+ readonly closeOnOutsidePress: {
125
+ readonly type: "boolean";
126
+ readonly default: true;
127
+ readonly description: "Requests closure on an outside press without preventing its interaction or restoring trigger focus.";
128
+ };
129
+ readonly initialFocus: {
130
+ readonly type: "boolean";
131
+ readonly default: false;
132
+ readonly description: "On committed opening (including initially open), focus the first focusable panel descendant, falling back to the panel without adding semantics. False leaves focus unchanged. Native moves accessible/input focus where supported.";
133
+ };
134
+ readonly restoreFocus: {
135
+ readonly type: "boolean";
136
+ readonly default: true;
137
+ readonly description: "After committed trigger, Escape, action or Back closure, restore focus only if still inside the panel and the trigger is connected and focusable. Never steal outside focus, restore after outside press, or restore for unsolicited prop closure.";
138
+ };
139
+ readonly side: {
140
+ readonly type: "enum";
141
+ readonly values: readonly ["top", "right", "bottom", "left"];
142
+ readonly default: "bottom";
143
+ readonly reflect: true;
144
+ readonly description: "Requested physical side; actual placement may flip. Recompute for trigger/panel size, viewport/safe-area, scrolling and orientation changes.";
145
+ };
146
+ readonly align: {
147
+ readonly type: "enum";
148
+ readonly values: readonly ["start", "center", "end"];
149
+ readonly default: "center";
150
+ readonly reflect: true;
151
+ readonly description: "Cross-axis alignment. On top/bottom, start/end follow inline direction (RTL reverses them); on left/right they mean top/bottom.";
152
+ };
153
+ readonly flip: {
154
+ readonly type: "boolean";
155
+ readonly default: true;
156
+ readonly description: "Try the opposite side when the requested side overflows the available viewport/safe area; flip only if it reduces main-axis overflow. Ties keep the requested side. Runs before shift.";
157
+ };
158
+ readonly shift: {
159
+ readonly type: "boolean";
160
+ readonly default: true;
161
+ readonly description: "After flip, translate within available viewport/safe-area bounds to reduce overflow. Constrain oversized panels to that region regardless of collision flags; flags never change requested props.";
162
+ };
163
+ };
164
+ readonly events: {
165
+ readonly openChange: {
166
+ readonly description: "Proposes visibility changes by trigger, hover or focus, or closure by Escape, outside press, panel action, close button or Android Back. Closing only is cancelable, synchronously via the web event or detail.preventDefault(); native uses detail.preventDefault(). Not a committed-state notification.";
167
+ readonly detail: "PopoverOpenChangeDetail";
168
+ readonly cancelable: true;
169
+ readonly names: {
170
+ readonly dom: "cosm-open-change";
171
+ readonly react: "onOpenChange";
172
+ readonly angular: "openChange";
173
+ readonly native: "onOpenChange";
174
+ };
175
+ };
176
+ };
177
+ readonly states: readonly [{
178
+ readonly prop: "open";
179
+ readonly event: "openChange";
180
+ readonly defaultProp: "defaultOpen";
181
+ }];
182
+ readonly slots: {
183
+ readonly trigger: "Consumer-supplied accessible trigger; its appearance and label belong to the consumer. Native accepts content or a render function receiving onPress, ref and accessibilityState for composing an IconButton without nested buttons.";
184
+ readonly '': "Consumer-supplied panel content and semantics. Native maps this content to children.";
185
+ };
186
+ readonly parts: {
187
+ readonly trigger: "Trigger container.";
188
+ readonly panel: "Non-modal anchored surface.";
189
+ readonly body: "Scrollable consumer content.";
190
+ readonly close: "Optional close IconButton.";
191
+ readonly arrow: "Decorative pointer; follows panel colors.";
192
+ };
193
+ readonly cssProperties: {
194
+ readonly '--cosm-popover-z-index': "Panel stacking level.";
195
+ readonly '--cosm-popover-padding': "Panel padding.";
196
+ readonly '--cosm-popover-radius': "Panel corner radius.";
197
+ readonly '--cosm-popover-shadow': "Panel shadow.";
198
+ };
199
+ readonly keyboard: readonly [{
200
+ readonly keys: readonly ["Enter", "Space"];
201
+ readonly action: "The focused trigger activates once and toggles open.";
202
+ }, {
203
+ readonly keys: readonly ["Escape"];
204
+ readonly action: "On web and React Native Web, requests close when open and closeOnEscape is true, unless a child already handled the key.";
205
+ }, {
206
+ readonly keys: readonly ["Tab", "Shift+Tab"];
207
+ readonly action: "Moves focus normally without a focus trap or automatic dismissal.";
208
+ }, {
209
+ readonly keys: readonly ["Android Back"];
210
+ readonly action: "Requests close while open on Android only.";
211
+ }];
212
+ };
213
+ //# sourceMappingURL=popover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../src/specs/popover.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,MAAM,MAAM,kBAAkB,GAC1B,SAAS,GACT,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,MAAM,GACN,cAAc,GACd,OAAO,GACP,OAAO,CAAC;AAEZ;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAC/B;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,OAAO,CAAA;CAAE,GACrD;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,kBAAkB,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,cAAc,IAAI,IAAI,CAAC;CACxB,CAAC;AAEN,4FAA4F;AAC5F,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAC9D,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEtD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,YAAY,IAAI,IAAI,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuJ1B,CAAC"}
@@ -0,0 +1,181 @@
1
+ import { defineContract } from '../contract.js';
2
+ /**
3
+ * Generic non-modal anchored content. There is no generic APG Popover pattern; the HTML
4
+ * Popover specification is a reference, not a requirement to use its native auto behavior.
5
+ *
6
+ * | State | Autonomous | Controlled | Event |
7
+ * | --- | --- | --- | --- |
8
+ * | open | Initialized once from defaultOpen; commits uncanceled proposals | Supplied open, including false, stays unchanged until the owner updates it | openChange proposes the next value |
9
+ *
10
+ * | Event | DOM | React | Angular | Native |
11
+ * | --- | --- | --- | --- | --- |
12
+ * | openChange | cosm-open-change | onOpenChange | openChange | onOpenChange |
13
+ *
14
+ * Web events bubble and are composed; only closing proposals are cancelable. Cancellation
15
+ * precedes autonomous commit. Owners must also honor a canceled controlled proposal.
16
+ * Owner prop updates never emit proposals and cannot be vetoed. A refused/canceled close
17
+ * never hides the panel or moves focus. Focus effects wait for an actual state transition.
18
+ * A controlled acceptance may restore focus only for its latest uncanceled close proposal;
19
+ * a later proposal supersedes it. Unsolicited prop closure does not restore focus.
20
+ *
21
+ * Consumers supply one keyboard-operable trigger and the panel content (web named trigger
22
+ * slot/default slot; native trigger content/children). Expose committed expanded state on
23
+ * the trigger (aria-expanded/accessibilityState.expanded); preserve its accessible name.
24
+ * Do not add a panel role, aria-modal, aria-haspopup, a focus trap or menu keyboard behavior.
25
+ * Content semantics/naming belong to the consumer. Closed content is hidden from focus and
26
+ * accessibility. Enter/Space use the trigger's ordinary activation, never duplicate it.
27
+ *
28
+ * Escape already handled by a child does not dismiss. Outside means a press outside both
29
+ * trigger and panel, including their descendants; never consume that target's interaction,
30
+ * even when closure is canceled. Focus leaving by Tab alone does not close the panel.
31
+ * Escape is supported on web and React Native Web, not by native Android or iOS hardware
32
+ * keyboards. Android Back requests reason "back" while open, consumes that Back even if vetoed, and
33
+ * does not navigate behind the panel. A canceled predictive Back gesture does not request
34
+ * closure. Back has no effect on other platforms. Guaranteed nested-overlay ordering is
35
+ * excluded.
36
+ *
37
+ * requestClose() is an imperative method, not a prop/event; see PopoverHandle.
38
+ * Hover mode adds pointer/focus opening on web (including React Native Web), never removes
39
+ * press activation, never steals focus on hover/focus opening, and keeps content reachable
40
+ * across the gap. Leaving both trigger and panel requests closure after 150ms unless focus
41
+ * remains inside. Escape/close-button dismissal suppresses reopening until pointer and focus
42
+ * leave. Android/iOS use press activation. No tooltip semantics are inferred.
43
+ * The optional close control uses IconButton and an individual Lucide X (ADR 0005).
44
+ * Arrow follows the actual side and trigger center, hiding when corners or collisions prevent
45
+ * a correct pointer. Gap measures free space to its tip (or panel edge without an arrow).
46
+ * No animation, named sizes or tones are added.
47
+ */
48
+ export const popoverContract = defineContract({
49
+ name: 'popover',
50
+ tag: 'cosm-popover',
51
+ description: 'Non-modal content anchored to a consumer trigger, with cancelable close requests and no imposed panel semantics.',
52
+ role: '',
53
+ pattern: 'https://html.spec.whatwg.org/multipage/popover.html',
54
+ props: {
55
+ open: {
56
+ type: 'boolean',
57
+ default: false,
58
+ reflect: true,
59
+ description: 'Committed visibility. Supplying this prop, including false, controls state; its metadata default does not establish a binding.',
60
+ },
61
+ defaultOpen: {
62
+ type: 'boolean',
63
+ default: false,
64
+ description: 'Initial autonomous visibility only; ignored when open is supplied. Later updates do not reset state.',
65
+ },
66
+ triggerMode: {
67
+ type: 'enum',
68
+ values: ['press', 'hover'],
69
+ default: 'press',
70
+ description: 'Hover adds pointer and keyboard-focus opening on web and React Native Web, while keeping press activation. Android/iOS use press. Does not change panel semantics.',
71
+ },
72
+ closable: {
73
+ type: 'boolean',
74
+ default: false,
75
+ description: 'Shows a built-in IconButton with an X. Requests a cancelable close with reason close-button.',
76
+ },
77
+ closeLabel: {
78
+ type: 'string',
79
+ default: 'Close',
80
+ description: 'Localized accessible name of the close button. Must be non-empty when closable is true.',
81
+ },
82
+ gap: {
83
+ type: 'number',
84
+ default: 8,
85
+ description: 'Non-negative finite distance from trigger to panel, or to the arrow tip. CSS pixels on web, logical units on native. Viewport/safe-area collision handling takes priority.',
86
+ },
87
+ arrow: {
88
+ type: 'boolean',
89
+ default: false,
90
+ description: 'Shows a decorative triangular pointer (16 wide, 8 deep), following the actual side, panel background and border. Hidden if it cannot point to the trigger without crossing a corner or viewport edge.',
91
+ },
92
+ closeOnEscape: {
93
+ type: 'boolean',
94
+ default: true,
95
+ description: 'Requests closure on unhandled Escape on web and React Native Web. Native Android and iOS hardware Escape is not supported.',
96
+ },
97
+ closeOnOutsidePress: {
98
+ type: 'boolean',
99
+ default: true,
100
+ description: 'Requests closure on an outside press without preventing its interaction or restoring trigger focus.',
101
+ },
102
+ initialFocus: {
103
+ type: 'boolean',
104
+ default: false,
105
+ description: 'On committed opening (including initially open), focus the first focusable panel descendant, falling back to the panel without adding semantics. False leaves focus unchanged. Native moves accessible/input focus where supported.',
106
+ },
107
+ restoreFocus: {
108
+ type: 'boolean',
109
+ default: true,
110
+ description: 'After committed trigger, Escape, action or Back closure, restore focus only if still inside the panel and the trigger is connected and focusable. Never steal outside focus, restore after outside press, or restore for unsolicited prop closure.',
111
+ },
112
+ side: {
113
+ type: 'enum',
114
+ values: ['top', 'right', 'bottom', 'left'],
115
+ default: 'bottom',
116
+ reflect: true,
117
+ description: 'Requested physical side; actual placement may flip. Recompute for trigger/panel size, viewport/safe-area, scrolling and orientation changes.',
118
+ },
119
+ align: {
120
+ type: 'enum',
121
+ values: ['start', 'center', 'end'],
122
+ default: 'center',
123
+ reflect: true,
124
+ description: 'Cross-axis alignment. On top/bottom, start/end follow inline direction (RTL reverses them); on left/right they mean top/bottom.',
125
+ },
126
+ flip: {
127
+ type: 'boolean',
128
+ default: true,
129
+ description: 'Try the opposite side when the requested side overflows the available viewport/safe area; flip only if it reduces main-axis overflow. Ties keep the requested side. Runs before shift.',
130
+ },
131
+ shift: {
132
+ type: 'boolean',
133
+ default: true,
134
+ description: 'After flip, translate within available viewport/safe-area bounds to reduce overflow. Constrain oversized panels to that region regardless of collision flags; flags never change requested props.',
135
+ },
136
+ },
137
+ events: {
138
+ openChange: {
139
+ description: 'Proposes visibility changes by trigger, hover or focus, or closure by Escape, outside press, panel action, close button or Android Back. Closing only is cancelable, synchronously via the web event or detail.preventDefault(); native uses detail.preventDefault(). Not a committed-state notification.',
140
+ detail: 'PopoverOpenChangeDetail',
141
+ cancelable: true,
142
+ names: {
143
+ dom: 'cosm-open-change',
144
+ react: 'onOpenChange',
145
+ angular: 'openChange',
146
+ native: 'onOpenChange',
147
+ },
148
+ },
149
+ },
150
+ states: [{ prop: 'open', event: 'openChange', defaultProp: 'defaultOpen' }],
151
+ slots: {
152
+ trigger: 'Consumer-supplied accessible trigger; its appearance and label belong to the consumer. Native accepts content or a render function receiving onPress, ref and accessibilityState for composing an IconButton without nested buttons.',
153
+ '': 'Consumer-supplied panel content and semantics. Native maps this content to children.',
154
+ },
155
+ parts: {
156
+ trigger: 'Trigger container.',
157
+ panel: 'Non-modal anchored surface.',
158
+ body: 'Scrollable consumer content.',
159
+ close: 'Optional close IconButton.',
160
+ arrow: 'Decorative pointer; follows panel colors.',
161
+ },
162
+ cssProperties: {
163
+ '--cosm-popover-z-index': 'Panel stacking level.',
164
+ '--cosm-popover-padding': 'Panel padding.',
165
+ '--cosm-popover-radius': 'Panel corner radius.',
166
+ '--cosm-popover-shadow': 'Panel shadow.',
167
+ },
168
+ keyboard: [
169
+ { keys: ['Enter', 'Space'], action: 'The focused trigger activates once and toggles open.' },
170
+ {
171
+ keys: ['Escape'],
172
+ action: 'On web and React Native Web, requests close when open and closeOnEscape is true, unless a child already handled the key.',
173
+ },
174
+ {
175
+ keys: ['Tab', 'Shift+Tab'],
176
+ action: 'Moves focus normally without a focus trap or automatic dismissal.',
177
+ },
178
+ { keys: ['Android Back'], action: 'Requests close while open on Android only.' },
179
+ ],
180
+ });
181
+ //# sourceMappingURL=popover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover.js","sour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KAAK,EAAE;QACL,OAAO,EAAE,oBAAoB;QAC7B,KAAK,EAAE,6BAA6B;QACpC,IAAI,EAAE,8BAA8B;QACpC,KAAK,EAAE,4BAA4B;QACnC,KAAK,EAAE,2CAA2C;KACnD;IACD,aAAa,EAAE;QACb,wBAAwB,EAAE,uBAAuB;QACjD,wBAAwB,EAAE,gBAAgB;QAC1C,uBAAuB,EAAE,sBAAsB;QAC/C,uBAAuB,EAAE,eAAe;KACzC;IACD,QAAQ,EAAE;QACR,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,sDAAsD,EAAE;QAC5F;YACE,IAAI,EAAE,CAAC,QAAQ,CAAC;YAChB,MAAM,EACJ,0HAA0H;SAC7H;QACD;YACE,IAAI,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC;YAC1B,MAAM,EAAE,mEAAmE;SAC5E;QACD,EAAE,IAAI,EAAE,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,4CAA4C,EAAE;KACjF;CACF,CAAC,CAAC"}
@@ -0,0 +1,77 @@
1
+ import type { ContractProps, Platform } from '../contract.js';
2
+ import type { PopoverCloseReason, popoverContract } from './popover.js';
3
+ /**
4
+ * Drivers install cancellation before the action, using the original event on web/wrappers
5
+ * or detail.preventDefault() on native. They record proposals even when canceled.
6
+ * A sync simulates the owner setting open; it never emits a proposal.
7
+ */
8
+ export type PopoverAction = {
9
+ type: 'trigger';
10
+ source: 'pointer' | 'touch' | 'keyboard';
11
+ cancel?: boolean;
12
+ } | {
13
+ type: 'escape';
14
+ handled?: boolean;
15
+ cancel?: boolean;
16
+ } | {
17
+ type: 'outside';
18
+ focusable: boolean;
19
+ cancel?: boolean;
20
+ } | {
21
+ type: 'action' | 'back' | 'close-button';
22
+ cancel?: boolean;
23
+ } | {
24
+ type: 'sync';
25
+ open: boolean;
26
+ } | {
27
+ type: 'set-default';
28
+ defaultOpen: boolean;
29
+ } | {
30
+ type: 'focus';
31
+ target: 'trigger' | 'panel' | 'outside';
32
+ };
33
+ /** Serializable projection of a proposal; cancellation functions are not snapshot data. */
34
+ export type PopoverChangeExpectation = {
35
+ open: true;
36
+ reason: 'trigger' | 'hover' | 'focus';
37
+ canceled: false;
38
+ } | {
39
+ open: false;
40
+ reason: PopoverCloseReason;
41
+ canceled: boolean;
42
+ };
43
+ export interface PopoverScenario {
44
+ name: string;
45
+ props: ContractProps<typeof popoverContract, 'web'>;
46
+ /** Focus starts on the trigger. By default the panel contains a focusable child. */
47
+ fixture?: {
48
+ panelHasFocusableContent?: boolean;
49
+ triggerFocusable?: boolean;
50
+ };
51
+ actions: readonly PopoverAction[];
52
+ expected: {
53
+ open: boolean;
54
+ /** Committed visibility after every action, including syncs and ignored actions. */
55
+ openAfterEachAction: readonly boolean[];
56
+ changes: readonly PopoverChangeExpectation[];
57
+ /**
58
+ * Unmanaged means hiding focused content leaves fallback to the platform: assert
59
+ * no component restoration, not that focus remains in hidden/unmounted content.
60
+ */
61
+ focus: 'trigger' | 'panel-first' | 'panel' | 'outside' | 'unmanaged';
62
+ /** Outside targets receive every press, even when closed, controlled or canceled. */
63
+ outsidePresses: number;
64
+ };
65
+ platforms?: readonly Platform[];
66
+ }
67
+ /**
68
+ * Shared normative cases, not a platform implementation. Drivers use a first focusable
69
+ * panel child unless the fixture opts out. "panel" includes the panel or a descendant;
70
+ * "panel-first" specifically asserts the initial-focus target. For outside presses on
71
+ * a nonfocusable target, the fixture preserves focus so lack of restoration is observable.
72
+ * Native Escape cases exercise React Native Web; hardware Escape is not supported on Android
73
+ * or iOS. Back cases are native Android cases; native drivers must run them in Android mode.
74
+ */
75
+ export declare const popoverScenarios: readonly PopoverScenario[];
76
+ export declare const popoverScenariosFor: (platform: Platform) => PopoverScenario[];
77
+ //# sourceMappingURL=popover.scenarios.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover.scenarios.d.ts","sourceRoot":"","sources":["../../src/specs/popover.scenarios.ts"],"names":[],"mappings":"AAAA,OA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