# Class BasicWidget

This is the base widget for all other widgets.

For information on using widgets, see the tutorial {@tutorial widget_basics}.

#### Hierarchy (View Summary)

- TypedBasicWidget < default >
  - BasicWidget
    - NoteContextAwareWidget

- Defined in src/public/app/widgets/basic_widget.ts:260

##### Index

### Constructors

constructor

### Properties

_noteId
_position
$widget
attrs
children
componentId
initialized
parent?

### Accessors

position
sanitizedClassName

### Methods

callMethod
canBeShown
child
class
cleanup
collapsible
contentSized
css
cssBlock
doRender
filling
getClosestNtxId
getPosition
handleEvent
handleEventInChildren
id
isEnabled
isHiddenExt
isHiddenInt
isVisible
logRenderingError
optChild
optCss
remove
render
setParent
toggleExt
toggleInt
triggerCommand
triggerEvent

## Constructors

### constructor

- new BasicWidget(): BasicWidget

  #### Returns BasicWidget

  Inherited from TypedBasicWidget.constructor

  - Defined in src/public/app/widgets/basic_widget.ts:13

## Properties

### _noteId

_noteId: string

Inherited from TypedBasicWidget._noteId

- Defined in src/public/app/widgets/basic_widget.ts:11

### _position

_position: number

Inherited from TypedBasicWidget._position

- Defined in src/public/app/components/component.ts:21

### $widget

$widget: JQuery<HTMLElement>

Inherited from TypedBasicWidget.$widget

- Defined in src/public/app/components/component.ts:16

### `Protected` attrs

attrs: Record <string, string>

Inherited from TypedBasicWidget.attrs

- Defined in src/public/app/widgets/basic_widget.ts:7

### children

children: default []

Inherited from TypedBasicWidget.children

- Defined in src/public/app/components/component.ts:18

### componentId

componentId: string

Inherited from TypedBasicWidget.componentId

- Defined in src/public/app/components/component.ts:17

### initialized

initialized: null | Promise<void>

Inherited from TypedBasicWidget.initialized

- Defined in src/public/app/components/component.ts:19

### `Optional` parent

parent?: TypedComponent <any>

Inherited from TypedBasicWidget.parent

- Defined in src/public/app/components/component.ts:20

## Accessors

### position

- get position(): number

  #### Returns number

  Inherited from TypedBasicWidget.position

  - Defined in src/public/app/components/component.ts:34
- set position(newPosition: number): void

  #### Parameters

  - newPosition: number

  #### Returns void

  Inherited from TypedBasicWidget.position

  - Defined in src/public/app/components/component.ts:38

### sanitizedClassName

- get sanitizedClassName(): string

  #### Returns string

  Inherited from TypedBasicWidget.sanitizedClassName

  - Defined in src/public/app/components/component.ts:29

## Methods

### callMethod

- callMethod(
  fun: (arg: unknown) => Promise<unknown>,
  data: unknown,
  ): undefined | Promise<unknown>

  #### Parameters

  - fun: (arg: unknown) => Promise<unknown>
  - data: unknown

  #### Returns undefined | Promise<unknown>

  Inherited from TypedBasicWidget.callMethod

  - Defined in src/public/app/components/component.ts:105

### canBeShown

- canBeShown(): boolean

  #### Returns boolean

  Inherited from TypedBasicWidget.canBeShown

  - Defined in src/public/app/widgets/basic_widget.ts:226

### child

- child(...components: default []): BasicWidget

  #### Parameters

  - ...components: default []

  #### Returns BasicWidget

  Inherited from TypedBasicWidget.child

  - Defined in src/public/app/widgets/basic_widget.ts:25

### class

- class(className: string): BasicWidget

  #### Parameters

  - className: string

  #### Returns BasicWidget

  Inherited from TypedBasicWidget.class

  - Defined in src/public/app/widgets/basic_widget.ts:64

