ng-primitives 0.40.0 → 0.42.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 (42) hide show
  1. package/checkbox/checkbox/checkbox.d.ts +1 -2
  2. package/fesm2022/ng-primitives-checkbox.mjs +3 -5
  3. package/fesm2022/ng-primitives-checkbox.mjs.map +1 -1
  4. package/fesm2022/ng-primitives-file-upload.mjs +62 -7
  5. package/fesm2022/ng-primitives-file-upload.mjs.map +1 -1
  6. package/fesm2022/ng-primitives-form-field.mjs +63 -40
  7. package/fesm2022/ng-primitives-form-field.mjs.map +1 -1
  8. package/fesm2022/ng-primitives-input.mjs +5 -6
  9. package/fesm2022/ng-primitives-input.mjs.map +1 -1
  10. package/fesm2022/ng-primitives-popover.mjs +19 -29
  11. package/fesm2022/ng-primitives-popover.mjs.map +1 -1
  12. package/fesm2022/ng-primitives-portal.mjs +131 -0
  13. package/fesm2022/ng-primitives-portal.mjs.map +1 -0
  14. package/fesm2022/ng-primitives-radio.mjs +6 -8
  15. package/fesm2022/ng-primitives-radio.mjs.map +1 -1
  16. package/fesm2022/ng-primitives-select.mjs +3 -5
  17. package/fesm2022/ng-primitives-select.mjs.map +1 -1
  18. package/fesm2022/ng-primitives-slider.mjs +3 -5
  19. package/fesm2022/ng-primitives-slider.mjs.map +1 -1
  20. package/fesm2022/ng-primitives-textarea.mjs +3 -5
  21. package/fesm2022/ng-primitives-textarea.mjs.map +1 -1
  22. package/fesm2022/ng-primitives-tooltip.mjs +23 -25
  23. package/fesm2022/ng-primitives-tooltip.mjs.map +1 -1
  24. package/file-upload/file-dropzone/file-drop-filter.d.ts +2 -0
  25. package/file-upload/file-dropzone/file-dropzone-state.d.ts +1 -0
  26. package/file-upload/file-dropzone/file-dropzone.d.ts +5 -1
  27. package/file-upload/file-upload/file-upload-state.d.ts +1 -0
  28. package/file-upload/file-upload/file-upload.d.ts +6 -2
  29. package/form-field/form-control/form-control-state.d.ts +1 -38
  30. package/form-field/form-control/form-control.d.ts +7 -36
  31. package/form-field/index.d.ts +2 -2
  32. package/input/input/input.d.ts +2 -3
  33. package/package.json +13 -9
  34. package/popover/popover-trigger/popover-trigger.d.ts +3 -2
  35. package/portal/README.md +3 -0
  36. package/portal/index.d.ts +1 -0
  37. package/portal/portal.d.ts +82 -0
  38. package/radio/radio-group/radio-group.d.ts +1 -2
  39. package/select/select/select.d.ts +1 -2
  40. package/slider/slider/slider.d.ts +1 -2
  41. package/textarea/textarea/textarea.d.ts +1 -2
  42. package/tooltip/tooltip-trigger/tooltip-trigger.d.ts +3 -2
@@ -1,6 +1,5 @@
1
1
  import { BooleanInput } from '@angular/cdk/coercion';
2
2
  import * as i0 from "@angular/core";
3
- import * as i1 from "ng-primitives/form-field";
4
3
  /**
5
4
  * Apply the `ngpCheckbox` directive to an element to that represents the checkbox, such as a `button`.
6
5
  */
@@ -42,5 +41,5 @@ export declare class NgpCheckbox {
42
41
  protected onEnter(event: KeyboardEvent): void;
43
42
  toggle(event?: Event): void;
44
43
  static ɵfac: i0.ɵɵFactoryDeclaration<NgpCheckbox, never>;
45
- static ɵdir: i0.ɵɵDirectiveDeclaration<NgpCheckbox, "[ngpCheckbox]", never, { "id": { "alias": "id"; "required": false; "isSignal": true; }; "checked": { "alias": "ngpCheckboxChecked"; "required": false; "isSignal": true; }; "indeterminate": { "alias": "ngpCheckboxIndeterminate"; "required": false; "isSignal": true; }; "required": { "alias": "ngpCheckboxRequired"; "required": false; "isSignal": true; }; "disabled": { "alias": "ngpCheckboxDisabled"; "required": false; "isSignal": true; }; }, { "checkedChange": "ngpCheckboxCheckedChange"; "indeterminateChange": "ngpCheckboxIndeterminateChange"; }, never, never, true, [{ directive: typeof i1.NgpFormControl; inputs: {}; outputs: {}; }]>;
44
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpCheckbox, "[ngpCheckbox]", never, { "id": { "alias": "id"; "required": false; "isSignal": true; }; "checked": { "alias": "ngpCheckboxChecked"; "required": false; "isSignal": true; }; "indeterminate": { "alias": "ngpCheckboxIndeterminate"; "required": false; "isSignal": true; }; "required": { "alias": "ngpCheckboxRequired"; "required": false; "isSignal": true; }; "disabled": { "alias": "ngpCheckboxDisabled"; "required": false; "isSignal": true; }; }, { "checkedChange": "ngpCheckboxCheckedChange"; "indeterminateChange": "ngpCheckboxIndeterminateChange"; }, never, never, true, never>;
46
45
  }
@@ -1,7 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { input, booleanAttribute, output, HostListener, Directive } from '@angular/core';
3
- import * as i1 from 'ng-primitives/form-field';
4
- import { syncFormControl, NgpFormControl } from 'ng-primitives/form-field';
3
+ import { setupFormControl } from 'ng-primitives/form-field';
5
4
  import { setupInteractions } from 'ng-primitives/internal';
6
5
  import { uniqueId } from 'ng-primitives/utils';
7
6
  import { createStateToken, createStateProvider, createStateInjector, createState } from 'ng-primitives/state';
@@ -77,7 +76,7 @@ class NgpCheckbox {
77
76
  * The state of the checkbox.
78
77
  */
79
78
  this.state = checkboxState(this);
80
- syncFormControl({ disabled: this.state.disabled });
79
+ setupFormControl({ id: this.state.id, disabled: this.state.disabled });
81
80
  setupInteractions({
82
81
  hover: true,
83
82
  press: true,
@@ -104,14 +103,13 @@ class NgpCheckbox {
104
103
  }
105
104
  }
106
105
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgpCheckbox, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
107
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.8", type: NgpCheckbox, isStandalone: true, selector: "[ngpCheckbox]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "ngpCheckboxChecked", isSignal: true, isRequired: false, transformFunction: null }, indeterminate: { classPropertyName: "indeterminate", publicName: "ngpCheckboxIndeterminate", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "ngpCheckboxRequired", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpCheckboxDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checkedChange: "ngpCheckboxCheckedChange", indeterminateChange: "ngpCheckboxIndeterminateChange" }, host: { attributes: { "role": "checkbox" }, listeners: { "keydown.enter": "onEnter($event)", "click": "toggle($event)", "keydown.space": "toggle($event)" }, properties: { "attr.aria-checked": "state.indeterminate() ? \"mixed\" : state.checked()", "attr.data-checked": "state.checked() ? \"\" : null", "attr.data-indeterminate": "state.indeterminate() ? \"\" : null", "attr.aria-disabled": "state.disabled()", "tabindex": "state.disabled() ? -1 : 0" } }, providers: [provideCheckboxState()], hostDirectives: [{ directive: i1.NgpFormControl }], ngImport: i0 }); }
106
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.8", type: NgpCheckbox, isStandalone: true, selector: "[ngpCheckbox]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "ngpCheckboxChecked", isSignal: true, isRequired: false, transformFunction: null }, indeterminate: { classPropertyName: "indeterminate", publicName: "ngpCheckboxIndeterminate", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "ngpCheckboxRequired", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpCheckboxDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checkedChange: "ngpCheckboxCheckedChange", indeterminateChange: "ngpCheckboxIndeterminateChange" }, host: { attributes: { "role": "checkbox" }, listeners: { "keydown.enter": "onEnter($event)", "click": "toggle($event)", "keydown.space": "toggle($event)" }, properties: { "attr.aria-checked": "state.indeterminate() ? \"mixed\" : state.checked()", "attr.data-checked": "state.checked() ? \"\" : null", "attr.data-indeterminate": "state.indeterminate() ? \"\" : null", "attr.aria-disabled": "state.disabled()", "tabindex": "state.disabled() ? -1 : 0" } }, providers: [provideCheckboxState()], ngImport: i0 }); }
108
107
  }
