@radix-ng/primitives 0.20.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/avatar/src/avatar-fallback.directive.d.ts +1 -1
  2. package/avatar/src/avatar-image.directive.d.ts +3 -3
  3. package/compodoc/documentation.json +6022 -1655
  4. package/core/index.d.ts +1 -0
  5. package/core/src/id-generator.d.ts +12 -0
  6. package/esm2022/avatar/src/avatar-fallback.directive.mjs +6 -8
  7. package/esm2022/avatar/src/avatar-image.directive.mjs +4 -3
  8. package/esm2022/core/index.mjs +2 -1
  9. package/esm2022/core/src/create-inject-context/index.mjs +2 -2
  10. package/esm2022/core/src/id-generator.mjs +43 -0
  11. package/esm2022/popover/index.mjs +14 -4
  12. package/esm2022/popover/src/popover-anchor.directive.mjs +70 -0
  13. package/esm2022/popover/src/popover-anchor.token.mjs +3 -0
  14. package/esm2022/popover/src/popover-arrow.directive.mjs +12 -7
  15. package/esm2022/popover/src/popover-close.directive.mjs +17 -5
  16. package/esm2022/popover/src/popover-close.token.mjs +3 -0
  17. package/esm2022/popover/src/popover-content-attributes.component.mjs +70 -0
  18. package/esm2022/popover/src/popover-content-attributes.token.mjs +3 -0
  19. package/esm2022/popover/src/popover-content.directive.mjs +120 -92
  20. package/esm2022/popover/src/popover-root.directive.mjs +234 -61
  21. package/esm2022/popover/src/popover-root.inject.mjs +4 -4
  22. package/esm2022/popover/src/popover-trigger.directive.mjs +10 -11
  23. package/esm2022/popover/src/popover.constants.mjs +2 -2
  24. package/esm2022/popover/src/popover.types.mjs +18 -1
  25. package/esm2022/popover/src/popover.utils.mjs +4 -6
  26. package/esm2022/switch/src/switch-input.directive.mjs +16 -7
  27. package/esm2022/switch/src/switch-root.directive.mjs +59 -14
  28. package/esm2022/switch/src/switch-thumb.directive.mjs +3 -3
  29. package/esm2022/toggle/index.mjs +2 -2
  30. package/esm2022/toggle/src/toggle-visually-hidden-input.directive.mjs +31 -0
  31. package/esm2022/toggle/src/toggle.directive.mjs +37 -8
  32. package/fesm2022/radix-ng-primitives-avatar.mjs +8 -9
  33. package/fesm2022/radix-ng-primitives-avatar.mjs.map +1 -1
  34. package/fesm2022/radix-ng-primitives-core.mjs +44 -3
  35. package/fesm2022/radix-ng-primitives-core.mjs.map +1 -1
  36. package/fesm2022/radix-ng-primitives-popover.mjs +679 -312
  37. package/fesm2022/radix-ng-primitives-popover.mjs.map +1 -1
  38. package/fesm2022/radix-ng-primitives-switch.mjs +76 -22
  39. package/fesm2022/radix-ng-primitives-switch.mjs.map +1 -1
  40. package/fesm2022/radix-ng-primitives-toggle.mjs +45 -15
  41. package/fesm2022/radix-ng-primitives-toggle.mjs.map +1 -1
  42. package/package.json +1 -1
  43. package/popover/index.d.ts +5 -1
  44. package/popover/src/popover-anchor.directive.d.ts +28 -0
  45. package/popover/src/popover-anchor.token.d.ts +3 -0
  46. package/popover/src/popover-arrow.directive.d.ts +8 -5
  47. package/popover/src/popover-close.directive.d.ts +2 -2
  48. package/popover/src/popover-close.token.d.ts +3 -0
  49. package/popover/src/popover-content-attributes.component.d.ts +17 -0
  50. package/popover/src/popover-content-attributes.token.d.ts +3 -0
  51. package/popover/src/popover-content.directive.d.ts +35 -24
  52. package/popover/src/popover-root.directive.d.ts +91 -18
  53. package/popover/src/popover-root.inject.d.ts +2 -1
  54. package/popover/src/popover-trigger.directive.d.ts +5 -5
  55. package/popover/src/popover.constants.d.ts +1 -1
  56. package/popover/src/popover.types.d.ts +14 -3
  57. package/switch/src/switch-input.directive.d.ts +2 -0
  58. package/switch/src/switch-root.directive.d.ts +33 -5
  59. package/toggle/index.d.ts +2 -2
  60. package/toggle/src/toggle-visually-hidden-input.directive.d.ts +6 -0
  61. package/toggle/src/toggle.directive.d.ts +19 -2
  62. package/esm2022/popover/src/popover-root.token.mjs +0 -3
  63. package/esm2022/toggle/src/toggle-input.directive.mjs +0 -30
  64. package/popover/src/popover-root.token.d.ts +0 -3
  65. package/toggle/src/toggle-input.directive.d.ts +0 -6
