@cngx/common 0.1.0-rc.8 → 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 (90) hide show
  1. package/a11y/README.md +15 -2
  2. package/button/README.md +258 -0
  3. package/command/README.md +42 -2
  4. package/data/README.md +15 -12
  5. package/fesm2022/cngx-common-a11y.mjs +1076 -319
  6. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  7. package/fesm2022/cngx-common-audio.mjs +99 -77
  8. package/fesm2022/cngx-common-audio.mjs.map +1 -1
  9. package/fesm2022/cngx-common-button.mjs +1084 -0
  10. package/fesm2022/cngx-common-button.mjs.map +1 -0
  11. package/fesm2022/cngx-common-card.mjs +138 -78
  12. package/fesm2022/cngx-common-card.mjs.map +1 -1
  13. package/fesm2022/cngx-common-chart.mjs +799 -327
  14. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  15. package/fesm2022/cngx-common-command.mjs +101 -25
  16. package/fesm2022/cngx-common-command.mjs.map +1 -1
  17. package/fesm2022/cngx-common-data.mjs +861 -423
  18. package/fesm2022/cngx-common-data.mjs.map +1 -1
  19. package/fesm2022/cngx-common-dialog.mjs +198 -160
  20. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  21. package/fesm2022/cngx-common-display.mjs +693 -329
  22. package/fesm2022/cngx-common-display.mjs.map +1 -1
  23. package/fesm2022/cngx-common-interactive.mjs +7303 -2774
  24. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  25. package/fesm2022/cngx-common-layout.mjs +2174 -442
  26. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  27. package/fesm2022/cngx-common-menu-button.mjs +557 -0
  28. package/fesm2022/cngx-common-menu-button.mjs.map +1 -0
  29. package/fesm2022/cngx-common-popover.mjs +2109 -557
  30. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  31. package/fesm2022/cngx-common-stepper.mjs +548 -419
  32. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  33. package/fesm2022/cngx-common-tabs.mjs +442 -331
  34. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  35. package/fesm2022/cngx-common-timeline.mjs +44 -71
  36. package/fesm2022/cngx-common-timeline.mjs.map +1 -1
  37. package/fesm2022/cngx-common.mjs +10 -10
  38. package/fesm2022/cngx-common.mjs.map +1 -1
  39. package/interactive/README.md +30 -19
  40. package/layout/README.md +17 -1
  41. package/menu-button/README.md +234 -0
  42. package/package.json +31 -8
  43. package/popover/README.md +81 -4
  44. package/popover/tooltip-indicator.scss +52 -0
  45. package/schematics/collection.json +9 -0
  46. package/schematics/ng-add/index.js +9 -0
  47. package/schematics/ng-add/schema.json +96 -0
  48. package/schematics/package.json +3 -0
  49. package/stepper/README.md +5 -5
  50. package/theming/components/cngx-accordion.css +36 -7
  51. package/theming/components/cngx-async.css +185 -37
  52. package/theming/components/cngx-backdrop.css +3 -1
  53. package/theming/components/cngx-badge.css +20 -5
  54. package/theming/components/cngx-bottom-sheet.css +2 -0
  55. package/theming/components/cngx-breadcrumb.css +3 -1
  56. package/theming/components/cngx-button-group.css +325 -0
  57. package/theming/components/cngx-button-toggle.css +55 -23
  58. package/theming/components/cngx-button.css +975 -0
  59. package/theming/components/cngx-data-grid.css +2 -0
  60. package/theming/components/cngx-dialog.css +3 -1
  61. package/theming/components/cngx-divider.css +24 -9
  62. package/theming/components/cngx-drawer.css +153 -0
  63. package/theming/components/cngx-icon-glyph.css +76 -0
  64. package/theming/components/cngx-listbox.css +79 -25
  65. package/theming/components/cngx-menu.css +112 -52
  66. package/theming/components/cngx-nav.css +1220 -0
  67. package/theming/components/cngx-popover-sheet.css +434 -0
  68. package/theming/components/cngx-popover.css +37 -9
  69. package/theming/components/cngx-recycler-placeholder.css +2 -0
  70. package/theming/components/cngx-ripple.css +74 -16
  71. package/theming/components/cngx-sidebar.css +71 -0
  72. package/theming/components/cngx-slider.css +3 -1
  73. package/theming/components/cngx-tooltip.css +2 -0
  74. package/timeline/README.md +2 -2
  75. package/types/cngx-common-a11y.d.ts +488 -112
  76. package/types/cngx-common-audio.d.ts +60 -88
  77. package/types/cngx-common-button.d.ts +698 -0
  78. package/types/cngx-common-card.d.ts +104 -78
  79. package/types/cngx-common-chart.d.ts +677 -389
  80. package/types/cngx-common-command.d.ts +55 -41
  81. package/types/cngx-common-data.d.ts +506 -360
  82. package/types/cngx-common-dialog.d.ts +94 -127
  83. package/types/cngx-common-display.d.ts +475 -300
  84. package/types/cngx-common-interactive.d.ts +4383 -1721
  85. package/types/cngx-common-layout.d.ts +1399 -288
  86. package/types/cngx-common-menu-button.d.ts +382 -0
  87. package/types/cngx-common-popover.d.ts +990 -268
  88. package/types/cngx-common-stepper.d.ts +374 -465
  89. package/types/cngx-common-tabs.d.ts +309 -403
  90. package/types/cngx-common-timeline.d.ts +50 -109
