ng-primitives 0.0.7 → 0.2.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.
Files changed (211) hide show
  1. package/README.md +14 -4
  2. package/accordion/accordion-trigger/accordion-trigger.directive.d.ts +2 -1
  3. package/autofill/README.md +3 -0
  4. package/autofill/autofill/autofill.directive.d.ts +19 -0
  5. package/{select/select-button/select-button.token.d.ts → autofill/autofill/autofill.token.d.ts} +4 -4
  6. package/autofill/index.d.ts +9 -0
  7. package/avatar/avatar/avatar.directive.d.ts +2 -1
  8. package/button/README.md +3 -0
  9. package/button/button/button.directive.d.ts +27 -0
  10. package/{select/select-option/select-option.token.d.ts → button/button/button.token.d.ts} +4 -4
  11. package/button/index.d.ts +9 -0
  12. package/checkbox/checkbox/checkbox.directive.d.ts +11 -61
  13. package/checkbox/index.d.ts +0 -4
  14. package/esm2022/a11y/visually-hidden/visually-hidden.directive.mjs +3 -3
  15. package/esm2022/accordion/accordion/accordion.directive.mjs +5 -4
  16. package/esm2022/accordion/accordion-content/accordion-content.directive.mjs +5 -6
  17. package/esm2022/accordion/accordion-item/accordion-item.directive.mjs +5 -5
  18. package/esm2022/accordion/accordion-trigger/accordion-trigger.directive.mjs +8 -5
  19. package/esm2022/autofill/autofill/autofill.directive.mjs +71 -0
  20. package/esm2022/autofill/autofill/autofill.token.mjs +16 -0
  21. package/esm2022/autofill/index.mjs +10 -0
  22. package/esm2022/autofill/ng-primitives-autofill.mjs +5 -0
  23. package/esm2022/avatar/avatar/avatar.directive.mjs +7 -4
  24. package/esm2022/avatar/avatar-fallback/avatar-fallback.directive.mjs +3 -3
  25. package/esm2022/avatar/avatar-image/avatar-image.directive.mjs +3 -3
  26. package/esm2022/button/button/button.directive.mjs +47 -0
  27. package/esm2022/button/button/button.token.mjs +16 -0
  28. package/esm2022/button/index.mjs +10 -0
  29. package/esm2022/button/ng-primitives-button.mjs +5 -0
  30. package/esm2022/checkbox/checkbox/checkbox.directive.mjs +29 -79
  31. package/esm2022/checkbox/index.mjs +1 -5
  32. package/esm2022/file-upload/file-upload/file-upload.directive.mjs +7 -4
  33. package/esm2022/focus-trap/focus-trap/focus-trap.directive.mjs +262 -0
  34. package/esm2022/focus-trap/focus-trap/focus-trap.token.mjs +16 -0
  35. package/esm2022/focus-trap/index.mjs +10 -0
  36. package/esm2022/focus-trap/ng-primitives-focus-trap.mjs +5 -0
  37. package/esm2022/form-field/description/description.directive.mjs +14 -14
  38. package/esm2022/form-field/error/error.directive.mjs +27 -29
  39. package/esm2022/form-field/form-control/form-control.directive.mjs +22 -16
  40. package/esm2022/form-field/form-field/form-field.directive.mjs +3 -3
  41. package/esm2022/form-field/form-field/form-field.token.mjs +3 -7
  42. package/esm2022/form-field/label/label.directive.mjs +56 -17
  43. package/esm2022/input/index.mjs +10 -0
  44. package/esm2022/input/input/input.directive.mjs +55 -0
  45. package/esm2022/input/input/input.token.mjs +16 -0
  46. package/esm2022/input/ng-primitives-input.mjs +5 -0
  47. package/esm2022/interactions/focus/focus.directive.mjs +15 -10
  48. package/esm2022/interactions/focus-visible/focus-visible.directive.mjs +12 -7
  49. package/esm2022/interactions/hover/hover.directive.mjs +16 -11
  50. package/esm2022/interactions/index.mjs +5 -1
  51. package/esm2022/interactions/move/move.directive.mjs +216 -0
  52. package/esm2022/interactions/move/move.token.mjs +16 -0
  53. package/esm2022/interactions/press/press.directive.mjs +118 -0
  54. package/esm2022/interactions/press/press.token.mjs +16 -0
  55. package/esm2022/internal/disabled/disabled.mjs +19 -0
  56. package/esm2022/internal/index.mjs +11 -0
  57. package/esm2022/internal/ng-primitives-internal.mjs +5 -0
  58. package/esm2022/internal/orientation/orientation.mjs +19 -0
  59. package/esm2022/internal/style-injector/style-injector.mjs +81 -0
  60. package/esm2022/progress/progress/progress.directive.mjs +3 -3
  61. package/esm2022/progress/progress-indicator/progress-indicator.directive.mjs +3 -3
  62. package/esm2022/radio/radio-group/radio-group.directive.mjs +14 -54
  63. package/esm2022/radio/radio-indicator/radio-indicator.directive.mjs +8 -5
  64. package/esm2022/radio/radio-item/radio-item.directive.mjs +8 -6
  65. package/esm2022/resize/resize/resize.directive.mjs +3 -3
  66. package/esm2022/roving-focus/roving-focus-group/roving-focus-group.directive.mjs +14 -9
  67. package/esm2022/roving-focus/roving-focus-item/roving-focus-item.directive.mjs +3 -3
  68. package/esm2022/search/index.mjs +10 -0
  69. package/esm2022/search/ng-primitives-search.mjs +5 -0
  70. package/esm2022/search/search-field/search-field.directive.mjs +47 -0
  71. package/esm2022/search/search-field/search-field.token.mjs +16 -0
  72. package/esm2022/select/index.mjs +1 -7
  73. package/esm2022/select/select/select.directive.mjs +23 -36
  74. package/esm2022/select/select/select.token.mjs +1 -1
  75. package/esm2022/slider/slider/slider.directive.mjs +18 -5
  76. package/esm2022/slider/slider-range/slider-range.directive.mjs +6 -5
  77. package/esm2022/slider/slider-thumb/slider-thumb.directive.mjs +7 -4
  78. package/esm2022/slider/slider-track/slider-track.directive.mjs +8 -4
  79. package/esm2022/switch/switch/switch.directive.mjs +18 -58
  80. package/esm2022/switch/switch-thumb/switch-thumb.directive.mjs +9 -6
  81. package/esm2022/tabs/tab-button/tab-button.directive.mjs +8 -6
  82. package/esm2022/tabs/tab-list/tab-list.directive.mjs +3 -3
  83. package/esm2022/tabs/tab-panel/tab-panel.directive.mjs +5 -6
  84. package/esm2022/tabs/tabset/tabset.directive.mjs +14 -18
  85. package/esm2022/textarea/index.mjs +10 -0
  86. package/esm2022/textarea/ng-primitives-textarea.mjs +5 -0
  87. package/esm2022/textarea/textarea/textarea.directive.mjs +37 -0
  88. package/esm2022/textarea/textarea/textarea.token.mjs +16 -0
  89. package/esm2022/toggle/toggle/toggle.directive.mjs +33 -13
  90. package/esm2022/tooltip/tooltip/tooltip.directive.mjs +3 -3
  91. package/esm2022/tooltip/tooltip-trigger/tooltip-trigger.directive.mjs +7 -7
  92. package/esm2022/utils/helpers/focus-manager.mjs +3 -3
  93. package/esm2022/utils/index.mjs +2 -2
  94. package/esm2022/utils/signals/async.mjs +11 -17
  95. package/fesm2022/ng-primitives-a11y.mjs +3 -3
  96. package/fesm2022/ng-primitives-accordion.mjs +19 -16
  97. package/fesm2022/ng-primitives-accordion.mjs.map +1 -1
  98. package/fesm2022/ng-primitives-autofill.mjs +100 -0
  99. package/fesm2022/ng-primitives-autofill.mjs.map +1 -0
  100. package/fesm2022/ng-primitives-avatar.mjs +13 -10
  101. package/fesm2022/ng-primitives-avatar.mjs.map +1 -1
  102. package/fesm2022/ng-primitives-button.mjs +76 -0
  103. package/fesm2022/ng-primitives-button.mjs.map +1 -0
  104. package/fesm2022/ng-primitives-checkbox.mjs +25 -203
  105. package/fesm2022/ng-primitives-checkbox.mjs.map +1 -1
  106. package/fesm2022/ng-primitives-file-upload.mjs +6 -3
  107. package/fesm2022/ng-primitives-file-upload.mjs.map +1 -1
  108. package/fesm2022/ng-primitives-focus-trap.mjs +291 -0
  109. package/fesm2022/ng-primitives-focus-trap.mjs.map +1 -0
  110. package/fesm2022/ng-primitives-form-field.mjs +119 -80
  111. package/fesm2022/ng-primitives-form-field.mjs.map +1 -1
  112. package/fesm2022/ng-primitives-input.mjs +84 -0
  113. package/fesm2022/ng-primitives-input.mjs.map +1 -0
  114. package/fesm2022/ng-primitives-interactions.mjs +394 -26
  115. package/fesm2022/ng-primitives-interactions.mjs.map +1 -1
  116. package/fesm2022/ng-primitives-internal.mjs +132 -0
  117. package/fesm2022/ng-primitives-internal.mjs.map +1 -0
  118. package/fesm2022/ng-primitives-progress.mjs +6 -6
  119. package/fesm2022/ng-primitives-radio.mjs +25 -62
  120. package/fesm2022/ng-primitives-radio.mjs.map +1 -1
  121. package/fesm2022/ng-primitives-resize.mjs +3 -3
  122. package/fesm2022/ng-primitives-roving-focus.mjs +15 -10
  123. package/fesm2022/ng-primitives-roving-focus.mjs.map +1 -1
  124. package/fesm2022/ng-primitives-search.mjs +76 -0
  125. package/fesm2022/ng-primitives-search.mjs.map +1 -0
  126. package/fesm2022/ng-primitives-select.mjs +23 -395
  127. package/fesm2022/ng-primitives-select.mjs.map +1 -1
  128. package/fesm2022/ng-primitives-slider.mjs +35 -14
  129. package/fesm2022/ng-primitives-slider.mjs.map +1 -1
  130. package/fesm2022/ng-primitives-switch.mjs +23 -62
  131. package/fesm2022/ng-primitives-switch.mjs.map +1 -1
  132. package/fesm2022/ng-primitives-tabs.mjs +27 -30
  133. package/fesm2022/ng-primitives-tabs.mjs.map +1 -1
  134. package/fesm2022/ng-primitives-textarea.mjs +66 -0
  135. package/fesm2022/ng-primitives-textarea.mjs.map +1 -0
  136. package/fesm2022/ng-primitives-toggle.mjs +32 -12
  137. package/fesm2022/ng-primitives-toggle.mjs.map +1 -1
  138. package/fesm2022/ng-primitives-tooltip.mjs +9 -9
  139. package/fesm2022/ng-primitives-tooltip.mjs.map +1 -1
  140. package/fesm2022/ng-primitives-utils.mjs +14 -20
  141. package/fesm2022/ng-primitives-utils.mjs.map +1 -1
  142. package/file-upload/file-upload/file-upload.directive.d.ts +2 -1
  143. package/focus-trap/README.md +3 -0
  144. package/focus-trap/focus-trap/focus-trap.directive.d.ts +64 -0
  145. package/{select/select-options/select-options.token.d.ts → focus-trap/focus-trap/focus-trap.token.d.ts} +4 -4
  146. package/focus-trap/index.d.ts +9 -0
  147. package/form-field/description/description.directive.d.ts +1 -1
  148. package/form-field/error/error.directive.d.ts +9 -5
  149. package/form-field/form-control/form-control.directive.d.ts +7 -3
  150. package/form-field/form-field/form-field.token.d.ts +1 -1
  151. package/form-field/label/label.directive.d.ts +3 -2
  152. package/input/README.md +3 -0
  153. package/input/index.d.ts +9 -0
  154. package/input/input/input.directive.d.ts +33 -0
  155. package/input/input/input.token.d.ts +14 -0
  156. package/interactions/focus/focus.directive.d.ts +6 -2
  157. package/interactions/focus-visible/focus-visible.directive.d.ts +5 -1
  158. package/interactions/hover/hover.directive.d.ts +5 -1
  159. package/interactions/index.d.ts +4 -0
  160. package/interactions/move/move.directive.d.ts +126 -0
  161. package/interactions/move/move.token.d.ts +14 -0
  162. package/interactions/press/press.directive.d.ts +59 -0
  163. package/interactions/press/press.token.d.ts +14 -0
  164. package/internal/README.md +3 -0
  165. package/internal/disabled/disabled.d.ts +21 -0
  166. package/internal/index.d.ts +10 -0
  167. package/internal/orientation/orientation.d.ts +22 -0
  168. package/internal/style-injector/style-injector.d.ts +36 -0
  169. package/package.json +49 -7
  170. package/radio/radio-group/radio-group.directive.d.ts +4 -41
  171. package/radio/radio-indicator/radio-indicator.directive.d.ts +2 -1
  172. package/radio/radio-item/radio-item.directive.d.ts +2 -1
  173. package/roving-focus/roving-focus-group/roving-focus-group.directive.d.ts +7 -2
  174. package/search/README.md +3 -0
  175. package/search/index.d.ts +9 -0
  176. package/search/search-field/search-field.directive.d.ts +15 -0
  177. package/search/search-field/search-field.token.d.ts +14 -0
  178. package/select/index.d.ts +0 -6
  179. package/select/select/select.directive.d.ts +7 -22
  180. package/select/select/select.token.d.ts +2 -2
  181. package/slider/slider/slider.directive.d.ts +4 -2
  182. package/slider/slider-thumb/slider-thumb.directive.d.ts +2 -1
  183. package/slider/slider-track/slider-track.directive.d.ts +1 -1
  184. package/switch/switch/switch.directive.d.ts +5 -45
  185. package/switch/switch-thumb/switch-thumb.directive.d.ts +2 -1
  186. package/tabs/tab-button/tab-button.directive.d.ts +2 -1
  187. package/tabs/tabset/tabset.directive.d.ts +3 -9
  188. package/textarea/README.md +3 -0
  189. package/textarea/index.d.ts +9 -0
  190. package/textarea/textarea/textarea.directive.d.ts +20 -0
  191. package/textarea/textarea/textarea.token.d.ts +14 -0
  192. package/toggle/toggle/toggle.directive.d.ts +16 -4
  193. package/utils/index.d.ts +1 -1
  194. package/utils/signals/async.d.ts +10 -12
  195. package/checkbox/checkbox-indicator/checkbox-indicator.directive.d.ts +0 -19
  196. package/checkbox/checkbox-indicator/checkbox-indicator.token.d.ts +0 -15
  197. package/checkbox/checkbox-input/checkbox-input.directive.d.ts +0 -10
  198. package/checkbox/checkbox-label/checkbox-label.directive.d.ts +0 -9
  199. package/esm2022/checkbox/checkbox-indicator/checkbox-indicator.directive.mjs +0 -51
  200. package/esm2022/checkbox/checkbox-indicator/checkbox-indicator.token.mjs +0 -17
  201. package/esm2022/checkbox/checkbox-input/checkbox-input.directive.mjs +0 -40
  202. package/esm2022/checkbox/checkbox-label/checkbox-label.directive.mjs +0 -32
  203. package/esm2022/select/select-button/select-button.directive.mjs +0 -84
  204. package/esm2022/select/select-button/select-button.token.mjs +0 -16
  205. package/esm2022/select/select-option/select-option.directive.mjs +0 -90
  206. package/esm2022/select/select-option/select-option.token.mjs +0 -16
  207. package/esm2022/select/select-options/select-options.directive.mjs +0 -157
  208. package/esm2022/select/select-options/select-options.token.mjs +0 -16
  209. package/select/select-button/select-button.directive.d.ts +0 -51
  210. package/select/select-option/select-option.directive.d.ts +0 -57
  211. package/select/select-options/select-options.directive.d.ts +0 -65
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import { BooleanInput } from '@angular/cdk/coercion';
9
9
  import * as i0 from "@angular/core";