@@ -1 +1 @@
1
- {"version":3,"file":"radix-ng-primitives-switch.mjs","sources":["../../../packages/primitives/switch/src/switch-root.directive.ts","../../../packages/primitives/switch/src/switch-input.directive.ts","../../../packages/primitives/switch/src/switch-thumb.directive.ts","../../../packages/primitives/switch/index.ts","../../../packages/primitives/switch/radix-ng-primitives-switch.ts"],"sourcesContent":["import { BooleanInput } from '@angular/cdk/coercion';\nimport {\n booleanAttribute,\n computed,\n Directive,\n inject,\n InjectionToken,\n input,\n InputSignalWithTransform,\n model,\n ModelSignal,\n output,\n OutputEmitterRef\n} from '@angular/core';\n\nexport const RdxSwitchToken = new InjectionToken<RdxSwitchRootDirective>('RdxSwitchToken');\n\nexport function injectSwitch(): RdxSwitchRootDirective {\n return inject(RdxSwitchToken);\n}\n\nexport interface SwitchProps {\n checked?: ModelSignal<boolean>;\n defaultChecked?: boolean;\n required?: InputSignalWithTransform<boolean, BooleanInput>;\n onCheckedChange?: OutputEmitterRef<boolean>;\n}\n\nlet idIterator = 0;\n\n@Directive({\n selector: 'button[rdxSwitchRoot]',\n exportAs: 'rdxSwitchRoot',\n standalone: true,\n providers: [\n { provide: RdxSwitchToken, useExisting: RdxSwitchRootDirective }],\n host: {\n role: 'switch',\n type: 'button',\n '[id]': 'elementId()',\n '[attr.aria-checked]': 'checked()',\n '[attr.aria-required]': 'required',\n '[attr.data-state]': 'checked() ? \"checked\" : \"unchecked\"',\n '[attr.data-disabled]': 'disabledState() ? \"true\" : null',\n '[attr.disabled]': 'disabledState() ? disabledState() : null',\n\n '(click)': 'toggle()'\n }\n})\nexport class RdxSwitchRootDirective implements SwitchProps {\n readonly id = input<string>(`rdx-switch-${idIterator++}`);\n protected readonly elementId = computed(() => (this.id() ? this.id() : null));\n\n /**\n * When true, indicates that the user must check the switch before the owning form can be submitted.\n */\n readonly required = input<boolean, BooleanInput>(false, {\n transform: booleanAttribute\n });\n\n /**\n * The controlled state of the switch. Must be used in conjunction with onCheckedChange.\n */\n readonly checked = model<boolean>(false);\n\n /**\n * When true, prevents the user from interacting with the switch.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n transform: booleanAttribute\n });\n\n /*\n * @ignore\n */\n readonly disabledState = computed(() => this.disabled());\n\n /**\n * Event handler called when the state of the switch changes.\n */\n readonly onCheckedChange = output<boolean>();\n\n /**\n * Toggles the checked state of the switch.\n * If the switch is disabled, the function returns early.\n */\n protected toggle(): void {\n if (this.disabledState()) {\n return;\n }\n\n this.checked.set(!this.checked());\n\n this.onCheckedChange.emit(this.checked());\n }\n}\n","import { Directive } from '@angular/core';\nimport { injectSwitch } from './switch-root.directive';\n\n@Directive({\n selector: 'input[rdxSwitchInput]',\n exportAs: 'rdxSwitchInput',\n standalone: true,\n host: {\n type: 'checkbox',\n tabindex: '-1',\n '[attr.defaultChecked]': 'switchRoot.checked()',\n '[attr.aria-checked]': 'switchRoot.checked()',\n '[attr.aria-hidden]': 'true',\n '[attr.aria-required]': 'switchRoot.required()',\n '[attr.data-state]': 'switchRoot.checked() ? \"checked\" : \"unchecked\"',\n '[attr.data-disabled]': 'switchRoot.disabledState() ? \"true\" : null',\n '[attr.disabled]': 'switchRoot.disabledState() ? switchRoot.disabledState() : null',\n '[attr.value]': 'switchRoot.checked() ? \"on\" : \"off\"',\n style: 'transform: translateX(-100%); position: absolute; overflow: hidden; pointerEvents: none; opacity: 0; margin: 0;'\n }\n})\nexport class RdxSwitchInputDirective {\n protected readonly switchRoot = injectSwitch();\n}\n","import { Directive } from '@angular/core';\nimport { injectSwitch } from './switch-root.directive';\n\n@Directive({\n selector: 'span[rdxSwitchThumb]',\n exportAs: 'rdxSwitchThumb',\n standalone: true,\n host: {\n '[attr.data-disabled]': 'switchRoot.disabledState() ? \"true\" : null',\n '[attr.data-state]': 'switchRoot.checked() ? \"checked\" : \"unchecked\"'\n }\n})\nexport class RdxSwitchThumbDirective {\n protected readonly switchRoot = injectSwitch();\n}\n","import { NgModule } from '@angular/core';\nimport { RdxSwitchInputDirective } from './src/switch-input.directive';\nimport { RdxSwitchRootDirective } from './src/switch-root.directive';\nimport { RdxSwitchThumbDirective } from './src/switch-thumb.directive';\n\nexport * from './src/switch-input.directive';\nexport * from './src/switch-root.directive';\nexport * from './src/switch-thumb.directive';\n\nexport type { SwitchProps } from './src/switch-root.directive';\n\nconst switchImports = [\n RdxSwitchRootDirective,\n RdxSwitchInputDirective,\n RdxSwitchThumbDirective\n];\n\n@NgModule({\n imports: [...switchImports],\n exports: [...switchImports]\n})\nexport class RdxSwitchModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;MAea,cAAc,GAAG,IAAI,cAAc,CAAyB,gBAAgB;SAEzE,YAAY,GAAA;AACxB,IAAA,OAAO,MAAM,CAAC,cAAc,CAAC;AACjC;AASA,IAAI,UAAU,GAAG,CAAC;MAqBL,sBAAsB,CAAA;AAnBnC,IAAA,WAAA,GAAA;QAoBa,IAAE,CAAA,EAAA,GAAG,KAAK,CAAS,CAAA,WAAA,EAAc,UAAU,EAAE,CAAA,CAAE,CAAC;QACtC,IAAS,CAAA,SAAA,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;AAE7E;;AAEG;AACM,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,EAAE;AACpD,YAAA,SAAS,EAAE;AACd,SAAA,CAAC;AAEF;;AAEG;AACM,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAAU,KAAK,CAAC;AAExC;;AAEG;AACM,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,EAAE;AACpD,YAAA,SAAS,EAAE;AACd,SAAA,CAAC;AAEF;;AAEG;QACM,IAAa,CAAA,aAAA,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;AAExD;;AAEG;QACM,IAAe,CAAA,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FAAf,eAAe,EAAA,UAAA,EAAA,CAAA;kBAJ3B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,OAAO,EAAE,CAAC,GAAG,aAAa,CAAC;AAC3B,oBAAA,OAAO,EAAE,CAAC,GAAG,aAAa;AAC7B,iBAAA;;;ACpBD;;AAEG;;;;"}
1
+ {"version":3,"file":"radix-ng-primitives-switch.mjs","sources":["../../../packages/primitives/switch/src/switch-root.directive.ts","../../../packages/primitives/switch/src/switch-input.directive.ts","../../../packages/primitives/switch/src/switch-thumb.directive.ts","../../../packages/primitives/switch/index.ts","../../../packages/primitives/switch/radix-ng-primitives-switch.ts"],"sourcesContent":["import { BooleanInput } from '@angular/cdk/coercion';\nimport {\n booleanAttribute,\n computed,\n Directive,\n effect,\n forwardRef,\n inject,\n InjectionToken,\n input,\n InputSignalWithTransform,\n model,\n ModelSignal,\n output,\n OutputEmitterRef,\n signal\n} from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\n\nexport const RdxSwitchToken = new InjectionToken<RdxSwitchRootDirective>('RdxSwitchToken');\n\nexport function injectSwitch(): RdxSwitchRootDirective {\n return inject(RdxSwitchToken);\n}\n\nexport const SWITCH_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => RdxSwitchRootDirective),\n multi: true\n};\n\nexport interface SwitchProps {\n checked?: ModelSignal<boolean>;\n defaultChecked?: InputSignalWithTransform<boolean, BooleanInput>;\n required?: InputSignalWithTransform<boolean, BooleanInput>;\n onCheckedChange?: OutputEmitterRef<boolean>;\n}\n\nlet idIterator = 0;\n\n@Directive({\n selector: 'button[rdxSwitchRoot]',\n exportAs: 'rdxSwitchRoot',\n standalone: true,\n providers: [\n { provide: RdxSwitchToken, useExisting: RdxSwitchRootDirective },\n SWITCH_VALUE_ACCESSOR\n ],\n host: {\n type: 'button',\n '[id]': 'elementId()',\n '[attr.aria-checked]': 'checkedState()',\n '[attr.aria-required]': 'required()',\n '[attr.data-state]': 'checkedState() ? \"checked\" : \"unchecked\"',\n '[attr.data-disabled]': 'disabledState() ? \"true\" : null',\n '[attr.disabled]': 'disabledState() ? disabledState() : null',\n\n '(click)': 'toggle()'\n }\n})\nexport class RdxSwitchRootDirective implements SwitchProps, ControlValueAccessor {\n readonly id = input<string | null>(`rdx-switch-${idIterator++}`);\n\n protected readonly elementId = computed(() => (this.id() ? this.id() : null));\n\n readonly inputId = input<string | null>(null);\n\n /**\n * When true, indicates that the user must check the switch before the owning form can be submitted.\n */\n readonly required = input<boolean, BooleanInput>(false, {\n transform: booleanAttribute\n });\n\n readonly ariaLabelledBy = input<string | null>(null, {\n alias: 'aria-labelledby'\n });\n\n readonly ariaLabel = input<string | null>(null, {\n alias: 'aria-label'\n });\n\n /**\n * The controlled state of the switch. Must be used in conjunction with onCheckedChange.\n */\n readonly checked = model<boolean>(false);\n\n readonly defaultChecked = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n /**\n * The state of the switch.\n * If `defaultChecked` is provided, it takes precedence over the `checked` state.\n * @ignore\n */\n readonly checkedState = computed(() => this.checked());\n\n /**\n * When true, prevents the user from interacting with the switch.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n transform: booleanAttribute\n });\n\n /** @ignore */\n readonly disabledState = computed(() => this.disabled() || this.accessorDisabled());\n\n /**\n * Event handler called when the state of the switch changes.\n */\n readonly onCheckedChange = output<boolean>();\n\n private readonly defaultCheckedUsed = computed(() => this.defaultChecked());\n\n constructor() {\n effect(\n () => {\n if (this.defaultCheckedUsed()) {\n this.checked.set(this.defaultChecked());\n }\n },\n { allowSignalWrites: true }\n );\n }\n\n /**\n * Toggles the checked state of the switch.\n * If the switch is disabled, the function returns early.\n * @ignore\n */\n toggle(): void {\n if (this.disabledState()) {\n return;\n }\n\n this.checked.set(!this.checked());\n\n this.onChange(this.checked());\n this.onCheckedChange.emit(this.checked());\n }\n\n private readonly accessorDisabled = signal(false);\n\n private onChange: (value: any) => void = () => {};\n /** @ignore */\n onTouched: (() => void) | undefined;\n\n /** @ignore */\n writeValue(value: any): void {\n this.checked.set(value);\n }\n\n /** @ignore */\n registerOnChange(fn: (value: any) => void): void {\n this.onChange = fn;\n }\n\n /** @ignore */\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n\n /** @ignore */\n setDisabledState(isDisabled: boolean): void {\n this.accessorDisabled.set(isDisabled);\n }\n}\n","import { Directive } from '@angular/core';\nimport { injectSwitch } from './switch-root.directive';\n\n@Directive({\n selector: 'input[rdxSwitchInput]',\n exportAs: 'rdxSwitchInput',\n standalone: true,\n host: {\n type: 'checkbox',\n role: 'switch',\n tabindex: '-1',\n '[attr.id]': 'switchRoot.inputId()',\n '[attr.defaultChecked]': 'switchRoot.checkedState()',\n '[attr.aria-checked]': 'switchRoot.checkedState()',\n '[attr.aria-hidden]': 'true',\n '[attr.aria-label]': 'switchRoot.ariaLabel()',\n '[attr.aria-labelledby]': 'switchRoot.ariaLabelledBy()',\n '[attr.aria-required]': 'switchRoot.required()',\n '[attr.data-state]': 'switchRoot.checkedState() ? \"checked\" : \"unchecked\"',\n '[attr.data-disabled]': 'switchRoot.disabledState() ? \"true\" : null',\n '[attr.disabled]': 'switchRoot.disabledState() ? switchRoot.disabledState() : null',\n '[attr.value]': 'switchRoot.checkedState() ? \"on\" : \"off\"',\n style: 'transform: translateX(-100%); position: absolute; overflow: hidden; pointerEvents: none; opacity: 0; margin: 0;',\n\n '(blur)': 'onBlur()'\n }\n})\nexport class RdxSwitchInputDirective {\n protected readonly switchRoot = injectSwitch();\n\n /** @ignore */\n protected onBlur() {\n this.switchRoot.onTouched?.();\n }\n}\n","import { Directive } from '@angular/core';\nimport { injectSwitch } from './switch-root.directive';\n\n@Directive({\n selector: 'span[rdxSwitchThumb]',\n exportAs: 'rdxSwitchThumb',\n standalone: true,\n host: {\n '[attr.data-disabled]': 'switchRoot.disabledState() ? \"true\" : null',\n '[attr.data-state]': 'switchRoot.checkedState() ? \"checked\" : \"unchecked\"'\n }\n})\nexport class RdxSwitchThumbDirective {\n protected readonly switchRoot = injectSwitch();\n}\n","import { NgModule } from '@angular/core';\nimport { RdxSwitchInputDirective } from './src/switch-input.directive';\nimport { RdxSwitchRootDirective } from './src/switch-root.directive';\nimport { RdxSwitchThumbDirective } from './src/switch-thumb.directive';\n\nexport * from './src/switch-input.directive';\nexport * from './src/switch-root.directive';\nexport * from './src/switch-thumb.directive';\n\nexport type { SwitchProps } from './src/switch-root.directive';\n\nconst switchImports = [\n RdxSwitchRootDirective,\n RdxSwitchInputDirective,\n RdxSwitchThumbDirective\n];\n\n@NgModule({\n imports: [...switchImports],\n exports: [...switchImports]\n})\nexport class RdxSwitchModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAmBa,cAAc,GAAG,IAAI,cAAc,CAAyB,gBAAgB;SAEzE,YAAY,GAAA;AACxB,IAAA,OAAO,MAAM,CAAC,cAAc,CAAC;AACjC;AAEa,MAAA,qBAAqB,GAAQ;AACtC,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,WAAW,EAAE,UAAU,CAAC,MAAM,sBAAsB,CAAC;AACrD,IAAA,KAAK,EAAE;;AAUX,IAAI,UAAU,GAAG,CAAC;MAsBL,sBAAsB,CAAA;AAqD/B,IAAA,WAAA,GAAA;QApDS,IAAE,CAAA,EAAA,GAAG,KAAK,CAAgB,CAAA,WAAA,EAAc,UAAU,EAAE,CAAA,CAAE,CAAC;QAE7C,IAAS,CAAA,SAAA,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;AAEpE,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAAgB,IAAI,CAAC;AAE7C;;AAEG;AACM,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,EAAE;AACpD,YAAA,SAAS,EAAE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ACtB,uBAAuB;YACvB,uBAAuB,CAAA,EAAA,CAAA,CAAA;gHAOd,eAAe,EAAA,CAAA,CAAA;;4FAAf,eAAe,EAAA,UAAA,EAAA,CAAA;kBAJ3B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,OAAO,EAAE,CAAC,GAAG,aAAa,CAAC;AAC3B,oBAAA,OAAO,EAAE,CAAC,GAAG,aAAa;AAC7B,iBAAA;;;ACpBD;;AAEG;;;;"}
@@ -1,17 +1,18 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Directive, input, booleanAttribute, model, output } from '@angular/core';
2
+ import { Directive, forwardRef, input, booleanAttribute, model, computed, output, signal } from '@angular/core';
3
3
  import * as i1 from '@radix-ng/primitives/visually-hidden';
4
4
  import { RdxVisuallyHiddenInputDirective } from '@radix-ng/primitives/visually-hidden';
5
+ import { NG_VALUE_ACCESSOR } from '@angular/forms';
5
6
 
6
- class RdxToggleInputDirective {
7
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxToggleInputDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
8
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.11", type: RdxToggleInputDirective, isStandalone: true, selector: "[rdxToggleInput]", host: { attributes: { "type": "checkbox" } }, exportAs: ["rdxToggleInput"], hostDirectives: [{ directive: i1.RdxVisuallyHiddenInputDirective, inputs: ["name", "name", "required", "required", "value", "value"] }], ngImport: i0 }); }
7
+ class RdxToggleVisuallyHiddenInputDirective {
8
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxToggleVisuallyHiddenInputDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
9
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.11", type: RdxToggleVisuallyHiddenInputDirective, isStandalone: true, selector: "input[rdxToggleVisuallyHiddenInput]", host: { attributes: { "type": "checkbox" } }, exportAs: ["rdxToggleVisuallyHiddenInput"], hostDirectives: [{ directive: i1.RdxVisuallyHiddenInputDirective, inputs: ["name", "name", "required", "required", "value", "value", "disabled", "disabled"] }], ngImport: i0 }); }
9
10
  }
10
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxToggleInputDirective, decorators: [{
11
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxToggleVisuallyHiddenInputDirective, decorators: [{
11
12
  type: Directive,
12
13
  args: [{
13
- selector: '[rdxToggleInput]',
14
- exportAs: 'rdxToggleInput',
14
+ selector: 'input[rdxToggleVisuallyHiddenInput]',
15
+ exportAs: 'rdxToggleVisuallyHiddenInput',
15
16
  standalone: true,
16
17
  hostDirectives: [
17
18
  {
@@ -19,7 +20,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
19
20
  inputs: [
20
21
  'name',
21
22
  'required',
22
- 'value'
23
+ 'value',
24
+ 'disabled'
23
25
  ]
24
26
  }
25
27
  ],
@@ -29,6 +31,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
29
31
  }]
30
32
  }] });
31
33
 
34
+ const TOGGLE_VALUE_ACCESSOR = {
35
+ provide: NG_VALUE_ACCESSOR,
36
+ useExisting: forwardRef(() => RdxToggleDirective),
37
+ multi: true
38
+ };
32
39
  class RdxToggleDirective {
33
40
  constructor() {
34
41
  /**
@@ -45,19 +52,41 @@ class RdxToggleDirective {
45
52
  * When true, prevents the user from interacting with the toggle.
46
53
  */
47
54
  this.disabled = input(false, { transform: booleanAttribute });
55
+ /** @ignore */
56
+ this.disabledState = computed(() => this.disabled() || this.accessorDisabled());
57
+ this.dataState = computed(() => {
58
+ return this.pressed() ? 'on' : 'off';
59
+ });
48
60
  /**
49
61
  * Event handler called when the pressed state of the toggle changes.
50
62
  */
51
63
  this.onPressedChange = output();
64
+ this.accessorDisabled = signal(false);
52
65
  }
53
- toggle() {
66
+ togglePressed() {
54
67
  if (!this.disabled()) {
55
68
  this.pressed.set(!this.pressed());
56
69
  this.onPressedChange.emit(this.pressed());
57
70
  }
58
71
  }
72
+ /** @ignore */
73
+ writeValue(value) {
74
+ this.pressed.set(value);
75
+ }
76
+ /** @ignore */
77
+ registerOnChange(fn) {
78
+ this.onChange = fn;
79
+ }
80
+ /** @ignore */
81
+ registerOnTouched(fn) {
82
+ this.onTouched = fn;
83
+ }
84
+ /** @ignore */
85
+ setDisabledState(isDisabled) {
86
+ this.accessorDisabled.set(isDisabled);
87
+ }
59
88
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxToggleDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
60
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.11", type: RdxToggleDirective, isStandalone: true, selector: "[rdxToggle]", inputs: { defaultPressed: { classPropertyName: "defaultPressed", publicName: "defaultPressed", isSignal: true, isRequired: false, transformFunction: null }, pressed: { classPropertyName: "pressed", publicName: "pressed", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { pressed: "pressedChange", onPressedChange: "onPressedChange" }, host: { listeners: { "click": "toggle()" }, properties: { "attr.aria-pressed": "pressed()", "attr.data-state": "pressed() ? \"on\" : \"off\"", "attr.data-disabled": "disabled()", "disabled": "disabled()" } }, exportAs: ["rdxToggle"], ngImport: i0 }); }
89
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.11", type: RdxToggleDirective, isStandalone: true, selector: "[rdxToggle]", inputs: { defaultPressed: { classPropertyName: "defaultPressed", publicName: "defaultPressed", isSignal: true, isRequired: false, transformFunction: null }, pressed: { classPropertyName: "pressed", publicName: "pressed", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { pressed: "pressedChange", onPressedChange: "onPressedChange" }, host: { listeners: { "click": "togglePressed()" }, properties: { "attr.aria-pressed": "pressed()", "attr.data-state": "dataState()", "attr.data-disabled": "disabledState() ? \"\" : undefined", "disabled": "disabledState()" } }, providers: [TOGGLE_VALUE_ACCESSOR], exportAs: ["rdxToggle"], ngImport: i0 }); }
61
90
  }