109
108
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgpCheckbox, decorators: [{
110
109
  type: Directive,
111
110
  args: [{
112
111
  selector: '[ngpCheckbox]',
113
112
  providers: [provideCheckboxState()],
114
- hostDirectives: [NgpFormControl],
115
113
  host: {
116
114
  role: 'checkbox',
117
115
  '[attr.aria-checked]': 'state.indeterminate() ? "mixed" : state.checked()',
@@ -1 +1 @@
1
- {"version":3,"file":"ng-primitives-checkbox.mjs","sources":["../../../../packages/ng-primitives/checkbox/src/checkbox/checkbox-state.ts","../../../../packages/ng-primitives/checkbox/src/checkbox/checkbox.ts","../../../../packages/ng-primitives/checkbox/src/ng-primitives-checkbox.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpCheckbox } from './checkbox';\n\n/**\n * The state token for the Checkbox primitive.\n */\nexport const NgpCheckboxStateToken = createStateToken<NgpCheckbox>('Checkbox');\n\n/**\n * Provides the Checkbox state.\n */\nexport const provideCheckboxState = createStateProvider(NgpCheckboxStateToken);\n\n/**\n * Injects the Checkbox state.\n */\nexport const injectCheckboxState = createStateInjector(NgpCheckboxStateToken);\n\n/**\n * The Checkbox state registration function.\n */\nexport const checkboxState = createState(NgpCheckboxStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { Directive, HostListener, booleanAttribute, input, output } from '@angular/core';\nimport { NgpFormControl, syncFormControl } from 'ng-primitives/form-field';\nimport { setupInteractions } from 'ng-primitives/internal';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { checkboxState, provideCheckboxState } from './checkbox-state';\n\n/**\n * Apply the `ngpCheckbox` directive to an element to that represents the checkbox, such as a `button`.\n */\n@Directive({\n selector: '[ngpCheckbox]',\n providers: [provideCheckboxState()],\n hostDirectives: [NgpFormControl],\n host: {\n role: 'checkbox',\n '[attr.aria-checked]': 'state.indeterminate() ? \"mixed\" : state.checked()',\n '[attr.data-checked]': 'state.checked() ? \"\" : null',\n '[attr.data-indeterminate]': 'state.indeterminate() ? \"\" : null',\n '[attr.aria-disabled]': 'state.disabled()',\n '[tabindex]': 'state.disabled() ? -1 : 0',\n },\n})\nexport class NgpCheckbox {\n /**\n * The id of the checkbox.\n * @internal\n */\n readonly id = input(uniqueId('ngp-checkbox'));\n\n /**\n * Defines whether the checkbox is checked.\n */\n readonly checked = input<boolean, BooleanInput>(false, {\n alias: 'ngpCheckboxChecked',\n transform: booleanAttribute,\n });\n\n /**\n * The event that is emitted when the checkbox value changes.\n */\n readonly checkedChange = output<boolean>({\n alias: 'ngpCheckboxCheckedChange',\n });\n\n /**\n * Defines whether the checkbox is indeterminate.\n */\n readonly indeterminate = input<boolean, BooleanInput>(false, {\n alias: 'ngpCheckboxIndeterminate',\n transform: booleanAttribute,\n });\n\n /**\n * The event that is emitted when the indeterminate value changes.\n */\n readonly indeterminateChange = output<boolean>({\n alias: 'ngpCheckboxIndeterminateChange',\n });\n\n /**\n * Whether the checkbox is required.\n */\n readonly required = input<boolean, BooleanInput>(false, {\n alias: 'ngpCheckboxRequired',\n transform: booleanAttribute,\n });\n\n /**\n * Defines whether the checkbox is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpCheckboxDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * The state of the checkbox.\n */\n protected readonly state = checkboxState<NgpCheckbox>(this);\n\n constructor() {\n syncFormControl({ disabled: this.state.disabled });\n setupInteractions({\n hover: true,\n press: true,\n focusVisible: true,\n disabled: this.state.disabled,\n });\n }\n\n @HostListener('keydown.enter', ['$event'])\n protected onEnter(event: KeyboardEvent): void {\n // According to WAI ARIA, Checkboxes don't activate on enter keypress\n event.preventDefault();\n }\n\n @HostListener('click', ['$event'])\n @HostListener('keydown.space', ['$event'])\n toggle(event?: Event): void {\n if (this.state.disabled()) {\n return;\n }\n\n // prevent this firing twice in cases where the label is clicked and the checkbox is clicked by the one event\n event?.preventDefault();\n\n this.state.checked.set(this.state.indeterminate() ? true : !this.state.checked());\n this.checkedChange.emit(this.state.checked());\n\n // if the checkbox was indeterminate, it isn't anymore\n if (this.state.indeterminate()) {\n this.state.indeterminate.set(false);\n this.indeterminateChange.emit(false);\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAQA;;AAEG;AACI,MAAM,qBAAqB,GAAG,gBAAgB,CAAc,UAAU,CAAC;AAE9E;;AAEG;MACU,oBAAoB,GAAG,mBAAmB,CAAC,qBAAqB;AAE7E;;AAEG;MACU,mBAAmB,GAAG,mBAAmB,CAAC,qBAAqB;AAE5E;;AAEG;AACI,MAAM,aAAa,GAAG,WAAW,CAAC,qBAAqB,CAAC;;ACnB/D;;AAEG;MAcU,WAAW,CAAA;AA0DtB,IAAA,WAAA,GAAA;AAzDA;;;AAGG;QACM,IAAE,CAAA,EAAA,GAAG,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;AAE7C;;AAEG;AACM,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAAwB,KAAK,EAAE;AACrD,YAAA,KAAK,EAAE,oBAAoB;AAC3B,YAAA,SAAS,EAAE,gBAAgB;AAC5B,SAAA,CAAC;AAEF;;AAEG;QACM,IAAa,CAAA,aAAA,GAAG,MAAM,CAAU;AACvC,YAAA,KAAK,EAAE,0BAA0B;AAClC,SAAA,CAAC;AAEF;;AAEG;AACM,QAAA,IAAA,CAAA,aAAa,GAAG,KAAK,CAAwB,KAAK,EAAE;AAC3D,YAAA,KAAK,EAAE,0BAA0B;AACjC,YAAA,SAAS,EAAE,gBAAgB;AAC5B,SAAA,CAAC;AAEF;;AAEG;QACM,IAAmB,CAAA,mBAAA,GAAG,MAAM,CAAU;AAC7C,YAAA,KAAK,EAAE,gCAAgC;AACxC,SAAA,CAAC;AAEF;;AAEG;AACM,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/checkbox-state.ts","../../../../packages/ng-primitives/checkbox/src/checkbox/checkbox.ts","../../../../packages/ng-primitives/checkbox/src/ng-primitives-checkbox.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpCheckbox } from './checkbox';\n\n/**\n * The state token for the Checkbox primitive.\n */\nexport const NgpCheckboxStateToken = createStateToken<NgpCheckbox>('Checkbox');\n\n/**\n * Provides the Checkbox state.\n */\nexport const provideCheckboxState = createStateProvider(NgpCheckboxStateToken);\n\n/**\n * Injects the Checkbox state.\n */\nexport const injectCheckboxState = createStateInjector(NgpCheckboxStateToken);\n\n/**\n * The Checkbox state registration function.\n */\nexport const checkboxState = createState(NgpCheckboxStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { Directive, HostListener, booleanAttribute, input, output } from '@angular/core';\nimport { setupFormControl } from 'ng-primitives/form-field';\nimport { setupInteractions } from 'ng-primitives/internal';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { checkboxState, provideCheckboxState } from './checkbox-state';\n\n/**\n * Apply the `ngpCheckbox` directive to an element to that represents the checkbox, such as a `button`.\n */\n@Directive({\n selector: '[ngpCheckbox]',\n providers: [provideCheckboxState()],\n host: {\n role: 'checkbox',\n '[attr.aria-checked]': 'state.indeterminate() ? \"mixed\" : state.checked()',\n '[attr.data-checked]': 'state.checked() ? \"\" : null',\n '[attr.data-indeterminate]': 'state.indeterminate() ? \"\" : null',\n '[attr.aria-disabled]': 'state.disabled()',\n '[tabindex]': 'state.disabled() ? -1 : 0',\n },\n})\nexport class NgpCheckbox {\n /**\n * The id of the checkbox.\n * @internal\n */\n readonly id = input(uniqueId('ngp-checkbox'));\n\n /**\n * Defines whether the checkbox is checked.\n */\n readonly checked = input<boolean, BooleanInput>(false, {\n alias: 'ngpCheckboxChecked',\n transform: booleanAttribute,\n });\n\n /**\n * The event that is emitted when the checkbox value changes.\n */\n readonly checkedChange = output<boolean>({\n alias: 'ngpCheckboxCheckedChange',\n });\n\n /**\n * Defines whether the checkbox is indeterminate.\n */\n readonly indeterminate = input<boolean, BooleanInput>(false, {\n alias: 'ngpCheckboxIndeterminate',\n transform: booleanAttribute,\n });\n\n /**\n * The event that is emitted when the indeterminate value changes.\n */\n readonly indeterminateChange = output<boolean>({\n alias: 'ngpCheckboxIndeterminateChange',\n });\n\n /**\n * Whether the checkbox is required.\n */\n readonly required = input<boolean, BooleanInput>(false, {\n alias: 'ngpCheckboxRequired',\n transform: booleanAttribute,\n });\n\n /**\n * Defines whether the checkbox is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpCheckboxDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * The state of the checkbox.\n */\n protected readonly state = checkboxState<NgpCheckbox>(this);\n\n constructor() {\n setupFormControl({ id: this.state.id, disabled: this.state.disabled });\n setupInteractions({\n hover: true,\n press: true,\n focusVisible: true,\n disabled: this.state.disabled,\n });\n }\n\n @HostListener('keydown.enter', ['$event'])\n protected onEnter(event: KeyboardEvent): void {\n // According to WAI ARIA, Checkboxes don't activate on enter keypress\n event.preventDefault();\n }\n\n @HostListener('click', ['$event'])\n @HostListener('keydown.space', ['$event'])\n toggle(event?: Event): void {\n if (this.state.disabled()) {\n return;\n }\n\n // prevent this firing twice in cases where the label is clicked and the checkbox is clicked by the one event\n event?.preventDefault();\n\n this.state.checked.set(this.state.indeterminate() ? true : !this.state.checked());\n this.checkedChange.emit(this.state.checked());\n\n // if the checkbox was indeterminate, it isn't anymore\n if (this.state.indeterminate()) {\n this.state.indeterminate.set(false);\n this.indeterminateChange.emit(false);\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAQA;;AAEG;AACI,MAAM,qBAAqB,GAAG,gBAAgB,CAAc,UAAU,CAAC;AAE9E;;AAEG;MACU,oBAAoB,GAAG,mBAAmB,CAAC,qBAAqB;AAE7E;;AAEG;MACU,mBAA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,CAAA;;2FAUxB,WAAW,EAAA,UAAA,EAAA,CAAA;kBAZvB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,eAAe;AACzB,oBAAA,SAAS,EAAE,CAAC,oBAAoB,EAAE,CAAC;AACnC,oBAAA,IAAI,EAAE;AACJ,wBAAA,IAAI,EAAE,UAAU;AAChB,wBAAA,qBAAqB,EAAE,mDAAmD;AAC1E,wBAAA,qBAAqB,EAAE,6BAA6B;AACpD,wBAAA,2BAA2B,EAAE,mCAAmC;AAChE,wBAAA,sBAAsB,EAAE,kBAAkB;AAC1C,wBAAA,YAAY,EAAE,2BAA2B;AAC1C,qBAAA;AACF,iBAAA;wDAsEW,OAAO,EAAA,CAAA;sBADhB,YAAY;uBAAC,eAAe,EAAE,CAAC,QAAQ,CAAC;gBAQzC,MAAM,EAAA,CAAA;sBAFL,YAAY;uBAAC,OAAO,EAAE,CAAC,QAAQ,CAAC;;sBAChC,YAAY;uBAAC,eAAe,EAAE,CAAC,QAAQ,CAAC;;;ACjG3C;;AAEG;;;;"}
@@ -4,6 +4,35 @@ import { inject, ElementRef, input, booleanAttribute, output, signal, HostListen
4
4
  import { setupHover, setupInteractions } from 'ng-primitives/internal';
5
5
  import { createStateToken, createStateProvider, createStateInjector, createState } from 'ng-primitives/state';
6
6
 
7
+ function fileDropFilter(fileList, acceptedTypes, multiple) {
8
+ const validFiles = Array.from(fileList).filter(file => isFileTypeAccepted(file, acceptedTypes));
9
+ const limitedFiles = multiple ? validFiles : validFiles.slice(0, 1);
10
+ return limitedFiles.length > 0 ? filesToFileList(limitedFiles) : null;
11
+ }
12
+ function isFileTypeAccepted(file, acceptedTypes) {
13
+ // allow all file types if no types are specified
14
+ if (!acceptedTypes || acceptedTypes.length === 0)
15
+ return true;
16
+ const mimeType = file.type;
17
+ const fileName = file.name.toLowerCase();
18
+ return acceptedTypes.some(type => {
19
+ type = type.toLowerCase();
20
+ if (type.startsWith('.')) {
21
+ return fileName.endsWith(type);
22
+ }
23
+ if (type.endsWith('/*')) {
24
+ const baseType = type.replace('/*', '');
25
+ return mimeType.startsWith(baseType);
26
+ }
27
+ return mimeType === type;
28
+ });
29
+ }
30
+ function filesToFileList(files) {
31
+ const dataTransfer = new DataTransfer();
32
+ files.forEach(file => dataTransfer.items.add(file));
33
+ return dataTransfer.files;
34
+ }
35
+
7
36
  /**
8
37
  * The state token for the FileDropzone primitive.
9
38
  */
@@ -65,6 +94,12 @@ class NgpFileDropzone {
65
94
  this.selected = output({
66
95
  alias: 'ngpFileDropzoneSelected',
67
96
  });
97
+ /**
98
+ * Emits when uploaded files are rejected because they do not match the allowed {@link fileTypes}.
99
+ */
100
+ this.rejected = output({
101
+ alias: 'ngpFileDropzoneRejected',
102
+ });
68
103
  /**
69
104
  * Emits when the user drags a file over the file upload.
70
105
  */
@@ -118,12 +153,19 @@ class NgpFileDropzone {
118
153
  event.preventDefault();
119
154
  this.isDragOver.set(false);
120
155
  this.dragOver.emit(false);
121
- if (event.dataTransfer?.files) {
122
- this.selected.emit(event.dataTransfer.files);
156
+ const fileList = event.dataTransfer?.files;
157
+ if (fileList) {
158
+ const filteredFiles = fileDropFilter(fileList, this.state.fileTypes(), this.state.multiple());
159
+ if (filteredFiles) {
160
+ this.selected.emit(filteredFiles);
161
+ }
162
+ else {
163
+ this.rejected.emit();
164
+ }
123
165
  }
124
166
  }
125
167
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgpFileDropzone, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
126
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.8", type: NgpFileDropzone, isStandalone: true, selector: "[ngpFileDropzone]", inputs: { fileTypes: { classPropertyName: "fileTypes", publicName: "ngpFileDropzoneFileTypes", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "ngpFileDropzoneMultiple", isSignal: true, isRequired: false, transformFunction: null }, directory: { classPropertyName: "directory", publicName: "ngpFileDropzoneDirectory", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpFileDropzoneDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selected: "ngpFileDropzoneSelected", dragOver: "ngpFileDropzoneDragOver" }, host: { listeners: { "dragenter": "onDragEnter($event)", "dragover": "onDragOver($event)", "dragleave": "onDragLeave($event)", "drop": "onDrop($event)" }, properties: { "attr.data-dragover": "isDragOver() ? \"\" : null", "attr.data-disabled": "disabled() ? \"\" : null" } }, providers: [provideFileDropzoneState()], exportAs: ["ngpFileDropzone"], ngImport: i0 }); }
168
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.8", type: NgpFileDropzone, isStandalone: true, selector: "[ngpFileDropzone]", inputs: { fileTypes: { classPropertyName: "fileTypes", publicName: "ngpFileDropzoneFileTypes", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "ngpFileDropzoneMultiple", isSignal: true, isRequired: false, transformFunction: null }, directory: { classPropertyName: "directory", publicName: "ngpFileDropzoneDirectory", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpFileDropzoneDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selected: "ngpFileDropzoneSelected", rejected: "ngpFileDropzoneRejected", dragOver: "ngpFileDropzoneDragOver" }, host: { listeners: { "dragenter": "onDragEnter($event)", "dragover": "onDragOver($event)", "dragleave": "onDragLeave($event)", "drop": "onDrop($event)" }, properties: { "attr.data-dragover": "isDragOver() ? \"\" : null", "attr.data-disabled": "disabled() ? \"\" : null" } }, providers: [provideFileDropzoneState()], exportAs: ["ngpFileDropzone"], ngImport: i0 }); }
127
169
  }
