igniteui-webcomponents 7.2.2 → 7.2.4

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 (125) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/animations/player.d.ts +4 -11
  3. package/animations/player.js +3 -9
  4. package/animations/player.js.map +1 -1
  5. package/animations/view-transition.d.ts +44 -0
  6. package/animations/view-transition.js +81 -0
  7. package/animations/view-transition.js.map +1 -0
  8. package/components/avatar/avatar.js +7 -7
  9. package/components/avatar/avatar.js.map +1 -1
  10. package/components/button/button-base.d.ts +1 -1
  11. package/components/button/button-base.js +7 -5
  12. package/components/button/button-base.js.map +1 -1
  13. package/components/button/icon-button.js +9 -9
  14. package/components/button/icon-button.js.map +1 -1
  15. package/components/calendar/calendar.js.map +1 -1
  16. package/components/calendar/days-view/days-view.js.map +1 -1
  17. package/components/carousel/carousel.js +1 -2
  18. package/components/carousel/carousel.js.map +1 -1
  19. package/components/chat/chat-input.js +4 -4
  20. package/components/chat/chat-input.js.map +1 -1
  21. package/components/chat/chat.js +6 -6
  22. package/components/chat/chat.js.map +1 -1
  23. package/components/chat/message-attachments.js.map +1 -1
  24. package/components/chat/types.js.map +1 -1
  25. package/components/checkbox/checkbox.js.map +1 -1
  26. package/components/combo/combo.d.ts +1 -4
  27. package/components/combo/combo.js +9 -1
  28. package/components/combo/combo.js.map +1 -1
  29. package/components/combo/types.d.ts +4 -0
  30. package/components/combo/types.js.map +1 -1
  31. package/components/common/context.d.ts +2 -0
  32. package/components/common/context.js.map +1 -1
  33. package/components/common/controllers/drag.d.ts +10 -0
  34. package/components/common/controllers/drag.js +11 -0
  35. package/components/common/controllers/drag.js.map +1 -1
  36. package/components/common/controllers/gestures.js.map +1 -1
  37. package/components/common/controllers/internals.d.ts +9 -0
  38. package/components/common/controllers/internals.js +4 -0
  39. package/components/common/controllers/internals.js.map +1 -1
  40. package/components/common/controllers/mutation-observer.d.ts +2 -2
  41. package/components/common/controllers/mutation-observer.js +10 -7
  42. package/components/common/controllers/mutation-observer.js.map +1 -1
  43. package/components/common/controllers/slot.d.ts +1 -1
  44. package/components/common/controllers/slot.js +4 -1
  45. package/components/common/controllers/slot.js.map +1 -1
  46. package/components/common/i18n/utils.js.map +1 -1
  47. package/components/common/mixins/forms/associated.d.ts +1 -1
  48. package/components/common/mixins/forms/associated.js +21 -13
  49. package/components/common/mixins/forms/associated.js.map +1 -1
  50. package/components/common/mixins/forms/types.d.ts +2 -1
  51. package/components/common/mixins/forms/types.js.map +1 -1
  52. package/components/common/templates/masked-input.d.ts +2 -0
  53. package/components/common/templates/masked-input.js +2 -1
  54. package/components/common/templates/masked-input.js.map +1 -1
  55. package/components/date-picker/date-picker.d.ts +2 -1
  56. package/components/date-picker/date-picker.js +6 -0
  57. package/components/date-picker/date-picker.js.map +1 -1
  58. package/components/date-range-picker/date-range-mask-parser.d.ts +11 -2
  59. package/components/date-range-picker/date-range-mask-parser.js.map +1 -1
  60. package/components/date-range-picker/date-range-picker.d.ts +2 -1
  61. package/components/date-range-picker/date-range-picker.js +10 -8
  62. package/components/date-range-picker/date-range-picker.js.map +1 -1
  63. package/components/date-range-picker/predefined-ranges-area.js.map +1 -1
  64. package/components/date-time-input/date-part.js.map +1 -1
  65. package/components/date-time-input/date-time-input.base.d.ts +15 -0
  66. package/components/date-time-input/date-time-input.base.js +9 -1
  67. package/components/date-time-input/date-time-input.base.js.map +1 -1
  68. package/components/dialog/dialog.js +4 -4
  69. package/components/dialog/dialog.js.map +1 -1
  70. package/components/file-input/file-input.js.map +1 -1
  71. package/components/icon/icon-state.broadcast.js.map +1 -1
  72. package/components/icon/icon.d.ts +3 -2
  73. package/components/icon/icon.js +7 -2
  74. package/components/icon/icon.js.map +1 -1
  75. package/components/input/input-base.d.ts +15 -0
  76. package/components/input/input-base.js +8 -1
  77. package/components/input/input-base.js.map +1 -1
  78. package/components/input/input.js +1 -0
  79. package/components/input/input.js.map +1 -1
  80. package/components/mask-input/mask-input.js +1 -0
  81. package/components/mask-input/mask-input.js.map +1 -1
  82. package/components/popover/popover.d.ts +10 -1
  83. package/components/popover/popover.js +31 -14
  84. package/components/popover/popover.js.map +1 -1
  85. package/components/popover/themes/light/popover.base.css.js +1 -1
  86. package/components/popover/themes/light/popover.base.css.js.map +1 -1
  87. package/components/select/select.d.ts +7 -1
  88. package/components/select/select.js +12 -1
  89. package/components/select/select.js.map +1 -1
  90. package/components/slider/range-slider.js +5 -5
  91. package/components/slider/range-slider.js.map +1 -1
  92. package/components/slider/slider-base.js +9 -9
  93. package/components/slider/slider-base.js.map +1 -1
  94. package/components/snackbar/snackbar.js +4 -4
  95. package/components/snackbar/snackbar.js.map +1 -1
  96. package/components/splitter/splitter.js.map +1 -1
  97. package/components/stepper/common/animations.js.map +1 -1
  98. package/components/stepper/step.js.map +1 -1
  99. package/components/tabs/tabs.js +29 -10
  100. package/components/tabs/tabs.js.map +1 -1
  101. package/components/textarea/textarea.js +1 -0
  102. package/components/textarea/textarea.js.map +1 -1
  103. package/components/tile-manager/tile-manager.d.ts +11 -0
  104. package/components/tile-manager/tile-manager.js +15 -0
  105. package/components/tile-manager/tile-manager.js.map +1 -1
  106. package/components/tile-manager/tile.js +15 -14
  107. package/components/tile-manager/tile.js.map +1 -1
  108. package/components/tooltip/tooltip.js +8 -8
  109. package/components/tooltip/tooltip.js.map +1 -1
  110. package/components/tree/tree-item.js +31 -31
  111. package/components/tree/tree-item.js.map +1 -1
  112. package/components/types.js.map +1 -1
  113. package/components/validation-container/validation-container.d.ts +32 -5
  114. package/components/validation-container/validation-container.js +74 -64
  115. package/components/validation-container/validation-container.js.map +1 -1
  116. package/custom-elements.json +809 -189
  117. package/igniteui-webcomponents.html-data.json +1 -1
  118. package/index.d.ts +6 -2
  119. package/index.js +3 -2
  120. package/index.js.map +1 -1
  121. package/package.json +1 -1
  122. package/skills/igniteui-wc-generate-from-image-design/references/gotchas.md +15 -1
  123. package/themes/dark/indigo.css +1 -1
  124. package/themes/light/indigo.css +1 -1
  125. package/web-types.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"internals.js","sourceRoot":"","sources":["../../../../src/components/common/controllers/internals.ts"],"names":[],"mappings":"AAiBA,MAAM,0BAA0B;IAW9B,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC9B,CAAC;IAUD,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;IAClC,CAAC;IASD,IAAW,iBAAiB;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC;IAC3C,CAAC;IAUD,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;IACtC,CAAC;IAED,YACE,IAAyC,EACzC,MAA+B;QAE/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QAE/C,IAAI,MAAM,EAAE,WAAW,EAAE,CAAC;YACxB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACnC,CAAC;QAED,IAAI,CAAC,aAAa,CAAC,IAA0B,CAAC,CAAC;IACjD,CAAC;IAGM,OAAO,CACZ,KAAuC;QAEvC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAMM,QAAQ,CAAC,KAAa,EAAE,KAAc;QAC3C,KAAK;YACH,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;YACnC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAWM,YAAY,CAAC,KAAoB,EAAE,KAAqB;QAC7D,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;IAUM,WAAW,CAAC,KAA0B,EAAE,OAAgB;QAC7D,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAUM,aAAa;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;IACzC,CAAC;IAUM,cAAc;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC;IAC1C,CAAC;CACF;AAGD,MAAM,UAAU,sBAAsB,CACpC,IAAyC,EACzC,MAA+B;IAE/B,OAAO,IAAI,0BAA0B,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import type {\n LitElement,\n ReactiveController,\n ReactiveControllerHost,\n} from 'lit';\nimport type { FormValueType } from '../mixins/forms/types.js';\n\n/** Configuration for the ElementInternalsController. */\ntype ElementInternalsConfig<T extends keyof ARIAMixin = keyof ARIAMixin> = {\n /** Initial ARIA attributes to set on the element internals. */\n initialARIA: Partial<Record<T, ARIAMixin[T]>>;\n};\n\n/**\n * A Lit ReactiveController to manage `ElementInternals` for a host element.\n * Provides methods to interact with custom element states and ARIA attributes..\n */\nclass ElementInternalsController {\n private readonly _host: ReactiveControllerHost & LitElement;\n private readonly _internals: ElementInternals;\n\n /**\n * Gets the closest ancestor `<form>` element or `null`.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true` in order to return the parent form.\n */\n public get form(): HTMLFormElement | null {\n return this._internals.form;\n }\n\n /**\n * Returns a `ValidityState` object which represents the different validity states\n * the element can be in, with respect to constraint validation.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true`.\n */\n public get validity(): ValidityState {\n return this._internals.validity;\n }\n\n /**\n * Returns a string containing the validation message of this element.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true`.\n */\n public get validationMessage(): string {\n return this._internals.validationMessage;\n }\n\n /**\n * Returns a boolean value which returns true if the element is a submittable element\n * which is a candidate for constraint validation.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true`.\n */\n public get willValidate(): boolean {\n return this._internals.willValidate;\n }\n\n constructor(\n host: ReactiveControllerHost & LitElement,\n config?: ElementInternalsConfig\n ) {\n this._host = host;\n this._internals = this._host.attachInternals();\n\n if (config?.initialARIA) {\n this.setARIA(config.initialARIA);\n }\n\n host.addController(this as ReactiveController);\n }\n\n /** Sets ARIA attributes on the element's internals. */\n public setARIA<T extends keyof ARIAMixin = keyof ARIAMixin>(\n state: Partial<Record<T, ARIAMixin[T]>>\n ): void {\n Object.assign(this._internals, state);\n }\n\n /**\n * Adds or removes a custom state from the element's internals.\n * Custom states can be styled via `:state()` selector in CSS.\n */\n public setState(state: string, value: boolean): void {\n value\n ? this._internals.states.add(state)\n : this._internals.states.delete(state);\n }\n\n /**\n * Sets both the state and submission value of internals's target element to value.\n *\n * If value is null, the element won't participate in form submission.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true`.\n */\n public setFormValue(value: FormValueType, state?: FormValueType): void {\n this._internals.setFormValue(value, state);\n }\n\n /**\n * Sets the internal validity state of the host element as well as the validation\n * message.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true`.\n */\n public setValidity(flags?: ValidityStateFlags, message?: string): void {\n this._internals.setValidity(flags, message);\n }\n\n /**\n * Checks the internal validity of the host element and fires an `invalid` event if\n * the host element fails validation constraints.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true`.\n */\n public checkValidity(): boolean {\n return this._internals.checkValidity();\n }\n\n /**\n * Checks the internal validity of the host element and fires an `invalid` event if\n * the host element fails validation constraints.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true`.\n */\n public reportValidity(): boolean {\n return this._internals.reportValidity();\n }\n}\n\n/** Creates and adds a {@link ElementInternalsController} to a LitElement host. */\nexport function addInternalsController(\n host: ReactiveControllerHost & LitElement,\n config?: ElementInternalsConfig\n): ElementInternalsController {\n return new ElementInternalsController(host, config);\n}\n\nexport type { ElementInternalsController };\n"]}