62
91
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: RdxToggleDirective, decorators: [{
63
92
  type: Directive,
@@ -65,12 +94,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
65
94
  selector: '[rdxToggle]',
66
95
  exportAs: 'rdxToggle',
67
96
  standalone: true,
97
+ providers: [TOGGLE_VALUE_ACCESSOR],
68
98
  host: {
69
99
  '[attr.aria-pressed]': 'pressed()',
70
- '[attr.data-state]': 'pressed() ? "on" : "off"',
71
- '[attr.data-disabled]': 'disabled()',
72
- '[disabled]': 'disabled()',
73
- '(click)': 'toggle()'
100
+ '[attr.data-state]': 'dataState()',
101
+ '[attr.data-disabled]': 'disabledState() ? "" : undefined',
102
+ '[disabled]': 'disabledState()',
103
+ '(click)': 'togglePressed()'
74
104
  }
75
105
  }]
76
106
  }] });
@@ -79,5 +109,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
79
109
  * Generated bundle index. Do not edit.
80
110
  */
81
111
 
82
- export { RdxToggleDirective, RdxToggleInputDirective };
112
+ export { RdxToggleDirective, RdxToggleVisuallyHiddenInputDirective, TOGGLE_VALUE_ACCESSOR };
83
113
  //# sourceMappingURL=radix-ng-primitives-toggle.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"radix-ng-primitives-toggle.mjs","sources":["../../../packages/primitives/toggle/src/toggle-input.directive.ts","../../../packages/primitives/toggle/src/toggle.directive.ts","../../../packages/primitives/toggle/radix-ng-primitives-toggle.ts"],"sourcesContent":["import { Directive } from '@angular/core';\nimport { RdxVisuallyHiddenInputDirective } from '@radix-ng/primitives/visually-hidden';\n\n@Directive({\n selector: '[rdxToggleInput]',\n exportAs: 'rdxToggleInput',\n standalone: true,\n hostDirectives: [\n {\n directive: RdxVisuallyHiddenInputDirective,\n inputs: [\n 'name',\n 'required',\n 'value'\n ]\n }\n ],\n host: {\n type: 'checkbox'\n }\n})\nexport class RdxToggleInputDirective {}\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input, model, output, OutputEmitterRef } from '@angular/core';\n\nexport interface ToggleProps {\n /**\n * The controlled state of the toggle.\n */\n pressed?: boolean;\n\n /**\n * The state of the toggle when initially rendered. Use `defaultPressed`\n * if you do not need to control the state of the toggle.\n * @defaultValue false\n */\n defaultPressed?: boolean;\n\n /**\n * The callback that fires when the state of the toggle changes.\n */\n onPressedChange?: OutputEmitterRef<boolean>;\n\n /**\n * Whether the toggle is disabled.\n * @defaultValue false\n */\n disabled?: boolean;\n}\n\n@Directive({\n selector: '[rdxToggle]',\n exportAs: 'rdxToggle',\n standalone: true,\n host: {\n '[attr.aria-pressed]': 'pressed()',\n '[attr.data-state]': 'pressed() ? \"on\" : \"off\"',\n '[attr.data-disabled]': 'disabled()',\n '[disabled]': 'disabled()',\n\n '(click)': 'toggle()'\n }\n})\nexport class RdxToggleDirective {\n /**\n * The pressed state of the toggle when it is initially rendered.\n * Use when you do not need to control its pressed state.\n */\n readonly defaultPressed = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n /**\n * The controlled pressed state of the toggle.\n * Must be used in conjunction with `onPressedChange`.\n */\n readonly pressed = model<boolean>(this.defaultPressed());\n\n /**\n * When true, prevents the user from interacting with the toggle.\n */\n readonly disabled = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n /**\n * Event handler called when the pressed state of the toggle changes.\n */\n readonly onPressedChange = output<boolean>();\n\n protected toggle(): void {\n if (!this.disabled()) {\n this.pressed.set(!this.pressed());\n this.onPressedChange.emit(this.pressed());\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MAqBa,uBAAuB,CAAA;+GAAvB,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;mGAAvB,uBAAuB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,kBAAA,EAAA,IAAA,EAAA,EAAA,UAAA,EAAA,EAAA,MAAA,EAAA,UAAA,EAAA,EAAA,EAAA,QAAA,EAAA,CAAA,gBAAA,CAAA,EAAA,cAAA,EAAA,CAAA,EAAA,SAAA,EAAA,EAAA,CAAA,+BAAA,EAAA,MAAA,EAAA,CAAA,MAAA,EAAA,MAAA,EAAA,UAAA,EAAA,UAAA,EAAA,OAAA,EAAA,OAAA,CAAA,EAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAAvB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBAlBnC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACP,oBAAA,QAAQ,EAAE,kBAAkB;AAC5B,oBAAA,QAAQ,EAAE,gBAAgB;AAC1B,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,cAAc,EAAE;AACZ,wBAAA;AACI,4BAAA,SAAS,EAAE,+BAA+B;AAC1C,4BAAA,MAAM,EAAE;gCACJ,MAAM;gCACN,UAAU;gCACV;AACH;AACJ;AACJ,qBAAA;AACD,oBAAA,IAAI,EAAE;AACF,wBAAA,IAAI,EAAE;AACT;AACJ,iBAAA;;;MCqBY,kBAAkB,CAAA;AAb/B,IAAA,WAAA,GAAA;AAcI;;;AAGG;QACM,IAAc,CAAA,cAAA,GAAG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A,eAAA,EAAA,iBAAA,EAAA,EAAA,IAAA,EAAA,EAAA,SAAA,EAAA,EAAA,OAAA,EAAA,UAAA,EAAA,EAAA,UAAA,EAAA,EAAA,mBAAA,EAAA,WAAA,EAAA,iBAAA,EAAA,8BAAA,EAAA,oBAAA,EAAA,YAAA,EAAA,UAAA,EAAA,YAAA,EAAA,EAAA,EAAA,QAAA,EAAA,CAAA,WAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAAlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAb9B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACP,oBAAA,QAAQ,EAAE,aAAa;AACvB,oBAAA,QAAQ,EAAE,WAAW;AACrB,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,IAAI,EAAE;AACF,wBAAA,qBAAqB,EAAE,WAAW;AAClC,wBAAA,mBAAmB,EAAE,0BAA0B;AAC/C,wBAAA,sBAAsB,EAAE,YAAY;AACpC,wBAAA,YAAY,EAAE,YAAY;AAE1B,wBAAA,SAAS,EAAE;AACd;AACJ,iBAAA;;;ACxCD;;AAEG;;;;"}
