-
Notifications
You must be signed in to change notification settings - Fork 1
KTNB-1205: Support Jupyter Widgets #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ileasile
wants to merge
58
commits into
master
Choose a base branch
from
ktnb-1205
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+21,860
−21
Open
Changes from 33 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
5b8bcbc
KTNB-1205: Support Jupyter Widgets - platform and 5 kinds of widgets
ileasile 70494cb
KTNB-1205: Extract widget factory management into `WidgetFactoryRegis…
ileasile bdce718
KTNB-1205: Refactor widget initialization to use WidgetFactoryRegistr…
ileasile 2168f29
KTNB-1205: Pass `WidgetManager` as a constructor parameter to WidgetM…
ileasile 5260224
KTNB-1205: Extract WidgetManager interface
ileasile 1a48b5d
KTNB-1205: Add separate integration module and README
ileasile 05f6492
KTNB-1205: Fix bugs according to codex review
ileasile 3dcdcd9
KTNB-1205: Fix bugs according to codex review
ileasile a59a70f
KTNB-1205: Add generator module and schema
ileasile 8d1952d
KTNB-1205: Replace handwritten widget definitions with generated widg…
ileasile 160bd40
KTNB-1205: Refactor widget generation to improve clarity, consistency…
ileasile e44a392
KTNB-1205: Replace widget-specific enums with generated reusable enum…
ileasile 39f3627
KTNB-1205: Add detailed property descriptions to widget definitions a…
ileasile 6c50e95
KTNB-1205: Refactor widget generator to modularize property type hand…
ileasile 5592116
KTNB-1205: Remove unused widget specs and related functions, clean up…
ileasile 61cea02
KTNB-1205: Add widgets-tests module with tests for widget comm messag…
ileasile 9da020d
KTNB-1205: Add tests for widget state updates, buffer handling, and c…
ileasile 5c0f7e2
KTNB-1205: Add tests for widget display serialization and validation …
ileasile 85a5ccc
KTNB-1205: Import enum package by default
ileasile 9539119
KTNB-1205: Add tests for primitive type serialization/deserialization…
ileasile be4d6d9
KTNB-1205: Handle missing widget ID during serialization in WidgetRef…
ileasile 8b2c734
KTNB-1205: Refactor widget state synchronization to distinguish front…
ileasile efae388
KTNB-1205: Update widgets to distinguish frontend-initialized and bac…
ileasile a4cde0f
KTNB-1205: Make layout and style properties nullable, update widget p…
ileasile 4d3620b
KTNB-1205: Transition to nullable property initialization for primiti…
ileasile da7cf38
KTNB-1205: Update dependencies for widgets modules to use `api` where…
ileasile 3c3734c
KTNB-1205: Add `echoUpdate` support for selective property updates; i…
ileasile 06ae94d
KTNB-1205: Refactor widget tests to use helper methods for event asse…
ileasile b6c6e4c
KTNB-1205: Support `Number` type for `step` property in `TimeWidget` …
ileasile 4dd9c4a
KTNB-1205: Refactor widget property handling to use specialized nulla…
ileasile 7366b2b
KTNB-1205: Update widgets README to include new modules, add developm…
ileasile 663d774
KTNB-1205: Remove widget references on comm close to prevent memory l…
ileasile 458ccf5
KTNB-1205: Introduce union types for widget properties, refactor prop…
ileasile c49593c
KTNB-1205: Add support for sending and receiving custom messages in w…
ileasile dade110
KTNB-1205: Update widget version handling to include patch version, u…
ileasile 99d7451
KTNB-1205: Fix widget version inconsistency by using `viewModuleVersi…
ileasile 09ca3e2
KTNB-1205: Replace `error` with `throw NotImplementedError` for excep…
ileasile 2cd3f98
added widgets.ipynb example notebook similar to the ipwidgets example…
Jolanrensen 0df0c77
KTNB-1205: Refactor `BufferPathsSerializer` to handle only `Int` for …
ileasile 55722a5
KTNB-1205: Reformat `NotebookTests` and `.editorconfig` for consisten…
ileasile 7c99586
Update misc.xml with Project JDK settings
ileasile 061c15e
KTNB-1205: Remove unused `byMap` and `stopAfter` functions in `Notebo…
ileasile 98adede
Add suppression for EditorConfig key correctness inspections in `.edi…
ileasile 6d6ad5b
Remove reference to the deleted widget
ileasile 92f522b
KTNB-1205: Add more possibilities for manual amending of generated en…
ileasile 7b39095
KTNB-1205: Add `IntRange` and `ClosedRange<Double>` and `PairType` su…
ileasile c582a9a
Add `setup` lambda to widget creation methods for customization
ileasile 762d797
KTNB-1205: Non-nullable types by default for array elements, base for…
ileasile d813b1f
KTNB-1205: Move options package
ileasile 0752dc1
KTNB-1205: Add docs
ileasile 973b1a6
KTNB-1205: Add more docs
ileasile 08c402c
KTNB-1205: Add test for outputs
ileasile 6bddf03
KTNB-1205: Structure tests
ileasile 35d4db7
KTNB-1205: Refactor widget naming, improve case conversion, and add r…
ileasile daf6350
KTNB-1205: Add missing newlines to auto-generated widget properties f…
ileasile d4930e7
KTNB-1205: Expand widget usage documentation with examples
ileasile 8bc4e6d
KTNB-1205: Add `linkProperties` & `getProperty` utilities with tests
ileasile a1cd4ef
KTNB-1205: Extend `linkProperties` API with overloads
ileasile File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| [](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub) | ||
| [](https://kotlinlang.org/docs/components-stability.html) | ||
|
|
||
| # Kotlin Notebook Widgets Integration | ||
|
|
||
| This integration provides a collection of interactive widgets for Kotlin Notebooks, such as sliders, labels, and more. It allows you to create a richer, more interactive experience within your notebooks. | ||
|
|
||
| ## Usage | ||
|
|
||
| Use this API through the `%use widgets` magic command in a Kotlin Notebook. | ||
|
|
||
| ```kotlin | ||
| %use widgets | ||
|
|
||
| val slider = intSliderWidget().apply { | ||
| min = 0 | ||
| max = 100 | ||
| value = 50 | ||
| description = "Select a value:" | ||
| } | ||
|
|
||
| val label = labelWidget().apply { | ||
| value = "Current value: ${slider.value}" | ||
| } | ||
|
|
||
| // Display the slider | ||
| slider | ||
| ``` | ||
|
|
||
| ## Module structure | ||
|
|
||
| This project consists of the following modules: | ||
|
|
||
| - `widgets-api`: Contains the core widget implementations, protocols, and model definitions. | ||
| - `widgets-jupyter`: Provides the integration logic and useful helpers for Kotlin Jupyter notebooks. | ||
| - `widgets-generator`: Generates widget models from `schema.json`. | ||
| - `widgets-tests`: Contains integration tests for widgets. | ||
|
|
||
| ## Development | ||
|
|
||
| Most widgets are automatically generated from a schema. | ||
| To regenerate widgets after changing `schema.json` or the generator itself, run: | ||
|
|
||
| ```bash | ||
| ./gradlew :integrations:widgets:widgets-generator:generateWidgets | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import org.jetbrains.kotlinx.publisher.apache2 | ||
| import org.jetbrains.kotlinx.publisher.githubRepo | ||
|
|
||
| plugins { | ||
| alias(libs.plugins.publisher) | ||
| } | ||
|
|
||
| kotlinPublications { | ||
| pom { | ||
| githubRepo("Kotlin", "kotlin-notebook-integrations") | ||
| inceptionYear = "2025" | ||
| licenses { | ||
| apache2() | ||
| } | ||
| developers { | ||
| developer { | ||
| id.set("kotlin-jupyter-team") | ||
| name.set("Kotlin Jupyter Team") | ||
| organization.set("JetBrains") | ||
| organizationUrl.set("https://www.jetbrains.com") | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| plugins { | ||
| alias(libs.plugins.kotlin.jvm) | ||
| alias(libs.plugins.publisher) | ||
| alias(libs.plugins.kotlin.serialization) | ||
| alias(libs.plugins.kotlin.jupyter.api) | ||
| } | ||
|
|
||
| dependencies { | ||
| api(libs.kotlinx.serialization.json) | ||
| implementation(libs.kotlin.reflect) | ||
|
|
||
| testImplementation(libs.kotlin.test) | ||
| testImplementation(libs.test.kotlintest.assertions) | ||
| testImplementation(libs.kotlinx.serialization.json) | ||
| } | ||
|
|
||
| tasks.test { | ||
| useJUnitPlatform() | ||
| } | ||
|
|
||
| kotlin { | ||
| jvmToolchain( | ||
| libs.versions.jvm.toolchain | ||
| .get() | ||
| .toInt(), | ||
| ) | ||
| explicitApi() | ||
| } | ||
|
|
||
| sourceSets { | ||
| main { | ||
| kotlin.srcDir("src/generated/kotlin") | ||
| } | ||
| } | ||
|
|
||
| kotlinPublications { | ||
| publication { | ||
| description.set("Kotlin APIs for IPython Widgets") | ||
| } | ||
| } | ||
52 changes: 52 additions & 0 deletions
52
...-api/src/generated/kotlin/org/jetbrains/kotlinx/jupyter/widget/library/AccordionWidget.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // Generated by widgets-generator. Do not edit manually. | ||
| package org.jetbrains.kotlinx.jupyter.widget.library | ||
|
|
||
| import org.jetbrains.kotlinx.jupyter.widget.WidgetManager | ||
| import org.jetbrains.kotlinx.jupyter.widget.library.enums.BoxStyle | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.DefaultWidgetFactory | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.DefaultWidgetModel | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.WidgetModel | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.WidgetSpec | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.createAndRegisterWidget | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.compound.ArrayType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.compound.NullableType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.enums.WidgetEnumEntry | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.enums.WidgetEnumType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.primitive.BooleanType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.primitive.IntType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.primitive.StringType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.widget.WidgetReferenceType | ||
|
|
||
| private val accordionSpec = WidgetSpec( | ||
| modelName = "AccordionModel", | ||
| modelModule = "@jupyter-widgets/controls", | ||
| modelModuleVersion = "2.0.0", | ||
| viewName = "AccordionView", | ||
| viewModule = "@jupyter-widgets/controls", | ||
| viewModuleVersion = "2.0.0", | ||
| ) | ||
|
|
||
| public fun WidgetManager.accordion(): AccordionWidget = createAndRegisterWidget(AccordionWidget.Factory) | ||
|
|
||
| public class AccordionWidget internal constructor( | ||
| widgetManager: WidgetManager, | ||
| fromFrontend: Boolean, | ||
| ) : DefaultWidgetModel(accordionSpec, widgetManager) { | ||
| internal object Factory : DefaultWidgetFactory<AccordionWidget>(accordionSpec, ::AccordionWidget) | ||
|
|
||
| /** CSS classes applied to widget DOM element */ | ||
| public var domClasses: List<String?> by prop("_dom_classes", ArrayType(NullableType(StringType)), emptyList()) | ||
| /** Use a predefined styling for the box. */ | ||
| public var boxStyle: WidgetEnumEntry<BoxStyle> by prop("box_style", WidgetEnumType(BoxStyle, BoxStyle.Default), BoxStyle.Default) | ||
| /** List of widget children */ | ||
| public var children: List<WidgetModel?> by prop("children", ArrayType(NullableType(WidgetReferenceType<WidgetModel>())), emptyList()) | ||
| public var layout: LayoutWidget? by nullableWidgetProp("layout", if (fromFrontend) null else widgetManager.layout()) | ||
| /** The index of the selected page. This is either an integer selecting a particular sub-widget, or None to have no widgets selected. */ | ||
| public var selectedIndex: Int? by nullableIntProp("selected_index", null) | ||
| /** Is widget tabbable? */ | ||
| public var tabbable: Boolean? by nullableBoolProp("tabbable", null) | ||
| /** Titles of the pages */ | ||
| public var titles: List<String?> by prop("titles", ArrayType(NullableType(StringType)), emptyList()) | ||
| /** A tooltip caption. */ | ||
| public var tooltip: String? by nullableStringProp("tooltip", null) | ||
| } |
50 changes: 50 additions & 0 deletions
50
...gets-api/src/generated/kotlin/org/jetbrains/kotlinx/jupyter/widget/library/AudioWidget.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // Generated by widgets-generator. Do not edit manually. | ||
| package org.jetbrains.kotlinx.jupyter.widget.library | ||
|
|
||
| import org.jetbrains.kotlinx.jupyter.widget.WidgetManager | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.DefaultWidgetFactory | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.DefaultWidgetModel | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.WidgetSpec | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.createAndRegisterWidget | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.compound.ArrayType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.compound.NullableType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.primitive.BooleanType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.primitive.BytesType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.primitive.StringType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.widget.WidgetReferenceType | ||
|
|
||
| private val audioSpec = WidgetSpec( | ||
| modelName = "AudioModel", | ||
| modelModule = "@jupyter-widgets/controls", | ||
| modelModuleVersion = "2.0.0", | ||
| viewName = "AudioView", | ||
| viewModule = "@jupyter-widgets/controls", | ||
| viewModuleVersion = "2.0.0", | ||
| ) | ||
|
|
||
| public fun WidgetManager.audio(): AudioWidget = createAndRegisterWidget(AudioWidget.Factory) | ||
|
|
||
| public class AudioWidget internal constructor( | ||
| widgetManager: WidgetManager, | ||
| fromFrontend: Boolean, | ||
| ) : DefaultWidgetModel(audioSpec, widgetManager) { | ||
| internal object Factory : DefaultWidgetFactory<AudioWidget>(audioSpec, ::AudioWidget) | ||
|
|
||
| /** CSS classes applied to widget DOM element */ | ||
| public var domClasses: List<String?> by prop("_dom_classes", ArrayType(NullableType(StringType)), emptyList()) | ||
| /** When true, the audio starts when it's displayed */ | ||
| public var autoplay: Boolean by boolProp("autoplay", true) | ||
| /** Specifies that audio controls should be displayed (such as a play/pause button etc) */ | ||
| public var controls: Boolean by boolProp("controls", true) | ||
| /** The format of the audio. */ | ||
| public var format: String by stringProp("format", "mp3") | ||
| public var layout: LayoutWidget? by nullableWidgetProp("layout", if (fromFrontend) null else widgetManager.layout()) | ||
| /** When true, the audio will start from the beginning after finishing */ | ||
| public var loop: Boolean by boolProp("loop", true) | ||
| /** Is widget tabbable? */ | ||
| public var tabbable: Boolean? by nullableBoolProp("tabbable", null) | ||
| /** A tooltip caption. */ | ||
| public var tooltip: String? by nullableStringProp("tooltip", null) | ||
| /** The media data as a memory view of bytes. */ | ||
| public var value: ByteArray by bytesProp("value", byteArrayOf()) | ||
| } |
58 changes: 58 additions & 0 deletions
58
...c/generated/kotlin/org/jetbrains/kotlinx/jupyter/widget/library/BoundedFloatTextWidget.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // Generated by widgets-generator. Do not edit manually. | ||
| package org.jetbrains.kotlinx.jupyter.widget.library | ||
|
|
||
| import org.jetbrains.kotlinx.jupyter.widget.WidgetManager | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.DefaultWidgetFactory | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.DefaultWidgetModel | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.WidgetSpec | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.createAndRegisterWidget | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.compound.ArrayType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.compound.NullableType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.primitive.BooleanType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.primitive.FloatType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.primitive.StringType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.widget.WidgetReferenceType | ||
|
|
||
| private val boundedFloatTextSpec = WidgetSpec( | ||
| modelName = "BoundedFloatTextModel", | ||
| modelModule = "@jupyter-widgets/controls", | ||
| modelModuleVersion = "2.0.0", | ||
| viewName = "FloatTextView", | ||
| viewModule = "@jupyter-widgets/controls", | ||
| viewModuleVersion = "2.0.0", | ||
| ) | ||
|
|
||
| public fun WidgetManager.boundedFloatText(): BoundedFloatTextWidget = createAndRegisterWidget(BoundedFloatTextWidget.Factory) | ||
|
|
||
| public class BoundedFloatTextWidget internal constructor( | ||
| widgetManager: WidgetManager, | ||
| fromFrontend: Boolean, | ||
| ) : DefaultWidgetModel(boundedFloatTextSpec, widgetManager) { | ||
| internal object Factory : DefaultWidgetFactory<BoundedFloatTextWidget>(boundedFloatTextSpec, ::BoundedFloatTextWidget) | ||
|
|
||
| /** CSS classes applied to widget DOM element */ | ||
| public var domClasses: List<String?> by prop("_dom_classes", ArrayType(NullableType(StringType)), emptyList()) | ||
| /** Update the value as the user types. If False, update on submission, e.g., pressing Enter or navigating away. */ | ||
| public var continuousUpdate: Boolean by boolProp("continuous_update", false) | ||
| /** Description of the control. */ | ||
| public var description: String by stringProp("description", "") | ||
| /** Accept HTML in the description. */ | ||
| public var descriptionAllowHtml: Boolean by boolProp("description_allow_html", false) | ||
| /** Enable or disable user changes */ | ||
| public var disabled: Boolean by boolProp("disabled", false) | ||
| public var layout: LayoutWidget? by nullableWidgetProp("layout", if (fromFrontend) null else widgetManager.layout()) | ||
| /** Max value */ | ||
| public var max: Double by doubleProp("max", 100.0) | ||
| /** Min value */ | ||
| public var min: Double by doubleProp("min", 0.0) | ||
| /** Minimum step to increment the value */ | ||
| public var step: Double? by nullableDoubleProp("step", null) | ||
| /** Styling customizations */ | ||
| public var style: DescriptionStyleWidget? by nullableWidgetProp("style", if (fromFrontend) null else widgetManager.descriptionStyle()) | ||
| /** Is widget tabbable? */ | ||
| public var tabbable: Boolean? by nullableBoolProp("tabbable", null) | ||
| /** A tooltip caption. */ | ||
| public var tooltip: String? by nullableStringProp("tooltip", null) | ||
| /** Float value */ | ||
| public var value: Double by doubleProp("value", 0.0) | ||
| } |
58 changes: 58 additions & 0 deletions
58
...src/generated/kotlin/org/jetbrains/kotlinx/jupyter/widget/library/BoundedIntTextWidget.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // Generated by widgets-generator. Do not edit manually. | ||
| package org.jetbrains.kotlinx.jupyter.widget.library | ||
|
|
||
| import org.jetbrains.kotlinx.jupyter.widget.WidgetManager | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.DefaultWidgetFactory | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.DefaultWidgetModel | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.WidgetSpec | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.createAndRegisterWidget | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.compound.ArrayType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.compound.NullableType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.primitive.BooleanType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.primitive.IntType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.primitive.StringType | ||
| import org.jetbrains.kotlinx.jupyter.widget.model.types.widget.WidgetReferenceType | ||
|
|
||
| private val boundedIntTextSpec = WidgetSpec( | ||
| modelName = "BoundedIntTextModel", | ||
| modelModule = "@jupyter-widgets/controls", | ||
| modelModuleVersion = "2.0.0", | ||
| viewName = "IntTextView", | ||
| viewModule = "@jupyter-widgets/controls", | ||
| viewModuleVersion = "2.0.0", | ||
| ) | ||
|
|
||
| public fun WidgetManager.boundedIntText(): BoundedIntTextWidget = createAndRegisterWidget(BoundedIntTextWidget.Factory) | ||
|
|
||
| public class BoundedIntTextWidget internal constructor( | ||
| widgetManager: WidgetManager, | ||
| fromFrontend: Boolean, | ||
| ) : DefaultWidgetModel(boundedIntTextSpec, widgetManager) { | ||
| internal object Factory : DefaultWidgetFactory<BoundedIntTextWidget>(boundedIntTextSpec, ::BoundedIntTextWidget) | ||
|
|
||
| /** CSS classes applied to widget DOM element */ | ||
| public var domClasses: List<String?> by prop("_dom_classes", ArrayType(NullableType(StringType)), emptyList()) | ||
| /** Update the value as the user types. If False, update on submission, e.g., pressing Enter or navigating away. */ | ||
| public var continuousUpdate: Boolean by boolProp("continuous_update", false) | ||
| /** Description of the control. */ | ||
| public var description: String by stringProp("description", "") | ||
| /** Accept HTML in the description. */ | ||
| public var descriptionAllowHtml: Boolean by boolProp("description_allow_html", false) | ||
| /** Enable or disable user changes */ | ||
| public var disabled: Boolean by boolProp("disabled", false) | ||
| public var layout: LayoutWidget? by nullableWidgetProp("layout", if (fromFrontend) null else widgetManager.layout()) | ||
| /** Max value */ | ||
| public var max: Int by intProp("max", 100) | ||
| /** Min value */ | ||
| public var min: Int by intProp("min", 0) | ||
| /** Minimum step to increment the value */ | ||
| public var step: Int by intProp("step", 1) | ||
| /** Styling customizations */ | ||
| public var style: DescriptionStyleWidget? by nullableWidgetProp("style", if (fromFrontend) null else widgetManager.descriptionStyle()) | ||
| /** Is widget tabbable? */ | ||
| public var tabbable: Boolean? by nullableBoolProp("tabbable", null) | ||
| /** A tooltip caption. */ | ||
| public var tooltip: String? by nullableStringProp("tooltip", null) | ||
| /** Int value */ | ||
| public var value: Int by intProp("value", 0) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new widgets-api module imports Jupyter API types such as
DisplayResultandCommManager(seeWidgetManagerImpl.kt), but its build file never adds the Kotlin Jupyter API dependency or callskotlinJupyter { addApiDependency() }the way other integrations do (e.g., http-util/ktor-client). With only serialization and reflect on the classpath, these imports will be unresolved and the module will not compile. Please add the kotlin-jupyter API dependency to this module (and transitively for widgets-jupyter/tests) so the code can build.Useful? React with 👍 / 👎.