128
170
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgpFileDropzone, decorators: [{
129
171
  type: Directive,
@@ -219,11 +261,17 @@ class NgpFileUpload {
219
261
  alias: 'ngpFileUploadSelected',
220
262
  });
221
263
  /**
222
- * Emits when the user selects files.
264
+ * Emits when the user cancel the file selection.
223
265
  */
224
266
  this.canceled = output({
225
267
  alias: 'ngpFileUploadCanceled',
226
268
  });
269
+ /**
270
+ * Emits when uploaded files are rejected because they do not match the allowed {@link fileTypes}.
271
+ */
272
+ this.rejected = output({
273
+ alias: 'ngpFileUploadRejected',
274
+ });
227
275
  /**
228
276
  * Emits when the user drags a file over the file upload.
229
277
  */
@@ -305,12 +353,19 @@ class NgpFileUpload {
305
353
  event.preventDefault();
306
354
  this.isDragOver.set(false);
307
355
  this.dragOver.emit(false);
308
- if (event.dataTransfer?.files) {
309
- this.selected.emit(event.dataTransfer.files);
356
+ const fileList = event.dataTransfer?.files;
357
+ if (fileList) {
358
+ const filteredFiles = fileDropFilter(fileList, this.state.fileTypes(), this.state.multiple());
359
+ if (filteredFiles) {
360
+ this.selected.emit(filteredFiles);
361
+ }
362
+ else {
363
+ this.rejected.emit();
364
+ }
310
365
  }
311
366
  }
312
367
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgpFileUpload, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
313
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.8", type: NgpFileUpload, isStandalone: true, selector: "[ngpFileUpload]", inputs: { fileTypes: { classPropertyName: "fileTypes", publicName: "ngpFileUploadFileTypes", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "ngpFileUploadMultiple", isSignal: true, isRequired: false, transformFunction: null }, directory: { classPropertyName: "directory", publicName: "ngpFileUploadDirectory", isSignal: true, isRequired: false, transformFunction: null }, dragAndDrop: { classPropertyName: "dragAndDrop", publicName: "ngpFileUploadDragDrop", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpFileUploadDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selected: "ngpFileUploadSelected", canceled: "ngpFileUploadCanceled", dragOver: "ngpFileUploadDragOver" }, host: { listeners: { "click": "showFileDialog()", "dragenter": "onDragEnter($event)", "dragover": "onDragOver($event)", "dragleave": "onDragLeave($event)", "drop": "onDrop($event)" }, properties: { "attr.data-disabled": "state.disabled() ? \"\" : null", "attr.data-dragover": "isDragOver() ? \"\" : null" } }, providers: [provideFileUploadState()], exportAs: ["ngpFileUpload"], ngImport: i0 }); }
368
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.8", type: NgpFileUpload, isStandalone: true, selector: "[ngpFileUpload]", inputs: { fileTypes: { classPropertyName: "fileTypes", publicName: "ngpFileUploadFileTypes", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "ngpFileUploadMultiple", isSignal: true, isRequired: false, transformFunction: null }, directory: { classPropertyName: "directory", publicName: "ngpFileUploadDirectory", isSignal: true, isRequired: false, transformFunction: null }, dragAndDrop: { classPropertyName: "dragAndDrop", publicName: "ngpFileUploadDragDrop", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpFileUploadDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selected: "ngpFileUploadSelected", canceled: "ngpFileUploadCanceled", rejected: "ngpFileUploadRejected", dragOver: "ngpFileUploadDragOver" }, host: { listeners: { "click": "showFileDialog()", "dragenter": "onDragEnter($event)", "dragover": "onDragOver($event)", "dragleave": "onDragLeave($event)", "drop": "onDrop($event)" }, properties: { "attr.data-disabled": "state.disabled() ? \"\" : null", "attr.data-dragover": "isDragOver() ? \"\" : null" } }, providers: [provideFileUploadState()], exportAs: ["ngpFileUpload"], ngImport: i0 }); }
314
369
  }