1
+ {"version":3,"file":"radix-ng-primitives-toggle.mjs","sources":["../../../packages/primitives/toggle/src/toggle-visually-hidden-input.directive.ts","../../../packages/primitives/toggle/src/toggle.directive.ts","../../../packages/primitives/toggle/radix-ng-primitives-toggle.ts"],"sourcesContent":["import { Directive } from '@angular/core';\nimport { RdxVisuallyHiddenInputDirective } from '@radix-ng/primitives/visually-hidden';\n\n@Directive({\n selector: 'input[rdxToggleVisuallyHiddenInput]',\n exportAs: 'rdxToggleVisuallyHiddenInput',\n standalone: true,\n hostDirectives: [\n {\n directive: RdxVisuallyHiddenInputDirective,\n inputs: [\n 'name',\n 'required',\n 'value',\n 'disabled'\n ]\n }\n ],\n host: {\n type: 'checkbox'\n }\n})\nexport class RdxToggleVisuallyHiddenInputDirective {}\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport {\n booleanAttribute,\n computed,\n Directive,\n forwardRef,\n input,\n model,\n output,\n OutputEmitterRef,\n signal\n} from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\n\nexport interface ToggleProps {\n /**\n * The controlled state of the toggle.\n */\n pressed?: boolean;\n\n /**\n * The state of the toggle when initially rendered. Use `defaultPressed`\n * if you do not need to control the state of the toggle.\n * @defaultValue false\n */\n defaultPressed?: boolean;\n\n /**\n * The callback that fires when the state of the toggle changes.\n */\n onPressedChange?: OutputEmitterRef<boolean>;\n\n /**\n * Whether the toggle is disabled.\n * @defaultValue false\n */\n disabled?: boolean;\n}\n\nexport type DataState = 'on' | 'off';\n\nexport const TOGGLE_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => RdxToggleDirective),\n multi: true\n};\n\n@Directive({\n selector: '[rdxToggle]',\n exportAs: 'rdxToggle',\n standalone: true,\n providers: [TOGGLE_VALUE_ACCESSOR],\n host: {\n '[attr.aria-pressed]': 'pressed()',\n '[attr.data-state]': 'dataState()',\n '[attr.data-disabled]': 'disabledState() ? \"\" : undefined',\n '[disabled]': 'disabledState()',\n\n '(click)': 'togglePressed()'\n }\n})\nexport class RdxToggleDirective implements ControlValueAccessor {\n /**\n * The pressed state of the toggle when it is initially rendered.\n * Use when you do not need to control its pressed state.\n */\n readonly defaultPressed = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n /**\n * The controlled pressed state of the toggle.\n * Must be used in conjunction with `onPressedChange`.\n */\n readonly pressed = model<boolean>(this.defaultPressed());\n\n /**\n * When true, prevents the user from interacting with the toggle.\n */\n readonly disabled = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n /** @ignore */\n readonly disabledState = computed(() => this.disabled() || this.accessorDisabled());\n\n protected readonly dataState = computed<DataState>(() => {\n return this.pressed() ? 'on' : 'off';\n });\n\n /**\n * Event handler called when the pressed state of the toggle changes.\n */\n readonly onPressedChange = output<boolean>();\n\n protected togglePressed(): void {\n if (!this.disabled()) {\n this.pressed.set(!this.pressed());\n this.onPressedChange.emit(this.pressed());\n }\n }\n\n private readonly accessorDisabled = signal(false);\n\n private onChange: ((value: any) => void) | undefined;\n private onTouched: (() => void) | undefined;\n\n /** @ignore */\n writeValue(value: any): void {\n this.pressed.set(value);\n }\n\n /** @ignore */\n registerOnChange(fn: (value: any) => void): void {\n this.onChange = fn;\n }\n\n /** @ignore */\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n\n /** @ignore */\n setDisabledState(isDisabled: boolean): void {\n this.accessorDisabled.set(isDisabled);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;MAsBa,qCAAqC,CAAA;+GAArC,qCAAqC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;mGAArC,qCAAqC,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,qCAAA,EAAA,IAAA,EAAA,EAAA,UAAA,EAAA,EAAA,MAAA,EAAA,UAAA,EAAA,EAAA,EAAA,QAAA,EAAA,CAAA,8BAAA,CAAA,EAAA,cAAA,EAAA,CAAA,EAAA,SAAA,EAAA,EAAA,CAAA,+BAAA,EAAA,MAAA,EAAA,CAAA,MAAA,EAAA,MAAA,EAAA,UAAA,EAAA,UAAA,EAAA,OAAA,EAAA,OAAA,EAAA,UAAA,EAAA,UAAA,CAAA,EAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAArC,qCAAqC,EAAA,UAAA,EAAA,CAAA;kBAnBjD,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACP,oBAAA,QAAQ,EAAE,qCAAqC;AAC/C,oBAAA,QAAQ,EAAE,8BAA8B;AACxC,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,cAAc,EAAE;AACZ,wBAAA;AACI,4BAAA,SAA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EAAA,mBAAA,EAAA,WAAA,EAAA,iBAAA,EAAA,aAAA,EAAA,oBAAA,EAAA,oCAAA,EAAA,UAAA,EAAA,iBAAA,EAAA,EAAA,EAAA,SAAA,EAVhB,CAAC,qBAAqB,CAAC,EAAA,QAAA,EAAA,CAAA,WAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAUzB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAd9B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACP,oBAAA,QAAQ,EAAE,aAAa;AACvB,oBAAA,QAAQ,EAAE,WAAW;AACrB,oBAAA,UAAU,EAAE,IAAI;oBAChB,SAAS,EAAE,CAAC,qBAAqB,CAAC;AAClC,oBAAA,IAAI,EAAE;AACF,wBAAA,qBAAqB,EAAE,WAAW;AAClC,wBAAA,mBAAmB,EAAE,aAAa;AAClC,wBAAA,sBAAsB,EAAE,kCAAkC;AAC1D,wBAAA,YAAY,EAAE,iBAAiB;AAE/B,wBAAA,SAAS,EAAE;AACd;AACJ,iBAAA;;;AC5DD;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ng/primitives",
3
- "version": "0.20.1",
3
+ "version": "0.21.0",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -4,14 +4,18 @@ import * as i2 from "./src/popover-close.directive";
4
4
  import * as i3 from "./src/popover-content.directive";
5
5
  import * as i4 from "./src/popover-trigger.directive";
6
6
  import * as i5 from "./src/popover-root.directive";
7
+ import * as i6 from "./src/popover-anchor.directive";
8
+ import * as i7 from "./src/popover-content-attributes.component";
9
+ export * from './src/popover-anchor.directive';
7
10
  export * from './src/popover-arrow.directive';
8
11
  export * from './src/popover-close.directive';
12
+ export * from './src/popover-content-attributes.component';
9
13
  export * from './src/popover-content.directive';
10
14
  export * from './src/popover-root.directive';
11
15
  export * from './src/popover-trigger.directive';
12
16
  export * from './src/popover.types';
13
17
  export declare class RdxPopoverModule {
14
18
  static ɵfac: i0.ɵɵFactoryDeclaration<RdxPopoverModule, never>;
15
- static ɵmod: i0.ɵɵNgModuleDeclaration<RdxPopoverModule, never, [typeof i1.RdxPopoverArrowDirective, typeof i2.RdxPopoverCloseDirective, typeof i3.RdxPopoverContentDirective, typeof i4.RdxPopoverTriggerDirective, typeof i5.RdxPopoverRootDirective], [typeof i1.RdxPopoverArrowDirective, typeof i2.RdxPopoverCloseDirective, typeof i3.RdxPopoverContentDirective, typeof i4.RdxPopoverTriggerDirective, typeof i5.RdxPopoverRootDirective]>;
19
+ static ɵmod: i0.ɵɵNgModuleDeclaration<RdxPopoverModule, never, [typeof i1.RdxPopoverArrowDirective, typeof i2.RdxPopoverCloseDirective, typeof i3.RdxPopoverContentDirective, typeof i4.RdxPopoverTriggerDirective, typeof i5.RdxPopoverRootDirective, typeof i6.RdxPopoverAnchorDirective, typeof i7.RdxPopoverContentAttributesComponent], [typeof i1.RdxPopoverArrowDirective, typeof i2.RdxPopoverCloseDirective, typeof i3.RdxPopoverContentDirective, typeof i4.RdxPopoverTriggerDirective, typeof i5.RdxPopoverRootDirective, typeof i6.RdxPopoverAnchorDirective, typeof i7.RdxPopoverContentAttributesComponent]>;
16
20
  static ɵinj: i0.ɵɵInjectorDeclaration<RdxPopoverModule>;
17
21
  }
@@ -0,0 +1,28 @@
1
+ import { CdkOverlayOrigin } from '@angular/cdk/overlay';
2
+ import { ElementRef } from '@angular/core';
3
+ import { RdxPopoverRootDirective } from './popover-root.directive';
4
+ import * as i0 from "@angular/core";
5
+ import * as i1 from "@angular/cdk/overlay";
6
+ export declare class RdxPopoverAnchorDirective {
7
+ /**
8
+ * @ignore
9
+ * If outside the root then null, otherwise the root directive - with optional `true` passed in as the first param.
10
+ * If outside the root and non-null value that means the html structure is wrong - popover inside popover.
11
+ * */
12
+ protected popoverRoot: RdxPopoverRootDirective | null;
13
+ /** @ignore */
14
+ readonly elementRef: ElementRef<any>;
15
+ /** @ignore */
16
+ readonly overlayOrigin: CdkOverlayOrigin;
17
+ /** @ignore */
18
+ readonly document: Document;
19
+ /** @ignore */
20
+ readonly name: import("@angular/core").Signal<string>;
21
+ /** @ignore */
22
+ click(): void;
23
+ /** @ignore */
24
+ setPopoverRoot(popoverRoot: RdxPopoverRootDirective): void;
25
+ private emitOutsideClick;
26
+ static ɵfac: i0.ɵɵFactoryDeclaration<RdxPopoverAnchorDirective, never>;
27
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RdxPopoverAnchorDirective, "[rdxPopoverAnchor]", ["rdxPopoverAnchor"], {}, {}, never, never, true, [{ directive: typeof i1.CdkOverlayOrigin; inputs: {}; outputs: {}; }]>;
28
+ }
@@ -0,0 +1,3 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { RdxPopoverAnchorDirective } from './popover-anchor.directive';
3
+ export declare const RdxPopoverAnchorToken: InjectionToken<RdxPopoverAnchorDirective>;
@@ -1,4 +1,4 @@
1
- import { AfterViewInit } from '@angular/core';
1
+ import { AfterViewInit, ElementRef } from '@angular/core';
2
2
  import * as i0 from "@angular/core";
3
3
  export declare class RdxPopoverArrowDirective implements AfterViewInit {
4
4
  /** @ignore */
@@ -6,13 +6,15 @@ export declare class RdxPopoverArrowDirective implements AfterViewInit {
6
6
  /** @ignore */
7
7
  private readonly popoverRoot;
8
8
  /** @ignore */
9
- private readonly elementRef;
9
+ readonly elementRef: ElementRef<any>;
10
10
  /**
11
- * The width of the arrow in pixels.
11
+ * @description The width of the arrow in pixels.
12
+ * @default 10
12
13
  */
13
14
  readonly width: import("@angular/core").InputSignal<number>;
14
15
  /**
15
- * The height of the arrow in pixels.
16
+ * @description The height of the arrow in pixels.
17
+ * @default 5
16
18
  */
17
19
  readonly height: import("@angular/core").InputSignal<number>;
18
20
  /** @ignore */
@@ -22,10 +24,11 @@ export declare class RdxPopoverArrowDirective implements AfterViewInit {
22
24
  /** @ignore */
23
25
  private readonly position;
24
26
  /** @ignore */
25
- private triggerRect;
27
+ private anchorOrTriggerRect;
26
28
  constructor();
27
29
  /** @ignore */
28
30
  ngAfterViewInit(): void;
31
+ private setAnchorOrTriggerRect;
29
32
  /** @ignore */
30
33
  private setPosition;
31
34
  /** @ignore */
@@ -2,9 +2,9 @@ import { ElementRef } from '@angular/core';
2
2
  import * as i0 from "@angular/core";
3
3
  export declare class RdxPopoverCloseDirective {
4
4
  /** @ignore */
5
- readonly popoverRoot: import("@radix-ng/primitives/popover").RdxPopoverRootDirective;
5
+ protected readonly popoverRoot: import("@radix-ng/primitives/popover").RdxPopoverRootDirective;
6
6
  /** @ignore */
7
- readonly elementRef: ElementRef<HTMLElement>;
7
+ readonly elementRef: ElementRef<any>;
8
8
  /** @ignore */
9
9
  private readonly renderer;
10
10
  constructor();
@@ -0,0 +1,3 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { RdxPopoverCloseDirective } from './popover-close.directive';
3
+ export declare const RdxPopoverCloseToken: InjectionToken<RdxPopoverCloseDirective>;
@@ -0,0 +1,17 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare class RdxPopoverContentAttributesComponent {
3
+ /** @ignore */
4
+ protected readonly popoverRoot: import("@radix-ng/primitives/popover").RdxPopoverRootDirective;
5
+ /** @ignore */
6
+ readonly name: import("@angular/core").Signal<string>;
7
+ /** @ignore */
8
+ readonly disableAnimation: import("@angular/core").Signal<boolean>;
9
+ /** @ignore */
10
+ protected onAnimationStart(_: AnimationEvent): void;
11
+ /** @ignore */
12
+ protected onAnimationEnd(_: AnimationEvent): void;
13
+ /** @ignore */
14
+ private canAnimate;
15
+ static ɵfac: i0.ɵɵFactoryDeclaration<RdxPopoverContentAttributesComponent, never>;
16
+ static ɵcmp: i0.ɵɵComponentDeclaration<RdxPopoverContentAttributesComponent, "[rdxPopoverContentAttributes]", never, {}, {}, never, ["*"], true, never>;
17
+ }
@@ -0,0 +1,3 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { RdxPopoverContentAttributesComponent } from './popover-content-attributes.component';
3
+ export declare const RdxPopoverContentAttributesToken: InjectionToken<RdxPopoverContentAttributesComponent>;
@@ -1,64 +1,70 @@
1
- import { Overlay } from '@angular/cdk/overlay';
2
- import { DestroyRef, OnInit, TemplateRef } from '@angular/core';
1
+ import { OnInit } from '@angular/core';
3
2
  import { RdxPopoverAlign, RdxPopoverSide } from './popover.types';
4
3
  import * as i0 from "@angular/core";
5
4
  import * as i1 from "@angular/cdk/overlay";
6
5
  export declare class RdxPopoverContentDirective implements OnInit {
7
6
  /** @ignore */
8
- readonly popoverRoot: import("@radix-ng/primitives/popover").RdxPopoverRootDirective;
7
+ private readonly popoverRoot;
9
8
  /** @ignore */
10
- readonly templateRef: TemplateRef<any>;
9
+ private readonly templateRef;
11
10
  /** @ignore */
12
- readonly overlay: Overlay;
11
+ private readonly overlay;
13
12
  /** @ignore */
14
- readonly destroyRef: DestroyRef;
13
+ private readonly destroyRef;
15
14
  /** @ignore */
16
15
  private readonly connectedOverlay;
16
+ /** @ignore */
17
+ readonly name: import("@angular/core").Signal<string>;
17
18
  /**
18
- * The preferred side of the trigger to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled.
19
+ * @description The preferred side of the trigger to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled.
20
+ * @default top
19
21
  */
20
22
  readonly side: import("@angular/core").InputSignal<RdxPopoverSide>;
21
23
  /**
22
- * The distance in pixels from the trigger.
24
+ * @description The distance in pixels from the trigger.
25
+ * @default undefined
23
26
  */
24
27
  readonly sideOffset: import("@angular/core").InputSignal<number | undefined>;
25
28
  /**
26
- * The preferred alignment against the trigger. May change when collisions occur.
29
+ * @description The preferred alignment against the trigger. May change when collisions occur.
30
+ * @default center
27
31
  */
28
32
  readonly align: import("@angular/core").InputSignal<RdxPopoverAlign>;
29
33
  /**
30
- * An offset in pixels from the "start" or "end" alignment options.
34
+ * @description An offset in pixels from the "start" or "end" alignment options.
35
+ * @default undefined
31
36
  */
32
37
  readonly alignOffset: import("@angular/core").InputSignal<number | undefined>;
33
38
  /**
34
- * Whether to add some alternate positions of the content.
39
+ * @description Whether to add some alternate positions of the content.
40
+ * @default false
35
41
  */
36
42
  readonly disableAlternatePositions: import("@angular/core").InputSignal<boolean>;
37
- /** @ingore */
38
- readonly positions: import("@angular/core").Signal<import("@angular/cdk/overlay").ConnectedPosition[]>;
39
43
  /**
40
- * Event handler called when the escape key is down. It can be prevented by calling event.preventDefault.
44
+ * @description Event handler called when the escape key is down. It can be prevented by calling event.preventDefault.
41
45
  */
42
46
  readonly onEscapeKeyDown: import("@angular/core").OutputEmitterRef<KeyboardEvent>;
43
47
  /**
44
- * Event handler called when a pointer event occurs outside the bounds of the component. It can be prevented by calling event.preventDefault.
48
+ * @description Event handler called when a pointer event occurs outside the bounds of the component. It can be prevented by calling event.preventDefault.
45
49
  */
46
- readonly onPointerDownOutside: import("@angular/core").OutputEmitterRef<MouseEvent>;
50
+ readonly onOutsideClick: import("@angular/core").OutputEmitterRef<MouseEvent>;
47
51
  /**
48
- * Event handler called when the overlay is atached
52
+ * @description Event handler called after the overlay is open
49
53
  */
50
- readonly onShow: import("@angular/core").OutputEmitterRef<void>;
54
+ readonly onOpen: import("@angular/core").OutputEmitterRef<void>;
51
55
  /**
52
- * Event handler called when the overlay is detached
56
+ * @description Event handler called after the overlay is closed
53
57
  */
54
- readonly onHide: import("@angular/core").OutputEmitterRef<void>;
58
+ readonly onClosed: import("@angular/core").OutputEmitterRef<void>;
59
+ /** @ingore */
60
+ readonly positions: import("@angular/core").Signal<import("@angular/cdk/overlay").ConnectedPosition[]>;
55
61
  constructor();
56
62
  /** @ignore */
57
63
  ngOnInit(): void;
58
64
  /** @ignore */
59
- show(): void;
65
+ open(): void;
60
66
  /** @ignore */
61
- hide(): void;
67
+ close(): void;
62
68
  /** @ignore */
63
69
  positionChange(): import("rxjs").Observable<import("@angular/cdk/overlay").ConnectedOverlayPositionChange>;
64
70
  /** @ignore */
@@ -76,9 +82,14 @@ export declare class RdxPopoverContentDirective implements OnInit {
76
82
  /** @ignore */
77
83
  private setOrigin;
78
84
  /** @ignore */
85
+ private setPositions;
86
+ /** @ignore */
87
+ private computePositions;
88
+ private onOriginChangeEffect;
89
+ /** @ignore */
79
90
  private onPositionChangeEffect;
80
91
  /** @ignore */
81
- private onControlledExternallyChangeEffect;
92
+ private fireOverlayNgOnChanges;
82
93
  static ɵfac: i0.ɵɵFactoryDeclaration<RdxPopoverContentDirective, never>;
83
- static ɵdir: i0.ɵɵDirectiveDeclaration<RdxPopoverContentDirective, "[rdxPopoverContent]", never, { "side": { "alias": "side"; "required": false; "isSignal": true; }; "sideOffset": { "alias": "sideOffset"; "required": false; "isSignal": true; }; "align": { "alias": "align"; "required": false; "isSignal": true; }; "alignOffset": { "alias": "alignOffset"; "required": false; "isSignal": true; }; "disableAlternatePositions": { "alias": "disableAlternatePositions"; "required": false; "isSignal": true; }; }, { "onEscapeKeyDown": "onEscapeKeyDown"; "onPointerDownOutside": "onPointerDownOutside"; "onShow": "onShow"; "onHide": "onHide"; }, never, never, true, [{ directive: typeof i1.CdkConnectedOverlay; inputs: {}; outputs: {}; }]>;
94
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RdxPopoverContentDirective, "[rdxPopoverContent]", never, { "side": { "alias": "side"; "required": false; "isSignal": true; }; "sideOffset": { "alias": "sideOffset"; "required": false; "isSignal": true; }; "align": { "alias": "align"; "required": false; "isSignal": true; }; "alignOffset": { "alias": "alignOffset"; "required": false; "isSignal": true; }; "disableAlternatePositions": { "alias": "disableAlternatePositions"; "required": false; "isSignal": true; }; }, { "onEscapeKeyDown": "onEscapeKeyDown"; "onOutsideClick": "onOutsideClick"; "onOpen": "onOpen"; "onClosed": "onClosed"; }, never, never, true, [{ directive: typeof i1.CdkConnectedOverlay; inputs: {}; outputs: {}; }]>;
84
95
  }