@cngx/common 0.0.1-rc.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.
- package/LICENSE +21 -0
- package/README.md +18 -0
- package/a11y/README.md +77 -0
- package/card/README.md +79 -0
- package/chart/README.md +31 -0
- package/data/README.md +883 -0
- package/dialog/README.md +84 -0
- package/display/README.md +30 -0
- package/fesm2022/cngx-common-a11y.mjs +1260 -0
- package/fesm2022/cngx-common-a11y.mjs.map +1 -0
- package/fesm2022/cngx-common-card.mjs +765 -0
- package/fesm2022/cngx-common-card.mjs.map +1 -0
- package/fesm2022/cngx-common-chart.mjs +2943 -0
- package/fesm2022/cngx-common-chart.mjs.map +1 -0
- package/fesm2022/cngx-common-data.mjs +2886 -0
- package/fesm2022/cngx-common-data.mjs.map +1 -0
- package/fesm2022/cngx-common-dialog.mjs +1366 -0
- package/fesm2022/cngx-common-dialog.mjs.map +1 -0
- package/fesm2022/cngx-common-display.mjs +1603 -0
- package/fesm2022/cngx-common-display.mjs.map +1 -0
- package/fesm2022/cngx-common-interactive.mjs +8185 -0
- package/fesm2022/cngx-common-interactive.mjs.map +1 -0
- package/fesm2022/cngx-common-layout.mjs +1335 -0
- package/fesm2022/cngx-common-layout.mjs.map +1 -0
- package/fesm2022/cngx-common-popover.mjs +1200 -0
- package/fesm2022/cngx-common-popover.mjs.map +1 -0
- package/fesm2022/cngx-common-stepper.mjs +1350 -0
- package/fesm2022/cngx-common-stepper.mjs.map +1 -0
- package/fesm2022/cngx-common-tabs.mjs +1551 -0
- package/fesm2022/cngx-common-tabs.mjs.map +1 -0
- package/fesm2022/cngx-common.mjs +34 -0
- package/fesm2022/cngx-common.mjs.map +1 -0
- package/interactive/README.md +211 -0
- package/layout/README.md +117 -0
- package/package.json +100 -0
- package/popover/README.md +218 -0
- package/stepper/README.md +102 -0
- package/tabs/README.md +32 -0
- package/types/cngx-common-a11y.d.ts +616 -0
- package/types/cngx-common-card.d.ts +413 -0
- package/types/cngx-common-chart.d.ts +1081 -0
- package/types/cngx-common-data.d.ts +1460 -0
- package/types/cngx-common-dialog.d.ts +772 -0
- package/types/cngx-common-display.d.ts +1136 -0
- package/types/cngx-common-interactive.d.ts +5013 -0
- package/types/cngx-common-layout.d.ts +737 -0
- package/types/cngx-common-popover.d.ts +520 -0
- package/types/cngx-common-stepper.d.ts +982 -0
- package/types/cngx-common-tabs.d.ts +1237 -0
- package/types/cngx-common.d.ts +13 -0
package/dialog/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# @cngx/common/dialog
|
|
2
|
+
|
|
3
|
+
Dialog system built on the native `<dialog>` element. Reactive lifecycle, deterministic focus and scroll-lock, nested dialog stacking. No CDK Overlay, no z-index management.
|
|
4
|
+
|
|
5
|
+
## When you reach for it
|
|
6
|
+
|
|
7
|
+
You need a dialog and want the browser to do the heavy lifting:
|
|
8
|
+
|
|
9
|
+
- A confirmation modal where the user picks one of two outcomes.
|
|
10
|
+
- A form that should stay open while saving and close itself when the save succeeds — or stay open with an error annotation when it fails.
|
|
11
|
+
- A wizard or multi-step flow where you re-open the same dialog as the user advances.
|
|
12
|
+
- A non-modal popover that floats above the page without trapping focus.
|
|
13
|
+
- A nested dialog (a confirm on top of an editor) that should not double-stack the backdrop.
|
|
14
|
+
- A mobile bottom sheet with a slide-up animation and swipe-to-dismiss.
|
|
15
|
+
- A draggable, persistent panel anchored to viewport coordinates.
|
|
16
|
+
|
|
17
|
+
If you want a small inline overlay anchored to a trigger — popover, tooltip, hovercard — that is `@cngx/common/popover`, not this entry.
|
|
18
|
+
|
|
19
|
+
## Two modes
|
|
20
|
+
|
|
21
|
+
Both modes share the same primitives and the same lifecycle. Pick the mode that matches how the dialog is authored, not what it does.
|
|
22
|
+
|
|
23
|
+
- **Declarative.** Place `<dialog cngxDialog>` directly in the template. Get a typed reference with `#dlg="cngxDialog"` and drive it from the surrounding template. No service, no boilerplate, no late wiring. The right default when the dialog markup belongs to one component and is opened from the same component.
|
|
24
|
+
- **Programmatic.** Inject `CngxDialogOpener` and call `open(MyDialogComponent, config)` from code. The right choice for dialogs that fan out from many call sites, are rendered from a route guard, or carry isolated content components. The API mirrors `MatDialog` so migrations stay mechanical.
|
|
25
|
+
|
|
26
|
+
## Lifecycle as UX
|
|
27
|
+
|
|
28
|
+
Every dialog walks through `closed → opening → open → closing → closed`. The transition states are first-class — they are not internal animation bookkeeping that consumers should ignore.
|
|
29
|
+
|
|
30
|
+
Why they exist:
|
|
31
|
+
|
|
32
|
+
- **`opening` and `closing` give CSS time.** Animations run on the transition states; the dialog does not finalize until the browser reports `transitionend`. There is no hardcoded `setTimeout` waiting for fade-out to "probably be done." Disable transitions and the finalization is immediate.
|
|
33
|
+
- **Focus restoration is automatic.** The element that was focused when `open()` was called is captured. On close, focus returns there. If the trigger has been removed from the DOM in the meantime, focus falls back to a consumer-supplied element.
|
|
34
|
+
- **Scroll lock is ref-counted.** Modal dialogs lock `<html>` scrolling for the duration. Two concurrent modals coordinate so the lock only releases when the last one closes — closing one of two stacked dialogs does not let the page scroll out from under the user.
|
|
35
|
+
|
|
36
|
+
The `result()` signal is `undefined` while the dialog is open, becomes the close value once it settles, or becomes the literal string `'dismissed'` when the user closed without picking a value. Reading the result reactively is the standard pattern — no `subscribe`, no manual cleanup.
|
|
37
|
+
|
|
38
|
+
## Async submit
|
|
39
|
+
|
|
40
|
+
`[submitAction]` turns a form dialog into a transactional surface. When the user clicks save, the action runs while the dialog stays open. The dialog blocks close and announces `aria-busy` while pending; on success it auto-closes with the result; on error it stays open, applies an error class, and surfaces the error to the screen reader.
|
|
41
|
+
|
|
42
|
+
Bind the dialog's `submitState` to a `[cngxToastOn]` or `[cngxBannerOn]` outside the dialog and the feedback layer wires itself with no extra plumbing — the dialog is a producer of `CngxAsyncState` like any other.
|
|
43
|
+
|
|
44
|
+
If the consumer wants to own the lifecycle entirely (custom retry-with-backoff, optimistic local cache update, etc.), bind `[state]` directly and skip `[submitAction]`. The external state takes precedence.
|
|
45
|
+
|
|
46
|
+
## Nested dialogs
|
|
47
|
+
|
|
48
|
+
Open a dialog from inside another dialog and the stack just works. The topmost dialog renders its backdrop; the ones underneath suppress theirs so the user never sees a tower of overlapping semi-transparent layers darkening into opaqueness. Closing the top dialog returns the backdrop to the one below it, and so on, ref-counted down to zero.
|
|
49
|
+
|
|
50
|
+
There is no consumer configuration for this. Open dialogs nest correctly out of the box. For isolated stacking (a portal subtree that should not see the outer stack), the stack service can be provided locally.
|
|
51
|
+
|
|
52
|
+
## Bottom sheet and draggable
|
|
53
|
+
|
|
54
|
+
Two opt-in directives extend the base dialog without forking it:
|
|
55
|
+
|
|
56
|
+
- **`CngxBottomSheet`** anchors a modal dialog to the viewport bottom, animates slide-up, and renders a drag-affordance handle. Combined with `CngxSwipeDismiss` on the same host, swipe-to-dismiss is auto-wired — the consumer does not bind a `(swiped)` event.
|
|
57
|
+
- **`CngxDialogDraggable`** turns any dialog into a draggable panel. Position is exposed as CSS custom properties so the theme applies the transform; keyboard navigation is wired automatically (arrows for fine moves, Shift+arrows for coarse, Home to reset). Optional grid snap and viewport-clamp inputs cover the common ergonomic requests.
|
|
58
|
+
|
|
59
|
+
## Non-modal
|
|
60
|
+
|
|
61
|
+
`[modal]="false"` opens the dialog via the native `show()` method instead of `showModal()`. No backdrop, no focus trap, no scroll lock, no `aria-modal`. The browser also does not announce that a non-modal dialog opened — a sibling `aria-live` region near the trigger is the consumer's responsibility, and a dev-mode warning fires when one is missing.
|
|
62
|
+
|
|
63
|
+
Use non-modal for floating panels that should not preempt the page. Most product dialogs are modal; reach for non-modal deliberately.
|
|
64
|
+
|
|
65
|
+
## Accessibility
|
|
66
|
+
|
|
67
|
+
The dialog system is built around the native `<dialog>` element, which is the only WAI-ARIA conformant primitive for modal dialogs in current browsers. The implications you should know:
|
|
68
|
+
|
|
69
|
+
- **`aria-labelledby` and `aria-describedby` are wired automatically** from `[cngxDialogTitle]` and `[cngxDialogDescription]` content children. Place them in the template; the linkage is reactive.
|
|
70
|
+
- **Title announcement.** When a modal dialog transitions to `'open'`, the title text is announced through a polite live region. Screen-reader users hear the dialog purpose without an explicit `aria-live` element.
|
|
71
|
+
- **Icon-only close buttons** need an explicit `aria-label`. The library does not invent labels.
|
|
72
|
+
- **Multi-step content** — wizards, tabbed dialogs, paginated forms — is the consumer's responsibility. The dialog moves focus once on open. After that, calling `.focus()` on the first element of the new step is on you.
|
|
73
|
+
- **Error state.** Bind `[error]` to apply `aria-invalid="true"` and the `cngx-dialog--error` class. Pair with a `cngx-form-errors` block (or any `role="alert"` region) inside the dialog for WCAG-compliant form-error announcements.
|
|
74
|
+
- **Reduced motion.** The theme honors `prefers-reduced-motion: reduce` — open and close transitions disable themselves automatically.
|
|
75
|
+
|
|
76
|
+
## See also
|
|
77
|
+
|
|
78
|
+
- Directive selectors, signals, methods, inputs, and CSS custom properties in the **API** tab of the generated docs.
|
|
79
|
+
- Migration mapping from `MatDialog` (provider, data token, ref token, result type) in the API tab — every `Mat*` symbol has a `Cngx*` equivalent.
|
|
80
|
+
- Live demos under `dev-app/src/app/demos/common/dialog/` cover declarative, programmatic, submit-action, bottom sheet, draggable, and nested patterns.
|
|
81
|
+
|
|
82
|
+
## Peer dependencies
|
|
83
|
+
|
|
84
|
+
`@angular/core`, `@angular/common`.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @cngx/common/display
|
|
2
|
+
|
|
3
|
+
Display-only atoms. Icons, avatars, badges, chips, tags, indicators, dividers — the visual vocabulary of cngx. No behaviour, no state beyond presentational flags.
|
|
4
|
+
|
|
5
|
+
## When you reach for it
|
|
6
|
+
|
|
7
|
+
You need a primitive visual piece that other components compose:
|
|
8
|
+
|
|
9
|
+
- An avatar that gracefully degrades from photo URL → initials → fallback.
|
|
10
|
+
- A chip the user can remove (used internally by multi-select, combobox, tag-input, filter-chips — and available to you for the same purpose).
|
|
11
|
+
- A tag pill that conveys status, category, or count — non-removable, theme-aware.
|
|
12
|
+
- A checkbox or radio glyph for a custom row design where you want the cngx look but own the selection logic yourself.
|
|
13
|
+
- A divider with an optional inline label.
|
|
14
|
+
|
|
15
|
+
For **interactive** atoms (ripple, async-click, nav badges, expandable disclosures), see `@cngx/common/interactive`. The split is by behaviour-versus-presentation: this entry only renders.
|
|
16
|
+
|
|
17
|
+
## Mental model
|
|
18
|
+
|
|
19
|
+
Every atom here is a thin visual surface that reads inputs and produces ARIA-correct markup. None of them own selection, focus, or async state — those are coordinated by the organisms that compose them. That separation is what lets `CngxCheckboxIndicator` appear inside a select panel row, a tree node, a menu item checkbox, and a custom table row without each context having to re-invent the visual or its accessibility shape.
|
|
20
|
+
|
|
21
|
+
`CngxChip` and `CngxTag` are easy to confuse: a chip is **removable and ephemeral** (the user added it, the user can remove it), a tag is **applied and static** (a label that classifies something). When in doubt, ask whether the user can dismiss it; if yes, it is a chip.
|
|
22
|
+
|
|
23
|
+
## Theming
|
|
24
|
+
|
|
25
|
+
Every visual property — colour, radius, spacing, sizing — is a CSS custom property with a Material 3 fallback. Override at any DOM level via standard cascade. The full token list lives next to each component in the API tab.
|
|
26
|
+
|
|
27
|
+
## See also
|
|
28
|
+
|
|
29
|
+
- Each component's inputs, slots, and CSS variables in the **API** tab.
|
|
30
|
+
- Live demos under `dev-app/src/app/demos/common/display/`.
|