315
370
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgpFileUpload, decorators: [{
316
371
  type: Directive,
@@ -1 +1 @@
1
- {"version":3,"file":"ng-primitives-file-upload.mjs","sources":["../../../../packages/ng-primitives/file-upload/src/file-dropzone/file-dropzone-state.ts","../../../../packages/ng-primitives/file-upload/src/file-dropzone/file-dropzone.ts","../../../../packages/ng-primitives/file-upload/src/file-upload/file-upload-state.ts","../../../../packages/ng-primitives/file-upload/src/file-upload/file-upload.ts","../../../../packages/ng-primitives/file-upload/src/ng-primitives-file-upload.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpFileDropzone } from './file-dropzone';\n\n/**\n * The state token for the FileDropzone primitive.\n */\nexport const NgpFileDropzoneStateToken = createStateToken<NgpFileDropzone>('FileDropzone');\n\n/**\n * Provides the FileDropzone state.\n */\nexport const provideFileDropzoneState = createStateProvider(NgpFileDropzoneStateToken);\n\n/**\n * Injects the FileDropzone state.\n */\nexport const injectFileDropzoneState = createStateInjector(NgpFileDropzoneStateToken);\n\n/**\n * The FileDropzone state registration function.\n */\nexport const fileDropzoneState = createState(NgpFileDropzoneStateToken);\n","import { BooleanInput, coerceStringArray } from '@angular/cdk/coercion';\nimport {\n booleanAttribute,\n Directive,\n ElementRef,\n HostListener,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\nimport { setupHover } from 'ng-primitives/internal';\nimport { fileDropzoneState, provideFileDropzoneState } from './file-dropzone-state';\n\n/**\n * Capture files dropped on the element.\n */\n@Directive({\n selector: '[ngpFileDropzone]',\n exportAs: 'ngpFileDropzone',\n providers: [provideFileDropzoneState()],\n host: {\n '[attr.data-dragover]': 'isDragOver() ? \"\" : null',\n '[attr.data-disabled]': 'disabled() ? \"\" : null',\n },\n})\nexport class NgpFileDropzone {\n /**\n * Access the host element.\n */\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * The accepted file types. This can be an array of strings or a comma-separated string.\n * Accepted types can either be file extensions (e.g. `.jpg`) or MIME types (e.g. `image/jpeg`).\n */\n readonly fileTypes = input<string[], string | string[]>(undefined, {\n alias: 'ngpFileDropzoneFileTypes',\n transform: types => coerceStringArray(types, ','),\n });\n\n /**\n * Whether to allow multiple files to be selected.\n */\n readonly multiple = input<boolean, BooleanInput>(false, {\n alias: 'ngpFileDropzoneMultiple',\n transform: booleanAttribute,\n });\n\n /**\n * Whether to allow the user to select directories.\n */\n readonly directory = input<boolean, BooleanInput>(false, {\n alias: 'ngpFileDropzoneDirectory',\n transform: booleanAttribute,\n });\n\n /**\n * Whether the file upload is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpFileDropzoneDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Emits when the user selects files.\n */\n readonly selected = output<FileList | null>({\n alias: 'ngpFileDropzoneSelected',\n });\n\n /**\n * Emits when the user drags a file over the file upload.\n */\n readonly dragOver = output<boolean>({\n alias: 'ngpFileDropzoneDragOver',\n });\n\n /**\n * Whether the user is currently dragging a file over the file upload.\n */\n protected readonly isDragOver = signal<boolean>(false);\n\n /**\n * The file upload state.\n */\n private readonly state = fileDropzoneState<NgpFileDropzone>(this);\n\n constructor() {\n setupHover({ disabled: this.state.disabled });\n }\n\n @HostListener('dragenter', ['$event'])\n protected onDragEnter(event: DragEvent): void {\n if (this.state.disabled()) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n this.isDragOver.set(true);\n this.dragOver.emit(true);\n }\n\n @HostListener('dragover', ['$event'])\n protected onDragOver(event: DragEvent): void {\n if (this.state.disabled()) {\n return;\n }\n\n event.stopPropagation();\n event.preventDefault();\n this.isDragOver.set(true);\n }\n\n @HostListener('dragleave', ['$event'])\n protected onDragLeave(event: DragEvent): void {\n if (this.state.disabled() || !this.isDragOver()) {\n return;\n }\n\n // if the element we are dragging over is a child of the file upload, ignore the event\n if (this.elementRef.nativeElement.contains(event.relatedTarget as Node)) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n this.isDragOver.set(false);\n this.dragOver.emit(false);\n }\n\n @HostListener('drop', ['$event'])\n protected onDrop(event: DragEvent): void {\n if (this.state.disabled()) {\n return;\n }\n\n event.preventDefault();\n this.isDragOver.set(false);\n this.dragOver.emit(false);\n\n if (event.dataTransfer?.files) {\n this.selected.emit(event.dataTransfer.files);\n }\n }\n}\n","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpFileUpload } from './file-upload';\n\n/**\n * The state token for the FileUpload primitive.\n */\nexport const NgpFileUploadStateToken = createStateToken<NgpFileUpload>('FileUpload');\n\n/**\n * Provides the FileUpload state.\n */\nexport const provideFileUploadState = createStateProvider(NgpFileUploadStateToken);\n\n/**\n * Injects the FileUpload state.\n */\nexport const injectFileUploadState = createStateInjector(NgpFileUploadStateToken);\n\n/**\n * The FileUpload state registration function.\n */\nexport const fileUploadState = createState(NgpFileUploadStateToken);\n","import { BooleanInput, coerceStringArray } from '@angular/cdk/coercion';\nimport {\n booleanAttribute,\n Directive,\n ElementRef,\n HostListener,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\nimport { setupInteractions } from 'ng-primitives/internal';\nimport { fileUploadState, provideFileUploadState } from './file-upload-state';\n\n/**\n * A directive that allows you to turn any element into a file upload trigger.\n */\n@Directive({\n selector: '[ngpFileUpload]',\n exportAs: 'ngpFileUpload',\n providers: [provideFileUploadState()],\n host: {\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n '[attr.data-dragover]': 'isDragOver() ? \"\" : null',\n },\n})\nexport class NgpFileUpload {\n /**\n * Access the host element.\n */\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * The accepted file types. This can be an array of strings or a comma-separated string.\n * Accepted types can either be file extensions (e.g. `.jpg`) or MIME types (e.g. `image/jpeg`).\n */\n readonly fileTypes = input<string[], string | string[]>(undefined, {\n alias: 'ngpFileUploadFileTypes',\n transform: types => coerceStringArray(types, ','),\n });\n\n /**\n * Whether to allow multiple files to be selected.\n */\n readonly multiple = input<boolean, BooleanInput>(false, {\n alias: 'ngpFileUploadMultiple',\n transform: booleanAttribute,\n });\n\n /**\n * Whether to allow the user to select directories.\n */\n readonly directory = input<boolean, BooleanInput>(false, {\n alias: 'ngpFileUploadDirectory',\n transform: booleanAttribute,\n });\n\n /**\n * Whether drag-and-drop is enabled.\n */\n readonly dragAndDrop = input<boolean, BooleanInput>(true, {\n alias: 'ngpFileUploadDragDrop',\n transform: booleanAttribute,\n });\n\n /**\n * Whether the file upload is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpFileUploadDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Emits when the user selects files.\n */\n readonly selected = output<FileList | null>({\n alias: 'ngpFileUploadSelected',\n });\n\n /**\n * Emits when the user selects files.\n */\n readonly canceled = output<void>({\n alias: 'ngpFileUploadCanceled',\n });\n\n /**\n * Emits when the user drags a file over the file upload.\n */\n readonly dragOver = output<boolean>({\n alias: 'ngpFileUploadDragOver',\n });\n\n /**\n * Whether the user is currently dragging a file over the file upload.\n */\n protected readonly isDragOver = signal<boolean>(false);\n\n /**\n * Store the file input element.\n */\n private input: HTMLInputElement = document.createElement('input');\n\n /**\n * The file upload state.\n */\n protected readonly state = fileUploadState<NgpFileUpload>(this);\n\n constructor() {\n setupInteractions({\n hover: true,\n press: true,\n focusVisible: true,\n disabled: this.state.disabled,\n });\n this.input.type = 'file';\n this.input.addEventListener('change', () => {\n this.selected.emit(this.input.files);\n // clear the input value to allow re-uploading the same file\n this.input.value = '';\n });\n this.input.addEventListener('cancel', () => this.canceled.emit());\n }\n\n @HostListener('click')\n protected showFileDialog(): void {\n if (this.state.disabled()) {\n return;\n }\n\n const fileTypes = this.state.fileTypes()?.join(',');\n\n if (fileTypes) {\n this.input.accept = fileTypes;\n }\n\n this.input.multiple = this.state.multiple();\n this.input.webkitdirectory = this.state.directory();\n this.input.click();\n }\n\n @HostListener('dragenter', ['$event'])\n protected onDragEnter(event: DragEvent): void {\n if (this.state.disabled() || !this.state.dragAndDrop()) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n this.isDragOver.set(true);\n this.dragOver.emit(true);\n }\n\n @HostListener('dragover', ['$event'])\n protected onDragOver(event: DragEvent): void {\n if (this.state.disabled() || !this.state.dragAndDrop()) {\n return;\n }\n\n event.stopPropagation();\n event.preventDefault();\n this.isDragOver.set(true);\n }\n\n @HostListener('dragleave', ['$event'])\n protected onDragLeave(event: DragEvent): void {\n if (this.state.disabled() || !this.state.dragAndDrop() || !this.isDragOver()) {\n return;\n }\n\n // if the element we are dragging over is a child of the file upload, ignore the event\n if (this.elementRef.nativeElement.contains(event.relatedTarget as Node)) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n this.isDragOver.set(false);\n this.dragOver.emit(false);\n }\n\n @HostListener('drop', ['$event'])\n protected onDrop(event: DragEvent): void {\n if (this.state.disabled() || !this.state.dragAndDrop()) {\n return;\n }\n\n event.preventDefault();\n this.isDragOver.set(false);\n this.dragOver.emit(false);\n\n if (event.dataTransfer?.files) {\n this.selected.emit(event.dataTransfer.files);\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAQA;;AAEG;AACI,MAAM,yBAAyB,GAAG,gBAAgB,CAAkB,cAAc,CAAC;AAE1F;;AAEG;MACU,wBAAwB,GAAG,mBAAmB,CAAC,yBAAyB;AAErF;;AAEG;MACU,uBAAuB,GAAG,mBAAmB,CAAC,yBAAyB;AAEpF;;AAEG;AACI,MAAM,iBAAiB,GAAG,WAAW,CAAC,yBAAyB,CAAC;;ACZvE;;AAEG;MAUU,eAAe,CAAA;AA+D1B,IAAA,WAAA,GAAA;AA9DA;;AAEG;AACc,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,CAA0B,UAAU,CAAC;AAEzE;;;AAGG;AACM,QAAA,IAAA,CAAA,SAAS,GAAG,KAAK,CAA8B,SAAS,EAAE;AACjE,YAAA,KAAK,EAAE,0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,uBAAA,EAAA,EAAA,IAAA,EAAA,EAAA,SAAA,EAAA,EAAA,OAAA,EAAA,kBAAA,EAAA,WAAA,EAAA,qBAAA,EAAA,UAAA,EAAA,oBAAA,EAAA,WAAA,EAAA,qBAAA,EAAA,MAAA,EAAA,gBAAA,EAAA,EAAA,UAAA,EAAA,EAAA,oBAAA,EAAA,gCAAA,EAAA,oBAAA,EAAA,4BAAA,EAAA,EAAA,EAAA,SAAA,EAAA,CAAC,sBAAsB,EAAE,CAAC,EAAA,QAAA,EAAA,CAAA,eAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAM1B,aAAa,EAAA,UAAA,EAAA,CAAA;kBATzB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,iBAAiB;AAC3B,oBAAA,QAAQ,EAAE,eAAe;AACzB,oBAAA,SAAS,EAAE,CAAC,sBAAsB,EAAE,CAAC;AACrC,oBAAA,IAAI,EAAE;AACJ,wBAAA,sBAAsB,EAAE,8BAA8B;AACtD,wBAAA,sBAAsB,EAAE,0BAA0B;AACnD,qBAAA;AACF,iBAAA;wDAqGW,cAAc,EAAA,CAAA;sBADvB,YAAY;uBAAC,OAAO;gBAkBX,WAAW,EAAA,CAAA;sBADpB,YAAY;uBAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;gBAa3B,UAAU,EAAA,CAAA;sBADnB,YAAY;uBAAC,UAAU,EAAE,CAAC,QAAQ,CAAC;gBAY1B,WAAW,EAAA,CAAA;sBADpB,YAAY;uBAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;gBAkB3B,MAAM,EAAA,CAAA;sBADf,YAAY;uBAAC,MAAM,EAAE,CAAC,QAAQ,CAAC;;;ACtLlC;;AAEG;;;;"}
1
+ {"version":3,"file":"ng-primitives-file-upload.mjs","sources":["../../../../packages/ng-primitives/file-upload/src/file-dropzone/file-drop-filter.ts","../../../../packages/ng-primitives/file-upload/src/file-dropzone/file-dropzone-state.ts","../../../../packages/ng-primitives/file-upload/src/file-dropzone/file-dropzone.ts","../../../../packages/ng-primitives/file-upload/src/file-upload/file-upload-state.ts","../../../../packages/ng-primitives/file-upload/src/file-upload/file-upload.ts","../../../../packages/ng-primitives/file-upload/src/ng-primitives-file-upload.ts"],"sourcesContent":["export function fileDropFilter(\n fileList: FileList,\n acceptedTypes: string[] | undefined,\n multiple: boolean,\n) {\n const validFiles = Array.from(fileList).filter(file => isFileTypeAccepted(file, acceptedTypes));\n\n const limitedFiles = multiple ? validFiles : validFiles.slice(0, 1);\n\n return limitedFiles.length > 0 ? filesToFileList(limitedFiles) : null;\n}\n\nexport function isFileTypeAccepted(file: File, acceptedTypes: string[] | undefined) {\n // allow all file types if no types are specified\n if (!acceptedTypes || acceptedTypes.length === 0) return true;\n\n const mimeType = file.type;\n const fileName = file.name.toLowerCase();\n\n return acceptedTypes.some(type => {\n type = type.toLowerCase();\n\n if (type.startsWith('.')) {\n return fileName.endsWith(type);\n }\n\n if (type.endsWith('/*')) {\n const baseType = type.replace('/*', '');\n return mimeType.startsWith(baseType);\n }\n\n return mimeType === type;\n });\n}\n\nfunction filesToFileList(files: File[]): FileList {\n const dataTransfer = new DataTransfer();\n files.forEach(file => dataTransfer.items.add(file));\n return dataTransfer.files;\n}\n","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpFileDropzone } from './file-dropzone';\n\n/**\n * The state token for the FileDropzone primitive.\n */\nexport const NgpFileDropzoneStateToken = createStateToken<NgpFileDropzone>('FileDropzone');\n\n/**\n * Provides the FileDropzone state.\n */\nexport const provideFileDropzoneState = createStateProvider(NgpFileDropzoneStateToken);\n\n/**\n * Injects the FileDropzone state.\n */\nexport const injectFileDropzoneState = createStateInjector(NgpFileDropzoneStateToken);\n\n/**\n * The FileDropzone state registration function.\n */\nexport const fileDropzoneState = createState(NgpFileDropzoneStateToken);\n","import { BooleanInput, coerceStringArray } from '@angular/cdk/coercion';\nimport {\n booleanAttribute,\n Directive,\n ElementRef,\n HostListener,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\nimport { setupHover } from 'ng-primitives/internal';\nimport { fileDropFilter } from './file-drop-filter';\nimport { fileDropzoneState, provideFileDropzoneState } from './file-dropzone-state';\n\n/**\n * Capture files dropped on the element.\n */\n@Directive({\n selector: '[ngpFileDropzone]',\n exportAs: 'ngpFileDropzone',\n providers: [provideFileDropzoneState()],\n host: {\n '[attr.data-dragover]': 'isDragOver() ? \"\" : null',\n '[attr.data-disabled]': 'disabled() ? \"\" : null',\n },\n})\nexport class NgpFileDropzone {\n /**\n * Access the host element.\n */\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * The accepted file types. This can be an array of strings or a comma-separated string.\n * Accepted types can either be file extensions (e.g. `.jpg`) or MIME types (e.g. `image/jpeg`).\n */\n readonly fileTypes = input<string[], string | string[]>(undefined, {\n alias: 'ngpFileDropzoneFileTypes',\n transform: types => coerceStringArray(types, ','),\n });\n\n /**\n * Whether to allow multiple files to be selected.\n */\n readonly multiple = input<boolean, BooleanInput>(false, {\n alias: 'ngpFileDropzoneMultiple',\n transform: booleanAttribute,\n });\n\n /**\n * Whether to allow the user to select directories.\n */\n readonly directory = input<boolean, BooleanInput>(false, {\n alias: 'ngpFileDropzoneDirectory',\n transform: booleanAttribute,\n });\n\n /**\n * Whether the file upload is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpFileDropzoneDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Emits when the user selects files.\n */\n readonly selected = output<FileList | null>({\n alias: 'ngpFileDropzoneSelected',\n });\n\n /**\n * Emits when uploaded files are rejected because they do not match the allowed {@link fileTypes}.\n */\n readonly rejected = output<void>({\n alias: 'ngpFileDropzoneRejected',\n });\n\n /**\n * Emits when the user drags a file over the file upload.\n */\n readonly dragOver = output<boolean>({\n alias: 'ngpFileDropzoneDragOver',\n });\n\n /**\n * Whether the user is currently dragging a file over the file upload.\n */\n protected readonly isDragOver = signal<boolean>(false);\n\n /**\n * The file upload state.\n */\n private readonly state = fileDropzoneState<NgpFileDropzone>(this);\n\n constructor() {\n setupHover({ disabled: this.state.disabled });\n }\n\n @HostListener('dragenter', ['$event'])\n protected onDragEnter(event: DragEvent): void {\n if (this.state.disabled()) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n this.isDragOver.set(true);\n this.dragOver.emit(true);\n }\n\n @HostListener('dragover', ['$event'])\n protected onDragOver(event: DragEvent): void {\n if (this.state.disabled()) {\n return;\n }\n\n event.stopPropagation();\n event.preventDefault();\n this.isDragOver.set(true);\n }\n\n @HostListener('dragleave', ['$event'])\n protected onDragLeave(event: DragEvent): void {\n if (this.state.disabled() || !this.isDragOver()) {\n return;\n }\n\n // if the element we are dragging over is a child of the file upload, ignore the event\n if (this.elementRef.nativeElement.contains(event.relatedTarget as Node)) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n this.isDragOver.set(false);\n this.dragOver.emit(false);\n }\n\n @HostListener('drop', ['$event'])\n protected onDrop(event: DragEvent): void {\n if (this.state.disabled()) {\n return;\n }\n\n event.preventDefault();\n this.isDragOver.set(false);\n this.dragOver.emit(false);\n\n const fileList = event.dataTransfer?.files;\n if (fileList) {\n const filteredFiles = fileDropFilter(fileList, this.state.fileTypes(), this.state.multiple());\n\n if (filteredFiles) {\n this.selected.emit(filteredFiles);\n } else {\n this.rejected.emit();\n }\n }\n }\n}\n","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpFileUpload } from './file-upload';\n\n/**\n * The state token for the FileUpload primitive.\n */\nexport const NgpFileUploadStateToken = createStateToken<NgpFileUpload>('FileUpload');\n\n/**\n * Provides the FileUpload state.\n */\nexport const provideFileUploadState = createStateProvider(NgpFileUploadStateToken);\n\n/**\n * Injects the FileUpload state.\n */\nexport const injectFileUploadState = createStateInjector(NgpFileUploadStateToken);\n\n/**\n * The FileUpload state registration function.\n */\nexport const fileUploadState = createState(NgpFileUploadStateToken);\n","import { BooleanInput, coerceStringArray } from '@angular/cdk/coercion';\nimport {\n booleanAttribute,\n Directive,\n ElementRef,\n HostListener,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\nimport { setupInteractions } from 'ng-primitives/internal';\nimport { fileDropFilter } from '../file-dropzone/file-drop-filter';\nimport { fileUploadState, provideFileUploadState } from './file-upload-state';\n\n/**\n * A directive that allows you to turn any element into a file upload trigger.\n */\n@Directive({\n selector: '[ngpFileUpload]',\n exportAs: 'ngpFileUpload',\n providers: [provideFileUploadState()],\n host: {\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n '[attr.data-dragover]': 'isDragOver() ? \"\" : null',\n },\n})\nexport class NgpFileUpload {\n /**\n * Access the host element.\n */\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * The accepted file types. This can be an array of strings or a comma-separated string.\n * Accepted types can either be file extensions (e.g. `.jpg`) or MIME types (e.g. `image/jpeg`).\n */\n readonly fileTypes = input<string[], string | string[]>(undefined, {\n alias: 'ngpFileUploadFileTypes',\n transform: types => coerceStringArray(types, ','),\n });\n\n /**\n * Whether to allow multiple files to be selected.\n */\n readonly multiple = input<boolean, BooleanInput>(false, {\n alias: 'ngpFileUploadMultiple',\n transform: booleanAttribute,\n });\n\n /**\n * Whether to allow the user to select directories.\n */\n readonly directory = input<boolean, BooleanInput>(false, {\n alias: 'ngpFileUploadDirectory',\n transform: booleanAttribute,\n });\n\n /**\n * Whether drag-and-drop is enabled.\n */\n readonly dragAndDrop = input<boolean, BooleanInput>(true, {\n alias: 'ngpFileUploadDragDrop',\n transform: booleanAttribute,\n });\n\n /**\n * Whether the file upload is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpFileUploadDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Emits when the user selects files.\n */\n readonly selected = output<FileList | null>({\n alias: 'ngpFileUploadSelected',\n });\n\n /**\n * Emits when the user cancel the file selection.\n */\n readonly canceled = output<void>({\n alias: 'ngpFileUploadCanceled',\n });\n\n /**\n * Emits when uploaded files are rejected because they do not match the allowed {@link fileTypes}.\n */\n readonly rejected = output<void>({\n alias: 'ngpFileUploadRejected',\n });\n\n /**\n * Emits when the user drags a file over the file upload.\n */\n readonly dragOver = output<boolean>({\n alias: 'ngpFileUploadDragOver',\n });\n\n /**\n * Whether the user is currently dragging a file over the file upload.\n */\n protected readonly isDragOver = signal<boolean>(false);\n\n /**\n * Store the file input element.\n */\n private input: HTMLInputElement = document.createElement('input');\n\n /**\n * The file upload state.\n */\n protected readonly state = fileUploadState<NgpFileUpload>(this);\n\n constructor() {\n setupInteractions({\n hover: true,\n press: true,\n focusVisible: true,\n disabled: this.state.disabled,\n });\n this.input.type = 'file';\n this.input.addEventListener('change', () => {\n this.selected.emit(this.input.files);\n // clear the input value to allow re-uploading the same file\n this.input.value = '';\n });\n this.input.addEventListener('cancel', () => this.canceled.emit());\n }\n\n @HostListener('click')\n protected showFileDialog(): void {\n if (this.state.disabled()) {\n return;\n }\n\n const fileTypes = this.state.fileTypes()?.join(',');\n\n if (fileTypes) {\n this.input.accept = fileTypes;\n }\n\n this.input.multiple = this.state.multiple();\n this.input.webkitdirectory = this.state.directory();\n this.input.click();\n }\n\n @HostListener('dragenter', ['$event'])\n protected onDragEnter(event: DragEvent): void {\n if (this.state.disabled() || !this.state.dragAndDrop()) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n this.isDragOver.set(true);\n this.dragOver.emit(true);\n }\n\n @HostListener('dragover', ['$event'])\n protected onDragOver(event: DragEvent): void {\n if (this.state.disabled() || !this.state.dragAndDrop()) {\n return;\n }\n\n event.stopPropagation();\n event.preventDefault();\n this.isDragOver.set(true);\n }\n\n @HostListener('dragleave', ['$event'])\n protected onDragLeave(event: DragEvent): void {\n if (this.state.disabled() || !this.state.dragAndDrop() || !this.isDragOver()) {\n return;\n }\n\n // if the element we are dragging over is a child of the file upload, ignore the event\n if (this.elementRef.nativeElement.contains(event.relatedTarget as Node)) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n this.isDragOver.set(false);\n this.dragOver.emit(false);\n }\n\n @HostListener('drop', ['$event'])\n protected onDrop(event: DragEvent): void {\n if (this.state.disabled() || !this.state.dragAndDrop()) {\n return;\n }\n\n event.preventDefault();\n this.isDragOver.set(false);\n this.dragOver.emit(false);\n\n const fileList = event.dataTransfer?.files;\n if (fileList) {\n const filteredFiles = fileDropFilter(fileList, this.state.fileTypes(), this.state.multiple());\n\n if (filteredFiles) {\n this.selected.emit(filteredFiles);\n } else {\n this.rejected.emit();\n }\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;SAAgB,cAAc,CAC5B,QAAkB,EAClB,aAAmC,EACnC,QAAiB,EAAA;IAEjB,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,kBAAkB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;AAE/F,IAAA,MAAM,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;AAEnE,IAAA,OAAO,YAAY,CAAC,MAAM,GAAG,CAAC,GAAG,eAAe,CAAC,YAAY,CAAC,GAAG,IAAI;AACvE;AAEgB,SAAA,kBAAkB,CAAC,IAAU,EAAE,aAAmC,EAAA;;AAEhF,IAAA,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;AAE7D,IAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI;IAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;AAExC,IAAA,OAAO,aAAa,CAAC,IAAI,CAAC,IAAI,IAAG;AAC/B,QAAA,IAAI,GAAG,IAAI,CA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AAE,8BAA8B;AACtD,wBAAA,sBAAsB,EAAE,0BAA0B;AACnD,qBAAA;AACF,iBAAA;wDA4GW,cAAc,EAAA,CAAA;sBADvB,YAAY;uBAAC,OAAO;gBAkBX,WAAW,EAAA,CAAA;sBADpB,YAAY;uBAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;gBAa3B,UAAU,EAAA,CAAA;sBADnB,YAAY;uBAAC,UAAU,EAAE,CAAC,QAAQ,CAAC;gBAY1B,WAAW,EAAA,CAAA;sBADpB,YAAY;uBAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;gBAkB3B,MAAM,EAAA,CAAA;sBADf,YAAY;uBAAC,MAAM,EAAE,CAAC,QAAQ,CAAC;;;AC9LlC;;AAEG;;;;"}
@@ -1,8 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, effect, Directive, computed, booleanAttribute, signal, contentChild, inject, ElementRef, HostListener } from '@angular/core';
2
+ import { input, effect, Directive, computed, booleanAttribute, signal, afterRenderEffect, contentChild, inject, ElementRef, HostListener } from '@angular/core';
3
3
  import { uniqueId, onBooleanChange, onChange } from 'ng-primitives/utils';
4
4
  import { createStateToken, createStateProvider, createStateInjector, createState } from 'ng-primitives/state';
5
- import { syncState } from 'ng-primitives/internal';
5
+ import { injectElementRef, explicitEffect } from 'ng-primitives/internal';
6
6
  import { NgControl } from '@angular/forms';
7
7
 
8
8
  /**
@@ -141,14 +141,6 @@ const injectFormControlState = createStateInjector(NgpFormControlStateToken);
141
141
  * The FormControl state registration function.
142
142
  */
143
143
  const formControlState = createState(NgpFormControlStateToken);
144
- /**
145
- * Sync the form control state with control state.
146
- * @param disabled The disabled state of the control.
147
- */
148
- function syncFormControl({ disabled }) {
149
- const formControl = injectFormControlState();
150
- syncState(disabled, formControl().disabled);
151
- }
152
144
 
153
145
  /**
154
146
  * Typically this primitive would be not be used directly, but instead a more specific form control primitive would be used (e.g. `ngpInput`). All of our form control primitives use `ngpFormControl` internally so they will have the same accessibility features as described below.
@@ -168,29 +160,15 @@ class NgpFormControl {
168
160
  alias: 'ngpFormControlDisabled',
169
161
  transform: booleanAttribute,
170
162
  });
171
- /**
172
- * Access the form field that the form control is associated with.
173
- */
174
- this.formField = injectFormFieldState({ optional: true });
175
- /**
176
- * Determine the aria-labelledby attribute value.
177
- */
178
- this.ariaLabelledBy = computed(() => this.formField()?.labels().join(' '));
179
- /**
180
- * Determine the aria-describedby attribute value.
181
- */
182
- this.ariaDescribedBy = computed(() => this.formField()?.descriptions().join(' '));
183
163
  /**
184
164
  * The state of the form control.
185
165
  */
186
166
  this.state = formControlState(this);
187
- effect(onCleanup => {
188
- this.formField()?.setFormControl(this.state.id());
189
- onCleanup(() => this.formField()?.removeFormControl());
190
- });
167
+ // Sync the form control state with the control state.
168
+ setupFormControl({ id: this.state.id, disabled: this.state.disabled });
191
169
  }
192
170
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgpFormControl, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
193
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.8", type: NgpFormControl, isStandalone: true, selector: "[ngpFormControl]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpFormControlDisabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "id": "id()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.aria-describedby": "ariaDescribedBy()", "attr.data-invalid": "formField()?.invalid() ? \"\" : null", "attr.data-valid": "formField()?.valid() ? \"\" : null", "attr.data-touched": "formField()?.touched() ? \"\" : null", "attr.data-pristine": "formField()?.pristine() ? \"\" : null", "attr.data-dirty": "formField()?.dirty() ? \"\" : null", "attr.data-pending": "formField()?.pending() ? \"\" : null", "attr.data-disabled": "formField()?.disabled() || state.disabled() ? \"\" : null" } }, providers: [provideFormControlState()], exportAs: ["ngpFormControl"], ngImport: i0 }); }
171
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.8", type: NgpFormControl, isStandalone: true, selector: "[ngpFormControl]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpFormControlDisabled", isSignal: true, isRequired: false, transformFunction: null } }, providers: [provideFormControlState()], exportAs: ["ngpFormControl"], ngImport: i0 }); }
194
172
  }
