@ni/nimble-components 21.10.0 → 21.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all-components-bundle.js +69 -27
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +8 -8
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/anchor/types.d.ts +1 -1
- package/dist/esm/anchor-tab/index.d.ts +1 -1
- package/dist/esm/anchor-tabs/index.d.ts +1 -1
- package/dist/esm/banner/types.d.ts +1 -1
- package/dist/esm/breadcrumb/types.d.ts +1 -1
- package/dist/esm/button/types.d.ts +1 -1
- package/dist/esm/combobox/index.d.ts +7 -2
- package/dist/esm/combobox/index.js +15 -0
- package/dist/esm/combobox/index.js.map +1 -1
- package/dist/esm/drawer/types.d.ts +1 -1
- package/dist/esm/icon-base/index.d.ts +1 -1
- package/dist/esm/icon-base/types.d.ts +1 -1
- package/dist/esm/label-provider/base/index.d.ts +1 -1
- package/dist/esm/label-provider/core/label-token-defaults.d.ts +1 -1
- package/dist/esm/label-provider/rich-text/label-token-defaults.d.ts +1 -1
- package/dist/esm/label-provider/table/label-token-defaults.d.ts +1 -1
- package/dist/esm/list-option/index.d.ts +2 -0
- package/dist/esm/list-option/index.js +12 -0
- package/dist/esm/list-option/index.js.map +1 -1
- package/dist/esm/mapping/base/types.d.ts +2 -2
- package/dist/esm/menu-button/types.d.ts +1 -1
- package/dist/esm/number-field/types.d.ts +1 -1
- package/dist/esm/patterns/button/types.d.ts +2 -2
- package/dist/esm/patterns/dialog/types.d.ts +1 -1
- package/dist/esm/patterns/dropdown/types.d.ts +16 -2
- package/dist/esm/patterns/dropdown/types.js.map +1 -1
- package/dist/esm/rich-text/editor/testing/types.d.ts +4 -4
- package/dist/esm/rich-text/editor/types.d.ts +3 -3
- package/dist/esm/rich-text-mention/base/models/mention-validator.d.ts +1 -1
- package/dist/esm/rich-text-mention/base/types.d.ts +2 -2
- package/dist/esm/select/index.d.ts +8 -3
- package/dist/esm/select/index.js +15 -0
- package/dist/esm/select/index.js.map +1 -1
- package/dist/esm/select/testing/select.pageobject.d.ts +2 -2
- package/dist/esm/select/testing/select.pageobject.js +4 -5
- package/dist/esm/select/testing/select.pageobject.js.map +1 -1
- package/dist/esm/select/types.d.ts +1 -1
- package/dist/esm/spinner/types.d.ts +1 -1
- package/dist/esm/table/index.js +10 -10
- package/dist/esm/table/index.js.map +1 -1
- package/dist/esm/table/models/array-to-tree.d.ts +1 -1
- package/dist/esm/table/types.d.ts +12 -12
- package/dist/esm/table-column/anchor/index.d.ts +1 -1
- package/dist/esm/table-column/base/types.d.ts +1 -1
- package/dist/esm/table-column/date-text/index.d.ts +1 -1
- package/dist/esm/table-column/date-text/types.d.ts +16 -16
- package/dist/esm/table-column/duration-text/index.d.ts +1 -1
- package/dist/esm/table-column/enum-base/index.d.ts +2 -2
- package/dist/esm/table-column/enum-base/types.d.ts +1 -1
- package/dist/esm/table-column/mixins/fractional-width-column.d.ts +2 -2
- package/dist/esm/table-column/mixins/groupable-column.d.ts +2 -2
- package/dist/esm/table-column/number-text/index.d.ts +1 -1
- package/dist/esm/table-column/number-text/models/number-text-unit-format.d.ts +1 -1
- package/dist/esm/table-column/number-text/types.d.ts +2 -2
- package/dist/esm/table-column/text/index.d.ts +1 -1
- package/dist/esm/table-column/text-base/cell-view/types.d.ts +1 -1
- package/dist/esm/text-area/types.d.ts +1 -1
- package/dist/esm/text-field/types.d.ts +1 -1
- package/dist/esm/theme-provider/design-token-comments.d.ts +1 -1
- package/dist/esm/theme-provider/design-token-names.d.ts +2 -2
- package/dist/esm/theme-provider/types.d.ts +1 -1
- package/dist/esm/tooltip/types.d.ts +1 -1
- package/dist/esm/tree-view/types.d.ts +1 -1
- package/dist/esm/utilities/models/tracker.d.ts +1 -1
- package/dist/esm/utilities/style/types.d.ts +1 -1
- package/dist/esm/utilities/unit-format/decimal-unit-format.d.ts +1 -1
- package/dist/esm/utilities/unit-format/default-unit-format.d.ts +1 -1
- package/dist/esm/utilities/unit-format/scaled-unit/scaled-unit.d.ts +1 -1
- package/dist/esm/utilities/unit-format/scaled-unit-format/manually-translated-scaled-unit-format.d.ts +1 -1
- package/dist/esm/wafer-map/modules/computations.js +5 -5
- package/dist/esm/wafer-map/modules/computations.js.map +1 -1
- package/dist/esm/wafer-map/modules/data-manager.js +5 -5
- package/dist/esm/wafer-map/modules/data-manager.js.map +1 -1
- package/dist/esm/wafer-map/modules/prerendering.js +6 -6
- package/dist/esm/wafer-map/modules/prerendering.js.map +1 -1
- package/dist/esm/wafer-map/types.d.ts +4 -4
- package/package.json +5 -5
|
@@ -6,4 +6,4 @@ export declare const AnchorAppearance: {
|
|
|
6
6
|
readonly default: undefined;
|
|
7
7
|
readonly prominent: "prominent";
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type AnchorAppearance = (typeof AnchorAppearance)[keyof typeof AnchorAppearance];
|
|
@@ -4,7 +4,7 @@ declare global {
|
|
|
4
4
|
'nimble-anchor-tabs': AnchorTabs;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export type TabsOptions = FoundationElementDefinition & StartEndOptions;
|
|
8
8
|
/**
|
|
9
9
|
* A nimble-styled set of anchor tabs
|
|
10
10
|
*/
|
|
@@ -8,7 +8,7 @@ export declare const BannerSeverity: {
|
|
|
8
8
|
readonly warning: "warning";
|
|
9
9
|
readonly information: "information";
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type BannerSeverity = (typeof BannerSeverity)[keyof typeof BannerSeverity];
|
|
12
12
|
/**
|
|
13
13
|
* The type of the detail associated with the `toggle`
|
|
14
14
|
* event on the banner.
|
|
@@ -6,4 +6,4 @@ export declare const BreadcrumbAppearance: {
|
|
|
6
6
|
readonly default: undefined;
|
|
7
7
|
readonly prominent: "prominent";
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type BreadcrumbAppearance = (typeof BreadcrumbAppearance)[keyof typeof BreadcrumbAppearance];
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Combobox as FoundationCombobox } from '@microsoft/fast-foundation';
|
|
2
2
|
import { ToggleButton } from '../toggle-button';
|
|
3
3
|
import type { ErrorPattern } from '../patterns/error/types';
|
|
4
|
-
import type { DropdownPattern } from '../patterns/dropdown/types';
|
|
4
|
+
import type { DropdownPattern, ListOptionOwner } from '../patterns/dropdown/types';
|
|
5
5
|
import { DropdownAppearance } from '../patterns/dropdown/types';
|
|
6
6
|
import type { AnchoredRegion } from '../anchored-region';
|
|
7
|
+
import type { ListOption } from '../list-option';
|
|
7
8
|
declare global {
|
|
8
9
|
interface HTMLElementTagNameMap {
|
|
9
10
|
'nimble-combobox': Combobox;
|
|
@@ -12,7 +13,7 @@ declare global {
|
|
|
12
13
|
/**
|
|
13
14
|
* A nimble-styed HTML combobox
|
|
14
15
|
*/
|
|
15
|
-
export declare class Combobox extends FoundationCombobox implements DropdownPattern, ErrorPattern {
|
|
16
|
+
export declare class Combobox extends FoundationCombobox implements DropdownPattern, ErrorPattern, ListOptionOwner {
|
|
16
17
|
appearance: DropdownAppearance;
|
|
17
18
|
/**
|
|
18
19
|
* The ref to the internal dropdown button element.
|
|
@@ -59,6 +60,10 @@ export declare class Combobox extends FoundationCombobox implements DropdownPatt
|
|
|
59
60
|
inputHandler(e: InputEvent): boolean | void;
|
|
60
61
|
keydownHandler(e: KeyboardEvent): boolean | void;
|
|
61
62
|
focusoutHandler(e: FocusEvent): boolean | void;
|
|
63
|
+
/**
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
registerOption(option: ListOption): void;
|
|
62
67
|
protected focusAndScrollOptionIntoView(): void;
|
|
63
68
|
protected openChanged(): void;
|
|
64
69
|
private regionChanged;
|
|
@@ -134,6 +134,21 @@ export class Combobox extends FoundationCombobox {
|
|
|
134
134
|
this.emitChangeIfValueUpdated();
|
|
135
135
|
return returnValue;
|
|
136
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
registerOption(option) {
|
|
141
|
+
if (this.options.includes(option)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
// Adding an option to the end, ultimately, isn't the correct
|
|
145
|
+
// thing to do, as this will mean the option's index in the options,
|
|
146
|
+
// at least temporarily, does not match the DOM order. However, it
|
|
147
|
+
// is expected that a successive run of `slottedOptionsChanged` will
|
|
148
|
+
// correct this order issue. See 'https://github.com/ni/nimble/issues/1915'
|
|
149
|
+
// for more info.
|
|
150
|
+
this.options.push(option);
|
|
151
|
+
}
|
|
137
152
|
focusAndScrollOptionIntoView() {
|
|
138
153
|
if (this.open) {
|
|
139
154
|
super.focusAndScrollOptionIntoView();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/combobox/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EACH,YAAY,EACZ,QAAQ,IAAI,kBAAkB,EAEjC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,QAAQ,EACX,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAgB,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAQtC;;GAEG;AACH,MAAM,OAAO,QACT,SAAQ,kBAAkB;IAD9B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ignSystem,\n Combobox as FoundationCombobox,\n ComboboxOptions\n} from '@microsoft/fast-foundation';\nimport {\n keyArrowDown,\n keyArrowUp,\n keyEnter,\n keySpace\n} from '@microsoft/fast-web-utilities';\nimport { ToggleButton, toggleButtonTag } from '../toggle-button';\nimport { errorTextTemplate } from '../patterns/error/template';\nimport { iconArrowExpanderDownTag } from '../icons/arrow-expander-down';\nimport { iconExclamationMarkTag } from '../icons/exclamation-mark';\n\nimport { styles } from './styles';\nimport type { ErrorPattern } from '../patterns/error/types';\nimport type { DropdownPattern } from '../patterns/dropdown/types';\nimport { DropdownAppearance } from '../patterns/dropdown/types';\nimport type { AnchoredRegion } from '../anchored-region';\nimport { template } from './template';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nimble-combobox': Combobox;\n }\n}\n\n/**\n * A nimble-styed HTML combobox\n */\nexport class Combobox\n extends FoundationCombobox\n implements DropdownPattern, ErrorPattern {\n @attr\n public appearance: DropdownAppearance = DropdownAppearance.underline;\n\n /**\n * The ref to the internal dropdown button element.\n *\n * @internal\n */\n @observable\n public readonly dropdownButton?: ToggleButton;\n\n /**\n * A message explaining why the value is invalid.\n *\n * @public\n * @remarks\n * HTML Attribute: error-text\n */\n @attr({ attribute: 'error-text' })\n public errorText?: string;\n\n @attr({ attribute: 'error-visible', mode: 'boolean' })\n public errorVisible = false;\n\n /**\n * @internal\n */\n @observable\n public region?: AnchoredRegion;\n\n /**\n * @internal\n */\n @observable\n public controlWrapper?: HTMLElement;\n\n /** @internal */\n @observable\n public hasOverflow = false;\n\n public override get value(): string {\n return super.value;\n }\n\n // This override is to work around an issue in FAST where an old filter value\n // is used after programmatically setting the value property.\n // See: https://github.com/microsoft/fast/issues/6749\n public override set value(next: string) {\n super.value = next;\n // Workaround using index notation to manipulate private member\n // Can remove when following resolved: https://github.com/microsoft/fast/issues/6749\n // eslint-disable-next-line @typescript-eslint/dot-notation\n this['filter'] = next;\n this.filterOptions();\n this.selectedIndex = this.options\n .map(option => option.text)\n .indexOf(this.value);\n }\n\n private valueUpdatedByInput = false;\n private valueBeforeTextUpdate?: string;\n\n // Workaround for https://github.com/microsoft/fast/issues/5123\n public override setPositioning(): void {\n if (!this.$fastController.isConnected) {\n // Don't call setPositioning() until we're connected,\n // since this.forcedPosition isn't initialized yet.\n return;\n }\n super.setPositioning();\n }\n\n // Workaround for https://github.com/microsoft/fast/issues/5773\n public override slottedOptionsChanged(\n prev: HTMLElement[],\n next: HTMLElement[]\n ): void {\n const value = this.value;\n super.slottedOptionsChanged(prev, next);\n if (value) {\n this.value = value;\n }\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n // Call setPositioning() after this.forcedPosition is initialized.\n this.setPositioning();\n this.updateInputAriaLabel();\n }\n\n public toggleButtonClickHandler(e: Event): void {\n e.stopImmediatePropagation();\n }\n\n public toggleButtonChangeHandler(e: Event): void {\n this.open = this.dropdownButton!.checked;\n e.stopImmediatePropagation();\n }\n\n public toggleButtonKeyDownHandler(e: KeyboardEvent): boolean {\n switch (e.key) {\n case keyArrowUp:\n case keyArrowDown:\n case keySpace:\n case keyEnter:\n this.open = true;\n this.stopPropagation(e);\n return false;\n default:\n return true;\n }\n }\n\n public override filterOptions(): void {\n super.filterOptions();\n const enabledOptions = this.filteredOptions.filter(o => !o.disabled);\n this.filteredOptions = enabledOptions;\n }\n\n /**\n * This is a workaround for the issue described here: https://github.com/microsoft/fast/issues/6267\n * For now, we will update the value ourselves while a user types in text. Note that there is other\n * implementation related to this (like the 'keydownEventHandler') needed to create the complete set\n * of desired behavior described in the issue noted above.\n */\n // eslint-disable-next-line @typescript-eslint/no-invalid-void-type\n public override inputHandler(e: InputEvent): boolean | void {\n const returnValue = super.inputHandler(e);\n if (!this.valueUpdatedByInput) {\n this.valueBeforeTextUpdate = this.value;\n }\n this.valueUpdatedByInput = true;\n // This is a workaround for this FAST issue: https://github.com/microsoft/fast/issues/6776\n if (this.value !== this.control.value) {\n this.focusAndScrollOptionIntoView();\n }\n\n this.value = this.control.value;\n return returnValue;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-invalid-void-type\n public override keydownHandler(e: KeyboardEvent): boolean | void {\n const returnValue = super.keydownHandler(e);\n if (e.ctrlKey || e.altKey) {\n return returnValue;\n }\n\n switch (e.key) {\n case keyEnter:\n this.emitChangeIfValueUpdated();\n break;\n case keyArrowDown:\n case keyArrowUp:\n if (this.open && this.valueUpdatedByInput) {\n this.valueUpdatedByInput = false;\n }\n break;\n default:\n return returnValue;\n }\n return returnValue;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-invalid-void-type\n public override focusoutHandler(e: FocusEvent): boolean | void {\n const returnValue = super.focusoutHandler(e);\n this.open = false;\n this.emitChangeIfValueUpdated();\n return returnValue;\n }\n\n protected override focusAndScrollOptionIntoView(): void {\n if (this.open) {\n super.focusAndScrollOptionIntoView();\n }\n }\n\n protected override openChanged(): void {\n super.openChanged();\n if (this.dropdownButton) {\n this.dropdownButton.checked = this.open;\n }\n }\n\n private regionChanged(\n _prev: AnchoredRegion | undefined,\n _next: AnchoredRegion | undefined\n ): void {\n if (this.region && this.controlWrapper) {\n this.region.anchorElement = this.controlWrapper;\n }\n }\n\n private controlWrapperChanged(\n _prev: HTMLElement | undefined,\n _next: HTMLElement | undefined\n ): void {\n if (this.region && this.controlWrapper) {\n this.region.anchorElement = this.controlWrapper;\n }\n }\n\n // Workaround for https://github.com/microsoft/fast/issues/6041.\n private ariaLabelChanged(_oldValue: string, _newValue: string): void {\n this.updateInputAriaLabel();\n }\n\n private maxHeightChanged(): void {\n this.updateListboxMaxHeightCssVariable();\n }\n\n private updateListboxMaxHeightCssVariable(): void {\n if (this.listbox) {\n this.listbox.style.setProperty(\n '--ni-private-select-max-height',\n `${this.maxHeight}px`\n );\n }\n }\n\n private updateInputAriaLabel(): void {\n const inputElement = this.shadowRoot?.querySelector('.selected-value');\n if (this.ariaLabel) {\n inputElement?.setAttribute('aria-label', this.ariaLabel);\n } else {\n inputElement?.removeAttribute('aria-label');\n }\n }\n\n /**\n * This will only emit a `change` event after text entry where the text in the input prior to\n * typing is different than the text present upon an attempt to commit (e.g. pressing <Enter>).\n * So, for a concrete example:\n * 1) User types 'Sue' (when Combobox input was blank).\n * 2) User presses <Enter> -> 'change' event fires\n * 3) User deletes 'Sue'\n * 4) User re-types 'Sue'\n * 5) User presses <Enter> -> NO 'change' event is fired\n */\n private emitChangeIfValueUpdated(): void {\n if (this.valueUpdatedByInput) {\n if (this.value !== this.valueBeforeTextUpdate) {\n this.$emit('change');\n }\n\n this.valueUpdatedByInput = false;\n }\n }\n}\n\nconst nimbleCombobox = Combobox.compose<ComboboxOptions>({\n baseName: 'combobox',\n baseClass: FoundationCombobox,\n template,\n styles,\n shadowOptions: {\n delegatesFocus: true\n },\n end: html<Combobox>`\n <div class=\"end-slot-container\">\n <${iconExclamationMarkTag}\n severity=\"error\"\n class=\"error-icon\"\n ></${iconExclamationMarkTag}>\n <div class=\"separator\"></div>\n <${toggleButtonTag}\n ${ref('dropdownButton')}\n appearance=\"ghost\"\n ?checked=\"${x => x.open}\"\n ?disabled=\"${x => x.disabled}\"\n content-hidden=\"true\"\n @click=\"${(x, c) => x.toggleButtonClickHandler(c.event)}\"\n @change=\"${(x, c) => x.toggleButtonChangeHandler(c.event)}\"\n @keydown=\"${(x, c) => x.toggleButtonKeyDownHandler(c.event as KeyboardEvent)}\"\n class=\"dropdown-button\"\n part=\"button\"\n aria-haspopup=\"true\"\n aria-expanded=\"${x => x.open}\"\n tabindex=\"-1\"\n >\n <${iconArrowExpanderDownTag}\n slot=\"start\"\n class=\"dropdown-icon\"\n >\n </${iconArrowExpanderDownTag}>\n </${toggleButtonTag}>\n </div>\n ${errorTextTemplate}\n `\n});\n\nDesignSystem.getOrCreate().withPrefix('nimble').register(nimbleCombobox());\nexport const comboboxTag = 'nimble-combobox';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/combobox/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE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ACR,MAAM;IACN,aAAa,EAAE;QACX,cAAc,EAAE,IAAI;KACvB;IACD,GAAG,EAAE,IAAI,CAAU;;eAER,sBAAsB;;;iBAGpB,sBAAsB;;eAExB,eAAe;kBACZ,GAAG,CAAC,gBAAgB,CAAC;;4BAEX,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;6BACV,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ;;0BAElB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,KAAK,CAAC;2BAC5C,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,KAAK,CAAC;4BAC7C,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,KAAsB,CAAC;;;;iCAI3D,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;;;mBAGzB,wBAAwB;;;;oBAIvB,wBAAwB;gBAC5B,eAAe;;UAErB,iBAAiB;KACtB;CACJ,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAC;AAC3E,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC","sourcesContent":["import { attr, html, observable, ref } from '@microsoft/fast-element';\nimport {\n DesignSystem,\n Combobox as FoundationCombobox,\n ComboboxOptions\n} from '@microsoft/fast-foundation';\nimport {\n keyArrowDown,\n keyArrowUp,\n keyEnter,\n keySpace\n} from '@microsoft/fast-web-utilities';\nimport { ToggleButton, toggleButtonTag } from '../toggle-button';\nimport { errorTextTemplate } from '../patterns/error/template';\nimport { iconArrowExpanderDownTag } from '../icons/arrow-expander-down';\nimport { iconExclamationMarkTag } from '../icons/exclamation-mark';\n\nimport { styles } from './styles';\nimport type { ErrorPattern } from '../patterns/error/types';\nimport type {\n DropdownPattern,\n ListOptionOwner\n} from '../patterns/dropdown/types';\nimport { DropdownAppearance } from '../patterns/dropdown/types';\nimport type { AnchoredRegion } from '../anchored-region';\nimport { template } from './template';\nimport type { ListOption } from '../list-option';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nimble-combobox': Combobox;\n }\n}\n\n/**\n * A nimble-styed HTML combobox\n */\nexport class Combobox\n extends FoundationCombobox\n implements DropdownPattern, ErrorPattern, ListOptionOwner {\n @attr\n public appearance: DropdownAppearance = DropdownAppearance.underline;\n\n /**\n * The ref to the internal dropdown button element.\n *\n * @internal\n */\n @observable\n public readonly dropdownButton?: ToggleButton;\n\n /**\n * A message explaining why the value is invalid.\n *\n * @public\n * @remarks\n * HTML Attribute: error-text\n */\n @attr({ attribute: 'error-text' })\n public errorText?: string;\n\n @attr({ attribute: 'error-visible', mode: 'boolean' })\n public errorVisible = false;\n\n /**\n * @internal\n */\n @observable\n public region?: AnchoredRegion;\n\n /**\n * @internal\n */\n @observable\n public controlWrapper?: HTMLElement;\n\n /** @internal */\n @observable\n public hasOverflow = false;\n\n public override get value(): string {\n return super.value;\n }\n\n // This override is to work around an issue in FAST where an old filter value\n // is used after programmatically setting the value property.\n // See: https://github.com/microsoft/fast/issues/6749\n public override set value(next: string) {\n super.value = next;\n // Workaround using index notation to manipulate private member\n // Can remove when following resolved: https://github.com/microsoft/fast/issues/6749\n // eslint-disable-next-line @typescript-eslint/dot-notation\n this['filter'] = next;\n this.filterOptions();\n this.selectedIndex = this.options\n .map(option => option.text)\n .indexOf(this.value);\n }\n\n private valueUpdatedByInput = false;\n private valueBeforeTextUpdate?: string;\n\n // Workaround for https://github.com/microsoft/fast/issues/5123\n public override setPositioning(): void {\n if (!this.$fastController.isConnected) {\n // Don't call setPositioning() until we're connected,\n // since this.forcedPosition isn't initialized yet.\n return;\n }\n super.setPositioning();\n }\n\n // Workaround for https://github.com/microsoft/fast/issues/5773\n public override slottedOptionsChanged(\n prev: HTMLElement[],\n next: HTMLElement[]\n ): void {\n const value = this.value;\n super.slottedOptionsChanged(prev, next);\n if (value) {\n this.value = value;\n }\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n // Call setPositioning() after this.forcedPosition is initialized.\n this.setPositioning();\n this.updateInputAriaLabel();\n }\n\n public toggleButtonClickHandler(e: Event): void {\n e.stopImmediatePropagation();\n }\n\n public toggleButtonChangeHandler(e: Event): void {\n this.open = this.dropdownButton!.checked;\n e.stopImmediatePropagation();\n }\n\n public toggleButtonKeyDownHandler(e: KeyboardEvent): boolean {\n switch (e.key) {\n case keyArrowUp:\n case keyArrowDown:\n case keySpace:\n case keyEnter:\n this.open = true;\n this.stopPropagation(e);\n return false;\n default:\n return true;\n }\n }\n\n public override filterOptions(): void {\n super.filterOptions();\n const enabledOptions = this.filteredOptions.filter(o => !o.disabled);\n this.filteredOptions = enabledOptions;\n }\n\n /**\n * This is a workaround for the issue described here: https://github.com/microsoft/fast/issues/6267\n * For now, we will update the value ourselves while a user types in text. Note that there is other\n * implementation related to this (like the 'keydownEventHandler') needed to create the complete set\n * of desired behavior described in the issue noted above.\n */\n // eslint-disable-next-line @typescript-eslint/no-invalid-void-type\n public override inputHandler(e: InputEvent): boolean | void {\n const returnValue = super.inputHandler(e);\n if (!this.valueUpdatedByInput) {\n this.valueBeforeTextUpdate = this.value;\n }\n this.valueUpdatedByInput = true;\n // This is a workaround for this FAST issue: https://github.com/microsoft/fast/issues/6776\n if (this.value !== this.control.value) {\n this.focusAndScrollOptionIntoView();\n }\n\n this.value = this.control.value;\n return returnValue;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-invalid-void-type\n public override keydownHandler(e: KeyboardEvent): boolean | void {\n const returnValue = super.keydownHandler(e);\n if (e.ctrlKey || e.altKey) {\n return returnValue;\n }\n\n switch (e.key) {\n case keyEnter:\n this.emitChangeIfValueUpdated();\n break;\n case keyArrowDown:\n case keyArrowUp:\n if (this.open && this.valueUpdatedByInput) {\n this.valueUpdatedByInput = false;\n }\n break;\n default:\n return returnValue;\n }\n return returnValue;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-invalid-void-type\n public override focusoutHandler(e: FocusEvent): boolean | void {\n const returnValue = super.focusoutHandler(e);\n this.open = false;\n this.emitChangeIfValueUpdated();\n return returnValue;\n }\n\n /**\n * @internal\n */\n public registerOption(option: ListOption): void {\n if (this.options.includes(option)) {\n return;\n }\n\n // Adding an option to the end, ultimately, isn't the correct\n // thing to do, as this will mean the option's index in the options,\n // at least temporarily, does not match the DOM order. However, it\n // is expected that a successive run of `slottedOptionsChanged` will\n // correct this order issue. See 'https://github.com/ni/nimble/issues/1915'\n // for more info.\n this.options.push(option);\n }\n\n protected override focusAndScrollOptionIntoView(): void {\n if (this.open) {\n super.focusAndScrollOptionIntoView();\n }\n }\n\n protected override openChanged(): void {\n super.openChanged();\n if (this.dropdownButton) {\n this.dropdownButton.checked = this.open;\n }\n }\n\n private regionChanged(\n _prev: AnchoredRegion | undefined,\n _next: AnchoredRegion | undefined\n ): void {\n if (this.region && this.controlWrapper) {\n this.region.anchorElement = this.controlWrapper;\n }\n }\n\n private controlWrapperChanged(\n _prev: HTMLElement | undefined,\n _next: HTMLElement | undefined\n ): void {\n if (this.region && this.controlWrapper) {\n this.region.anchorElement = this.controlWrapper;\n }\n }\n\n // Workaround for https://github.com/microsoft/fast/issues/6041.\n private ariaLabelChanged(_oldValue: string, _newValue: string): void {\n this.updateInputAriaLabel();\n }\n\n private maxHeightChanged(): void {\n this.updateListboxMaxHeightCssVariable();\n }\n\n private updateListboxMaxHeightCssVariable(): void {\n if (this.listbox) {\n this.listbox.style.setProperty(\n '--ni-private-select-max-height',\n `${this.maxHeight}px`\n );\n }\n }\n\n private updateInputAriaLabel(): void {\n const inputElement = this.shadowRoot?.querySelector('.selected-value');\n if (this.ariaLabel) {\n inputElement?.setAttribute('aria-label', this.ariaLabel);\n } else {\n inputElement?.removeAttribute('aria-label');\n }\n }\n\n /**\n * This will only emit a `change` event after text entry where the text in the input prior to\n * typing is different than the text present upon an attempt to commit (e.g. pressing <Enter>).\n * So, for a concrete example:\n * 1) User types 'Sue' (when Combobox input was blank).\n * 2) User presses <Enter> -> 'change' event fires\n * 3) User deletes 'Sue'\n * 4) User re-types 'Sue'\n * 5) User presses <Enter> -> NO 'change' event is fired\n */\n private emitChangeIfValueUpdated(): void {\n if (this.valueUpdatedByInput) {\n if (this.value !== this.valueBeforeTextUpdate) {\n this.$emit('change');\n }\n\n this.valueUpdatedByInput = false;\n }\n }\n}\n\nconst nimbleCombobox = Combobox.compose<ComboboxOptions>({\n baseName: 'combobox',\n baseClass: FoundationCombobox,\n template,\n styles,\n shadowOptions: {\n delegatesFocus: true\n },\n end: html<Combobox>`\n <div class=\"end-slot-container\">\n <${iconExclamationMarkTag}\n severity=\"error\"\n class=\"error-icon\"\n ></${iconExclamationMarkTag}>\n <div class=\"separator\"></div>\n <${toggleButtonTag}\n ${ref('dropdownButton')}\n appearance=\"ghost\"\n ?checked=\"${x => x.open}\"\n ?disabled=\"${x => x.disabled}\"\n content-hidden=\"true\"\n @click=\"${(x, c) => x.toggleButtonClickHandler(c.event)}\"\n @change=\"${(x, c) => x.toggleButtonChangeHandler(c.event)}\"\n @keydown=\"${(x, c) => x.toggleButtonKeyDownHandler(c.event as KeyboardEvent)}\"\n class=\"dropdown-button\"\n part=\"button\"\n aria-haspopup=\"true\"\n aria-expanded=\"${x => x.open}\"\n tabindex=\"-1\"\n >\n <${iconArrowExpanderDownTag}\n slot=\"start\"\n class=\"dropdown-icon\"\n >\n </${iconArrowExpanderDownTag}>\n </${toggleButtonTag}>\n </div>\n ${errorTextTemplate}\n `\n});\n\nDesignSystem.getOrCreate().withPrefix('nimble').register(nimbleCombobox());\nexport const comboboxTag = 'nimble-combobox';\n"]}
|
|
@@ -14,6 +14,6 @@ export declare class Icon extends FoundationElement {
|
|
|
14
14
|
severity: IconSeverity;
|
|
15
15
|
constructor(/** @internal */ icon: NimbleIcon);
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
type IconClass = typeof Icon;
|
|
18
18
|
export declare const registerIcon: (baseName: string, iconClass: IconClass) => void;
|
|
19
19
|
export {};
|
|
@@ -9,4 +9,4 @@ export declare const IconSeverity: {
|
|
|
9
9
|
readonly success: "success";
|
|
10
10
|
readonly information: "information";
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type IconSeverity = (typeof IconSeverity)[keyof typeof IconSeverity];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DesignToken, FoundationElement } from '@microsoft/fast-foundation';
|
|
2
2
|
import { type Subscriber } from '@microsoft/fast-element';
|
|
3
|
-
export
|
|
3
|
+
export type DesignTokensFor<ObjectT> = {
|
|
4
4
|
[key in keyof ObjectT]: string | undefined;
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
@@ -31,5 +31,7 @@ export declare class ListOption extends FoundationListboxOption {
|
|
|
31
31
|
hasOverflow: boolean;
|
|
32
32
|
/** @internal */
|
|
33
33
|
get elementTextContent(): string;
|
|
34
|
+
connectedCallback(): void;
|
|
35
|
+
private isListOptionOwner;
|
|
34
36
|
}
|
|
35
37
|
export declare const listOptionTag = "nimble-list-option";
|
|
@@ -36,6 +36,18 @@ export class ListOption extends FoundationListboxOption {
|
|
|
36
36
|
.map(node => node.textContent?.trim())
|
|
37
37
|
.join(' ');
|
|
38
38
|
}
|
|
39
|
+
connectedCallback() {
|
|
40
|
+
super.connectedCallback();
|
|
41
|
+
if (this.isListOptionOwner(this.parentElement)) {
|
|
42
|
+
this.parentElement.registerOption(this);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
isListOptionOwner(parent) {
|
|
46
|
+
if (!parent) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return typeof parent.registerOption === 'function';
|
|
50
|
+
}
|
|
39
51
|
}
|
|
40
52
|
__decorate([
|
|
41
53
|
attr({ mode: 'boolean' })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/list-option/index.ts"],"names":[],"mappings":";AAAA,OAAO,EACH,YAAY,EACZ,aAAa,IAAI,uBAAuB,EAC3C,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/list-option/index.ts"],"names":[],"mappings":";AAAA,OAAO,EACH,YAAY,EACZ,aAAa,IAAI,uBAAuB,EAC3C,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAStC;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,uBAAuB;IAAvD;;QAII;;;;;;;WAOG;QAEa,WAAM,GAAG,KAAK,CAAC;QAE/B;;;;;;WAMG;QAEI,mBAAc,GAAG,KAAK,CAAC;QAE9B,gBAAgB;QAET,gBAAW,GAAG,KAAK,CAAC;IA0B/B,CAAC;IAxBG,gBAAgB;IAChB,IAAW,kBAAkB;QACzB,OAAO,IAAI,CAAC,WAAW;aAClB,aAAa,EAAE;aACf,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC;aACrC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAEe,iBAAiB;QAC7B,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE;YAC5C,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;SAC3C;IACL,CAAC;IAEO,iBAAiB,CACrB,MAA0B;QAE1B,IAAI,CAAC,MAAM,EAAE;YACT,OAAO,KAAK,CAAC;SAChB;QAED,OAAO,OAAQ,MAA0B,CAAC,cAAc,KAAK,UAAU,CAAC;IAC5E,CAAC;CACJ;AAxCG;IADC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;0CACK;AAU/B;IADC,IAAI,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;kDAC1B;AAI9B;IADC,UAAU;+CACgB;AA4B/B,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,CAAC;IACxC,QAAQ,EAAE,aAAa;IACvB,SAAS,EAAE,uBAAuB;IAClC,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,aAAa,GAAG,oBAAoB,CAAC","sourcesContent":["import {\n DesignSystem,\n ListboxOption as FoundationListboxOption\n} from '@microsoft/fast-foundation';\nimport { observable, attr } from '@microsoft/fast-element';\nimport { styles } from './styles';\nimport { template } from './template';\nimport type { ListOptionOwner } from '../patterns/dropdown/types';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nimble-list-option': ListOption;\n }\n}\n\n/**\n * A nimble-styled HTML listbox option\n */\nexport class ListOption extends FoundationListboxOption {\n /** @internal */\n public contentSlot!: HTMLSlotElement;\n\n /**\n * The hidden state of the element.\n *\n * @public\n * @defaultValue - false\n * @remarks\n * HTML Attribute: hidden\n */\n @attr({ mode: 'boolean' })\n public override hidden = false;\n\n /**\n * @internal\n * This attribute is required to allow use-cases that offer dynamic filtering\n * (like the Select) to visually hide options that are filtered out, but still\n * allow users to use the native 'hidden' attribute without it being affected\n * by the filtering process.\n */\n @attr({ attribute: 'visually-hidden', mode: 'boolean' })\n public visuallyHidden = false;\n\n /** @internal */\n @observable\n public hasOverflow = false;\n\n /** @internal */\n public get elementTextContent(): string {\n return this.contentSlot\n .assignedNodes()\n .map(node => node.textContent?.trim())\n .join(' ');\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n if (this.isListOptionOwner(this.parentElement)) {\n this.parentElement.registerOption(this);\n }\n }\n\n private isListOptionOwner(\n parent: HTMLElement | null\n ): parent is ListOptionOwner {\n if (!parent) {\n return false;\n }\n\n return typeof (parent as ListOptionOwner).registerOption === 'function';\n }\n}\n\nconst nimbleListOption = ListOption.compose({\n baseName: 'list-option',\n baseClass: FoundationListboxOption,\n template,\n styles\n});\n\nDesignSystem.getOrCreate().withPrefix('nimble').register(nimbleListOption());\nexport const listOptionTag = 'nimble-list-option';\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type MappingKey = string | number | boolean;
|
|
2
2
|
/** For user mapping, a string formatted as a URL. */
|
|
3
|
-
export
|
|
3
|
+
export type MappingUserKey = string;
|
|
@@ -11,7 +11,7 @@ export declare const MenuButtonPosition: {
|
|
|
11
11
|
readonly below: "below";
|
|
12
12
|
readonly auto: "auto";
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type MenuButtonPosition = (typeof MenuButtonPosition)[keyof typeof MenuButtonPosition];
|
|
15
15
|
/**
|
|
16
16
|
* The type of the detail associated with the `toggle` and `beforetoggle`
|
|
17
17
|
* events on the menu button.
|
|
@@ -6,4 +6,4 @@ export declare const NumberFieldAppearance: {
|
|
|
6
6
|
readonly outline: "outline";
|
|
7
7
|
readonly block: "block";
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type NumberFieldAppearance = (typeof NumberFieldAppearance)[keyof typeof NumberFieldAppearance];
|
|
@@ -36,7 +36,7 @@ export declare const ButtonAppearance: {
|
|
|
36
36
|
readonly ghost: "ghost";
|
|
37
37
|
readonly block: "block";
|
|
38
38
|
};
|
|
39
|
-
export
|
|
39
|
+
export type ButtonAppearance = (typeof ButtonAppearance)[keyof typeof ButtonAppearance];
|
|
40
40
|
/**
|
|
41
41
|
* Types of button appearance variants.
|
|
42
42
|
* @public
|
|
@@ -46,4 +46,4 @@ export declare const ButtonAppearanceVariant: {
|
|
|
46
46
|
readonly primary: "primary";
|
|
47
47
|
readonly accent: "accent";
|
|
48
48
|
};
|
|
49
|
-
export
|
|
49
|
+
export type ButtonAppearanceVariant = (typeof ButtonAppearanceVariant)[keyof typeof ButtonAppearanceVariant];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ListOption } from '../../list-option';
|
|
1
2
|
import type { ErrorPattern } from '../error/types';
|
|
2
3
|
/**
|
|
3
4
|
* The interface that dropdowns of various types implement. The properties in this interface
|
|
@@ -10,10 +11,23 @@ export declare const DropdownPosition: {
|
|
|
10
11
|
readonly above: "above";
|
|
11
12
|
readonly below: "below";
|
|
12
13
|
};
|
|
13
|
-
export
|
|
14
|
+
export type DropdownPosition = (typeof DropdownPosition)[keyof typeof DropdownPosition];
|
|
14
15
|
export declare const DropdownAppearance: {
|
|
15
16
|
readonly underline: "underline";
|
|
16
17
|
readonly outline: "outline";
|
|
17
18
|
readonly block: "block";
|
|
18
19
|
};
|
|
19
|
-
export
|
|
20
|
+
export type DropdownAppearance = (typeof DropdownAppearance)[keyof typeof DropdownAppearance];
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*
|
|
24
|
+
* This interface is used to register options with their parent once their
|
|
25
|
+
* 'connectedCallback' method is run. This allows for the "owner", like the
|
|
26
|
+
* Select, to have its value set to that newly registered option earlier than it
|
|
27
|
+
* might otherwise in certain situations. One such scenario is in an Angular
|
|
28
|
+
* reactive form, where the form value is set to an option immediately after
|
|
29
|
+
* dynamically adding it.
|
|
30
|
+
*/
|
|
31
|
+
export interface ListOptionOwner extends HTMLElement {
|
|
32
|
+
registerOption: (option: ListOption) => void;
|
|
33
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/patterns/dropdown/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/patterns/dropdown/types.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;CACR,CAAC;AAIX,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAC9B,SAAS,EAAE,WAAW;IACtB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;CACR,CAAC","sourcesContent":["import type { ListOption } from '../../list-option';\nimport type { ErrorPattern } from '../error/types';\n\n/**\n * The interface that dropdowns of various types implement. The properties in this interface\n * are leveraged by the shared dropdown pattern css.\n */\nexport interface DropdownPattern extends ErrorPattern {\n position?: DropdownPosition;\n}\n\nexport const DropdownPosition = {\n above: 'above',\n below: 'below'\n} as const;\nexport type DropdownPosition =\n (typeof DropdownPosition)[keyof typeof DropdownPosition];\n\nexport const DropdownAppearance = {\n underline: 'underline',\n outline: 'outline',\n block: 'block'\n} as const;\nexport type DropdownAppearance =\n (typeof DropdownAppearance)[keyof typeof DropdownAppearance];\n\n/**\n * @internal\n *\n * This interface is used to register options with their parent once their\n * 'connectedCallback' method is run. This allows for the \"owner\", like the\n * Select, to have its value set to that newly registered option earlier than it\n * might otherwise in certain situations. One such scenario is in an Angular\n * reactive form, where the form value is set to an option immediately after\n * dynamically adding it.\n */\nexport interface ListOptionOwner extends HTMLElement {\n registerOption: (option: ListOption) => void;\n}\n"]}
|
|
@@ -7,16 +7,16 @@ export declare const ToolbarButton: {
|
|
|
7
7
|
readonly bulletList: 2;
|
|
8
8
|
readonly numberedList: 3;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type ToolbarButton = (typeof ToolbarButton)[keyof typeof ToolbarButton];
|
|
11
11
|
export declare const ArrowKeyButton: {
|
|
12
12
|
readonly up: "ArrowUp";
|
|
13
13
|
readonly down: "ArrowDown";
|
|
14
14
|
readonly left: "ArrowLeft";
|
|
15
15
|
readonly right: "ArrowRight";
|
|
16
16
|
};
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
17
|
+
export type ArrowKeyButton = (typeof ArrowKeyButton)[keyof typeof ArrowKeyButton];
|
|
18
|
+
export type LabelProvider = 'toggleBold' | 'toggleItalics' | 'toggleBulletedList' | 'toggleNumberedList';
|
|
19
|
+
export type ToolbarButtonKey = keyof typeof ToolbarButton;
|
|
20
20
|
export interface UserMentionElements {
|
|
21
21
|
userMentionElement: RichTextMentionUsers;
|
|
22
22
|
mappingElements: MappingUser[];
|
|
@@ -7,7 +7,7 @@ export declare const TipTapNodeName: {
|
|
|
7
7
|
readonly bulletList: "bulletList";
|
|
8
8
|
readonly numberedList: "orderedList";
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type TipTapNodeName = (typeof TipTapNodeName)[keyof typeof TipTapNodeName];
|
|
11
11
|
export interface MentionExtensionConfig {
|
|
12
12
|
name: string;
|
|
13
13
|
key: string;
|
|
@@ -23,5 +23,5 @@ export interface MentionDetail {
|
|
|
23
23
|
displayName: string;
|
|
24
24
|
}
|
|
25
25
|
export declare const mentionPluginPrefix = "mention-plugin-";
|
|
26
|
-
export
|
|
27
|
-
export
|
|
26
|
+
export type ActiveMentionCommandEmitter = (command?: SuggestionProps['command']) => void;
|
|
27
|
+
export type ActiveMentionCharacterEmitter = (character: string) => void;
|
|
@@ -3,7 +3,7 @@ import { Validator, ValidityObject } from '../../../utilities/models/validator';
|
|
|
3
3
|
import type { MentionInternals } from './mention-internals';
|
|
4
4
|
export interface RichTextMentionValidity extends ValidityObject {
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
type FlagNames<T> = T extends readonly (infer U)[] ? U : never;
|
|
7
7
|
export declare const baseValidityFlagNames: readonly ["duplicateMappingMentionHref", "missingMentionHrefValue", "mentionHrefNotValidUrl", "mentionHrefDoesNotMatchPattern", "missingPatternAttribute", "unsupportedPatternValue"];
|
|
8
8
|
/**
|
|
9
9
|
* Validator for RichTextMention
|
|
@@ -6,5 +6,5 @@ import type { MappingConfig } from './models/mapping-config';
|
|
|
6
6
|
export interface MentionUpdateEventDetail {
|
|
7
7
|
filter: string;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
10
|
-
export
|
|
9
|
+
export type MappingConfigs = ReadonlyMap<string, MappingConfig>;
|
|
10
|
+
export type MentionUpdateEmitter = (filter: string) => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AnchoredRegion, ListboxOption, SelectPosition } from '@microsoft/fast-foundation';
|
|
2
|
-
import { DropdownAppearance } from '../patterns/dropdown/types';
|
|
2
|
+
import { DropdownAppearance, ListOptionOwner } from '../patterns/dropdown/types';
|
|
3
3
|
import type { ErrorPattern } from '../patterns/error/types';
|
|
4
|
+
import { ListOption } from '../list-option';
|
|
4
5
|
import { FilterMode } from './types';
|
|
5
6
|
import { FormAssociatedSelect } from './models/select-form-associated';
|
|
6
7
|
declare global {
|
|
@@ -8,11 +9,11 @@ declare global {
|
|
|
8
9
|
'nimble-select': Select;
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
+
type BooleanOrVoid = boolean | void;
|
|
12
13
|
/**
|
|
13
14
|
* A nimble-styled HTML select.
|
|
14
15
|
*/
|
|
15
|
-
export declare class Select extends FormAssociatedSelect implements ErrorPattern {
|
|
16
|
+
export declare class Select extends FormAssociatedSelect implements ErrorPattern, ListOptionOwner {
|
|
16
17
|
appearance: DropdownAppearance;
|
|
17
18
|
/**
|
|
18
19
|
* Reflects the placement for the listbox when the select is open.
|
|
@@ -212,6 +213,10 @@ export declare class Select extends FormAssociatedSelect implements ErrorPattern
|
|
|
212
213
|
formResetCallback(): void;
|
|
213
214
|
selectNextOption(): void;
|
|
214
215
|
selectPreviousOption(): void;
|
|
216
|
+
/**
|
|
217
|
+
* @internal
|
|
218
|
+
*/
|
|
219
|
+
registerOption(option: ListOption): void;
|
|
215
220
|
protected setSelectedOptions(): void;
|
|
216
221
|
protected focusAndScrollOptionIntoView(): void;
|
|
217
222
|
protected positionChanged(_: SelectPosition | undefined, next: SelectPosition | undefined): void;
|
package/dist/esm/select/index.js
CHANGED
|
@@ -466,6 +466,21 @@ export class Select extends FormAssociatedSelect {
|
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
|
+
/**
|
|
470
|
+
* @internal
|
|
471
|
+
*/
|
|
472
|
+
registerOption(option) {
|
|
473
|
+
if (this.options.includes(option)) {
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
// Adding an option to the end, ultimately, isn't the correct
|
|
477
|
+
// thing to do, as this will mean the option's index in the options,
|
|
478
|
+
// at least temporarily, does not match the DOM order. However, it
|
|
479
|
+
// is expected that a successive run of `slottedOptionsChanged` will
|
|
480
|
+
// correct this order issue. See 'https://github.com/ni/nimble/issues/1915'
|
|
481
|
+
// for more info.
|
|
482
|
+
this.options.push(option);
|
|
483
|
+
}
|
|
469
484
|
// Prevents parent classes from resetting selectedIndex to a positive
|
|
470
485
|
// value while filtering, which can result in a disabled option being
|
|
471
486
|
// selected.
|