@radix-ng/primitives 1.1.0 → 1.1.1
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/fesm2022/radix-ng-primitives-autocomplete.mjs +66 -7
- package/fesm2022/radix-ng-primitives-autocomplete.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-checkbox.mjs +147 -125
- package/fesm2022/radix-ng-primitives-checkbox.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-combobox.mjs +171 -37
- package/fesm2022/radix-ng-primitives-combobox.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-core.mjs +173 -5
- package/fesm2022/radix-ng-primitives-core.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-number-field.mjs +38 -7
- package/fesm2022/radix-ng-primitives-number-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-radio.mjs +49 -2
- package/fesm2022/radix-ng-primitives-radio.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-select.mjs +35 -3
- package/fesm2022/radix-ng-primitives-select.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-slider.mjs +17 -2
- package/fesm2022/radix-ng-primitives-slider.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-switch.mjs +60 -7
- package/fesm2022/radix-ng-primitives-switch.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle-group.mjs +25 -3
- package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +1 -1
- package/package.json +1 -1
- package/types/radix-ng-primitives-autocomplete.d.ts +10 -1
- package/types/radix-ng-primitives-checkbox.d.ts +56 -43
- package/types/radix-ng-primitives-combobox.d.ts +46 -2
- package/types/radix-ng-primitives-core.d.ts +62 -4
- package/types/radix-ng-primitives-number-field.d.ts +12 -5
- package/types/radix-ng-primitives-radio.d.ts +6 -1
- package/types/radix-ng-primitives-select.d.ts +8 -1
- package/types/radix-ng-primitives-slider.d.ts +2 -1
- package/types/radix-ng-primitives-switch.d.ts +19 -3
- package/types/radix-ng-primitives-toggle-group.d.ts +5 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { numberAttribute, computed, signal, inject, DestroyRef, input, booleanAttribute, Directive, ElementRef, model, output, effect, untracked, NgModule } from '@angular/core';
|
|
3
3
|
import * as i1 from '@radix-ng/primitives/core';
|
|
4
|
-
import { createContext, clamp, getActiveElement, RdxFormUiControlBase, injectControlValueAccessor, injectId, createCancelableChangeEventDetails, RdxControlValueAccessor } from '@radix-ng/primitives/core';
|
|
4
|
+
import { createContext, clamp, getActiveElement, RdxFormUiControlBase, injectControlValueAccessor, injectId, useNativeFormControl, serializeNativeFormValue, createCancelableChangeEventDetails, RdxControlValueAccessor } from '@radix-ng/primitives/core';
|
|
5
5
|
import { NumberFormatter, NumberParser } from '@internationalized/number';
|
|
6
6
|
import * as i1$1 from '@radix-ng/primitives/portal';
|
|
7
7
|
import { RdxPortal } from '@radix-ng/primitives/portal';
|
|
@@ -362,15 +362,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImpor
|
|
|
362
362
|
}] });
|
|
363
363
|
|
|
364
364
|
/**
|
|
365
|
-
* The hidden native `input[type=number]` that mirrors the field value for
|
|
366
|
-
*
|
|
367
|
-
* the visible
|
|
365
|
+
* The optional hidden native `input[type=number]` that mirrors the field value for browser constraint
|
|
366
|
+
* validation (min/max/step/required) and autofill. When present it also owns native form serialization;
|
|
367
|
+
* without it the root generates a plain hidden entry. Place it inside the root, alongside the visible
|
|
368
|
+
* `[rdxNumberFieldInput]`.
|
|
368
369
|
*
|
|
369
370
|
* @see https://base-ui.com/react/components/number-field
|
|
370
371
|
*/
|
|
371
372
|
class RdxNumberFieldHiddenInput {
|
|
372
373
|
constructor() {
|
|
373
374
|
this.rootContext = injectNumberFieldRootContext();
|
|
375
|
+
const input = inject(ElementRef).nativeElement;
|
|
376
|
+
this.rootContext.registerNativeInput(input);
|
|
377
|
+
inject(DestroyRef).onDestroy(() => this.rootContext.registerNativeInput(null));
|
|
374
378
|
}
|
|
375
379
|
/** Move focus to the visible input when the hidden one is focused (e.g. via form validation). */
|
|
376
380
|
onFocus() {
|
|
@@ -413,7 +417,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImpor
|
|
|
413
417
|
'(change)': 'onChange($event)'
|
|
414
418
|
}
|
|
415
419
|
}]
|
|
416
|
-
}] });
|
|
420
|
+
}], ctorParameters: () => [] });
|
|
417
421
|
|
|
418
422
|
/**
|
|
419
423
|
* A stepper button that increases the field value when clicked or held.
|
|
@@ -720,10 +724,10 @@ class RdxNumberFieldRoot extends RdxFormUiControlBase {
|
|
|
720
724
|
* @default false
|
|
721
725
|
*/
|
|
722
726
|
this.required = input(false, { ...(ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
723
|
-
/** Name
|
|
727
|
+
/** Name used when serializing this field into native `FormData`. */
|
|
724
728
|
this.name = input(/* @ts-ignore */
|
|
725
729
|
...(ngDevMode ? [undefined, { debugName: "name" }] : /* istanbul ignore next */ []));
|
|
726
|
-
/** Id of
|
|
730
|
+
/** Id of an external form that owns this field. */
|
|
727
731
|
this.form = input(/* @ts-ignore */
|
|
728
732
|
...(ngDevMode ? [undefined, { debugName: "form" }] : /* istanbul ignore next */ []));
|
|
729
733
|
/** The uncontrolled value of the field when it is initially rendered. */
|
|
@@ -748,6 +752,9 @@ class RdxNumberFieldRoot extends RdxFormUiControlBase {
|
|
|
748
752
|
/** @ignore The native input element, registered by `[rdxNumberFieldInput]`. */
|
|
749
753
|
this.inputEl = signal(undefined, /* @ts-ignore */
|
|
750
754
|
...(ngDevMode ? [{ debugName: "inputEl" }] : /* istanbul ignore next */ []));
|
|
755
|
+
/** @ignore Optional native number input that owns constraints/autofill and form serialization. */
|
|
756
|
+
this.nativeInputEl = signal(null, /* @ts-ignore */
|
|
757
|
+
...(ngDevMode ? [{ debugName: "nativeInputEl" }] : /* istanbul ignore next */ []));
|
|
751
758
|
/**
|
|
752
759
|
* @ignore Gate that prevents the formatted value from overwriting in-progress typing.
|
|
753
760
|
* Plain field (not a signal): it is toggled imperatively inside event handlers.
|
|
@@ -771,6 +778,26 @@ class RdxNumberFieldRoot extends RdxFormUiControlBase {
|
|
|
771
778
|
/** @ignore The current numeric value (`null` when empty). */
|
|
772
779
|
this.currentValue = computed(() => this.cva.value() ?? null, /* @ts-ignore */
|
|
773
780
|
...(ngDevMode ? [{ debugName: "currentValue" }] : /* istanbul ignore next */ []));
|
|
781
|
+
// The hidden number input remains an opt-in constraint-validation/autofill bridge and owns native
|
|
782
|
+
// serialization when present. Otherwise the shared layer supplies a plain hidden form control.
|
|
783
|
+
this.nativeFormControl = useNativeFormControl({
|
|
784
|
+
name: this.name,
|
|
785
|
+
form: this.form,
|
|
786
|
+
disabled: this.isDisabled,
|
|
787
|
+
value: this.currentValue,
|
|
788
|
+
serialize: serializeNativeFormValue,
|
|
789
|
+
hasNativeControl: computed(() => this.nativeInputEl() !== null),
|
|
790
|
+
defaultValue: () => this.defaultValue() ?? this.cva.value() ?? null,
|
|
791
|
+
onReset: (value) => {
|
|
792
|
+
this.value.set(value);
|
|
793
|
+
if (!this.resetNgControl(value)) {
|
|
794
|
+
this.cva.setValue(value);
|
|
795
|
+
}
|
|
796
|
+
this.allowInputSync = true;
|
|
797
|
+
this.setInputValue(this.formatNumber(value));
|
|
798
|
+
this.formUi.resetInteractionState?.();
|
|
799
|
+
}
|
|
800
|
+
});
|
|
774
801
|
/** @ignore */
|
|
775
802
|
this.minWithDefault = computed(() => this.min() ?? Number.MIN_SAFE_INTEGER, /* @ts-ignore */
|
|
776
803
|
...(ngDevMode ? [{ debugName: "minWithDefault" }] : /* istanbul ignore next */ []));
|
|
@@ -849,6 +876,10 @@ class RdxNumberFieldRoot extends RdxFormUiControlBase {
|
|
|
849
876
|
registerInput(el) {
|
|
850
877
|
this.inputEl.set(el);
|
|
851
878
|
}
|
|
879
|
+
/** @ignore Registers the optional native constraint/autofill input. */
|
|
880
|
+
registerNativeInput(el) {
|
|
881
|
+
this.nativeInputEl.set(el);
|
|
882
|
+
}
|
|
852
883
|
/** @ignore Sets the displayed text without changing the numeric value. */
|
|
853
884
|
setInputValue(text) {
|
|
854
885
|
this.inputValue.set(text);
|