@@ -0,0 +1,434 @@
1
+ /**
2
+ * @overview
3
+ * Sheet and fullscreen presentation for `[cngxPopoverSheet]` popovers.
4
+ *
5
+ * **Breakpoint**
6
+ *
7
+ * Written once, here: `(pointer: coarse) and (max-width: 48rem)` sets
8
+ * `--cngx-popover-sheet-breakpoint` to `1` on the root, otherwise `0`.
9
+ * `CngxPopoverSheet` reads that property to resolve its `'auto'` request;
10
+ * no TypeScript length constant exists. A viewport query is admitted here
11
+ * because it decides overlay modality, not in-flow layout
12
+ * (responsive-by-default rule 2).
13
+ *
14
+ * **Presentations**
15
+ *
16
+ * Visuals key only on `data-cngx-presentation`, which the directive writes:
17
+ *
18
+ * - `sheet` - bottom-flush, full inline size, content-sized up to
19
+ * `--cngx-popover-sheet-max-block-size`, dimmed `::backdrop`
20
+ * - `fullscreen` - fills the dynamic viewport (`100dvh`)
21
+ * - `anchored` - keeps the popover's position and inline size, capped at
22
+ * the space next to the anchor minus the anchor offset on both edges
23
+ *
24
+ * In every presentation the host is a non-scrolling flex column: the
25
+ * `cngxPopoverSheetHeader` part stays put as a row and every other direct
26
+ * child scrolls. A swipe region inside a scrolling panel never fires, so
27
+ * only the content below the header may scroll. A footer that must stay
28
+ * pinned sets `flex: none`.
29
+ *
30
+ * **Settling**
31
+ *
32
+ * While `data-cngx-sheet-settling` is present (the first frames after open,
33
+ * until the panel rect is stable) the host is transparent and holds the
34
+ * slide start state without a transition, so the one-frame offset of the
35
+ * pinned scroll lock on iOS is never visible. The slide starts when the
36
+ * attribute is removed. Opacity keeps the initial focus target focusable.
37
+ *
38
+ * **Safe area**
39
+ *
40
+ * Inline padding is the larger of the token and both horizontal safe-area
41
+ * insets, on both edges, so it stays correct in RTL and in either landscape
42
+ * rotation; the block end pads `env(safe-area-inset-bottom)`. Edge-to-edge
43
+ * landscape on iOS needs the app to opt into `viewport-fit=cover`.
44
+ *
45
+ * **Defaults**
46
+ *
47
+ * The defaults match `CngxBottomSheet` and `CngxDialog` (16px top corners,
48
+ * 80dvh cap, a 40 x 4px handle pill centred on its own row, the dialog
49
+ * shadow, a 50% black backdrop), with phone-sized padding: 16px from
50
+ * `--cngx-space-md`.
51
+ *
52
+ * **Dark mode**
53
+ *
54
+ * Three hooks (`prefers-color-scheme: dark`, `[data-color-scheme="dark"]`,
55
+ * `.dark`) deepen the shadow and dim the handle.
56
+ *
57
+ * **Pair with**
58
+ *
59
+ * - `@cngx/themes/material/popover-sheet-theme` - Material 3 surface
60
+ *
61
+ * @themes CngxPopoverSheet, CngxPopoverSheetHeader
62
+ */
63
+
64
+ @layer cngx.tokens {
65
+ /**
66
+ * Maximum block size of the `sheet` presentation. Room above it keeps
67
+ * the page visible behind the backdrop.
68
+ * @group Layout
69
+ */
70
+ @property --cngx-popover-sheet-max-block-size {
71
+ syntax: '*';
72
+ inherits: false;
73
+ initial-value: 80dvh;
74
+ }
75
+
76
+ /**
77
+ * Corner radius shorthand of the `sheet` presentation. Rounded top
78
+ * corners only, matching the bottom-anchored anatomy.
79
+ * @group Layout
80
+ */
81
+ @property --cngx-popover-sheet-radius {
82
+ syntax: '*';
83
+ inherits: false;
84
+ initial-value: 16px 16px 0 0;
85
+ }
86
+
87
+ /**
88
+ * Padding inside the panel. SET from `--cngx-space-md` on the host, so
89
+ * density reaches it; the safe-area insets win where they are larger.
90
+ * @group Layout
91
+ */
92
+ @property --cngx-popover-sheet-padding {
93
+ syntax: '<length>';
94
+ inherits: true;
95
+ initial-value: 16px;
96
+ }
97
+
98
+ /**
99
+ * Gap between the items of the header row and below it. SET from
100
+ * `--cngx-space-sm`.
101
+ * @group Layout
102
+ */
103
+ @property --cngx-popover-sheet-header-gap {
104
+ syntax: '<length>';
105
+ inherits: true;
106
+ initial-value: 8px;
107
+ }
108
+
109
+ /**
110
+ * Inline size of the decorative handle pill.
111
+ * @group Handle
112
+ */
113
+ @property --cngx-popover-sheet-handle-inline-size {
114
+ syntax: '<length>';
115
+ inherits: true;
116
+ initial-value: 40px;
117
+ }
118
+
119
+ /**
120
+ * Block size of the decorative handle pill.
121
+ * @group Handle
122
+ */
123
+ @property --cngx-popover-sheet-handle-block-size {
124
+ syntax: '<length>';
125
+ inherits: true;
126
+ initial-value: 4px;
127
+ }
128
+
129
+ /**
130
+ * Corner radius of the decorative handle pill.
131
+ * @group Handle
132
+ */
133
+ @property --cngx-popover-sheet-handle-radius {
134
+ syntax: '<length>';
135
+ inherits: true;
136
+ initial-value: 2px;
137
+ }
138
+
139
+ /**
140
+ * Margin shorthand around the handle pill: centres it and pushes the
141
+ * header row down. SET from `--cngx-space-md` on the host.
142
+ * @group Handle
143
+ */
144
+ @property --cngx-popover-sheet-handle-margin {
145
+ syntax: '*';
146
+ inherits: true;
147
+ initial-value: 0 auto 16px;
148
+ }
149
+
150
+ /**
151
+ * Fill of the decorative handle pill. `inherits: true` so the root
152
+ * dark-mode value reaches the handle part.
153
+ * @group Handle
154
+ */
155
+ @property --cngx-popover-sheet-handle-color {
156
+ syntax: '<color>';
157
+ inherits: true;
158
+ initial-value: oklch(0.8 0.005 250);
159
+ }
160
+
161
+ /**
162
+ * Panel surface. SET from `--cngx-color-surface` on the host.
163
+ * @group Surface
164
+ */
165
+ @property --cngx-popover-sheet-surface {
166
+ syntax: '<color>';
167
+ inherits: false;
168
+ initial-value: oklch(1 0 0);
169
+ }
170
+
171
+ /**
172
+ * Panel text colour. SET from `--cngx-color-text` on the host.
173
+ * @group Surface
174
+ */
175
+ @property --cngx-popover-sheet-color {
176
+ syntax: '<color>';
177
+ inherits: false;
178
+ initial-value: oklch(0.2 0 0);
179
+ }
180
+
181
+ /**
182
+ * Drop shadow of the `sheet` presentation, the `CngxDialog` elevation.
183
+ * `inherits: true` so the dark-mode value set on the root reaches the host.
184
+ * @group Surface
185
+ */
186
+ @property --cngx-popover-sheet-shadow {
187
+ syntax: '*';
188
+ inherits: true;
189
+ initial-value: 0 8px 32px oklch(0 0 0 / 0.12);
190
+ }
191
+
192
+ /**
193
+ * Dimming paint of the `sheet` `::backdrop`. Paint only: taps outside
194
+ * the panel are handled by the directive, not by the backdrop.
195
+ * `inherits: true` so the host value reaches the pseudo-element.
196
+ * @group Surface
197
+ */
198
+ @property --cngx-popover-sheet-backdrop {
199
+ syntax: '<color>';
200
+ inherits: true;
201
+ initial-value: oklch(0 0 0 / 0.5);
202
+ }
203
+
204
+ /**
205
+ * Duration of the slide in and out. SET from `--cngx-duration-base`.
206
+ * @group Motion
207
+ * @relatedTo provideMotion, CngxMotionScope, injectMotion
208
+ */
209
+ @property --cngx-popover-sheet-duration {
210
+ syntax: '<time>';
211
+ inherits: false;
212
+ initial-value: 200ms;
213
+ }
214
+
215
+ /**
216
+ * Easing curve of the slide in and out.
217
+ * @group Motion
218
+ */
219
+ @property --cngx-popover-sheet-easing {
220
+ syntax: '*';
221
+ inherits: false;
222
+ initial-value: ease;
223
+ }
224
+
225
+ /* SET-from-scale: the registered initial values above win over a read-site
226
+ * var() fallback, so density, motion and foundation colour reach the sheet
227
+ * only through these host SETs. */
228
+ :where(.cngx-popover-sheet) {
229
+ --cngx-popover-sheet-padding: var(--cngx-space-md);
230
+ --cngx-popover-sheet-header-gap: var(--cngx-space-sm);
231
+ --cngx-popover-sheet-handle-margin: 0 auto var(--cngx-space-md);
232
+ --cngx-popover-sheet-duration: var(--cngx-duration-base);
233
+ --cngx-popover-sheet-surface: var(--cngx-color-surface);
234
+ --cngx-popover-sheet-color: var(--cngx-color-text);
235
+ }
236
+
237
+ @media (prefers-color-scheme: dark) {
238
+ :root:not([data-color-scheme='light']):not(.light) {
239
+ --cngx-popover-sheet-shadow: 0 8px 32px oklch(0 0 0 / 0.5);
240
+ --cngx-popover-sheet-handle-color: oklch(0.5 0.005 250);
241
+ }
242
+ }
243
+ [data-color-scheme='dark'],
244
+ .dark {
245
+ --cngx-popover-sheet-shadow: 0 8px 32px oklch(0 0 0 / 0.5);
246
+ --cngx-popover-sheet-handle-color: oklch(0.5 0.005 250);
247
+ }
248
+ [data-color-scheme='light'],
249
+ .light {
250
+ --cngx-popover-sheet-shadow: 0 8px 32px oklch(0 0 0 / 0.12);
251
+ --cngx-popover-sheet-handle-color: oklch(0.8 0.005 250);
252
+ }
253
+ }
254
+
255
+ @layer cngx.components {
256
+ /* The breakpoint, written once, on the root: every sheet shares one
257
+ * observer that reads it there. Unregistered on purpose: the directive
258
+ * reads the raw value. */
259
+ :root {
260
+ --cngx-popover-sheet-breakpoint: 0;
261
+ }
262
+
263
+ @media (pointer: coarse) and (max-width: 48rem) {
264
+ :root {
265
+ --cngx-popover-sheet-breakpoint: 1;
266
+ }
267
+ }
268
+
269
+ .cngx-popover-sheet:is([data-cngx-presentation='sheet'], [data-cngx-presentation='fullscreen']) {
270
+ position: fixed;
271
+ /* Span the full layout viewport width (100vw includes the classic
272
+ scrollbar gutter) rather than `100%` of the fixed containing block,
273
+ which excludes the gutter and left the sheet inset ~11px on a classic
274
+ scrollbar. The sheet is modal and locks scroll, so 100vw never overflows
275
+ into a horizontal scrollbar. */
276
+ inset: auto auto 0 0;
277
+ margin: 0;
278
+ box-sizing: border-box;
279
+ inline-size: 100vw;
280
+ max-inline-size: 100vw;
281
+ min-inline-size: 0;
282
+ max-block-size: var(--cngx-popover-sheet-max-block-size, 80dvh);
283
+ flex-direction: column;
284
+ overflow: hidden;
285
+ border: 0;
286
+ border-radius: var(--cngx-popover-sheet-radius, 16px 16px 0 0);
287
+ padding-block: var(--cngx-popover-sheet-padding, 16px)
288
+ max(var(--cngx-popover-sheet-padding, 16px), env(safe-area-inset-bottom, 0px));
289
+ /* Symmetric on purpose: the notch side flips with the device rotation,
290
+ * and the larger inset on both edges stays correct in RTL. */
291
+ padding-inline: max(
292
+ var(--cngx-popover-sheet-padding, 16px),
293
+ env(safe-area-inset-left, 0px),
294
+ env(safe-area-inset-right, 0px)
295
+ );
296
+ background: var(--cngx-popover-sheet-surface, oklch(1 0 0));
297
+ color: var(--cngx-popover-sheet-color, oklch(0.2 0 0));
298
+ box-shadow: var(--cngx-popover-sheet-shadow, 0 8px 32px oklch(0 0 0 / 0.12));
299
+ translate: 0 0;
300
+ transition:
301
+ translate var(--cngx-popover-sheet-duration, 200ms) var(--cngx-popover-sheet-easing, ease),
302
+ opacity var(--cngx-popover-sheet-duration, 200ms) var(--cngx-popover-sheet-easing, ease);
303
+ }
304
+
305
+ /* Open only: a display value on the closed host would override the UA
306
+ * `[popover]:not(:popover-open) { display: none }` and keep it rendered. */
307
+ .cngx-popover-sheet:is(
308
+ [data-cngx-presentation='sheet'],
309
+ [data-cngx-presentation='fullscreen'],
310
+ [data-cngx-presentation='anchored']
311
+ ):popover-open {
312
+ display: flex;
313
+ }
314
+
315
+ /* Anchored keeps the popover's position and inline size; it gets the
316
+ * column model and a cap at the space next to the anchor. Under
317
+ * `position-area` the containing block is the area cell and the margin box
318
+ * (the anchor offset on both block edges) must fit inside it. The offset
319
+ * comes as one length: the margin property is a shorthand `calc()` cannot
320
+ * multiply. Without anchor positioning `100%` resolves against the
321
+ * viewport. */
322
+ .cngx-popover-sheet[data-cngx-presentation='anchored'] {
323
+ flex-direction: column;
324
+ overflow: hidden;
325
+ max-block-size: calc(100% - 2 * var(--cngx-popover-anchor-offset, 0px));
326
+ position-try-order: most-block-size;
327
+ }
328
+
329
+ .cngx-popover-sheet[data-cngx-presentation='fullscreen'] {
330
+ inset: 0;
331
+ block-size: 100dvh;
332
+ max-block-size: 100dvh;
333
+ border-radius: 0;
334
+ padding-block-start: max(
335
+ var(--cngx-popover-sheet-padding, 16px),
336
+ env(safe-area-inset-top, 0px)
337
+ );
338
+ box-shadow: none;
339
+ }
340
+
341
+ .cngx-popover-sheet[data-cngx-presentation='sheet']::backdrop {
342
+ background: var(--cngx-popover-sheet-backdrop, oklch(0 0 0 / 0.5));
343
+ }
344
+
345
+ /* Slide start and end state. Opening holds it until the popover flips to
346
+ * open on the next frame; closing returns to it, and CngxPopover waits
347
+ * for the transition before hiding. */
348
+ .cngx-popover-sheet:is(
349
+ [data-cngx-presentation='sheet'],
350
+ [data-cngx-presentation='fullscreen']
351
+ ):is(.cngx-popover--opening, .cngx-popover--closing) {
352
+ translate: 0 100%;
353
+ }
354
+
355
+ .cngx-popover-sheet:is(
356
+ [data-cngx-presentation='sheet'],
357
+ [data-cngx-presentation='fullscreen']
358
+ )[data-cngx-sheet-settling] {
359
+ opacity: 0;
360
+ translate: 0 100%;
361
+ transition: none;
362
+ }
363
+
364
+ /* Only the content below the header scrolls: a swipe region inside a
365
+ * scrolling panel never fires. */
366
+ .cngx-popover-sheet:is(
367
+ [data-cngx-presentation='sheet'],
368
+ [data-cngx-presentation='fullscreen'],
369
+ [data-cngx-presentation='anchored']
370
+ )
371
+ > * {
372
+ flex: 1 1 auto;
373
+ min-block-size: 0;
374
+ overflow: auto;
375
+ overscroll-behavior: contain;
376
+ }
377
+
378
+ /* Handle on its own row, title and controls on the next one. */
379
+ .cngx-popover-sheet:is(
380
+ [data-cngx-presentation='sheet'],
381
+ [data-cngx-presentation='fullscreen'],
382
+ [data-cngx-presentation='anchored']
383
+ )
384
+ > .cngx-popover-sheet-header {
385
+ flex: none;
386
+ overflow: visible;
387
+ display: flex;
388
+ flex-wrap: wrap;
389
+ align-items: center;
390
+ gap: var(--cngx-popover-sheet-header-gap, 8px);
391
+ padding-block-end: var(--cngx-popover-sheet-header-gap, 8px);
392
+ }
393
+
394
+ .cngx-popover-sheet-handle {
395
+ display: none;
396
+ }
397
+
398
+ .cngx-popover-sheet[data-cngx-presentation='sheet'] .cngx-popover-sheet-handle {
399
+ display: block;
400
+ flex: 0 0 100%;
401
+ }
402
+
403
+ .cngx-popover-sheet[data-cngx-presentation='sheet'] .cngx-popover-sheet-handle::before {
404
+ content: '';
405
+ display: block;
406
+ inline-size: var(--cngx-popover-sheet-handle-inline-size, 40px);
407
+ block-size: var(--cngx-popover-sheet-handle-block-size, 4px);
408
+ margin: var(--cngx-popover-sheet-handle-margin, 0 auto 16px);
409
+ border-radius: var(--cngx-popover-sheet-handle-radius, 2px);
410
+ background: var(--cngx-popover-sheet-handle-color, oklch(0.8 0.005 250));
411
+ }
412
+ }
413
+
414
+ @media (prefers-reduced-motion: reduce) {
415
+ .cngx-popover-sheet:is([data-cngx-presentation='sheet'], [data-cngx-presentation='fullscreen']) {
416
+ transition: none;
417
+ }
418
+ }
419
+
420
+ /* forced-colors (WHCM): the sheet surface is bounded by a box-shadow only,
421
+ * which the forced palette strips, and the handle is a background bar that
422
+ * flattens to Canvas. Re-draw the top edge and the handle with CanvasText.
423
+ * Unlayered to beat the layered component rules. */
424
+ @media (forced-colors: active) {
425
+ .cngx-popover-sheet:is([data-cngx-presentation='sheet'], [data-cngx-presentation='fullscreen']) {
426
+ background: Canvas;
427
+ color: CanvasText;
428
+ border-block-start: 1px solid CanvasText;
429
+ }
430
+
431
+ .cngx-popover-sheet[data-cngx-presentation='sheet'] .cngx-popover-sheet-handle::before {
432
+ background: CanvasText;
433
+ }
434
+ }
@@ -4,21 +4,49 @@
4
4
  *