195
173
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: NgpFormControl, decorators: [{
196
174
  type: Directive,
@@ -198,20 +176,65 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
198
176
  selector: '[ngpFormControl]',
199
177
  exportAs: 'ngpFormControl',
200
178
  providers: [provideFormControlState()],
201
- host: {
202
- '[id]': 'id()',
203
- '[attr.aria-labelledby]': 'ariaLabelledBy()',
204
- '[attr.aria-describedby]': 'ariaDescribedBy()',
205
- '[attr.data-invalid]': 'formField()?.invalid() ? "" : null',
206
- '[attr.data-valid]': 'formField()?.valid() ? "" : null',
207
- '[attr.data-touched]': 'formField()?.touched() ? "" : null',
208
- '[attr.data-pristine]': 'formField()?.pristine() ? "" : null',
209
- '[attr.data-dirty]': 'formField()?.dirty() ? "" : null',
210
- '[attr.data-pending]': 'formField()?.pending() ? "" : null',
211
- '[attr.data-disabled]': 'formField()?.disabled() || state.disabled() ? "" : null',
212
- },
213
179
  }]
214
180
  }], ctorParameters: () => [] });
181
+ function setupFormControl({ id = signal(uniqueId('ngp-form-control')), disabled = signal(false), }) {
182
+ const element = injectElementRef().nativeElement;
183
+ // Access the form field that the form control is associated with.
184
+ const formField = injectFormFieldState({ optional: true });
185
+ // Determine the aria-labelledby attribute value.
186
+ const ariaLabelledBy = computed(() => formField()?.labels().join(' '));
187
+ // Determine the aria-describedby attribute value.
188
+ const ariaDescribedBy = computed(() => formField()?.descriptions().join(' '));
189
+ explicitEffect([id], ([id], onCleanup) => {
190
+ formField()?.setFormControl(id);
191
+ onCleanup(() => formField()?.removeFormControl());
192
+ });
193
+ afterRenderEffect({
194
+ write: () => {
195
+ setAttribute(element, 'id', id());
196
+ setAttribute(element, 'aria-labelledby', ariaLabelledBy());
197
+ setAttribute(element, 'aria-describedby', ariaDescribedBy());
198
+ setStateAttribute(element, formField()?.invalid(), 'data-invalid');
199
+ setStateAttribute(element, formField()?.valid(), 'data-valid');
200
+ setStateAttribute(element, formField()?.touched(), 'data-touched');
201
+ setStateAttribute(element, formField()?.pristine(), 'data-pristine');
202
+ setStateAttribute(element, formField()?.dirty(), 'data-dirty');
203
+ setStateAttribute(element, formField()?.pending(), 'data-pending');
204
+ setStateAttribute(element, disabled() || formField()?.disabled(), 'data-disabled');
205
+ },
206
+ });
207
+ }
208
+ /**
209
+ * Sets the attribute on the element. If the value is not empty, the attribute is set to the value.
210
+ * If the value is empty, the attribute is removed.
211
+ * @param element The element to set the attribute on.
212
+ * @param attribute The attribute to set on the element.
213
+ * @param value The value to set on the attribute.
214
+ */
215
+ function setAttribute(element, attribute, value) {
216
+ if (value && value.length > 0) {
217
+ element.setAttribute(attribute, value);
218
+ }
219
+ else {
220
+ element.removeAttribute(attribute);
221
+ }
222
+ }
223
+ /**
224
+ * Sets the attribute on the element based on the state. If the state is true, the attribute
225
+ * is set to an empty string. If the state is false, the attribute is removed.
226
+ * @param element The element to set the attribute on.
227
+ * @param state The state to set the attribute based on.
228
+ * @param attribute The attribute to set on the element.
229
+ */
230
+ function setStateAttribute(element, state, attribute) {
231
+ if (state) {
232
+ element.setAttribute(attribute, '');
233
+ }
234
+ else {
235
+ element.removeAttribute(attribute);
236
+ }
237
+ }
215
238
 
216
239
  /**
217
240
  * The `NgpFormField` directive is a container for form field elements. Any labels, form controls, or descriptions should be placed within this directive.
@@ -476,5 +499,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
476
499
  * Generated bundle index. Do not edit.
477
500
  */
478
501
 
479
- export { NgpDescription, NgpError, NgpFormControl, NgpFormField, NgpLabel, injectFormControlState, injectFormFieldState, provideFormControlState, provideFormFieldState, syncFormControl };
502
+ export { NgpDescription, NgpError, NgpFormControl, NgpFormField, NgpLabel, injectFormControlState, injectFormFieldState, provideFormControlState, provideFormFieldState, setupFormControl };
480
503
  //# sourceMappingURL=ng-primitives-form-field.mjs.map