1
+ {"version":3,"file":"internals.js","sourceRoot":"","sources":["../../../../src/components/common/controllers/internals.ts"],"names":[],"mappings":"AAiBA,MAAM,0BAA0B;IAW9B,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC9B,CAAC;IAUD,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;IAClC,CAAC;IASD,IAAW,iBAAiB;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC;IAC3C,CAAC;IAUD,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;IACtC,CAAC;IAUD,IAAW,MAAM;QACf,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,MAAoC,CAAC;QACpE,OAAO,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjE,CAAC;IAED,YACE,IAAyC,EACzC,MAA+B;QAE/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QAE/C,IAAI,MAAM,EAAE,WAAW,EAAE,CAAC;YACxB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACnC,CAAC;QAED,IAAI,CAAC,aAAa,CAAC,IAA0B,CAAC,CAAC;IACjD,CAAC;IAGM,OAAO,CACZ,KAAuC;QAEvC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAMM,QAAQ,CAAC,KAAa,EAAE,KAAc;QAC3C,KAAK;YACH,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;YACnC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAWM,YAAY,CAAC,KAAoB,EAAE,KAAqB;QAC7D,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;IAUM,WAAW,CAAC,KAA0B,EAAE,OAAgB;QAC7D,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAUM,aAAa;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;IACzC,CAAC;IAUM,cAAc;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC;IAC1C,CAAC;CACF;AAGD,MAAM,UAAU,sBAAsB,CACpC,IAAyC,EACzC,MAA+B;IAE/B,OAAO,IAAI,0BAA0B,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import type {\n LitElement,\n ReactiveController,\n ReactiveControllerHost,\n} from 'lit';\nimport type { FormValueType } from '../mixins/forms/types.js';\n\n/** Configuration for the ElementInternalsController. */\ntype ElementInternalsConfig<T extends keyof ARIAMixin = keyof ARIAMixin> = {\n /** Initial ARIA attributes to set on the element internals. */\n initialARIA: Partial<Record<T, ARIAMixin[T]>>;\n};\n\n/**\n * A Lit ReactiveController to manage `ElementInternals` for a host element.\n * Provides methods to interact with custom element states and ARIA attributes..\n */\nclass ElementInternalsController {\n private readonly _host: ReactiveControllerHost & LitElement;\n private readonly _internals: ElementInternals;\n\n /**\n * Gets the closest ancestor `<form>` element or `null`.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true` in order to return the parent form.\n */\n public get form(): HTMLFormElement | null {\n return this._internals.form;\n }\n\n /**\n * Returns a `ValidityState` object which represents the different validity states\n * the element can be in, with respect to constraint validation.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true`.\n */\n public get validity(): ValidityState {\n return this._internals.validity;\n }\n\n /**\n * Returns a string containing the validation message of this element.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true`.\n */\n public get validationMessage(): string {\n return this._internals.validationMessage;\n }\n\n /**\n * Returns a boolean value which returns true if the element is a submittable element\n * which is a candidate for constraint validation.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true`.\n */\n public get willValidate(): boolean {\n return this._internals.willValidate;\n }\n\n /**\n * Returns a read-only array of the `<label>` elements associated with the host element, or `null` if there are no associated labels.\n * The association is determined by the `for` attribute of `<label>` elements or by nesting the host element inside a `<label>`.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true` in order to return associated labels.\n */\n public get labels(): ReadonlyArray<Element> | null {\n const labels = this._internals.labels as NodeListOf<Element> | null;\n return labels && labels.length > 0 ? Array.from(labels) : null;\n }\n\n constructor(\n host: ReactiveControllerHost & LitElement,\n config?: ElementInternalsConfig\n ) {\n this._host = host;\n this._internals = this._host.attachInternals();\n\n if (config?.initialARIA) {\n this.setARIA(config.initialARIA);\n }\n\n host.addController(this as ReactiveController);\n }\n\n /** Sets ARIA attributes on the element's internals. */\n public setARIA<T extends keyof ARIAMixin = keyof ARIAMixin>(\n state: Partial<Record<T, ARIAMixin[T]>>\n ): void {\n Object.assign(this._internals, state);\n }\n\n /**\n * Adds or removes a custom state from the element's internals.\n * Custom states can be styled via `:state()` selector in CSS.\n */\n public setState(state: string, value: boolean): void {\n value\n ? this._internals.states.add(state)\n : this._internals.states.delete(state);\n }\n\n /**\n * Sets both the state and submission value of internals's target element to value.\n *\n * If value is null, the element won't participate in form submission.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true`.\n */\n public setFormValue(value: FormValueType, state?: FormValueType): void {\n this._internals.setFormValue(value, state);\n }\n\n /**\n * Sets the internal validity state of the host element as well as the validation\n * message.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true`.\n */\n public setValidity(flags?: ValidityStateFlags, message?: string): void {\n this._internals.setValidity(flags, message);\n }\n\n /**\n * Checks the internal validity of the host element and fires an `invalid` event if\n * the host element fails validation constraints.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true`.\n */\n public checkValidity(): boolean {\n return this._internals.checkValidity();\n }\n\n /**\n * Checks the internal validity of the host element and fires an `invalid` event if\n * the host element fails validation constraints.\n *\n * @remarks\n * The host element must be form associated, that is, it should have\n * `static formAssociated = true`.\n */\n public reportValidity(): boolean {\n return this._internals.reportValidity();\n }\n}\n\n/** Creates and adds a {@link ElementInternalsController} to a LitElement host. */\nexport function addInternalsController(\n host: ReactiveControllerHost & LitElement,\n config?: ElementInternalsConfig\n): ElementInternalsController {\n return new ElementInternalsController(host, config);\n}\n\nexport type { ElementInternalsController };\n"]}
@@ -1,4 +1,4 @@
1
- import type { ReactiveController, ReactiveControllerHost } from 'lit';
1
+ import { type ReactiveController, type ReactiveControllerHost } from 'lit';
2
2
  /** @ignore */