10
+ import * as i1 from "ng-primitives/interactions";
10
11
  export declare class NgpFileUpload {
11
12
  /**
12
13
  * Access the host element.
@@ -55,5 +56,5 @@ export declare class NgpFileUpload {
55
56
  protected onDragLeave(event: DragEvent): void;
56
57
  protected onDrop(event: DragEvent): void;
57
58
  static ɵfac: i0.ɵɵFactoryDeclaration<NgpFileUpload, never>;
58
- static ɵdir: i0.ɵɵDirectiveDeclaration<NgpFileUpload, "[ngpFileUpload]", ["ngpFileUpload"], { "fileTypes": { "alias": "ngpFileUploadFileTypes"; "required": false; "isSignal": true; }; "multiple": { "alias": "ngpFileUploadMultiple"; "required": false; "isSignal": true; }; "directory": { "alias": "ngpFileUploadDirectory"; "required": false; "isSignal": true; }; "dragAndDrop": { "alias": "ngpFileUploadDragDrop"; "required": false; "isSignal": true; }; "disabled": { "alias": "ngpFileUploadDisabled"; "required": false; "isSignal": true; }; }, { "selected": "ngpFileUploadSelected"; "dragOver": "ngpFileUploadDragOver"; }, never, never, true, never>;
59
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpFileUpload, "[ngpFileUpload]", ["ngpFileUpload"], { "fileTypes": { "alias": "ngpFileUploadFileTypes"; "required": false; "isSignal": true; }; "multiple": { "alias": "ngpFileUploadMultiple"; "required": false; "isSignal": true; }; "directory": { "alias": "ngpFileUploadDirectory"; "required": false; "isSignal": true; }; "dragAndDrop": { "alias": "ngpFileUploadDragDrop"; "required": false; "isSignal": true; }; "disabled": { "alias": "ngpFileUploadDisabled"; "required": false; "isSignal": true; }; }, { "selected": "ngpFileUploadSelected"; "dragOver": "ngpFileUploadDragOver"; }, never, never, true, [{ directive: typeof i1.NgpHover; inputs: {}; outputs: {}; }, { directive: typeof i1.NgpFocusVisible; inputs: {}; outputs: {}; }, { directive: typeof i1.NgpPress; inputs: {}; outputs: {}; }]>;
59
60
  }
@@ -0,0 +1,3 @@
1
+ # ng-primitives/focus-trap
2
+
3
+ Secondary entry point of `ng-primitives`. It can be used by importing from `ng-primitives/focus-trap`.
@@ -0,0 +1,64 @@
1
+ import { OnDestroy, OnInit } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export declare class NgpFocusTrap implements OnInit, OnDestroy {
4
+ /**
5
+ * Create a new focus trap.
6
+ */
7
+ private readonly focusTrap;
8
+ /**
9
+ * Access the interactivity checker.
10
+ */
11
+ private readonly interactivityChecker;
12
+ /**
13
+ * Get the focus trap container element.
14
+ */
15
+ private readonly elementRef;
16
+ /**
17
+ * Access NgZone to run the focus trap events outside of Angular's zone.
18
+ */
19
+ private readonly ngZone;
20
+ /**
21
+ * Store the mutation observer.
22
+ */
23
+ private mutationObserver;
24
+ /**
25
+ * Store the last focused element.
26
+ */
27
+ private lastFocusedElement;
28
+ /**
29
+ * Whether the focus trap is disabled.
30
+ */
31
+ readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
32
+ ngOnInit(): void;
33
+ ngOnDestroy(): void;
34
+ private handleFocusIn;
35
+ /**
36
+ * Handles the `focusout` event.
37
+ */
38
+ private handleFocusOut;
39
+ /**
40
+ * If the focused element gets removed from the DOM, browsers move focus back to the document.body.
41
+ * We move focus to the container to keep focus trapped correctly.
42
+ */
43
+ private handleMutations;
44
+ /**
45
+ * Handles the `keydown` event.
46
+ */
47
+ protected handleKeyDown(event: KeyboardEvent): void;
48
+ /**
49
+ * Returns the first and last tabbable elements inside a container.
50
+ */
51
+ private getTabbableEdges;
52
+ /**
53
+ * Returns a list of potential focusable elements inside a container.
54
+ */
55
+ private getTabbableCandidates;
56
+ /**
57
+ * Returns the first visible element in a list..
58
+ */
59
+ private findVisible;
60
+ private focus;
61
+ private focusFirst;
62
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgpFocusTrap, never>;
63
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpFocusTrap, "[ngpFocusTrap]", ["ngpFocusTrap"], { "disabled": { "alias": "ngpFocusTrapDisabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
64
+ }
@@ -6,9 +6,9 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  import { InjectionToken } from '@angular/core';
9
- import type { NgpSelectOptions } from './select-options.directive';
10
- export declare const NgpSelectOptionsToken: InjectionToken<NgpSelectOptions<unknown>>;
9
+ import type { NgpFocusTrap } from './focus-trap.directive';
10
+ export declare const NgpFocusTrapToken: InjectionToken<NgpFocusTrap>;
11
11
  /**
12
- * Inject the SelectOptions directive instance
12
+ * Inject the FocusTrap directive instance
13
13
  */
14
- export declare function injectSelectOptions<T>(): NgpSelectOptions<T>;
14
+ export declare function injectFocusTrap(): NgpFocusTrap;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright © 2024 Angular Primitives.
3
+ * https://github.com/ng-primitives/ng-primitives
4
+ *
5
+ * This source code is licensed under the CC BY-ND 4.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export { NgpFocusTrap } from './focus-trap/focus-trap.directive';
9
+ export { NgpFocusTrapToken } from './focus-trap/focus-trap.token';
@@ -3,7 +3,7 @@ export declare class NgpDescription {
3
3
  /**
4
4
  * Access the form field that the description is associated with.
5
5
  */
6
- protected readonly formField: import("ng-primitives/form-field").NgpFormField;
6
+ protected readonly formField: import("ng-primitives/form-field").NgpFormField | null;
7
7
  /**
8
8
  * The id of the description. If not provided, a unique id will be generated.
9
9
  */
@@ -5,13 +5,13 @@
5
5
  * This source code is licensed under the CC BY-ND 4.0 license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
- import { OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
8
+ import { OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
9
9
  import * as i0 from "@angular/core";
10
- export declare class NgpError implements OnInit, OnChanges, OnDestroy {
10
+ export declare class NgpError implements OnChanges, OnDestroy {
11
11
  /**
12
12
  * Access the form field that the description is associated with.
13
13
  */
14
- protected readonly formField: import("ng-primitives/form-field").NgpFormField;
14
+ protected readonly formField: import("ng-primitives/form-field").NgpFormField | null;
15
15
  /**
16
16
  * The id of the error message. If not provided, a unique id will be generated.
17
17
  */
@@ -20,11 +20,15 @@ export declare class NgpError implements OnInit, OnChanges, OnDestroy {
20
20
  * The validator associated with the error message.
21
21
  */
22
22
  readonly validator: import("@angular/core").InputSignal<string | null>;
23
+ /**
24
+ * Determine if there is an error message.
25
+ */
26
+ protected readonly hasError: import("@angular/core").Signal<boolean>;
23
27
  /**
24
28
  * Determine whether the validator associated with this error is failing.
25
29
  */
26
- protected readonly state: import("@angular/core").Signal<"fail" | "pass" | null>;
27
- ngOnInit(): void;
30
+ protected readonly state: import("@angular/core").Signal<"fail" | "pass">;
31
+ constructor();
28
32
  ngOnChanges(changes: SimpleChanges): void;
29
33
  ngOnDestroy(): void;
30
34
  static ɵfac: i0.ɵɵFactoryDeclaration<NgpError, never>;
@@ -3,7 +3,11 @@ export declare class NgpFormControl {
3
3
  /**
4
4
  * Access the form field that the form control is associated with.
5
5
  */
6
- protected readonly formField: import("ng-primitives/form-field").NgpFormField;
6
+ protected readonly formField: import("ng-primitives/form-field").NgpFormField | null;
7
+ /**
8
+ * Whether the form control is disabled by a parent.
9
+ */
10
+ protected readonly disabled: import("@angular/core").Signal<boolean>;
7
11
  /**
8
12
  * The id of the form control. If not provided, a unique id will be generated.
9
13
  */
@@ -11,11 +15,11 @@ export declare class NgpFormControl {
11
15
  /**
12
16
  * Determine the aria-labelledby attribute value.
13
17
  */
14
- protected readonly ariaLabelledBy: import("@angular/core").Signal<string>;
18
+ protected readonly ariaLabelledBy: import("@angular/core").Signal<string | undefined>;
15
19
  /**
16
20
  * Determine the aria-describedby attribute value.
17
21
  */
18
- protected readonly ariaDescribedBy: import("@angular/core").Signal<string>;
22
+ protected readonly ariaDescribedBy: import("@angular/core").Signal<string | undefined>;
19
23
  constructor();
20
24
  static ɵfac: i0.ɵɵFactoryDeclaration<NgpFormControl, never>;
21
25
  static ɵdir: i0.ɵɵDirectiveDeclaration<NgpFormControl, "[ngpFormControl]", ["ngpFormControl"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
@@ -12,4 +12,4 @@ export declare const NgpFormFieldToken: InjectionToken<NgpFormField>;
12
12
  * Inject the FormField directive instance
13
13
  * @param primitive
14
14
  */
15
- export declare function injectFormField(primitive: string): NgpFormField;
15
+ export declare function injectFormField(): NgpFormField | null;
@@ -7,7 +7,7 @@ export declare class NgpLabel {
7
7
  /**
8
8
  * Access the form field that the label is associated with.
9
9
  */
10
- protected readonly formField: import("ng-primitives/form-field").NgpFormField;
10
+ protected readonly formField: import("ng-primitives/form-field").NgpFormField | null;
11
11
  /**
12
12
  * The id of the label. If not provided, a unique id will be generated.
13
13
  */
@@ -19,8 +19,9 @@ export declare class NgpLabel {
19
19
  /**
20
20
  * Derive the for attribute value if the label is an HTML label element.
21
21
  */
22
- protected readonly htmlFor: import("@angular/core").Signal<string | null>;
22
+ protected readonly htmlFor: import("@angular/core").Signal<string | null | undefined>;
23
23
  constructor();
24
+ protected onClick(event: MouseEvent): void;
24
25
  static ɵfac: i0.ɵɵFactoryDeclaration<NgpLabel, never>;
25
26
  static ɵdir: i0.ɵɵDirectiveDeclaration<NgpLabel, "[ngpLabel]", ["ngpLabel"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
26
27
  }
@@ -0,0 +1,3 @@
1
+ # ng-primitives/input
2
+
3
+ Secondary entry point of `ng-primitives`. It can be used by importing from `ng-primitives/input`.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright © 2024 Angular Primitives.
3
+ * https://github.com/ng-primitives/ng-primitives
4
+ *
5
+ * This source code is licensed under the CC BY-ND 4.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export { NgpInput } from './input/input.directive';
9
+ export { NgpInputToken } from './input/input.token';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright © 2024 Angular Primitives.
3
+ * https://github.com/ng-primitives/ng-primitives
4
+ *
5
+ * This source code is licensed under the CC BY-ND 4.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { BooleanInput } from '@angular/cdk/coercion';
9
+ import { ElementRef } from '@angular/core';
10
+ import { NgpCanDisable } from 'ng-primitives/internal';
11
+ import * as i0 from "@angular/core";
12
+ import * as i1 from "ng-primitives/form-field";
13
+ import * as i2 from "ng-primitives/interactions";
14
+ import * as i3 from "ng-primitives/autofill";
15
+ export declare class NgpInput implements NgpCanDisable {
16
+ /**
17
+ * Access the underlying input element.
18
+ * @internal
19
+ */
20
+ readonly element: ElementRef<HTMLInputElement>;
21
+ /**
22
+ * Whether the element is disabled.
23
+ */
24
+ readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, BooleanInput>;
25
+ /**
26
+ * Sync the input value.
27
+ * @internal
28
+ */
29
+ readonly value: import("@angular/core").WritableSignal<string>;
30
+ protected valueDidChange(): void;
31
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgpInput, never>;
32
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpInput, "input[ngpInput]", ["ngpInput"], { "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, [{ directive: typeof i1.NgpFormControl; inputs: {}; outputs: {}; }, { directive: typeof i2.NgpHover; inputs: {}; outputs: {}; }, { directive: typeof i2.NgpFocus; inputs: {}; outputs: {}; }, { directive: typeof i2.NgpPress; inputs: {}; outputs: {}; }, { directive: typeof i3.NgpAutofill; inputs: {}; outputs: {}; }]>;
33
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright © 2024 Angular Primitives.
3
+ * https://github.com/ng-primitives/ng-primitives
4
+ *
5
+ * This source code is licensed under the CC BY-ND 4.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { InjectionToken } from '@angular/core';
9
+ import type { NgpInput } from './input.directive';
10
+ export declare const NgpInputToken: InjectionToken<NgpInput>;
11
+ /**
12
+ * Inject the Input directive instance
13
+ */
14
+ export declare function injectInput(): NgpInput;
@@ -20,10 +20,14 @@ export declare class NgpFocus {
20
20
  * Whether listening for focus events is disabled.
21
21
  */
22
22
  readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, BooleanInput>;
23
+ /**
24
+ * Access the disabled state from any parent.
25
+ */
26
+ private readonly isDisabled;
23
27
  /**
24
28
  * Emit when the focus state changes.
25
29
  */
26
- readonly stateChange: import("@angular/core").OutputEmitterRef<boolean>;
30
+ readonly focus: import("@angular/core").OutputEmitterRef<boolean>;
27
31
  /**
28
32
  * Listen for focus events.
29
33
  * @param event
@@ -35,5 +39,5 @@ export declare class NgpFocus {
35
39
  */
36
40
  protected onBlur(event: FocusEvent): void;
37
41
  static ɵfac: i0.ɵɵFactoryDeclaration<NgpFocus, never>;
38
- static ɵdir: i0.ɵɵDirectiveDeclaration<NgpFocus, "[ngpFocus]", ["ngpFocus"], { "disabled": { "alias": "ngpFocusDisabled"; "required": false; "isSignal": true; }; }, { "stateChange": "ngpFocusChange"; }, never, never, true, never>;
42
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpFocus, "[ngpFocus]", ["ngpFocus"], { "disabled": { "alias": "ngpFocusDisabled"; "required": false; "isSignal": true; }; }, { "focus": "ngpFocus"; }, never, never, true, never>;
39
43
  }
@@ -13,6 +13,10 @@ export declare class NgpFocusVisible {
13
13
  * Whether focus events are listened to.
14
14
  */
15
15
  readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, BooleanInput>;
16
+ /**
17
+ * Access the disabled state from any parent.
18
+ */
19
+ private readonly isDisabled;
16
20
  /**
17
21
  * Emit when the element is visually focused.
18
22
  */
@@ -29,5 +33,5 @@ export declare class NgpFocusVisible {
29
33
  protected onBlur(): void;
30
34
  private alwaysShowFocus;
31
35
  static ɵfac: i0.ɵɵFactoryDeclaration<NgpFocusVisible, never>;
32
- static ɵdir: i0.ɵɵDirectiveDeclaration<NgpFocusVisible, "[ngpFocusVisible]", ["ngpFocusVisible"], { "disabled": { "alias": "ngpFocusVisibleDisabled"; "required": false; "isSignal": true; }; }, { "focusChange": "ngpFocusVisibleChange"; }, never, never, true, never>;
36
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpFocusVisible, "[ngpFocusVisible]", ["ngpFocusVisible"], { "disabled": { "alias": "ngpFocusVisibleDisabled"; "required": false; "isSignal": true; }; }, { "focusChange": "ngpFocusVisible"; }, never, never, true, never>;
33
37
  }
@@ -23,6 +23,10 @@ export declare class NgpHover implements OnChanges {
23
23
  * Whether hoving should be disabled.
24
24
  */
25
25
  readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, BooleanInput>;
26
+ /**
27
+ * Access the disabled state from any parent.
28
+ */
29
+ private readonly isDisabled;
26
30
  /**
27
31
  * Store the current hover state.
28
32
  */
@@ -61,5 +65,5 @@ export declare class NgpHover implements OnChanges {
61
65
  protected onMouseEnter(event: MouseEvent): void;
62
66
  protected onMouseLeave(event: MouseEvent): void;
63
67
  static ɵfac: i0.ɵɵFactoryDeclaration<NgpHover, never>;
64
- static ɵdir: i0.ɵɵDirectiveDeclaration<NgpHover, "[ngpHover]", ["ngpHover"], { "disabled": { "alias": "ngpHoverDisabled"; "required": false; "isSignal": true; }; }, { "hoverStart": "ngpHoverStart"; "hoverEnd": "ngpHoverEnd"; "hoverChange": "ngpHoverChange"; }, never, never, true, never>;
68
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpHover, "[ngpHover]", ["ngpHover"], { "disabled": { "alias": "ngpHoverDisabled"; "required": false; "isSignal": true; }; }, { "hoverStart": "ngpHoverStart"; "hoverEnd": "ngpHoverEnd"; "hoverChange": "ngpHover"; }, never, never, true, never>;
65
69
  }
@@ -11,3 +11,7 @@ export { NgpFocus } from './focus/focus.directive';
11
11
  export { NgpFocusToken } from './focus/focus.token';
12
12
  export { NgpFocusVisible } from './focus-visible/focus-visible.directive';
13
13
  export { NgpFocusVisibleToken } from './focus-visible/focus-visible.token';
14
+ export { NgpPress } from './press/press.directive';
15
+ export { NgpPressToken } from './press/press.token';
16
+ export { NgpMove } from './move/move.directive';
17
+ export { NgpMoveToken } from './move/move.token';
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Copyright © 2024 Angular Primitives.
3
+ * https://github.com/ng-primitives/ng-primitives
4
+ *
5
+ * This source code is licensed under the CC BY-ND 4.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { BooleanInput } from '@angular/cdk/coercion';
9
+ import * as i0 from "@angular/core";
10
+ /**
11
+ * Inspired by react-aria useMove hook:
12
+ * https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/interactions/src/useMove.ts
13
+ */
14
+ export declare class NgpMove {
15
+ /**
16
+ * Access the disposable helper.
17
+ */
18
+ private readonly disposables;
19
+ /**
20
+ * Whether movement is disabled.
21
+ */
22
+ readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, BooleanInput>;
23
+ /**
24
+ * Access the disabled state from any parent.
25
+ */
26
+ private readonly isDisabled;
27
+ /**
28
+ * Emit when the move event begins.
29
+ */
30
+ readonly start: import("@angular/core").OutputEmitterRef<NgpMoveBaseEvent>;
31
+ /**
32
+ * Emit when the element is moved.
33
+ */
34
+ readonly move: import("@angular/core").OutputEmitterRef<NgpMoveEvent>;
35
+ /**
36
+ * Emit when the move event ends.
37
+ */
38
+ readonly end: import("@angular/core").OutputEmitterRef<NgpMoveBaseEvent>;
39
+ /**
40
+ * Whether the element is currently being moved.
41
+ */
42
+ private isMoving;
43
+ /**
44
+ * Store the last x position of the element.
45
+ */
46
+ private x;
47
+ /**
48
+ * Store the last y position of the element.
49
+ */
50
+ private y;
51
+ /**
52
+ * Store the id of the last pointer.
53
+ */
54
+ private pointerId;
55
+ /**
56
+ * Store the disposable event listeners.
57
+ */
58
+ private disposableListeners;
59
+ /**
60
+ * Handle a move start.
61
+ */
62
+ private onMoveStart;
63
+ /**
64
+ * Handle a move event.
65
+ */
66
+ private onMove;
67
+ /**
68
+ * Handle a move end.
69
+ */
70
+ private onMoveEnd;
71
+ /**
72
+ * Handle the pointer down event.
73
+ */
74
+ protected onPointerDown(event: PointerEvent): void;
75
+ /**
76
+ * Handle the pointer up event.
77
+ */
78
+ protected onPointerUp(event: PointerEvent): void;
79
+ /**
80
+ * Handle the pointer move event.
81
+ */
82
+ protected onPointerMove(event: PointerEvent): void;
83
+ private triggerKeyboardMove;
84
+ protected onArrowUp(event: KeyboardEvent): void;
85
+ protected onArrowDown(event: KeyboardEvent): void;
86
+ protected onArrowLeft(event: KeyboardEvent): void;
87
+ protected onArrowRight(event: KeyboardEvent): void;
88
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgpMove, never>;
89
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpMove, "[ngpMove]", ["ngpMove"], { "disabled": { "alias": "ngpMoveDisabled"; "required": false; "isSignal": true; }; }, { "start": "ngpMoveStart"; "move": "ngpMove"; "end": "ngpMoveEnd"; }, never, never, true, never>;
90
+ }
91
+ interface NgpMoveBaseEvent {
92
+ /**
93
+ * Whether the event was triggered by a mouse or keyboard event.
94
+ */
95
+ pointerType: PointerType;
96
+ /**
97
+ * Whether the shift key was pressed during the event.
98
+ */
99
+ shiftKey: boolean;
100
+ /**
101
+ * Whether the control key was pressed during the event.
102
+ */
103
+ ctrlKey: boolean;
104
+ /**
105
+ * Whether the meta key was pressed during the event.
106
+ */
107
+ metaKey: boolean;
108
+ /**
109
+ * Whether the alt key was pressed during the event.
110
+ */
111
+ altKey: boolean;
112
+ }
113
+ export type NgpMoveStartEvent = NgpMoveBaseEvent;
114
+ export type NgpMoveEndEvent = NgpMoveBaseEvent;
115
+ export interface NgpMoveEvent extends NgpMoveBaseEvent {
116
+ /**
117
+ * The amount of pixels moved in the x-axis.
118
+ */
119
+ deltaX: number;
120
+ /**
121
+ * The amount of pixels moved in the y-axis.
122
+ */
123
+ deltaY: number;
124
+ }
125
+ export type PointerType = 'mouse' | 'pen' | 'touch' | 'keyboard' | 'virtual';
126
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright © 2024 Angular Primitives.
3
+ * https://github.com/ng-primitives/ng-primitives
4
+ *
5
+ * This source code is licensed under the CC BY-ND 4.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { InjectionToken } from '@angular/core';
9
+ import type { NgpMove } from './move.directive';
10
+ export declare const NgpMoveToken: InjectionToken<NgpMove>;
11
+ /**
12
+ * Inject the Move directive instance
13
+ */
14
+ export declare function injectMove(): NgpMove;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Copyright © 2024 Angular Primitives.
3
+ * https://github.com/ng-primitives/ng-primitives
4
+ *
5
+ * This source code is licensed under the CC BY-ND 4.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { BooleanInput } from '@angular/cdk/coercion';
9
+ import * as i0 from "@angular/core";
10
+ /**
11
+ * This was inpsired by Headless UI's active-press hook:
12
+ * https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-react/src/hooks/use-active-press.tsx
13
+ */
14
+ export declare class NgpPress {
15
+ /**
16
+ * Access the HTML Element.
17
+ */
18
+ private readonly element;
19
+ /**
20
+ * Access the disposables.
21
+ */
22
+ private readonly disposables;
23
+ /**
24
+ * Whether listening for press events is disabled.
25
+ */
26
+ readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, BooleanInput>;
27
+ /**
28
+ * Access the disabled state from any parent.
29
+ */
30
+ private readonly isDisabled;
31
+ /**
32
+ * Emit when the press begins.
33
+ */
34
+ readonly pressStart: import("@angular/core").OutputEmitterRef<void>;
35
+ /**
36
+ * Emit when the press ends.
37
+ */
38
+ readonly pressEnd: import("@angular/core").OutputEmitterRef<void>;
39
+ /**
40
+ * Emit when the press changes.
41
+ */
42
+ readonly pressChange: import("@angular/core").OutputEmitterRef<boolean>;
43
+ /**
44
+ * The press state.
45
+ */
46
+ protected readonly pressed: import("@angular/core").WritableSignal<boolean>;
47
+ /**
48
+ * Reset the press state.
49
+ */
50
+ private reset;
51
+ /**
52
+ * Store the list of disposables.
53
+ */
54
+ private disposableListeners;
55
+ protected onPointerDown(): void;
56
+ private onPointerMove;
57
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgpPress, never>;
58
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpPress, "[ngpPress]", ["ngpPress"], { "disabled": { "alias": "ngpPressDisabled"; "required": false; "isSignal": true; }; }, { "pressStart": "ngpPressStart"; "pressEnd": "ngpPressEnd"; "pressChange": "ngpPress"; }, never, never, true, never>;
59
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright © 2024 Angular Primitives.
3
+ * https://github.com/ng-primitives/ng-primitives
4
+ *
5
+ * This source code is licensed under the CC BY-ND 4.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { InjectionToken } from '@angular/core';
9
+ import type { NgpPress } from './press.directive';
10
+ export declare const NgpPressToken: InjectionToken<NgpPress>;
11
+ /**
12
+ * Inject the Press directive instance
13
+ */
14
+ export declare function injectPress(): NgpPress;
@@ -0,0 +1,3 @@
1
+ # ng-primitives/internal
2
+
3
+ Secondary entry point of `ng-primitives`. It can be used by importing from `ng-primitives/internal`.
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright © 2024 Angular Primitives.
3
+ * https://github.com/ng-primitives/ng-primitives
4
+ *
5
+ * This source code is licensed under the CC BY-ND 4.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { InjectionToken, Signal } from '@angular/core';
9
+ export declare const NgpDisabledToken: InjectionToken<NgpCanDisable>;
10
+ export interface NgpCanDisable {
11
+ /**
12
+ * Whether the element is disabled.
13
+ */
14
+ readonly disabled: Signal<boolean>;
15
+ }
16
+ /**
17
+ * Determine if we are in a disabled context.
18
+ * @param disabled The disabled signal for the local context.
19
+ * @returns The disabled signal.
20
+ */
21
+ export declare function injectDisabled(disabled?: Signal<boolean>): Signal<boolean>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright © 2024 Angular Primitives.
3
+ * https://github.com/ng-primitives/ng-primitives
4
+ *
5
+ * This source code is licensed under the CC BY-ND 4.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export * from './disabled/disabled';
9
+ export * from './orientation/orientation';
10
+ export * from './style-injector/style-injector';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright © 2024 Angular Primitives.
3
+ * https://github.com/ng-primitives/ng-primitives
4
+ *
5
+ * This source code is licensed under the CC BY-ND 4.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { InjectionToken, Signal } from '@angular/core';
9
+ export declare const NgpOrientationToken: InjectionToken<NgpCanOrientate>;
10
+ export interface NgpCanOrientate {
11
+ /**
12
+ * The desired orientation.
13
+ */
14
+ readonly orientation: Signal<NgpOrientation>;
15
+ }
16
+ /**
17
+ * Determine if we are in a orientation context.
18
+ * @param orientation The orientation signal for the local context.
19
+ * @returns The orientation signal.
20
+ */
21
+ export declare function injectOrientation(orientation?: Signal<NgpOrientation>): Signal<NgpOrientation>;
22
+ export type NgpOrientation = 'horizontal' | 'vertical';