@ni/nimble-components 29.4.0 → 29.4.1

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.
@@ -41,6 +41,7 @@ export declare class ListOption extends FoundationListboxOption {
41
41
  /** @internal */
42
42
  get elementTextContent(): string;
43
43
  connectedCallback(): void;
44
+ private getListOptionOwner;
44
45
  private isListOptionOwner;
45
46
  }
46
47
  export declare const listOptionTag = "nimble-list-option";
@@ -47,9 +47,18 @@ export class ListOption extends FoundationListboxOption {
47
47
  }
48
48
  connectedCallback() {
49
49
  super.connectedCallback();
50
- if (this.isListOptionOwner(this.parentElement)) {
51
- this.parentElement.registerOption(this);
50
+ const owner = this.getListOptionOwner();
51
+ owner?.registerOption(this);
52
+ }
53
+ getListOptionOwner() {
54
+ let parent = this.parentElement;
55
+ while (parent) {
56
+ if (this.isListOptionOwner(parent)) {
57
+ return parent;
58
+ }
59
+ parent = parent.parentElement;
52
60
  }
61
+ return undefined;
53
62
  }
54
63
  isListOptionOwner(parent) {
55
64
  if (!parent) {
@@ -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;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;;;;;;;WAOG;QAEI,iBAAY,GAAG,KAAK,CAAC;QAE5B,gBAAgB;QAET,gBAAW,GAAG,KAAK,CA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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 /**\n * @internal\n * This attribute is used to control the visual selected state of an option. This\n * is handled independently of the public 'selected' attribute, as 'selected' is\n * representative of the current value of the container control. However, while\n * a dropdown is open users can navigate through the options (requiring visual\n * updates) without changing the value of the container control.\n */\n @attr({ attribute: 'active-option', mode: 'boolean' })\n public activeOption = 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
+ {"version":3,"file":"index.js","sourceRo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,CAAC,MAAM,EAAE;YACT,OAAO,KAAK,CAAC;SAChB;QAED,OAAO,OAAQ,MAA0B,CAAC,cAAc,KAAK,UAAU,CAAC;IAC5E,CAAC;CACJ;AAhEmB;IADf,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;0CACK;AAUxB;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;kDAC1B;AAWvB;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;gDAC1B;AAIrB;IADN,UAAU;+CACgB;AAyC/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 /**\n * @internal\n * This attribute is used to control the visual selected state of an option. This\n * is handled independently of the public 'selected' attribute, as 'selected' is\n * representative of the current value of the container control. However, while\n * a dropdown is open users can navigate through the options (requiring visual\n * updates) without changing the value of the container control.\n */\n @attr({ attribute: 'active-option', mode: 'boolean' })\n public activeOption = 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 const owner = this.getListOptionOwner();\n owner?.registerOption(this);\n }\n\n private getListOptionOwner(): ListOptionOwner | undefined {\n let parent = this.parentElement;\n\n while (parent) {\n if (this.isListOptionOwner(parent)) {\n return parent;\n }\n\n parent = parent.parentElement;\n }\n\n return undefined;\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ni/nimble-components",
3
- "version": "29.4.0",
3
+ "version": "29.4.1",
4
4
  "description": "Styled web components for the NI Nimble Design System",
5
5
  "scripts": {
6
6
  "build": "npm run generate-icons && npm run generate-workers && npm run build-components && npm run bundle-components && npm run generate-scss",