### cleanup

- cleanup(): void

  #### Returns void

  Inherited from TypedBasicWidget.cleanup

  - Defined in src/public/app/widgets/basic_widget.ts:252

### collapsible

- collapsible(): BasicWidget

  #### Returns BasicWidget

  Inherited from TypedBasicWidget.collapsible

  - Defined in src/public/app/widgets/basic_widget.ts:103

### contentSized

- contentSized(): BasicWidget

  #### Returns BasicWidget

  Inherited from TypedBasicWidget.contentSized

  - Defined in src/public/app/widgets/basic_widget.ts:97

### css

- css(name: string, value: string): BasicWidget

  Sets the CSS attribute of the given name to the given value.

  #### Parameters

  - name: string

    the name of the CSS attribute to set (e.g. `padding-left`).

  - value: string

    the value of the CSS attribute to set (e.g. `12px`).

  #### Returns BasicWidget

  self for chaining.

  Inherited from TypedBasicWidget.css

  - Defined in src/public/app/widgets/basic_widget.ts:76

### cssBlock

- cssBlock(block: string): BasicWidget

  Accepts a string of CSS to add with the widget.

  #### Parameters

  - block: string

  #### Returns BasicWidget

  for chaining

  Inherited from TypedBasicWidget.cssBlock

  - Defined in src/public/app/widgets/basic_widget.ts:118

### doRender

- doRender(): void

  Method used for rendering the widget.

  Your class should override this method. The method is expected to create a this.$widget containing jQuery object

  #### Returns void

  Inherited from TypedBasicWidget.doRender

  - Defined in src/public/app/widgets/basic_widget.ts:206

### filling

- filling(): BasicWidget

  #### Returns BasicWidget

  Inherited from TypedBasicWidget.filling

  - Defined in src/public/app/widgets/basic_widget.ts:109

### getClosestNtxId

- getClosestNtxId(): undefined | null | string

  #### Returns undefined | null | string

  Inherited from TypedBasicWidget.getClosestNtxId

  - Defined in src/public/app/widgets/basic_widget.ts:244

### getPosition

- getPosition(): number

  #### Returns number

  Inherited from TypedBasicWidget.getPosition

  - Defined in src/public/app/widgets/basic_widget.ts:234

### handleEvent

- handleEvent< T extends EventNames >(
  name: T ,
  data: EventData < T >,
  ): undefined | null | Promise<unknown>

  #### Type Parameters

  - T extends EventNames

  #### Parameters

  - name: T
  - data: EventData < T >

  #### Returns undefined | null | Promise<unknown>

  Inherited from TypedBasicWidget.handleEvent

  - Defined in src/public/app/components/component.ts:57

### handleEventInChildren

- handleEventInChildren< T extends EventNames >(
  name: T ,
  data: EventData < T >,
  ): null | Promise<unknown>

  #### Type Parameters

  - T extends EventNames

  #### Parameters

  - name: T
  - data: EventData < T >

  #### Returns null | Promise<unknown>

  Inherited from TypedBasicWidget.handleEventInChildren

  - Defined in src/public/app/components/component.ts:76

### id

- id(id: string): BasicWidget

  #### Parameters

  - id: string

  #### Returns BasicWidget

  Inherited from TypedBasicWidget.id

  - Defined in src/public/app/widgets/basic_widget.ts:59

### isEnabled

- isEnabled(): undefined | null | boolean

  Indicates if the widget is enabled. Widgets are enabled by default. Generally setting this to `false` will cause the widget not to be displayed, however it will still be available on the DOM but hidden.

  #### Returns undefined | null | boolean

  whether the widget is enabled.

  Inherited from TypedBasicWidget.isEnabled

  - Defined in src/public/app/widgets/basic_widget.ts:196

### isHiddenExt

- isHiddenExt(): boolean

  #### Returns boolean

  Inherited from TypedBasicWidget.isHiddenExt

  - Defined in src/public/app/widgets/basic_widget.ts:222

