A platform for community discussion. Free, open, simple.
DEV: Type strict-narrowed members in ui-kit and select-kit (#44654)
Sérgio Saquetim3442344a2b4e
diff --git a/frontend/discourse/app/ui-kit/d-calendar-date-time-input.gjs b/frontend/discourse/app/ui-kit/d-calendar-date-time-input.gjsindex 2a2c6546e1d..bb93c782564 100644--- a/frontend/discourse/app/ui-kit/d-calendar-date-time-input.gjs+++ b/frontend/discourse/app/ui-kit/d-calendar-date-time-input.gjs@@ -14,6 +14,8 @@ export default class DCalendarDateTimeInput extends Component {_timeFormat = this.args.timeFormat || "HH:mm:ss";_dateFormat = this.args.dateFormat || "YYYY-MM-DD";_dateTimeFormat = this.args.dateTimeFormat || "YYYY-MM-DD HH:mm:ss";++ /** @type {{ setDate: (date: Date | string | null, preventOnSelect?: boolean) => void, setMinDate: (date: Date | null) => void, destroy: () => void } | null} */_picker = null;@tracked _time;diff --git a/frontend/discourse/app/ui-kit/d-cook-text.gjs b/frontend/discourse/app/ui-kit/d-cook-text.gjsindex 7fc2074fd5c..a31f7cd956e 100644--- a/frontend/discourse/app/ui-kit/d-cook-text.gjs+++ b/frontend/discourse/app/ui-kit/d-cook-text.gjs@@ -12,6 +12,7 @@ import { cook } from "discourse/lib/text";export default class DCookText extends Component {@service siteSettings;+ /** @type {import("@ember/template").TrustedHTML | null} */@tracked cooked = null;constructor(owner, args) {diff --git a/frontend/discourse/app/ui-kit/d-date-input.gjs b/frontend/discourse/app/ui-kit/d-date-input.gjsindex 834a28e3d6c..6534df765a8 100644--- a/frontend/discourse/app/ui-kit/d-date-input.gjs+++ b/frontend/discourse/app/ui-kit/d-date-input.gjs@@ -9,6 +9,14 @@ import { on as onEvent } from "@ember-decorators/object";import { Promise } from "rsvp";import { i18n } from "discourse-i18n";+/**+ * @typedef {Object} DateInputPicker+ * @property {(date: import("moment").Moment | Date | string | null, preventOnSelect?: boolean) => void} setDate+ * @property {(date: import("moment").Moment | Date | string | null | undefined) => void} setMinDate+ * @property {() => void} hide+ * @property {() => void} destroy+ */+function isInputDateSupported() {const input = document.createElement("input");const value = "a";@@ -19,8 +27,11 @@ function isInputDateSupported() {@classNames("d-date-input")export default class DDateInput extends Component {+ /** @type {import("moment").Moment | Date | string | null | undefined} */date = null;useNativePicker = isInputDateSupported();++ /** @type {DateInputPicker | null} */_picker = null;@computed("_placeholder")diff --git a/frontend/discourse/app/ui-kit/d-date-picker.gjs b/frontend/discourse/app/ui-kit/d-date-picker.gjsindex c42fa9a8369..012ad7feb4b 100644--- a/frontend/discourse/app/ui-kit/d-date-picker.gjs+++ b/frontend/discourse/app/ui-kit/d-date-picker.gjs@@ -11,9 +11,16 @@ const DATE_FORMAT = "YYYY-MM-DD";@classNames("date-picker-wrapper")export default class DDatePicker extends Component {+ /** @type {import("moment").Moment | Date | string | null | undefined} */value = null;++ /** @type {Date | null | undefined} */minDate = null;++ /** @type {Date | null | undefined} */maxDate = null;++ /** @type {{ setDate: (date: Date | string | null, preventOnSelect?: boolean) => void, destroy: () => void } | (HTMLInputElement & { hide: () => void, destroy: () => void }) | null} */_picker = null;@computed("_placeholder")@@ -104,6 +111,7 @@ export default class DDatePicker extends Component {}}+ /** @returns {{ defaultDate?: Date | string | null, setDefaultDate?: boolean, minDate?: Date | null, maxDate?: Date | null } | null} */_opts() {return null;}diff --git a/frontend/discourse/app/ui-kit/d-decorated-html.gjs b/frontend/discourse/app/ui-kit/d-decorated-html.gjsindex 44235e53851..574138f46d5 100644--- a/frontend/discourse/app/ui-kit/d-decorated-html.gjs+++ b/frontend/discourse/app/ui-kit/d-decorated-html.gjs@@ -69,7 +69,7 @@ export function registerHtmlDecorator(decorator, type) {* Applies registered HTML decorators to a DOM element and returns their cleanup functions.** @param {HTMLElement} element - The DOM element to apply decorators to- * @param {Object} helper - Helper object passed to each decorator. Use NULL_HELPER for contexts without a model.+ * @param {DecorateHtmlHelper | typeof NULL_HELPER} helper - Helper object passed to each decorator. Use NULL_HELPER for contexts without a model.* @param {Symbol|string} [type=NON_STREAM_HTML_DECORATOR] - The type of decorators to apply.* @returns {Function[]} Array of cleanup functions from decorators that returned them.*/@@ -323,10 +323,11 @@ class DecorateHtmlHelper {* Renders a Glimmer component into a specified target HTML element with provided data.* Handles deprecation warnings if invalid parameters are passed.*+ * @template T* @param {Element} targetElement The HTML element where the Glimmer component should be rendered. Must be a valid DOM element.- * @param {Object} component The Glimmer component object to render. Should not have a name of "factory" to avoid deprecation warnings.- * @param {Object} data The data to be passed to the Glimmer component for rendering.- * @param {Object} [opts={}] Additional options for rendering. Supports an `append` boolean property that defaults to `true` to determine if the content should be appended to the target element.+ * @param {import("@glint/template").ComponentLike<{ Args: { data: T } }>} component The Glimmer component object to render. Should not have a name of "factory" to avoid deprecation warnings.+ * @param {T} [data] The data to be passed to the Glimmer component as `@data`.+ * @param {{ append?: boolean }} [opts={}] Additional options for rendering. Supports an `append` boolean property that defaults to `true` to determine if the content should be appended to the target element.* @return {void}*/renderGlimmer(targetElement, component, data, opts = {}) {diff --git a/frontend/discourse/app/ui-kit/d-editor.gjs b/frontend/discourse/app/ui-kit/d-editor.gjsindex 6d4506056d1..b4d2a24415f 100644--- a/frontend/discourse/app/ui-kit/d-editor.gjs+++ b/frontend/discourse/app/ui-kit/d-editor.gjs@@ -251,8 +251,8 @@ export default class DEditor extends Component {* @property {function} addText - Adds text* @property {function} applyList - Applies a list format* @property {*} selected - The current selection- * @property {Object} commands - Available commands- * @property {Object} state - Current editor state (inWrap, inBold, etc.)+ * @property {import("discourse/lib/composer/text-manipulation").TextManipulation["commands"]} commands - Available commands+ * @property {import("discourse/lib/composer/text-manipulation").TextManipulation["state"]} state - Current editor state (inWrap, inBold, etc.)*//**diff --git a/frontend/discourse/app/ui-kit/d-filter-controls.gjs b/frontend/discourse/app/ui-kit/d-filter-controls.gjsindex 843ce21cb90..67c9ec5ce68 100644--- a/frontend/discourse/app/ui-kit/d-filter-controls.gjs+++ b/frontend/discourse/app/ui-kit/d-filter-controls.gjs@@ -284,9 +284,9 @@ export default class DFilterControls extends Component {* Allows searchable props in the format user.name, this function gets the* nested value based on a dot-separated path.*- * @param {Object} obj - The object to get value from+ * @param {object} obj - The object to get value from* @param {String} path - The property path (e.g. "user.name")- * @returns {*} The value at the path+ * @returns {unknown} The value at the path*/getNestedValue(obj, path) {return path.split(".").reduce((current, key) => current?.[key], obj);diff --git a/frontend/discourse/app/ui-kit/d-future-date-input.gjs b/frontend/discourse/app/ui-kit/d-future-date-input.gjsindex e4fa09ed71e..fa30e62209d 100644--- a/frontend/discourse/app/ui-kit/d-future-date-input.gjs+++ b/frontend/discourse/app/ui-kit/d-future-date-input.gjs@@ -22,14 +22,26 @@ import { i18n } from "discourse-i18n";@tagName("")export default class DFutureDateInput extends Component {+ /** @type {string | null | undefined} */selection = null;includeDateTime = true;+ /** @type {string | null} */displayLabel = null;++ /** @type {string | null | undefined} */labelClasses = null;++ /** @type {string | null | undefined} */userTimezone = null;++ /** @type {((value: string | null) => void) | null | undefined} */onChangeInput = null;++ /** @type {string | null} */_date = null;++ /** @type {string | null} */_time = null;init() {diff --git a/frontend/discourse/app/ui-kit/d-interpolated-translation.gjs b/frontend/discourse/app/ui-kit/d-interpolated-translation.gjsindex a930ad9db52..60cd655561a 100644--- a/frontend/discourse/app/ui-kit/d-interpolated-translation.gjs+++ b/frontend/discourse/app/ui-kit/d-interpolated-translation.gjs@@ -6,6 +6,15 @@ import { isProduction } from "discourse/lib/environment";import dUniqueId from "discourse/ui-kit/helpers/d-unique-id";import I18n, { i18n, I18nMissingInterpolationArgument } from "discourse-i18n";+/**+ * @typedef {Object} TranslationPlaceholders+ * @property {Map<string, string[]>} appearance+ * @property {Map<string, HTMLSpanElement[]>} elements+ * @property {Map<string, string>} keys+ * @property {string[]} rendered+ * @property {(string | HTMLSpanElement)[]} parts+ */+/*** Provides the ability to interpolate both strings and components into translatable strings.* This component allows for complex i18n scenarios where you need to embed interactive@@ -51,7 +60,7 @@ export default class DInterpolatedTranslation extends Component {/*** Processes the translation string and returns all of the rendering data.*- * @returns {Object}+ * @returns {TranslationPlaceholders}*/get textAndPlaceholders() {const optionsArg = this.args.options || {};@@ -147,7 +156,7 @@ export default class DInterpolatedTranslation extends Component {/*** Checks for any mismatches between the placeholders expected, and those provided.*- * @param {Object} info The rendering object returned by textAndPlaceholders().+ * @param {TranslationPlaceholders} info The rendering object returned by textAndPlaceholders().*/@actioncheckPlaceholders(info) {diff --git a/frontend/discourse/app/ui-kit/d-multi-select.gjs b/frontend/discourse/app/ui-kit/d-multi-select.gjsindex b88eec460be..9b2783a55f9 100644--- a/frontend/discourse/app/ui-kit/d-multi-select.gjs+++ b/frontend/discourse/app/ui-kit/d-multi-select.gjs@@ -37,6 +37,7 @@ class Skeleton extends Component {export default class DMultiSelect extends Component {@tracked searchTerm = "";+ /** @type {object | null | undefined} */@tracked preselectedItem = null;compareKey = "id";diff --git a/frontend/discourse/app/ui-kit/d-pick-files-button.gjs b/frontend/discourse/app/ui-kit/d-pick-files-button.gjsindex 864280e9165..85015ed99d7 100644--- a/frontend/discourse/app/ui-kit/d-pick-files-button.gjs+++ b/frontend/discourse/app/ui-kit/d-pick-files-button.gjs@@ -28,9 +28,14 @@ import { i18n } from "discourse-i18n";export default class DPickFilesButton extends Component {@service dialog;+ /** @type {string | null | undefined} */fileInputId = null;++ /** @type {string | null | undefined} */fileInputClass = null;fileInputDisabled = false;++ /** @type {string | string[] | null | undefined} */acceptedFormatsOverride = null;allowMultiple = false;showButton = false;diff --git a/frontend/discourse/app/ui-kit/d-popup-input-tip.gjs b/frontend/discourse/app/ui-kit/d-popup-input-tip.gjsindex 9f7d6132ffb..27b03ba3147 100644--- a/frontend/discourse/app/ui-kit/d-popup-input-tip.gjs+++ b/frontend/discourse/app/ui-kit/d-popup-input-tip.gjs@@ -17,6 +17,7 @@ import dIcon from "discourse/ui-kit/helpers/d-icon";export default class DPopupInputTip extends Component {@service composer;+ /** @type {import("@ember/template").TrustedHTML | null} */tipReason = null;tabindex = "0";diff --git a/frontend/discourse/app/ui-kit/d-text-field.js b/frontend/discourse/app/ui-kit/d-text-field.jsindex 2496db9c830..d6f63ba085e 100644--- a/frontend/discourse/app/ui-kit/d-text-field.js+++ b/frontend/discourse/app/ui-kit/d-text-field.js@@ -20,7 +20,10 @@ const DEBOUNCE_MS = 500;"resolvedPlaceholder:placeholder")export default class DTextField extends TextField {+ /** @type {string | number | null | undefined} */_prevValue = null;++ /** @type {import("@ember/runloop").Timer | null} */_timer = null;@computed("siteSettings.support_mixed_text_direction", "value")diff --git a/frontend/discourse/app/ui-kit/d-textarea.gjs b/frontend/discourse/app/ui-kit/d-textarea.gjsindex 63548178567..dcdf68d80cd 100644--- a/frontend/discourse/app/ui-kit/d-textarea.gjs+++ b/frontend/discourse/app/ui-kit/d-textarea.gjs@@ -65,13 +65,17 @@ const DTextarea = Component.extend({"title","aria-label",],+ /** @type {number | string | null | undefined} */rows: null,+ /** @type {number | string | null | undefined} */cols: null,value: "",+ /** @type {string | null | undefined} */placeholder: null,disabled: false,+ /** @type {number | string | null | undefined} */maxlength: null,init() {diff --git a/frontend/discourse/app/ui-kit/d-time-input.gjs b/frontend/discourse/app/ui-kit/d-time-input.gjsindex 2add4cb9bf2..3288e55f263 100644--- a/frontend/discourse/app/ui-kit/d-time-input.gjs+++ b/frontend/discourse/app/ui-kit/d-time-input.gjs@@ -54,8 +54,13 @@ function convertMinutesToDurationString(n) {@tagName("")export default class DTimeInput extends Component {+ /** @type {number | string | null | undefined} */hours = null;++ /** @type {number | string | null | undefined} */minutes = null;++ /** @type {import("moment").Moment | null | undefined} */relativeDate = null;@computed("relativeDate", "date")diff --git a/frontend/discourse/app/ui-kit/d-time-shortcut-picker.gjs b/frontend/discourse/app/ui-kit/d-time-shortcut-picker.gjsindex c0ab8c2958e..cd20d404c25 100644--- a/frontend/discourse/app/ui-kit/d-time-shortcut-picker.gjs+++ b/frontend/discourse/app/ui-kit/d-time-shortcut-picker.gjs@@ -46,26 +46,48 @@ const BINDINGS = {@tagName("")export default class DTimeShortcutPicker extends Component {+ /** @type {string | null | undefined} */userTimezone = null;+ /** @type {((type: string, datetime: import("moment").Moment | null | undefined) => void) | null | undefined} */onTimeSelected = null;+ /** @type {string | null} */selectedShortcut = null;selectedTime = null;selectedDate = null;++ /** @type {import("moment").Moment | null | undefined} */selectedDatetime = null;++ /** @type {import("moment").Moment | Date | string | null | undefined} */prefilledDatetime = null;++ /** @type {number | null | undefined} */selectedDurationMins = null;+ /** @type {string[] | null | undefined} */hiddenOptions = null;++ /** @type {unknown[] | null} */customOptions = null;+ /** @type {string | null} */lastCustomDate = null;++ /** @type {string | null} */lastCustomTime = null;++ /** @type {import("moment").Moment | null} */parsedLastCustomDatetime = null;++ /** @type {string | null} */customDate = null;++ /** @type {string | null} */customTime = null;+ /** @type {{ bind: (keys: string | string[], callback: (event: KeyboardEvent, combo: string) => unknown) => unknown, unbind: (keys: string | string[]) => unknown } | null} */_itsatrap = null;@computed("selectedShortcut")@@ -78,6 +100,7 @@ export default class DTimeShortcutPicker extends Component {return this.selectedShortcut === TIME_SHORTCUT_TYPES.RELATIVE;}+ /** @returns {string | null} */@computed("customDate", "customTime")get customDatetimeFilled() {return this.customDate && this.customTime;diff --git a/frontend/discourse/app/ui-kit/helpers/d-category-link.js b/frontend/discourse/app/ui-kit/helpers/d-category-link.jsindex f4a271b3c54..f6d37295afc 100644--- a/frontend/discourse/app/ui-kit/helpers/d-category-link.js+++ b/frontend/discourse/app/ui-kit/helpers/d-category-link.js@@ -11,6 +11,38 @@ import Category from "discourse/models/category";import dEmoji from "discourse/ui-kit/helpers/d-emoji";import { i18n } from "discourse-i18n";+/**+ * @typedef {Object} CategoryBadgeCategory+ * @property {number | string} [id]+ * @property {string} [name]+ * @property {string | null} [slug]+ * @property {string | null} [color]+ * @property {string | null} [textColor]+ * @property {string | null} [style_type]+ * @property {string | null} [icon]+ * @property {string | null} [emoji]+ * @property {boolean} [read_restricted]+ * @property {number | null} [parent_category_id]+ * @property {CategoryBadgeCategory | null} [parentCategory]+ */++/**+ * @typedef {Object} CategoryBadgeOptions+ * @property {String} [url] The url that we want the category badge to link to.+ * @property {Boolean} [allowUncategorized] If false, returns an empty string for the uncategorized category.+ * @property {boolean | "false"} [link] If false, the category badge will not be a link.+ * @property {Boolean} [hideParent] If true, parent category will be hidden in the badge.+ * @property {Boolean} [previewColor] If true, category color will be set as an inline style.+ * @property {CategoryBadgeCategory[]} [ancestors] The ancestors of the category to generate the badge for.+ * @property {String} [styleType] Badge style, either "icon", "emoji" or "square" (default).+ * @property {String} [emoji] The emoji to use for the badge (if styleType is "emoji").+ * @property {String} [icon] The icon to use for the badge (if styleType is "icon").+ * @property {string} [extraClasses] Additional wrapper classes.+ * @property {number} [topicCount] Topic count displayed after the badge.+ * @property {boolean} [hasSubcategories] Whether to display the subcategory indicator.+ * @property {boolean} [readOnly] Whether to display the read-only indicator.+ */+let _renderer = defaultCategoryLinkRenderer;export function replaceCategoryLinkRenderer(fn) {@@ -26,17 +58,9 @@ export function addExtraIconRenderer(renderer) {/**Generates category badge HTML- @param {Object} category The category to generate the badge for.- @param {Object} opts- @param {String} [opts.url] The url that we want the category badge to link to.- @param {Boolean} [opts.allowUncategorized] If false, returns an empty string for the uncategorized category.- @param {Boolean} [opts.link] If false, the category badge will not be a link.- @param {Boolean} [opts.hideParent] If true, parent category will be hidden in the badge.- @param {Boolean} [opts.previewColor] If true, category color will be set as an inline style.- @param {Array} [opts.ancestors] The ancestors of the category to generate the badge for.- @param {String} [opts.styleType] Badge style, either "icon", "emoji" or "square" (default).- @param {String} [opts.emoji] The emoji to use for the badge (if styleType is "emoji").- @param {String} [opts.icon] The icon to use for the badge (if styleType is "icon").+ @param {CategoryBadgeCategory | null} [category] The category to generate the badge for.+ @param {CategoryBadgeOptions | null} [opts]+ @returns {string}**/export function categoryBadgeHTML(category, opts) {const { site, siteSettings } = helperContext();diff --git a/frontend/discourse/app/ui-kit/modifiers/d-autocomplete.js b/frontend/discourse/app/ui-kit/modifiers/d-autocomplete.jsindex cb5136aa582..cfc88b65ade 100644--- a/frontend/discourse/app/ui-kit/modifiers/d-autocomplete.js+++ b/frontend/discourse/app/ui-kit/modifiers/d-autocomplete.js@@ -24,6 +24,27 @@ export const CANCELLED_STATUS = "__CANCELLED";export const EMOJI_ALLOWED_PRECEDING_CHARS_REGEXP =/[\s.…?,@/#!%&*;:\[\]{}=\-_()+]/;+/**+ * @template [T=unknown]+ * @typedef {Object} AutocompleteOptions+ * @property {string} [key]+ * @property {(term: string) => T[] | "skip" | "__CANCELLED" | null | undefined | PromiseLike<T[] | "skip" | "__CANCELLED" | null | undefined>} [dataSource]+ * @property {(data: { options: T[] }) => string} [template]+ * @property {unknown} [component]+ * @property {(result: T, event: Event | undefined) => string | null | undefined | PromiseLike<string | null | undefined>} [transformComplete]+ * @property {(text: string, event: Event | undefined) => void} [afterComplete]+ * @property {boolean} [debounced]+ * @property {boolean} [preserveKey]+ * @property {boolean} [autoSelectFirstSuggestion]+ * @property {(element: HTMLElement, context: { backSpace?: boolean, inCodeBlock: () => boolean | Promise<boolean>, inLink: () => boolean | Promise<boolean> }) => boolean | undefined | PromiseLike<boolean | undefined>} [triggerRule]+ * @property {(text: string, caretPosition: number) => string[] | null | undefined} [onKeyUp]+ * @property {boolean} [fixedTextareaPosition]+ * @property {number} [offset]+ * @property {boolean} [forceRefresh]+ * @property {(results: T[]) => void} [onRender]+ * @property {() => void} [onClose]+ */+/*** Class-based modifier for adding autocomplete functionality to input elements* Preserves exact CSS structure for backward compatibility@@ -47,10 +68,11 @@ export default class DAutocompleteModifier extends Modifier {/*** Static helper function to set up autocomplete on any element*- * @param {Object} owner - Ember owner+ * @template T+ * @param {import("@ember/owner").default} owner - Ember owner* @param {HTMLElement} element - The element to modify with autocomplete functionality- * @param {Object} autocompleteHandler - Handler for text operations- * @param {Object} options - Autocomplete options+ * @param {import("discourse/lib/composer/text-manipulation").AutocompleteHandler} autocompleteHandler - Handler for text operations+ * @param {AutocompleteOptions<T>} options - Autocomplete options*/static setupAutocomplete(owner, element, autocompleteHandler, options) {const modifier = new DAutocompleteModifier(owner, {@@ -75,13 +97,22 @@ export default class DAutocompleteModifier extends Modifier {@tracked results = [];@tracked selectedIndex = -1;@tracked searchTerm = "";++ /** @type {number | null} */@tracked completeStart = null;++ /** @type {number | null} */@tracked completeEnd = null;@tracked pendingSpaceSearch = false;// Internal state+ /** @type {string | null} */previousTerm = null;++ /** @type {import("@ember/runloop").Timer | null} */debouncedSearch = null;++ /** @type {HTMLElement | null} */targetElement = null;// Constantsdiff --git a/frontend/discourse/select-kit/components/category-drop.js b/frontend/discourse/select-kit/components/category-drop.jsindex 97ad36750a1..98617c68291 100644--- a/frontend/discourse/select-kit/components/category-drop.js+++ b/frontend/discourse/select-kit/components/category-drop.js@@ -48,6 +48,8 @@ export default class CategoryDrop extends ComboBoxComponent {noCategoriesLabel = i18n("categories.no_subcategories");navigateToEdit = false;editingCategory = false;++ /** @type {string | null | undefined} */editingCategoryTab = null;init() {diff --git a/frontend/discourse/select-kit/components/category-selector.js b/frontend/discourse/select-kit/components/category-selector.jsindex 0189f46e7c7..d529cfa701a 100644--- a/frontend/discourse/select-kit/components/category-selector.js+++ b/frontend/discourse/select-kit/components/category-selector.js@@ -17,7 +17,10 @@ import SelectedChoiceCategory from "./selected-choice-category.gjs";})@pluginApiIdentifiers(["category-selector"])export default class CategorySelector extends MultiSelectComponent {+ /** @type {Array<import("discourse/models/category").default | { id: number, name: string }> | null | undefined} */categories = null;++ /** @type {import("discourse/models/category").default[] | null | undefined} */blockedCategories = null;init() {diff --git a/frontend/discourse/select-kit/components/future-date-input-selector.js b/frontend/discourse/select-kit/components/future-date-input-selector.jsindex 11130c31f3b..4ce5c014277 100644--- a/frontend/discourse/select-kit/components/future-date-input-selector.js+++ b/frontend/discourse/select-kit/components/future-date-input-selector.js@@ -18,6 +18,7 @@ export const FORMAT = "YYYY-MM-DD HH:mmZ";})@pluginApiIdentifiers("future-date-input-selector")export default class FutureDateInputSelector extends ComboBoxComponent {+ /** @type {string | null | undefined} */userTimezone = null;init() {diff --git a/frontend/discourse/select-kit/components/list-setting.js b/frontend/discourse/select-kit/components/list-setting.jsindex f76581536f8..8abb249a25b 100644--- a/frontend/discourse/select-kit/components/list-setting.js+++ b/frontend/discourse/select-kit/components/list-setting.js@@ -18,10 +18,16 @@ import SelectedChoiceColor from "./selected-choice-color.js";})@pluginApiIdentifiers("list-setting")export default class ListSetting extends MultiSelectComponent {+ /** @type {(string | { id?: string | number, name?: string, value?: string | number, label?: string, color?: string })[] | null | undefined} */choices = null;++ /** @type {string | null | undefined} */nameProperty = null;++ /** @type {string | null | undefined} */valueProperty = null;+ /** @returns {ListSetting["choices"]} */@computed("choices")get content() {return this.choices;diff --git a/frontend/discourse/select-kit/components/multi-select/format-selected-content.gjs b/frontend/discourse/select-kit/components/multi-select/format-selected-content.gjsindex ab5af3d940b..8e89ea6b735 100644--- a/frontend/discourse/select-kit/components/multi-select/format-selected-content.gjs+++ b/frontend/discourse/select-kit/components/multi-select/format-selected-content.gjs@@ -8,7 +8,10 @@ import selectKitPropUtils from "discourse/select-kit/lib/select-kit-prop-utils";@tagName("")@selectKitPropUtilsexport default class FormatSelectedContent extends Component {+ /** @type {unknown} */content = null;++ /** @type {import("discourse/select-kit/components/select-kit").SelectKitState | null} */selectKit = null;@computed("content")diff --git a/frontend/discourse/select-kit/components/multiple-categories-selector.js b/frontend/discourse/select-kit/components/multiple-categories-selector.jsindex d1870956f94..cc7856dea24 100644--- a/frontend/discourse/select-kit/components/multiple-categories-selector.js+++ b/frontend/discourse/select-kit/components/multiple-categories-selector.js@@ -28,7 +28,10 @@ export const LIMITED_RESULTS_NOTICE_VALUE =})@pluginApiIdentifiers(["multiple-categories-selector"])export default class MultipleCategoriesSelector extends MultiSelectComponent {+ /** @type {import("discourse/models/category").default[] | null | undefined} */categories = null;++ /** @type {import("discourse/models/category").default[] | null | undefined} */blockedCategories = null;init() {diff --git a/frontend/discourse/select-kit/components/select-kit.js b/frontend/discourse/select-kit/components/select-kit.jsindex b60f79967b1..4695a4eb472 100644--- a/frontend/discourse/select-kit/components/select-kit.js+++ b/frontend/discourse/select-kit/components/select-kit.js@@ -42,6 +42,63 @@ import SelectKitRow from "./select-kit/select-kit-row.gjs";import SelectedChoice from "./selected-choice.gjs";import SelectedName from "./selected-name.gjs";+/**+ * @typedef {Object} SelectKitStateProperties+ * @property {string} uniqueID+ * @property {number} [totalCount]+ * @property {boolean} [isDisabled]+ * @property {string | ((item: unknown) => unknown) | null | undefined} valueProperty+ * @property {string | ((item: unknown) => unknown) | null | undefined} nameProperty+ * @property {string | ((item: unknown) => unknown) | null | undefined} labelProperty+ * @property {string | ((item: unknown) => unknown) | null | undefined} titleProperty+ * @property {string | ((item: unknown) => unknown) | null | undefined} langProperty+ * @property {EmberObject & Record<string, unknown>} options+ * @property {boolean} isLoading+ * @property {boolean} isHidden+ * @property {boolean} isExpanded+ * @property {boolean} isPlacedAbove+ * @property {boolean} isFilterExpanded+ * @property {boolean} enterDisabled+ * @property {boolean} hasSelection+ * @property {boolean} hasNoContent+ * @property {unknown} highlighted+ * @property {unknown} noneItem+ * @property {unknown} newItem+ * @property {string | null | undefined} filter+ * @property {SelectKit["_modifyContentWrapper"]} modifyContent+ * @property {SelectKit["_modifySelectionWrapper"]} modifySelection+ * @property {SelectKit["_modifyComponentForRowWrapper"]} modifyComponentForRow+ * @property {SelectKit["_modifyContentForCollectionWrapper"]} modifyContentForCollection+ * @property {SelectKit["_modifyComponentForCollectionWrapper"]} modifyComponentForCollection+ * @property {SelectKit["_toggle"]} toggle+ * @property {SelectKit["_close"]} close+ * @property {SelectKit["_open"]} open+ * @property {SelectKit["_highlightNext"]} highlightNext+ * @property {SelectKit["_highlightPrevious"]} highlightPrevious+ * @property {SelectKit["_highlightLast"]} highlightLast+ * @property {SelectKit["_highlightFirst"]} highlightFirst+ * @property {SelectKit["_deselectLast"]} deselectLast+ * @property {SelectKit["_onChangeWrapper"]} change+ * @property {SelectKit["select"]} select+ * @property {SelectKit["deselect"]} deselect+ * @property {SelectKit["deselectByValue"]} deselectByValue+ * @property {SelectKit["append"]} append+ * @property {SelectKit["_cancelSearch"]} cancelSearch+ * @property {SelectKit["triggerSearch"]} triggerSearch+ * @property {SelectKit["_focusFilter"]} focusFilter+ * @property {SelectKit["_onOpenWrapper"]} onOpen+ * @property {SelectKit["_onCloseWrapper"]} onClose+ * @property {SelectKit["_onInput"]} onInput+ * @property {SelectKit["_onClearSelection"]} onClearSelection+ * @property {SelectKit["_onHover"]} onHover+ * @property {SelectKit["_onKeydownWrapper"]} onKeydown+ * @property {SelectKit["_mainElement"]} mainElement+ * @property {SelectKit["_headerElement"]} headerElement+ * @property {SelectKit["_bodyElement"]} bodyElement+ */++/** @typedef {EmberObject & SelectKitStateProperties} SelectKitState */+export const MAIN_COLLECTION = "MAIN_COLLECTION";export const ERRORS_COLLECTION = "ERRORS_COLLECTION";export const FILTER_VISIBILITY_THRESHOLD = 10;@@ -178,16 +235,34 @@ export default class SelectKit extends Component {multiSelect = false;@protoProp tabindex = 0;++ /** @type {unknown[] | null | undefined} */@protoProp content = null;++ /** @type {unknown} */@protoProp value = null;++ /** @type {SelectKitState | null} */@protoProp selectKit = null;++ /** @type {Record<string, unknown> | EmberObject | null | undefined} */@protoProp options = null;@protoProp valueProperty = "id";@protoProp nameProperty = "name";++ /** @type {string | ((item: unknown) => unknown) | null | undefined} */@protoProp labelProperty = null;++ /** @type {string | ((item: unknown) => unknown) | null | undefined} */@protoProp titleProperty = null;++ /** @type {string | ((item: unknown) => unknown) | null | undefined} */@protoProp langProperty = null;++ /** @type {unknown[] | null} */@autoTrackedArray mainCollection = null;++ /** @type {string[] | null} */@autoTrackedArray errorsCollection = null;_handleNativeToggle = () => {@@ -199,7 +274,8 @@ export default class SelectKit extends Component {init() {super.init(...arguments);- this._searchPromise = null;+ this._searchPromise =+ /** @type {Promise<unknown[] | undefined> | null | undefined} */ (null);this.errorsCollection = [];this._collections = [ERRORS_COLLECTION, MAIN_COLLECTION];@@ -890,6 +966,10 @@ export default class SelectKit extends Component {return boundaryAction;}+ /**+ * @param {string | null | undefined} filter+ * @returns {Promise<unknown[] | undefined>}+ */_searchWrapper(filter) {if (this.isDestroying) {return Promise.resolve([]);diff --git a/frontend/discourse/select-kit/components/select-kit/select-kit-header.js b/frontend/discourse/select-kit/components/select-kit/select-kit-header.jsindex f52b81b273c..5b0a17ecc4e 100644--- a/frontend/discourse/select-kit/components/select-kit/select-kit-header.js+++ b/frontend/discourse/select-kit/components/select-kit/select-kit-header.js@@ -21,6 +21,7 @@ import selectKitPropUtils from "discourse/select-kit/lib/select-kit-prop-utils";)@selectKitPropUtilsexport default class SelectKitHeader extends Component {+ /** @type {import("discourse/select-kit/components/select-kit").SelectKitState | null} */selectKit = null;tabindex = 0;diff --git a/frontend/discourse/select-kit/components/selected-choice.gjs b/frontend/discourse/select-kit/components/selected-choice.gjsindex 465d1bdbb8e..e8f7f133bcf 100644--- a/frontend/discourse/select-kit/components/selected-choice.gjs+++ b/frontend/discourse/select-kit/components/selected-choice.gjs@@ -12,9 +12,16 @@ import { i18n } from "discourse-i18n";@tagName("")@selectKitPropUtilsexport default class SelectedChoice extends Component {+ /** @type {unknown} */item = null;++ /** @type {import("discourse/select-kit/components/select-kit").SelectKitState | null} */selectKit = null;++ /** @type {string | null | undefined} */extraClass = null;++ /** @type {string | null} */id = null;init() {diff --git a/frontend/discourse/select-kit/components/selected-name.gjs b/frontend/discourse/select-kit/components/selected-name.gjsindex 433327f2e66..51ad9e957ab 100644--- a/frontend/discourse/select-kit/components/selected-name.gjs+++ b/frontend/discourse/select-kit/components/selected-name.gjs@@ -14,11 +14,22 @@ import dIcon from "discourse/ui-kit/helpers/d-icon";@tagName("")@selectKitPropUtilsexport default class SelectedName extends Component {+ /** @type {string | number | import("@ember/template").TrustedHTML | null | undefined} */name = null;++ /** @type {unknown} */value = null;++ /** @type {string | number | import("@ember/template").TrustedHTML | null | undefined} */headerTitle = null;++ /** @type {string | null | undefined} */headerLang = null;++ /** @type {string | number | import("@ember/template").TrustedHTML | null | undefined} */headerLabel = null;++ /** @type {string | null} */id = null;@tracked _langOverride;diff --git a/frontend/discourse/select-kit/components/tag-chooser.js b/frontend/discourse/select-kit/components/tag-chooser.jsindex e90d507c739..0dcf7b499d8 100644--- a/frontend/discourse/select-kit/components/tag-chooser.js+++ b/frontend/discourse/select-kit/components/tag-chooser.js@@ -31,6 +31,7 @@ export default class TagChooser extends MultiSelectComponent {valueProperty = "id";nameProperty = "name";+ /** @type {(string | { id: number | string, name: string })[] | null | undefined} */blockedTags = null;excludeSynonyms = false;excludeHasSynonyms = false;diff --git a/frontend/discourse/select-kit/components/tags-intersection-chooser.js b/frontend/discourse/select-kit/components/tags-intersection-chooser.jsindex 61033705486..08a10a5d4df 100644--- a/frontend/discourse/select-kit/components/tags-intersection-chooser.js+++ b/frontend/discourse/select-kit/components/tags-intersection-chooser.js@@ -9,7 +9,10 @@ import { pluginApiIdentifiers } from "discourse/select-kit/components/select-kit@classNames("tags-intersection-chooser")@pluginApiIdentifiers("tags-intersection-chooser")export default class TagsIntersectionChooser extends MiniTagChooser {+ /** @type {{ id?: number | string, name: string, slug?: string | null } | null | undefined} */mainTag = null;++ /** @type {string[] | null | undefined} */additionalTags = null;didReceiveAttrs() {diff --git a/frontend/discourse/select-kit/components/topic-chooser.js b/frontend/discourse/select-kit/components/topic-chooser.jsindex 42afabffb6e..034e4424100 100644--- a/frontend/discourse/select-kit/components/topic-chooser.js+++ b/frontend/discourse/select-kit/components/topic-chooser.js@@ -25,6 +25,10 @@ export default class TopicChooser extends ComboBoxComponent {return TopicRow;}+ /**+ * @param {string | null | undefined} filter+ * @returns {import("discourse/models/topic").default[] | import("rsvp").Promise<(import("discourse/models/topic").default | undefined)[] | undefined>}+ */search(filter) {if (isEmpty(filter) && isEmpty(this.selectKit.options.additionalFilters)) {return [];diff --git a/frontend/discourse/select-kit/components/user-notifications-dropdown.js b/frontend/discourse/select-kit/components/user-notifications-dropdown.jsindex 08631be0928..f8cc722d90e 100644--- a/frontend/discourse/select-kit/components/user-notifications-dropdown.js+++ b/frontend/discourse/select-kit/components/user-notifications-dropdown.js@@ -15,6 +15,7 @@ import { i18n } from "discourse-i18n";export default class UserNotificationsDropdown extends DropdownSelectBox {@service modal;+ /** @returns {string | null} */@computed("mainCollection.[]", "value")get userNotificationIcon() {return (