@difizen/libro-widget 0.1.33 → 0.1.35
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/es/index.d.ts +3 -4
- package/es/index.d.ts.map +1 -1
- package/es/index.js +3 -4
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +5 -0
- package/es/slider/contribution.d.ts +10 -0
- package/es/slider/contribution.d.ts.map +1 -0
- package/es/{widgets/instances-progress-widget-view-contribution.js → slider/contribution.js} +15 -9
- package/es/slider/index.d.ts +3 -0
- package/es/slider/index.d.ts.map +1 -0
- package/es/slider/index.js +2 -0
- package/es/slider/index.less +3 -0
- package/es/slider/view.d.ts +23 -0
- package/es/slider/view.d.ts.map +1 -0
- package/es/{widgets/progress-widget-view.js → slider/view.js} +62 -68
- package/es/text/contribution.d.ts +10 -0
- package/es/text/contribution.d.ts.map +1 -0
- package/es/{widgets/text-widget-view-contribution.js → text/contribution.js} +3 -3
- package/es/text/index.d.ts +3 -0
- package/es/text/index.d.ts.map +1 -0
- package/es/text/index.js +2 -0
- package/es/{widgets/text-widget-view.d.ts → text/view.d.ts} +5 -6
- package/es/text/view.d.ts.map +1 -0
- package/es/{widgets/text-widget-view.js → text/view.js} +11 -12
- package/package.json +6 -5
- package/src/index.spec.ts +2 -3
- package/src/index.ts +3 -4
- package/src/module.ts +15 -0
- package/src/slider/contribution.ts +25 -0
- package/src/slider/index.less +3 -0
- package/src/slider/index.ts +2 -0
- package/src/slider/view.tsx +92 -0
- package/src/{widgets/text-widget-view-contribution.ts → text/contribution.ts} +4 -5
- package/src/text/index.ts +2 -0
- package/src/{widgets/text-widget-view.tsx → text/view.tsx} +7 -10
- package/es/base/comm.d.ts +0 -65
- package/es/base/comm.d.ts.map +0 -1
- package/es/base/comm.js +0 -151
- package/es/base/index.d.ts +0 -7
- package/es/base/index.d.ts.map +0 -1
- package/es/base/index.js +0 -6
- package/es/base/libro-widgets.d.ts +0 -79
- package/es/base/libro-widgets.d.ts.map +0 -1
- package/es/base/libro-widgets.js +0 -286
- package/es/base/protocal.d.ts +0 -171
- package/es/base/protocal.d.ts.map +0 -1
- package/es/base/protocal.js +0 -21
- package/es/base/utils.d.ts +0 -27
- package/es/base/utils.d.ts.map +0 -1
- package/es/base/utils.js +0 -59
- package/es/base/version.d.ts +0 -3
- package/es/base/version.d.ts.map +0 -1
- package/es/base/version.js +0 -2
- package/es/base/widget-manager.d.ts +0 -18
- package/es/base/widget-manager.d.ts.map +0 -1
- package/es/base/widget-manager.js +0 -68
- package/es/base/widget-view-contribution.d.ts +0 -10
- package/es/base/widget-view-contribution.d.ts.map +0 -1
- package/es/base/widget-view-contribution.js +0 -36
- package/es/base/widget-view.d.ts +0 -52
- package/es/base/widget-view.d.ts.map +0 -1
- package/es/base/widget-view.js +0 -137
- package/es/components/index.d.ts +0 -3
- package/es/components/index.d.ts.map +0 -1
- package/es/components/index.js +0 -2
- package/es/components/progressBar.d.ts +0 -15
- package/es/components/progressBar.d.ts.map +0 -1
- package/es/components/progressBar.js +0 -20
- package/es/components/progressCircle.d.ts +0 -11
- package/es/components/progressCircle.d.ts.map +0 -1
- package/es/components/progressCircle.js +0 -16
- package/es/widget-module.d.ts +0 -3
- package/es/widget-module.d.ts.map +0 -1
- package/es/widget-module.js +0 -39
- package/es/widgets/hbox-widget-view-contribution.d.ts +0 -10
- package/es/widgets/hbox-widget-view-contribution.d.ts.map +0 -1
- package/es/widgets/hbox-widget-view-contribution.js +0 -39
- package/es/widgets/hbox-widget-view.d.ts +0 -17
- package/es/widgets/hbox-widget-view.d.ts.map +0 -1
- package/es/widgets/hbox-widget-view.js +0 -69
- package/es/widgets/index.d.ts +0 -9
- package/es/widgets/index.d.ts.map +0 -1
- package/es/widgets/index.js +0 -8
- package/es/widgets/index.less +0 -3
- package/es/widgets/instances-progress-widget-view-contribution.d.ts +0 -10
- package/es/widgets/instances-progress-widget-view-contribution.d.ts.map +0 -1
- package/es/widgets/instances-progress-widget-view.d.ts +0 -31
- package/es/widgets/instances-progress-widget-view.d.ts.map +0 -1
- package/es/widgets/instances-progress-widget-view.js +0 -181
- package/es/widgets/progress-widget-view-contribution.d.ts +0 -10
- package/es/widgets/progress-widget-view-contribution.d.ts.map +0 -1
- package/es/widgets/progress-widget-view-contribution.js +0 -39
- package/es/widgets/progress-widget-view.d.ts +0 -25
- package/es/widgets/progress-widget-view.d.ts.map +0 -1
- package/es/widgets/text-widget-view-contribution.d.ts +0 -10
- package/es/widgets/text-widget-view-contribution.d.ts.map +0 -1
- package/es/widgets/text-widget-view.d.ts.map +0 -1
- package/src/base/comm.ts +0 -152
- package/src/base/index.ts +0 -6
- package/src/base/libro-widgets.ts +0 -207
- package/src/base/protocal.ts +0 -218
- package/src/base/utils.ts +0 -67
- package/src/base/version.ts +0 -2
- package/src/base/widget-manager.ts +0 -41
- package/src/base/widget-view-contribution.ts +0 -14
- package/src/base/widget-view.tsx +0 -146
- package/src/components/index.ts +0 -3
- package/src/components/progressBar.tsx +0 -29
- package/src/components/progressCircle.tsx +0 -18
- package/src/widget-module.ts +0 -68
- package/src/widgets/hbox-widget-view-contribution.ts +0 -20
- package/src/widgets/hbox-widget-view.tsx +0 -64
- package/src/widgets/index.less +0 -3
- package/src/widgets/index.ts +0 -8
- package/src/widgets/instances-progress-widget-view-contribution.ts +0 -20
- package/src/widgets/instances-progress-widget-view.tsx +0 -160
- package/src/widgets/progress-widget-view-contribution.ts +0 -24
- package/src/widgets/progress-widget-view.tsx +0 -85
package/es/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './widgets/index.js';
|
|
1
|
+
export * from './module.js';
|
|
2
|
+
export * from './slider/index.js';
|
|
3
|
+
export * from './text/index.js';
|
|
5
4
|
//# sourceMappingURL=index.d.ts.map
|
package/es/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
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
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./widgets/index.js";
|
|
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 @@
|
|
|
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"}
|
package/es/{widgets/instances-progress-widget-view-contribution.js → slider/contribution.js}
RENAMED
|
@@ -8,29 +8,35 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
8
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
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
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';
|
|
11
12
|
import { ViewManager, inject, singleton } from '@difizen/mana-app';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
export var InstancesProgressWidgetViewContribution = (_dec = singleton({
|
|
13
|
+
import { SliderWidget } from "./view.js";
|
|
14
|
+
export var SilderWidgetContribution = (_dec = singleton({
|
|
15
15
|
contrib: WidgetViewContribution
|
|
16
16
|
}), _dec2 = inject(ViewManager), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
17
|
-
function
|
|
18
|
-
_classCallCheck(this,
|
|
17
|
+
function SilderWidgetContribution() {
|
|
18
|
+
_classCallCheck(this, SilderWidgetContribution);
|
|
19
19
|
_initializerDefineProperty(this, "viewManager", _descriptor, this);
|
|
20
20
|
this.canHandle = function (attributes) {
|
|
21
|
-
if (attributes._model_name === '
|
|
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') {
|
|
22
28
|
return 100;
|
|
23
29
|
}
|
|
24
30
|
return 1;
|
|
25
31
|
};
|
|
26
32
|
}
|
|
27
|
-
_createClass(
|
|
33
|
+
_createClass(SilderWidgetContribution, [{
|
|
28
34
|
key: "factory",
|
|
29
35
|
value: function factory(props) {
|
|
30
|
-
return this.viewManager.getOrCreateView(
|
|
36
|
+
return this.viewManager.getOrCreateView(SliderWidget, props);
|
|
31
37
|
}
|
|
32
38
|
}]);
|
|
33
|
-
return
|
|
39
|
+
return SilderWidgetContribution;
|
|
34
40
|
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "viewManager", [_dec2], {
|
|
35
41
|
configurable: true,
|
|
36
42
|
enumerable: true,
|
|
@@ -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,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"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
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,
|
|
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; }
|
|
3
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 }); }
|
|
4
7
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
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); } }
|
|
@@ -16,88 +19,79 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
16
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; }
|
|
17
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.'); }
|
|
18
21
|
import { LibroContextKey } from '@difizen/libro-core';
|
|
19
|
-
import {
|
|
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';
|
|
20
26
|
import { forwardRef } from 'react';
|
|
21
|
-
import { WidgetView } from "../base/widget-view.js";
|
|
22
|
-
import { ProgressBar } from "../components/index.js";
|
|
23
27
|
import "./index.less";
|
|
24
28
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var percent = widgetView.value / ((widgetView.max - widgetView.min) / 100);
|
|
29
|
-
if (widgetView.isCommClosed) {
|
|
29
|
+
export var LibroWidgetIntSliderComponent = /*#__PURE__*/forwardRef(function LibroWidgetIntSliderComponent(props, ref) {
|
|
30
|
+
var widget = useInject(ViewInstance);
|
|
31
|
+
if (widget.isCommClosed) {
|
|
30
32
|
return null;
|
|
31
33
|
}
|
|
32
|
-
return /*#__PURE__*/
|
|
33
|
-
className: "libro-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
+
})
|
|
40
45
|
});
|
|
41
46
|
});
|
|
42
|
-
export var
|
|
43
|
-
_inherits(
|
|
44
|
-
var _super = _createSuper(
|
|
45
|
-
function
|
|
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) {
|
|
46
51
|
var _this;
|
|
47
|
-
_classCallCheck(this,
|
|
52
|
+
_classCallCheck(this, SliderWidget);
|
|
48
53
|
_this = _super.call(this, props, libroContextKey);
|
|
49
|
-
_this.view =
|
|
50
|
-
_initializerDefineProperty(_this, "
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
_this.
|
|
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);
|
|
62
67
|
return _this;
|
|
63
68
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
var method = data.method;
|
|
74
|
-
switch (method) {
|
|
75
|
-
case 'update':
|
|
76
|
-
case 'echo_update':
|
|
77
|
-
if (data.state.value) {
|
|
78
|
-
this.value = data.state.value;
|
|
79
|
-
}
|
|
80
|
-
if (data.state.description) {
|
|
81
|
-
this.description = data.state.description;
|
|
82
|
-
}
|
|
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
|
+
}
|
|
83
78
|
}
|
|
84
|
-
|
|
79
|
+
var attributes = props.attributes;
|
|
80
|
+
this.state.max = attributes.max;
|
|
81
|
+
this.state.min = attributes.min;
|
|
82
|
+
this.setState(attributes);
|
|
85
83
|
}
|
|
86
84
|
}]);
|
|
87
|
-
return
|
|
88
|
-
}(WidgetView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "
|
|
85
|
+
return SliderWidget;
|
|
86
|
+
}(WidgetView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "state", [_dec3], {
|
|
89
87
|
configurable: true,
|
|
90
88
|
enumerable: true,
|
|
91
89
|
writable: true,
|
|
92
|
-
initializer:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
configurable: true,
|
|
100
|
-
enumerable: true,
|
|
101
|
-
writable: true,
|
|
102
|
-
initializer: null
|
|
90
|
+
initializer: function initializer() {
|
|
91
|
+
return _objectSpread(_objectSpread({}, defaultWidgetState), {}, {
|
|
92
|
+
orientation: 'horizontal',
|
|
93
|
+
step: 1,
|
|
94
|
+
value: 0
|
|
95
|
+
});
|
|
96
|
+
}
|
|
103
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"}
|
|
@@ -8,9 +8,9 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
8
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
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
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';
|
|
11
12
|
import { ViewManager, inject, singleton } from '@difizen/mana-app';
|
|
12
|
-
import {
|
|
13
|
-
import { LibroTextWidget } from "./text-widget-view.js";
|
|
13
|
+
import { TextWidget } from "./view.js";
|
|
14
14
|
export var TextModelContribution = (_dec = singleton({
|
|
15
15
|
contrib: WidgetViewContribution
|
|
16
16
|
}), _dec2 = inject(ViewManager), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
@@ -27,7 +27,7 @@ export var TextModelContribution = (_dec = singleton({
|
|
|
27
27
|
_createClass(TextModelContribution, [{
|
|
28
28
|
key: "factory",
|
|
29
29
|
value: function factory(props) {
|
|
30
|
-
return this.viewManager.getOrCreateView(
|
|
30
|
+
return this.viewManager.getOrCreateView(TextWidget, props);
|
|
31
31
|
}
|
|
32
32
|
}]);
|
|
33
33
|
return TextModelContribution;
|
|
@@ -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"}
|
package/es/text/index.js
ADDED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" resolution-mode="require"/>
|
|
2
2
|
import { LibroContextKey } from '@difizen/libro-core';
|
|
3
|
-
import type { IWidgetViewProps } from '
|
|
4
|
-
import { WidgetView } from '
|
|
5
|
-
import
|
|
6
|
-
export declare
|
|
7
|
-
export declare class LibroTextWidget extends WidgetView {
|
|
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 {
|
|
8
7
|
view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
|
|
9
8
|
bar_style: string;
|
|
10
9
|
description: string;
|
|
@@ -16,4 +15,4 @@ export declare class LibroTextWidget extends WidgetView {
|
|
|
16
15
|
value: number;
|
|
17
16
|
constructor(props: IWidgetViewProps, libroContextKey: LibroContextKey);
|
|
18
17
|
}
|
|
19
|
-
//# sourceMappingURL=
|
|
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"}
|
|
@@ -16,14 +16,13 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
16
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
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
18
|
import { LibroContextKey } from '@difizen/libro-core';
|
|
19
|
+
import { WidgetView } from '@difizen/libro-jupyter';
|
|
19
20
|
import { view, ViewOption, transient, useInject, ViewInstance, inject, prop } from '@difizen/mana-app';
|
|
20
21
|
import { Input } from 'antd';
|
|
21
22
|
import { forwardRef } from 'react';
|
|
22
|
-
import { WidgetView } from "../base/widget-view.js";
|
|
23
|
-
import "./index.less";
|
|
24
23
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
|
-
export var
|
|
25
|
+
export var TextWidgetComponent = /*#__PURE__*/forwardRef(function TextWidgetComponent(_props, ref) {
|
|
27
26
|
var widgetView = useInject(ViewInstance);
|
|
28
27
|
if (widgetView.isCommClosed) {
|
|
29
28
|
return null;
|
|
@@ -61,14 +60,14 @@ export var LibroTextWidgetComponent = /*#__PURE__*/forwardRef(function LibroText
|
|
|
61
60
|
})]
|
|
62
61
|
});
|
|
63
62
|
});
|
|
64
|
-
export var
|
|
65
|
-
_inherits(
|
|
66
|
-
var _super = _createSuper(
|
|
67
|
-
function
|
|
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) {
|
|
68
67
|
var _this;
|
|
69
|
-
_classCallCheck(this,
|
|
68
|
+
_classCallCheck(this, TextWidget);
|
|
70
69
|
_this = _super.call(this, props, libroContextKey);
|
|
71
|
-
_this.view =
|
|
70
|
+
_this.view = TextWidgetComponent;
|
|
72
71
|
_initializerDefineProperty(_this, "value", _descriptor, _assertThisInitialized(_this));
|
|
73
72
|
_this.bar_style = props.attributes.bar_style;
|
|
74
73
|
_this.description = props.attributes.description;
|
|
@@ -80,9 +79,9 @@ export var LibroTextWidget = (_dec = transient(), _dec2 = view('libro-widget-tex
|
|
|
80
79
|
_this.placeholder = props.attributes.placeholder;
|
|
81
80
|
return _this;
|
|
82
81
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return _createClass(
|
|
82
|
+
TextWidget = inject(LibroContextKey)(TextWidget, undefined, 1) || TextWidget;
|
|
83
|
+
TextWidget = inject(ViewOption)(TextWidget, undefined, 0) || TextWidget;
|
|
84
|
+
return _createClass(TextWidget);
|
|
86
85
|
}(WidgetView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "value", [_dec3], {
|
|
87
86
|
configurable: true,
|
|
88
87
|
enumerable: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-widget",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro"
|
|
@@ -31,10 +31,11 @@
|
|
|
31
31
|
"src"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@difizen/libro-core": "^0.1.
|
|
35
|
-
"@difizen/libro-common": "^0.1.
|
|
36
|
-
"@difizen/libro-kernel": "^0.1.
|
|
37
|
-
"@difizen/libro-rendermime": "^0.1.
|
|
34
|
+
"@difizen/libro-core": "^0.1.35",
|
|
35
|
+
"@difizen/libro-common": "^0.1.35",
|
|
36
|
+
"@difizen/libro-kernel": "^0.1.35",
|
|
37
|
+
"@difizen/libro-rendermime": "^0.1.35",
|
|
38
|
+
"@difizen/libro-jupyter": "^0.1.35",
|
|
38
39
|
"@difizen/mana-app": "latest"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
package/src/index.spec.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
// import { SliderWidget } from './index.js';
|
|
4
4
|
import 'reflect-metadata';
|
|
5
5
|
|
|
6
6
|
describe('libro-widget', () => {
|
|
7
7
|
it('#import', () => {
|
|
8
|
-
assert(
|
|
9
|
-
assert(WidgetView);
|
|
8
|
+
assert(true);
|
|
10
9
|
});
|
|
11
10
|
});
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './widgets/index.js';
|
|
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
|
+
}
|