ng-primitives 0.48.0 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y/visually-hidden/visually-hidden-state.d.ts +1 -36
- package/accordion/accordion/accordion-state.d.ts +1 -12
- package/accordion/accordion-content/accordion-content.d.ts +1 -12
- package/accordion/accordion-item/accordion-item-state.d.ts +1 -12
- package/avatar/avatar/avatar-state.d.ts +1 -5
- package/avatar/avatar-image/avatar-image.d.ts +1 -36
- package/button/button/button-state.d.ts +1 -6
- package/checkbox/checkbox/checkbox-state.d.ts +1 -12
- package/combobox/combobox/combobox-state.d.ts +1 -44
- package/combobox/combobox-button/combobox-button.d.ts +1 -44
- package/combobox/combobox-dropdown/combobox-dropdown.d.ts +1 -44
- package/combobox/combobox-input/combobox-input.d.ts +1 -45
- package/combobox/combobox-option/combobox-option.d.ts +1 -44
- package/dialog/dialog/dialog-state.d.ts +1 -17
- package/fesm2022/ng-primitives-a11y.mjs.map +1 -1
- package/fesm2022/ng-primitives-accordion.mjs.map +1 -1
- package/fesm2022/ng-primitives-avatar.mjs.map +1 -1
- package/fesm2022/ng-primitives-button.mjs.map +1 -1
- package/fesm2022/ng-primitives-checkbox.mjs.map +1 -1
- package/fesm2022/ng-primitives-combobox.mjs.map +1 -1
- package/fesm2022/ng-primitives-date-picker.mjs.map +1 -1
- package/fesm2022/ng-primitives-dialog.mjs.map +1 -1
- package/fesm2022/ng-primitives-file-upload.mjs.map +1 -1
- package/fesm2022/ng-primitives-focus-trap.mjs.map +1 -1
- package/fesm2022/ng-primitives-form-field.mjs +2 -2
- package/fesm2022/ng-primitives-form-field.mjs.map +1 -1
- package/fesm2022/ng-primitives-input.mjs +8 -2
- package/fesm2022/ng-primitives-input.mjs.map +1 -1
- package/fesm2022/ng-primitives-listbox.mjs +3 -1
- package/fesm2022/ng-primitives-listbox.mjs.map +1 -1
- package/fesm2022/ng-primitives-menu.mjs.map +1 -1
- package/fesm2022/ng-primitives-meter.mjs.map +1 -1
- package/fesm2022/ng-primitives-pagination.mjs.map +1 -1
- package/fesm2022/ng-primitives-progress.mjs.map +1 -1
- package/fesm2022/ng-primitives-radio.mjs +8 -2
- package/fesm2022/ng-primitives-radio.mjs.map +1 -1
- package/fesm2022/ng-primitives-roving-focus.mjs.map +1 -1
- package/fesm2022/ng-primitives-search.mjs.map +1 -1
- package/fesm2022/ng-primitives-select.mjs +8 -2
- package/fesm2022/ng-primitives-select.mjs.map +1 -1
- package/fesm2022/ng-primitives-slider.mjs +8 -2
- package/fesm2022/ng-primitives-slider.mjs.map +1 -1
- package/fesm2022/ng-primitives-switch.mjs +8 -2
- package/fesm2022/ng-primitives-switch.mjs.map +1 -1
- package/fesm2022/ng-primitives-tabs.mjs.map +1 -1
- package/fesm2022/ng-primitives-textarea.mjs +11 -2
- package/fesm2022/ng-primitives-textarea.mjs.map +1 -1
- package/fesm2022/ng-primitives-toggle-group.mjs.map +1 -1
- package/fesm2022/ng-primitives-toggle.mjs.map +1 -1
- package/fesm2022/ng-primitives-toolbar.mjs.map +1 -1
- package/fesm2022/ng-primitives-tooltip.mjs.map +1 -1
- package/file-upload/file-dropzone/file-dropzone-state.d.ts +1 -16
- package/file-upload/file-upload/file-upload-state.d.ts +1 -21
- package/focus-trap/focus-trap/focus-trap-state.d.ts +1 -28
- package/form-field/description/description.d.ts +1 -25
- package/form-field/error/error.d.ts +1 -25
- package/form-field/form-control/form-control-state.d.ts +1 -5
- package/form-field/form-control/form-control.d.ts +2 -2
- package/form-field/form-field/form-field-state.d.ts +1 -25
- package/form-field/label/label.d.ts +1 -25
- package/input/input/input-state.d.ts +1 -14
- package/input/input/input.d.ts +5 -1
- package/listbox/listbox/listbox-state.d.ts +1 -25
- package/menu/menu-trigger/menu-trigger-state.d.ts +1 -22
- package/menu/submenu-trigger/submenu-trigger-state.d.ts +1 -20
- package/meter/meter/meter-state.d.ts +1 -9
- package/meter/meter-indicator/meter-indicator.d.ts +1 -9
- package/meter/meter-label/meter-label.d.ts +1 -9
- package/package.json +5 -5
- package/pagination/pagination/pagination-state.d.ts +1 -10
- package/pagination/pagination-button/pagination-button.d.ts +1 -10
- package/pagination/pagination-first/pagination-first.d.ts +1 -10
- package/pagination/pagination-next/pagination-next.d.ts +1 -10
- package/pagination/pagination-previous/pagination-previous.d.ts +1 -10
- package/progress/progress/progress-state.d.ts +1 -12
- package/progress/progress-indicator/progress-indicator.d.ts +1 -12
- package/progress/progress-label/progress-label.d.ts +1 -12
- package/progress/progress-track/progress-track.d.ts +1 -12
- package/progress/progress-value/progress-value.d.ts +1 -12
- package/radio/radio-group/radio-group.d.ts +5 -1
- package/roving-focus/roving-focus-group/roving-focus-group-state.d.ts +1 -19
- package/search/search/search-state.d.ts +1 -9
- package/search/search-clear/search-clear.d.ts +1 -9
- package/select/select/select-state.d.ts +1 -4
- package/select/select/select.d.ts +5 -1
- package/slider/slider/slider-state.d.ts +1 -12
- package/slider/slider/slider.d.ts +5 -1
- package/slider/slider-range/slider-range.d.ts +1 -12
- package/slider/slider-thumb/slider-thumb.d.ts +1 -12
- package/slider/slider-track/slider-track.d.ts +1 -12
- package/switch/switch/switch-state.d.ts +1 -10
- package/switch/switch/switch.d.ts +5 -1
- package/switch/switch-thumb/switch-thumb.d.ts +1 -10
- package/tabs/tab-button/tab-button.d.ts +1 -36
- package/tabs/tab-list/tab-list.d.ts +1 -33
- package/tabs/tab-panel/tab-panel.d.ts +1 -33
- package/tabs/tabset/tabset-state.d.ts +1 -33
- package/textarea/textarea/textarea-state.d.ts +1 -4
- package/textarea/textarea/textarea.d.ts +5 -1
- package/toggle/toggle/toggle-state.d.ts +1 -10
- package/toggle-group/toggle-group/toggle-group-state.d.ts +1 -32
- package/toggle-group/toggle-group-item/toggle-group-item-state.d.ts +1 -22
- package/toolbar/toolbar/toolbar-state.d.ts +1 -23
- package/tooltip/tooltip-trigger/tooltip-trigger-state.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
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 { DOCUMENT } from '@angular/common';\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 document\n */\n private readonly document = inject<Document>(DOCUMENT);\n\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 = this.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,MA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EAAA,CAAA,CAAA;;4FAM1B,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;wDAiHW,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;;;ACpMlC;;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 =\n createStateInjector<NgpFileDropzone>(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<NgpFileUpload>(NgpFileUploadStateToken);\n\n/**\n * The FileUpload state registration function.\n */\nexport const fileUploadState = createState(NgpFileUploadStateToken);\n","import { BooleanInput, coerceStringArray } from '@angular/cdk/coercion';\nimport { DOCUMENT } from '@angular/common';\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 document\n */\n private readonly document = inject<Document>(DOCUMENT);\n\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 = this.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,CAAC,WAAW,EAAE;AAEzB,QAAA,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;AACxB,YAAA,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;;AAGhC,QAAA,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,E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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;;;ACpMlC;;AAEG;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-focus-trap.mjs","sources":["../../../../packages/ng-primitives/focus-trap/src/focus-trap/focus-trap-state.ts","../../../../packages/ng-primitives/focus-trap/src/focus-trap/focus-trap.ts","../../../../packages/ng-primitives/focus-trap/src/ng-primitives-focus-trap.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpFocusTrap } from './focus-trap';\n\n/**\n * The state token for the FocusTrap primitive.\n */\nexport const NgpFocusTrapStateToken = createStateToken<NgpFocusTrap>('FocusTrap');\n\n/**\n * Provides the FocusTrap state.\n */\nexport const provideFocusTrapState = createStateProvider(NgpFocusTrapStateToken);\n\n/**\n * Injects the FocusTrap state.\n */\nexport const injectFocusTrapState = createStateInjector(NgpFocusTrapStateToken);\n\n/**\n * The FocusTrap state registration function.\n */\nexport const focusTrapState = createState(NgpFocusTrapStateToken);\n","import { FocusMonitor, InteractivityChecker } from '@angular/cdk/a11y';\nimport { BooleanInput } from '@angular/cdk/coercion';\nimport {\n afterNextRender,\n booleanAttribute,\n Directive,\n ElementRef,\n HostListener,\n inject,\n Injector,\n input,\n NgZone,\n OnDestroy,\n OnInit,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { NgpOverlay } from 'ng-primitives/portal';\nimport { focusTrapState, provideFocusTrapState } from './focus-trap-state';\n\n/**\n * This implementation is based on the Radix UI FocusScope:\n * https://github.com/radix-ui/primitives/blob/main/packages/react/focus-scope/src/FocusScope.tsx#L306\n */\n\nclass FocusTrap {\n /**\n * Whether the focus trap is active.\n */\n active: boolean = false;\n\n /**\n * Activates the focus trap.\n */\n activate(): void {\n this.active = true;\n }\n\n /**\n * Deactivates the focus trap.\n */\n deactivate(): void {\n this.active = false;\n }\n}\n\nclass FocusTrapStack {\n /**\n * The stack of focus traps.\n */\n private readonly stack: FocusTrap[] = [];\n\n /**\n * Adds a focus trap to the stack.\n */\n add(focusTrap: FocusTrap): void {\n // deactivate the previous focus trap\n this.stack.forEach(t => t.deactivate());\n\n // add the new focus trap and activate it\n this.stack.push(focusTrap);\n focusTrap.activate();\n }\n\n /**\n * Removes a focus trap from the stack.\n */\n remove(focusTrap: FocusTrap): void {\n // remove the focus trap\n const index = this.stack.indexOf(focusTrap);\n\n if (index >= 0) {\n this.stack.splice(index, 1);\n }\n\n // activate the previous focus trap\n const previous = this.stack[this.stack.length - 1];\n\n if (previous) {\n previous.activate();\n }\n }\n}\n\n// create a global stack of focus traps\nconst focusTrapStack = new FocusTrapStack();\n\n/**\n * The `NgpFocusTrap` directive traps focus within the host element.\n */\n@Directive({\n selector: '[ngpFocusTrap]',\n exportAs: 'ngpFocusTrap',\n providers: [provideFocusTrapState()],\n host: {\n '[attr.tabindex]': '-1',\n '[attr.data-focus-trap]': '!disabled() ? \"\" : null',\n },\n})\nexport class NgpFocusTrap implements OnInit, OnDestroy {\n /**\n * Access any parent overlay.\n */\n private readonly overlay = inject(NgpOverlay, { optional: true });\n\n /**\n * Create a new focus trap.\n */\n private readonly focusTrap = new FocusTrap();\n\n /**\n * Access the injector.\n */\n private readonly injector = inject(Injector);\n\n /**\n * Access the focus monitor.\n */\n private readonly focusMonitor = inject(FocusMonitor);\n\n /**\n * Access the interactivity checker.\n */\n private readonly interactivityChecker = inject(InteractivityChecker);\n\n /**\n * Get the focus trap container element.\n */\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Access NgZone to run the focus trap events outside of Angular's zone.\n */\n private readonly ngZone = inject(NgZone);\n\n /**\n * Store the mutation observer.\n */\n private mutationObserver: MutationObserver | null = null;\n\n /**\n * Store the last focused element.\n */\n private lastFocusedElement: HTMLElement | null = null;\n\n /**\n * Whether the focus trap is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpFocusTrapDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * The focus trap state.\n */\n protected readonly state = focusTrapState<NgpFocusTrap>(this);\n\n constructor() {\n // if this is used within an overlay we must disable the focus trap as soon as the overlay is closing\n this.overlay?.closing.pipe(takeUntilDestroyed()).subscribe(() => this.focusTrap.deactivate());\n }\n\n ngOnInit(): void {\n focusTrapStack.add(this.focusTrap);\n\n this.mutationObserver = new MutationObserver(this.handleMutations.bind(this));\n\n // setup event listeners\n this.ngZone.runOutsideAngular(() => {\n this.mutationObserver!.observe(this.elementRef.nativeElement, {\n childList: true,\n subtree: true,\n });\n document.addEventListener('focusin', this.handleFocusIn.bind(this));\n document.addEventListener('focusout', this.handleFocusOut.bind(this));\n });\n\n const previouslyFocusedElement = document.activeElement as HTMLElement | null;\n const hasFocusedCandidate = this.elementRef.nativeElement.contains(previouslyFocusedElement);\n\n if (!hasFocusedCandidate) {\n // we do this to ensure the content is rendered before we try to find the first focusable element\n // and focus it\n afterNextRender(\n {\n write: () => {\n this.focusFirst();\n\n // if the focus didn't change, focus the container\n if (document.activeElement === previouslyFocusedElement) {\n this.focus(this.elementRef.nativeElement);\n }\n },\n },\n { injector: this.injector },\n );\n }\n }\n\n ngOnDestroy(): void {\n focusTrapStack.remove(this.focusTrap);\n this.mutationObserver?.disconnect();\n this.mutationObserver = null;\n this.focusTrap.deactivate();\n }\n\n private handleFocusIn(event: FocusEvent): void {\n if (!this.focusTrap.active || this.state.disabled()) {\n return;\n }\n\n const target = event.target as HTMLElement | null;\n\n if (this.elementRef.nativeElement.contains(target)) {\n this.lastFocusedElement = target;\n } else {\n this.focus(this.lastFocusedElement);\n }\n }\n\n /**\n * Handles the `focusout` event.\n */\n private handleFocusOut(event: FocusEvent) {\n if (!this.focusTrap.active || this.state.disabled() || event.relatedTarget === null) {\n return;\n }\n\n const relatedTarget = event.relatedTarget as HTMLElement;\n\n if (!this.elementRef.nativeElement.contains(relatedTarget)) {\n this.focus(this.lastFocusedElement);\n }\n }\n\n /**\n * If the focused element gets removed from the DOM, browsers move focus back to the document.body.\n * We move focus to the container to keep focus trapped correctly.\n */\n private handleMutations(mutations: MutationRecord[]): void {\n const focusedElement = document.activeElement as HTMLElement | null;\n\n if (focusedElement !== document.body) {\n return;\n }\n\n for (const mutation of mutations) {\n if (mutation.removedNodes.length > 0) {\n this.focus(this.elementRef.nativeElement);\n }\n }\n }\n\n /**\n * Handles the `keydown` event.\n */\n @HostListener('keydown', ['$event'])\n protected handleKeyDown(event: KeyboardEvent): void {\n if (!this.focusTrap.active || this.state.disabled()) {\n return;\n }\n\n const isTabKey = event.key === 'Tab' && !event.altKey && !event.ctrlKey && !event.metaKey;\n const focusedElement = document.activeElement as HTMLElement | null;\n\n if (isTabKey && focusedElement) {\n const container = event.currentTarget as HTMLElement;\n const [first, last] = this.getTabbableEdges(container);\n const hasTabbableElementsInside = first && last;\n\n // we can only wrap focus if we have tabbable edges\n if (!hasTabbableElementsInside) {\n if (focusedElement === container) {\n event.preventDefault();\n }\n } else {\n if (!event.shiftKey && focusedElement === last) {\n event.preventDefault();\n this.focus(first);\n } else if (event.shiftKey && focusedElement === first) {\n event.preventDefault();\n this.focus(last);\n }\n }\n }\n }\n\n /**\n * Returns the first and last tabbable elements inside a container.\n */\n private getTabbableEdges(container: HTMLElement) {\n const candidates = this.getTabbableCandidates(container);\n const first = this.findVisible(candidates);\n const last = this.findVisible(candidates.reverse());\n return [first, last] as const;\n }\n\n /**\n * Returns a list of potential focusable elements inside a container.\n */\n private getTabbableCandidates(container: HTMLElement) {\n const nodes: HTMLElement[] = [];\n const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode: (node: HTMLElement) =>\n this.interactivityChecker.isFocusable(node)\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_SKIP,\n });\n while (walker.nextNode()) {\n nodes.push(walker.currentNode as HTMLElement);\n }\n return nodes;\n }\n\n /**\n * Returns the first visible element in a list..\n */\n private findVisible(elements: HTMLElement[]) {\n return elements.find(element => this.interactivityChecker.isVisible(element)) ?? null;\n }\n\n private focus(element: HTMLElement | null): void {\n if (!element) {\n return;\n }\n // Its not great that we are relying on an internal API here, but we need to in order to\n // try and best determine the focus origin when it is programmatically closed by the user.\n this.focusMonitor.focusVia(element, (this.focusMonitor as any)._lastFocusOrigin, {\n preventScroll: true,\n });\n }\n\n private focusFirst(): void {\n const previouslyFocusedElement = document.activeElement;\n\n for (const candidate of this.getTabbableCandidates(this.elementRef.nativeElement)) {\n this.focus(candidate);\n\n if (document.activeElement !== previouslyFocusedElement) {\n return;\n }\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAQA;;AAEG;AACI,MAAM,sBAAsB,GAAG,gBAAgB,CAAe,WAAW,CAAC;AAEjF;;AAEG;MACU,qBAAqB,GAAG,mBAAmB,CAAC,sBAAsB;AAE/E;;AAEG;MACU,oBAAoB,GAAG,mBAAmB,CAAC,sBAAsB;AAE9E;;AAEG;AACI,MAAM,cAAc,GAAG,WAAW,CAAC,sBAAsB,CAAC;;ACPjE;;;AAGG;AAEH,MAAM,SAAS,CAAA;AAAf,IAAA,WAAA,GAAA;AACE;;AAEG;QACH,IAAM,CAAA,MAAA,GAAY,KAAK;;AAEvB;;AAEG;IACH,QAAQ,GAAA;AACN,QAAA,IAAI,CAAC,MAAM,GAAG,IAAI;;AAGpB;;AAEG;IACH,UAAU,GAAA;AACR,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;;AAEtB;AAED,MAAM,cAAc,CAAA;AAApB,IAAA,WAAA,GAAA;AACE;;A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AAA,SAAA,EAAA,CAAC,qBAAqB,EAAE,CAAC,EAAA,QAAA,EAAA,CAAA,cAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAMzB,YAAY,EAAA,UAAA,EAAA,CAAA;kBATxB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,gBAAgB;AAC1B,oBAAA,QAAQ,EAAE,cAAc;AACxB,oBAAA,SAAS,EAAE,CAAC,qBAAqB,EAAE,CAAC;AACpC,oBAAA,IAAI,EAAE;AACJ,wBAAA,iBAAiB,EAAE,IAAI;AACvB,wBAAA,wBAAwB,EAAE,yBAAyB;AACpD,qBAAA;AACF,iBAAA;wDAgKW,aAAa,EAAA,CAAA;sBADtB,YAAY;uBAAC,SAAS,EAAE,CAAC,QAAQ,CAAC;;;AChQrC;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-focus-trap.mjs","sources":["../../../../packages/ng-primitives/focus-trap/src/focus-trap/focus-trap-state.ts","../../../../packages/ng-primitives/focus-trap/src/focus-trap/focus-trap.ts","../../../../packages/ng-primitives/focus-trap/src/ng-primitives-focus-trap.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpFocusTrap } from './focus-trap';\n\n/**\n * The state token for the FocusTrap primitive.\n */\nexport const NgpFocusTrapStateToken = createStateToken<NgpFocusTrap>('FocusTrap');\n\n/**\n * Provides the FocusTrap state.\n */\nexport const provideFocusTrapState = createStateProvider(NgpFocusTrapStateToken);\n\n/**\n * Injects the FocusTrap state.\n */\nexport const injectFocusTrapState = createStateInjector<NgpFocusTrap>(NgpFocusTrapStateToken);\n\n/**\n * The FocusTrap state registration function.\n */\nexport const focusTrapState = createState(NgpFocusTrapStateToken);\n","import { FocusMonitor, InteractivityChecker } from '@angular/cdk/a11y';\nimport { BooleanInput } from '@angular/cdk/coercion';\nimport {\n afterNextRender,\n booleanAttribute,\n Directive,\n ElementRef,\n HostListener,\n inject,\n Injector,\n input,\n NgZone,\n OnDestroy,\n OnInit,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { NgpOverlay } from 'ng-primitives/portal';\nimport { focusTrapState, provideFocusTrapState } from './focus-trap-state';\n\n/**\n * This implementation is based on the Radix UI FocusScope:\n * https://github.com/radix-ui/primitives/blob/main/packages/react/focus-scope/src/FocusScope.tsx#L306\n */\n\nclass FocusTrap {\n /**\n * Whether the focus trap is active.\n */\n active: boolean = false;\n\n /**\n * Activates the focus trap.\n */\n activate(): void {\n this.active = true;\n }\n\n /**\n * Deactivates the focus trap.\n */\n deactivate(): void {\n this.active = false;\n }\n}\n\nclass FocusTrapStack {\n /**\n * The stack of focus traps.\n */\n private readonly stack: FocusTrap[] = [];\n\n /**\n * Adds a focus trap to the stack.\n */\n add(focusTrap: FocusTrap): void {\n // deactivate the previous focus trap\n this.stack.forEach(t => t.deactivate());\n\n // add the new focus trap and activate it\n this.stack.push(focusTrap);\n focusTrap.activate();\n }\n\n /**\n * Removes a focus trap from the stack.\n */\n remove(focusTrap: FocusTrap): void {\n // remove the focus trap\n const index = this.stack.indexOf(focusTrap);\n\n if (index >= 0) {\n this.stack.splice(index, 1);\n }\n\n // activate the previous focus trap\n const previous = this.stack[this.stack.length - 1];\n\n if (previous) {\n previous.activate();\n }\n }\n}\n\n// create a global stack of focus traps\nconst focusTrapStack = new FocusTrapStack();\n\n/**\n * The `NgpFocusTrap` directive traps focus within the host element.\n */\n@Directive({\n selector: '[ngpFocusTrap]',\n exportAs: 'ngpFocusTrap',\n providers: [provideFocusTrapState()],\n host: {\n '[attr.tabindex]': '-1',\n '[attr.data-focus-trap]': '!disabled() ? \"\" : null',\n },\n})\nexport class NgpFocusTrap implements OnInit, OnDestroy {\n /**\n * Access any parent overlay.\n */\n private readonly overlay = inject(NgpOverlay, { optional: true });\n\n /**\n * Create a new focus trap.\n */\n private readonly focusTrap = new FocusTrap();\n\n /**\n * Access the injector.\n */\n private readonly injector = inject(Injector);\n\n /**\n * Access the focus monitor.\n */\n private readonly focusMonitor = inject(FocusMonitor);\n\n /**\n * Access the interactivity checker.\n */\n private readonly interactivityChecker = inject(InteractivityChecker);\n\n /**\n * Get the focus trap container element.\n */\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Access NgZone to run the focus trap events outside of Angular's zone.\n */\n private readonly ngZone = inject(NgZone);\n\n /**\n * Store the mutation observer.\n */\n private mutationObserver: MutationObserver | null = null;\n\n /**\n * Store the last focused element.\n */\n private lastFocusedElement: HTMLElement | null = null;\n\n /**\n * Whether the focus trap is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpFocusTrapDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * The focus trap state.\n */\n protected readonly state = focusTrapState<NgpFocusTrap>(this);\n\n constructor() {\n // if this is used within an overlay we must disable the focus trap as soon as the overlay is closing\n this.overlay?.closing.pipe(takeUntilDestroyed()).subscribe(() => this.focusTrap.deactivate());\n }\n\n ngOnInit(): void {\n focusTrapStack.add(this.focusTrap);\n\n this.mutationObserver = new MutationObserver(this.handleMutations.bind(this));\n\n // setup event listeners\n this.ngZone.runOutsideAngular(() => {\n this.mutationObserver!.observe(this.elementRef.nativeElement, {\n childList: true,\n subtree: true,\n });\n document.addEventListener('focusin', this.handleFocusIn.bind(this));\n document.addEventListener('focusout', this.handleFocusOut.bind(this));\n });\n\n const previouslyFocusedElement = document.activeElement as HTMLElement | null;\n const hasFocusedCandidate = this.elementRef.nativeElement.contains(previouslyFocusedElement);\n\n if (!hasFocusedCandidate) {\n // we do this to ensure the content is rendered before we try to find the first focusable element\n // and focus it\n afterNextRender(\n {\n write: () => {\n this.focusFirst();\n\n // if the focus didn't change, focus the container\n if (document.activeElement === previouslyFocusedElement) {\n this.focus(this.elementRef.nativeElement);\n }\n },\n },\n { injector: this.injector },\n );\n }\n }\n\n ngOnDestroy(): void {\n focusTrapStack.remove(this.focusTrap);\n this.mutationObserver?.disconnect();\n this.mutationObserver = null;\n this.focusTrap.deactivate();\n }\n\n private handleFocusIn(event: FocusEvent): void {\n if (!this.focusTrap.active || this.state.disabled()) {\n return;\n }\n\n const target = event.target as HTMLElement | null;\n\n if (this.elementRef.nativeElement.contains(target)) {\n this.lastFocusedElement = target;\n } else {\n this.focus(this.lastFocusedElement);\n }\n }\n\n /**\n * Handles the `focusout` event.\n */\n private handleFocusOut(event: FocusEvent) {\n if (!this.focusTrap.active || this.state.disabled() || event.relatedTarget === null) {\n return;\n }\n\n const relatedTarget = event.relatedTarget as HTMLElement;\n\n if (!this.elementRef.nativeElement.contains(relatedTarget)) {\n this.focus(this.lastFocusedElement);\n }\n }\n\n /**\n * If the focused element gets removed from the DOM, browsers move focus back to the document.body.\n * We move focus to the container to keep focus trapped correctly.\n */\n private handleMutations(mutations: MutationRecord[]): void {\n const focusedElement = document.activeElement as HTMLElement | null;\n\n if (focusedElement !== document.body) {\n return;\n }\n\n for (const mutation of mutations) {\n if (mutation.removedNodes.length > 0) {\n this.focus(this.elementRef.nativeElement);\n }\n }\n }\n\n /**\n * Handles the `keydown` event.\n */\n @HostListener('keydown', ['$event'])\n protected handleKeyDown(event: KeyboardEvent): void {\n if (!this.focusTrap.active || this.state.disabled()) {\n return;\n }\n\n const isTabKey = event.key === 'Tab' && !event.altKey && !event.ctrlKey && !event.metaKey;\n const focusedElement = document.activeElement as HTMLElement | null;\n\n if (isTabKey && focusedElement) {\n const container = event.currentTarget as HTMLElement;\n const [first, last] = this.getTabbableEdges(container);\n const hasTabbableElementsInside = first && last;\n\n // we can only wrap focus if we have tabbable edges\n if (!hasTabbableElementsInside) {\n if (focusedElement === container) {\n event.preventDefault();\n }\n } else {\n if (!event.shiftKey && focusedElement === last) {\n event.preventDefault();\n this.focus(first);\n } else if (event.shiftKey && focusedElement === first) {\n event.preventDefault();\n this.focus(last);\n }\n }\n }\n }\n\n /**\n * Returns the first and last tabbable elements inside a container.\n */\n private getTabbableEdges(container: HTMLElement) {\n const candidates = this.getTabbableCandidates(container);\n const first = this.findVisible(candidates);\n const last = this.findVisible(candidates.reverse());\n return [first, last] as const;\n }\n\n /**\n * Returns a list of potential focusable elements inside a container.\n */\n private getTabbableCandidates(container: HTMLElement) {\n const nodes: HTMLElement[] = [];\n const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode: (node: HTMLElement) =>\n this.interactivityChecker.isFocusable(node)\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_SKIP,\n });\n while (walker.nextNode()) {\n nodes.push(walker.currentNode as HTMLElement);\n }\n return nodes;\n }\n\n /**\n * Returns the first visible element in a list..\n */\n private findVisible(elements: HTMLElement[]) {\n return elements.find(element => this.interactivityChecker.isVisible(element)) ?? null;\n }\n\n private focus(element: HTMLElement | null): void {\n if (!element) {\n return;\n }\n // Its not great that we are relying on an internal API here, but we need to in order to\n // try and best determine the focus origin when it is programmatically closed by the user.\n this.focusMonitor.focusVia(element, (this.focusMonitor as any)._lastFocusOrigin, {\n preventScroll: true,\n });\n }\n\n private focusFirst(): void {\n const previouslyFocusedElement = document.activeElement;\n\n for (const candidate of this.getTabbableCandidates(this.elementRef.nativeElement)) {\n this.focus(candidate);\n\n if (document.activeElement !== previouslyFocusedElement) {\n return;\n }\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAQA;;AAEG;AACI,MAAM,sBAAsB,GAAG,gBAAgB,CAAe,WAAW,CAAC;AAEjF;;AAEG;MACU,qBAAqB,GAAG,mBAAmB,CAAC,sBAAsB;AAE/E;;AAEG;MACU,oBAAoB,GAAG,mBAAmB,CAAe,sBAAsB;AAE5F;;AAEG;AACI,MAAM,cAAc,GAAG,WAAW,CAAC,sBAAsB,CAAC;;ACPjE;;;AAGG;AAEH,MAAM,SAAS,CAAA;AAAf,IAAA,WAAA,GAAA;AACE;;AAEG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AAA,sBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,IAAA,EAAA,EAAA,SAAA,EAAA,EAAA,SAAA,EAAA,uBAAA,EAAA,EAAA,UAAA,EAAA,EAAA,eAAA,EAAA,IAAA,EAAA,sBAAA,EAAA,2BAAA,EAAA,EAAA,EAAA,SAAA,EAAA,CAAC,qBAAqB,EAAE,CAAC,EAAA,QAAA,EAAA,CAAA,cAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAMzB,YAAY,EAAA,UAAA,EAAA,CAAA;kBATxB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,gBAAgB;AAC1B,oBAAA,QAAQ,EAAE,cAAc;AACxB,oBAAA,SAAS,EAAE,CAAC,qBAAqB,EAAE,CAAC;AACpC,oBAAA,IAAI,EAAE;AACJ,wBAAA,iBAAiB,EAAE,IAAI;AACvB,wBAAA,wBAAwB,EAAE,yBAAyB;AACpD,qBAAA;AACF,iBAAA;wDAgKW,aAAa,EAAA,CAAA;sBADtB,YAAY;uBAAC,SAAS,EAAE,CAAC,QAAQ,CAAC;;;AChQrC;;AAEG;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, effect, Directive, computed, booleanAttribute,
|
|
2
|
+
import { input, effect, Directive, computed, booleanAttribute, afterRenderEffect, signal, contentChild, inject, ElementRef, HostListener } from '@angular/core';
|
|
3
3
|
import { uniqueId, onBooleanChange, controlStatus, onChange } from 'ng-primitives/utils';
|
|
4
4
|
import { createStateToken, createStateProvider, createStateInjector, createState } from 'ng-primitives/state';
|
|
5
5
|
import { injectElementRef, explicitEffect } from 'ng-primitives/internal';
|
|
@@ -178,7 +178,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImpo
|
|
|
178
178
|
providers: [provideFormControlState()],
|
|
179
179
|
}]
|
|
180
180
|
}], ctorParameters: () => [] });
|
|
181
|
-
function setupFormControl({ id
|
|
181
|
+
function setupFormControl({ id, disabled = signal(false) }) {
|
|
182
182
|
const element = injectElementRef().nativeElement;
|
|
183
183
|
// Access the form field that the form control is associated with.
|
|
184
184
|
const formField = injectFormFieldState({ optional: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-form-field.mjs","sources":["../../../../packages/ng-primitives/form-field/src/form-field/form-field-state.ts","../../../../packages/ng-primitives/form-field/src/description/description.ts","../../../../packages/ng-primitives/form-field/src/error/error.ts","../../../../packages/ng-primitives/form-field/src/form-control/form-control-state.ts","../../../../packages/ng-primitives/form-field/src/form-control/form-control.ts","../../../../packages/ng-primitives/form-field/src/form-field/form-field.ts","../../../../packages/ng-primitives/form-field/src/label/label.ts","../../../../packages/ng-primitives/form-field/src/ng-primitives-form-field.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpFormField } from './form-field';\n\n/**\n * The state token for the FormField primitive.\n */\nexport const NgpFormFieldStateToken = createStateToken<NgpFormField>('FormField');\n\n/**\n * Provides the FormField state.\n */\nexport const provideFormFieldState = createStateProvider(NgpFormFieldStateToken);\n\n/**\n * Injects the FormField state.\n */\nexport const injectFormFieldState = createStateInjector(NgpFormFieldStateToken);\n\n/**\n * The FormField state registration function.\n */\nexport const formFieldState = createState(NgpFormFieldStateToken);\n","import { Directive, effect, input } from '@angular/core';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectFormFieldState } from '../form-field/form-field-state';\n\n/**\n * The `NgpDescription` directive is used to mark a description element within a form field. There may be multiple descriptions associated with a form control.\n */\n@Directive({\n selector: '[ngpDescription]',\n exportAs: 'ngpDescription',\n host: {\n '[attr.id]': 'id()',\n '[attr.data-invalid]': 'formField()?.invalid() ? \"\" : null',\n '[attr.data-valid]': 'formField()?.valid() ? \"\" : null',\n '[attr.data-touched]': 'formField()?.touched() ? \"\" : null',\n '[attr.data-pristine]': 'formField()?.pristine() ? \"\" : null',\n '[attr.data-dirty]': 'formField()?.dirty() ? \"\" : null',\n '[attr.data-pending]': 'formField()?.pending() ? \"\" : null',\n '[attr.data-disabled]': 'formField()?.disabled() ? \"\" : null',\n },\n})\nexport class NgpDescription {\n /**\n * The id of the description. If not provided, a unique id will be generated.\n */\n readonly id = input<string>(uniqueId('ngp-description'));\n /**\n * Access the form field that the description is associated with.\n */\n protected readonly formField = injectFormFieldState({ optional: true });\n\n constructor() {\n effect(onCleanup => {\n this.formField()?.addDescription(this.id());\n onCleanup(() => this.formField()?.removeDescription(this.id()));\n });\n }\n}\n","import { Directive, OnChanges, OnDestroy, SimpleChanges, computed, input } from '@angular/core';\nimport { onBooleanChange, uniqueId } from 'ng-primitives/utils';\nimport { injectFormFieldState } from '../form-field/form-field-state';\n\n/**\n * The `NgpError` directive is used to mark an error message element within a form field. There may be multiple error messages associated with a form control.\n */\n@Directive({\n selector: '[ngpError]',\n exportAs: 'ngpError',\n host: {\n '[attr.id]': 'id()',\n '[attr.data-invalid]': 'formField()?.invalid() ? \"\" : null',\n '[attr.data-valid]': 'formField()?.valid() ? \"\" : null',\n '[attr.data-touched]': 'formField()?.touched() ? \"\" : null',\n '[attr.data-pristine]': 'formField()?.pristine() ? \"\" : null',\n '[attr.data-dirty]': 'formField()?.dirty() ? \"\" : null',\n '[attr.data-pending]': 'formField()?.pending() ? \"\" : null',\n '[attr.data-disabled]': 'formField()?.disabled() ? \"\" : null',\n '[attr.data-validator]': 'state()',\n },\n})\nexport class NgpError implements OnChanges, OnDestroy {\n /**\n * Access the form field that the description is associated with.\n */\n protected readonly formField = injectFormFieldState({ optional: true });\n\n /**\n * The id of the error message. If not provided, a unique id will be generated.\n */\n readonly id = input<string>(uniqueId('ngp-error'));\n\n /**\n * The validator associated with the error message.\n */\n readonly validator = input<string | null>(null, {\n alias: 'ngpErrorValidator',\n });\n\n /**\n * Determine if there is an error message.\n */\n protected readonly hasError = computed(() => {\n const errors = this.formField()?.errors() ?? [];\n const validator = this.validator();\n\n return validator ? errors?.includes(validator) : errors?.length > 0;\n });\n\n /**\n * Determine whether the validator associated with this error is failing.\n */\n protected readonly state = computed(() => (this.hasError() ? 'fail' : 'pass'));\n\n constructor() {\n // add or remove the error message when the error state changes\n onBooleanChange(\n this.hasError,\n () => this.formField()?.addDescription(this.id()),\n () => this.formField()?.removeDescription(this.id()),\n );\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if ('id' in changes) {\n this.formField()?.removeDescription(changes['id'].previousValue);\n }\n }\n\n ngOnDestroy(): void {\n this.formField()?.removeDescription(this.id());\n }\n}\n","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpFormControl } from './form-control';\n\n/**\n * The state token for the FormControl primitive.\n */\nexport const NgpFormControlStateToken = createStateToken<NgpFormControl>('FormControl');\n\n/**\n * Provides the FormControl state.\n */\nexport const provideFormControlState = createStateProvider(NgpFormControlStateToken);\n\n/**\n * Injects the FormControl state.\n */\nexport const injectFormControlState = createStateInjector(NgpFormControlStateToken);\n\n/**\n * The FormControl state registration function.\n */\nexport const formControlState = createState(NgpFormControlStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport {\n afterRenderEffect,\n booleanAttribute,\n computed,\n Directive,\n input,\n signal,\n Signal,\n} from '@angular/core';\nimport { explicitEffect, injectElementRef } from 'ng-primitives/internal';\nimport { controlStatus, uniqueId } from 'ng-primitives/utils';\nimport { injectFormFieldState } from '../form-field/form-field-state';\nimport { formControlState, provideFormControlState } from './form-control-state';\n\n/**\n * 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.\n *\n * The `NgpFormControl` directive is used to mark a form control element within a form field. This element will have an `aria-labelledby` attribute set to the ID of the label element within the form field and an `aria-describedby` attribute set to the ID of the description elements within the form field.\n */\n@Directive({\n selector: '[ngpFormControl]',\n exportAs: 'ngpFormControl',\n providers: [provideFormControlState()],\n})\nexport class NgpFormControl {\n /**\n * The id of the form control. If not provided, a unique id will be generated.\n */\n readonly id = input<string>(uniqueId('ngp-form-control'));\n\n /**\n * Whether the form control is disabled by a parent.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpFormControlDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * The state of the form control.\n */\n private readonly state = formControlState<NgpFormControl>(this);\n\n constructor() {\n // Sync the form control state with the control state.\n setupFormControl({ id: this.state.id, disabled: this.state.disabled });\n }\n}\n\ninterface FormControlState {\n id?: Signal<string>;\n disabled?: Signal<boolean>;\n}\n\nexport function setupFormControl({\n id = signal(uniqueId('ngp-form-control')),\n disabled = signal(false),\n}: FormControlState) {\n const element = injectElementRef().nativeElement;\n // Access the form field that the form control is associated with.\n const formField = injectFormFieldState({ optional: true });\n // Access the form control status.\n const status = controlStatus();\n // Determine the aria-labelledby attribute value.\n const ariaLabelledBy = computed(() => formField()?.labels().join(' '));\n // Determine the aria-describedby attribute value.\n const ariaDescribedBy = computed(() => formField()?.descriptions().join(' '));\n\n explicitEffect([id], ([id], onCleanup) => {\n formField()?.setFormControl(id);\n onCleanup(() => formField()?.removeFormControl());\n });\n\n afterRenderEffect({\n write: () => {\n setAttribute(element, 'id', id());\n setAttribute(element, 'aria-labelledby', ariaLabelledBy());\n setAttribute(element, 'aria-describedby', ariaDescribedBy());\n\n setStateAttribute(element, status().invalid, 'data-invalid');\n setStateAttribute(element, status().valid, 'data-valid');\n setStateAttribute(element, status().touched, 'data-touched');\n setStateAttribute(element, status().pristine, 'data-pristine');\n setStateAttribute(element, status().dirty, 'data-dirty');\n setStateAttribute(element, status().pending, 'data-pending');\n setStateAttribute(element, disabled() || status().disabled, 'data-disabled');\n },\n });\n}\n\n/**\n * Sets the attribute on the element. If the value is not empty, the attribute is set to the value.\n * If the value is empty, the attribute is removed.\n * @param element The element to set the attribute on.\n * @param attribute The attribute to set on the element.\n * @param value The value to set on the attribute.\n */\nfunction setAttribute(element: HTMLElement, attribute: string, value: string) {\n if (value && value.length > 0) {\n element.setAttribute(attribute, value);\n } else {\n element.removeAttribute(attribute);\n }\n}\n\n/**\n * Sets the attribute on the element based on the state. If the state is true, the attribute\n * is set to an empty string. If the state is false, the attribute is removed.\n * @param element The element to set the attribute on.\n * @param state The state to set the attribute based on.\n * @param attribute The attribute to set on the element.\n */\nfunction setStateAttribute(element: HTMLElement, state: boolean | null, attribute: string) {\n if (state) {\n element.setAttribute(attribute, '');\n } else {\n element.removeAttribute(attribute);\n }\n}\n","import { Directive, OnDestroy, contentChild, signal } from '@angular/core';\nimport { NgControl } from '@angular/forms';\nimport { onChange } from 'ng-primitives/utils';\nimport { Subscription } from 'rxjs';\nimport { formFieldState, provideFormFieldState } from './form-field-state';\n\n/**\n * The `NgpFormField` directive is a container for form field elements. Any labels, form controls, or descriptions should be placed within this directive.\n */\n@Directive({\n selector: '[ngpFormField]',\n exportAs: 'ngpFormField',\n providers: [provideFormFieldState()],\n host: {\n '[attr.data-invalid]': 'invalid() ? \"\" : null',\n '[attr.data-valid]': 'valid() ? \"\" : null',\n '[attr.data-touched]': 'touched() ? \"\" : null',\n '[attr.data-pristine]': 'pristine() ? \"\" : null',\n '[attr.data-dirty]': 'dirty() ? \"\" : null',\n '[attr.data-pending]': 'pending() ? \"\" : null',\n '[attr.data-disabled]': 'disabled() ? \"\" : null',\n },\n})\nexport class NgpFormField implements OnDestroy {\n /**\n * Store the form label.\n * @internal\n */\n readonly labels = signal<string[]>([]);\n\n /**\n * Store the form descriptions.\n * @internal\n */\n readonly descriptions = signal<string[]>([]);\n\n /**\n * Store the id of the associated form control.\n * @internal\n */\n readonly formControl = signal<string | null>(null);\n\n /**\n * Find any NgControl within the form field.\n * @internal\n */\n private readonly ngControl = contentChild(NgControl);\n\n /**\n * Store the validation error messages.\n * @internal\n */\n readonly errors = signal<string[]>([]);\n\n /**\n * Whether the control is pristine.\n * @internal\n */\n readonly pristine = signal<boolean | null>(null);\n\n /**\n * Whether the control is touched.\n * @internal\n */\n readonly touched = signal<boolean | null>(null);\n\n /**\n * Whether the control is dirty.\n * @internal\n */\n readonly dirty = signal<boolean | null>(null);\n\n /**\n * Whether the control is valid.\n */\n readonly valid = signal<boolean | null>(null);\n\n /**\n * Whether the control is invalid.\n * @internal\n */\n readonly invalid = signal<boolean | null>(null);\n\n /**\n * Whether the control is pending.\n * @internal\n */\n readonly pending = signal<boolean | null>(null);\n\n /**\n * Whether the control is disabled.\n * @internal\n */\n readonly disabled = signal<boolean | null>(null);\n\n /**\n * Store the current status subscription.\n */\n private subscription?: Subscription;\n\n /**\n * The form field state.\n */\n protected readonly state = formFieldState<NgpFormField>(this);\n\n constructor() {\n // any time the ngControl changes, setup the subscriptions.\n onChange(this.ngControl, this.setupSubscriptions.bind(this));\n }\n\n ngOnDestroy(): void {\n this.subscription?.unsubscribe();\n }\n\n /**\n * Setup a listener for the form control status.\n * @param control\n */\n private setupSubscriptions(control: NgControl | null | undefined): void {\n // Unsubscribe from the previous subscriptions.\n this.subscription?.unsubscribe();\n\n // set the initial values\n this.updateStatus();\n\n // Listen for changes to the form control.\n this.subscription = control?.valueChanges?.subscribe(this.updateStatus.bind(this));\n }\n\n private updateStatus(): void {\n const control = this.ngControl();\n\n if (!control) {\n return;\n }\n\n this.pristine.set(control.pristine);\n this.touched.set(control.touched);\n this.dirty.set(control.dirty);\n this.valid.set(control.valid);\n this.invalid.set(control.invalid);\n this.pending.set(control.pending);\n this.disabled.set(control.disabled);\n this.errors.set(control?.errors ? Object.keys(control.errors) : []);\n }\n\n /**\n * Register the id of the associated form control.\n * @param id\n * @internal\n */\n setFormControl(id: string): void {\n this.formControl.set(id);\n }\n\n /**\n * Register a label with the form field.\n * @param label\n * @internal\n */\n addLabel(label: string): void {\n this.labels.update(labels => [...labels, label]);\n }\n\n /**\n * Register a description with the form field.\n * @param description\n * @internal\n */\n addDescription(description: string): void {\n this.descriptions.update(descriptions => [...descriptions, description]);\n }\n\n /**\n * Remove the associated form control.\n * @internal\n */\n removeFormControl(): void {\n this.formControl.set(null);\n }\n\n /**\n * Remove a label from the form field.\n * @param label\n * @internal\n */\n removeLabel(label: string): void {\n this.labels.update(labels => labels.filter(l => l !== label));\n }\n\n /**\n * Remove a description from the form field.\n * @param description\n * @internal\n */\n removeDescription(description: string): void {\n this.descriptions.update(descriptions => descriptions.filter(d => d !== description));\n }\n}\n","import {\n computed,\n Directive,\n effect,\n ElementRef,\n HostListener,\n inject,\n input,\n} from '@angular/core';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectFormFieldState } from '../form-field/form-field-state';\n\n/**\n * The `NgpLabel` directive is used to mark a label element within a form field. Preferably, there should use an HTML `<label>` element.\n */\n@Directive({\n selector: '[ngpLabel]',\n exportAs: 'ngpLabel',\n host: {\n '[attr.id]': 'id()',\n '[attr.for]': 'htmlFor()',\n '[attr.data-invalid]': 'formField()?.invalid() ? \"\" : null',\n '[attr.data-valid]': 'formField()?.valid() ? \"\" : null',\n '[attr.data-touched]': 'formField()?.touched() ? \"\" : null',\n '[attr.data-pristine]': 'formField()?.pristine() ? \"\" : null',\n '[attr.data-dirty]': 'formField()?.dirty() ? \"\" : null',\n '[attr.data-pending]': 'formField()?.pending() ? \"\" : null',\n '[attr.data-disabled]': 'formField()?.disabled() ? \"\" : null',\n },\n})\nexport class NgpLabel {\n /**\n * The id of the label. If not provided, a unique id will be generated.\n */\n readonly id = input<string>(uniqueId('ngp-label'));\n /**\n * Access the form field that the label is associated with.\n */\n protected readonly formField = injectFormFieldState({ optional: true });\n /**\n * Derive the for attribute value if the label is an HTML label element.\n */\n protected readonly htmlFor = computed(() => this.formField()?.formControl());\n /**\n * Access the element that the label is associated with.\n */\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n /**\n * Determine if the label is an HTML label element.\n */\n protected readonly isLabel = this.elementRef.nativeElement instanceof HTMLLabelElement;\n\n constructor() {\n effect(onCleanup => {\n this.formField()?.addLabel(this.id());\n onCleanup(() => this.formField()?.removeLabel(this.id()));\n });\n }\n\n @HostListener('click', ['$event'])\n protected onClick(event: MouseEvent): void {\n // by default a label will perform a click on the associated form control, however\n // this only works if the associated form control is an input element which may not always\n // be the case, so we prevent the default behavior and handle the click event ourselves.\n // This was inspired by the HeadlessUI approach:\n // https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-react/src/components/label/label.tsx#L58\n if (this.isLabel) {\n event.preventDefault();\n }\n\n // to find the associated form control we can lookup via the known id\n const targetId = this.htmlFor();\n\n if (!targetId) {\n return;\n }\n\n const target = document.getElementById(targetId);\n\n if (!target) {\n return;\n }\n\n // if the target is disabled then do nothing\n const disabled = target.getAttribute('disabled');\n const ariaDisabled = target.getAttribute('aria-disabled');\n\n if (disabled === '' || disabled === 'true' || ariaDisabled === 'true') {\n return;\n }\n\n // radio buttons, checkboxes and switches should all be clicked immediately as they require state changes\n if (\n (target instanceof HTMLInputElement &&\n (target.type === 'radio' || target.type === 'checkbox')) ||\n target.role === 'radio' ||\n target.role === 'checkbox' ||\n target.role === 'switch'\n ) {\n target.click();\n }\n\n // Move focus to the element, this allows you to start using keyboard shortcuts since the\n // bound element is now focused.\n target.focus({ preventScroll: true });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAQA;;AAEG;AACI,MAAM,sBAAsB,GAAG,gBAAgB,CAAe,WAAW,CAAC;AAEjF;;AAEG;MACU,qBAAqB,GAAG,mBAAmB,CAAC,sBAAsB;AAE/E;;AAEG;MACU,oBAAoB,GAAG,mBAAmB,CAAC,sBAAsB;AAE9E;;AAEG;AACI,MAAM,cAAc,GAAG,WAAW,CAAC,sBAAsB,CAAC;;ACtBjE;;AAEG;MAeU,cAAc,CAAA;AAUzB,IAAA,WAAA,GAAA;AATA;;AAEG;QACM,IAAE,CAAA,EAAA,GAAG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,oCAAoC;AAC3D,wBAAA,mBAAmB,EAAE,kCAAkC;AACvD,wBAAA,qBAAqB,EAAE,oCAAoC;AAC3D,wBAAA,sBAAsB,EAAE,qCAAqC;AAC7D,wBAAA,mBAAmB,EAAE,kCAAkC;AACvD,wBAAA,qBAAqB,EAAE,oCAAoC;AAC3D,wBAAA,sBAAsB,EAAE,qCAAqC;AAC9D,qBAAA;AACF,iBAAA;wDA+BW,OAAO,EAAA,CAAA;sBADhB,YAAY;uBAAC,OAAO,EAAE,CAAC,QAAQ,CAAC;;;AC3DnC;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-form-field.mjs","sources":["../../../../packages/ng-primitives/form-field/src/form-field/form-field-state.ts","../../../../packages/ng-primitives/form-field/src/description/description.ts","../../../../packages/ng-primitives/form-field/src/error/error.ts","../../../../packages/ng-primitives/form-field/src/form-control/form-control-state.ts","../../../../packages/ng-primitives/form-field/src/form-control/form-control.ts","../../../../packages/ng-primitives/form-field/src/form-field/form-field.ts","../../../../packages/ng-primitives/form-field/src/label/label.ts","../../../../packages/ng-primitives/form-field/src/ng-primitives-form-field.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpFormField } from './form-field';\n\n/**\n * The state token for the FormField primitive.\n */\nexport const NgpFormFieldStateToken = createStateToken<NgpFormField>('FormField');\n\n/**\n * Provides the FormField state.\n */\nexport const provideFormFieldState = createStateProvider(NgpFormFieldStateToken);\n\n/**\n * Injects the FormField state.\n */\nexport const injectFormFieldState = createStateInjector<NgpFormField>(NgpFormFieldStateToken);\n\n/**\n * The FormField state registration function.\n */\nexport const formFieldState = createState(NgpFormFieldStateToken);\n","import { Directive, effect, input } from '@angular/core';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectFormFieldState } from '../form-field/form-field-state';\n\n/**\n * The `NgpDescription` directive is used to mark a description element within a form field. There may be multiple descriptions associated with a form control.\n */\n@Directive({\n selector: '[ngpDescription]',\n exportAs: 'ngpDescription',\n host: {\n '[attr.id]': 'id()',\n '[attr.data-invalid]': 'formField()?.invalid() ? \"\" : null',\n '[attr.data-valid]': 'formField()?.valid() ? \"\" : null',\n '[attr.data-touched]': 'formField()?.touched() ? \"\" : null',\n '[attr.data-pristine]': 'formField()?.pristine() ? \"\" : null',\n '[attr.data-dirty]': 'formField()?.dirty() ? \"\" : null',\n '[attr.data-pending]': 'formField()?.pending() ? \"\" : null',\n '[attr.data-disabled]': 'formField()?.disabled() ? \"\" : null',\n },\n})\nexport class NgpDescription {\n /**\n * The id of the description. If not provided, a unique id will be generated.\n */\n readonly id = input<string>(uniqueId('ngp-description'));\n /**\n * Access the form field that the description is associated with.\n */\n protected readonly formField = injectFormFieldState({ optional: true });\n\n constructor() {\n effect(onCleanup => {\n this.formField()?.addDescription(this.id());\n onCleanup(() => this.formField()?.removeDescription(this.id()));\n });\n }\n}\n","import { Directive, OnChanges, OnDestroy, SimpleChanges, computed, input } from '@angular/core';\nimport { onBooleanChange, uniqueId } from 'ng-primitives/utils';\nimport { injectFormFieldState } from '../form-field/form-field-state';\n\n/**\n * The `NgpError` directive is used to mark an error message element within a form field. There may be multiple error messages associated with a form control.\n */\n@Directive({\n selector: '[ngpError]',\n exportAs: 'ngpError',\n host: {\n '[attr.id]': 'id()',\n '[attr.data-invalid]': 'formField()?.invalid() ? \"\" : null',\n '[attr.data-valid]': 'formField()?.valid() ? \"\" : null',\n '[attr.data-touched]': 'formField()?.touched() ? \"\" : null',\n '[attr.data-pristine]': 'formField()?.pristine() ? \"\" : null',\n '[attr.data-dirty]': 'formField()?.dirty() ? \"\" : null',\n '[attr.data-pending]': 'formField()?.pending() ? \"\" : null',\n '[attr.data-disabled]': 'formField()?.disabled() ? \"\" : null',\n '[attr.data-validator]': 'state()',\n },\n})\nexport class NgpError implements OnChanges, OnDestroy {\n /**\n * Access the form field that the description is associated with.\n */\n protected readonly formField = injectFormFieldState({ optional: true });\n\n /**\n * The id of the error message. If not provided, a unique id will be generated.\n */\n readonly id = input<string>(uniqueId('ngp-error'));\n\n /**\n * The validator associated with the error message.\n */\n readonly validator = input<string | null>(null, {\n alias: 'ngpErrorValidator',\n });\n\n /**\n * Determine if there is an error message.\n */\n protected readonly hasError = computed(() => {\n const errors = this.formField()?.errors() ?? [];\n const validator = this.validator();\n\n return validator ? errors?.includes(validator) : errors?.length > 0;\n });\n\n /**\n * Determine whether the validator associated with this error is failing.\n */\n protected readonly state = computed(() => (this.hasError() ? 'fail' : 'pass'));\n\n constructor() {\n // add or remove the error message when the error state changes\n onBooleanChange(\n this.hasError,\n () => this.formField()?.addDescription(this.id()),\n () => this.formField()?.removeDescription(this.id()),\n );\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if ('id' in changes) {\n this.formField()?.removeDescription(changes['id'].previousValue);\n }\n }\n\n ngOnDestroy(): void {\n this.formField()?.removeDescription(this.id());\n }\n}\n","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpFormControl } from './form-control';\n\n/**\n * The state token for the FormControl primitive.\n */\nexport const NgpFormControlStateToken = createStateToken<NgpFormControl>('FormControl');\n\n/**\n * Provides the FormControl state.\n */\nexport const provideFormControlState = createStateProvider(NgpFormControlStateToken);\n\n/**\n * Injects the FormControl state.\n */\nexport const injectFormControlState = createStateInjector<NgpFormControl>(NgpFormControlStateToken);\n\n/**\n * The FormControl state registration function.\n */\nexport const formControlState = createState(NgpFormControlStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport {\n afterRenderEffect,\n booleanAttribute,\n computed,\n Directive,\n input,\n signal,\n Signal,\n} from '@angular/core';\nimport { explicitEffect, injectElementRef } from 'ng-primitives/internal';\nimport { controlStatus, uniqueId } from 'ng-primitives/utils';\nimport { injectFormFieldState } from '../form-field/form-field-state';\nimport { formControlState, provideFormControlState } from './form-control-state';\n\n/**\n * 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.\n *\n * The `NgpFormControl` directive is used to mark a form control element within a form field. This element will have an `aria-labelledby` attribute set to the ID of the label element within the form field and an `aria-describedby` attribute set to the ID of the description elements within the form field.\n */\n@Directive({\n selector: '[ngpFormControl]',\n exportAs: 'ngpFormControl',\n providers: [provideFormControlState()],\n})\nexport class NgpFormControl {\n /**\n * The id of the form control. If not provided, a unique id will be generated.\n */\n readonly id = input<string>(uniqueId('ngp-form-control'));\n\n /**\n * Whether the form control is disabled by a parent.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpFormControlDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * The state of the form control.\n */\n private readonly state = formControlState<NgpFormControl>(this);\n\n constructor() {\n // Sync the form control state with the control state.\n setupFormControl({ id: this.state.id, disabled: this.state.disabled });\n }\n}\n\ninterface FormControlState {\n id: Signal<string>;\n disabled?: Signal<boolean>;\n}\n\nexport function setupFormControl({ id, disabled = signal(false) }: FormControlState) {\n const element = injectElementRef().nativeElement;\n // Access the form field that the form control is associated with.\n const formField = injectFormFieldState({ optional: true });\n // Access the form control status.\n const status = controlStatus();\n // Determine the aria-labelledby attribute value.\n const ariaLabelledBy = computed(() => formField()?.labels().join(' '));\n // Determine the aria-describedby attribute value.\n const ariaDescribedBy = computed(() => formField()?.descriptions().join(' '));\n\n explicitEffect([id], ([id], onCleanup) => {\n formField()?.setFormControl(id);\n onCleanup(() => formField()?.removeFormControl());\n });\n\n afterRenderEffect({\n write: () => {\n setAttribute(element, 'id', id());\n setAttribute(element, 'aria-labelledby', ariaLabelledBy());\n setAttribute(element, 'aria-describedby', ariaDescribedBy());\n\n setStateAttribute(element, status().invalid, 'data-invalid');\n setStateAttribute(element, status().valid, 'data-valid');\n setStateAttribute(element, status().touched, 'data-touched');\n setStateAttribute(element, status().pristine, 'data-pristine');\n setStateAttribute(element, status().dirty, 'data-dirty');\n setStateAttribute(element, status().pending, 'data-pending');\n setStateAttribute(element, disabled() || status().disabled, 'data-disabled');\n },\n });\n}\n\n/**\n * Sets the attribute on the element. If the value is not empty, the attribute is set to the value.\n * If the value is empty, the attribute is removed.\n * @param element The element to set the attribute on.\n * @param attribute The attribute to set on the element.\n * @param value The value to set on the attribute.\n */\nfunction setAttribute(element: HTMLElement, attribute: string, value: string) {\n if (value && value.length > 0) {\n element.setAttribute(attribute, value);\n } else {\n element.removeAttribute(attribute);\n }\n}\n\n/**\n * Sets the attribute on the element based on the state. If the state is true, the attribute\n * is set to an empty string. If the state is false, the attribute is removed.\n * @param element The element to set the attribute on.\n * @param state The state to set the attribute based on.\n * @param attribute The attribute to set on the element.\n */\nfunction setStateAttribute(element: HTMLElement, state: boolean | null, attribute: string) {\n if (state) {\n element.setAttribute(attribute, '');\n } else {\n element.removeAttribute(attribute);\n }\n}\n","import { Directive, OnDestroy, contentChild, signal } from '@angular/core';\nimport { NgControl } from '@angular/forms';\nimport { onChange } from 'ng-primitives/utils';\nimport { Subscription } from 'rxjs';\nimport { formFieldState, provideFormFieldState } from './form-field-state';\n\n/**\n * The `NgpFormField` directive is a container for form field elements. Any labels, form controls, or descriptions should be placed within this directive.\n */\n@Directive({\n selector: '[ngpFormField]',\n exportAs: 'ngpFormField',\n providers: [provideFormFieldState()],\n host: {\n '[attr.data-invalid]': 'invalid() ? \"\" : null',\n '[attr.data-valid]': 'valid() ? \"\" : null',\n '[attr.data-touched]': 'touched() ? \"\" : null',\n '[attr.data-pristine]': 'pristine() ? \"\" : null',\n '[attr.data-dirty]': 'dirty() ? \"\" : null',\n '[attr.data-pending]': 'pending() ? \"\" : null',\n '[attr.data-disabled]': 'disabled() ? \"\" : null',\n },\n})\nexport class NgpFormField implements OnDestroy {\n /**\n * Store the form label.\n * @internal\n */\n readonly labels = signal<string[]>([]);\n\n /**\n * Store the form descriptions.\n * @internal\n */\n readonly descriptions = signal<string[]>([]);\n\n /**\n * Store the id of the associated form control.\n * @internal\n */\n readonly formControl = signal<string | null>(null);\n\n /**\n * Find any NgControl within the form field.\n * @internal\n */\n private readonly ngControl = contentChild(NgControl);\n\n /**\n * Store the validation error messages.\n * @internal\n */\n readonly errors = signal<string[]>([]);\n\n /**\n * Whether the control is pristine.\n * @internal\n */\n readonly pristine = signal<boolean | null>(null);\n\n /**\n * Whether the control is touched.\n * @internal\n */\n readonly touched = signal<boolean | null>(null);\n\n /**\n * Whether the control is dirty.\n * @internal\n */\n readonly dirty = signal<boolean | null>(null);\n\n /**\n * Whether the control is valid.\n */\n readonly valid = signal<boolean | null>(null);\n\n /**\n * Whether the control is invalid.\n * @internal\n */\n readonly invalid = signal<boolean | null>(null);\n\n /**\n * Whether the control is pending.\n * @internal\n */\n readonly pending = signal<boolean | null>(null);\n\n /**\n * Whether the control is disabled.\n * @internal\n */\n readonly disabled = signal<boolean | null>(null);\n\n /**\n * Store the current status subscription.\n */\n private subscription?: Subscription;\n\n /**\n * The form field state.\n */\n protected readonly state = formFieldState<NgpFormField>(this);\n\n constructor() {\n // any time the ngControl changes, setup the subscriptions.\n onChange(this.ngControl, this.setupSubscriptions.bind(this));\n }\n\n ngOnDestroy(): void {\n this.subscription?.unsubscribe();\n }\n\n /**\n * Setup a listener for the form control status.\n * @param control\n */\n private setupSubscriptions(control: NgControl | null | undefined): void {\n // Unsubscribe from the previous subscriptions.\n this.subscription?.unsubscribe();\n\n // set the initial values\n this.updateStatus();\n\n // Listen for changes to the form control.\n this.subscription = control?.valueChanges?.subscribe(this.updateStatus.bind(this));\n }\n\n private updateStatus(): void {\n const control = this.ngControl();\n\n if (!control) {\n return;\n }\n\n this.pristine.set(control.pristine);\n this.touched.set(control.touched);\n this.dirty.set(control.dirty);\n this.valid.set(control.valid);\n this.invalid.set(control.invalid);\n this.pending.set(control.pending);\n this.disabled.set(control.disabled);\n this.errors.set(control?.errors ? Object.keys(control.errors) : []);\n }\n\n /**\n * Register the id of the associated form control.\n * @param id\n * @internal\n */\n setFormControl(id: string): void {\n this.formControl.set(id);\n }\n\n /**\n * Register a label with the form field.\n * @param label\n * @internal\n */\n addLabel(label: string): void {\n this.labels.update(labels => [...labels, label]);\n }\n\n /**\n * Register a description with the form field.\n * @param description\n * @internal\n */\n addDescription(description: string): void {\n this.descriptions.update(descriptions => [...descriptions, description]);\n }\n\n /**\n * Remove the associated form control.\n * @internal\n */\n removeFormControl(): void {\n this.formControl.set(null);\n }\n\n /**\n * Remove a label from the form field.\n * @param label\n * @internal\n */\n removeLabel(label: string): void {\n this.labels.update(labels => labels.filter(l => l !== label));\n }\n\n /**\n * Remove a description from the form field.\n * @param description\n * @internal\n */\n removeDescription(description: string): void {\n this.descriptions.update(descriptions => descriptions.filter(d => d !== description));\n }\n}\n","import {\n computed,\n Directive,\n effect,\n ElementRef,\n HostListener,\n inject,\n input,\n} from '@angular/core';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { injectFormFieldState } from '../form-field/form-field-state';\n\n/**\n * The `NgpLabel` directive is used to mark a label element within a form field. Preferably, there should use an HTML `<label>` element.\n */\n@Directive({\n selector: '[ngpLabel]',\n exportAs: 'ngpLabel',\n host: {\n '[attr.id]': 'id()',\n '[attr.for]': 'htmlFor()',\n '[attr.data-invalid]': 'formField()?.invalid() ? \"\" : null',\n '[attr.data-valid]': 'formField()?.valid() ? \"\" : null',\n '[attr.data-touched]': 'formField()?.touched() ? \"\" : null',\n '[attr.data-pristine]': 'formField()?.pristine() ? \"\" : null',\n '[attr.data-dirty]': 'formField()?.dirty() ? \"\" : null',\n '[attr.data-pending]': 'formField()?.pending() ? \"\" : null',\n '[attr.data-disabled]': 'formField()?.disabled() ? \"\" : null',\n },\n})\nexport class NgpLabel {\n /**\n * The id of the label. If not provided, a unique id will be generated.\n */\n readonly id = input<string>(uniqueId('ngp-label'));\n /**\n * Access the form field that the label is associated with.\n */\n protected readonly formField = injectFormFieldState({ optional: true });\n /**\n * Derive the for attribute value if the label is an HTML label element.\n */\n protected readonly htmlFor = computed(() => this.formField()?.formControl());\n /**\n * Access the element that the label is associated with.\n */\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n /**\n * Determine if the label is an HTML label element.\n */\n protected readonly isLabel = this.elementRef.nativeElement instanceof HTMLLabelElement;\n\n constructor() {\n effect(onCleanup => {\n this.formField()?.addLabel(this.id());\n onCleanup(() => this.formField()?.removeLabel(this.id()));\n });\n }\n\n @HostListener('click', ['$event'])\n protected onClick(event: MouseEvent): void {\n // by default a label will perform a click on the associated form control, however\n // this only works if the associated form control is an input element which may not always\n // be the case, so we prevent the default behavior and handle the click event ourselves.\n // This was inspired by the HeadlessUI approach:\n // https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-react/src/components/label/label.tsx#L58\n if (this.isLabel) {\n event.preventDefault();\n }\n\n // to find the associated form control we can lookup via the known id\n const targetId = this.htmlFor();\n\n if (!targetId) {\n return;\n }\n\n const target = document.getElementById(targetId);\n\n if (!target) {\n return;\n }\n\n // if the target is disabled then do nothing\n const disabled = target.getAttribute('disabled');\n const ariaDisabled = target.getAttribute('aria-disabled');\n\n if (disabled === '' || disabled === 'true' || ariaDisabled === 'true') {\n return;\n }\n\n // radio buttons, checkboxes and switches should all be clicked immediately as they require state changes\n if (\n (target instanceof HTMLInputElement &&\n (target.type === 'radio' || target.type === 'checkbox')) ||\n target.role === 'radio' ||\n target.role === 'checkbox' ||\n target.role === 'switch'\n ) {\n target.click();\n }\n\n // Move focus to the element, this allows you to start using keyboard shortcuts since the\n // bound element is now focused.\n target.focus({ preventScroll: true });\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAQA;;AAEG;AACI,MAAM,sBAAsB,GAAG,gBAAgB,CAAe,WAAW,CAAC;AAEjF;;AAEG;MACU,qBAAqB,GAAG,mBAAmB,CAAC,sBAAsB;AAE/E;;AAEG;MACU,oBAAoB,GAAG,mBAAmB,CAAe,sBAAsB;AAE5F;;AAEG;AACI,MAAM,cAAc,GAAG,WAAW,CAAC,sBAAsB,CAAC;;AC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A,YAAY,EAAE,WAAW;AACzB,wBAAA,qBAAqB,EAAE,oCAAoC;AAC3D,wBAAA,mBAAmB,EAAE,kCAAkC;AACvD,wBAAA,qBAAqB,EAAE,oCAAoC;AAC3D,wBAAA,sBAAsB,EAAE,qCAAqC;AAC7D,wBAAA,mBAAmB,EAAE,kCAAkC;AACvD,wBAAA,qBAAqB,EAAE,oCAAoC;AAC3D,wBAAA,sBAAsB,EAAE,qCAAqC;AAC9D,qBAAA;AACF,iBAAA;wDA+BW,OAAO,EAAA,CAAA;sBADhB,YAAY;uBAAC,OAAO,EAAE,CAAC,QAAQ,CAAC;;;AC3DnC;;AAEG;;;;"}
|
|
@@ -5,6 +5,7 @@ import { NgpAutofill } from 'ng-primitives/autofill';
|
|
|
5
5
|
import { setupFormControl } from 'ng-primitives/form-field';
|
|
6
6
|
import { injectElementRef, setupInteractions } from 'ng-primitives/internal';
|
|
7
7
|
import { injectSearchState } from 'ng-primitives/search';
|
|
8
|
+
import { uniqueId } from 'ng-primitives/utils';
|
|
8
9
|
import { createStateToken, createStateProvider, createStateInjector, createState } from 'ng-primitives/state';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -26,6 +27,10 @@ const inputState = createState(NgpInputStateToken);
|
|
|
26
27
|
|
|
27
28
|
class NgpInput {
|
|
28
29
|
constructor() {
|
|
30
|
+
/**
|
|
31
|
+
* The id of the input.
|
|
32
|
+
*/
|
|
33
|
+
this.id = input(uniqueId('ngp-input'));
|
|
29
34
|
/**
|
|
30
35
|
* The input may be used within a search field, if so we need to register it.
|
|
31
36
|
*/
|
|
@@ -50,11 +55,11 @@ class NgpInput {
|
|
|
50
55
|
focus: true,
|
|
51
56
|
disabled: this.state.disabled,
|
|
52
57
|
});
|
|
53
|
-
setupFormControl({ disabled: this.state.disabled });
|
|
58
|
+
setupFormControl({ id: this.state.id, disabled: this.state.disabled });
|
|
54
59
|
this.searchState()?.registerInput(this.elementRef.nativeElement);
|
|
55
60
|
}
|
|
56
61
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: NgpInput, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
57
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.11", type: NgpInput, isStandalone: true, selector: "input[ngpInput]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.disabled": "disabled() ? \"\" : null" } }, providers: [provideInputState()], exportAs: ["ngpInput"], hostDirectives: [{ directive: i1.NgpAutofill }], ngImport: i0 }); }
|
|
62
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.11", type: NgpInput, isStandalone: true, selector: "input[ngpInput]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.id": "id()", "attr.disabled": "disabled() ? \"\" : null" } }, providers: [provideInputState()], exportAs: ["ngpInput"], hostDirectives: [{ directive: i1.NgpAutofill }], ngImport: i0 }); }
|
|
58
63
|
}
|
|
59
64
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: NgpInput, decorators: [{
|
|
60
65
|
type: Directive,
|
|
@@ -64,6 +69,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImpo
|
|
|
64
69
|
providers: [provideInputState()],
|
|
65
70
|
hostDirectives: [NgpAutofill],
|
|
66
71
|
host: {
|
|
72
|
+
'[attr.id]': 'id()',
|
|
67
73
|
'[attr.disabled]': 'disabled() ? "" : null',
|
|
68
74
|
},
|
|
69
75
|
}]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-input.mjs","sources":["../../../../packages/ng-primitives/input/src/input/input-state.ts","../../../../packages/ng-primitives/input/src/input/input.ts","../../../../packages/ng-primitives/input/src/ng-primitives-input.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpInput } from './input';\n\n/**\n * The state token for the Input primitive.\n */\nexport const NgpInputStateToken = createStateToken<NgpInput>('Input');\n\n/**\n * Provides the Input state.\n */\nexport const provideInputState = createStateProvider(NgpInputStateToken);\n\n/**\n * Injects the Input state.\n */\nexport const injectInputState = createStateInjector(NgpInputStateToken);\n\n/**\n * The Input state registration function.\n */\nexport const inputState = createState(NgpInputStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input } from '@angular/core';\nimport { NgpAutofill } from 'ng-primitives/autofill';\nimport { setupFormControl } from 'ng-primitives/form-field';\nimport { injectElementRef, setupInteractions } from 'ng-primitives/internal';\nimport { injectSearchState } from 'ng-primitives/search';\nimport { inputState, provideInputState } from './input-state';\n\n@Directive({\n selector: 'input[ngpInput]',\n exportAs: 'ngpInput',\n providers: [provideInputState()],\n hostDirectives: [NgpAutofill],\n host: {\n '[attr.disabled]': 'disabled() ? \"\" : null',\n },\n})\nexport class NgpInput {\n /**\n * The input may be used within a search field, if so we need to register it.\n */\n private readonly searchState = injectSearchState({ optional: true });\n\n /**\n * Access the element reference.\n */\n private readonly elementRef = injectElementRef<HTMLInputElement>();\n\n /**\n * Whether the element is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n transform: booleanAttribute,\n });\n\n /**\n * The input state.\n */\n protected readonly state = inputState<NgpInput>(this);\n\n constructor() {\n setupInteractions({\n hover: true,\n press: true,\n focus: true,\n disabled: this.state.disabled,\n });\n setupFormControl({ disabled: this.state.disabled });\n\n this.searchState()?.registerInput(this.elementRef.nativeElement);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ng-primitives-input.mjs","sources":["../../../../packages/ng-primitives/input/src/input/input-state.ts","../../../../packages/ng-primitives/input/src/input/input.ts","../../../../packages/ng-primitives/input/src/ng-primitives-input.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpInput } from './input';\n\n/**\n * The state token for the Input primitive.\n */\nexport const NgpInputStateToken = createStateToken<NgpInput>('Input');\n\n/**\n * Provides the Input state.\n */\nexport const provideInputState = createStateProvider(NgpInputStateToken);\n\n/**\n * Injects the Input state.\n */\nexport const injectInputState = createStateInjector<NgpInput>(NgpInputStateToken);\n\n/**\n * The Input state registration function.\n */\nexport const inputState = createState(NgpInputStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input } from '@angular/core';\nimport { NgpAutofill } from 'ng-primitives/autofill';\nimport { setupFormControl } from 'ng-primitives/form-field';\nimport { injectElementRef, setupInteractions } from 'ng-primitives/internal';\nimport { injectSearchState } from 'ng-primitives/search';\nimport { uniqueId } from 'ng-primitives/utils';\nimport { inputState, provideInputState } from './input-state';\n\n@Directive({\n selector: 'input[ngpInput]',\n exportAs: 'ngpInput',\n providers: [provideInputState()],\n hostDirectives: [NgpAutofill],\n host: {\n '[attr.id]': 'id()',\n '[attr.disabled]': 'disabled() ? \"\" : null',\n },\n})\nexport class NgpInput {\n /**\n * The id of the input.\n */\n readonly id = input(uniqueId('ngp-input'));\n\n /**\n * The input may be used within a search field, if so we need to register it.\n */\n private readonly searchState = injectSearchState({ optional: true });\n\n /**\n * Access the element reference.\n */\n private readonly elementRef = injectElementRef<HTMLInputElement>();\n\n /**\n * Whether the element is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n transform: booleanAttribute,\n });\n\n /**\n * The input state.\n */\n protected readonly state = inputState<NgpInput>(this);\n\n constructor() {\n setupInteractions({\n hover: true,\n press: true,\n focus: true,\n disabled: this.state.disabled,\n });\n setupFormControl({ id: this.state.id, disabled: this.state.disabled });\n\n this.searchState()?.registerInput(this.elementRef.nativeElement);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAQA;;AAEG;AACI,MAAM,kBAAkB,GAAG,gBAAgB,CAAW,OAAO,CAAC;AAErE;;AAEG;MACU,iBAAiB,GAAG,mBAAmB,CAAC,kBAAkB;AAEvE;;AAEG;MACU,gBAAgB,GAAG,mBAAmB,CAAW,kBAAkB;AAEhF;;AAEG;AACI,MAAM,UAAU,GAAG,WAAW,CAAC,kBAAkB,CAAC;;MCP5C,QAAQ,CAAA;AA4BnB,IAAA,WAAA,GAAA;AA3BA;;AAEG;QACM,IAAE,CAAA,EAAA,GAAG,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAE1C;;AAEG;QACc,IAAW,CAAA,WAAA,GAAG,iBAAiB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAEpE;;AAEG;QACc,IAAU,CAAA,UAAA,GAAG,gBAAgB,EAAoB;AAElE;;AAEG;AACM,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,EAAE;AACtD,YAAA,SAAS,EAAE,gBAAgB;AAC5B,SAAA,CAAC;AAEF;;AAEG;AACgB,QAAA,IAAA,CAAA,KAAK,GAAG,UAAU,CAAW,IAAI,CAAC;AAGnD,QAAA,iBAAiB,CAAC;AAChB,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ;AAC9B,SAAA,CAAC;AACF,QAAA,gBAAgB,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;AAEtE,QAAA,IAAI,CAAC,WAAW,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC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AACnB,wBAAA,iBAAiB,EAAE,wBAAwB;AAC5C,qBAAA;AACF,iBAAA;;;AClBD;;AAEG;;;;"}
|
|
@@ -19,7 +19,9 @@ const provideListboxState = createStateProvider(NgpListboxStateToken);
|
|
|
19
19
|
/**
|
|
20
20
|
* Injects the Listbox state.
|
|
21
21
|
*/
|
|
22
|
-
const injectListboxState = createStateInjector(NgpListboxStateToken, {
|
|
22
|
+
const injectListboxState = createStateInjector(NgpListboxStateToken, {
|
|
23
|
+
deferred: true,
|
|
24
|
+
});
|
|
23
25
|
/**
|
|
24
26
|
* The Listbox state registration function.
|
|
25
27
|
*/
|