### isHiddenInt

- isHiddenInt(): boolean

  #### Returns boolean

  Inherited from TypedBasicWidget.isHiddenInt

  - Defined in src/public/app/widgets/basic_widget.ts:213

### isVisible

- isVisible(): boolean

  #### Returns boolean

  Inherited from TypedBasicWidget.isVisible

  - Defined in src/public/app/widgets/basic_widget.ts:230

### logRenderingError

- logRenderingError(e: Error): void

  #### Parameters

  - e: Error

  #### Returns void

  Inherited from TypedBasicWidget.logRenderingError

  - Defined in src/public/app/widgets/basic_widget.ts:163

### optChild

- optChild(condition: boolean, ...components: default []): BasicWidget

  Conditionally adds the given components as children to this component.

  #### Parameters

  - condition: boolean

    whether to add the components.

  - ...components: default []

    the components to be added as children to this component provided the condition is truthy.

  #### Returns BasicWidget

  self for chaining.

  Inherited from TypedBasicWidget.optChild

  - Defined in src/public/app/widgets/basic_widget.ts:51

### optCss

- optCss(condition: boolean, name: string, value: string): BasicWidget

  Sets the CSS attribute of the given name to the given value, but only if the condition provided is truthy.

  #### Parameters

  - condition: boolean

    `true` in order to apply the CSS, `false` to ignore it.

  - name: string

    the name of the CSS attribute to set (e.g. `padding-left`).

  - value: string

    the value of the CSS attribute to set (e.g. `12px`).

  #### Returns BasicWidget

  self for chaining.

  Inherited from TypedBasicWidget.optCss

  - Defined in src/public/app/widgets/basic_widget.ts:89

### remove

- remove(): void

  #### Returns void

  Inherited from TypedBasicWidget.remove

  - Defined in src/public/app/widgets/basic_widget.ts:238

### render

- render(): JQuery<HTMLElement>

  #### Returns JQuery<HTMLElement>

  Inherited from TypedBasicWidget.render

  - Defined in src/public/app/widgets/basic_widget.ts:123

### setParent

- setParent(parent: TypedComponent <any>): BasicWidget

  #### Parameters

  - parent: TypedComponent <any>

  #### Returns BasicWidget

  Inherited from TypedBasicWidget.setParent

  - Defined in src/public/app/components/component.ts:42

### toggleExt

- toggleExt(show: undefined | null | boolean | ""): void

  #### Parameters

  - show: undefined | null | boolean | ""

  #### Returns void

  Inherited from TypedBasicWidget.toggleExt

  - Defined in src/public/app/widgets/basic_widget.ts:217

### toggleInt

- toggleInt(show: undefined | null | boolean): void

  #### Parameters

  - show: undefined | null | boolean

  #### Returns void

  Inherited from TypedBasicWidget.toggleInt

  - Defined in src/public/app/widgets/basic_widget.ts:208

### triggerCommand

- triggerCommand< K extends keyof CommandMappings >(
  name: K ,
  data?: CommandMappings [ K ],
  ): undefined | null | Promise<unknown>

  #### Type Parameters

  - K extends keyof CommandMappings

  #### Parameters

  - name: K
  - `Optional` data: CommandMappings [ K ]

  #### Returns undefined | null | Promise<unknown>

  Inherited from TypedBasicWidget.triggerCommand

  - Defined in src/public/app/components/component.ts:91

### triggerEvent

- triggerEvent< T extends EventNames >(
  name: T ,
  data: EventData < T >,
  ): undefined | null | Promise<unknown>

  #### Type Parameters

  - T extends EventNames

  #### Parameters

  - name: T
  - data: EventData < T >

  #### Returns undefined | null | Promise<unknown>

  Inherited from TypedBasicWidget.triggerEvent

  - Defined in src/public/app/components/component.ts:72