5
5
  * A `CngxPopover` host is a native popover element (`[attr.popover]`), so the
6
6
  * browser paints its UA chrome - a `3px solid` border, a `Canvas` background
7
- * and `0.25em` padding. `CngxPopoverPanel` and the select panels paint their
8
- * own surface, but a *bare* popover (a menu placed directly in `[cngxPopover]`,
9
- * e.g. a headless context menu) inherits that UA chrome and reads as an
10
- * unstyled black-bordered box.
7
+ * and `0.25em` padding. A *bare* popover (a menu placed directly in
8
+ * `[cngxPopover]`, e.g. a headless context menu) would inherit that UA chrome
9
+ * and read as an unstyled black-bordered box.
11
10
  *
12
- * Neutralise the chrome on hosts that carry no surface of their own; the
13
- * styled surfaces are excluded by class so they keep their own paint. Only the
14
- * chrome is reset - positioning (`inset`, `position-anchor`, the host's inline
15
- * `margin`) is owned by `CngxPopover` and left untouched.
11
+ * The reset runs at `:where()` zero specificity, so any surface that paints
12
+ * itself on the popover element (`CngxPopoverPanel`, the select panels, the
13
+ * tabs overflow menu, the sheet presentation, a consumer class) wins by
14
+ * specificity in the same layer; this sheet names none of them. A surface
15
+ * that leaves a reset property unset (its text colour, say) gets the reset
16
+ * value, so it sets what it owns. Only the chrome is reset - positioning
17
+ * (`inset`, `position-anchor`) is owned by `CngxPopover`. The UA
18
+ * `overflow: auto` goes too: the host is exactly as large as its content, so
19
+ * it would clip the shadow of the surface inside it (a `cngxMenu`'s
20
+ * elevation).
21
+ *
22
+ * The anchor offset margin is written by `CngxPopover` as the
23
+ * `--cngx-popover-anchor-margin` custom property and applied here in the
24
+ * components layer, so a Material bridge can zero it by setting the variable
25
+ * (no `!important` needed - an inline `margin` could only be beaten by one).
26
+ * The sheet and fullscreen presentations own their box, so the margin rule
27
+ * skips them.
28
+ *
29
+ * @themes CngxPopover
16
30
  */
