ng-hub-ui-forms 22.4.0 → 22.5.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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-hub-ui-forms",
3
- "version": "22.4.0",
3
+ "version": "22.5.0",
4
4
  "license": "MIT",
5
5
  "description": "Accessible, signal-based form fields for Angular (input, textarea, slider, select, datepicker) with automatic error display for controls, FormGroups and FormArrays. Reactive Forms today, Signal Forms ready. Part of the ng-hub-ui family.",
6
6
  "author": "Carlos Morcillo <carlos.morcillo@me.com> (https://www.carlosmorcillo.com)",
@@ -221,11 +221,11 @@
221
221
 
222
222
  // ── Segmented ───────────────────────────────────────────────────────────────
223
223
  --hub-segmented-bg: var(--hub-sys-surface-elevated, #f8f9fa);
224
- // Optional single-slot accent. Its default (transparent) contributes nothing, so the selected
225
- // pill keeps the neutral white surface below; set it — or apply a `[color]` / `data-variant` —
226
- // to tint the pill. A custom variant re-bases `--hub-segmented-selected-bg` (mirrors the
227
- // `--hub-table-accent` model), which both the sliding indicator and the multiple-mode pill read.
228
- --hub-segmented-accent: transparent;
224
+ // Single-slot accent (mirrors `--hub-table-accent` / `--hub-btn-accent`). When a `[color]` is
225
+ // applied it is set — from a ds token or a literal colour — and the selected pill derives its
226
+ // surface and contrast text from it (see the `[data-variant]` rule in the component styles).
227
+ // With no `[color]` the neutral defaults below keep the white-pill look.
228
+ --hub-segmented-accent: var(--hub-sys-color-primary, #0d6efd);
229
229
  --hub-segmented-selected-bg: var(--hub-sys-surface-page, #fff);
230
230
  --hub-segmented-selected-color: var(--hub-sys-text-primary, #212529);
231
231
  --hub-segmented-radius: var(--hub-ref-radius-md, 0.375rem);
@@ -13,4 +13,6 @@
13
13
  @use 'field';
14
14
 
15
15
  // One-call theming mixins (opt-in; forwarded so consumers can `@use` them from the package root).
16
+ // `hub-forms-theme` themes the shared field chrome; `hub-segmented-theme` tunes `<hub-segmented>`.
17
+ @forward 'mixins/forms-theme';
16
18
  @forward 'mixins/segmented-theme';
@@ -0,0 +1,67 @@
1
+ // ─────────────────────────────────────────────────────────────────────────
2
+ // hub-forms-theme — one-call theming for the shared `ng-hub-ui-forms` chrome
3
+ // ─────────────────────────────────────────────────────────────────────────
4
+ //
5
+ // Sets the cross-cutting `--hub-form-*` tokens that EVERY form control reads
6
+ // (focus ring, validation accents, disabled state, motion) in a single include.
7
+ // Every parameter is OPTIONAL and defaults to `null`: only the parameters you
8
+ // pass are emitted, so the rest keep the library defaults. Token-based and
9
+ // self-contained (no Bootstrap dependencies). For a specific control, layer the
10
+ // matching component mixin on top (e.g. `hub-segmented-theme`).
11
+ //
12
+ // Apply it inside any selector that wraps the fields — a form, a container, a
13
+ // route, or `:root` for a global theme.
14
+ //
15
+ // @example — brand focus ring + softer disabled state, globally:
16
+ //
17
+ // @use 'ng-hub-ui-forms/styles' as *;
18
+ //
19
+ // :root {
20
+ // @include hub-forms-theme(
21
+ // $focus-ring-color: var(--hub-sys-color-info-subtle),
22
+ // $disabled-opacity: 0.5
23
+ // );
24
+ // }
25
+ //
26
+ // scss-docs-start hub-forms-theme
27
+ @mixin hub-forms-theme(
28
+ // ── Focus ring (shared by every control) ──
29
+ $focus-ring-color: null, // focus-ring colour
30
+ $focus-ring-width: null, // focus-ring width
31
+ // ── Validation accents ──
32
+ $invalid-color: null, // invalid text + border colour
33
+ $valid-color: null, // valid text + border colour
34
+ // ── State ──
35
+ $disabled-opacity: null, // opacity applied to a disabled control
36
+ // ── Motion ──
37
+ $transition: null // border/box-shadow transition shared by inputs
38
+ ) {
39
+ // Focus ring
40
+ @if $focus-ring-color != null {
41
+ --hub-form-focus-ring-color: #{$focus-ring-color};
42
+ }
43
+ @if $focus-ring-width != null {
44
+ --hub-form-focus-ring-width: #{$focus-ring-width};
45
+ }
46
+
47
+ // Validation accents (text + border move together)
48
+ @if $invalid-color != null {
49
+ --hub-form-invalid-color: #{$invalid-color};
50
+ --hub-form-invalid-border-color: #{$invalid-color};
51
+ }
52
+ @if $valid-color != null {
53
+ --hub-form-valid-color: #{$valid-color};
54
+ --hub-form-valid-border-color: #{$valid-color};
55
+ }
56
+
57
+ // State
58
+ @if $disabled-opacity != null {
59
+ --hub-form-disabled-opacity: #{$disabled-opacity};
60
+ }
61
+
62
+ // Motion
63
+ @if $transition != null {
64
+ --hub-form-transition: #{$transition};
65
+ }
66
+ }
67
+ // scss-docs-end hub-forms-theme
@@ -12,7 +12,7 @@
12
12
  //
13
13
  // @example — a compact, brand-accented bar with a rounded frame:
14
14
  //
15
- // @use 'ng-hub-ui-forms/styles/mixins/segmented-theme' as *;
15
+ // @use 'ng-hub-ui-forms/styles' as *;
16
16
  //
17
17
  // .view-switch {
18
18
  // @include hub-segmented-theme(
@@ -813,14 +813,20 @@ declare class HubSegmentedComponent extends HubFieldControl {
813
813
  /** Visual density. */
814
814
  readonly size: _angular_core.InputSignal<HubSegmentedSize>;
815
815
  /**
816
- * Semantic accent for the selected pill. Drives `data-variant` on the bar, which re-bases the
817
- * `--hub-segmented-selected-*` tokens. Built-in values map to the design-system palette
818
- * (`primary`, `secondary`, `success`, `danger`, `warning`, `info`, `neutral`), but the set is
819
- * OPEN — any custom string works as long as the consumer supplies the matching
820
- * `--hub-segmented-selected-bg` / `--hub-segmented-selected-color` (or `--hub-segmented-accent`)
821
- * for that `data-variant`. Empty string (default) keeps the neutral white-pill look.
816
+ * Accent for the selected pill. Accepts ANY colour value:
817
+ * - a built-in semantic name (`primary`, `success`, …) or any registered accent → resolves to
818
+ * the matching `--hub-sys-color-*` design-system token;
819
+ * - a literal colour (`#ff0000`, `rgb(...)`, `oklch(...)`, `rebeccapurple`) → used as-is.
820
+ * Both the sliding indicator and the multiple-mode pill follow it, and the selected label gets a
821
+ * derived contrast colour automatically. Empty string (default) keeps the neutral white-pill look.
822
822
  */
823
823
  readonly color: _angular_core.InputSignal<string>;
824
+ /**
825
+ * Resolves {@link color} to a paintable accent for the `--hub-segmented-accent` slot: a bareword
826
+ * becomes a `--hub-sys-color-*` token with the word as raw fallback (so named CSS colours work
827
+ * too), while a literal `#hex` / `rgb()` / `oklch()` / `var()` is passed through unchanged.
828
+ */
829
+ protected readonly accentVar: _angular_core.Signal<string | null>;
824
830
  /** Label text. */
825
831
  readonly label: _angular_core.InputSignal<string>;
826
832
  /** Label display type (`stacked`, `horizontal`). */
Binary file
File without changes