@radix-ng/primitives 1.0.6 → 1.0.8
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/aspect-ratio/README.md +1 -1
- package/fesm2022/radix-ng-primitives-accordion.mjs +6 -1
- package/fesm2022/radix-ng-primitives-accordion.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-aspect-ratio.mjs +9 -34
- package/fesm2022/radix-ng-primitives-aspect-ratio.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-autocomplete.mjs +43 -9
- package/fesm2022/radix-ng-primitives-autocomplete.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-avatar.mjs +69 -18
- package/fesm2022/radix-ng-primitives-avatar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-checkbox.mjs +93 -16
- package/fesm2022/radix-ng-primitives-checkbox.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-collapsible.mjs +4 -3
- package/fesm2022/radix-ng-primitives-collapsible.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-combobox.mjs +43 -9
- package/fesm2022/radix-ng-primitives-combobox.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-core.mjs +208 -2
- package/fesm2022/radix-ng-primitives-core.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-date-field.mjs +50 -9
- package/fesm2022/radix-ng-primitives-date-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-editable.mjs +31 -5
- package/fesm2022/radix-ng-primitives-editable.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-field.mjs +276 -58
- package/fesm2022/radix-ng-primitives-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-form.mjs +111 -27
- package/fesm2022/radix-ng-primitives-form.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-input.mjs +16 -6
- package/fesm2022/radix-ng-primitives-input.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-label.mjs +5 -4
- package/fesm2022/radix-ng-primitives-label.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-number-field.mjs +39 -10
- package/fesm2022/radix-ng-primitives-number-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-progress.mjs +37 -22
- package/fesm2022/radix-ng-primitives-progress.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-radio.mjs +18 -9
- package/fesm2022/radix-ng-primitives-radio.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-scroll-area.mjs +4 -4
- package/fesm2022/radix-ng-primitives-scroll-area.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-select.mjs +26 -8
- package/fesm2022/radix-ng-primitives-select.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-separator.mjs +7 -13
- package/fesm2022/radix-ng-primitives-separator.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-signal-forms.mjs +184 -0
- package/fesm2022/radix-ng-primitives-signal-forms.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-slider.mjs +25 -10
- package/fesm2022/radix-ng-primitives-slider.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-switch.mjs +32 -8
- package/fesm2022/radix-ng-primitives-switch.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tabs.mjs +4 -4
- package/fesm2022/radix-ng-primitives-tabs.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-time-field.mjs +49 -9
- package/fesm2022/radix-ng-primitives-time-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle-group.mjs +33 -16
- package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle.mjs +24 -29
- package/fesm2022/radix-ng-primitives-toggle.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toolbar.mjs +15 -2
- package/fesm2022/radix-ng-primitives-toolbar.mjs.map +1 -1
- package/package.json +11 -1
- package/types/radix-ng-primitives-accordion.d.ts +1 -0
- package/types/radix-ng-primitives-aspect-ratio.d.ts +10 -23
- package/types/radix-ng-primitives-autocomplete.d.ts +21 -2
- package/types/radix-ng-primitives-avatar.d.ts +51 -25
- package/types/radix-ng-primitives-checkbox.d.ts +78 -101
- package/types/radix-ng-primitives-combobox.d.ts +51 -2
- package/types/radix-ng-primitives-core.d.ts +206 -3
- package/types/radix-ng-primitives-date-field.d.ts +27 -2
- package/types/radix-ng-primitives-editable.d.ts +15 -2
- package/types/radix-ng-primitives-field.d.ts +165 -236
- package/types/radix-ng-primitives-form.d.ts +122 -37
- package/types/radix-ng-primitives-input.d.ts +8 -1
- package/types/radix-ng-primitives-label.d.ts +3 -2
- package/types/radix-ng-primitives-number-field.d.ts +15 -4
- package/types/radix-ng-primitives-progress.d.ts +59 -121
- package/types/radix-ng-primitives-radio.d.ts +7 -3
- package/types/radix-ng-primitives-select.d.ts +11 -3
- package/types/radix-ng-primitives-separator.d.ts +0 -7
- package/types/radix-ng-primitives-signal-forms.d.ts +97 -0
- package/types/radix-ng-primitives-slider.d.ts +9 -7
- package/types/radix-ng-primitives-switch.d.ts +15 -2
- package/types/radix-ng-primitives-time-field.d.ts +26 -2
- package/types/radix-ng-primitives-toggle-group.d.ts +13 -7
- package/types/radix-ng-primitives-toggle.d.ts +8 -8
- package/types/radix-ng-primitives-toolbar.d.ts +2 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { forwardRef, input, booleanAttribute, output, linkedSignal, untracked, Directive, inject, isDevMode, HOST_TAG_NAME, ElementRef, InjectionToken, computed, APP_ID, Injectable, DOCUMENT, PLATFORM_ID, DestroyRef, signal, effect, afterNextRender, assertInInjectionContext, Injector } from '@angular/core';
|
|
2
|
+
import { forwardRef, input, booleanAttribute, output, linkedSignal, untracked, Directive, inject, isDevMode, HOST_TAG_NAME, ElementRef, InjectionToken, computed, APP_ID, Injectable, DOCUMENT, PLATFORM_ID, DestroyRef, signal, model, effect, afterNextRender, assertInInjectionContext, Injector } from '@angular/core';
|
|
3
3
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
4
|
import { getLocalTimeZone, CalendarDateTime, ZonedDateTime, getDayOfWeek, DateFormatter, createCalendar, toCalendar, CalendarDate, Time, startOfMonth, endOfMonth, today } from '@internationalized/date';
|
|
5
5
|
import { isPlatformBrowser, DOCUMENT as DOCUMENT$1 } from '@angular/common';
|
|
@@ -2030,6 +2030,212 @@ function provideToken(token, type) {
|
|
|
2030
2030
|
};
|
|
2031
2031
|
}
|
|
2032
2032
|
|
|
2033
|
+
/**
|
|
2034
|
+
* Builds the shared form-UI state and its mutators from a control's input signals, removing the
|
|
2035
|
+
* per-control copy-paste of the `invalidState`/`touchedState`/`dirtyState` computeds and the
|
|
2036
|
+
* `markAsTouched`/`markDirty` logic.
|
|
2037
|
+
*
|
|
2038
|
+
* **Why the inputs stay on the control (not in here):** Angular's compiler only discovers
|
|
2039
|
+
* `input()`/`model()` declared as field initializers, and Signal Forms binds form-written state
|
|
2040
|
+
* (`errors`/`disabled`/`touched`) onto the single directive that carries the `value`/`checked`
|
|
2041
|
+
* model — so the inputs must co-locate with `value` on the control directive. This helper takes
|
|
2042
|
+
* those signals and centralizes only the derivation.
|
|
2043
|
+
*
|
|
2044
|
+
* Safe to call from a field initializer: `signal()`/`computed()` need no injection context.
|
|
2045
|
+
*/
|
|
2046
|
+
function createFormUiState(options) {
|
|
2047
|
+
const dirtyValue = signal(false, /* @ts-ignore */
|
|
2048
|
+
...(ngDevMode ? [{ debugName: "dirtyValue" }] : /* istanbul ignore next */ []));
|
|
2049
|
+
return {
|
|
2050
|
+
invalidState: computed(() => options.invalid() || (options.errors()?.length ?? 0) > 0),
|
|
2051
|
+
touchedState: computed(() => options.touched()),
|
|
2052
|
+
dirtyState: computed(() => options.dirty() || dirtyValue()),
|
|
2053
|
+
markDirty: () => dirtyValue.set(true),
|
|
2054
|
+
markAsTouched: () => {
|
|
2055
|
+
options.cva?.markAsTouched();
|
|
2056
|
+
options.touched.set(true);
|
|
2057
|
+
options.touch.emit();
|
|
2058
|
+
}
|
|
2059
|
+
};
|
|
2060
|
+
}
|
|
2061
|
+
/** Spread helper to wire {@link RdxFormUiStateContext} fields from an {@link RdxFormUiState} into a context factory. */
|
|
2062
|
+
function formUiStateContext(state) {
|
|
2063
|
+
return {
|
|
2064
|
+
invalidState: state.invalidState,
|
|
2065
|
+
touchedState: state.touchedState,
|
|
2066
|
+
dirtyState: state.dirtyState,
|
|
2067
|
+
markAsTouched: () => state.markAsTouched()
|
|
2068
|
+
};
|
|
2069
|
+
}
|
|
2070
|
+
/** DI token holding the control's {@link RdxFormUiState}, read by {@link RdxFormUiStateHost}. */
|
|
2071
|
+
const RDX_FORM_UI_STATE = new InjectionToken('RdxFormUiState');
|
|
2072
|
+
/**
|
|
2073
|
+
* Tri-state *displayed* validity (`true` valid / `false` invalid / `null` neutral) an enclosing `Field`
|
|
2074
|
+
* exposes so a control can reflect the field's single, gated display-state instead of its own eager
|
|
2075
|
+
* invalid. A control inside a `rdxFieldRoot` reads this for its `data-valid` / `data-invalid` /
|
|
2076
|
+
* `aria-invalid`; standalone (token absent) it falls back to its own binary invalidity. This keeps the
|
|
2077
|
+
* field root, the control, and any trigger/group part on one display-state (Base UI's `valid: boolean |
|
|
2078
|
+
* null`). `Field` provides it (`useFactory` over the root's `validState`).
|
|
2079
|
+
*/
|
|
2080
|
+
const RDX_FIELD_VALIDITY = new InjectionToken('RdxFieldValidity');
|
|
2081
|
+
/**
|
|
2082
|
+
* Tri-state display validity: when inside a `Field` the field's gated `validState` is the **single
|
|
2083
|
+
* source** (the control reflects it, including its `validationMode` neutral state); standalone, the
|
|
2084
|
+
* control's own binary invalidity.
|
|
2085
|
+
*
|
|
2086
|
+
* **Contract:** inside a `Field` a control's own `invalid` / `errors` inputs are **not** displayed — the
|
|
2087
|
+
* Field owns displayed validity. Drive validity through the Field instead: bind `rdxSignalField`
|
|
2088
|
+
* (Signal Forms), or set `[invalid]` on `rdxFieldRoot`. The control's own `invalid`/`errors` are for
|
|
2089
|
+
* standalone use.
|
|
2090
|
+
*/
|
|
2091
|
+
function resolveDisplayValid(fieldValidity, ownInvalid) {
|
|
2092
|
+
return fieldValidity ? fieldValidity() : ownInvalid() ? false : true;
|
|
2093
|
+
}
|
|
2094
|
+
/**
|
|
2095
|
+
* Provide a control's {@link RdxFormUiState} on its host element so {@link RdxFormUiStateHost} can
|
|
2096
|
+
* reflect it. Pair with `hostDirectives: [RdxFormUiStateHost]`:
|
|
2097
|
+
*
|
|
2098
|
+
* ```ts
|
|
2099
|
+
* providers: [provideFormUiState(() => inject(MyControl).formUi)],
|
|
2100
|
+
* hostDirectives: [RdxFormUiStateHost]
|
|
2101
|
+
* ```
|
|
2102
|
+
*/
|
|
2103
|
+
function provideFormUiState(state) {
|
|
2104
|
+
return { provide: RDX_FORM_UI_STATE, useFactory: state };
|
|
2105
|
+
}
|
|
2106
|
+
/**
|
|
2107
|
+
* Host directive that reflects a control's {@link RdxFormUiState} as the standard validation
|
|
2108
|
+
* `data-*`/`aria-invalid` attributes and marks the control touched on focus-out — the binding block
|
|
2109
|
+
* that was otherwise copy-pasted into every form control's `host`.
|
|
2110
|
+
*
|
|
2111
|
+
* Compose it via `hostDirectives` on a control (or group root) whose host element is the one that
|
|
2112
|
+
* should carry the attributes, and provide the state with {@link provideFormUiState}. It reads the
|
|
2113
|
+
* state from DI, so the control does not need to expose `invalidState`/`touchedState`/`dirtyState`
|
|
2114
|
+
* or a `markAsTouched` method just for the host bindings.
|
|
2115
|
+
*
|
|
2116
|
+
* Note: the `focusout` listener marks touched for controls whose touched-trigger is blur/focus-out
|
|
2117
|
+
* (text inputs, groups). Controls that latch touched on interaction instead (e.g. checkbox) still do
|
|
2118
|
+
* so themselves; the extra focus-out call only ever sets `touched` to `true`, so it is harmless.
|
|
2119
|
+
*
|
|
2120
|
+
* Not for compound controls that surface state on a child part via context (e.g. select reflects on
|
|
2121
|
+
* its trigger) — those keep their own child-part bindings.
|
|
2122
|
+
*/
|
|
2123
|
+
class RdxFormUiStateHost {
|
|
2124
|
+
constructor() {
|
|
2125
|
+
/** @ignore The injected state the host bindings read. */
|
|
2126
|
+
this.formUi = inject(RDX_FORM_UI_STATE);
|
|
2127
|
+
this.fieldValidity = inject(RDX_FIELD_VALIDITY, { optional: true });
|
|
2128
|
+
/** @ignore Tri-state display validity (enclosing Field's gated state, else own invalidity). */
|
|
2129
|
+
this.displayValid = computed(() => resolveDisplayValid(this.fieldValidity, this.formUi.invalidState), /* @ts-ignore */
|
|
2130
|
+
...(ngDevMode ? [{ debugName: "displayValid" }] : /* istanbul ignore next */ []));
|
|
2131
|
+
}
|
|
2132
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: RdxFormUiStateHost, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2133
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.2", type: RdxFormUiStateHost, isStandalone: true, host: { listeners: { "focusout": "formUi.markAsTouched()" }, properties: { "attr.aria-invalid": "displayValid() === false ? \"true\" : undefined", "attr.data-invalid": "displayValid() === false ? \"\" : undefined", "attr.data-valid": "displayValid() === true ? \"\" : undefined", "attr.data-touched": "formUi.touchedState() ? \"\" : undefined", "attr.data-dirty": "formUi.dirtyState() ? \"\" : undefined" } }, ngImport: i0 }); }
|
|
2134
|
+
}
|
|
2135
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: RdxFormUiStateHost, decorators: [{
|
|
2136
|
+
type: Directive,
|
|
2137
|
+
args: [{
|
|
2138
|
+
host: {
|
|
2139
|
+
// Tri-state via the enclosing Field when present (neutral → neither data-valid nor data-invalid),
|
|
2140
|
+
// else the control's own binary invalidity. `touched`/`dirty` always reflect the control.
|
|
2141
|
+
'[attr.aria-invalid]': 'displayValid() === false ? "true" : undefined',
|
|
2142
|
+
'[attr.data-invalid]': 'displayValid() === false ? "" : undefined',
|
|
2143
|
+
'[attr.data-valid]': 'displayValid() === true ? "" : undefined',
|
|
2144
|
+
'[attr.data-touched]': 'formUi.touchedState() ? "" : undefined',
|
|
2145
|
+
'[attr.data-dirty]': 'formUi.dirtyState() ? "" : undefined',
|
|
2146
|
+
'(focusout)': 'formUi.markAsTouched()'
|
|
2147
|
+
}
|
|
2148
|
+
}]
|
|
2149
|
+
}] });
|
|
2150
|
+
/**
|
|
2151
|
+
* Abstract base that declares the optional `FormUiControl` state inputs
|
|
2152
|
+
* (`invalid`/`errors`/`touched`/`dirty` + the `touch` output) once and builds the control's
|
|
2153
|
+
* {@link RdxFormUiState} from them, so a control directive can inherit the whole surface with a
|
|
2154
|
+
* single `extends` instead of re-declaring it.
|
|
2155
|
+
*
|
|
2156
|
+
* The declarations must live on a decorated **directive class** (Angular only discovers
|
|
2157
|
+
* `input()`/`model()`/`output()` as field initializers, and Signal Forms binds form-written state
|
|
2158
|
+
* onto the single directive carrying the `value`/`checked` model) — inheritance keeps them on that
|
|
2159
|
+
* directive, which a host directive could not. The control still declares its own `value`/`checked`
|
|
2160
|
+
* model (the type-parametric part) and, for `data-*` reflection, either composes
|
|
2161
|
+
* {@link RdxFormUiStateHost} or binds the attributes itself.
|
|
2162
|
+
*
|
|
2163
|
+
* Dual controls override {@link formUiTouchTarget} to bridge their `ControlValueAccessor` into
|
|
2164
|
+
* `markAsTouched`.
|
|
2165
|
+
*/
|
|
2166
|
+
class RdxFormUiControlBase {
|
|
2167
|
+
constructor() {
|
|
2168
|
+
/** Whether the control is invalid. A non-empty {@link errors} list also marks it invalid. */
|
|
2169
|
+
this.invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
2170
|
+
/** Whether the control has been touched. A `model()` so Signal Forms can write it; set on blur/focus-out. */
|
|
2171
|
+
this.touched = model(false, /* @ts-ignore */
|
|
2172
|
+
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
2173
|
+
/** Whether the value changed from its initial value. Merged with internal tracking. */
|
|
2174
|
+
this.dirty = input(false, { ...(ngDevMode ? { debugName: "dirty" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
2175
|
+
/** Validation errors for the control. A non-empty list marks it invalid. */
|
|
2176
|
+
this.errors = input([], /* @ts-ignore */
|
|
2177
|
+
...(ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []));
|
|
2178
|
+
/** Emits when the control is touched, notifying Signal Forms (stable Angular 22 contract). */
|
|
2179
|
+
this.touch = output();
|
|
2180
|
+
/** The shared form-UI state derived from the inputs above. Call `formUi.markDirty()` on value change. */
|
|
2181
|
+
this.formUi = createFormUiState({
|
|
2182
|
+
invalid: this.invalid,
|
|
2183
|
+
errors: this.errors,
|
|
2184
|
+
touched: this.touched,
|
|
2185
|
+
touch: this.touch,
|
|
2186
|
+
dirty: this.dirty,
|
|
2187
|
+
cva: this.formUiTouchTarget()
|
|
2188
|
+
});
|
|
2189
|
+
/** The enclosing Field's tri-state display validity, if any. `protected` so a control whose own
|
|
2190
|
+
* invalidity is richer than `formUi.invalidState` (e.g. date/time-field add a parse check) can build
|
|
2191
|
+
* its own `displayValid` from it. */
|
|
2192
|
+
this.fieldValidity = inject(RDX_FIELD_VALIDITY, { optional: true });
|
|
2193
|
+
/**
|
|
2194
|
+
* Tri-state *displayed* validity for controls that bind their own host attributes (radio, switch,
|
|
2195
|
+
* number-field): the enclosing Field's gated state when inside a `rdxFieldRoot`, else this control's
|
|
2196
|
+
* own binary invalidity (`formUi.invalidState`). Bind `data-valid`/`data-invalid`/`aria-invalid` to
|
|
2197
|
+
* this so a neutral field shows neither. Controls whose `invalidState` is richer than
|
|
2198
|
+
* `formUi.invalidState` override this with `resolveDisplayValid(this.fieldValidity, this.invalidState)`.
|
|
2199
|
+
*/
|
|
2200
|
+
this.displayValid = computed(() => resolveDisplayValid(this.fieldValidity, this.formUi.invalidState), /* @ts-ignore */
|
|
2201
|
+
...(ngDevMode ? [{ debugName: "displayValid" }] : /* istanbul ignore next */ []));
|
|
2202
|
+
}
|
|
2203
|
+
/**
|
|
2204
|
+
* Override to bridge the control's `ControlValueAccessor` into `markAsTouched` (dual controls —
|
|
2205
|
+
* return `injectControlValueAccessor()` or a `{ markAsTouched }` adapter). Default: no CVA
|
|
2206
|
+
* (Signal-Forms-only controls such as select).
|
|
2207
|
+
*/
|
|
2208
|
+
formUiTouchTarget() {
|
|
2209
|
+
return null;
|
|
2210
|
+
}
|
|
2211
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: RdxFormUiControlBase, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2212
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.2", type: RdxFormUiControlBase, isStandalone: true, inputs: { invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null }, dirty: { classPropertyName: "dirty", publicName: "dirty", isSignal: true, isRequired: false, transformFunction: null }, errors: { classPropertyName: "errors", publicName: "errors", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { touched: "touchedChange", touch: "touch" }, ngImport: i0 }); }
|
|
2213
|
+
}
|
|
2214
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: RdxFormUiControlBase, decorators: [{
|
|
2215
|
+
type: Directive
|
|
2216
|
+
}], propDecorators: { invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }, { type: i0.Output, args: ["touchedChange"] }], dirty: [{ type: i0.Input, args: [{ isSignal: true, alias: "dirty", required: false }] }], errors: [{ type: i0.Input, args: [{ isSignal: true, alias: "errors", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }] } });
|
|
2217
|
+
|
|
2218
|
+
/** The default validation-display mode when neither `rdxFieldRoot` nor `rdxFormRoot` sets one. */
|
|
2219
|
+
const RDX_DEFAULT_VALIDATION_MODE = 'onBlur';
|
|
2220
|
+
/**
|
|
2221
|
+
* Whether a Field should reveal its (client-side) validity given the {@link RdxValidationMode} and the
|
|
2222
|
+
* field's interaction state. `false` means stay neutral (neither `data-valid` nor `data-invalid`, error
|
|
2223
|
+
* hidden); `true` means reflect the actual validity.
|
|
2224
|
+
*/
|
|
2225
|
+
function isValidationRevealed(mode, interaction) {
|
|
2226
|
+
const { touched, dirty, submitAttempted } = interaction;
|
|
2227
|
+
switch (mode) {
|
|
2228
|
+
case 'always':
|
|
2229
|
+
return true;
|
|
2230
|
+
case 'onChange':
|
|
2231
|
+
return dirty || submitAttempted;
|
|
2232
|
+
case 'onBlur':
|
|
2233
|
+
return touched || submitAttempted;
|
|
2234
|
+
case 'onSubmit':
|
|
2235
|
+
return submitAttempted;
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2033
2239
|
function createCancelableChangeEventDetails(reason, event, trigger) {
|
|
2034
2240
|
let canceled = false;
|
|
2035
2241
|
let propagationAllowed = false;
|
|
@@ -4075,5 +4281,5 @@ var RdxPositionAlign;
|
|
|
4075
4281
|
* Generated bundle index. Do not edit.
|
|
4076
4282
|
*/
|
|
4077
4283
|
|
|
4078
|
-
export { A, ALT, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, ARROW_UP, ASTERISK, BACKSPACE, CAPS_LOCK, CONTROL, CTRL, DELETE, DOCS_BASE_URL, END, ENTER, ESCAPE, F1, F10, F11, F12, F2, F3, F4, F5, F6, F7, F8, F9, HOME, META, P, PAGE_DOWN, PAGE_UP, RDX_FLOATING_REGISTRATION, RDX_FLOATING_ROOT_CONTEXT, RDX_FLOATING_TREE, RDX_INTERNAL_BACKDROP_ATTR, RDX_SCROLL_LOCKED_ATTR, RdxControlValueAccessor, RdxFloatingNode, RdxFloatingNodeRegistration, RdxFloatingRegistrationContext, RdxFloatingRootContext, RdxFloatingTree, RdxIdGenerator, RdxLiveAnnouncer, RdxPositionAlign, RdxPositionSide, RdxTriggerRegistry, SHIFT, SPACE, SPACE_CODE, TAB, TIME_GRANULARITIES, a, areAllDaysBetweenValid, clamp, createCancelableChangeEventDetails, createContent, createContext, createFloatingEvents, createFloatingRootContext, createFormatter, createMonth, createMonths, docsUrl, elementSize, getActiveElement, getDaysBetween, getDaysInMonth, getDefaultDate, getDefaultTime, getLastFirstDayOfWeek, getMaxTransitionDuration, getNextLastDayOfWeek, getOptsByGranularity, getPlaceholder, getSegmentElements, getWeekNumber, handleAndDispatchCustomEvent, handleCalendarInitialFocus, hasTime, initializeSegmentValues, injectControlValueAccessor, injectDocument, injectFloatingRootContext, injectId, isAcceptableSegmentKey, isAfter, isAfterOrSame, isBefore, isBeforeOrSame, isBetween, isBetweenInclusive, isCalendarDateTime, isEqual, isItemEqualToValue, isNullish, isNumberString, isSegmentNavigationKey, isZonedDateTime, itemToStringLabel, itemToStringValue, j, k, n, normalizeDateStep, normalizeHour12, normalizeHourCycle, p, provideFloatingRegistration, provideFloatingRootContext, provideFloatingTree, provideToken, provideValueAccessor, rdxCheckLabelElement, rdxCheckTriggerElement, rdxDevError, rdxDevWarning, resetRdxDevWarnings, resizeEffect, resolveFloatingTree, roundToStepPrecision, segmentBuilders, setupInternalBackdrop, snapValueToStep, syncSegmentValues, syncTimeSegmentValues, toDate, useAnchoredScrollLock, useArrowNavigation, useDateField, useFilter, useGraceArea, useListHighlight, usePointerDrag, useScrollLock, useTransitionStatus, watch };
|
|
4284
|
+
export { A, ALT, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, ARROW_UP, ASTERISK, BACKSPACE, CAPS_LOCK, CONTROL, CTRL, DELETE, DOCS_BASE_URL, END, ENTER, ESCAPE, F1, F10, F11, F12, F2, F3, F4, F5, F6, F7, F8, F9, HOME, META, P, PAGE_DOWN, PAGE_UP, RDX_DEFAULT_VALIDATION_MODE, RDX_FIELD_VALIDITY, RDX_FLOATING_REGISTRATION, RDX_FLOATING_ROOT_CONTEXT, RDX_FLOATING_TREE, RDX_FORM_UI_STATE, RDX_INTERNAL_BACKDROP_ATTR, RDX_SCROLL_LOCKED_ATTR, RdxControlValueAccessor, RdxFloatingNode, RdxFloatingNodeRegistration, RdxFloatingRegistrationContext, RdxFloatingRootContext, RdxFloatingTree, RdxFormUiControlBase, RdxFormUiStateHost, RdxIdGenerator, RdxLiveAnnouncer, RdxPositionAlign, RdxPositionSide, RdxTriggerRegistry, SHIFT, SPACE, SPACE_CODE, TAB, TIME_GRANULARITIES, a, areAllDaysBetweenValid, clamp, createCancelableChangeEventDetails, createContent, createContext, createFloatingEvents, createFloatingRootContext, createFormUiState, createFormatter, createMonth, createMonths, docsUrl, elementSize, formUiStateContext, getActiveElement, getDaysBetween, getDaysInMonth, getDefaultDate, getDefaultTime, getLastFirstDayOfWeek, getMaxTransitionDuration, getNextLastDayOfWeek, getOptsByGranularity, getPlaceholder, getSegmentElements, getWeekNumber, handleAndDispatchCustomEvent, handleCalendarInitialFocus, hasTime, initializeSegmentValues, injectControlValueAccessor, injectDocument, injectFloatingRootContext, injectId, isAcceptableSegmentKey, isAfter, isAfterOrSame, isBefore, isBeforeOrSame, isBetween, isBetweenInclusive, isCalendarDateTime, isEqual, isItemEqualToValue, isNullish, isNumberString, isSegmentNavigationKey, isValidationRevealed, isZonedDateTime, itemToStringLabel, itemToStringValue, j, k, n, normalizeDateStep, normalizeHour12, normalizeHourCycle, p, provideFloatingRegistration, provideFloatingRootContext, provideFloatingTree, provideFormUiState, provideToken, provideValueAccessor, rdxCheckLabelElement, rdxCheckTriggerElement, rdxDevError, rdxDevWarning, resetRdxDevWarnings, resizeEffect, resolveDisplayValid, resolveFloatingTree, roundToStepPrecision, segmentBuilders, setupInternalBackdrop, snapValueToStep, syncSegmentValues, syncTimeSegmentValues, toDate, useAnchoredScrollLock, useArrowNavigation, useDateField, useFilter, useGraceArea, useListHighlight, usePointerDrag, useScrollLock, useTransitionStatus, watch };
|
|
4079
4285
|
//# sourceMappingURL=radix-ng-primitives-core.mjs.map
|