17
31
  @layer cngx.components {
18
- [cngxPopover]:not(.cngx-popover-panel):not(.cngx-select__panel) {
32
+ :where([cngxPopover]) {
19
33
  border: 0;
20
34
  padding: 0;
21
35
  background: transparent;
22
36
  color: inherit;
37
+ overflow: visible;
38
+ }
39
+
40
+ /* The anchor offset margin, applied to every anchored popover (the styled
41
+ panels included) from the custom property the directive writes inline.
42
+ `--cngx-popover-margin-override` lets a theme (the Material select bridge)
43
+ force the margin to 0 without `!important`: a stylesheet cannot outrank the
44
+ directive's inline `--cngx-popover-anchor-margin`, but the override var is
45
+ read first and is not set inline, so the theme's value wins. Sheet and
46
+ fullscreen presentations own their own box, so they are excluded. */
47
+ [cngxPopover]:not([data-cngx-presentation='sheet']):not(
48
+ [data-cngx-presentation='fullscreen']
49
+ ) {
50
+ margin: var(--cngx-popover-margin-override, var(--cngx-popover-anchor-margin, 0));
23
51
  }
24
52
  }
@@ -34,6 +34,8 @@
34
34
  *
35
35
  * The fill and shimmer are white-alpha in dark mode so they read on a dark
36
36
  * surface. Unlayered, direct selectors so they beat the layered defaults.
37
+ *
38
+ * @themes CngxRecyclerPlaceholder
37
39
  */
38
40
 
39
41
  @layer cngx.tokens {
@@ -1,10 +1,19 @@
1
1
  /**
2
2
  * @overview
3
3
  * Theming bridge for the `CngxRipple` directive. The directive
4
- * injects `<span class="cngx-ripple__wave">` into the host on
5
- * pointerdown and removes it after the animation completes; all
6
- * visual treatment lives here, the directive only handles geometry
7
- * and DOM injection.
4
+ * injects `<span class="cngx-ripple__wave">` into a
5
+ * `<span class="cngx-ripple__container">` on pointerdown and removes
6
+ * the wave after the animation completes; all visual treatment lives
7
+ * here, the directive only handles geometry and DOM injection.
8
+ *
9
+ * **Clipping**
10
+ *
11
+ * The container covers the host (`inset: 0`), inherits its
12
+ * `border-radius` and clips with `overflow: hidden`, so only the wave
13
+ * is cut to the host shape. The host is never clipped: a touch hit-area
14
+ * pseudo-element, a corner badge or a focus ring may overhang it. The
15
+ * `.cngx-ripple` host class adds `position: relative` at zero
16
+ * specificity so an already positioned host keeps its own value.
8
17
  *
9
18
  * **Animation**
10
19
  *
@@ -12,9 +21,13 @@
12
21
  * `--cngx-ripple-duration` and fades opacity from
13
22
  * `--cngx-ripple-opacity` to 0.
14
23
  *
15
- * Under `prefers-reduced-motion: reduce` the keyframe is suppressed
16
- * and the wave appears as a static tint that fades on opacity
17
- * transition only.
24
+ * Under reduced motion (`[data-motion='reduced']` on an ancestor, or
25
+ * `prefers-reduced-motion: reduce` without a root `data-motion='full'`)
26
+ * the wave skips the expansion: it appears at full size and fades
27
+ * with `cngx-ripple-fade`. With `motion-tokens.css` loaded (it is part
28
+ * of `@cngx/themes/cngx.css`) the safety net collapses that fade to
29
+ * 0.01ms, so the wave is effectively not shown; the fade only plays
30
+ * where the net is not loaded.
18
31
  *
19
32
  * **Per-instance geometry**
20
33
  *
@@ -24,12 +37,22 @@
24
37
  *
25
38
  * **Inheritance**
26
39
  *
40
+ * The wave sits two levels below the host (host > container > wave),
41
+ * so all three surface tokens inherit: a value set on the host or an
42
+ * ancestor reaches the wave. The Material bridge sets the tokens on
43
+ * every `.cngx-ripple` host, so with the bridge loaded an override
44
+ * must sit on the host itself; an ancestor value is shadowed there.
45
+ * The directive writes `--cngx-ripple-color` inline only when
46
+ * `[rippleColor]` is bound.
47
+ *
27
48
  * - `--cngx-ripple-color` defaults to `currentColor` so the wave
28
49
  * tracks the host's text color without a per-component override
29
50
  *
30
51
  * **Pair with**
31
52
  *
32
53
  * - `@cngx/themes/material/ripple-theme` - Material state-layer surface
54
+ *
55
+ * @themes CngxRipple
33
56
  */
34
57
 
35
58
  @layer cngx.tokens {
@@ -51,7 +74,7 @@
51
74
  */
52
75
  @property --cngx-ripple-opacity {
53
76
  syntax: '<number>';
54
- inherits: false;
77
+ inherits: true;
55
78
  initial-value: 0.12;
56
79
  }
57
80
 
@@ -61,17 +84,35 @@
61
84
  */
62
85
  @property --cngx-ripple-duration {
63
86
  syntax: '<time>';
64
- inherits: false;
87
+ inherits: true;
65
88
  initial-value: 0.5s;
66
89
  }
67
90
  }
68
91
 
69
92
  @layer cngx.components {
93
+ :where(.cngx-ripple) {
94
+ position: relative;
95
+ }
96
+
97
+ @scope (.cngx-ripple__container) {
98
+ :scope {
99
+ position: absolute;
100
+ inset: 0;
101
+ border-radius: inherit;
102
+ overflow: hidden;
103
+ pointer-events: none;
104
+ }
105
+ }
106
+
70
107
  @scope (.cngx-ripple__wave) {
71
108
  :scope {
72
109
  position: absolute;
110
+ /* Physical on purpose: the directive measures --cngx-ripple-x from the
111
+ host's left edge (clientX - rect.left) and the translate below is
112
+ physical too, so a logical start anchor would put the wave on the
113
+ wrong side under dir="rtl". */
73
114
  top: 0;
74
- inset-inline-start: 0;
115
+ left: 0;
75
116
  width: var(--cngx-ripple-size, 100px);
76
117
  height: var(--cngx-ripple-size, 100px);
77
118
  border-radius: 50%;
@@ -84,13 +125,30 @@
84
125
  );
85
126
  animation: cngx-ripple-expand var(--cngx-ripple-duration, 0.5s) ease-out forwards;
86
127
  }
128
+ }
129
+
130
+ /* Reduced motion follows the same axis as the safety net in
131
+ motion-tokens.css: a [data-motion='reduced'] ancestor (provideMotion,
132
+ cngxMotionScope), or the OS preference unless the root opts back in with
133
+ data-motion='full'. The wave appears at full size and only fades, so
134
+ animationend still removes it (instantly under the safety net). */
135
+ [data-motion='reduced'] .cngx-ripple__wave {
136
+ animation-name: cngx-ripple-fade;
137
+ }
138
+
139
+ @media (prefers-reduced-motion: reduce) {
140
+ :root:not([data-motion='full']) .cngx-ripple__wave {
141
+ animation-name: cngx-ripple-fade;
142
+ }
143
+ }
87
144
 
88
- @media (prefers-reduced-motion: reduce) {
89
- :scope {
90
- animation: none;
91
- opacity: var(--cngx-ripple-opacity, 0.12);
92
- transition: opacity var(--cngx-duration-fast, 150ms) ease;
93
- }
145
+ @keyframes cngx-ripple-fade {
146
+ 0% {
147
+ opacity: var(--cngx-ripple-opacity, 0.12);
148
+ }
149
+
150
+ 100% {
151
+ opacity: 0;
94
152
  }
95
153
  }
96
154