@salmonui/overlays 0.0.0-stage → 0.2.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 (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -2
  3. package/dist/dialog/AlertDialog.d.ts +62 -0
  4. package/dist/dialog/AlertDialog.d.ts.map +1 -0
  5. package/dist/dialog/AlertDialog.js +100 -0
  6. package/dist/dialog/AlertDialog.js.map +1 -0
  7. package/dist/dialog/Dialog.d.ts +15 -0
  8. package/dist/dialog/Dialog.d.ts.map +1 -0
  9. package/dist/dialog/Dialog.js +17 -0
  10. package/dist/dialog/Dialog.js.map +1 -0
  11. package/dist/dialog.css +656 -0
  12. package/dist/dialog.d.ts +6 -0
  13. package/dist/dialog.d.ts.map +1 -0
  14. package/dist/dialog.js +13 -0
  15. package/dist/dialog.js.map +1 -0
  16. package/dist/drawer/Drawer.d.ts +23 -0
  17. package/dist/drawer/Drawer.d.ts.map +1 -0
  18. package/dist/drawer/Drawer.js +11 -0
  19. package/dist/drawer/Drawer.js.map +1 -0
  20. package/dist/drawer.css +247 -0
  21. package/dist/drawer.d.ts +5 -0
  22. package/dist/drawer.d.ts.map +1 -0
  23. package/dist/drawer.js +11 -0
  24. package/dist/drawer.js.map +1 -0
  25. package/dist/internal/placement.d.ts +18 -0
  26. package/dist/internal/placement.d.ts.map +1 -0
  27. package/dist/internal/placement.js +19 -0
  28. package/dist/internal/placement.js.map +1 -0
  29. package/dist/popover/Popover.d.ts +99 -0
  30. package/dist/popover/Popover.d.ts.map +1 -0
  31. package/dist/popover/Popover.js +140 -0
  32. package/dist/popover/Popover.js.map +1 -0
  33. package/dist/popover.css +116 -0
  34. package/dist/popover.d.ts +3 -0
  35. package/dist/popover.d.ts.map +1 -0
  36. package/dist/popover.js +9 -0
  37. package/dist/popover.js.map +1 -0
  38. package/dist/styles.css +870 -0
  39. package/dist/tooltip/Tooltip.d.ts +87 -0
  40. package/dist/tooltip/Tooltip.d.ts.map +1 -0
  41. package/dist/tooltip/Tooltip.js +183 -0
  42. package/dist/tooltip/Tooltip.js.map +1 -0
  43. package/dist/tooltip.css +57 -0
  44. package/dist/tooltip.d.ts +3 -0
  45. package/dist/tooltip.d.ts.map +1 -0
  46. package/dist/tooltip.js +8 -0
  47. package/dist/tooltip.js.map +1 -0
  48. package/package.json +57 -4
@@ -0,0 +1,23 @@
1
+ import type { ReactElement } from 'react';
2
+ import { type DialogParts, type DialogProps } from '@salmonui/core/internal/dialog-core/Dialog';
3
+ export interface DrawerProps extends Omit<DialogProps, 'placement' | 'position' | 'defaultPosition' | 'onPositionChange' | 'draggable' | 'dragHandle' | 'onMoveStart' | 'onMove' | 'onMoveEnd' | 'resizable' | 'onResizeStart' | 'onResize' | 'onResizeEnd' | 'fullScreen'> {
4
+ /** Edge the panel slides from: logical `'start'` (default) / `'end'`, or `'top'` / `'bottom'`. */
5
+ readonly side?: 'start' | 'end' | 'top' | 'bottom' | undefined;
6
+ /** Inline size (start / end) or block size (top / bottom), number px or CSS length. Default 320 px. */
7
+ readonly size?: number | string | undefined;
8
+ }
9
+ /**
10
+ * Drawer (`.salmon-drawer`): a modal (or modeless) dialog docked to an edge,
11
+ * on the same dialog host. Escape and a backdrop press close it by default.
12
+ * The Navigation category's Sidebar overlay mode renders it.
13
+ */
14
+ export declare namespace Drawer {
15
+ const Trigger: DialogParts['Trigger'];
16
+ const Close: DialogParts['Close'];
17
+ const Title: DialogParts['Title'];
18
+ const Description: DialogParts['Description'];
19
+ const Body: DialogParts['Body'];
20
+ const Footer: DialogParts['Footer'];
21
+ }
22
+ export declare function Drawer(props: DrawerProps): ReactElement;
23
+ //# sourceMappingURL=Drawer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../src/drawer/Drawer.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAA0B,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAGxH,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,UAAU,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,WAAW,GAAG,YAAY,GAAG,aAAa,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,GAAG,eAAe,GAAG,UAAU,GAAG,aAAa,GAAG,YAAY,CAAC;IACzQ,kGAAkG;IAClG,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC/D,uGAAuG;IACvG,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAC7C;AAED;;;;GAIG;AAEH,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IACvB,MAAM,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACtC,MAAM,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,WAAW,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;IAC9C,MAAM,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;CAC5C;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CAIvD"}
@@ -0,0 +1,11 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { css, DialogRoot, PARTS } from '@salmonui/core/internal/dialog-core/Dialog';
4
+ import { useLocaleText } from '@salmonui/core/internal/locale';
5
+ export function Drawer(props) {
6
+ const { side = 'start', size, style, dismissible = true, ...rest } = props;
7
+ const localeText = useLocaleText('dialog', props.localeText);
8
+ return _jsx(DialogRoot, { ...rest, localeText: localeText, dismissible: dismissible, kind: "drawer", side: side, style: size === undefined ? style : { ...style, '--salmon-drawer-size': css(size) } });
9
+ }
10
+ Object.assign(Drawer, PARTS);
11
+ //# sourceMappingURL=Drawer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Drawer.js","sourceRoot":"","sources":["../../src/drawer/Drawer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AASb,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAsC,MAAM,4CAA4C,CAAC;AACxH,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAuB/D,MAAM,UAAU,MAAM,CAAC,KAAkB;IACvC,MAAM,EAAE,IAAI,GAAG,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAC3E,MAAM,UAAU,GAAG,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC7D,OAAO,KAAC,UAAU,OAAK,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,sBAAsB,EAAE,GAAG,CAAC,IAAI,CAAC,EAAmB,GAAI,CAAC;AACpN,CAAC;AAED,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC"}
@@ -0,0 +1,247 @@
1
+ @layer salmon.a,salmon.b;
2
+ @layer salmon.a {
3
+ /* Dialog core (no subpath): the native <dialog> surface, parts, close button,
4
+ drag and resize handles, full-screen sheets. Carried by /dialog/styles.css
5
+ and /drawer/styles.css. Logical properties only. */
6
+
7
+ /* Direction sign: -1 under the nearest dir="rtl", 1 under dir="ltr". */
8
+ :where([dir='rtl']) { --salmon-dir: -1; }
9
+ :where([dir='ltr']) { --salmon-dir: 1; }
10
+
11
+ .salmon-dialog {
12
+ --salmon-dialog-x: 0px;
13
+ --salmon-dialog-y: 0px;
14
+ box-sizing: border-box;
15
+ display: none;
16
+ flex-direction: column;
17
+ inline-size: min(560px, calc(100vw - 32px));
18
+ max-inline-size: calc(100vw - 32px);
19
+ max-block-size: calc(100dvh - 32px);
20
+ margin: auto;
21
+ padding: 0;
22
+ overflow: hidden;
23
+ font-family: var(--salmon-font-sans);
24
+ font-size: var(--salmon-font-size-md);
25
+ line-height: var(--salmon-line-height-normal);
26
+ color: var(--salmon-text-primary);
27
+ background: var(--salmon-surface-overlay);
28
+ border: 1px solid var(--salmon-border-default);
29
+ border-radius: var(--salmon-radius-lg);
30
+ box-shadow: var(--salmon-shadow-lg);
31
+ translate: calc(var(--salmon-dialog-x) * var(--salmon-dir, 1)) var(--salmon-dialog-y);
32
+ opacity: 1;
33
+ transition: opacity 150ms ease-out, display 150ms allow-discrete, overlay 150ms allow-discrete;
34
+ }
35
+
36
+ .salmon-dialog[open] {
37
+ display: flex;
38
+ }
39
+
40
+ @starting-style {
41
+ .salmon-dialog[open] {
42
+ opacity: 0;
43
+ }
44
+ }
45
+
46
+ .salmon-dialog *,
47
+ .salmon-dialog ::before,
48
+ .salmon-dialog ::after {
49
+ box-sizing: border-box;
50
+ }
51
+
52
+ .salmon-dialog::backdrop {
53
+ background: var(--salmon-surface-backdrop);
54
+ }
55
+
56
+ .salmon-dialog:not([data-modal]) {
57
+ position: fixed;
58
+ inset: 0;
59
+ z-index: 1000;
60
+ }
61
+
62
+ .salmon-dialog[data-contained] {
63
+ position: absolute;
64
+ max-inline-size: 100%;
65
+ max-block-size: 100%;
66
+ }
67
+
68
+ .salmon-dialog[data-placement='top'] {
69
+ margin-block-start: 48px;
70
+ }
71
+
72
+ .salmon-dialog:focus-visible {
73
+ outline: var(--salmon-state-focus-ring-width) solid var(--salmon-state-focus-ring);
74
+ outline-offset: var(--salmon-state-focus-ring-offset);
75
+ }
76
+
77
+ .salmon-dialog-title {
78
+ margin: 0;
79
+ padding: var(--salmon-space-4) var(--salmon-space-4) var(--salmon-space-2);
80
+ padding-inline-end: 48px;
81
+ font-size: var(--salmon-font-size-lg);
82
+ font-weight: 600;
83
+ line-height: var(--salmon-line-height-tight);
84
+ }
85
+
86
+ .salmon-dialog[data-draggable] .salmon-dialog-title {
87
+ cursor: move;
88
+ touch-action: none;
89
+ user-select: none;
90
+ }
91
+
92
+ .salmon-dialog-description {
93
+ margin: 0;
94
+ padding: 0 var(--salmon-space-4) var(--salmon-space-2);
95
+ color: var(--salmon-text-secondary);
96
+ }
97
+
98
+ .salmon-dialog-body {
99
+ flex: 1 1 auto;
100
+ min-block-size: 0;
101
+ padding: var(--salmon-space-2) var(--salmon-space-4);
102
+ overflow: auto;
103
+ }
104
+
105
+ .salmon-dialog-footer {
106
+ display: flex;
107
+ flex-wrap: wrap;
108
+ justify-content: flex-end;
109
+ gap: var(--salmon-space-2);
110
+ padding: var(--salmon-space-3) var(--salmon-space-4) var(--salmon-space-4);
111
+ }
112
+
113
+ .salmon-dialog-close-button {
114
+ position: absolute;
115
+ inset-block-start: 6px;
116
+ inset-inline-end: 6px;
117
+ display: inline-flex;
118
+ align-items: center;
119
+ justify-content: center;
120
+ inline-size: var(--salmon-control-height-md, 32px);
121
+ block-size: var(--salmon-control-height-md, 32px);
122
+ padding: 0;
123
+ color: var(--salmon-text-secondary);
124
+ background: transparent;
125
+ border: 0;
126
+ border-radius: var(--salmon-radius-md);
127
+ cursor: pointer;
128
+ }
129
+
130
+ .salmon-dialog-close-button > svg {
131
+ flex: none;
132
+ inline-size: 16px;
133
+ block-size: 16px;
134
+ }
135
+
136
+ .salmon-dialog-close-button:hover {
137
+ color: var(--salmon-text-primary);
138
+ background: var(--salmon-surface-hover);
139
+ }
140
+
141
+ .salmon-dialog-close-button:focus-visible,
142
+ .salmon-dialog-resize-handle:focus-visible,
143
+ .salmon-dialog-title:focus-visible {
144
+ outline: var(--salmon-state-focus-ring-width) solid var(--salmon-state-focus-ring);
145
+ outline-offset: calc(-1 * var(--salmon-state-focus-ring-width));
146
+ }
147
+
148
+ .salmon-dialog-live {
149
+ position: absolute;
150
+ inline-size: 1px;
151
+ block-size: 1px;
152
+ overflow: hidden;
153
+ clip-path: inset(50%);
154
+ white-space: nowrap;
155
+ }
156
+
157
+ .salmon-dialog-resize-handle {
158
+ position: absolute;
159
+ inline-size: 12px;
160
+ block-size: 12px;
161
+ touch-action: none;
162
+ }
163
+
164
+ .salmon-dialog-resize-handle[data-edge='bottomEnd'] { inset-block-end: 0; inset-inline-end: 0; cursor: nwse-resize; }
165
+ .salmon-dialog-resize-handle[data-edge='bottomStart'] { inset-block-end: 0; inset-inline-start: 0; cursor: nesw-resize; }
166
+ .salmon-dialog-resize-handle[data-edge='topEnd'] { inset-block-start: 0; inset-inline-end: 0; cursor: nesw-resize; }
167
+ .salmon-dialog-resize-handle[data-edge='topStart'] { inset-block-start: 0; inset-inline-start: 0; cursor: nwse-resize; }
168
+ .salmon-dialog-resize-handle:is([data-edge='top'], [data-edge='bottom']) { inset-inline: 12px; inline-size: auto; cursor: ns-resize; }
169
+ .salmon-dialog-resize-handle[data-edge='top'] { inset-block-start: 0; }
170
+ .salmon-dialog-resize-handle[data-edge='bottom'] { inset-block-end: 0; }
171
+ .salmon-dialog-resize-handle:is([data-edge='start'], [data-edge='end']) { inset-block: 12px; block-size: auto; cursor: ew-resize; }
172
+ .salmon-dialog-resize-handle[data-edge='start'] { inset-inline-start: 0; }
173
+ .salmon-dialog-resize-handle[data-edge='end'] { inset-inline-end: 0; }
174
+
175
+ /* Full screen: always, or below the mobile width (the Data Grid adaptive sheet rule). */
176
+ .salmon-dialog[data-full-screen='always'] {
177
+ inline-size: 100vw;
178
+ max-inline-size: none;
179
+ block-size: 100dvh;
180
+ max-block-size: none;
181
+ border: 0;
182
+ border-radius: 0;
183
+ translate: none;
184
+ }
185
+
186
+ @media (max-width: 640px) {
187
+ .salmon-dialog[data-full-screen='mobile'] {
188
+ inline-size: 100vw;
189
+ max-inline-size: none;
190
+ block-size: 100dvh;
191
+ max-block-size: none;
192
+ border: 0;
193
+ border-radius: 0;
194
+ translate: none;
195
+ }
196
+ }
197
+
198
+ @media (prefers-reduced-motion: reduce) {
199
+ .salmon-dialog {
200
+ transition: none;
201
+ }
202
+ }
203
+
204
+ }
205
+ @layer salmon.b {
206
+ /* The Drawer edge panel on the dialog core. @salmonui/overlays/drawer/styles.css
207
+ is dialog-core.css followed by this file. Logical properties only. */
208
+
209
+ /* --salmon-dir: the direction sign set by dialog-core.css. */
210
+ /* Drawer: docked to a logical edge, full block (or inline) size, slides in. */
211
+ /* Doubled class: dialog.css may load after this file on a page with both. */
212
+ .salmon-dialog.salmon-drawer {
213
+ --salmon-drawer-size: 320px;
214
+ margin: 0;
215
+ inline-size: min(var(--salmon-drawer-size), 100vw);
216
+ max-inline-size: 100vw;
217
+ block-size: 100dvh;
218
+ max-block-size: none;
219
+ border-radius: 0;
220
+ translate: none;
221
+ transition: translate 200ms ease-out, display 200ms allow-discrete, overlay 200ms allow-discrete;
222
+ }
223
+
224
+ .salmon-drawer[data-side='start'] { margin-inline-end: auto; border-block: 0; border-inline-start: 0; border-start-end-radius: var(--salmon-radius-lg); border-end-end-radius: var(--salmon-radius-lg); }
225
+ .salmon-drawer[data-side='end'] { margin-inline-start: auto; border-block: 0; border-inline-end: 0; border-start-start-radius: var(--salmon-radius-lg); border-end-start-radius: var(--salmon-radius-lg); }
226
+ .salmon-dialog.salmon-drawer:is([data-side='top'], [data-side='bottom']) {
227
+ inline-size: 100vw;
228
+ block-size: min(var(--salmon-drawer-size), 100dvh);
229
+ border-inline: 0;
230
+ }
231
+ .salmon-drawer[data-side='top'] { margin-block-end: auto; border-block-start: 0; border-end-start-radius: var(--salmon-radius-lg); border-end-end-radius: var(--salmon-radius-lg); }
232
+ .salmon-drawer[data-side='bottom'] { margin-block-start: auto; border-block-end: 0; border-start-start-radius: var(--salmon-radius-lg); border-start-end-radius: var(--salmon-radius-lg); }
233
+
234
+ @starting-style {
235
+ .salmon-drawer[open][data-side='start'] { translate: calc(-100% * var(--salmon-dir, 1)) 0; }
236
+ .salmon-drawer[open][data-side='end'] { translate: calc(100% * var(--salmon-dir, 1)) 0; }
237
+ .salmon-drawer[open][data-side='top'] { translate: 0 -100%; }
238
+ .salmon-drawer[open][data-side='bottom'] { translate: 0 100%; }
239
+ }
240
+
241
+ @media (prefers-reduced-motion: reduce) {
242
+ .salmon-drawer {
243
+ transition: none;
244
+ }
245
+ }
246
+
247
+ }
@@ -0,0 +1,5 @@
1
+ export { Drawer } from './drawer/Drawer.js';
2
+ export type { DrawerProps } from './drawer/Drawer.js';
3
+ export { DialogTrigger as DrawerTrigger, DialogClose as DrawerClose, DialogTitle as DrawerTitle, DialogDescription as DrawerDescription, DialogBody as DrawerBody, DialogFooter as DrawerFooter } from '@salmonui/core/internal/dialog-core/Dialog';
4
+ export type { DialogOpenChangeEvent as DrawerOpenChangeEvent, DialogOpenChangeReason as DrawerOpenChangeReason } from '@salmonui/core/internal/dialog-core/Dialog';
5
+ //# sourceMappingURL=drawer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../src/drawer.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,IAAI,aAAa,EAAE,WAAW,IAAI,WAAW,EAAE,WAAW,IAAI,WAAW,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,UAAU,IAAI,UAAU,EAAE,YAAY,IAAI,YAAY,EAAE,MAAM,4CAA4C,CAAC;AACpP,YAAY,EAAE,qBAAqB,IAAI,qBAAqB,EAAE,sBAAsB,IAAI,sBAAsB,EAAE,MAAM,4CAA4C,CAAC"}
package/dist/drawer.js ADDED
@@ -0,0 +1,11 @@
1
+ 'use client';
2
+ import { expectStylesheet } from '@salmonui/core/internal/dev';
3
+ // `@salmonui/overlays/drawer`: Drawer (the Navigation
4
+ // category's Sidebar overlay mode renders it). Render-safe: a closed drawer
5
+ // renders only its trigger. Composes the dialog core (`dialog-core/`); its
6
+ // stylesheet carries the dialog core and drawer rules.
7
+ export { Drawer } from './drawer/Drawer.js';
8
+ export { DialogTrigger as DrawerTrigger, DialogClose as DrawerClose, DialogTitle as DrawerTitle, DialogDescription as DrawerDescription, DialogBody as DrawerBody, DialogFooter as DrawerFooter } from '@salmonui/core/internal/dialog-core/Dialog';
9
+ if (process.env.NODE_ENV !== 'production')
10
+ expectStylesheet('@salmonui/overlays/drawer', 'salmon-drawer');
11
+ //# sourceMappingURL=drawer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawer.js","sourceRoot":"","sources":["../src/drawer.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,sDAAsD;AACtD,4EAA4E;AAC5E,2EAA2E;AAC3E,uDAAuD;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,aAAa,IAAI,aAAa,EAAE,WAAW,IAAI,WAAW,EAAE,WAAW,IAAI,WAAW,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,UAAU,IAAI,UAAU,EAAE,YAAY,IAAI,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAMpP,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;IAAE,gBAAgB,CAAC,2BAA2B,EAAE,eAAe,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Placement } from '@salmonui/core/internal/position';
2
+ export type OverlayPlacement = 'top' | 'topStart' | 'topEnd' | 'bottom' | 'bottomStart' | 'bottomEnd' | 'start' | 'startTop' | 'startBottom' | 'end' | 'endTop' | 'endBottom';
3
+ /**
4
+ * The positioning primitive's placement for a public placement:
5
+ * `topStart` -> `top-start`; on the inline sides the block word maps to the
6
+ * alignment (`startTop` -> `start-start`, `endBottom` -> `end-end`).
7
+ */
8
+ export declare function toPlacement(placement: OverlayPlacement | undefined, fallback: OverlayPlacement): Placement;
9
+ /** `offset` prop form shared by Tooltip and Popover. */
10
+ export type OverlayOffset = number | {
11
+ readonly mainAxis?: number | undefined;
12
+ readonly crossAxis?: number | undefined;
13
+ };
14
+ export declare function splitOffset(offset: OverlayOffset | undefined, fallback: number): {
15
+ main: number;
16
+ cross: number;
17
+ };
18
+ //# sourceMappingURL=placement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placement.d.ts","sourceRoot":"","sources":["../../src/internal/placement.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAElE,MAAM,MAAM,gBAAgB,GACxB,KAAK,GACL,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,aAAa,GACb,WAAW,GACX,OAAO,GACP,UAAU,GACV,aAAa,GACb,KAAK,GACL,QAAQ,GACR,WAAW,CAAC;AAEhB;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,gBAAgB,GAAG,SAAS,EAAE,QAAQ,EAAE,gBAAgB,GAAG,SAAS,CAE1G;AAED,wDAAwD;AACxD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEzH,wBAAgB,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAIhH"}
@@ -0,0 +1,19 @@
1
+ // Public placement vocabulary of the Layout overlays: twelve logical placements in camel case, resolved
2
+ // against `dir` by `internal/position.ts`. `start` / `end` are the
3
+ // inline-start / inline-end sides; the second word aligns along the edge.
4
+ /**
5
+ * The positioning primitive's placement for a public placement:
6
+ * `topStart` -> `top-start`; on the inline sides the block word maps to the
7
+ * alignment (`startTop` -> `start-start`, `endBottom` -> `end-end`).
8
+ */
9
+ export function toPlacement(placement, fallback) {
10
+ return (placement ?? fallback).replace(/[A-Z]/, (c) => `-${c.toLowerCase()}`).replace('-top', '-start').replace('-bottom', '-end');
11
+ }
12
+ export function splitOffset(offset, fallback) {
13
+ if (offset === undefined)
14
+ return { main: fallback, cross: 0 };
15
+ if (typeof offset === 'number')
16
+ return { main: offset, cross: 0 };
17
+ return { main: offset.mainAxis ?? fallback, cross: offset.crossAxis ?? 0 };
18
+ }
19
+ //# sourceMappingURL=placement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placement.js","sourceRoot":"","sources":["../../src/internal/placement.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,mEAAmE;AACnE,0EAA0E;AAkB1E;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,SAAuC,EAAE,QAA0B;IAC7F,OAAO,CAAC,SAAS,IAAI,QAAQ,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAc,CAAC;AAClJ,CAAC;AAKD,MAAM,UAAU,WAAW,CAAC,MAAiC,EAAE,QAAgB;IAC7E,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAC9D,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAClE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,QAAQ,IAAI,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,SAAS,IAAI,CAAC,EAAE,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,99 @@
1
+ import { type ButtonHTMLAttributes, type HTMLAttributes, type ReactElement, type ReactNode, type Ref, type RefObject } from 'react';
2
+ import { type OverlayOffset, type OverlayPlacement } from '../internal/placement.js';
3
+ import { type PressSource } from '@salmonui/core/internal/press';
4
+ export type PopoverPlacement = OverlayPlacement;
5
+ export type PopoverOffset = OverlayOffset;
6
+ export type PopoverOpenChangeReason = 'trigger' | 'close' | 'escape' | 'outside' | 'focus-outside' | 'api';
7
+ /** Second argument of `onOpenChange`: frozen, allocated only when a callback is bound. */
8
+ export interface PopoverOpenChangeEvent {
9
+ readonly reason: PopoverOpenChangeReason;
10
+ readonly source: PressSource | 'api';
11
+ }
12
+ export interface PopoverProps {
13
+ /** `Popover.Trigger` and `Popover.Content` (any order, any depth). */
14
+ readonly children?: ReactNode;
15
+ readonly open?: boolean | undefined;
16
+ /** Applied after hydration, so server and client markup stay identical. */
17
+ readonly defaultOpen?: boolean | undefined;
18
+ readonly onOpenChange?: ((open: boolean, event: PopoverOpenChangeEvent) => void) | undefined;
19
+ /** Logical placement, resolved against `dir`. Default `'bottom'`. Flips and shifts to stay inside the collision boundary. */
20
+ readonly placement?: PopoverPlacement | undefined;
21
+ /** Gap to the anchor in px (default 8), or `{ mainAxis, crossAxis }`. */
22
+ readonly offset?: PopoverOffset | undefined;
23
+ /** Renders an arrow pointing at the anchor. Default false. */
24
+ readonly arrow?: boolean | undefined;
25
+ /** Element whose box limits flip and shift (a scrolling container). Default the viewport. */
26
+ readonly collisionBoundary?: Element | null | undefined;
27
+ /** Anchor element other than the trigger (a field the popover belongs to). */
28
+ readonly anchor?: RefObject<Element | null> | undefined;
29
+ /** Portal target for browsers without the Popover API (top layer otherwise). Default `document.body`. */
30
+ readonly container?: Element | null | undefined;
31
+ /** Close on a press outside the content and trigger. Default true. */
32
+ readonly closeOnOutsidePress?: boolean | undefined;
33
+ /** Close on Escape. Default true. */
34
+ readonly closeOnEscape?: boolean | undefined;
35
+ /** Close when focus moves outside (Tab past the last control). Default true. */
36
+ readonly closeOnFocusOutside?: boolean | undefined;
37
+ /** Initial focus: the first tabbable control (default), the content element, or none. */
38
+ readonly initialFocus?: 'first' | 'container' | false | undefined;
39
+ /** Return focus to the trigger on close. Default true. */
40
+ readonly returnFocus?: boolean | undefined;
41
+ }
42
+ /**
43
+ * Popover root: holds the open triad and the ids. Renders no element of its
44
+ * own.
45
+ */
46
+ export declare function Popover(props: PopoverProps): ReactElement;
47
+ export declare namespace Popover {
48
+ export { PopoverTrigger as Trigger };
49
+ export { PopoverContent as Content };
50
+ export { PopoverTitle as Title };
51
+ export { PopoverDescription as Description };
52
+ export { PopoverClose as Close };
53
+ }
54
+ /** Props `Popover.Trigger` computes for its element (spread them in `render`). */
55
+ export type PopoverTriggerRenderProps = ButtonHTMLAttributes<HTMLButtonElement> & {
56
+ readonly ref: Ref<HTMLButtonElement>;
57
+ };
58
+ export interface PopoverTriggerProps extends ButtonHTMLAttributes<HTMLButtonElement> {
59
+ /** Renders another element (a `Button`, a link) with the computed props. */
60
+ readonly render?: ((props: PopoverTriggerRenderProps) => ReactElement) | undefined;
61
+ readonly ref?: Ref<HTMLButtonElement> | undefined;
62
+ }
63
+ /**
64
+ * The element that toggles the popover: a `<button type="button">` with
65
+ * `aria-haspopup="dialog"`, `aria-expanded` and, while open,
66
+ * `aria-controls`. `render` swaps the element (`render={(p) => <Button {...p} />}`).
67
+ */
68
+ export declare function PopoverTrigger(props: PopoverTriggerProps): ReactElement;
69
+ /** `id` is reserved: the trigger's `aria-controls` points at it. */
70
+ export interface PopoverContentProps extends Omit<HTMLAttributes<HTMLDivElement>, 'role' | 'id'> {
71
+ readonly children?: ReactNode;
72
+ /** The content element (`role="dialog"`). */
73
+ readonly ref?: Ref<HTMLDivElement> | undefined;
74
+ }
75
+ /**
76
+ * The floating panel (`role="dialog"`, no `aria-modal`): mounted only while
77
+ * open, in the top layer, positioned next to the trigger (or `anchor`).
78
+ * Labelled by `Popover.Title` and described by `Popover.Description` when
79
+ * they are rendered and no `aria-label` / `aria-labelledby` is given.
80
+ */
81
+ export declare function PopoverContent(props: PopoverContentProps): ReactNode;
82
+ export interface PopoverTitleProps extends HTMLAttributes<HTMLHeadingElement> {
83
+ readonly ref?: Ref<HTMLHeadingElement> | undefined;
84
+ }
85
+ /** Heading of the popover (`<h2>`); labels the content. */
86
+ export declare function PopoverTitle(props: PopoverTitleProps): ReactElement;
87
+ export interface PopoverDescriptionProps extends HTMLAttributes<HTMLParagraphElement> {
88
+ readonly ref?: Ref<HTMLParagraphElement> | undefined;
89
+ }
90
+ /** Description of the popover (`<p>`); describes the content. */
91
+ export declare function PopoverDescription(props: PopoverDescriptionProps): ReactElement;
92
+ export type PopoverCloseRenderProps = PopoverTriggerRenderProps;
93
+ export interface PopoverCloseProps extends ButtonHTMLAttributes<HTMLButtonElement> {
94
+ readonly render?: ((props: PopoverCloseRenderProps) => ReactElement) | undefined;
95
+ readonly ref?: Ref<HTMLButtonElement> | undefined;
96
+ }
97
+ /** A button that closes the popover (`reason: 'close'`); `render` swaps the element. */
98
+ export declare function PopoverClose(props: PopoverCloseProps): ReactElement;
99
+ //# sourceMappingURL=Popover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../src/popover/Popover.tsx"],"names":[],"mappings":"AASA,OAAO,EAOL,KAAK,oBAAoB,EACzB,KAAK,cAAc,EAEnB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,GAAG,EACR,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,EAA4B,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC/G,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,+BAA+B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AAC,EAAE,SAAS,CAAC;IAC9B,6CAA6C;IAC7C,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;CAChD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,SAAS,CA4CpE;AAED,MAAM,WAAW,iBAAkB,SAAQ,cAAc,CAAC,kBAAkB,CAAC;IAC3E,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,kBAAkB,CAAC,GAAG,SAAS,CAAC;CACpD;AAED,2DAA2D;AAC3D,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CAInE;AAED,MAAM,WAAW,uBAAwB,SAAQ,cAAc,CAAC,oBAAoB,CAAC;IACnF,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,oBAAoB,CAAC,GAAG,SAAS,CAAC;CACtD;AAED,iEAAiE;AACjE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,YAAY,CAI/E;AAED,MAAM,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAEhE,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IAChF,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,uBAAuB,KAAK,YAAY,CAAC,GAAG,SAAS,CAAC;IACjF,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,GAAG,SAAS,CAAC;CACnD;AAED,wFAAwF;AACxF,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CAGnE"}
@@ -0,0 +1,140 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // Popover: a non-modal, interactive
4
+ // anchored overlay. APG non-modal dialog guidance: `role="dialog"` without
5
+ // `aria-modal`, focus moves in on open and returns to the trigger on close,
6
+ // Tab is not contained. Built on the internal overlay, dismiss and focus
7
+ // primitives; content renders only while open (client only), so the server
8
+ // HTML holds the trigger alone.
9
+ import { createContext, use, useCallback, useId, useLayoutEffect, useRef, } from 'react';
10
+ import { useControllableState } from '@salmonui/core/internal/controllable';
11
+ import { Overlay, useHydrated } from '@salmonui/core/internal/overlay';
12
+ import { splitOffset, toPlacement } from '../internal/placement.js';
13
+ import { pressSource } from '@salmonui/core/internal/press';
14
+ const PopoverContext = createContext(null);
15
+ /** `base` plus the caller's `className`. */
16
+ const cx = (base, extra) => (extra ? `${base} ${extra}` : base);
17
+ /** Parts read the root's context; rendering a part outside `<Popover>` is a usage error (throws on the null context). */
18
+ const usePopoverContext = () => use(PopoverContext);
19
+ /**
20
+ * Popover root: holds the open triad and the ids. Renders no element of its
21
+ * own.
22
+ */
23
+ export function Popover(props) {
24
+ const { open: openProp, defaultOpen, onOpenChange } = props;
25
+ // The event object is allocated only when a callback is bound.
26
+ const notify = onOpenChange && ((open, reason, source) => onOpenChange(open, Object.freeze({ reason, source })));
27
+ const [open, setOpenState] = useControllableState(openProp, defaultOpen ?? false, notify, 'Popover open');
28
+ const triggerRef = useRef(null);
29
+ const base = useId();
30
+ // The server and the hydration render show the popover closed (content is
31
+ // client only); an initially open popover opens right after hydration.
32
+ const hydrated = useHydrated();
33
+ const value = {
34
+ open: open && hydrated,
35
+ setOpen: setOpenState,
36
+ triggerRef,
37
+ contentId: `${base}-content`,
38
+ titleId: `${base}-title`,
39
+ descriptionId: `${base}-description`,
40
+ props,
41
+ };
42
+ return _jsx(PopoverContext, { value: value, children: props.children });
43
+ }
44
+ function assignRef(ref, value) {
45
+ if (typeof ref === 'function')
46
+ ref(value);
47
+ else if (ref)
48
+ ref.current = value;
49
+ }
50
+ /** A callback ref that writes `own` and the caller's `ref`. */
51
+ function useMergedRef(own, ref) {
52
+ return useCallback((el) => {
53
+ own.current = el;
54
+ assignRef(ref, el);
55
+ },
56
+ // `own` is a ref owned by the caller (stable).
57
+ // eslint-disable-next-line react-hooks/exhaustive-deps
58
+ [ref]);
59
+ }
60
+ /** Trigger and Close: a `<button type="button">` (or `render`) that proposes an open state. */
61
+ function popoverButton(ctx, props, part, extra, next, ref) {
62
+ const { render, ref: _ref, onClick, className, type, ...rest } = props;
63
+ const computed = {
64
+ ...rest,
65
+ ...extra,
66
+ type: type ?? 'button',
67
+ className: cx(`salmon-popover-${part}`, className),
68
+ ref,
69
+ onClick: (event) => {
70
+ onClick?.(event);
71
+ if (!event.defaultPrevented)
72
+ ctx.setOpen(next, part, pressSource(event));
73
+ },
74
+ };
75
+ return render ? render(computed) : _jsx("button", { ...computed });
76
+ }
77
+ /**
78
+ * The element that toggles the popover: a `<button type="button">` with
79
+ * `aria-haspopup="dialog"`, `aria-expanded` and, while open,
80
+ * `aria-controls`. `render` swaps the element (`render={(p) => <Button {...p} />}`).
81
+ */
82
+ export function PopoverTrigger(props) {
83
+ const ctx = usePopoverContext();
84
+ const ref = useMergedRef(ctx.triggerRef, props.ref);
85
+ const extra = { 'aria-haspopup': 'dialog', 'aria-expanded': ctx.open, 'aria-controls': ctx.open ? ctx.contentId : undefined };
86
+ return popoverButton(ctx, props, 'trigger', extra, !ctx.open, ref);
87
+ }
88
+ /**
89
+ * The floating panel (`role="dialog"`, no `aria-modal`): mounted only while
90
+ * open, in the top layer, positioned next to the trigger (or `anchor`).
91
+ * Labelled by `Popover.Title` and described by `Popover.Description` when
92
+ * they are rendered and no `aria-label` / `aria-labelledby` is given.
93
+ */
94
+ export function PopoverContent(props) {
95
+ const ctx = usePopoverContext();
96
+ const { children, className, style, ref, ...rest } = props;
97
+ const root = ctx.props;
98
+ const own = useRef(null);
99
+ const wire = [
100
+ ['aria-labelledby', ctx.titleId, rest['aria-label'] !== undefined || rest['aria-labelledby'] !== undefined],
101
+ ['aria-describedby', ctx.descriptionId, rest['aria-describedby'] !== undefined],
102
+ ];
103
+ // Point aria-labelledby / -describedby at the parts actually rendered (no dangling ids, no re-render).
104
+ useLayoutEffect(() => {
105
+ const el = own.current;
106
+ if (el)
107
+ for (const [name, partId, given] of wire)
108
+ if (!given)
109
+ el.querySelector(`[id="${partId}"]`) ? el.setAttribute(name, partId) : el.removeAttribute(name);
110
+ });
111
+ const setRef = useMergedRef(own, ref);
112
+ if (!ctx.open)
113
+ return null;
114
+ const { main, cross } = splitOffset(root.offset, 8);
115
+ const anchor = root.anchor ?? ctx.triggerRef;
116
+ return (_jsxs(Overlay, { ...rest, ref: setRef, id: ctx.contentId, role: "dialog", anchor: anchor, className: cx('salmon-popover', className), style: style, "data-arrow": root.arrow ? '' : undefined, placement: toPlacement(root.placement, 'bottom'), offset: main, crossOffset: cross, collisionBoundary: root.collisionBoundary, container: root.container, insideRefs: [ctx.triggerRef, anchor], onDismiss: (reason, event) => ctx.setOpen(false, reason, event.type === 'pointerdown' ? 'pointer' : 'keyboard'), dismissOnOutsidePress: root.closeOnOutsidePress !== false, dismissOnEscape: root.closeOnEscape !== false, dismissOnFocusOutside: root.closeOnFocusOutside !== false, focus: { autoFocus: root.initialFocus ?? 'first', tab: 'leave', restoreFocus: root.returnFocus !== false && ctx.triggerRef }, children: [children, root.arrow ? _jsx("span", { className: "salmon-popover-arrow", "aria-hidden": "true" }) : null] }));
117
+ }
118
+ /** Heading of the popover (`<h2>`); labels the content. */
119
+ export function PopoverTitle(props) {
120
+ const ctx = usePopoverContext();
121
+ const { className, ...rest } = props;
122
+ return _jsx("h2", { id: ctx.titleId, ...rest, className: cx('salmon-popover-title', className) });
123
+ }
124
+ /** Description of the popover (`<p>`); describes the content. */
125
+ export function PopoverDescription(props) {
126
+ const ctx = usePopoverContext();
127
+ const { className, ...rest } = props;
128
+ return _jsx("p", { id: ctx.descriptionId, ...rest, className: cx('salmon-popover-description', className) });
129
+ }
130
+ /** A button that closes the popover (`reason: 'close'`); `render` swaps the element. */
131
+ export function PopoverClose(props) {
132
+ const ctx = usePopoverContext();
133
+ return popoverButton(ctx, props, 'close', {}, false, props.ref);
134
+ }
135
+ Popover.Trigger = PopoverTrigger;
136
+ Popover.Content = PopoverContent;
137
+ Popover.Title = PopoverTitle;
138
+ Popover.Description = PopoverDescription;
139
+ Popover.Close = PopoverClose;
140
+ //# sourceMappingURL=Popover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../src/popover/Popover.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,oCAAoC;AACpC,2EAA2E;AAC3E,4EAA4E;AAC5E,yEAAyE;AACzE,2EAA2E;AAC3E,gCAAgC;AAEhC,OAAO,EACL,aAAa,EACb,GAAG,EACH,WAAW,EACX,KAAK,EACL,eAAe,EACf,MAAM,GAQP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,WAAW,EAA6C,MAAM,0BAA0B,CAAC;AAC/G,OAAO,EAAE,WAAW,EAAoB,MAAM,+BAA+B,CAAC;AAqD9E,MAAM,cAAc,GAAG,aAAa,CAA6B,IAAI,CAAC,CAAC;AAEvE,4CAA4C;AAC5C,MAAM,EAAE,GAAG,CAAC,IAAY,EAAE,KAAyB,EAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAEpG,yHAAyH;AACzH,MAAM,iBAAiB,GAAG,GAAwB,EAAE,CAAC,GAAG,CAAC,cAAc,CAAwB,CAAC;AAEhG;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,KAAmB;IACzC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAC5D,+DAA+D;IAC/D,MAAM,MAAM,GAAG,YAAY,IAAI,CAAC,CAAC,IAAa,EAAE,MAA+B,EAA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