@difizen/libro-widget 0.0.0-snapshot-20241017072317

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present Difizen Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # libro-widget
package/es/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './module.js';
2
+ export * from './slider/index.js';
3
+ export * from './text/index.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
package/es/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./module.js";
2
+ export * from "./slider/index.js";
3
+ export * from "./text/index.js";
package/es/module.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { ManaModule } from '@difizen/mana-app';
2
+ export declare const CommonWidgetsModule: ManaModule;
3
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C,eAAO,MAAM,mBAAmB,YAQP,CAAC"}
package/es/module.js ADDED
@@ -0,0 +1,5 @@
1
+ import { WidgetModule } from '@difizen/libro-jupyter';
2
+ import { ManaModule } from '@difizen/mana-app';
3
+ import { SilderWidgetContribution, SliderWidget } from "./slider/index.js";
4
+ import { TextModelContribution, TextWidget } from "./text/index.js";
5
+ export var CommonWidgetsModule = ManaModule.create().register(SliderWidget, SilderWidgetContribution, TextWidget, TextModelContribution).dependOn(WidgetModule);
@@ -0,0 +1,10 @@
1
+ import type { IWidgetViewProps } from '@difizen/libro-jupyter';
2
+ import { WidgetViewContribution } from '@difizen/libro-jupyter';
3
+ import { ViewManager } from '@difizen/mana-app';
4
+ import { SliderWidget } from './view.js';
5
+ export declare class SilderWidgetContribution implements WidgetViewContribution {
6
+ viewManager: ViewManager;
7
+ canHandle: (attributes: any) => 1 | 100;
8
+ factory(props: IWidgetViewProps): Promise<SliderWidget>;
9
+ }
10
+ //# sourceMappingURL=contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contribution.d.ts","sourceRoot":"","sources":["../../src/slider/contribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,qBACa,wBAAyB,YAAW,sBAAsB;IAChD,WAAW,EAAE,WAAW,CAAC;IAC9C,SAAS,eAAgB,GAAG,aAW1B;IACF,OAAO,CAAC,KAAK,EAAE,gBAAgB;CAGhC"}
@@ -0,0 +1,45 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _dec, _dec2, _class, _class2, _descriptor;
3
+ function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
4
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
6
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
8
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
10
+ function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
11
+ import { WidgetViewContribution } from '@difizen/libro-jupyter';
12
+ import { ViewManager, inject, singleton } from '@difizen/mana-app';
13
+ import { SliderWidget } from "./view.js";
14
+ export var SilderWidgetContribution = (_dec = singleton({
15
+ contrib: WidgetViewContribution
16
+ }), _dec2 = inject(ViewManager), _dec(_class = (_class2 = /*#__PURE__*/function () {
17
+ function SilderWidgetContribution() {
18
+ _classCallCheck(this, SilderWidgetContribution);
19
+ _initializerDefineProperty(this, "viewManager", _descriptor, this);
20
+ this.canHandle = function (attributes) {
21
+ if (attributes._model_name === 'IntSliderModel') {
22
+ return 100;
23
+ }
24
+ if (attributes.__view_name === 'IntSliderView') {
25
+ return 100;
26
+ }
27
+ if (attributes._model_name === 'FloatSliderModel') {
28
+ return 100;
29
+ }
30
+ return 1;
31
+ };
32
+ }
33
+ _createClass(SilderWidgetContribution, [{
34
+ key: "factory",
35
+ value: function factory(props) {
36
+ return this.viewManager.getOrCreateView(SliderWidget, props);
37
+ }
38
+ }]);
39
+ return SilderWidgetContribution;
40
+ }(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "viewManager", [_dec2], {
41
+ configurable: true,
42
+ enumerable: true,
43
+ writable: true,
44
+ initializer: null
45
+ })), _class2)) || _class);
@@ -0,0 +1,3 @@
1
+ export * from './contribution.js';
2
+ export * from './view.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/slider/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./contribution.js";
2
+ export * from "./view.js";
@@ -0,0 +1,3 @@
1
+ .libro-widget-slider {
2
+ display: block;
3
+ }
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" resolution-mode="require"/>
2
+ import type { JSONObject } from '@difizen/libro-common';
3
+ import { LibroContextKey } from '@difizen/libro-core';
4
+ import type { IWidgetViewProps } from '@difizen/libro-jupyter';
5
+ import type { OrientableState, WidgetState } from '@difizen/libro-jupyter';
6
+ import { WidgetView } from '@difizen/libro-jupyter';
7
+ import './index.less';
8
+ export declare const LibroWidgetIntSliderComponent: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
9
+ interface SliderState extends WidgetState, OrientableState {
10
+ max?: number;
11
+ min?: number;
12
+ step: number;
13
+ value: number;
14
+ }
15
+ export declare class SliderWidget extends WidgetView {
16
+ view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
17
+ state: JSONObject & SliderState;
18
+ constructor(props: IWidgetViewProps, libroContextKey: LibroContextKey);
19
+ protected initialize(props: IWidgetViewProps): void;
20
+ handleChange: (value: number) => void;
21
+ }
22
+ export {};
23
+ //# sourceMappingURL=view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/slider/view.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAcpD,OAAO,cAAc,CAAC;AAEtB,eAAO,MAAM,6BAA6B,0FAqBzC,CAAC;AAEF,UAAU,WAAY,SAAQ,WAAW,EAAE,eAAe;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAEa,YAAa,SAAQ,UAAU;IACjC,IAAI,2FAAiC;IAGrC,KAAK,EAAE,UAAU,GAAG,WAAW,CAKtC;gBAGoB,KAAK,EAAE,gBAAgB,EAClB,eAAe,EAAE,eAAe;IAM3D,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAYnD,YAAY,UAAW,MAAM,UAO3B;CACH"}
@@ -0,0 +1,97 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _dec, _dec2, _dec3, _class, _class2, _descriptor;
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
7
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
9
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
11
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
12
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
13
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
14
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
15
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
16
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
17
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
18
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
19
+ function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
20
+ function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
21
+ import { LibroContextKey } from '@difizen/libro-core';
22
+ import { WidgetView } from '@difizen/libro-jupyter';
23
+ import { defaultWidgetState } from '@difizen/libro-jupyter';
24
+ import { view, transient, useInject, ViewInstance, prop, inject, ViewOption } from '@difizen/mana-app';
25
+ import { Slider } from 'antd';
26
+ import { forwardRef } from 'react';
27
+ import "./index.less";
28
+ import { jsx as _jsx } from "react/jsx-runtime";
29
+ export var LibroWidgetIntSliderComponent = /*#__PURE__*/forwardRef(function LibroWidgetIntSliderComponent(props, ref) {
30
+ var widget = useInject(ViewInstance);
31
+ if (widget.isCommClosed) {
32
+ return null;
33
+ }
34
+ return /*#__PURE__*/_jsx("div", {
35
+ className: "libro-widget-slider",
36
+ ref: ref,
37
+ children: /*#__PURE__*/_jsx(Slider, {
38
+ max: widget.state.max,
39
+ min: widget.state.min,
40
+ vertical: widget.state.orientation === 'vertical',
41
+ disabled: widget.state.disabled,
42
+ onChange: widget.handleChange,
43
+ value: widget.state.value
44
+ })
45
+ });
46
+ });
47
+ export var SliderWidget = (_dec = transient(), _dec2 = view('libro-widget-slider-view'), _dec3 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_WidgetView) {
48
+ _inherits(SliderWidget, _WidgetView);
49
+ var _super = _createSuper(SliderWidget);
50
+ function SliderWidget(props, libroContextKey) {
51
+ var _this;
52
+ _classCallCheck(this, SliderWidget);
53
+ _this = _super.call(this, props, libroContextKey);
54
+ _this.view = LibroWidgetIntSliderComponent;
55
+ _initializerDefineProperty(_this, "state", _descriptor, _assertThisInitialized(_this));
56
+ _this.handleChange = function (value) {
57
+ var data = {
58
+ buffer_paths: [],
59
+ method: 'update',
60
+ state: {
61
+ value: value
62
+ }
63
+ };
64
+ _this.send(data);
65
+ };
66
+ _this.initialize(props);
67
+ return _this;
68
+ }
69
+ SliderWidget = inject(LibroContextKey)(SliderWidget, undefined, 1) || SliderWidget;
70
+ SliderWidget = inject(ViewOption)(SliderWidget, undefined, 0) || SliderWidget;
71
+ _createClass(SliderWidget, [{
72
+ key: "initialize",
73
+ value: function initialize(props) {
74
+ if (this.model_name === 'FloatSliderModel') {
75
+ if (!this.state.step) {
76
+ this.state.step === 0.01;
77
+ }
78
+ }
79
+ var attributes = props.attributes;
80
+ this.state.max = attributes.max;
81
+ this.state.min = attributes.min;
82
+ this.setState(attributes);
83
+ }
84
+ }]);
85
+ return SliderWidget;
86
+ }(WidgetView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "state", [_dec3], {
87
+ configurable: true,
88
+ enumerable: true,
89
+ writable: true,
90
+ initializer: function initializer() {
91
+ return _objectSpread(_objectSpread({}, defaultWidgetState), {}, {
92
+ orientation: 'horizontal',
93
+ step: 1,
94
+ value: 0
95
+ });
96
+ }
97
+ })), _class2)) || _class) || _class);
@@ -0,0 +1,10 @@
1
+ import type { IWidgetViewProps } from '@difizen/libro-jupyter';
2
+ import { WidgetViewContribution } from '@difizen/libro-jupyter';
3
+ import { ViewManager } from '@difizen/mana-app';
4
+ import { TextWidget } from './view.js';
5
+ export declare class TextModelContribution implements WidgetViewContribution {
6
+ viewManager: ViewManager;
7
+ canHandle: (attributes: any) => 1 | 100;
8
+ factory(props: IWidgetViewProps): Promise<TextWidget>;
9
+ }
10
+ //# sourceMappingURL=contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contribution.d.ts","sourceRoot":"","sources":["../../src/text/contribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,qBACa,qBAAsB,YAAW,sBAAsB;IAC7C,WAAW,EAAE,WAAW,CAAC;IAC9C,SAAS,eAAgB,GAAG,aAK1B;IACF,OAAO,CAAC,KAAK,EAAE,gBAAgB;CAGhC"}
@@ -0,0 +1,39 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _dec, _dec2, _class, _class2, _descriptor;
3
+ function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
4
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
6
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
8
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
10
+ function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
11
+ import { WidgetViewContribution } from '@difizen/libro-jupyter';
12
+ import { ViewManager, inject, singleton } from '@difizen/mana-app';
13
+ import { TextWidget } from "./view.js";
14
+ export var TextModelContribution = (_dec = singleton({
15
+ contrib: WidgetViewContribution
16
+ }), _dec2 = inject(ViewManager), _dec(_class = (_class2 = /*#__PURE__*/function () {
17
+ function TextModelContribution() {
18
+ _classCallCheck(this, TextModelContribution);
19
+ _initializerDefineProperty(this, "viewManager", _descriptor, this);
20
+ this.canHandle = function (attributes) {
21
+ if (attributes._model_name === 'TextModel') {
22
+ return 100;
23
+ }
24
+ return 1;
25
+ };
26
+ }
27
+ _createClass(TextModelContribution, [{
28
+ key: "factory",
29
+ value: function factory(props) {
30
+ return this.viewManager.getOrCreateView(TextWidget, props);
31
+ }
32
+ }]);
33
+ return TextModelContribution;
34
+ }(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "viewManager", [_dec2], {
35
+ configurable: true,
36
+ enumerable: true,
37
+ writable: true,
38
+ initializer: null
39
+ })), _class2)) || _class);
@@ -0,0 +1,3 @@
1
+ export * from './contribution.js';
2
+ export * from './view.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/text/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./contribution.js";
2
+ export * from "./view.js";
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" resolution-mode="require"/>
2
+ import { LibroContextKey } from '@difizen/libro-core';
3
+ import type { IWidgetViewProps } from '@difizen/libro-jupyter';
4
+ import { WidgetView } from '@difizen/libro-jupyter';
5
+ export declare const TextWidgetComponent: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
6
+ export declare class TextWidget extends WidgetView {
7
+ view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
8
+ bar_style: string;
9
+ description: string;
10
+ description_tooltip: null;
11
+ layout: string;
12
+ orientation: string;
13
+ style: string;
14
+ placeholder: string;
15
+ value: number;
16
+ constructor(props: IWidgetViewProps, libroContextKey: LibroContextKey);
17
+ }
18
+ //# sourceMappingURL=view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/text/view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAapD,eAAO,MAAM,mBAAmB,0FAoC/B,CAAC;AACF,qBAEa,UAAW,SAAQ,UAAU;IAC/B,IAAI,2FAAuB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IAEpB,KAAK,EAAE,MAAM,CAAC;gBAEQ,KAAK,EAAE,gBAAgB,EAClB,eAAe,EAAE,eAAe;CAY5D"}
@@ -0,0 +1,90 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _dec, _dec2, _dec3, _class, _class2, _descriptor;
3
+ function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
4
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
5
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
10
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
11
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
13
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
14
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
15
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
16
+ function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
17
+ function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
18
+ import { LibroContextKey } from '@difizen/libro-core';
19
+ import { WidgetView } from '@difizen/libro-jupyter';
20
+ import { view, ViewOption, transient, useInject, ViewInstance, inject, prop } from '@difizen/mana-app';
21
+ import { Input } from 'antd';
22
+ import { forwardRef } from 'react';
23
+ import { jsxs as _jsxs } from "react/jsx-runtime";
24
+ import { jsx as _jsx } from "react/jsx-runtime";
25
+ export var TextWidgetComponent = /*#__PURE__*/forwardRef(function TextWidgetComponent(_props, ref) {
26
+ var widgetView = useInject(ViewInstance);
27
+ if (widgetView.isCommClosed) {
28
+ return null;
29
+ }
30
+ var handleChange = function handleChange(e) {
31
+ var data = {
32
+ buffer_paths: [],
33
+ method: 'update',
34
+ state: {
35
+ value: e.target.value
36
+ }
37
+ };
38
+ widgetView.send(data);
39
+ };
40
+ var handlePressEnter = function handlePressEnter() {
41
+ var data = {
42
+ method: 'custom',
43
+ content: {
44
+ event: 'submit'
45
+ }
46
+ };
47
+ widgetView.send(data);
48
+ };
49
+ return /*#__PURE__*/_jsxs("div", {
50
+ className: "libro-input-widget",
51
+ ref: ref,
52
+ children: [/*#__PURE__*/_jsxs("span", {
53
+ className: "libro-input-widget-description",
54
+ children: [' ', widgetView.description]
55
+ }), /*#__PURE__*/_jsx(Input, {
56
+ placeholder: widgetView.placeholder,
57
+ size: "small",
58
+ onChange: handleChange,
59
+ onPressEnter: handlePressEnter
60
+ })]
61
+ });
62
+ });
63
+ export var TextWidget = (_dec = transient(), _dec2 = view('libro-widget-text-view'), _dec3 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_WidgetView) {
64
+ _inherits(TextWidget, _WidgetView);
65
+ var _super = _createSuper(TextWidget);
66
+ function TextWidget(props, libroContextKey) {
67
+ var _this;
68
+ _classCallCheck(this, TextWidget);
69
+ _this = _super.call(this, props, libroContextKey);
70
+ _this.view = TextWidgetComponent;
71
+ _initializerDefineProperty(_this, "value", _descriptor, _assertThisInitialized(_this));
72
+ _this.bar_style = props.attributes.bar_style;
73
+ _this.description = props.attributes.description;
74
+ _this.description_tooltip = props.attributes.description_tooltip;
75
+ _this.layout = props.attributes.layout;
76
+ _this.orientation = props.attributes.orientation;
77
+ _this.style = props.attributes.style;
78
+ _this.value = props.attributes.value;
79
+ _this.placeholder = props.attributes.placeholder;
80
+ return _this;
81
+ }
82
+ TextWidget = inject(LibroContextKey)(TextWidget, undefined, 1) || TextWidget;
83
+ TextWidget = inject(ViewOption)(TextWidget, undefined, 0) || TextWidget;
84
+ return _createClass(TextWidget);
85
+ }(WidgetView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "value", [_dec3], {
86
+ configurable: true,
87
+ enumerable: true,
88
+ writable: true,
89
+ initializer: null
90
+ })), _class2)) || _class) || _class);
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@difizen/libro-widget",
3
+ "version": "0.0.0-snapshot-20241017072317",
4
+ "description": "",
5
+ "keywords": [
6
+ "libro"
7
+ ],
8
+ "repository": "git@github.com:difizen/libro.git",
9
+ "license": "MIT",
10
+ "type": "module",
11
+ "exports": {
12
+ ".": {
13
+ "typings": "./es/index.d.ts",
14
+ "default": "./es/index.js"
15
+ },
16
+ "./mock": {
17
+ "typings": "./es/mock/index.d.ts",
18
+ "default": "./es/mock/index.js"
19
+ },
20
+ "./es/mock": {
21
+ "typings": "./es/mock/index.d.ts",
22
+ "default": "./es/mock/index.js"
23
+ },
24
+ "./package.json": "./package.json"
25
+ },
26
+ "main": "es/index.js",
27
+ "module": "es/index.js",
28
+ "typings": "es/index.d.ts",
29
+ "files": [
30
+ "es",
31
+ "src"
32
+ ],
33
+ "dependencies": {
34
+ "@difizen/libro-core": "0.0.0-snapshot-20241017072317",
35
+ "@difizen/libro-common": "0.0.0-snapshot-20241017072317",
36
+ "@difizen/libro-kernel": "0.0.0-snapshot-20241017072317",
37
+ "@difizen/libro-rendermime": "0.0.0-snapshot-20241017072317",
38
+ "@difizen/libro-jupyter": "0.0.0-snapshot-20241017072317",
39
+ "@difizen/mana-app": "latest"
40
+ },
41
+ "peerDependencies": {
42
+ "antd": "^5.8.6",
43
+ "react": ">=16"
44
+ },
45
+ "devDependencies": {
46
+ "@types/react": "^18.2.25"
47
+ },
48
+ "scripts": {
49
+ "setup": "father build",
50
+ "build": "father build",
51
+ "test": ": Note: lint task is delegated to test:* scripts",
52
+ "test:vitest": "vitest run",
53
+ "test:jest": "jest",
54
+ "coverage": ": Note: lint task is delegated to coverage:* scripts",
55
+ "coverage:vitest": "vitest run --coverage",
56
+ "coverage:jest": "jest --coverage",
57
+ "lint": ": Note: lint task is delegated to lint:* scripts",
58
+ "lint:eslint": "eslint src",
59
+ "typecheck:tsc": "tsc --noEmit"
60
+ }
61
+ }
@@ -0,0 +1,10 @@
1
+ import assert from 'assert';
2
+
3
+ // import { SliderWidget } from './index.js';
4
+ import 'reflect-metadata';
5
+
6
+ describe('libro-widget', () => {
7
+ it('#import', () => {
8
+ assert(true);
9
+ });
10
+ });
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './module.js';
2
+ export * from './slider/index.js';
3
+ export * from './text/index.js';
package/src/module.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { WidgetModule } from '@difizen/libro-jupyter';
2
+ import { ManaModule } from '@difizen/mana-app';
3
+
4
+ import { SilderWidgetContribution, SliderWidget } from './slider/index.js';
5
+ import { TextModelContribution, TextWidget } from './text/index.js';
6
+
7
+ export const CommonWidgetsModule = ManaModule.create()
8
+ .register(
9
+ SliderWidget,
10
+ SilderWidgetContribution,
11
+
12
+ TextWidget,
13
+ TextModelContribution,
14
+ )
15
+ .dependOn(WidgetModule);
@@ -0,0 +1,25 @@
1
+ import type { IWidgetViewProps } from '@difizen/libro-jupyter';
2
+ import { WidgetViewContribution } from '@difizen/libro-jupyter';
3
+ import { ViewManager, inject, singleton } from '@difizen/mana-app';
4
+
5
+ import { SliderWidget } from './view.js';
6
+
7
+ @singleton({ contrib: WidgetViewContribution })
8
+ export class SilderWidgetContribution implements WidgetViewContribution {
9
+ @inject(ViewManager) viewManager: ViewManager;
10
+ canHandle = (attributes: any) => {
11
+ if (attributes._model_name === 'IntSliderModel') {
12
+ return 100;
13
+ }
14
+ if (attributes.__view_name === 'IntSliderView') {
15
+ return 100;
16
+ }
17
+ if (attributes._model_name === 'FloatSliderModel') {
18
+ return 100;
19
+ }
20
+ return 1;
21
+ };
22
+ factory(props: IWidgetViewProps) {
23
+ return this.viewManager.getOrCreateView(SliderWidget, props);
24
+ }
25
+ }
@@ -0,0 +1,3 @@
1
+ .libro-widget-slider {
2
+ display: block;
3
+ }
@@ -0,0 +1,2 @@
1
+ export * from './contribution.js';
2
+ export * from './view.js';
@@ -0,0 +1,92 @@
1
+ import type { JSONObject } from '@difizen/libro-common';
2
+ import { LibroContextKey } from '@difizen/libro-core';
3
+ import type { IWidgetViewProps } from '@difizen/libro-jupyter';
4
+ import type { OrientableState, WidgetState } from '@difizen/libro-jupyter';
5
+ import { WidgetView } from '@difizen/libro-jupyter';
6
+ import { defaultWidgetState } from '@difizen/libro-jupyter';
7
+ import {
8
+ view,
9
+ transient,
10
+ useInject,
11
+ ViewInstance,
12
+ prop,
13
+ inject,
14
+ ViewOption,
15
+ } from '@difizen/mana-app';
16
+ import { Slider } from 'antd';
17
+ import { forwardRef } from 'react';
18
+
19
+ import './index.less';
20
+
21
+ export const LibroWidgetIntSliderComponent = forwardRef<HTMLDivElement>(
22
+ function LibroWidgetIntSliderComponent(props, ref) {
23
+ const widget = useInject<SliderWidget>(ViewInstance);
24
+
25
+ if (widget.isCommClosed) {
26
+ return null;
27
+ }
28
+
29
+ return (
30
+ <div className="libro-widget-slider" ref={ref}>
31
+ <Slider
32
+ max={widget.state.max}
33
+ min={widget.state.min}
34
+ vertical={widget.state.orientation === 'vertical'}
35
+ disabled={widget.state.disabled}
36
+ onChange={widget.handleChange}
37
+ value={widget.state.value}
38
+ />
39
+ </div>
40
+ );
41
+ },
42
+ );
43
+
44
+ interface SliderState extends WidgetState, OrientableState {
45
+ max?: number;
46
+ min?: number;
47
+ step: number;
48
+ value: number;
49
+ }
50
+
51
+ @transient()
52
+ @view('libro-widget-slider-view')
53
+ export class SliderWidget extends WidgetView {
54
+ override view = LibroWidgetIntSliderComponent;
55
+
56
+ @prop()
57
+ override state: JSONObject & SliderState = {
58
+ ...defaultWidgetState,
59
+ orientation: 'horizontal',
60
+ step: 1,
61
+ value: 0,
62
+ };
63
+
64
+ constructor(
65
+ @inject(ViewOption) props: IWidgetViewProps,
66
+ @inject(LibroContextKey) libroContextKey: LibroContextKey,
67
+ ) {
68
+ super(props, libroContextKey);
69
+ this.initialize(props);
70
+ }
71
+
72
+ protected initialize(props: IWidgetViewProps): void {
73
+ if (this.model_name === 'FloatSliderModel') {
74
+ if (!this.state.step) {
75
+ this.state.step === 0.01;
76
+ }
77
+ }
78
+ const attributes = props.attributes;
79
+ this.state.max = attributes.max;
80
+ this.state.min = attributes.min;
81
+ this.setState(attributes);
82
+ }
83
+
84
+ handleChange = (value: number) => {
85
+ const data = {
86
+ buffer_paths: [],
87
+ method: 'update',
88
+ state: { value: value },
89
+ };
90
+ this.send(data);
91
+ };
92
+ }
@@ -0,0 +1,19 @@
1
+ import type { IWidgetViewProps } from '@difizen/libro-jupyter';
2
+ import { WidgetViewContribution } from '@difizen/libro-jupyter';
3
+ import { ViewManager, inject, singleton } from '@difizen/mana-app';
4
+
5
+ import { TextWidget } from './view.js';
6
+
7
+ @singleton({ contrib: WidgetViewContribution })
8
+ export class TextModelContribution implements WidgetViewContribution {
9
+ @inject(ViewManager) viewManager: ViewManager;
10
+ canHandle = (attributes: any) => {
11
+ if (attributes._model_name === 'TextModel') {
12
+ return 100;
13
+ }
14
+ return 1;
15
+ };
16
+ factory(props: IWidgetViewProps) {
17
+ return this.viewManager.getOrCreateView(TextWidget, props);
18
+ }
19
+ }
@@ -0,0 +1,2 @@
1
+ export * from './contribution.js';
2
+ export * from './view.js';
@@ -0,0 +1,80 @@
1
+ import { LibroContextKey } from '@difizen/libro-core';
2
+ import type { IWidgetViewProps } from '@difizen/libro-jupyter';
3
+ import { WidgetView } from '@difizen/libro-jupyter';
4
+ import {
5
+ view,
6
+ ViewOption,
7
+ transient,
8
+ useInject,
9
+ ViewInstance,
10
+ inject,
11
+ prop,
12
+ } from '@difizen/mana-app';
13
+ import { Input } from 'antd';
14
+ import { forwardRef } from 'react';
15
+
16
+ export const TextWidgetComponent = forwardRef<HTMLDivElement>(
17
+ function TextWidgetComponent(_props, ref) {
18
+ const widgetView = useInject<TextWidget>(ViewInstance);
19
+ if (widgetView.isCommClosed) {
20
+ return null;
21
+ }
22
+
23
+ const handleChange = (e: any) => {
24
+ const data = {
25
+ buffer_paths: [],
26
+ method: 'update',
27
+ state: { value: e.target.value },
28
+ };
29
+ widgetView.send(data);
30
+ };
31
+
32
+ const handlePressEnter = () => {
33
+ const data = { method: 'custom', content: { event: 'submit' } };
34
+ widgetView.send(data);
35
+ };
36
+
37
+ return (
38
+ <div className="libro-input-widget" ref={ref}>
39
+ <span className="libro-input-widget-description">
40
+ {' '}
41
+ {widgetView.description}
42
+ </span>
43
+ <Input
44
+ placeholder={widgetView.placeholder}
45
+ size="small"
46
+ onChange={handleChange}
47
+ onPressEnter={handlePressEnter}
48
+ />
49
+ </div>
50
+ );
51
+ },
52
+ );
53
+ @transient()
54
+ @view('libro-widget-text-view')
55
+ export class TextWidget extends WidgetView {
56
+ override view = TextWidgetComponent;
57
+ bar_style: string;
58
+ description: string;
59
+ description_tooltip: null;
60
+ layout: string;
61
+ orientation: string;
62
+ style: string;
63
+ placeholder: string;
64
+ @prop()
65
+ value: number;
66
+ constructor(
67
+ @inject(ViewOption) props: IWidgetViewProps,
68
+ @inject(LibroContextKey) libroContextKey: LibroContextKey,
69
+ ) {
70
+ super(props, libroContextKey);
71
+ this.bar_style = props.attributes.bar_style;
72
+ this.description = props.attributes.description;
73
+ this.description_tooltip = props.attributes.description_tooltip;
74
+ this.layout = props.attributes.layout;
75
+ this.orientation = props.attributes.orientation;
76
+ this.style = props.attributes.style;
77
+ this.value = props.attributes.value;
78
+ this.placeholder = props.attributes.placeholder;
79
+ }
80
+ }