3
3
  export interface MutationControllerConfig<T extends Node = Node> {
4
4
  /** The callback function to run when a mutation occurs. */
@@ -52,11 +52,11 @@ export type MutationControllerParams<T extends Node = Node> = {
52
52
  };
53
53
  declare class MutationController<T extends Node = Node> implements ReactiveController {
54
54
  private readonly _host;
55
- private readonly _observer;
56
55
  private readonly _target;
57
56
  private readonly _config;
58
57
  private readonly _callback;
59
58
  private readonly _filter?;
59
+ private _observer?;
60
60
  constructor(host: ReactiveControllerHost & Element, options: MutationControllerConfig<T>);
61
61
  /** @internal */
62
62
  hostConnected(): void;
@@ -1,3 +1,4 @@
1
+ import { isServer, } from 'lit';
1
2
  import { isElement } from '../util.js';
2
3
  function applyNodeFilter(nodes, predicate) {
3
4
  if (!predicate) {
@@ -15,11 +16,13 @@ class MutationController {
15
16
  this._config = options.config;
16
17
  this._target = options.target ?? this._host;
17
18
  this._filter = options.filter;
18
- this._observer = new MutationObserver((records) => {
19
- this.disconnect();
20
- this._callback.call(this._host, this._process(records));
21
- this.observe();
22
- });
19
+ if (!isServer) {
20
+ this._observer = new MutationObserver((records) => {
21
+ this.disconnect();
22
+ this._callback.call(this._host, this._process(records));
23
+ this.observe();
24
+ });
25
+ }
23
26
  host.addController(this);
24
27
  }
25
28
  hostConnected() {
@@ -57,10 +60,10 @@ class MutationController {
57
60
  return { records, changes, observer: this };
58
61
  }
59
62
  observe() {
60
- this._observer.observe(this._target, this._config);
63
+ this._observer?.observe(this._target, this._config);
61
64
  }
62
65
  disconnect() {
63
- this._observer.disconnect();
66
+ this._observer?.disconnect();
64
67
  }
65
68
  }
66
69
  export function createMutationController(host, config) {
@@ -1 +1 @@
1
- {"version":3,"file":"mutation-observer.js","sourceRoot":"","sources":["../../../../src/components/common/controllers/mutation-observer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAgEvC,SAAS,eAAe,CACtB,KAAU,EACV,SAAuC;IAEvC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;QAC7B,CAAC,CAAC,KAAK,CAAC,MAAM,CACV,CAAC,IAAI,EAAE,EAAE,CACP,SAAS,CAAC,IAAI,CAAC;YACf,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CACvD;QACH,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,kBAAkB;IAQtB,YACE,IAAsC,EACtC,OAAoC;QAEpC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ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,CAAC,CACJ,CAAC;YACJ,CAAC;iBAAM,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;gBAChC,OAAO,CAAC,KAAK,CAAC,IAAI,CAChB,GAAG,eAAe,CAAC,CAAC,GAAG,UAAU,CAAQ,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;oBACnE,MAAM,EAAE,MAAiB;oBACzB,IAAI;iBACL,CAAC,CAAC,CACJ,CAAC;gBACF,OAAO,CAAC,OAAO,CAAC,IAAI,CAClB,GAAG,eAAe,CAAC,CAAC,GAAG,YAAY,CAAQ,EAAE,SAAS,CAAC,CAAC,GAAG,CACzD,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;oBACT,MAAM,EAAE,MAAiB;oBACzB,IAAI;iBACL,CAAC,CACH,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC9C,CAAC;IAMM,OAAO;QACZ,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;IAGM,UAAU;QACf,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;IAC9B,CAAC;CACF;AAWD,MAAM,UAAU,wBAAwB,CACtC,IAAsC,EACtC,MAAmC;IAEnC,OAAO,IAAI,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\nimport { isElement } from '../util.js';\n\n/** @ignore */\nexport interface MutationControllerConfig<T extends Node = Node> {\n /** The callback function to run when a mutation occurs. */\n callback: MutationControllerCallback<T>;\n /** The underlying mutation observer configuration parameters. */\n config: MutationObserverInit;\n /**\n * The element to observe.\n * If left out, the observer will listen on the host component itself.\n */\n target?: Element;\n /**\n * A filter configuration.\n * See {@link MutationControllerFilter|this} for additional information.\n */\n filter?: MutationControllerFilter<T>;\n}\n\ntype MutationControllerCallback<T extends Node = Node> = (\n params: MutationControllerParams<T>\n) => unknown;\n\n/**\n * Filter configuration to return elements that either match\n * an array of selector strings or a predicate function.\n */\ntype MutationControllerFilter<T extends Node = Node> =\n | string[]\n | ((node: T) => boolean);\n\ntype MutationDOMChange<T extends Node = Node> = {\n /** The parent of the added/removed element. */\n target: Element;\n /** The added/removed element. */\n node: T;\n};\n\ntype MutationAttributeChange<T extends Node = Node> = {\n /** The host element of the changed attribute. */\n node: T;\n /** The changed attribute name. */\n attributeName: string | null;\n};\n\ntype MutationChange<T extends Node = Node> = {\n /** Elements that have attribute(s) changes. */\n attributes: MutationAttributeChange<T>[];\n /** Elements that have been added. */\n added: MutationDOMChange<T>[];\n /** Elements that have been removed. */\n removed: MutationDOMChange<T>[];\n};\n\nexport type MutationControllerParams<T extends Node = Node> = {\n /** The original mutation records from the underlying observer. */\n records: MutationRecord[];\n /** The aggregated changes. */\n changes: MutationChange<T>;\n /** The observer controller instance. */\n observer: MutationController<T>;\n};\n\nfunction applyNodeFilter<T extends Node = Node>(\n nodes: T[],\n predicate?: MutationControllerFilter<T>\n): T[] {\n if (!predicate) {\n return nodes;\n }\n\n return Array.isArray(predicate)\n ? nodes.filter(\n (node) =>\n isElement(node) &&\n predicate.some((selector) => node.matches(selector))\n )\n : nodes.filter(predicate);\n}\n\nclass MutationController<T extends Node = Node> implements ReactiveController {\n private readonly _host: ReactiveControllerHost & Element;\n private readonly _observer: MutationObserver;\n private readonly _target: Element;\n private readonly _config: MutationObserverInit;\n private readonly _callback: MutationControllerCallback<T>;\n private readonly _filter?: MutationControllerFilter<T>;\n\n constructor(\n host: ReactiveControllerHost & Element,\n options: MutationControllerConfig<T>\n ) {\n this._host = host;\n this._callback = options.callback;\n this._config = options.config;\n this._target = options.target ?? this._host;\n this._filter = options.filter;\n\n this._observer = new MutationObserver((records) => {\n this.disconnect();\n this._callback.call(this._host, this._process(records));\n this.observe();\n });\n\n host.addController(this);\n }\n\n /** @internal */\n public hostConnected(): void {\n this.observe();\n }\n\n /** @internal */\n public hostDisconnected(): void {\n this.disconnect();\n }\n\n private _process(records: MutationRecord[]): MutationControllerParams<T> {\n const predicate = this._filter;\n const changes: MutationChange<T> = {\n attributes: [],\n added: [],\n removed: [],\n };\n\n for (const record of records) {\n const { type, target, attributeName, addedNodes, removedNodes } = record;\n\n if (type === 'attributes') {\n changes.attributes.push(\n ...applyNodeFilter([target as T], predicate).map((node) => ({\n node,\n attributeName,\n }))\n );\n } else if (type === 'childList') {\n changes.added.push(\n ...applyNodeFilter([...addedNodes] as T[], predicate).map((node) => ({\n target: target as Element,\n node,\n }))\n );\n changes.removed.push(\n ...applyNodeFilter([...removedNodes] as T[], predicate).map(\n (node) => ({\n target: target as Element,\n node,\n })\n )\n );\n }\n }\n\n return { records, changes, observer: this };\n }\n\n /**\n * Begin receiving notifications of changes to the DOM based\n * on the configured {@link MutationControllerConfig.target|target} and observer {@link MutationControllerConfig.config|options}.\n */\n public observe(): void {\n this._observer.observe(this._target, this._config);\n }\n\n /** Stop watching for mutations. */\n public disconnect(): void {\n this._observer.disconnect();\n }\n}\n\n/**\n * Creates and attaches a mutation controller with `config` to the passed in `host`.\n *\n * Automatically starts/stops observing for mutation changes\n * in the respective component connect/disconnect callbacks.\n *\n * The mutation observer is disconnected before invoking the passed in callback and re-attached\n * after that in order to not loop itself in endless stream of changes.\n */\nexport function createMutationController<T extends Node = Node>(\n host: ReactiveControllerHost & Element,\n config: MutationControllerConfig<T>\n): MutationController<T> {\n return new MutationController(host, config);\n}\n"]}
1
+ {"version":3,"file":"mutation-observer.js","sourceRoot":"","sources":["../../../../src/components/common/controllers/mutation-observer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,GAGT,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA+DvC,SAAS,eAAe,CACtB,KAAU,EACV,S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OAAO;QACZ,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAGM,UAAU;QACf,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,CAAC;IAC/B,CAAC;CACF;AAWD,MAAM,UAAU,wBAAwB,CACtC,IAAsC,EACtC,MAAmC;IAEnC,OAAO,IAAI,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["import {\n isServer,\n type ReactiveController,\n type ReactiveControllerHost,\n} from 'lit';\nimport { isElement } from '../util.js';\n\n/** @ignore */\nexport interface MutationControllerConfig<T extends Node = Node> {\n /** The callback function to run when a mutation occurs. */\n callback: MutationControllerCallback<T>;\n /** The underlying mutation observer configuration parameters. */\n config: MutationObserverInit;\n /**\n * The element to observe.\n * If left out, the observer will listen on the host component itself.\n */\n target?: Element;\n /**\n * A filter configuration.\n * See {@link MutationControllerFilter|this} for additional information.\n */\n filter?: MutationControllerFilter<T>;\n}\n\ntype MutationControllerCallback<T extends Node = Node> = (\n params: MutationControllerParams<T>\n) => unknown;\n\n/**\n * Filter configuration to return elements that either match\n * an array of selector strings or a predicate function.\n */\ntype MutationControllerFilter<T extends Node = Node> =\n string[] | ((node: T) => boolean);\n\ntype MutationDOMChange<T extends Node = Node> = {\n /** The parent of the added/removed element. */\n target: Element;\n /** The added/removed element. */\n node: T;\n};\n\ntype MutationAttributeChange<T extends Node = Node> = {\n /** The host element of the changed attribute. */\n node: T;\n /** The changed attribute name. */\n attributeName: string | null;\n};\n\ntype MutationChange<T extends Node = Node> = {\n /** Elements that have attribute(s) changes. */\n attributes: MutationAttributeChange<T>[];\n /** Elements that have been added. */\n added: MutationDOMChange<T>[];\n /** Elements that have been removed. */\n removed: MutationDOMChange<T>[];\n};\n\nexport type MutationControllerParams<T extends Node = Node> = {\n /** The original mutation records from the underlying observer. */\n records: MutationRecord[];\n /** The aggregated changes. */\n changes: MutationChange<T>;\n /** The observer controller instance. */\n observer: MutationController<T>;\n};\n\nfunction applyNodeFilter<T extends Node = Node>(\n nodes: T[],\n predicate?: MutationControllerFilter<T>\n): T[] {\n if (!predicate) {\n return nodes;\n }\n\n return Array.isArray(predicate)\n ? nodes.filter(\n (node) =>\n isElement(node) &&\n predicate.some((selector) => node.matches(selector))\n )\n : nodes.filter(predicate);\n}\n\nclass MutationController<T extends Node = Node> implements ReactiveController {\n private readonly _host: ReactiveControllerHost & Element;\n private readonly _target: Element;\n private readonly _config: MutationObserverInit;\n private readonly _callback: MutationControllerCallback<T>;\n private readonly _filter?: MutationControllerFilter<T>;\n\n private _observer?: MutationObserver;\n\n constructor(\n host: ReactiveControllerHost & Element,\n options: MutationControllerConfig<T>\n ) {\n this._host = host;\n this._callback = options.callback;\n this._config = options.config;\n this._target = options.target ?? this._host;\n this._filter = options.filter;\n\n if (!isServer) {\n this._observer = new MutationObserver((records) => {\n this.disconnect();\n this._callback.call(this._host, this._process(records));\n this.observe();\n });\n }\n\n host.addController(this);\n }\n\n /** @internal */\n public hostConnected(): void {\n this.observe();\n }\n\n /** @internal */\n public hostDisconnected(): void {\n this.disconnect();\n }\n\n private _process(records: MutationRecord[]): MutationControllerParams<T> {\n const predicate = this._filter;\n const changes: MutationChange<T> = {\n attributes: [],\n added: [],\n removed: [],\n };\n\n for (const record of records) {\n const { type, target, attributeName, addedNodes, removedNodes } = record;\n\n if (type === 'attributes') {\n changes.attributes.push(\n ...applyNodeFilter([target as T], predicate).map((node) => ({\n node,\n attributeName,\n }))\n );\n } else if (type === 'childList') {\n changes.added.push(\n ...applyNodeFilter([...addedNodes] as T[], predicate).map((node) => ({\n target: target as Element,\n node,\n }))\n );\n changes.removed.push(\n ...applyNodeFilter([...removedNodes] as T[], predicate).map(\n (node) => ({\n target: target as Element,\n node,\n })\n )\n );\n }\n }\n\n return { records, changes, observer: this };\n }\n\n /**\n * Begin receiving notifications of changes to the DOM based\n * on the configured {@link MutationControllerConfig.target|target} and observer {@link MutationControllerConfig.config|options}.\n */\n public observe(): void {\n this._observer?.observe(this._target, this._config);\n }\n\n /** Stop watching for mutations. */\n public disconnect(): void {\n this._observer?.disconnect();\n }\n}\n\n/**\n * Creates and attaches a mutation controller with `config` to the passed in `host`.\n *\n * Automatically starts/stops observing for mutation changes\n * in the respective component connect/disconnect callbacks.\n *\n * The mutation observer is disconnected before invoking the passed in callback and re-attached\n * after that in order to not loop itself in endless stream of changes.\n */\nexport function createMutationController<T extends Node = Node>(\n host: ReactiveControllerHost & Element,\n config: MutationControllerConfig<T>\n): MutationController<T> {\n return new MutationController(host, config);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { LitElement, ReactiveController, ReactiveControllerHost } from 'lit';
1
+ import { type LitElement, type ReactiveController, type ReactiveControllerHost } from 'lit';
2
2
  type InferSlotNames<T> = T extends readonly (infer U)[] ? U : never;
3
3
  /**
4
4
  * Additional query options for the slot controller methods.
@@ -1,3 +1,4 @@
1
+ import { isServer, } from 'lit';
1
2
  import { isEmpty } from '../util.js';
2
3
  const DefaultSlot = '[default]';
3
4
  class SlotController {
@@ -9,10 +10,12 @@ class SlotController {
9
10
  this._slots = options?.slots ? new Set(options.slots) : undefined;
10
11
  }
11
12
  _getSlot(slotName) {
13
+ if (isServer)
14
+ return null;
12
15
  if (slotName === DefaultSlot) {
13
16
  return this._host.renderRoot.querySelector('slot:not([name])');
14
17
  }
15
- return this._host.renderRoot.querySelector(`slot[name=${slotName}]`);
18
+ return this._host.renderRoot.querySelector(`slot[name="${slotName}"]`);
16
19
  }
17
20
  getAssignedNodes(slot, flatten = false) {
18
21
  return this._getSlot(slot)?.assignedNodes({ flatten }) ?? [];
@@ -1 +1 @@
1
- {"version":3,"file":"slot.js","sourceRoot":"","sources":["../../../../src/components/common/controllers/slot.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AA4CrC,MAAM,WAAW,GAAG,WAAW,CAAC;AAEh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zB,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;gBACvC,IAAI,EAAE,WAAgB;gBACtB,SAAS,EAAE,KAAK;gBAChB,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AAED,SAAS,iBAAiB,CACxB,IAA4B,EAC5B,OAEC;IAED,OAAO,IAAI,cAAc,CAAC,IAA2C,EAAE;QACrE,GAAG,OAAO;QACV,KAAK,EAAE,OAAO,EAAE,KAAoC;KACrD,CAAC,CAAC;AACL,CAAC;AAED,SAAS,QAAQ,CAAoC,GAAG,KAAQ;IAC9D,OAAO,CAAC,WAAW,EAAE,GAAG,KAAK,CAAU,CAAC;AAC1C,CAAC;AAUD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import type {\n LitElement,\n ReactiveController,\n ReactiveControllerHost,\n} from 'lit';\nimport { isEmpty } from '../util.js';\n\ntype InferSlotNames<T> = T extends readonly (infer U)[] ? U : never;\n\n/**\n * Additional query options for the slot controller methods.\n */\ntype SlotQueryOptions = {\n /**\n * If set to `true`, it returns a sequence of both the elements assigned to the queried slot,\n * as well as elements assigned to any other slots that are descendants of this slot. If no\n * assigned elements are found, it returns the slot's fallback content.\n *\n * Defaults to `false`.\n */\n flatten?: boolean;\n /**\n * CSS selector used to filter the elements returned.\n */\n selector?: string;\n};\n\ntype SlotChangeCallback<T> = (\n parameters: SlotChangeCallbackParameters<T>\n) => void;\n\ntype SlotChangeCallbackParameters<T> = {\n /** The slot name that has its assigned nodes changed. */\n slot: T;\n /** `true` if the slot is the default slot. */\n isDefault: boolean;\n /** `true` if the callback handler is called for the initial host update. */\n isInitial: boolean;\n};\n\ntype SlotControllerOptions<T> = {\n /** An iterable collection of slot names to observe. */\n slots?: Iterable<T>;\n /** Callback function which is invoked a slot's assigned nodes change. */\n onChange?: SlotChangeCallback<T>;\n /** If set to `true`, the `onChange` callback is invoked once after the host is updated for the first time. */\n initial?: boolean;\n};\n\nconst DefaultSlot = '[default]';\n\nclass SlotController<T> implements ReactiveController {\n private readonly _host: ReactiveControllerHost & LitElement;\n private readonly _options: SlotControllerOptions<T>;\n private readonly _slots?: Set<T>;\n private _initialized = false;\n\n constructor(\n host: ReactiveControllerHost & LitElement,\n options?: SlotControllerOptions<T>\n ) {\n this._host = host;\n this._host.addController(this);\n\n this._options = { ...options };\n this._slots = options?.slots ? new Set(options.slots) : undefined;\n }\n\n private _getSlot(slotName?: T): HTMLSlotElement | null {\n if (slotName === DefaultSlot) {\n return this._host.renderRoot.querySelector<HTMLSlotElement>(\n 'slot:not([name])'\n );\n }\n\n return this._host.renderRoot.querySelector<HTMLSlotElement>(\n `slot[name=${slotName}]`\n );\n }\n\n /**\n * Returns an array of the assigned nodes for `slot`.\n *\n * If `flatten` is set to `true`, it returns a sequence of both the nodes assigned to the queried slot,\n * as well as nodes assigned to any other slots that are descendants of this slot. If no\n * assigned nodes are found, it returns the slot's fallback content.\n */\n public getAssignedNodes(slot: T, flatten = false): Node[] {\n return this._getSlot(slot)?.assignedNodes({ flatten }) ?? [];\n }\n\n /**\n * Returns an array of the assigned elements for `slot` with additional `options`.\n *\n * See {@link SlotQueryOptions.flatten} and {@link SlotQueryOptions.selector} for more information.\n */\n public getAssignedElements<U extends Element>(\n slot: T,\n options?: SlotQueryOptions\n ): U[] {\n const elements =\n (this._getSlot(slot)?.assignedElements({\n flatten: options?.flatten,\n }) as U[]) ?? [];\n\n return options?.selector\n ? elements.filter((e) => e.matches(options.selector!))\n : elements;\n }\n\n /**\n * Return whether `slot` has assigned nodes.\n *\n * If `flatten` is set to `true`, it returns a sequence of both the nodes assigned to the queried slot,\n * as well as nodes assigned to any other slots that are descendants of this slot. If no\n * assigned nodes are found, it returns the slot's fallback content.\n */\n public hasAssignedNodes(slot: T, flatten = false): boolean {\n return !isEmpty(this.getAssignedNodes(slot, flatten));\n }\n\n /**\n * Return whether `slot` has assigned elements accepting additional `options`.\n *\n * See {@link SlotQueryOptions.flatten} and {@link SlotQueryOptions.selector} for more information.\n */\n public hasAssignedElements(slot: T, options?: SlotQueryOptions): boolean {\n return !isEmpty(this.getAssignedElements(slot, options));\n }\n\n /** @internal */\n public handleEvent(event: Event): void {\n const slot = event.target as HTMLSlotElement;\n const name = slot.name as T;\n const isDefault = name === '';\n\n if (\n !this._slots ||\n this._slots.has(isDefault ? (DefaultSlot as T) : (slot.name as T))\n ) {\n this._options.onChange?.call(this._host, {\n slot: name,\n isDefault,\n isInitial: false,\n });\n this._host.requestUpdate();\n }\n }\n\n /** @internal */\n public hostConnected(): void {\n this._host.renderRoot.addEventListener('slotchange', this);\n }\n\n /** @internal */\n public hostDisconnected(): void {\n this._host.renderRoot.removeEventListener('slotchange', this);\n }\n\n /** @internal */\n public hostUpdated(): void {\n if (!this._initialized && this._options.initial) {\n this._initialized = true;\n this._options.onChange?.call(this._host, {\n slot: '<initial>' as T,\n isDefault: false,\n isInitial: true,\n });\n }\n }\n}\n\nfunction addSlotController<K extends readonly string[]>(\n host: ReactiveControllerHost,\n options?: SlotControllerOptions<InferSlotNames<K>> & {\n slots?: K;\n }\n): SlotController<InferSlotNames<K>> {\n return new SlotController(host as ReactiveControllerHost & LitElement, {\n ...options,\n slots: options?.slots as Iterable<InferSlotNames<K>>,\n });\n}\n\nfunction setSlots<const T extends readonly string[]>(...slots: T) {\n return [DefaultSlot, ...slots] as const;\n}\n\nexport type {\n InferSlotNames,\n SlotChangeCallback,\n SlotChangeCallbackParameters,\n SlotController,\n SlotControllerOptions,\n SlotQueryOptions,\n};\nexport { addSlotController, DefaultSlot, setSlots };\n"]}
1
+ {"version":3,"file":"slot.js","sourceRoot":"","sources":["../../../../src/components/common/controllers/slot.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,GAIT,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AA4CrC,MAAM,WAAW,GAAG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,OAAO,EAAE,CAAC;YAChD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;gBACvC,IAAI,EAAE,WAAgB;gBACtB,SAAS,EAAE,KAAK;gBAChB,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AAED,SAAS,iBAAiB,CACxB,IAA4B,EAC5B,OAEC;IAED,OAAO,IAAI,cAAc,CAAC,IAA2C,EAAE;QACrE,GAAG,OAAO;QACV,KAAK,EAAE,OAAO,EAAE,KAAoC;KACrD,CAAC,CAAC;AACL,CAAC;AAED,SAAS,QAAQ,CAAoC,GAAG,KAAQ;IAC9D,OAAO,CAAC,WAAW,EAAE,GAAG,KAAK,CAAU,CAAC;AAC1C,CAAC;AAUD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import {\n isServer,\n type LitElement,\n type ReactiveController,\n type ReactiveControllerHost,\n} from 'lit';\nimport { isEmpty } from '../util.js';\n\ntype InferSlotNames<T> = T extends readonly (infer U)[] ? U : never;\n\n/**\n * Additional query options for the slot controller methods.\n */\ntype SlotQueryOptions = {\n /**\n * If set to `true`, it returns a sequence of both the elements assigned to the queried slot,\n * as well as elements assigned to any other slots that are descendants of this slot. If no\n * assigned elements are found, it returns the slot's fallback content.\n *\n * Defaults to `false`.\n */\n flatten?: boolean;\n /**\n * CSS selector used to filter the elements returned.\n */\n selector?: string;\n};\n\ntype SlotChangeCallback<T> = (\n parameters: SlotChangeCallbackParameters<T>\n) => void;\n\ntype SlotChangeCallbackParameters<T> = {\n /** The slot name that has its assigned nodes changed. */\n slot: T;\n /** `true` if the slot is the default slot. */\n isDefault: boolean;\n /** `true` if the callback handler is called for the initial host update. */\n isInitial: boolean;\n};\n\ntype SlotControllerOptions<T> = {\n /** An iterable collection of slot names to observe. */\n slots?: Iterable<T>;\n /** Callback function which is invoked a slot's assigned nodes change. */\n onChange?: SlotChangeCallback<T>;\n /** If set to `true`, the `onChange` callback is invoked once after the host is updated for the first time. */\n initial?: boolean;\n};\n\nconst DefaultSlot = '[default]';\n\nclass SlotController<T> implements ReactiveController {\n private readonly _host: ReactiveControllerHost & LitElement;\n private readonly _options: SlotControllerOptions<T>;\n private readonly _slots?: Set<T>;\n private _initialized = false;\n\n constructor(\n host: ReactiveControllerHost & LitElement,\n options?: SlotControllerOptions<T>\n ) {\n this._host = host;\n this._host.addController(this);\n\n this._options = { ...options };\n this._slots = options?.slots ? new Set(options.slots) : undefined;\n }\n\n private _getSlot(slotName?: T): HTMLSlotElement | null {\n if (isServer) return null;\n if (slotName === DefaultSlot) {\n return this._host.renderRoot.querySelector<HTMLSlotElement>(\n 'slot:not([name])'\n );\n }\n\n return this._host.renderRoot.querySelector<HTMLSlotElement>(\n `slot[name=\"${slotName}\"]`\n );\n }\n\n /**\n * Returns an array of the assigned nodes for `slot`.\n *\n * If `flatten` is set to `true`, it returns a sequence of both the nodes assigned to the queried slot,\n * as well as nodes assigned to any other slots that are descendants of this slot. If no\n * assigned nodes are found, it returns the slot's fallback content.\n */\n public getAssignedNodes(slot: T, flatten = false): Node[] {\n return this._getSlot(slot)?.assignedNodes({ flatten }) ?? [];\n }\n\n /**\n * Returns an array of the assigned elements for `slot` with additional `options`.\n *\n * See {@link SlotQueryOptions.flatten} and {@link SlotQueryOptions.selector} for more information.\n */\n public getAssignedElements<U extends Element>(\n slot: T,\n options?: SlotQueryOptions\n ): U[] {\n const elements =\n (this._getSlot(slot)?.assignedElements({\n flatten: options?.flatten,\n }) as U[]) ?? [];\n\n return options?.selector\n ? elements.filter((e) => e.matches(options.selector!))\n : elements;\n }\n\n /**\n * Return whether `slot` has assigned nodes.\n *\n * If `flatten` is set to `true`, it returns a sequence of both the nodes assigned to the queried slot,\n * as well as nodes assigned to any other slots that are descendants of this slot. If no\n * assigned nodes are found, it returns the slot's fallback content.\n */\n public hasAssignedNodes(slot: T, flatten = false): boolean {\n return !isEmpty(this.getAssignedNodes(slot, flatten));\n }\n\n /**\n * Return whether `slot` has assigned elements accepting additional `options`.\n *\n * See {@link SlotQueryOptions.flatten} and {@link SlotQueryOptions.selector} for more information.\n */\n public hasAssignedElements(slot: T, options?: SlotQueryOptions): boolean {\n return !isEmpty(this.getAssignedElements(slot, options));\n }\n\n /** @internal */\n public handleEvent(event: Event): void {\n const slot = event.target as HTMLSlotElement;\n const name = slot.name as T;\n const isDefault = name === '';\n\n if (\n !this._slots ||\n this._slots.has(isDefault ? (DefaultSlot as T) : (slot.name as T))\n ) {\n this._options.onChange?.call(this._host, {\n slot: name,\n isDefault,\n isInitial: false,\n });\n this._host.requestUpdate();\n }\n }\n\n /** @internal */\n public hostConnected(): void {\n this._host.renderRoot.addEventListener('slotchange', this);\n }\n\n /** @internal */\n public hostDisconnected(): void {\n this._host.renderRoot.removeEventListener('slotchange', this);\n }\n\n /** @internal */\n public hostUpdated(): void {\n if (!this._initialized && this._options.initial) {\n this._initialized = true;\n this._options.onChange?.call(this._host, {\n slot: '<initial>' as T,\n isDefault: false,\n isInitial: true,\n });\n }\n }\n}\n\nfunction addSlotController<K extends readonly string[]>(\n host: ReactiveControllerHost,\n options?: SlotControllerOptions<InferSlotNames<K>> & {\n slots?: K;\n }\n): SlotController<InferSlotNames<K>> {\n return new SlotController(host as ReactiveControllerHost & LitElement, {\n ...options,\n slots: options?.slots as Iterable<InferSlotNames<K>>,\n });\n}\n\nfunction setSlots<const T extends readonly string[]>(...slots: T) {\n return [DefaultSlot, ...slots] as const;\n}\n\nexport type {\n InferSlotNames,\n SlotChangeCallback,\n SlotChangeCallbackParameters,\n SlotController,\n SlotControllerOptions,\n SlotQueryOptions,\n};\nexport { addSlotController, DefaultSlot, setSlots };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/components/common/i18n/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE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AAC;YAC1D,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACpB,MAAM,CAAC,MAAiB,CAAC,GAAG,KAAmB,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,QAAW,EACX,eAAqC;IAErC,MAAM,MAAM,GAAqB,EAAE,CAAC;IACpC,MAAM,WAAW,GAAG,cAAc,CAAC,eAAe,CAAC,CAAC;IAEpD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,QAA4B,CAAC;IACtC,CAAC;IAED,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,WAAW,EAAE,CAAC;QAC5C,IAAI,OAAO,IAAI,OAAO,IAAI,QAAQ,EAAE,CAAC;YACnC,MAAM,CAAC,OAAiC,CAAC,GAAG,QAAQ,CAClD,OAAkB,CACT,CAAC;QACd,CAAC;aAAM,IAAI,OAAO,EAAE,CAAC;YACnB,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAiB,CAAC,CAAC;YAC1C,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACpB,MAAM,CAAC,OAAiC,CAAC,GAAG,KAAK,CAAC;YACpD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { IResourceStrings } from 'igniteui-i18n-core';\nimport { isString } from '../util.js';\nimport type { IgcCalendarResourceStrings } from './EN/calendar.resources.js';\nimport type { IgcChatResourceStrings } from './EN/chat.resources.js';\nimport type { IgcDatePickerResourceStrings } from './EN/date-picker.resources.js';\nimport type { IgcDateRangePickerResourceStrings } from './EN/date-range-picker.resources.js';\n\n/** Names of components currently handling a mix of old and new resource strings. */\nexport type I18nResourceMapNames =\n | 'calendar'\n | 'date-picker'\n | 'date-range-picker'\n | 'chat';\n\nexport const calendarResourcesMap = new Map<\n keyof IgcCalendarResourceStrings,\n string | undefined\n>([\n ['selectMonth', 'calendar_select_month'],\n ['selectYear', 'calendar_select_year'],\n ['selectDate', 'calendar_select_date'],\n ['selectRange', 'calendar_range_placeholder'],\n ['selectedDate', undefined], // This one seems not to be in use anyway\n ['startDate', 'calendar_range_label_start'],\n ['endDate', 'calendar_range_label_end'],\n ['previousMonth', 'calendar_previous_month'],\n ['nextMonth', 'calendar_next_month'],\n ['previousYear', 'calendar_previous_year'],\n ['nextYear', 'calendar_next_year'],\n ['previousYears', 'calendar_previous_years'],\n ['nextYears', 'calendar_next_years'],\n ['weekLabel', 'i18n/getWeekLabel'],\n]);\n\nexport const chatResourcesMap = new Map<keyof IgcChatResourceStrings, string>([\n ['suggestionsHeader', 'chat_suggestions_header'],\n ['reactionCopy', 'chat_reaction_copy'],\n ['reactionLike', 'chat_reaction_like'],\n ['reactionDislike', 'chat_reaction_dislike'],\n ['reactionRegenerate', 'chat_reaction_regenerate'],\n ['attachmentLabel', 'chat_attachment_label'],\n ['attachmentsListLabel', 'chat_attachments_list_label'],\n ['messageCopied', 'chat_message_copied'],\n]);\n\nexport const dateRangePickerResourcesMap = new Map<\n keyof IgcDateRangePickerResourceStrings,\n string | undefined\n>([\n ['separator', 'date_range_picker_date_separator'],\n ['done', 'date_range_picker_done_button'],\n ['cancel', 'date_range_picker_cancel_button'],\n ['last7Days', 'date_range_picker_last7Days'],\n ['last30Days', 'date_range_picker_last30Days'],\n ['currentMonth', 'date_range_picker_currentMonth'],\n ['yearToDate', 'date_range_picker_yearToDate'],\n ...(\n calendarResourcesMap as Map<\n keyof IgcDateRangePickerResourceStrings,\n string | undefined\n >\n ).entries(),\n]);\n\nexport const datePickerResourcesMap = new Map<\n keyof IgcDatePickerResourceStrings,\n string | undefined\n>([\n ['changeDate', 'date_picker_change_date'],\n ['chooseDate', 'date_picker_choose_date'],\n ...(\n calendarResourcesMap as Map<\n keyof IgcCalendarResourceStrings,\n string | undefined\n >\n ).entries(),\n]);\n\nfunction getResourceMap(\n name: I18nResourceMapNames\n): Map<string, string | undefined> | undefined {\n switch (name) {\n case 'calendar':\n return calendarResourcesMap;\n case 'chat':\n return chatResourcesMap;\n case 'date-picker':\n return datePickerResourcesMap;\n case 'date-range-picker':\n return dateRangePickerResourcesMap;\n default:\n break;\n }\n\n return new Map<string, string | undefined>();\n}\n\nexport function convertToIgcResource<T extends object>(\n resource: IResourceStrings,\n resourceMapName: I18nResourceMapNames\n): T {\n const result = {} as T;\n const resourceMap = getResourceMap(resourceMapName);\n\n if (!resourceMap) {\n return resource as T;\n }\n\n for (const [igcKey, coreKey] of resourceMap) {\n if (igcKey in resource) {\n result[igcKey as keyof T] = resource[\n igcKey as keyof IResourceStrings\n ] as T[keyof T];\n } else if (coreKey && coreKey in resource) {\n const value = resource[coreKey as keyof IResourceStrings];\n if (isString(value)) {\n result[igcKey as keyof T] = value as T[keyof T];\n }\n }\n }\n\n return result;\n}\n\nexport function convertToCoreResource<T extends object>(\n resource: T,\n resourceMapName: I18nResourceMapNames\n): IResourceStrings {\n const result: IResourceStrings = {};\n const resourceMap = getResourceMap(resourceMapName);\n\n if (!resourceMap) {\n return resource as IResourceStrings;\n }\n\n for (const [igcKey, coreKey] of resourceMap) {\n if (coreKey && coreKey in resource) {\n result[coreKey as keyof IResourceStrings] = resource[\n coreKey as keyof T\n ] as string;\n } else if (coreKey) {\n const value = resource[igcKey as keyof T];\n if (isString(value)) {\n result[coreKey as keyof IResourceStrings] = value;\n }\n }\n }\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/components/common/i18n/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAUtC,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAGzC;IACA,CAAC,aAAa,EAAE,uBAAuB,CAAC;IACxC,CAAC,YAAY,EAAE,sBAAsB,CAAC;IACtC,CAAC,YAAY,EAAE,sBAAsB,CAAC;IACtC,CAAC,aAA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AqC;IAErC,MAAM,MAAM,GAAqB,EAAE,CAAC;IACpC,MAAM,WAAW,GAAG,cAAc,CAAC,eAAe,CAAC,CAAC;IAEpD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,QAA4B,CAAC;IACtC,CAAC;IAED,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,WAAW,EAAE,CAAC;QAC5C,IAAI,OAAO,IAAI,OAAO,IAAI,QAAQ,EAAE,CAAC;YACnC,MAAM,CAAC,OAAiC,CAAC,GAAG,QAAQ,CAClD,OAAkB,CACT,CAAC;QACd,CAAC;aAAM,IAAI,OAAO,EAAE,CAAC;YACnB,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAiB,CAAC,CAAC;YAC1C,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACpB,MAAM,CAAC,OAAiC,CAAC,GAAG,KAAK,CAAC;YACpD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { IResourceStrings } from 'igniteui-i18n-core';\nimport { isString } from '../util.js';\nimport type { IgcCalendarResourceStrings } from './EN/calendar.resources.js';\nimport type { IgcChatResourceStrings } from './EN/chat.resources.js';\nimport type { IgcDatePickerResourceStrings } from './EN/date-picker.resources.js';\nimport type { IgcDateRangePickerResourceStrings } from './EN/date-range-picker.resources.js';\n\n/** Names of components currently handling a mix of old and new resource strings. */\nexport type I18nResourceMapNames =\n 'calendar' | 'date-picker' | 'date-range-picker' | 'chat';\n\nexport const calendarResourcesMap = new Map<\n keyof IgcCalendarResourceStrings,\n string | undefined\n>([\n ['selectMonth', 'calendar_select_month'],\n ['selectYear', 'calendar_select_year'],\n ['selectDate', 'calendar_select_date'],\n ['selectRange', 'calendar_range_placeholder'],\n ['selectedDate', undefined], // This one seems not to be in use anyway\n ['startDate', 'calendar_range_label_start'],\n ['endDate', 'calendar_range_label_end'],\n ['previousMonth', 'calendar_previous_month'],\n ['nextMonth', 'calendar_next_month'],\n ['previousYear', 'calendar_previous_year'],\n ['nextYear', 'calendar_next_year'],\n ['previousYears', 'calendar_previous_years'],\n ['nextYears', 'calendar_next_years'],\n ['weekLabel', 'i18n/getWeekLabel'],\n]);\n\nexport const chatResourcesMap = new Map<keyof IgcChatResourceStrings, string>([\n ['suggestionsHeader', 'chat_suggestions_header'],\n ['reactionCopy', 'chat_reaction_copy'],\n ['reactionLike', 'chat_reaction_like'],\n ['reactionDislike', 'chat_reaction_dislike'],\n ['reactionRegenerate', 'chat_reaction_regenerate'],\n ['attachmentLabel', 'chat_attachment_label'],\n ['attachmentsListLabel', 'chat_attachments_list_label'],\n ['messageCopied', 'chat_message_copied'],\n]);\n\nexport const dateRangePickerResourcesMap = new Map<\n keyof IgcDateRangePickerResourceStrings,\n string | undefined\n>([\n ['separator', 'date_range_picker_date_separator'],\n ['done', 'date_range_picker_done_button'],\n ['cancel', 'date_range_picker_cancel_button'],\n ['last7Days', 'date_range_picker_last7Days'],\n ['last30Days', 'date_range_picker_last30Days'],\n ['currentMonth', 'date_range_picker_currentMonth'],\n ['yearToDate', 'date_range_picker_yearToDate'],\n ...(\n calendarResourcesMap as Map<\n keyof IgcDateRangePickerResourceStrings,\n string | undefined\n >\n ).entries(),\n]);\n\nexport const datePickerResourcesMap = new Map<\n keyof IgcDatePickerResourceStrings,\n string | undefined\n>([\n ['changeDate', 'date_picker_change_date'],\n ['chooseDate', 'date_picker_choose_date'],\n ...(\n calendarResourcesMap as Map<\n keyof IgcCalendarResourceStrings,\n string | undefined\n >\n ).entries(),\n]);\n\nfunction getResourceMap(\n name: I18nResourceMapNames\n): Map<string, string | undefined> | undefined {\n switch (name) {\n case 'calendar':\n return calendarResourcesMap;\n case 'chat':\n return chatResourcesMap;\n case 'date-picker':\n return datePickerResourcesMap;\n case 'date-range-picker':\n return dateRangePickerResourcesMap;\n default:\n break;\n }\n\n return new Map<string, string | undefined>();\n}\n\nexport function convertToIgcResource<T extends object>(\n resource: IResourceStrings,\n resourceMapName: I18nResourceMapNames\n): T {\n const result = {} as T;\n const resourceMap = getResourceMap(resourceMapName);\n\n if (!resourceMap) {\n return resource as T;\n }\n\n for (const [igcKey, coreKey] of resourceMap) {\n if (igcKey in resource) {\n result[igcKey as keyof T] = resource[\n igcKey as keyof IResourceStrings\n ] as T[keyof T];\n } else if (coreKey && coreKey in resource) {\n const value = resource[coreKey as keyof IResourceStrings];\n if (isString(value)) {\n result[igcKey as keyof T] = value as T[keyof T];\n }\n }\n }\n\n return result;\n}\n\nexport function convertToCoreResource<T extends object>(\n resource: T,\n resourceMapName: I18nResourceMapNames\n): IResourceStrings {\n const result: IResourceStrings = {};\n const resourceMap = getResourceMap(resourceMapName);\n\n if (!resourceMap) {\n return resource as IResourceStrings;\n }\n\n for (const [igcKey, coreKey] of resourceMap) {\n if (coreKey && coreKey in resource) {\n result[coreKey as keyof IResourceStrings] = resource[\n coreKey as keyof T\n ] as string;\n } else if (coreKey) {\n const value = resource[igcKey as keyof T];\n if (isString(value)) {\n result[coreKey as keyof IResourceStrings] = value;\n }\n }\n }\n\n return result;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { LitElement } from 'lit';
1
+ import { type LitElement } from 'lit';
2
2
  import type { Constructor } from '../constructor.js';
3
3
  import { type FormAssociatedCheckboxElementInterface, type FormAssociatedElementInterface } from './types.js';
4
4
  /**
@@ -4,6 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
+ import { isServer } from 'lit';
7
8
  import { property } from 'lit/decorators.js';
8
9
  import { addInternalsController } from '../../controllers/internals.js';
9
10
  import { enterKey } from '../../controllers/key-bindings.js';
@@ -50,20 +51,20 @@ function BaseFormAssociated(base) {
50
51
  return this._isExternalInvalid || this._shouldApplyStyles;
51
52
  }
52
53
  get form() {
53
- return this.__internals.form;
54
+ return this._internals.form;
54
55
  }
55
56
  get validity() {
56
- return this.__internals.validity;
57
+ return this._internals.validity;
57
58
  }
58
59
  get validationMessage() {
59
- return this.__internals.validationMessage;
60
+ return this._internals.validationMessage;
60
61
  }
61
62
  get willValidate() {
62
- return this.__internals.willValidate;
63
+ return this._internals.willValidate;
63
64
  }
64
65
  constructor(...args) {
65
- super(args);
66
- this.__internals = addInternalsController(this);
66
+ super(...args);
67
+ this._internals = addInternalsController(this);
67
68
  this._isFormSubmit = false;
68
69
  this._isInternalValidation = false;
69
70
  this._touched = false;
@@ -107,7 +108,10 @@ function BaseFormAssociated(base) {
107
108
  }
108
109
  }
109
110
  _setInvalidStyles() {
110
- this.__internals.setState(INVALID_STATE, this._shouldApplyStyles);
111
+ this._internals.setState(INVALID_STATE, this._shouldApplyStyles);
112
+ }
113
+ _resolveInternalValidation() {
114
+ this._isInternalValidation = false;
111
115
  }
112
116
  __runValidators() {
113
117
  const validity = {};
@@ -127,6 +131,8 @@ function BaseFormAssociated(base) {
127
131
  return { validity, message };
128
132
  }
129
133
  _validate(userMessage) {
134
+ if (isServer)
135
+ return;
130
136
  let { validity, message } = this.__runValidators();
131
137
  const hasCustomError = this.validity.customError;
132
138
  if (validity.valueMissing) {
@@ -146,9 +152,10 @@ function BaseFormAssociated(base) {
146
152
  validity.customError = true;
147
153
  message = userMessage;
148
154
  }
149
- this.__internals.setValidity(validity, message);
155
+ this._internals.setValidity(validity, message);
150
156
  this._isInternalValidation = true;
151
- this._invalid = !this.__internals.checkValidity();
157
+ this._invalid = !this._internals.checkValidity();
158
+ this._resolveInternalValidation();
152
159
  }
153
160
  _handleBlur() {
154
161
  this._setTouchedState();
@@ -169,7 +176,7 @@ function BaseFormAssociated(base) {
169
176
  }
170
177
  _setFormValue(value, state) {
171
178
  this._pristine = false;
172
- this.__internals.setFormValue(value, state);
179
+ this._internals.setFormValue(value, state);
173
180
  this._validate();
174
181
  this._setInvalidStyles();
175
182
  }
@@ -188,14 +195,15 @@ function BaseFormAssociated(base) {
188
195
  }
189
196
  formStateRestoreCallback(_state, _mode) { }
190
197
  reportValidity() {
191
- const state = this.__internals.reportValidity();
198
+ const state = this._internals.reportValidity();
192
199
  this._invalid = !state;
193
200
  return state;
194
201
  }
195
202
  checkValidity() {
196
203
  this._isInternalValidation = true;
197
- const state = this.__internals.checkValidity();
204
+ const state = this._internals.checkValidity();
198
205
  this._invalid = !state;
206
+ this._resolveInternalValidation();
199
207
  return state;
200
208
  }
201
209
  setCustomValidity(message) {
@@ -209,7 +217,7 @@ function BaseFormAssociated(base) {
209
217
  property({ reflect: true })
210
218
  ], BaseFormAssociatedElement.prototype, "name", void 0);
211
219
  __decorate([
212
- property({ type: Boolean, reflect: true })
220
+ property({ type: Boolean })
213
221
  ], BaseFormAssociatedElement.prototype, "disabled", null);
214
222
  __decorate([
215
223
  property({ type: Boolean })
@@ -1 +1 @@
1
- {"version":3,"file":"associated.js","sourceRoot":"","sources":["../../../../../src/components/common/mixins/forms/associated.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI3E,OAAO,EAKL,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAEpB,MAAM,aAAa,GAAG,YAAY,CAAC;AAEnC,MAAM,YAAY,GAAG;IACnB,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,KAAK;CAChB,CAAC;AAEF,SAAS,oBAAoB,CAAC,IAAgB;IAC5C,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC,CAAC;AAC1E,CAA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CAAC;YACpD,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;gBACrB,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;KACF;IAxBC;QADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;6DAS9B;IAkBH,OAAO,qBACJ,CAAC;AACN,CAAC;AAKD,MAAM,UAAU,2BAA2B,CACzC,IAAO;IAEP,MAAM,6BAA8B,SAAQ,kBAAkB,CAAC,IAAI,CAAC;QAGlE,IAAW,cAAc,CAAC,KAAc;YACtC,IAAI,CAAC,UAAU,CAAC,YAAY,GAAG,KAAK,CAAC;YAErC,IAAI,IAAI,CAAC,SAAS,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;gBACxC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC;gBACnC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBACtB,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,CAAC;QACH,CAAC;QAED,IAAW,cAAc;YACvB,OAAO,IAAI,CAAC,UAAU,CAAC,YAAuB,CAAC;QACjD,CAAC;QAEe,wBAAwB,CACtC,IAAY,EACZ,IAAmB,EACnB,OAAsB;YAEtB,KAAK,CAAC,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;YACpD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;KACF;IAxBC;QADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uEAS9B;IAkBH,OAAO,6BACJ,CAAC;AACN,CAAC","sourcesContent":["import type { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { addInternalsController } from '../../controllers/internals.js';\nimport { enterKey } from '../../controllers/key-bindings.js';\nimport { addSafeEventListener, isFunction, isString } from '../../util.js';\nimport type { Validator } from '../../validators.js';\nimport type { Constructor } from '../constructor.js';\nimport type { FormValue } from './form-value.js';\nimport {\n type FormAssociatedCheckboxElementInterface,\n type FormAssociatedElementInterface,\n type FormRestoreMode,\n type FormValueType,\n InternalInvalidEvent,\n InternalResetEvent,\n} from './types.js';\n\nconst INVALID_STATE = 'ig-invalid';\n\nconst eventOptions = {\n bubbles: false,\n composed: false,\n};\n\nfunction emitFormInvalidEvent(host: LitElement): void {\n host.dispatchEvent(new CustomEvent(InternalInvalidEvent, eventOptions));\n}\n\nfunction emitFormResetEvent(host: LitElement): void {\n host.dispatchEvent(new CustomEvent(InternalResetEvent, eventOptions));\n}\n\nfunction BaseFormAssociated<T extends Constructor<LitElement>>(base: T) {\n class BaseFormAssociatedElement extends base {\n public static readonly formAssociated = true;\n\n //#region Internal state and properties\n\n private readonly __internals = addInternalsController(this);\n protected readonly _formValue!: FormValue<unknown>;\n\n private _isFormSubmit = false;\n private _isInternalValidation = false;\n private _touched = false;\n private _isExternalInvalid = false;\n\n private get _hasUserInteraction(): boolean {\n return this._touched || this._isFormSubmit;\n }\n\n private get _shouldApplyStyles(): boolean {\n if (this._isExternalInvalid) {\n return true;\n }\n\n return (\n this._invalid && this._hasUserInteraction && !this._isInternalValidation\n );\n }\n\n protected _disabled = false;\n protected _invalid = false;\n protected _pristine = true;\n\n protected get __validators(): Validator[] {\n return [];\n }\n\n //#endregion\n\n //#region Public properties and attributes\n\n /**\n * The name attribute of the control.\n * @attr\n */\n @property({ reflect: true })\n public name!: string;\n\n /**\n * The disabled state of the component.\n * @attr\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public set disabled(value: boolean) {\n this._disabled = value;\n this.toggleAttribute('disabled', Boolean(this._disabled));\n }\n\n public get disabled(): boolean {\n return this._disabled;\n }\n\n /**\n * Sets the control into invalid state (visual state only).\n * @attr\n * @default false\n */\n @property({ type: Boolean })\n public set invalid(value: boolean) {\n this._isExternalInvalid = value;\n this._setInvalidStyles();\n }\n\n public get invalid(): boolean {\n return this._isExternalInvalid || this._shouldApplyStyles;\n }\n\n /** Returns the HTMLFormElement associated with this element. */\n public get form(): HTMLFormElement | null {\n return this.__internals.form;\n }\n\n /**\n * Returns a ValidityState object which represents the different validity states\n * the element can be in, with respect to constraint validation.\n */\n public get validity(): ValidityState {\n return this.__internals.validity;\n }\n\n /** A string containing the validation message of this element. */\n public get validationMessage(): string {\n return this.__internals.validationMessage;\n }\n\n /**\n * A boolean value which returns true if the element is a submittable element\n * that is a candidate for constraint validation.\n */\n public get willValidate(): boolean {\n return this.__internals.willValidate;\n }\n //#endregion\n\n //#region Life-cycle hooks\n\n constructor(...args: any[]) {\n super(args);\n addSafeEventListener(this, 'invalid', this._handleInvalid);\n }\n\n /** @internal */\n public override connectedCallback(): void {\n super.connectedCallback();\n this._pristine = true;\n this._touched = false;\n this._validate();\n }\n\n //#endregion\n\n //#region Enter key submission handling\n\n protected _handleEnterKeydown(event: KeyboardEvent): void {\n if (event.key !== enterKey) return;\n if (event.repeat) return;\n\n const canSubmit =\n this.form && (this.form.noValidate || this.checkValidity());\n\n if (canSubmit) {\n this.form?.requestSubmit();\n }\n }\n\n //#endregion\n\n //#region Form value and validation states\n\n private async _handleInvalid(event: Event): Promise<void> {\n event.preventDefault();\n this._invalid = true;\n\n if (this._isInternalValidation) {\n this._isInternalValidation = false;\n } else {\n this._isFormSubmit = true;\n emitFormInvalidEvent(this);\n }\n\n this._setInvalidStyles();\n this.requestUpdate();\n\n if (this._isFormSubmit) {\n await this.updateComplete;\n this._isFormSubmit = false;\n }\n }\n\n private _setInvalidStyles(): void {\n this.__internals.setState(INVALID_STATE, this._shouldApplyStyles);\n }\n\n private __runValidators() {\n const validity: ValidityStateFlags = {};\n let message = '';\n let validationFailed = false;\n\n for (const validator of this.__validators) {\n const isValid = validator.isValid(this);\n\n validity[validator.key] = !isValid;\n\n if (!isValid) {\n validationFailed = true;\n message = isFunction(validator.message)\n ? validator.message(this)\n : validator.message;\n }\n }\n\n this._invalid = validationFailed;\n\n return { validity, message };\n }\n\n /**\n * Executes the component validators and updates the internal validity state.\n */\n protected _validate(userMessage?: string): void {\n let { validity, message } = this.__runValidators();\n const hasCustomError = this.validity.customError;\n\n // valueMissing has precedence over the other validators aside from customError\n if (validity.valueMissing) {\n validity = {\n valueMissing: true,\n customError: hasCustomError,\n };\n }\n\n if (hasCustomError && userMessage === undefined) {\n // Internal validation cycle after the user has called setCustomValidity()\n // with some message. Keep the customError flag and the passed in message.\n validity.customError = true;\n message = this.validationMessage;\n } else if (hasCustomError && userMessage === '') {\n // setCustomValidity with an empty message.\n validity.customError = false;\n } else if (userMessage && userMessage !== '') {\n // setCustomValidity with a message.\n validity.customError = true;\n message = userMessage;\n }\n\n this.__internals.setValidity(validity, message);\n this._isInternalValidation = true;\n this._invalid = !this.__internals.checkValidity();\n }\n\n protected _handleBlur(): void {\n this._setTouchedState();\n this._validate();\n }\n\n protected _setTouchedState(): void {\n if (!this._touched) {\n this._touched = true;\n }\n }\n\n protected _setDefaultValue(current: string | null): void {\n this._formValue.defaultValue = current;\n }\n\n protected _restoreDefaultValue(): void {\n const value = this._formValue.value;\n this._formValue.setValueAndFormState(this._formValue.defaultValue);\n this.requestUpdate('value', value);\n }\n\n protected _setFormValue(value: FormValueType, state?: FormValueType): void {\n this._pristine = false;\n this.__internals.setFormValue(value, state);\n this._validate();\n this._setInvalidStyles();\n }\n\n //#region Form associated callback hooks\n\n protected formAssociatedCallback(_form: HTMLFormElement): void {}\n\n protected formDisabledCallback(state: boolean): void {\n this._disabled = state;\n this.requestUpdate();\n }\n\n protected formResetCallback(): void {\n this._restoreDefaultValue();\n this._pristine = true;\n this._touched = false;\n this._invalid = false;\n this._setInvalidStyles();\n emitFormResetEvent(this);\n }\n\n /* c8 ignore next 4 */\n protected formStateRestoreCallback(\n _state: FormValueType,\n _mode: FormRestoreMode\n ): void {}\n\n //#endregion\n\n //#region Public API\n\n /** Checks for validity of the control and shows the browser message if it invalid. */\n public reportValidity(): boolean {\n const state = this.__internals.reportValidity();\n this._invalid = !state;\n return state;\n }\n\n /** Checks for validity of the control and emits the invalid event if it invalid. */\n public checkValidity(): boolean {\n this._isInternalValidation = true;\n const state = this.__internals.checkValidity();\n this._invalid = !state;\n return state;\n }\n\n /**\n * Sets a custom validation message for the control.\n * As long as `message` is not empty, the control is considered invalid.\n */\n public setCustomValidity(message: string): void {\n this._validate(message);\n this._isInternalValidation = message === '';\n this._setInvalidStyles();\n this.requestUpdate();\n }\n\n //#endregion\n }\n return BaseFormAssociatedElement as Constructor<BaseFormAssociatedElement> &\n T;\n}\n\n/**\n * Mixes the passed in class and turns it into a form associated custom element.\n */\nexport function FormAssociatedMixin<T extends Constructor<LitElement>>(\n base: T\n) {\n class FormAssociatedElement extends BaseFormAssociated(base) {\n /* blazorCSSuppress */\n @property({ attribute: false })\n public set defaultValue(value: unknown) {\n this._formValue.defaultValue = value;\n\n if (this._pristine && 'value' in this) {\n this.value = this.defaultValue;\n this._pristine = true;\n this._validate();\n }\n }\n\n public get defaultValue(): unknown {\n return this._formValue.defaultValue;\n }\n\n public override attributeChangedCallback(\n name: string,\n prev: string | null,\n current: string | null\n ): void {\n super.attributeChangedCallback(name, prev, current);\n if (name === 'value') {\n this._setDefaultValue(current);\n }\n }\n }\n\n return FormAssociatedElement as unknown as Constructor<FormAssociatedElementInterface> &\n T;\n}\n\n/**\n * Mixes the passed in class and turns it into a form associated custom element.\n */\nexport function FormAssociatedCheckboxMixin<T extends Constructor<LitElement>>(\n base: T\n) {\n class FormAssociatedCheckboxElement extends BaseFormAssociated(base) {\n /* blazorCSSuppress */\n @property({ attribute: false })\n public set defaultChecked(value: boolean) {\n this._formValue.defaultValue = value;\n\n if (this._pristine && 'checked' in this) {\n this.checked = this.defaultChecked;\n this._pristine = true;\n this._validate();\n }\n }\n\n public get defaultChecked(): boolean {\n return this._formValue.defaultValue as boolean;\n }\n\n public override attributeChangedCallback(\n name: string,\n prev: string | null,\n current: string | null\n ): void {\n super.attributeChangedCallback(name, prev, current);\n if (name === 'checked') {\n this._setDefaultValue(isString(current) ? 'true' : null);\n }\n }\n }\n\n return FormAssociatedCheckboxElement as unknown as Constructor<FormAssociatedCheckboxElementInterface> &\n T;\n}\n"]}
1
+ {"version":3,"file":"associated.js","sourceRoot":"","sources":["../../../../../src/components/common/mixins/forms/associated.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAmB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI3E,OAAO,EAKL,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAEpB,MAAM,aAAa,GAAG,YAAY,CAAC;AAEnC,MAAM,YAAY,GAAG;IACnB,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,KAAK;CAChB,CAAC;AAEF,SAAS,oBAAoB,CAAC,IAAgB;IAC5C,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAgB;IAC1C,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,kBAAkB,CAAoC,IAAO;IACpE,MAAM,yBAA0B,SAAQ,IAAI;iBACnB,mBAAc,GAAG,IAAI,AAAP,CAAQ;QAyB7C,IAAY,mBAAmB;YAC7B,OAAO,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,aAAa,CAAC;QAC7C,CAAC;QA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K,EAAE,CAAC;6DAS9B;IAkBH,OAAO,qBACJ,CAAC;AACN,CAAC;AAKD,MAAM,UAAU,2BAA2B,CACzC,IAAO;IAEP,MAAM,6BAA8B,SAAQ,kBAAkB,CAAC,IAAI,CAAC;QAGlE,IAAW,cAAc,CAAC,KAAc;YACtC,IAAI,CAAC,UAAU,CAAC,YAAY,GAAG,KAAK,CAAC;YAErC,IAAI,IAAI,CAAC,SAAS,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;gBACxC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC;gBACnC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBACtB,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,CAAC;QACH,CAAC;QAED,IAAW,cAAc;YACvB,OAAO,IAAI,CAAC,UAAU,CAAC,YAAuB,CAAC;QACjD,CAAC;QAEe,wBAAwB,CACtC,IAAY,EACZ,IAAmB,EACnB,OAAsB;YAEtB,KAAK,CAAC,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;YACpD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;KACF;IAxBC;QADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uEAS9B;IAkBH,OAAO,6BACJ,CAAC;AACN,CAAC","sourcesContent":["import { isServer, type LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { addInternalsController } from '../../controllers/internals.js';\nimport { enterKey } from '../../controllers/key-bindings.js';\nimport { addSafeEventListener, isFunction, isString } from '../../util.js';\nimport type { Validator } from '../../validators.js';\nimport type { Constructor } from '../constructor.js';\nimport type { FormValue } from './form-value.js';\nimport {\n type FormAssociatedCheckboxElementInterface,\n type FormAssociatedElementInterface,\n type FormRestoreMode,\n type FormValueType,\n InternalInvalidEvent,\n InternalResetEvent,\n} from './types.js';\n\nconst INVALID_STATE = 'ig-invalid';\n\nconst eventOptions = {\n bubbles: false,\n composed: false,\n};\n\nfunction emitFormInvalidEvent(host: LitElement): void {\n host.dispatchEvent(new CustomEvent(InternalInvalidEvent, eventOptions));\n}\n\nfunction emitFormResetEvent(host: LitElement): void {\n host.dispatchEvent(new CustomEvent(InternalResetEvent, eventOptions));\n}\n\nfunction BaseFormAssociated<T extends Constructor<LitElement>>(base: T) {\n class BaseFormAssociatedElement extends base {\n public static readonly formAssociated = true;\n\n //#region Internal state and properties\n\n protected readonly _internals = addInternalsController(this);\n protected readonly _formValue!: FormValue<unknown>;\n\n /**\n * Marks that validation is running as part of a form submission. Counts as\n * user interaction (so invalid styles apply) and is cleared once the\n * submit-driven update settles. Orthogonal to `_isInternalValidation`: a\n * programmatic re-check can run while a submission is still in flight.\n */\n private _isFormSubmit = false;\n\n /**\n * Suppresses invalid styling for a programmatic validation cycle\n * (`checkValidity`/`_validate`). Scoped to the synchronous validity check:\n * set immediately before it and cleared immediately after, so it never\n * leaks into a later submission or user-interaction cycle.\n */\n private _isInternalValidation = false;\n private _touched = false;\n private _isExternalInvalid = false;\n\n private get _hasUserInteraction(): boolean {\n return this._touched || this._isFormSubmit;\n }\n\n private get _shouldApplyStyles(): boolean {\n if (this._isExternalInvalid) {\n return true;\n }\n\n return (\n this._invalid && this._hasUserInteraction && !this._isInternalValidation\n );\n }\n\n protected _disabled = false;\n protected _invalid = false;\n protected _pristine = true;\n\n protected get __validators(): Validator[] {\n return [];\n }\n\n //#endregion\n\n //#region Public properties and attributes\n\n /**\n * The name attribute of the control.\n * @attr\n */\n @property({ reflect: true })\n public name!: string;\n\n /**\n * The disabled state of the component.\n * @attr\n * @default false\n */\n @property({ type: Boolean })\n public set disabled(value: boolean) {\n this._disabled = value;\n this.toggleAttribute('disabled', Boolean(this._disabled));\n }\n\n public get disabled(): boolean {\n return this._disabled;\n }\n\n /**\n * Sets the control into invalid state (visual state only).\n * @attr\n * @default false\n */\n @property({ type: Boolean })\n public set invalid(value: boolean) {\n this._isExternalInvalid = value;\n this._setInvalidStyles();\n }\n\n public get invalid(): boolean {\n return this._isExternalInvalid || this._shouldApplyStyles;\n }\n\n /** Returns the HTMLFormElement associated with this element. */\n public get form(): HTMLFormElement | null {\n return this._internals.form;\n }\n\n /**\n * Returns a ValidityState object which represents the different validity states\n * the element can be in, with respect to constraint validation.\n */\n public get validity(): ValidityState {\n return this._internals.validity;\n }\n\n /** A string containing the validation message of this element. */\n public get validationMessage(): string {\n return this._internals.validationMessage;\n }\n\n /**\n * A boolean value which returns true if the element is a submittable element\n * that is a candidate for constraint validation.\n */\n public get willValidate(): boolean {\n return this._internals.willValidate;\n }\n //#endregion\n\n //#region Life-cycle hooks\n\n constructor(...args: any[]) {\n super(...args);\n addSafeEventListener(this, 'invalid', this._handleInvalid);\n }\n\n /** @internal */\n public override connectedCallback(): void {\n super.connectedCallback();\n this._pristine = true;\n this._touched = false;\n this._validate();\n }\n\n //#endregion\n\n //#region Enter key submission handling\n\n protected _handleEnterKeydown(event: KeyboardEvent): void {\n if (event.key !== enterKey) return;\n if (event.repeat) return;\n\n const canSubmit =\n this.form && (this.form.noValidate || this.checkValidity());\n\n if (canSubmit) {\n this.form?.requestSubmit();\n }\n }\n\n //#endregion\n\n //#region Form value and validation states\n\n private async _handleInvalid(event: Event): Promise<void> {\n event.preventDefault();\n this._invalid = true;\n\n if (this._isInternalValidation) {\n this._isInternalValidation = false;\n } else {\n this._isFormSubmit = true;\n emitFormInvalidEvent(this);\n }\n\n this._setInvalidStyles();\n this.requestUpdate();\n\n if (this._isFormSubmit) {\n await this.updateComplete;\n this._isFormSubmit = false;\n }\n }\n\n private _setInvalidStyles(): void {\n this._internals.setState(INVALID_STATE, this._shouldApplyStyles);\n }\n\n /**\n * Closes a programmatic validation cycle. If the control was invalid, the\n * synchronous `invalid` event already cleared the flag; if it was valid no\n * event fired, so clear it here to stop it leaking into a later submission\n * or user-interaction cycle.\n */\n private _resolveInternalValidation(): void {\n this._isInternalValidation = false;\n }\n\n private __runValidators(): {\n validity: ValidityStateFlags;\n message: string;\n } {\n const validity: ValidityStateFlags = {};\n let message = '';\n let validationFailed = false;\n\n for (const validator of this.__validators) {\n const isValid = validator.isValid(this);\n\n validity[validator.key] = !isValid;\n\n if (!isValid) {\n validationFailed = true;\n message = isFunction(validator.message)\n ? validator.message(this)\n : validator.message;\n }\n }\n\n this._invalid = validationFailed;\n\n return { validity, message };\n }\n\n /**\n * Executes the component validators and updates the internal validity state.\n */\n protected _validate(userMessage?: string): void {\n if (isServer) return;\n let { validity, message } = this.__runValidators();\n const hasCustomError = this.validity.customError;\n\n // valueMissing has precedence over the other validators aside from customError\n if (validity.valueMissing) {\n validity = {\n valueMissing: true,\n customError: hasCustomError,\n };\n }\n\n if (hasCustomError && userMessage === undefined) {\n // Internal validation cycle after the user has called setCustomValidity()\n // with some message. Keep the customError flag and the passed in message.\n validity.customError = true;\n message = this.validationMessage;\n } else if (hasCustomError && userMessage === '') {\n // setCustomValidity with an empty message.\n validity.customError = false;\n } else if (userMessage && userMessage !== '') {\n // setCustomValidity with a message.\n validity.customError = true;\n message = userMessage;\n }\n\n this._internals.setValidity(validity, message);\n this._isInternalValidation = true;\n this._invalid = !this._internals.checkValidity();\n this._resolveInternalValidation();\n }\n\n protected _handleBlur(): void {\n this._setTouchedState();\n this._validate();\n }\n\n protected _setTouchedState(): void {\n if (!this._touched) {\n this._touched = true;\n }\n }\n\n protected _setDefaultValue(current: string | null): void {\n this._formValue.defaultValue = current;\n }\n\n protected _restoreDefaultValue(): void {\n const value = this._formValue.value;\n this._formValue.setValueAndFormState(this._formValue.defaultValue);\n this.requestUpdate('value', value);\n }\n\n protected _setFormValue(value: FormValueType, state?: FormValueType): void {\n this._pristine = false;\n this._internals.setFormValue(value, state);\n this._validate();\n this._setInvalidStyles();\n }\n\n //#region Form associated callback hooks\n\n protected formAssociatedCallback(_form: HTMLFormElement): void {}\n\n protected formDisabledCallback(state: boolean): void {\n this._disabled = state;\n this.requestUpdate();\n }\n\n protected formResetCallback(): void {\n this._restoreDefaultValue();\n this._pristine = true;\n this._touched = false;\n this._invalid = false;\n this._setInvalidStyles();\n emitFormResetEvent(this);\n }\n\n /* c8 ignore next 4 */\n protected formStateRestoreCallback(\n _state: FormValueType,\n _mode: FormRestoreMode\n ): void {}\n\n //#endregion\n\n //#region Public API\n\n /** Checks for validity of the control and shows the browser message if it invalid. */\n public reportValidity(): boolean {\n const state = this._internals.reportValidity();\n this._invalid = !state;\n return state;\n }\n\n /** Checks for validity of the control and emits the invalid event if it invalid. */\n public checkValidity(): boolean {\n this._isInternalValidation = true;\n const state = this._internals.checkValidity();\n this._invalid = !state;\n this._resolveInternalValidation();\n return state;\n }\n\n /**\n * Sets a custom validation message for the control.\n * As long as `message` is not empty, the control is considered invalid.\n */\n public setCustomValidity(message: string): void {\n this._validate(message);\n this._isInternalValidation = message === '';\n this._setInvalidStyles();\n this.requestUpdate();\n }\n\n //#endregion\n }\n return BaseFormAssociatedElement as Constructor<BaseFormAssociatedElement> &\n T;\n}\n\n/**\n * Mixes the passed in class and turns it into a form associated custom element.\n */\nexport function FormAssociatedMixin<T extends Constructor<LitElement>>(\n base: T\n) {\n class FormAssociatedElement extends BaseFormAssociated(base) {\n /* blazorCSSuppress */\n @property({ attribute: false })\n public set defaultValue(value: unknown) {\n this._formValue.defaultValue = value;\n\n if (this._pristine && 'value' in this) {\n this.value = this.defaultValue;\n this._pristine = true;\n this._validate();\n }\n }\n\n public get defaultValue(): unknown {\n return this._formValue.defaultValue;\n }\n\n public override attributeChangedCallback(\n name: string,\n prev: string | null,\n current: string | null\n ): void {\n super.attributeChangedCallback(name, prev, current);\n if (name === 'value') {\n this._setDefaultValue(current);\n }\n }\n }\n\n return FormAssociatedElement as unknown as Constructor<FormAssociatedElementInterface> &\n T;\n}\n\n/**\n * Mixes the passed in class and turns it into a form associated custom element.\n */\nexport function FormAssociatedCheckboxMixin<T extends Constructor<LitElement>>(\n base: T\n) {\n class FormAssociatedCheckboxElement extends BaseFormAssociated(base) {\n /* blazorCSSuppress */\n @property({ attribute: false })\n public set defaultChecked(value: boolean) {\n this._formValue.defaultValue = value;\n\n if (this._pristine && 'checked' in this) {\n this.checked = this.defaultChecked;\n this._pristine = true;\n this._validate();\n }\n }\n\n public get defaultChecked(): boolean {\n return this._formValue.defaultValue as boolean;\n }\n\n public override attributeChangedCallback(\n name: string,\n prev: string | null,\n current: string | null\n ): void {\n super.attributeChangedCallback(name, prev, current);\n if (name === 'checked') {\n this._setDefaultValue(isString(current) ? 'true' : null);\n }\n }\n }\n\n return FormAssociatedCheckboxElement as unknown as Constructor<FormAssociatedCheckboxElementInterface> &\n T;\n}\n"]}
@@ -1,11 +1,12 @@
1
1
  import type { LitElement } from 'lit';
2
+ import type { ElementInternalsController } from '../../controllers/internals.js';
2
3
  import type { Validator } from '../../validators.js';
3
4
  export type FormRestoreMode = 'autocomplete' | 'restore';
4
5
  export type FormValueType = string | File | FormData | null;
5
6
  export type IgcFormControl = LitElement & (FormAssociatedElementInterface | FormAssociatedCheckboxElementInterface);
6
7
  declare class BaseFormAssociatedElement {
7
8
  static readonly formAssociated: boolean;
8
- private readonly __internals;
9
+ protected readonly _internals: ElementInternalsController;
9
10
  protected readonly _formValue: unknown;
10
11
  protected _pristine: boolean;
11
12
  protected _disabled: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/common/mixins/forms/types.ts"],"names":[],"mappings":"AAuLA,MAAM,CAAC,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AAChE,MAAM,CAAC,MAAM,kBAAkB,GAAG,yBAAyB,CAAC","sourcesContent":["import type { LitElement } from 'lit';\nimport type { ElementInternalsController } from '../../controllers/internals.js';\nimport type { Validator } from '../../validators.js';\n\nexport type FormRestoreMode = 'autocomplete' | 'restore';\nexport type FormValueType = string | File | FormData | null;\nexport type IgcFormControl = LitElement &\n (FormAssociatedElementInterface | FormAssociatedCheckboxElementInterface);\n\ndeclare class BaseFormAssociatedElement {\n public static readonly formAssociated: boolean;\n\n //#region Properties\n\n private readonly __internals: ElementInternalsController;\n protected readonly _formValue: unknown;\n\n protected _pristine: boolean;\n protected _disabled: boolean;\n protected _invalid: boolean;\n\n protected get __validators(): Validator[];\n\n /**\n * The disabled state of the component.\n * @attr\n * @default false\n */\n public disabled: boolean;\n\n /**\n * Sets the control into invalid state (visual state only).\n * @attr\n * @default false\n */\n public invalid: boolean;\n\n /**\n * The name attribute of the control.\n * @attr\n */\n public name: string;\n\n /** Returns the HTMLFormElement associated with this element. */\n public get form(): HTMLFormElement | null;\n\n /**\n * Returns a ValidityState object which represents the different validity states\n * the element can be in, with respect to constraint validation.\n */\n public get validity(): ValidityState;\n\n /** A string containing the validation message of this element. */\n public get validationMessage(): string;\n\n /**\n * A boolean value which returns true if the element is a submittable element\n * that is a candidate for constraint validation.\n */\n public get willValidate(): boolean;\n\n //#endregion\n\n //#region Methods\n\n /**\n * Default implementation for handling the `Enter` key press on the component.\n * Checks if the component is inside a form and if so, submits it.\n */\n protected _handleEnterKeydown(event: KeyboardEvent): void;\n\n /**\n * Sets the **touched** state of the component and invokes {@link BaseFormAssociatedElement._validate | `_validate()`} method.\n *\n * As the naming of the method suggests, this should be invoked either on **blur** or **focusout**, depending\n * on the DOM structure and how focus state is managed by the component.\n */\n protected _handleBlur(): void;\n\n /**\n * Sets the **touched** state of the component and **DOES NOT** invoke {@link BaseFormAssociatedElement._validate | `_validate()`} method.\n *\n * This should be called whenever a user interaction triggers a response, usually an event, from the component in\n * regards to its value.\n */\n protected _setTouchedState(): void;\n\n /**\n * Sets the default value of the component.\n * Called in `attributeChangedCallback`(i.e. when the `value` attribute of the control is set).\n */\n protected _setDefaultValue(current: string | null): void;\n\n /**\n * Called when the associated parent form is reset.\n */\n protected _restoreDefaultValue(): void;\n\n /**\n * Executes the component validators and updates the internal validity state.\n */\n protected _validate(message?: string): void;\n\n /**\n * Sets the component's submission value and state.\n */\n protected _setFormValue(value: FormValueType, state?: FormValueType): void;\n\n /**\n * Called by the browser when it associates/disassociates the component with/from a given form element.\n * Receives the form element as a parameter.\n *\n * @remarks\n * This is not implemented currently.\n */\n protected formAssociatedCallback(form: HTMLFormElement): void;\n\n /**\n * Called whenever the component or a parent `fieldset` elements are disabled.\n * Receives the current disabled state.\n */\n protected formDisabledCallback(state: boolean): void;\n\n /**\n * Called when the form is reset.\n * Resets the component value/checked state to the default one, internal state and validation.\n *\n * @remarks\n * The default implementation calls {@link BaseFormAssociatedElement._restoreDefaultValue | `_restoreDefaultValue`}.\n * If additional customization is needed, it is better to override that method instead of this callback.\n */\n protected formResetCallback(): void;\n\n /**\n * Called when the browser attempts to automatically fill out the component.\n *\n * @remarks\n * This is not implemented currently.\n */\n protected formStateRestoreCallback(\n state: FormValueType,\n mode: FormRestoreMode\n ): void;\n\n /** Checks for validity of the control and emits the invalid event if it invalid. */\n public checkValidity(): boolean;\n\n /** Checks for validity of the control and shows the browser message if it invalid. */\n public reportValidity(): boolean;\n\n /**\n * Sets a custom validation message for the control.\n * As long as `message` is not empty, the control is considered invalid.\n */\n public setCustomValidity(message: string): void;\n\n //#endregion\n}\n\nexport declare class FormAssociatedElementInterface extends BaseFormAssociatedElement {\n /** The initial value of the component. */\n public set defaultValue(value: unknown);\n public get defaultValue(): unknown;\n}\n\nexport declare class FormAssociatedCheckboxElementInterface extends BaseFormAssociatedElement {\n /** The initial checked state of the component. */\n public set defaultChecked(value: boolean);\n public get defaultChecked(): boolean;\n}\n\nexport declare class FormRequiredInterface {\n protected _required: boolean;\n\n /**\n * When set, makes the component a required field for validation.\n * @attr\n * @default false\n */\n public set required(value: boolean);\n public get required(): boolean;\n}\n\nexport const InternalInvalidEvent = 'igc-form-internal-invalid';\nexport const InternalResetEvent = 'igc-form-internal-reset';\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/common/mixins/forms/types.ts"],"names":[],"mappings":"AAuLA,MAAM,CAAC,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AAChE,MAAM,CAAC,MAAM,kBAAkB,GAAG,yBAAyB,CAAC","sourcesContent":["import type { LitElement } from 'lit';\nimport type { ElementInternalsController } from '../../controllers/internals.js';\nimport type { Validator } from '../../validators.js';\n\nexport type FormRestoreMode = 'autocomplete' | 'restore';\nexport type FormValueType = string | File | FormData | null;\nexport type IgcFormControl = LitElement &\n (FormAssociatedElementInterface | FormAssociatedCheckboxElementInterface);\n\ndeclare class BaseFormAssociatedElement {\n public static readonly formAssociated: boolean;\n\n //#region Properties\n\n protected readonly _internals: ElementInternalsController;\n protected readonly _formValue: unknown;\n\n protected _pristine: boolean;\n protected _disabled: boolean;\n protected _invalid: boolean;\n\n protected get __validators(): Validator[];\n\n /**\n * The disabled state of the component.\n * @attr\n * @default false\n */\n public disabled: boolean;\n\n /**\n * Sets the control into invalid state (visual state only).\n * @attr\n * @default false\n */\n public invalid: boolean;\n\n /**\n * The name attribute of the control.\n * @attr\n */\n public name: string;\n\n /** Returns the HTMLFormElement associated with this element. */\n public get form(): HTMLFormElement | null;\n\n /**\n * Returns a ValidityState object which represents the different validity states\n * the element can be in, with respect to constraint validation.\n */\n public get validity(): ValidityState;\n\n /** A string containing the validation message of this element. */\n public get validationMessage(): string;\n\n /**\n * A boolean value which returns true if the element is a submittable element\n * that is a candidate for constraint validation.\n */\n public get willValidate(): boolean;\n\n //#endregion\n\n //#region Methods\n\n /**\n * Default implementation for handling the `Enter` key press on the component.\n * Checks if the component is inside a form and if so, submits it.\n */\n protected _handleEnterKeydown(event: KeyboardEvent): void;\n\n /**\n * Sets the **touched** state of the component and invokes {@link BaseFormAssociatedElement._validate | `_validate()`} method.\n *\n * As the naming of the method suggests, this should be invoked either on **blur** or **focusout**, depending\n * on the DOM structure and how focus state is managed by the component.\n */\n protected _handleBlur(): void;\n\n /**\n * Sets the **touched** state of the component and **DOES NOT** invoke {@link BaseFormAssociatedElement._validate | `_validate()`} method.\n *\n * This should be called whenever a user interaction triggers a response, usually an event, from the component in\n * regards to its value.\n */\n protected _setTouchedState(): void;\n\n /**\n * Sets the default value of the component.\n * Called in `attributeChangedCallback`(i.e. when the `value` attribute of the control is set).\n */\n protected _setDefaultValue(current: string | null): void;\n\n /**\n * Called when the associated parent form is reset.\n */\n protected _restoreDefaultValue(): void;\n\n /**\n * Executes the component validators and updates the internal validity state.\n */\n protected _validate(message?: string): void;\n\n /**\n * Sets the component's submission value and state.\n */\n protected _setFormValue(value: FormValueType, state?: FormValueType): void;\n\n /**\n * Called by the browser when it associates/disassociates the component with/from a given form element.\n * Receives the form element as a parameter.\n *\n * @remarks\n * This is not implemented currently.\n */\n protected formAssociatedCallback(form: HTMLFormElement): void;\n\n /**\n * Called whenever the component or a parent `fieldset` elements are disabled.\n * Receives the current disabled state.\n */\n protected formDisabledCallback(state: boolean): void;\n\n /**\n * Called when the form is reset.\n * Resets the component value/checked state to the default one, internal state and validation.\n *\n * @remarks\n * The default implementation calls {@link BaseFormAssociatedElement._restoreDefaultValue | `_restoreDefaultValue`}.\n * If additional customization is needed, it is better to override that method instead of this callback.\n */\n protected formResetCallback(): void;\n\n /**\n * Called when the browser attempts to automatically fill out the component.\n *\n * @remarks\n * This is not implemented currently.\n */\n protected formStateRestoreCallback(\n state: FormValueType,\n mode: FormRestoreMode\n ): void;\n\n /** Checks for validity of the control and emits the invalid event if it invalid. */\n public checkValidity(): boolean;\n\n /** Checks for validity of the control and shows the browser message if it invalid. */\n public reportValidity(): boolean;\n\n /**\n * Sets a custom validation message for the control.\n * As long as `message` is not empty, the control is considered invalid.\n */\n public setCustomValidity(message: string): void;\n\n //#endregion\n}\n\nexport declare class FormAssociatedElementInterface extends BaseFormAssociatedElement {\n /** The initial value of the component. */\n public set defaultValue(value: unknown);\n public get defaultValue(): unknown;\n}\n\nexport declare class FormAssociatedCheckboxElementInterface extends BaseFormAssociatedElement {\n /** The initial checked state of the component. */\n public set defaultChecked(value: boolean);\n public get defaultChecked(): boolean;\n}\n\nexport declare class FormRequiredInterface {\n protected _required: boolean;\n\n /**\n * When set, makes the component a required field for validation.\n * @attr\n * @default false\n */\n public set required(value: boolean);\n public get required(): boolean;\n}\n\nexport const InternalInvalidEvent = 'igc-form-internal-invalid';\nexport const InternalResetEvent = 'igc-form-internal-reset';\n"]}
@@ -18,6 +18,8 @@ export interface MaskedInputOptions {
18
18
  tabindex?: number;
19
19
  /** When provided, sets the `aria-describedby` attribute. */
20
20
  ariaDescribedBy?: string;
21
+ /** When provided, sets the `aria-labelledby` attribute using the provided elements. */
22
+ ariaLabelledByElements?: ReadonlyArray<Element> | null;
21
23
  onInput: (event: InputEvent) => void;
22
24
  onFocus: (event: FocusEvent) => void;
23
25
  onBlur: (event: FocusEvent) => void;
@@ -16,8 +16,9 @@ export function renderMaskedNativeInput(opts) {
16
16
  ?disabled=${opts.disabled}
17
17
  ?autofocus=${opts.autofocus}
18
18
  inputmode=${ifDefined(opts.inputMode)}
19
- tabindex=${bindIf(opts.tabindex !== undefined, opts.tabindex)}
19
+ tabindex=${bindIf(opts.tabindex != null, opts.tabindex)}
20
20
  aria-describedby=${bindIf(!!opts.ariaDescribedBy, opts.ariaDescribedBy)}
21
+ .ariaLabelledByElements=${opts.ariaLabelledByElements ?? null}
21
22
  @input=${opts.onInput}
22
23
  @focus=${opts.onFocus}
23
24
  @blur=${opts.onBlur}
@@ -1 +1 @@
1
- {"version":3,"file":"masked-input.js","sourceRoot":"","sources":["../../../../src/components/common/templates/masked-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AA4CpC,MAAM,UAAU,uBAAuB,CACrC,IAAwB;IAExB,OAAO,IAAI,CAAA;;WAEF,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;;aAEhB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;aACvB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;eAClB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;qBACV,IAAI,CAAC,WAAW;kBACnB,IAAI,CAAC,QAAQ;kBACb,IAAI,CAAC,QAAQ;mBACZ,IAAI,CAAC,SAAS;kBACf,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;iBAC1B,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC;yBAC1C,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,eAAe,CAAC;eAC9D,IAAI,CAAC,OAAO;eACZ,IAAI,CAAC,OAAO;cACb,IAAI,CAAC,MAAM;eACV,IAAI,CAAC,OAAO;iBACV,IAAI,CAAC,kBAAkB;aAC3B,IAAI,CAAC,kBAAkB;mBACjB,IAAI,CAAC,kBAAkB;0BAChB,IAAI,CAAC,kBAAkB;wBACzB,IAAI,CAAC,gBAAgB;gBAC7B,IAAI,CAAC,QAAQ;eACd,IAAI,CAAC,OAAO;mBACR,IAAI,CAAC,WAAW;mBAChB,IAAI,CAAC,WAAW;;GAEhC,CAAC;AACJ,CAAC","sourcesContent":["import { html, type TemplateResult } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { partMap } from '../part-map.js';\nimport { bindIf } from '../util.js';\n\nexport interface MaskedInputOptions {\n /** Optional id for the native input element. */\n id?: string;\n /** Resolved part-name map applied to the input. */\n partNames: Record<string, boolean>;\n /** The form-associated name attribute. */\n name?: string;\n /** Current value to render through `live()`. */\n value: string;\n /** Pre-resolved placeholder text. Caller decides empty-string semantics. */\n placeholder: string;\n readOnly: boolean;\n disabled: boolean;\n autofocus?: boolean;\n inputMode?: string;\n /** When provided, sets the `tabindex` attribute. */\n tabindex?: number;\n /** When provided, sets the `aria-describedby` attribute. */\n ariaDescribedBy?: string;\n\n // Required mask handlers\n onInput: (event: InputEvent) => void;\n onFocus: (event: FocusEvent) => void;\n onBlur: (event: FocusEvent) => void;\n onClick: () => void;\n /** Wired to `keydown`, `cut`, and `dragstart` to capture the current selection. */\n onSetMaskSelection: (event: Event) => void;\n onCompositionStart: () => void;\n onCompositionEnd: (event: CompositionEvent) => void;\n\n // Optional handlers\n onChange?: () => void;\n onWheel?: (event: WheelEvent) => void;\n onDragEnter?: () => void;\n onDragLeave?: () => void;\n}\n\n/**\n * Renders the native `<input>` element shared by mask-driven components\n * (`igc-mask-input`, `igc-date-time-input`, `igc-date-range-input`).\n * Centralizes mask event wiring so leaves only describe their extras.\n */\nexport function renderMaskedNativeInput(\n opts: MaskedInputOptions\n): TemplateResult {\n return html`\n <input\n id=${ifDefined(opts.id)}\n type=\"text\"\n part=${partMap(opts.partNames)}\n name=${ifDefined(opts.name)}\n .value=${live(opts.value)}\n .placeholder=${opts.placeholder}\n ?readonly=${opts.readOnly}\n ?disabled=${opts.disabled}\n ?autofocus=${opts.autofocus}\n inputmode=${ifDefined(opts.inputMode)}\n tabindex=${bindIf(opts.tabindex !== undefined, opts.tabindex)}\n aria-describedby=${bindIf(!!opts.ariaDescribedBy, opts.ariaDescribedBy)}\n @input=${opts.onInput}\n @focus=${opts.onFocus}\n @blur=${opts.onBlur}\n @click=${opts.onClick}\n @keydown=${opts.onSetMaskSelection}\n @cut=${opts.onSetMaskSelection}\n @dragstart=${opts.onSetMaskSelection}\n @compositionstart=${opts.onCompositionStart}\n @compositionend=${opts.onCompositionEnd}\n @change=${opts.onChange}\n @wheel=${opts.onWheel}\n @dragenter=${opts.onDragEnter}\n @dragleave=${opts.onDragLeave}\n />\n `;\n}\n"]}
1
+ {"version":3,"file":"masked-input.js","sourceRoot":"","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AAC","sourcesContent":["import { html, type TemplateResult } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { partMap } from '../part-map.js';\nimport { bindIf } from '../util.js';\n\nexport interface MaskedInputOptions {\n /** Optional id for the native input element. */\n id?: string;\n /** Resolved part-name map applied to the input. */\n partNames: Record<string, boolean>;\n /** The form-associated name attribute. */\n name?: string;\n /** Current value to render through `live()`. */\n value: string;\n /** Pre-resolved placeholder text. Caller decides empty-string semantics. */\n placeholder: string;\n readOnly: boolean;\n disabled: boolean;\n autofocus?: boolean;\n inputMode?: string;\n /** When provided, sets the `tabindex` attribute. */\n tabindex?: number;\n /** When provided, sets the `aria-describedby` attribute. */\n ariaDescribedBy?: string;\n /** When provided, sets the `aria-labelledby` attribute using the provided elements. */\n ariaLabelledByElements?: ReadonlyArray<Element> | null;\n\n // Required mask handlers\n onInput: (event: InputEvent) => void;\n onFocus: (event: FocusEvent) => void;\n onBlur: (event: FocusEvent) => void;\n onClick: () => void;\n /** Wired to `keydown`, `cut`, and `dragstart` to capture the current selection. */\n onSetMaskSelection: (event: Event) => void;\n onCompositionStart: () => void;\n onCompositionEnd: (event: CompositionEvent) => void;\n\n // Optional handlers\n onChange?: () => void;\n onWheel?: (event: WheelEvent) => void;\n onDragEnter?: () => void;\n onDragLeave?: () => void;\n}\n\n/**\n * Renders the native `<input>` element shared by mask-driven components\n * (`igc-mask-input`, `igc-date-time-input`, `igc-date-range-input`).\n * Centralizes mask event wiring so leaves only describe their extras.\n */\nexport function renderMaskedNativeInput(\n opts: MaskedInputOptions\n): TemplateResult {\n return html`\n <input\n id=${ifDefined(opts.id)}\n type=\"text\"\n part=${partMap(opts.partNames)}\n name=${ifDefined(opts.name)}\n .value=${live(opts.value)}\n .placeholder=${opts.placeholder}\n ?readonly=${opts.readOnly}\n ?disabled=${opts.disabled}\n ?autofocus=${opts.autofocus}\n inputmode=${ifDefined(opts.inputMode)}\n tabindex=${bindIf(opts.tabindex != null, opts.tabindex)}\n aria-describedby=${bindIf(!!opts.ariaDescribedBy, opts.ariaDescribedBy)}\n .ariaLabelledByElements=${opts.ariaLabelledByElements ?? null}\n @input=${opts.onInput}\n @focus=${opts.onFocus}\n @blur=${opts.onBlur}\n @click=${opts.onClick}\n @keydown=${opts.onSetMaskSelection}\n @cut=${opts.onSetMaskSelection}\n @dragstart=${opts.onSetMaskSelection}\n @compositionstart=${opts.onCompositionStart}\n @compositionend=${opts.onCompositionEnd}\n @change=${opts.onChange}\n @wheel=${opts.onWheel}\n @dragenter=${opts.onDragEnter}\n @dragleave=${opts.onDragLeave}\n />\n `;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { type ICalendarResourceStrings, type IDatePickerResourceStrings } from 'igniteui-i18n-core';
2
- import { type TemplateResult } from 'lit';
2
+ import { type PropertyValues, type TemplateResult } from 'lit';
3
3
  import type { CalendarHeaderOrientation, DateRangeDescriptor, WeekDays } from '../calendar/types.js';
4
4
  import type { IgcCalendarResourceStrings } from '../common/i18n/EN/calendar.resources.js';
5
5
  import { IgcComboBoxBaseLikeComponent } from '../common/mixins/combo-box.js';
@@ -246,6 +246,7 @@ export default class IgcDatePickerComponent extends IgcDatePickerComponent_base
246
246
  weekStart: WeekDays;
247
247
  protected _openChange(): void;
248
248
  constructor();
249
+ protected updated(changedProperties: PropertyValues): void;
249
250
  private _setDateConstraints;
250
251
  private _shouldCloseCalendarDropdown;
251
252
  protected _onEscapeKey(): Promise<void>;
@@ -161,6 +161,12 @@ let IgcDatePickerComponent = class IgcDatePickerComponent extends FormAssociated
161
161
  .set([altKey, arrowUp], this._onEscapeKey)
162
162
  .set(escapeKey, this._onEscapeKey);
163
163
  }
164
+ updated(changedProperties) {
165
+ super.updated(changedProperties);
166
+ if (this._input) {
167
+ this._input._labelElements = this._internals.labels;
168
+ }
169
+ }
164
170
  _setDateConstraints() {
165
171
  this._dateConstraints = createDateConstraints(this.min, this.max, this.disabledDates);
166
172
  }