ng-primitives 0.124.0 → 0.125.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/date-time-date-fns/README.md +3 -0
- package/fesm2022/ng-primitives-avatar.mjs +4 -2
- package/fesm2022/ng-primitives-avatar.mjs.map +1 -1
- package/fesm2022/ng-primitives-checkbox.mjs +4 -2
- package/fesm2022/ng-primitives-checkbox.mjs.map +1 -1
- package/fesm2022/ng-primitives-date-picker.mjs +42 -44
- package/fesm2022/ng-primitives-date-picker.mjs.map +1 -1
- package/fesm2022/ng-primitives-date-time-date-fns.mjs +95 -0
- package/fesm2022/ng-primitives-date-time-date-fns.mjs.map +1 -0
- package/fesm2022/ng-primitives-date-time-luxon.mjs +21 -3
- package/fesm2022/ng-primitives-date-time-luxon.mjs.map +1 -1
- package/fesm2022/ng-primitives-date-time.mjs +18 -3
- package/fesm2022/ng-primitives-date-time.mjs.map +1 -1
- package/fesm2022/ng-primitives-dialog.mjs +11 -4
- package/fesm2022/ng-primitives-dialog.mjs.map +1 -1
- package/fesm2022/ng-primitives-form-field.mjs +3 -0
- package/fesm2022/ng-primitives-form-field.mjs.map +1 -1
- package/fesm2022/ng-primitives-input-otp.mjs +15 -7
- package/fesm2022/ng-primitives-input-otp.mjs.map +1 -1
- package/fesm2022/ng-primitives-listbox.mjs +5 -4
- package/fesm2022/ng-primitives-listbox.mjs.map +1 -1
- package/fesm2022/ng-primitives-menu.mjs +8 -0
- package/fesm2022/ng-primitives-menu.mjs.map +1 -1
- package/fesm2022/ng-primitives-meter.mjs +20 -5
- package/fesm2022/ng-primitives-meter.mjs.map +1 -1
- package/fesm2022/ng-primitives-number-field.mjs +10 -0
- package/fesm2022/ng-primitives-number-field.mjs.map +1 -1
- package/fesm2022/ng-primitives-pagination.mjs +16 -6
- package/fesm2022/ng-primitives-pagination.mjs.map +1 -1
- package/fesm2022/ng-primitives-popover.mjs +4 -0
- package/fesm2022/ng-primitives-popover.mjs.map +1 -1
- package/fesm2022/ng-primitives-progress.mjs +36 -11
- package/fesm2022/ng-primitives-progress.mjs.map +1 -1
- package/fesm2022/ng-primitives-roving-focus.mjs +13 -2
- package/fesm2022/ng-primitives-roving-focus.mjs.map +1 -1
- package/fesm2022/ng-primitives-search.mjs +2 -1
- package/fesm2022/ng-primitives-search.mjs.map +1 -1
- package/fesm2022/ng-primitives-slider.mjs +38 -18
- package/fesm2022/ng-primitives-slider.mjs.map +1 -1
- package/fesm2022/ng-primitives-switch.mjs +18 -8
- package/fesm2022/ng-primitives-switch.mjs.map +1 -1
- package/fesm2022/ng-primitives-tabs.mjs +22 -6
- package/fesm2022/ng-primitives-tabs.mjs.map +1 -1
- package/fesm2022/ng-primitives-textarea.mjs +10 -8
- package/fesm2022/ng-primitives-textarea.mjs.map +1 -1
- package/fesm2022/ng-primitives-toast.mjs +3 -0
- package/fesm2022/ng-primitives-toast.mjs.map +1 -1
- package/fesm2022/ng-primitives-toggle-group.mjs +31 -8
- package/fesm2022/ng-primitives-toggle-group.mjs.map +1 -1
- package/package.json +8 -1
- package/schematics/ng-generate/templates/checkbox/checkbox.__fileSuffix@dasherize__.ts.template +2 -1
- package/schematics/ng-generate/templates/combobox/combobox.__fileSuffix@dasherize__.ts.template +3 -2
- package/schematics/ng-generate/templates/date-picker/date-picker.__fileSuffix@dasherize__.ts.template +2 -1
- package/schematics/ng-generate/templates/listbox/listbox.__fileSuffix@dasherize__.ts.template +9 -4
- package/schematics/ng-generate/templates/pagination/pagination.__fileSuffix@dasherize__.ts.template +7 -1
- package/schematics/ng-generate/templates/range-slider/range-slider.__fileSuffix@dasherize__.ts.template +4 -3
- package/schematics/ng-generate/templates/slider/slider.__fileSuffix@dasherize__.ts.template +2 -1
- package/schematics/ng-generate/templates/switch/switch.__fileSuffix@dasherize__.ts.template +2 -1
- package/types/ng-primitives-checkbox.d.ts +5 -1
- package/types/ng-primitives-date-picker.d.ts +7 -9
- package/types/ng-primitives-date-time-date-fns.d.ts +30 -0
- package/types/ng-primitives-date-time.d.ts +15 -3
- package/types/ng-primitives-dialog.d.ts +4 -0
- package/types/ng-primitives-input-otp.d.ts +5 -5
- package/types/ng-primitives-meter.d.ts +9 -2
- package/types/ng-primitives-pagination.d.ts +34 -8
- package/types/ng-primitives-progress.d.ts +4 -2
- package/types/ng-primitives-roving-focus.d.ts +7 -0
- package/types/ng-primitives-slider.d.ts +5 -4
- package/types/ng-primitives-switch.d.ts +14 -4
- package/types/ng-primitives-tabs.d.ts +6 -1
- package/types/ng-primitives-toggle-group.d.ts +51 -37
|
@@ -32,7 +32,7 @@ function injectToggleGroupConfig() {
|
|
|
32
32
|
return inject(NgpToggleGroupConfigToken, { optional: true }) ?? defaultToggleGroupConfig;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const [NgpToggleGroupStateToken, ngpToggleGroup,
|
|
35
|
+
const [NgpToggleGroupStateToken, ngpToggleGroup, _injectToggleGroupState, provideToggleGroupState,] = createPrimitive('NgpToggleGroup', ({ orientation: _orientation, wrap: _wrap, allowDeselection: _allowDeselection, type: _type, value: _value, defaultValue: _defaultValue, disabled: _disabled, compareWith: _compareWith, onValueChange, }) => {
|
|
36
36
|
const element = injectElementRef();
|
|
37
37
|
const allowDeselection = controlled(_allowDeselection, true);
|
|
38
38
|
const type = controlled(_type, 'single');
|
|
@@ -40,6 +40,7 @@ const [NgpToggleGroupStateToken, ngpToggleGroup, injectToggleGroupState, provide
|
|
|
40
40
|
const orientation = controlled(_orientation, 'horizontal');
|
|
41
41
|
const wrap = controlled(_wrap, true);
|
|
42
42
|
const defaultValue = controlled(_defaultValue, []);
|
|
43
|
+
const compareWith = controlled(_compareWith, (a, b) => a === b);
|
|
43
44
|
const [value, setValueInternal, valueChange] = controlledState({
|
|
44
45
|
value: _value,
|
|
45
46
|
defaultValue,
|
|
@@ -78,7 +79,8 @@ const [NgpToggleGroupStateToken, ngpToggleGroup, injectToggleGroupState, provide
|
|
|
78
79
|
if (disabled() || !allowDeselection()) {
|
|
79
80
|
return;
|
|
80
81
|
}
|
|
81
|
-
const
|
|
82
|
+
const cmp = compareWith();
|
|
83
|
+
const newValue = value().filter(v => !cmp(v, selection));
|
|
82
84
|
setValue(newValue);
|
|
83
85
|
}
|
|
84
86
|
/**
|
|
@@ -86,7 +88,8 @@ const [NgpToggleGroupStateToken, ngpToggleGroup, injectToggleGroupState, provide
|
|
|
86
88
|
* @internal
|
|
87
89
|
*/
|
|
88
90
|
function isSelected(itemValue) {
|
|
89
|
-
|
|
91
|
+
const cmp = compareWith();
|
|
92
|
+
return value().some(v => cmp(v, itemValue));
|
|
90
93
|
}
|
|
91
94
|
/**
|
|
92
95
|
* Toggle a value in the toggle group.
|
|
@@ -118,6 +121,7 @@ const [NgpToggleGroupStateToken, ngpToggleGroup, injectToggleGroupState, provide
|
|
|
118
121
|
toggle,
|
|
119
122
|
value: deprecatedSetter(value, 'setValue', setValue),
|
|
120
123
|
orientation: deprecatedSetter(orientation, 'setOrientation', setOrientation),
|
|
124
|
+
type,
|
|
121
125
|
setValue,
|
|
122
126
|
setDefaultValue: defaultValue.set,
|
|
123
127
|
setDisabled,
|
|
@@ -125,15 +129,27 @@ const [NgpToggleGroupStateToken, ngpToggleGroup, injectToggleGroupState, provide
|
|
|
125
129
|
valueChange,
|
|
126
130
|
};
|
|
127
131
|
});
|
|
132
|
+
/**
|
|
133
|
+
* Injects the ToggleGroup state, typed to the value type `T`.
|
|
134
|
+
*/
|
|
135
|
+
function injectToggleGroupState(options) {
|
|
136
|
+
return _injectToggleGroupState(options);
|
|
137
|
+
}
|
|
128
138
|
|
|
129
|
-
const [NgpToggleGroupItemToken, ngpToggleGroupItem, injectToggleGroupItemState, provideToggleGroupItemState,] = createPrimitive('NgpToggleGroupItem', ({ value, disabled = signal(false) }) => {
|
|
139
|
+
const [NgpToggleGroupItemToken, ngpToggleGroupItem, injectToggleGroupItemState, provideToggleGroupItemState,] = createPrimitive('NgpToggleGroupItem', ({ value, disabled = signal(false), }) => {
|
|
130
140
|
const element = injectElementRef();
|
|
131
141
|
const toggleGroup = injectToggleGroupState();
|
|
132
142
|
// Whether the item is selected.
|
|
133
143
|
const selected = computed(() => toggleGroup()?.isSelected(value()) ?? false, ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
|
|
144
|
+
// Whether the item belongs to a multiple-select toggle group.
|
|
145
|
+
const multiple = computed(() => toggleGroup()?.type() === 'multiple', ...(ngDevMode ? [{ debugName: "multiple" }] : /* istanbul ignore next */ []));
|
|
134
146
|
// Host bindings
|
|
135
|
-
|
|
136
|
-
|
|
147
|
+
// In a single-select group the items behave like radio buttons, while in a
|
|
148
|
+
// multiple-select group they are independent toggle buttons exposing
|
|
149
|
+
// aria-pressed, matching the standalone toggle primitive.
|
|
150
|
+
attrBinding(element, 'role', () => (multiple() ? null : 'radio'));
|
|
151
|
+
attrBinding(element, 'aria-checked', () => (multiple() ? null : selected()));
|
|
152
|
+
attrBinding(element, 'aria-pressed', () => (multiple() ? selected() : null));
|
|
137
153
|
dataBinding(element, 'data-selected', selected);
|
|
138
154
|
attrBinding(element, 'aria-disabled', disabled);
|
|
139
155
|
dataBinding(element, 'data-disabled', disabled);
|
|
@@ -225,6 +241,12 @@ class NgpToggleGroup {
|
|
|
225
241
|
* Emits when the value of the toggle group changes.
|
|
226
242
|
*/
|
|
227
243
|
this.valueChange = output({ alias: 'ngpToggleGroupValueChange' });
|
|
244
|
+
/**
|
|
245
|
+
* The comparator used to determine whether two values are equal.
|
|
246
|
+
* Useful when values are objects and equality should be checked by value rather than by reference.
|
|
247
|
+
* @default (a, b) => a === b
|
|
248
|
+
*/
|
|
249
|
+
this.compareWith = input((a, b) => a === b, { ...(ngDevMode ? { debugName: "compareWith" } : /* istanbul ignore next */ {}), alias: 'ngpToggleGroupCompareWith' });
|
|
228
250
|
/**
|
|
229
251
|
* Whether the toggle group is disabled.
|
|
230
252
|
*/
|
|
@@ -241,6 +263,7 @@ class NgpToggleGroup {
|
|
|
241
263
|
value: this.value,
|
|
242
264
|
defaultValue: this.defaultValue,
|
|
243
265
|
disabled: this.disabled,
|
|
266
|
+
compareWith: this.compareWith,
|
|
244
267
|
onValueChange: (value) => this.valueChange.emit(value),
|
|
245
268
|
});
|
|
246
269
|
}
|
|
@@ -275,7 +298,7 @@ class NgpToggleGroup {
|
|
|
275
298
|
this.state.setOrientation(newOrientation);
|
|
276
299
|
}
|
|
277
300
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpToggleGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
278
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.14", type: NgpToggleGroup, isStandalone: true, selector: "[ngpToggleGroup]", inputs: { orientation: { classPropertyName: "orientation", publicName: "ngpToggleGroupOrientation", isSignal: true, isRequired: false, transformFunction: null }, wrap: { classPropertyName: "wrap", publicName: "ngpToggleGroupWrap", isSignal: true, isRequired: false, transformFunction: null }, allowDeselection: { classPropertyName: "allowDeselection", publicName: "ngpToggleGroupAllowDeselection", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "ngpToggleGroupType", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "ngpToggleGroupValue", isSignal: true, isRequired: false, transformFunction: null }, defaultValue: { classPropertyName: "defaultValue", publicName: "ngpToggleGroupDefaultValue", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpToggleGroupDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "ngpToggleGroupValueChange" }, providers: [provideToggleGroupState(), provideRovingFocusGroupState({ inherit: true })], exportAs: ["ngpToggleGroup"], ngImport: i0 }); }
|
|
301
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.14", type: NgpToggleGroup, isStandalone: true, selector: "[ngpToggleGroup]", inputs: { orientation: { classPropertyName: "orientation", publicName: "ngpToggleGroupOrientation", isSignal: true, isRequired: false, transformFunction: null }, wrap: { classPropertyName: "wrap", publicName: "ngpToggleGroupWrap", isSignal: true, isRequired: false, transformFunction: null }, allowDeselection: { classPropertyName: "allowDeselection", publicName: "ngpToggleGroupAllowDeselection", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "ngpToggleGroupType", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "ngpToggleGroupValue", isSignal: true, isRequired: false, transformFunction: null }, defaultValue: { classPropertyName: "defaultValue", publicName: "ngpToggleGroupDefaultValue", isSignal: true, isRequired: false, transformFunction: null }, compareWith: { classPropertyName: "compareWith", publicName: "ngpToggleGroupCompareWith", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpToggleGroupDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "ngpToggleGroupValueChange" }, providers: [provideToggleGroupState(), provideRovingFocusGroupState({ inherit: true })], exportAs: ["ngpToggleGroup"], ngImport: i0 }); }
|
|
279
302
|
}
|
|
280
303
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: NgpToggleGroup, decorators: [{
|
|
281
304
|
type: Directive,
|
|
@@ -284,7 +307,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
284
307
|
exportAs: 'ngpToggleGroup',
|
|
285
308
|
providers: [provideToggleGroupState(), provideRovingFocusGroupState({ inherit: true })],
|
|
286
309
|
}]
|
|
287
|
-
}], propDecorators: { orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToggleGroupOrientation", required: false }] }], wrap: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToggleGroupWrap", required: false }] }], allowDeselection: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToggleGroupAllowDeselection", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToggleGroupType", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToggleGroupValue", required: false }] }], defaultValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToggleGroupDefaultValue", required: false }] }], valueChange: [{ type: i0.Output, args: ["ngpToggleGroupValueChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToggleGroupDisabled", required: false }] }] } });
|
|
310
|
+
}], propDecorators: { orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToggleGroupOrientation", required: false }] }], wrap: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToggleGroupWrap", required: false }] }], allowDeselection: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToggleGroupAllowDeselection", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToggleGroupType", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToggleGroupValue", required: false }] }], defaultValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToggleGroupDefaultValue", required: false }] }], valueChange: [{ type: i0.Output, args: ["ngpToggleGroupValueChange"] }], compareWith: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToggleGroupCompareWith", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "ngpToggleGroupDisabled", required: false }] }] } });
|
|
288
311
|
|
|
289
312
|
/**
|
|
290
313
|
* Generated bundle index. Do not edit.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-toggle-group.mjs","sources":["../../../../packages/ng-primitives/toggle-group/src/config/toggle-group-config.ts","../../../../packages/ng-primitives/toggle-group/src/toggle-group/toggle-group-state.ts","../../../../packages/ng-primitives/toggle-group/src/toggle-group-item/toggle-group-item-state.ts","../../../../packages/ng-primitives/toggle-group/src/toggle-group-item/toggle-group-item.ts","../../../../packages/ng-primitives/toggle-group/src/toggle-group/toggle-group.ts","../../../../packages/ng-primitives/toggle-group/src/ng-primitives-toggle-group.ts"],"sourcesContent":["import { InjectionToken, Provider, inject } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\n\nexport interface NgpToggleGroupConfig {\n /**\n * The orientation of the toggle group.\n * @default 'horizontal'\n */\n orientation: NgpOrientation;\n\n /**\n * The type of the toggle group, whether only one item can be selected or multiple.\n * @default 'single'\n */\n type: 'single' | 'multiple';\n\n /**\n * Whether a toggle button can be deselected.\n * @default true\n */\n allowDeselection: boolean;\n\n /**\n * Whether focus should wrap around when reaching the end of the toggle group.\n * @default true\n */\n wrap: boolean;\n}\n\nexport const defaultToggleGroupConfig: NgpToggleGroupConfig = {\n orientation: 'horizontal',\n type: 'single',\n allowDeselection: true,\n wrap: true,\n};\n\nexport const NgpToggleGroupConfigToken = new InjectionToken<NgpToggleGroupConfig>(\n 'NgpToggleGroupConfigToken',\n);\n\n/**\n * Provide the default ToggleGroup configuration\n * @param config The ToggleGroup configuration\n * @returns The provider\n */\nexport function provideToggleGroupConfig(config: Partial<NgpToggleGroupConfig>): Provider[] {\n return [\n {\n provide: NgpToggleGroupConfigToken,\n useValue: { ...defaultToggleGroupConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the ToggleGroup configuration\n * @returns The global ToggleGroup configuration\n */\nexport function injectToggleGroupConfig(): NgpToggleGroupConfig {\n return inject(NgpToggleGroupConfigToken, { optional: true }) ?? defaultToggleGroupConfig;\n}\n","import { Signal, WritableSignal } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport { ngpRovingFocusGroup } from 'ng-primitives/roving-focus';\nimport {\n attrBinding,\n controlled,\n controlledState,\n createPrimitive,\n dataBinding,\n deprecatedSetter,\n SetterOptions,\n} from 'ng-primitives/state';\nimport { Observable } from 'rxjs';\n\n/**\n * The state interface for the ToggleGroup pattern.\n */\nexport interface NgpToggleGroupState {\n /**\n * The current value(s) of the toggle group.\n */\n readonly value: WritableSignal<string[]>;\n\n /**\n * Emit when the value changes.\n */\n readonly valueChange: Observable<string[]>;\n\n /**\n * Whether the toggle group is disabled.\n */\n readonly disabled: WritableSignal<boolean>;\n\n /**\n * The orientation of the toggle group.\n */\n readonly orientation: WritableSignal<NgpOrientation>;\n /**\n * Select a value in the toggle group.\n */\n select(selection: string): void;\n\n /**\n * De-select a value in the toggle group.\n */\n deselect(selection: string): void;\n\n /**\n * Check if a value is selected in the toggle group.\n */\n isSelected(selection: string): boolean;\n\n /**\n * Toggle a value in the toggle group.\n */\n toggle(selection: string): void;\n\n /**\n * Set the value(s) of the toggle group.\n */\n setValue(newValue: string[], options?: SetterOptions): void;\n\n /**\n * Set the default value(s) of the toggle group.\n */\n setDefaultValue(defaultValue: string[]): void;\n\n /**\n * Set the disabled state of the toggle group.\n */\n setDisabled(isDisabled: boolean): void;\n\n /**\n * Set the orientation of the toggle group.\n */\n setOrientation(newOrientation: NgpOrientation): void;\n}\n\n/**\n * The props interface for the ToggleGroup pattern.\n */\nexport interface NgpToggleGroupProps {\n /**\n * The orientation of the toggle-group.\n */\n readonly orientation?: Signal<NgpOrientation>;\n /**\n * Whether focus should wrap around when reaching the end of the toggle-group.\n */\n readonly wrap?: Signal<boolean>;\n /**\n * Whether deselection is allowed in the toggle-group.\n */\n readonly allowDeselection?: Signal<boolean>;\n /**\n * The type of the toggle-group (e.g., 'single' or 'multiple').\n */\n readonly type?: Signal<'single' | 'multiple'>;\n /**\n * The value(s) of the toggle-group.\n */\n readonly value: Signal<string[] | undefined>;\n /**\n * The default value(s) of the toggle-group for uncontrolled usage.\n */\n readonly defaultValue?: Signal<string[]>;\n /**\n * Whether the toggle-group is disabled.\n */\n readonly disabled?: Signal<boolean>;\n /**\n * Emit when the value changes.\n */\n readonly onValueChange?: (value: string[]) => void;\n}\n\nexport const [\n NgpToggleGroupStateToken,\n ngpToggleGroup,\n injectToggleGroupState,\n provideToggleGroupState,\n] = createPrimitive(\n 'NgpToggleGroup',\n ({\n orientation: _orientation,\n wrap: _wrap,\n allowDeselection: _allowDeselection,\n type: _type,\n value: _value,\n defaultValue: _defaultValue,\n disabled: _disabled,\n onValueChange,\n }: NgpToggleGroupProps): NgpToggleGroupState => {\n const element = injectElementRef();\n\n const allowDeselection = controlled(_allowDeselection, true);\n const type = controlled(_type, 'single');\n const disabled = controlled(_disabled, false);\n const orientation = controlled(_orientation, 'horizontal');\n const wrap = controlled(_wrap, true);\n const defaultValue = controlled(_defaultValue, []);\n\n const [value, setValueInternal, valueChange] = controlledState<string[]>({\n value: _value,\n defaultValue,\n onChange: onValueChange,\n });\n\n // Own the roving focus group so it shares the group's `disabled` and\n // `orientation` signals directly. This keeps keyboard navigation in sync\n // with programmatic/form-driven changes (e.g. `setDisabled`, `setOrientation`)\n // without needing to re-push each value across a directive boundary.\n ngpRovingFocusGroup({ orientation, disabled, wrap });\n\n // Host bindings\n attrBinding(element, 'role', 'group');\n dataBinding(element, 'data-orientation', orientation);\n dataBinding(element, 'data-type', type);\n dataBinding(element, 'data-disabled', disabled);\n\n /**\n * Select a value in the toggle group.\n */\n function select(selection: string): void {\n if (disabled()) {\n return;\n }\n\n let newValue: string[] = [];\n\n if (type() === 'single') {\n newValue = [selection];\n } else {\n newValue = [...value(), selection];\n }\n\n setValue(newValue);\n }\n\n /**\n * De-select a value in the toggle group.\n */\n function deselect(selection: string): void {\n if (disabled() || !allowDeselection()) {\n return;\n }\n\n const newValue = value().filter(v => v !== selection);\n setValue(newValue);\n }\n\n /**\n * Check if a value is selected in the toggle group.\n * @internal\n */\n function isSelected(itemValue: string): boolean {\n return value().includes(itemValue);\n }\n\n /**\n * Toggle a value in the toggle group.\n * @internal\n */\n function toggle(itemValue: string): void {\n if (isSelected(itemValue)) {\n deselect(itemValue);\n } else {\n select(itemValue);\n }\n }\n\n function setValue(newValue: string[], options?: SetterOptions): void {\n setValueInternal(newValue, options);\n }\n\n function setDisabled(isDisabled: boolean): void {\n disabled.set(isDisabled);\n }\n\n function setOrientation(newOrientation: NgpOrientation): void {\n // The roving focus group shares this signal, so it stays in sync.\n orientation.set(newOrientation);\n }\n\n return {\n select,\n deselect,\n disabled: deprecatedSetter(disabled, 'setDisabled'),\n isSelected,\n toggle,\n value: deprecatedSetter(value, 'setValue', setValue),\n orientation: deprecatedSetter(orientation, 'setOrientation', setOrientation),\n setValue,\n setDefaultValue: defaultValue.set,\n setDisabled,\n setOrientation,\n valueChange,\n } satisfies NgpToggleGroupState;\n },\n);\n","import { computed, signal, Signal } from '@angular/core';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport { attrBinding, createPrimitive, dataBinding, listener } from 'ng-primitives/state';\nimport { injectToggleGroupState } from '../toggle-group/toggle-group-state';\n\n/**\n * The state interface for the ToggleGroupItem pattern.\n */\nexport interface NgpToggleGroupItemState {\n selected: Signal<boolean>;\n toggle(): void;\n}\n\n/**\n * The props interface for the ToggleGroupItem pattern.\n */\nexport interface NgpToggleGroupItemProps {\n /**\n * The value of the toggle group item.\n */\n value: Signal<string>;\n\n /**\n * Whether the toggle group item is disabled.\n */\n disabled?: Signal<boolean>;\n}\n\nexport const [\n NgpToggleGroupItemToken,\n ngpToggleGroupItem,\n injectToggleGroupItemState,\n provideToggleGroupItemState,\n] = createPrimitive(\n 'NgpToggleGroupItem',\n ({ value, disabled = signal(false) }: NgpToggleGroupItemProps): NgpToggleGroupItemState => {\n const element = injectElementRef();\n const toggleGroup = injectToggleGroupState();\n\n // Whether the item is selected.\n const selected = computed(() => toggleGroup()?.isSelected(value()!) ?? false);\n\n // Host bindings\n attrBinding(element, 'role', 'radio');\n attrBinding(element, 'aria-checked', selected);\n dataBinding(element, 'data-selected', selected);\n attrBinding(element, 'aria-disabled', disabled);\n dataBinding(element, 'data-disabled', disabled);\n\n // Host listener\n listener(element, 'click', () => toggle());\n\n // Toggle the item.\n const toggle = (): void => {\n if (disabled?.()) {\n return;\n }\n toggleGroup()?.toggle(value()!);\n };\n\n return { selected, toggle } satisfies NgpToggleGroupItemState;\n },\n);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input, OnInit, Signal } from '@angular/core';\nimport { ngpRovingFocusItem, provideRovingFocusItemState } from 'ng-primitives/roving-focus';\nimport { ngpToggleGroupItem, provideToggleGroupItemState } from './toggle-group-item-state';\n\n@Directive({\n selector: '[ngpToggleGroupItem]',\n exportAs: 'ngpToggleGroupItem',\n providers: [provideToggleGroupItemState(), provideRovingFocusItemState()],\n})\nexport class NgpToggleGroupItem implements OnInit {\n /**\n * The value of the item.\n * @required\n */\n readonly value = input<string>(undefined, {\n alias: 'ngpToggleGroupItemValue',\n });\n\n /**\n * Whether the item is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpToggleGroupItemDisabled',\n transform: booleanAttribute,\n });\n\n constructor() {\n ngpToggleGroupItem({\n value: this.value as Signal<string>,\n disabled: this.disabled,\n });\n // Initialize the roving focus item state\n ngpRovingFocusItem({ disabled: this.disabled });\n }\n\n ngOnInit(): void {\n // we can't use a required input for value as it is used in a computed property before the input is set\n if (this.value() === undefined) {\n throw new Error('The value input is required for the toggle group item.');\n }\n }\n}\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input, output } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\nimport { provideRovingFocusGroupState } from 'ng-primitives/roving-focus';\nimport { SetterOptions } from 'ng-primitives/state';\nimport { injectToggleGroupConfig } from '../config/toggle-group-config';\nimport { ngpToggleGroup, provideToggleGroupState } from './toggle-group-state';\n\n@Directive({\n selector: '[ngpToggleGroup]',\n exportAs: 'ngpToggleGroup',\n providers: [provideToggleGroupState(), provideRovingFocusGroupState({ inherit: true })],\n})\nexport class NgpToggleGroup {\n /**\n * Access the global toggle group configuration.\n */\n private readonly config = injectToggleGroupConfig();\n\n /**\n * The orientation of the toggle group.\n */\n readonly orientation = input<NgpOrientation>(this.config.orientation, {\n alias: 'ngpToggleGroupOrientation',\n });\n\n /**\n * Whether focus should wrap around when reaching the end of the toggle group.\n * @default true\n */\n readonly wrap = input<boolean, BooleanInput>(this.config.wrap, {\n alias: 'ngpToggleGroupWrap',\n transform: booleanAttribute,\n });\n\n /**\n * Whether toggle buttons can be deselected. If set to `false`, clicking a selected toggle button will not deselect it.\n * @default true\n */\n readonly allowDeselection = input<boolean, BooleanInput>(this.config.allowDeselection, {\n alias: 'ngpToggleGroupAllowDeselection',\n transform: booleanAttribute,\n });\n\n /**\n * The type of the toggle group, whether only one item can be selected or multiple.\n */\n readonly type = input<'single' | 'multiple'>(this.config.type, { alias: 'ngpToggleGroupType' });\n\n /**\n * The selected value(s) of the toggle group.\n */\n readonly value = input<string[] | undefined>(undefined, { alias: 'ngpToggleGroupValue' });\n\n /**\n * The default selected value(s) for uncontrolled usage.\n * @default []\n */\n readonly defaultValue = input<string[]>([], { alias: 'ngpToggleGroupDefaultValue' });\n\n /**\n * Emits when the value of the toggle group changes.\n */\n readonly valueChange = output<string[]>({ alias: 'ngpToggleGroupValueChange' });\n\n /**\n * Whether the toggle group is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpToggleGroupDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * The state of the toggle group.\n */\n protected readonly state = ngpToggleGroup({\n orientation: this.orientation,\n wrap: this.wrap,\n allowDeselection: this.allowDeselection,\n type: this.type,\n value: this.value,\n defaultValue: this.defaultValue,\n disabled: this.disabled,\n onValueChange: (value: string[]) => this.valueChange.emit(value),\n });\n\n /**\n * Toggle a value in the toggle group.\n */\n toggle(value: string): void {\n this.state.toggle(value);\n }\n\n /**\n * Set the value(s) of the toggle group.\n */\n setValue(newValue: string[], options?: SetterOptions): void {\n this.state.setValue(newValue, options);\n }\n\n /**\n * Set the default value(s) of the toggle group.\n */\n setDefaultValue(defaultValue: string[]): void {\n this.state.setDefaultValue(defaultValue);\n }\n\n /**\n * Set the disabled state of the toggle group.\n */\n setDisabled(isDisabled: boolean): void {\n this.state.setDisabled(isDisabled);\n }\n\n /**\n * Set the orientation of the toggle group.\n */\n setOrientation(newOrientation: NgpOrientation): void {\n this.state.setOrientation(newOrientation);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AA6BO,MAAM,wBAAwB,GAAyB;AAC5D,IAAA,WAAW,EAAE,YAAY;AACzB,IAAA,IAAI,EAAE,QAAQ;AACd,IAAA,gBAAgB,EAAE,IAAI;AACtB,IAAA,IAAI,EAAE,IAAI;CACX;AAEM,MAAM,yBAAyB,GAAG,IAAI,cAAc,CACzD,2BAA2B,CAC5B;AAED;;;;AAIG;AACG,SAAU,wBAAwB,CAAC,MAAqC,EAAA;IAC5E,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,yBAAyB;AAClC,YAAA,QAAQ,EAAE,EAAE,GAAG,wBAAwB,EAAE,GAAG,MAAM,EAAE;AACrD,SAAA;KACF;AACH;AAEA;;;AAGG;SACa,uBAAuB,GAAA;AACrC,IAAA,OAAO,MAAM,CAAC,yBAAyB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,wBAAwB;AAC1F;;MCyDa,CACX,wBAAwB,EACxB,cAAc,EACd,sBAAsB,EACtB,uBAAuB,EACxB,GAAG,eAAe,CACjB,gBAAgB,EAChB,CAAC,EACC,WAAW,EAAE,YAAY,EACzB,IAAI,EAAE,KAAK,EACX,gBAAgB,EAAE,iBAAiB,EACnC,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,aAAa,EAC3B,QAAQ,EAAE,SAAS,EACnB,aAAa,GACO,KAAyB;AAC7C,IAAA,MAAM,OAAO,GAAG,gBAAgB,EAAE;IAElC,MAAM,gBAAgB,GAAG,UAAU,CAAC,iBAAiB,EAAE,IAAI,CAAC;IAC5D,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC;IACxC,MAAM,QAAQ,GAAG,UAAU,CAAC,SAAS,EAAE,KAAK,CAAC;IAC7C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,gBAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAE5E,cAAc,EAAA,UAAA,EAAA,CAAA;kBAL1B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,kBAAkB;AAC5B,oBAAA,QAAQ,EAAE,gBAAgB;AAC1B,oBAAA,SAAS,EAAE,CAAC,uBAAuB,EAAE,EAAE,4BAA4B,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AACxF,iBAAA;;;ACZD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-toggle-group.mjs","sources":["../../../../packages/ng-primitives/toggle-group/src/config/toggle-group-config.ts","../../../../packages/ng-primitives/toggle-group/src/toggle-group/toggle-group-state.ts","../../../../packages/ng-primitives/toggle-group/src/toggle-group-item/toggle-group-item-state.ts","../../../../packages/ng-primitives/toggle-group/src/toggle-group-item/toggle-group-item.ts","../../../../packages/ng-primitives/toggle-group/src/toggle-group/toggle-group.ts","../../../../packages/ng-primitives/toggle-group/src/ng-primitives-toggle-group.ts"],"sourcesContent":["import { InjectionToken, Provider, inject } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\n\nexport interface NgpToggleGroupConfig {\n /**\n * The orientation of the toggle group.\n * @default 'horizontal'\n */\n orientation: NgpOrientation;\n\n /**\n * The type of the toggle group, whether only one item can be selected or multiple.\n * @default 'single'\n */\n type: 'single' | 'multiple';\n\n /**\n * Whether a toggle button can be deselected.\n * @default true\n */\n allowDeselection: boolean;\n\n /**\n * Whether focus should wrap around when reaching the end of the toggle group.\n * @default true\n */\n wrap: boolean;\n}\n\nexport const defaultToggleGroupConfig: NgpToggleGroupConfig = {\n orientation: 'horizontal',\n type: 'single',\n allowDeselection: true,\n wrap: true,\n};\n\nexport const NgpToggleGroupConfigToken = new InjectionToken<NgpToggleGroupConfig>(\n 'NgpToggleGroupConfigToken',\n);\n\n/**\n * Provide the default ToggleGroup configuration\n * @param config The ToggleGroup configuration\n * @returns The provider\n */\nexport function provideToggleGroupConfig(config: Partial<NgpToggleGroupConfig>): Provider[] {\n return [\n {\n provide: NgpToggleGroupConfigToken,\n useValue: { ...defaultToggleGroupConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the ToggleGroup configuration\n * @returns The global ToggleGroup configuration\n */\nexport function injectToggleGroupConfig(): NgpToggleGroupConfig {\n return inject(NgpToggleGroupConfigToken, { optional: true }) ?? defaultToggleGroupConfig;\n}\n","import { Signal, WritableSignal } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport { ngpRovingFocusGroup } from 'ng-primitives/roving-focus';\nimport {\n attrBinding,\n controlled,\n controlledState,\n createPrimitive,\n dataBinding,\n deprecatedSetter,\n SetterOptions,\n StateInjectionOptions,\n} from 'ng-primitives/state';\nimport { Observable } from 'rxjs';\n\n/**\n * The state interface for the ToggleGroup pattern.\n */\nexport interface NgpToggleGroupState<T = string> {\n /**\n * The current value(s) of the toggle group.\n */\n readonly value: WritableSignal<T[]>;\n\n /**\n * Emit when the value changes.\n */\n readonly valueChange: Observable<T[]>;\n\n /**\n * Whether the toggle group is disabled.\n */\n readonly disabled: WritableSignal<boolean>;\n\n /**\n * The orientation of the toggle group.\n */\n readonly orientation: WritableSignal<NgpOrientation>;\n\n /**\n * The type of the toggle group, whether only one item can be selected or multiple.\n */\n readonly type: Signal<'single' | 'multiple'>;\n\n /**\n * Select a value in the toggle group.\n */\n select(selection: T): void;\n\n /**\n * De-select a value in the toggle group.\n */\n deselect(selection: T): void;\n\n /**\n * Check if a value is selected in the toggle group.\n */\n isSelected(selection: T): boolean;\n\n /**\n * Toggle a value in the toggle group.\n */\n toggle(selection: T): void;\n\n /**\n * Set the value(s) of the toggle group.\n */\n setValue(newValue: T[], options?: SetterOptions): void;\n\n /**\n * Set the default value(s) of the toggle group.\n */\n setDefaultValue(defaultValue: T[]): void;\n\n /**\n * Set the disabled state of the toggle group.\n */\n setDisabled(isDisabled: boolean): void;\n\n /**\n * Set the orientation of the toggle group.\n */\n setOrientation(newOrientation: NgpOrientation): void;\n}\n\n/**\n * The props interface for the ToggleGroup pattern.\n */\nexport interface NgpToggleGroupProps<T = string> {\n /**\n * The orientation of the toggle-group.\n */\n readonly orientation?: Signal<NgpOrientation>;\n /**\n * Whether focus should wrap around when reaching the end of the toggle-group.\n */\n readonly wrap?: Signal<boolean>;\n /**\n * Whether deselection is allowed in the toggle-group.\n */\n readonly allowDeselection?: Signal<boolean>;\n /**\n * The type of the toggle-group (e.g., 'single' or 'multiple').\n */\n readonly type?: Signal<'single' | 'multiple'>;\n /**\n * The value(s) of the toggle-group.\n */\n readonly value: Signal<T[] | undefined>;\n /**\n * The default value(s) of the toggle-group for uncontrolled usage.\n */\n readonly defaultValue?: Signal<T[]>;\n /**\n * Whether the toggle-group is disabled.\n */\n readonly disabled?: Signal<boolean>;\n /**\n * The comparator used to determine whether two values are equal.\n * @default (a, b) => a === b\n */\n readonly compareWith?: Signal<(a: T, b: T) => boolean>;\n /**\n * Emit when the value changes.\n */\n readonly onValueChange?: (value: T[]) => void;\n}\n\nexport const [\n NgpToggleGroupStateToken,\n ngpToggleGroup,\n _injectToggleGroupState,\n provideToggleGroupState,\n] = createPrimitive(\n 'NgpToggleGroup',\n <T = string>({\n orientation: _orientation,\n wrap: _wrap,\n allowDeselection: _allowDeselection,\n type: _type,\n value: _value,\n defaultValue: _defaultValue,\n disabled: _disabled,\n compareWith: _compareWith,\n onValueChange,\n }: NgpToggleGroupProps<T>): NgpToggleGroupState<T> => {\n const element = injectElementRef();\n\n const allowDeselection = controlled(_allowDeselection, true);\n const type = controlled(_type, 'single');\n const disabled = controlled(_disabled, false);\n const orientation = controlled(_orientation, 'horizontal');\n const wrap = controlled(_wrap, true);\n const defaultValue = controlled(_defaultValue, []);\n const compareWith = controlled(_compareWith, (a: T, b: T) => a === b);\n\n const [value, setValueInternal, valueChange] = controlledState<T[]>({\n value: _value,\n defaultValue,\n onChange: onValueChange,\n });\n\n // Own the roving focus group so it shares the group's `disabled` and\n // `orientation` signals directly. This keeps keyboard navigation in sync\n // with programmatic/form-driven changes (e.g. `setDisabled`, `setOrientation`)\n // without needing to re-push each value across a directive boundary.\n ngpRovingFocusGroup({ orientation, disabled, wrap });\n\n // Host bindings\n attrBinding(element, 'role', 'group');\n dataBinding(element, 'data-orientation', orientation);\n dataBinding(element, 'data-type', type);\n dataBinding(element, 'data-disabled', disabled);\n\n /**\n * Select a value in the toggle group.\n */\n function select(selection: T): void {\n if (disabled()) {\n return;\n }\n\n let newValue: T[] = [];\n\n if (type() === 'single') {\n newValue = [selection];\n } else {\n newValue = [...value(), selection];\n }\n\n setValue(newValue);\n }\n\n /**\n * De-select a value in the toggle group.\n */\n function deselect(selection: T): void {\n if (disabled() || !allowDeselection()) {\n return;\n }\n\n const cmp = compareWith();\n const newValue = value().filter(v => !cmp(v, selection));\n setValue(newValue);\n }\n\n /**\n * Check if a value is selected in the toggle group.\n * @internal\n */\n function isSelected(itemValue: T): boolean {\n const cmp = compareWith();\n return value().some(v => cmp(v, itemValue));\n }\n\n /**\n * Toggle a value in the toggle group.\n * @internal\n */\n function toggle(itemValue: T): void {\n if (isSelected(itemValue)) {\n deselect(itemValue);\n } else {\n select(itemValue);\n }\n }\n\n function setValue(newValue: T[], options?: SetterOptions): void {\n setValueInternal(newValue, options);\n }\n\n function setDisabled(isDisabled: boolean): void {\n disabled.set(isDisabled);\n }\n\n function setOrientation(newOrientation: NgpOrientation): void {\n // The roving focus group shares this signal, so it stays in sync.\n orientation.set(newOrientation);\n }\n\n return {\n select,\n deselect,\n disabled: deprecatedSetter(disabled, 'setDisabled'),\n isSelected,\n toggle,\n value: deprecatedSetter(value, 'setValue', setValue),\n orientation: deprecatedSetter(orientation, 'setOrientation', setOrientation),\n type,\n setValue,\n setDefaultValue: defaultValue.set,\n setDisabled,\n setOrientation,\n valueChange,\n } satisfies NgpToggleGroupState<T>;\n },\n);\n\n/**\n * Injects the ToggleGroup state, typed to the value type `T`.\n */\nexport function injectToggleGroupState<T = string>(\n options?: StateInjectionOptions,\n): Signal<NgpToggleGroupState<T>> {\n return _injectToggleGroupState(options) as Signal<NgpToggleGroupState<T>>;\n}\n","import { computed, signal, Signal } from '@angular/core';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport { attrBinding, createPrimitive, dataBinding, listener } from 'ng-primitives/state';\nimport { injectToggleGroupState } from '../toggle-group/toggle-group-state';\n\n/**\n * The state interface for the ToggleGroupItem pattern.\n */\nexport interface NgpToggleGroupItemState {\n selected: Signal<boolean>;\n toggle(): void;\n}\n\n/**\n * The props interface for the ToggleGroupItem pattern.\n */\nexport interface NgpToggleGroupItemProps<T = string> {\n /**\n * The value of the toggle group item.\n */\n value: Signal<T>;\n\n /**\n * Whether the toggle group item is disabled.\n */\n disabled?: Signal<boolean>;\n}\n\nexport const [\n NgpToggleGroupItemToken,\n ngpToggleGroupItem,\n injectToggleGroupItemState,\n provideToggleGroupItemState,\n] = createPrimitive(\n 'NgpToggleGroupItem',\n <T = string>({\n value,\n disabled = signal(false),\n }: NgpToggleGroupItemProps<T>): NgpToggleGroupItemState => {\n const element = injectElementRef();\n const toggleGroup = injectToggleGroupState<T>();\n\n // Whether the item is selected.\n const selected = computed(() => toggleGroup()?.isSelected(value()!) ?? false);\n\n // Whether the item belongs to a multiple-select toggle group.\n const multiple = computed(() => toggleGroup()?.type() === 'multiple');\n\n // Host bindings\n // In a single-select group the items behave like radio buttons, while in a\n // multiple-select group they are independent toggle buttons exposing\n // aria-pressed, matching the standalone toggle primitive.\n attrBinding(element, 'role', () => (multiple() ? null : 'radio'));\n attrBinding(element, 'aria-checked', () => (multiple() ? null : selected()));\n attrBinding(element, 'aria-pressed', () => (multiple() ? selected() : null));\n dataBinding(element, 'data-selected', selected);\n attrBinding(element, 'aria-disabled', disabled);\n dataBinding(element, 'data-disabled', disabled);\n\n // Host listener\n listener(element, 'click', () => toggle());\n\n // Toggle the item.\n const toggle = (): void => {\n if (disabled?.()) {\n return;\n }\n toggleGroup()?.toggle(value()!);\n };\n\n return { selected, toggle } satisfies NgpToggleGroupItemState;\n },\n);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input, OnInit, Signal } from '@angular/core';\nimport { ngpRovingFocusItem, provideRovingFocusItemState } from 'ng-primitives/roving-focus';\nimport { ngpToggleGroupItem, provideToggleGroupItemState } from './toggle-group-item-state';\n\n@Directive({\n selector: '[ngpToggleGroupItem]',\n exportAs: 'ngpToggleGroupItem',\n providers: [provideToggleGroupItemState(), provideRovingFocusItemState()],\n})\nexport class NgpToggleGroupItem<T = string> implements OnInit {\n /**\n * The value of the item.\n * @required\n */\n readonly value = input<T>(undefined, {\n alias: 'ngpToggleGroupItemValue',\n });\n\n /**\n * Whether the item is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpToggleGroupItemDisabled',\n transform: booleanAttribute,\n });\n\n constructor() {\n ngpToggleGroupItem<T>({\n value: this.value as Signal<T>,\n disabled: this.disabled,\n });\n // Initialize the roving focus item state\n ngpRovingFocusItem({ disabled: this.disabled });\n }\n\n ngOnInit(): void {\n // we can't use a required input for value as it is used in a computed property before the input is set\n if (this.value() === undefined) {\n throw new Error('The value input is required for the toggle group item.');\n }\n }\n}\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input, output } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\nimport { provideRovingFocusGroupState } from 'ng-primitives/roving-focus';\nimport { SetterOptions } from 'ng-primitives/state';\nimport { injectToggleGroupConfig } from '../config/toggle-group-config';\nimport { ngpToggleGroup, provideToggleGroupState } from './toggle-group-state';\n\n@Directive({\n selector: '[ngpToggleGroup]',\n exportAs: 'ngpToggleGroup',\n providers: [provideToggleGroupState(), provideRovingFocusGroupState({ inherit: true })],\n})\nexport class NgpToggleGroup<T = string> {\n /**\n * Access the global toggle group configuration.\n */\n private readonly config = injectToggleGroupConfig();\n\n /**\n * The orientation of the toggle group.\n */\n readonly orientation = input<NgpOrientation>(this.config.orientation, {\n alias: 'ngpToggleGroupOrientation',\n });\n\n /**\n * Whether focus should wrap around when reaching the end of the toggle group.\n * @default true\n */\n readonly wrap = input<boolean, BooleanInput>(this.config.wrap, {\n alias: 'ngpToggleGroupWrap',\n transform: booleanAttribute,\n });\n\n /**\n * Whether toggle buttons can be deselected. If set to `false`, clicking a selected toggle button will not deselect it.\n * @default true\n */\n readonly allowDeselection = input<boolean, BooleanInput>(this.config.allowDeselection, {\n alias: 'ngpToggleGroupAllowDeselection',\n transform: booleanAttribute,\n });\n\n /**\n * The type of the toggle group, whether only one item can be selected or multiple.\n */\n readonly type = input<'single' | 'multiple'>(this.config.type, { alias: 'ngpToggleGroupType' });\n\n /**\n * The selected value(s) of the toggle group.\n */\n readonly value = input<T[] | undefined>(undefined, { alias: 'ngpToggleGroupValue' });\n\n /**\n * The default selected value(s) for uncontrolled usage.\n * @default []\n */\n readonly defaultValue = input<T[]>([], { alias: 'ngpToggleGroupDefaultValue' });\n\n /**\n * Emits when the value of the toggle group changes.\n */\n readonly valueChange = output<T[]>({ alias: 'ngpToggleGroupValueChange' });\n\n /**\n * The comparator used to determine whether two values are equal.\n * Useful when values are objects and equality should be checked by value rather than by reference.\n * @default (a, b) => a === b\n */\n readonly compareWith = input<(a: T, b: T) => boolean>((a, b) => a === b, {\n alias: 'ngpToggleGroupCompareWith',\n });\n\n /**\n * Whether the toggle group is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpToggleGroupDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * The state of the toggle group.\n */\n protected readonly state = ngpToggleGroup<T>({\n orientation: this.orientation,\n wrap: this.wrap,\n allowDeselection: this.allowDeselection,\n type: this.type,\n value: this.value,\n defaultValue: this.defaultValue,\n disabled: this.disabled,\n compareWith: this.compareWith,\n onValueChange: (value: T[]) => this.valueChange.emit(value),\n });\n\n /**\n * Toggle a value in the toggle group.\n */\n toggle(value: T): void {\n this.state.toggle(value);\n }\n\n /**\n * Set the value(s) of the toggle group.\n */\n setValue(newValue: T[], options?: SetterOptions): void {\n this.state.setValue(newValue, options);\n }\n\n /**\n * Set the default value(s) of the toggle group.\n */\n setDefaultValue(defaultValue: T[]): void {\n this.state.setDefaultValue(defaultValue);\n }\n\n /**\n * Set the disabled state of the toggle group.\n */\n setDisabled(isDisabled: boolean): void {\n this.state.setDisabled(isDisabled);\n }\n\n /**\n * Set the orientation of the toggle group.\n */\n setOrientation(newOrientation: NgpOrientation): void {\n this.state.setOrientation(newOrientation);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AA6BO,MAAM,wBAAwB,GAAyB;AAC5D,IAAA,WAAW,EAAE,YAAY;AACzB,IAAA,IAAI,EAAE,QAAQ;AACd,IAAA,gBAAgB,EAAE,IAAI;AACtB,IAAA,IAAI,EAAE,IAAI;CACX;AAEM,MAAM,yBAAyB,GAAG,IAAI,cAAc,CACzD,2BAA2B,CAC5B;AAED;;;;AAIG;AACG,SAAU,wBAAwB,CAAC,MAAqC,EAAA;IAC5E,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,yBAAyB;AAClC,YAAA,QAAQ,EAAE,EAAE,GAAG,wBAAwB,EAAE,GAAG,MAAM,EAAE;AACrD,SAAA;KACF;AACH;AAEA;;;AAGG;SACa,uBAAuB,GAAA;AACrC,IAAA,OAAO,MAAM,CAAC,yBAAyB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,wBAAwB;AAC1F;;ACqEO,MAAM,CACX,wBAAwB,EACxB,cAAc,EACd,uBAAuB,EACvB,uBAAuB,EACxB,GAAG,eAAe,CACjB,gBAAgB,EAChB,CAAa,EACX,WAAW,EAAE,YAAY,EACzB,IAAI,EAAE,KAAK,EACX,gBAAgB,EAAE,iBAAiB,EACnC,IAAI,EAAE,KAAK,EACX,KAAK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IAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,WAAA,EAAA,2BAAA,EAAA,EAAA,SAAA,EAFd,CAAC,uBAAuB,EAAE,EAAE,4BAA4B,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAA,QAAA,EAAA,CAAA,gBAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAE5E,cAAc,EAAA,UAAA,EAAA,CAAA;kBAL1B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,kBAAkB;AAC5B,oBAAA,QAAQ,EAAE,gBAAgB;AAC1B,oBAAA,SAAS,EAAE,CAAC,uBAAuB,EAAE,EAAE,4BAA4B,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AACxF,iBAAA;;;ACZD;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "ng-primitives",
|
|
3
3
|
"description": "Angular Primitives is a low-level headless UI component library with a focus on accessibility, customization, and developer experience. ",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.125.0",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"angular",
|
|
8
8
|
"primitives",
|
|
@@ -45,6 +45,9 @@
|
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"luxon": {
|
|
47
47
|
"optional": true
|
|
48
|
+
},
|
|
49
|
+
"date-fns": {
|
|
50
|
+
"optional": true
|
|
48
51
|
}
|
|
49
52
|
},
|
|
50
53
|
"ng-add": {
|
|
@@ -116,6 +119,10 @@
|
|
|
116
119
|
"types": "./types/ng-primitives-date-time.d.ts",
|
|
117
120
|
"default": "./fesm2022/ng-primitives-date-time.mjs"
|
|
118
121
|
},
|
|
122
|
+
"./date-time-date-fns": {
|
|
123
|
+
"types": "./types/ng-primitives-date-time-date-fns.d.ts",
|
|
124
|
+
"default": "./fesm2022/ng-primitives-date-time-date-fns.mjs"
|
|
125
|
+
},
|
|
119
126
|
"./date-time-luxon": {
|
|
120
127
|
"types": "./types/ng-primitives-date-time-luxon.d.ts",
|
|
121
128
|
"default": "./fesm2022/ng-primitives-date-time-luxon.mjs"
|
package/schematics/ng-generate/templates/checkbox/checkbox.__fileSuffix@dasherize__.ts.template
CHANGED
|
@@ -94,7 +94,8 @@ export class Checkbox<%= componentSuffix %> implements ControlValueAccessor {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
writeValue(checked: boolean): void {
|
|
97
|
-
|
|
97
|
+
// writing a value from the model must not re-emit through onChange
|
|
98
|
+
this.state().setChecked(checked, { emit: false });
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
registerOnChange(fn: ChangeFn<boolean>): void {
|
package/schematics/ng-generate/templates/combobox/combobox.__fileSuffix@dasherize__.ts.template
CHANGED
|
@@ -215,7 +215,7 @@ export class Combobox<%= componentSuffix %> implements ControlValueAccessor {
|
|
|
215
215
|
protected readonly formDisabled = signal(false);
|
|
216
216
|
|
|
217
217
|
/** The on change callback */
|
|
218
|
-
private onChange?: ChangeFn<string>;
|
|
218
|
+
private onChange?: ChangeFn<string | undefined>;
|
|
219
219
|
|
|
220
220
|
/** The on touch callback */
|
|
221
221
|
protected onTouched?: TouchedFn;
|
|
@@ -254,9 +254,10 @@ export class Combobox<%= componentSuffix %> implements ControlValueAccessor {
|
|
|
254
254
|
return;
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
// if the filter value is empty,
|
|
257
|
+
// if the filter value is empty, clear the value and notify the form control
|
|
258
258
|
if (this.filter() === '') {
|
|
259
259
|
this.value.set(undefined);
|
|
260
|
+
this.onChange?.(undefined);
|
|
260
261
|
} else {
|
|
261
262
|
// otherwise set the filter value to the selected value
|
|
262
263
|
this.filter.set(this.value() ?? '');
|
|
@@ -228,7 +228,8 @@ export class DatePicker<%= componentSuffix %> implements ControlValueAccessor {
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
writeValue(date: Date): void {
|
|
231
|
-
|
|
231
|
+
// writing a value from the model must not re-emit through onChange
|
|
232
|
+
this.state().select(date, false, { emit: false });
|
|
232
233
|
}
|
|
233
234
|
|
|
234
235
|
registerOnChange(fn: ChangeFn<Date | undefined>): void {
|
package/schematics/ng-generate/templates/listbox/listbox.__fileSuffix@dasherize__.ts.template
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BooleanInput } from '@angular/cdk/coercion';
|
|
2
|
-
import { booleanAttribute, Component, input, model } from '@angular/core';
|
|
2
|
+
import { booleanAttribute, Component, input, model, signal } from '@angular/core';
|
|
3
3
|
import { ControlValueAccessor } from '@angular/forms';
|
|
4
4
|
import { provideIcons } from '@ng-icons/core';
|
|
5
5
|
import { heroChevronDownSolid } from '@ng-icons/heroicons/solid';
|
|
@@ -19,7 +19,7 @@ import { ChangeFn, provideValueAccessor, TouchedFn } from 'ng-primitives/utils';
|
|
|
19
19
|
<div
|
|
20
20
|
[(ngpListboxValue)]="value"
|
|
21
21
|
[ngpListboxMode]="mode()"
|
|
22
|
-
[ngpListboxDisabled]="disabled()"
|
|
22
|
+
[ngpListboxDisabled]="disabled() || formDisabled()"
|
|
23
23
|
[ngpListboxCompareWith]="compareWith()"
|
|
24
24
|
[attr.aria-label]="ariaLabel()"
|
|
25
25
|
(ngpListboxValueChange)="onListboxValueChange($event)"
|
|
@@ -43,6 +43,7 @@ import { ChangeFn, provideValueAccessor, TouchedFn } from 'ng-primitives/utils';
|
|
|
43
43
|
`,
|
|
44
44
|
host: {
|
|
45
45
|
'[attr.aria-label]': 'null',
|
|
46
|
+
'(focusout)': 'onTouch?.()',
|
|
46
47
|
},
|
|
47
48
|
})
|
|
48
49
|
export class Listbox<%= componentSuffix %> implements ControlValueAccessor {
|
|
@@ -95,8 +96,12 @@ export class Listbox<%= componentSuffix %> implements ControlValueAccessor {
|
|
|
95
96
|
*/
|
|
96
97
|
protected onTouch?: TouchedFn;
|
|
97
98
|
|
|
99
|
+
/** Form-driven disabled state, combined with the `disabled` input. */
|
|
100
|
+
protected readonly formDisabled = signal(false);
|
|
101
|
+
|
|
98
102
|
writeValue(value: string[]): void {
|
|
99
|
-
|
|
103
|
+
// drive the value through the bound model so the controlled input reflects it
|
|
104
|
+
this.value.set(value);
|
|
100
105
|
}
|
|
101
106
|
|
|
102
107
|
registerOnChange(fn: ChangeFn<string[]>): void {
|
|
@@ -108,7 +113,7 @@ export class Listbox<%= componentSuffix %> implements ControlValueAccessor {
|
|
|
108
113
|
}
|
|
109
114
|
|
|
110
115
|
setDisabledState(isDisabled: boolean): void {
|
|
111
|
-
this.
|
|
116
|
+
this.formDisabled.set(isDisabled);
|
|
112
117
|
}
|
|
113
118
|
|
|
114
119
|
onListboxValueChange(value: string[]): void {
|
package/schematics/ng-generate/templates/pagination/pagination.__fileSuffix@dasherize__.ts.template
CHANGED
|
@@ -168,7 +168,8 @@ export class Pagination<%= componentSuffix %> implements ControlValueAccessor {
|
|
|
168
168
|
|
|
169
169
|
/** Write a new value to the control */
|
|
170
170
|
writeValue(value: number): void {
|
|
171
|
-
|
|
171
|
+
// writing a value from the model must not re-emit through onChange
|
|
172
|
+
this.state().setPage(value, { emit: false });
|
|
172
173
|
}
|
|
173
174
|
|
|
174
175
|
/** Register a callback to be called when the value changes */
|
|
@@ -180,4 +181,9 @@ export class Pagination<%= componentSuffix %> implements ControlValueAccessor {
|
|
|
180
181
|
registerOnTouched(fn: TouchedFn): void {
|
|
181
182
|
this.onTouched = fn;
|
|
182
183
|
}
|
|
184
|
+
|
|
185
|
+
/** Reflect the form control's disabled state onto the pagination. */
|
|
186
|
+
setDisabledState(isDisabled: boolean): void {
|
|
187
|
+
this.state().setDisabled(isDisabled);
|
|
188
|
+
}
|
|
183
189
|
}
|
|
@@ -118,9 +118,10 @@ export class RangeSlider<%= componentSuffix %> implements ControlValueAccessor {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
const [low, high] = value;
|
|
121
|
-
// Use the directive's clamping setters to respect min/max and ordering
|
|
122
|
-
|
|
123
|
-
this.state().
|
|
121
|
+
// Use the directive's clamping setters to respect min/max and ordering.
|
|
122
|
+
// writing a value from the model must not re-emit through onChange
|
|
123
|
+
this.state().setLowValue(low, { emit: false });
|
|
124
|
+
this.state().setHighValue(high, { emit: false });
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
registerOnChange(fn: ChangeFn<[number, number]>): void {
|
|
@@ -108,7 +108,8 @@ export class Slider<%= componentSuffix %> implements ControlValueAccessor {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
writeValue(value: number): void {
|
|
111
|
-
|
|
111
|
+
// writing a value from the model must not re-emit through onChange
|
|
112
|
+
this.state().setValue(value, { emit: false });
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
registerOnChange(fn: ChangeFn<number>): void {
|
|
@@ -88,7 +88,8 @@ export class Switch<%= componentSuffix %> implements ControlValueAccessor {
|
|
|
88
88
|
|
|
89
89
|
/** Write a new value to the switch. */
|
|
90
90
|
writeValue(value: boolean): void {
|
|
91
|
-
|
|
91
|
+
// writing a value from the model must not re-emit through onChange
|
|
92
|
+
this.switch().setChecked(value, { emit: false });
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
/** Register a callback function to be called when the value changes. */
|
|
@@ -142,6 +142,10 @@ interface NgpCheckboxProps {
|
|
|
142
142
|
* Whether the checkbox is disabled.
|
|
143
143
|
*/
|
|
144
144
|
readonly disabled?: Signal<boolean>;
|
|
145
|
+
/**
|
|
146
|
+
* Whether the checkbox is required.
|
|
147
|
+
*/
|
|
148
|
+
readonly required?: Signal<boolean>;
|
|
145
149
|
/**
|
|
146
150
|
* Callback fired when the checked state changes.
|
|
147
151
|
*/
|
|
@@ -151,7 +155,7 @@ interface NgpCheckboxProps {
|
|
|
151
155
|
*/
|
|
152
156
|
readonly onIndeterminateChange?: (indeterminate: boolean) => void;
|
|
153
157
|
}
|
|
154
|
-
declare const ngpCheckbox: ({ id, checked: _checked, defaultChecked: _defaultChecked, indeterminate: _indeterminate, disabled: _disabled, onCheckedChange, onIndeterminateChange, }: NgpCheckboxProps) => NgpCheckboxState;
|
|
158
|
+
declare const ngpCheckbox: ({ id, checked: _checked, defaultChecked: _defaultChecked, indeterminate: _indeterminate, disabled: _disabled, required: _required, onCheckedChange, onIndeterminateChange, }: NgpCheckboxProps) => NgpCheckboxState;
|
|
155
159
|
declare const injectCheckboxState: {
|
|
156
160
|
(): Signal<NgpCheckboxState>;
|
|
157
161
|
(options: ng_primitives_state.StateInjectionOptions): Signal<NgpCheckboxState | null>;
|
|
@@ -106,18 +106,12 @@ declare function injectDatePickerCellDate<T>(): T;
|
|
|
106
106
|
* A cell in the date picker grid.
|
|
107
107
|
*/
|
|
108
108
|
declare class NgpDatePickerCell {
|
|
109
|
-
/**
|
|
110
|
-
* Access the date picker.
|
|
111
|
-
*/
|
|
112
|
-
private readonly state;
|
|
113
109
|
/**
|
|
114
110
|
* Access the child date picker date button.
|
|
111
|
+
* The cell's accessible name comes from this button's day content, not the
|
|
112
|
+
* shared month/year label (which would make every cell announce the month).
|
|
115
113
|
*/
|
|
116
114
|
protected readonly datePickerButton: _angular_core.Signal<ng_primitives_date_picker.NgpDatePickerDateButton<unknown> | undefined>;
|
|
117
|
-
/**
|
|
118
|
-
* Access the label id.
|
|
119
|
-
*/
|
|
120
|
-
protected readonly labelId: _angular_core.Signal<string | undefined>;
|
|
121
115
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpDatePickerCell, never>;
|
|
122
116
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgpDatePickerCell, "[ngpDatePickerCell]", ["ngpDatePickerCell"], {}, {}, ["datePickerButton"], never, true, never>;
|
|
123
117
|
}
|
|
@@ -521,9 +515,13 @@ declare class NgpDatePicker<T> {
|
|
|
521
515
|
* Select a date.
|
|
522
516
|
* @param date The date to select.
|
|
523
517
|
* @param preserveTime Whether to preserve time components from existing selected date.
|
|
518
|
+
* @param options Options for the selection. Set `emit` to false to update the state without
|
|
519
|
+
* emitting `dateChange` (e.g. when writing a value from a form model).
|
|
524
520
|
* @internal
|
|
525
521
|
*/
|
|
526
|
-
select(date: T, preserveTime?: boolean
|
|
522
|
+
select(date: T, preserveTime?: boolean, options?: {
|
|
523
|
+
emit?: boolean;
|
|
524
|
+
}): void;
|
|
527
525
|
/**
|
|
528
526
|
* Determine if a date is selected.
|
|
529
527
|
* @param date The date to check.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { NgpDateAdapter, NgpDateUnits, NgpDuration } from 'ng-primitives/date-time';
|
|
2
|
+
|
|
3
|
+
declare class NgpDateFnsDateAdapter implements NgpDateAdapter<Date> {
|
|
4
|
+
create({ day, hour, minute, month, second, year, millisecond }: NgpDateUnits): Date;
|
|
5
|
+
now(): Date;
|
|
6
|
+
set(date: Date, values: NgpDateUnits): Date;
|
|
7
|
+
add(date: Date, duration: NgpDuration): Date;
|
|
8
|
+
subtract(date: Date, duration: NgpDuration): Date;
|
|
9
|
+
compare(a: Date, b: Date): number;
|
|
10
|
+
isEqual(a: Date, b: Date): boolean;
|
|
11
|
+
isBefore(a: Date, b: Date): boolean;
|
|
12
|
+
isAfter(a: Date, b: Date): boolean;
|
|
13
|
+
isSameDay(a: Date, b: Date): boolean;
|
|
14
|
+
isSameMonth(a: Date, b: Date): boolean;
|
|
15
|
+
isSameYear(a: Date, b: Date): boolean;
|
|
16
|
+
getYear(date: Date): number;
|
|
17
|
+
getMonth(date: Date): number;
|
|
18
|
+
getDate(date: Date): number;
|
|
19
|
+
getDay(date: Date): number;
|
|
20
|
+
getHours(date: Date): number;
|
|
21
|
+
getMinutes(date: Date): number;
|
|
22
|
+
getSeconds(date: Date): number;
|
|
23
|
+
getMilliseconds(date: Date): number;
|
|
24
|
+
startOfMonth(date: Date): Date;
|
|
25
|
+
endOfMonth(date: Date): Date;
|
|
26
|
+
startOfDay(date: Date): Date;
|
|
27
|
+
endOfDay(date: Date): Date;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { NgpDateFnsDateAdapter };
|
|
@@ -6,7 +6,9 @@ import { Type, ClassProvider } from '@angular/core';
|
|
|
6
6
|
*/
|
|
7
7
|
interface NgpDateAdapter<T> {
|
|
8
8
|
/**
|
|
9
|
-
* Create a new date time object.
|
|
9
|
+
* Create a new date time object. Here `month` is one-based (1-12), matching
|
|
10
|
+
* the `NgpDateUnits` documentation. Note this differs from `set` and
|
|
11
|
+
* `getMonth`, which use a zero-based month (0-11).
|
|
10
12
|
*/
|
|
11
13
|
create(values: NgpDateUnits): T;
|
|
12
14
|
/**
|
|
@@ -14,7 +16,10 @@ interface NgpDateAdapter<T> {
|
|
|
14
16
|
*/
|
|
15
17
|
now(): T;
|
|
16
18
|
/**
|
|
17
|
-
* Set the
|
|
19
|
+
* Set the specified units on the date time object, leaving the rest
|
|
20
|
+
* unchanged. Here `month` is zero-based (0-11), matching `getMonth` so
|
|
21
|
+
* `set(date, { month: getMonth(other) })` round-trips. Note this differs from
|
|
22
|
+
* `create`, which takes a one-based month (1-12).
|
|
18
23
|
*/
|
|
19
24
|
set(date: T, values: NgpDateUnits): T;
|
|
20
25
|
/**
|
|
@@ -58,7 +63,8 @@ interface NgpDateAdapter<T> {
|
|
|
58
63
|
*/
|
|
59
64
|
getYear(date: T): number;
|
|
60
65
|
/**
|
|
61
|
-
* Get the month.
|
|
66
|
+
* Get the month as a zero-based number (0-11, January = 0). This matches the
|
|
67
|
+
* range accepted by `set`, so `set(date, { month: getMonth(other) })` round-trips.
|
|
62
68
|
*/
|
|
63
69
|
getMonth(date: T): number;
|
|
64
70
|
/**
|
|
@@ -200,6 +206,12 @@ declare class NgpNativeDateAdapter implements NgpDateAdapter<Date> {
|
|
|
200
206
|
* Subtract a duration from the date time object
|
|
201
207
|
*/
|
|
202
208
|
subtract(date: Date, duration: NgpDuration): Date;
|
|
209
|
+
/**
|
|
210
|
+
* Apply a duration in `sign` direction. Year/month are applied first with the
|
|
211
|
+
* day clamped to the target month's length (so 31 Jan + 1 month is 28 Feb, not
|
|
212
|
+
* 3 Mar), matching the Luxon and date-fns adapters; day/time deltas follow.
|
|
213
|
+
*/
|
|
214
|
+
private shift;
|
|
203
215
|
/**
|
|
204
216
|
* Compare two date time objects
|
|
205
217
|
*/
|
|
@@ -321,6 +321,10 @@ declare class NgpDialog<T = unknown, R = unknown> implements OnDestroy {
|
|
|
321
321
|
protected readonly labelledBy: _angular_core.WritableSignal<string[]>;
|
|
322
322
|
/** The describedby ids */
|
|
323
323
|
protected readonly describedBy: _angular_core.WritableSignal<string[]>;
|
|
324
|
+
/** The aria-labelledby value, omitted when there are no ids to reference. */
|
|
325
|
+
protected readonly ariaLabelledBy: _angular_core.Signal<string | null>;
|
|
326
|
+
/** The aria-describedby value, omitted when there are no ids to reference. */
|
|
327
|
+
protected readonly ariaDescribedBy: _angular_core.Signal<string | null>;
|
|
324
328
|
/** The dialog state */
|
|
325
329
|
protected readonly state: ng_primitives_state.CreatedState<NgpDialog<T, R>>;
|
|
326
330
|
ngOnDestroy(): void;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as ng_primitives_state from 'ng-primitives/state';
|
|
2
2
|
import * as ng_primitives_input_otp from 'ng-primitives/input-otp';
|
|
3
3
|
import * as _angular_core from '@angular/core';
|
|
4
|
-
import {
|
|
4
|
+
import { OnDestroy } from '@angular/core';
|
|
5
5
|
import * as i1 from 'ng-primitives/a11y';
|
|
6
6
|
import { BooleanInput } from '@angular/cdk/coercion';
|
|
7
7
|
|
|
8
|
-
declare class NgpInputOtpInput
|
|
8
|
+
declare class NgpInputOtpInput {
|
|
9
9
|
/**
|
|
10
10
|
* Access the element reference.
|
|
11
11
|
*/
|
|
@@ -15,7 +15,6 @@ declare class NgpInputOtpInput implements AfterViewInit {
|
|
|
15
15
|
*/
|
|
16
16
|
protected readonly state: _angular_core.Signal<ng_primitives_state.State<ng_primitives_input_otp.NgpInputOtp>>;
|
|
17
17
|
constructor();
|
|
18
|
-
ngAfterViewInit(): void;
|
|
19
18
|
/**
|
|
20
19
|
* Focus the input.
|
|
21
20
|
* @internal
|
|
@@ -115,9 +114,10 @@ declare class NgpInputOtp {
|
|
|
115
114
|
*/
|
|
116
115
|
readonly id: _angular_core.InputSignal<string>;
|
|
117
116
|
/**
|
|
118
|
-
* The current value of the OTP.
|
|
117
|
+
* The current value of the OTP. A null/undefined value (e.g. from a form
|
|
118
|
+
* `writeValue(null)` or `reset()`) is coerced to an empty string.
|
|
119
119
|
*/
|
|
120
|
-
readonly value: _angular_core.
|
|
120
|
+
readonly value: _angular_core.InputSignalWithTransform<string, string | null | undefined>;
|
|
121
121
|
/**
|
|
122
122
|
* The regex pattern for allowed characters.
|
|
123
123
|
*/
|