cx 26.3.5 → 26.3.6
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/build/charts/helpers/SnapPointFinder.d.ts +2 -2
- package/build/charts/helpers/SnapPointFinder.d.ts.map +1 -1
- package/build/charts/helpers/ValueAtFinder.d.ts +4 -4
- package/build/charts/helpers/ValueAtFinder.d.ts.map +1 -1
- package/build/charts/helpers/ValueAtFinder.js +2 -5
- package/build/data/createAccessorModelProxy.d.ts +6 -11
- package/build/data/createAccessorModelProxy.d.ts.map +1 -1
- package/build/data/createAccessorModelProxy.js +1 -3
- package/build/jsx-runtime.d.ts +2 -1
- package/build/jsx-runtime.d.ts.map +1 -1
- package/build/ui/createFunctionalComponent.d.ts +4 -1
- package/build/ui/createFunctionalComponent.d.ts.map +1 -1
- package/build/widgets/form/Calendar.d.ts +1 -0
- package/build/widgets/form/Calendar.d.ts.map +1 -1
- package/build/widgets/form/Calendar.js +14 -22
- package/build/widgets/form/TimeList.d.ts +3 -1
- package/build/widgets/form/TimeList.d.ts.map +1 -1
- package/build/widgets/grid/Grid.d.ts +3 -3
- package/build/widgets/grid/Grid.d.ts.map +1 -1
- package/build/widgets/grid/Grid.js +86 -188
- package/build/widgets/index.d.ts +3 -1
- package/build/widgets/index.d.ts.map +1 -1
- package/build/widgets/index.js +3 -1
- package/build/widgets/nav/Tab.d.ts.map +1 -1
- package/build/widgets/nav/Tab.js +9 -5
- package/build/widgets/overlay/Overlay.d.ts +1 -1
- package/build/widgets/overlay/Overlay.d.ts.map +1 -1
- package/build/widgets/overlay/Overlay.js +10 -19
- package/build/widgets/overlay/Window.d.ts.map +1 -1
- package/build/widgets/overlay/Window.js +5 -11
- package/dist/charts.css +256 -256
- package/dist/manifest.js +722 -713
- package/dist/widgets.css +15 -7
- package/dist/widgets.js +31 -17
- package/package.json +1 -1
- package/src/charts/BarGraph.scss +31 -31
- package/src/charts/Legend.scss +57 -57
- package/src/charts/LegendEntry.scss +35 -35
- package/src/charts/LineGraph.scss +28 -28
- package/src/charts/helpers/SnapPointFinder.ts +136 -136
- package/src/charts/helpers/ValueAtFinder.ts +72 -72
- package/src/data/createAccessorModelProxy.ts +66 -66
- package/src/ui/DataProxy.ts +55 -55
- package/src/ui/Rescope.ts +50 -50
- package/src/ui/adapter/ArrayAdapter.ts +229 -229
- package/src/ui/exprHelpers.ts +96 -96
- package/src/util/scss/include.scss +69 -69
- package/src/widgets/Button.maps.scss +103 -103
- package/src/widgets/Sandbox.ts +104 -104
- package/src/widgets/form/Calendar.tsx +772 -772
- package/src/widgets/form/ColorField.scss +112 -112
- package/src/widgets/form/DateTimeField.scss +111 -111
- package/src/widgets/form/LookupField.scss +228 -228
- package/src/widgets/form/MonthField.scss +113 -113
- package/src/widgets/form/NumberField.scss +72 -72
- package/src/widgets/form/Select.scss +104 -104
- package/src/widgets/form/TextField.scss +66 -66
- package/src/widgets/form/variables.scss +110 -110
- package/src/widgets/grid/Grid.tsx +4264 -4264
- package/src/widgets/grid/variables.scss +47 -47
- package/src/widgets/index.ts +63 -63
- package/src/widgets/nav/Tab.ts +122 -122
- package/src/widgets/overlay/Overlay.tsx +1028 -1028
- package/src/widgets/overlay/Window.tsx +320 -320
- package/src/widgets/variables.scss +61 -61
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
@use "sass:map";
|
|
2
|
-
@use "../box" as *;
|
|
3
|
-
@use "../../util/scss/defaults" as *;
|
|
4
|
-
@use "../../util/scss/include" as *;
|
|
5
|
-
@use "../../util/scss/clockwise.scss" as *;
|
|
6
|
-
@use "../../util/scss/calc.scss" as *;
|
|
7
|
-
|
|
8
|
-
// GRID
|
|
9
|
-
$cx-default-grid-font-size: $cx-default-box-font-size !default;
|
|
10
|
-
$cx-default-grid-border-color: $cx-default-border-color !default;
|
|
11
|
-
$cx-default-grid-background: null !default;
|
|
12
|
-
$cx-default-grid-border-radius: null !default;
|
|
13
|
-
$cx-default-grid-box-shadow: null !default;
|
|
14
|
-
|
|
15
|
-
// header
|
|
16
|
-
$cx-default-grid-header-font-size: $cx-default-box-font-size !default;
|
|
17
|
-
$cx-default-grid-header-font-weight: normal !default;
|
|
18
|
-
$cx-default-grid-header-line-height: null !default;
|
|
19
|
-
$cx-default-grid-header-color: $cx-default-color !default;
|
|
20
|
-
$cx-default-grid-header-background-color: #eee !default;
|
|
21
|
-
$cx-default-grid-header-border-color: $cx-default-border-color !default;
|
|
22
|
-
$cx-default-grid-header-box-shadow: null !default;
|
|
23
|
-
$cx-default-grid-header-padding: null !default;
|
|
24
|
-
|
|
25
|
-
// data
|
|
26
|
-
$cx-default-grid-data-font-size: null !default;
|
|
27
|
-
$cx-default-grid-data-font-weight: null !default;
|
|
28
|
-
$cx-default-grid-data-line-height: null !default;
|
|
29
|
-
$cx-default-grid-data-background-color: transparent !default;
|
|
30
|
-
$cx-default-grid-data-alternate-background-color: null !default;
|
|
31
|
-
$cx-default-grid-data-border-color: $cx-default-grid-border-color !default;
|
|
32
|
-
$cx-default-grid-data-padding: 5px !default;
|
|
33
|
-
$cx-default-grid-scroll-wrapper-padding-top: 0 !default;
|
|
34
|
-
$cx-default-grid-caption-gap: 15px !default;
|
|
35
|
-
|
|
36
|
-
// pagination
|
|
37
|
-
$cx-grid-pagination-default-border-width: $cx-default-border-width !default;
|
|
38
|
-
$cx-grid-pagination-default-border-color: $cx-default-border-color !default;
|
|
39
|
-
$cx-grid-pagination-default-border-radius: null !default;
|
|
40
|
-
$cx-grid-pagination-default-outer-border-radius: $cx-default-border-radius !default;
|
|
41
|
-
$cx-grid-pagination-default-padding: $cx-default-box-padding-top cx-multiply(2, $cx-default-box-padding-top) !default;
|
|
42
|
-
|
|
43
|
-
@include cx-register-dependencies(
|
|
44
|
-
(
|
|
45
|
-
"cx/widgets/Grid": "cx/widgets/DragClone",
|
|
46
|
-
)
|
|
47
|
-
);
|
|
1
|
+
@use "sass:map";
|
|
2
|
+
@use "../box" as *;
|
|
3
|
+
@use "../../util/scss/defaults" as *;
|
|
4
|
+
@use "../../util/scss/include" as *;
|
|
5
|
+
@use "../../util/scss/clockwise.scss" as *;
|
|
6
|
+
@use "../../util/scss/calc.scss" as *;
|
|
7
|
+
|
|
8
|
+
// GRID
|
|
9
|
+
$cx-default-grid-font-size: $cx-default-box-font-size !default;
|
|
10
|
+
$cx-default-grid-border-color: $cx-default-border-color !default;
|
|
11
|
+
$cx-default-grid-background: null !default;
|
|
12
|
+
$cx-default-grid-border-radius: null !default;
|
|
13
|
+
$cx-default-grid-box-shadow: null !default;
|
|
14
|
+
|
|
15
|
+
// header
|
|
16
|
+
$cx-default-grid-header-font-size: $cx-default-box-font-size !default;
|
|
17
|
+
$cx-default-grid-header-font-weight: normal !default;
|
|
18
|
+
$cx-default-grid-header-line-height: null !default;
|
|
19
|
+
$cx-default-grid-header-color: $cx-default-color !default;
|
|
20
|
+
$cx-default-grid-header-background-color: #eee !default;
|
|
21
|
+
$cx-default-grid-header-border-color: $cx-default-border-color !default;
|
|
22
|
+
$cx-default-grid-header-box-shadow: null !default;
|
|
23
|
+
$cx-default-grid-header-padding: null !default;
|
|
24
|
+
|
|
25
|
+
// data
|
|
26
|
+
$cx-default-grid-data-font-size: null !default;
|
|
27
|
+
$cx-default-grid-data-font-weight: null !default;
|
|
28
|
+
$cx-default-grid-data-line-height: null !default;
|
|
29
|
+
$cx-default-grid-data-background-color: transparent !default;
|
|
30
|
+
$cx-default-grid-data-alternate-background-color: null !default;
|
|
31
|
+
$cx-default-grid-data-border-color: $cx-default-grid-border-color !default;
|
|
32
|
+
$cx-default-grid-data-padding: 5px !default;
|
|
33
|
+
$cx-default-grid-scroll-wrapper-padding-top: 0 !default;
|
|
34
|
+
$cx-default-grid-caption-gap: 15px !default;
|
|
35
|
+
|
|
36
|
+
// pagination
|
|
37
|
+
$cx-grid-pagination-default-border-width: $cx-default-border-width !default;
|
|
38
|
+
$cx-grid-pagination-default-border-color: $cx-default-border-color !default;
|
|
39
|
+
$cx-grid-pagination-default-border-radius: null !default;
|
|
40
|
+
$cx-grid-pagination-default-outer-border-radius: $cx-default-border-radius !default;
|
|
41
|
+
$cx-grid-pagination-default-padding: $cx-default-box-padding-top cx-multiply(2, $cx-default-box-padding-top) !default;
|
|
42
|
+
|
|
43
|
+
@include cx-register-dependencies(
|
|
44
|
+
(
|
|
45
|
+
"cx/widgets/Grid": "cx/widgets/DragClone",
|
|
46
|
+
)
|
|
47
|
+
);
|
package/src/widgets/index.ts
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import { Widget } from "../ui/Widget";
|
|
2
|
-
import { Text } from "../ui/Text";
|
|
3
|
-
import { StaticText } from "../ui/StaticText";
|
|
4
|
-
import { PureContainer } from "../ui/PureContainer";
|
|
5
|
-
import { IsolatedScope } from "../ui/IsolatedScope";
|
|
6
|
-
import { DetachedScope } from "../ui/DetachedScope";
|
|
7
|
-
import { Restate, PrivateStore } from "../ui/Restate";
|
|
8
|
-
import { DataProxy } from "../ui/DataProxy";
|
|
9
|
-
import { Content } from "../ui/layout/Content";
|
|
10
|
-
import { ContentPlaceholder, ContentPlaceholderScope } from "../ui/layout/ContentPlaceholder";
|
|
11
|
-
import { LabelsTopLayout, LabelsTopLayoutCell } from "../ui/layout/LabelsTopLayout";
|
|
12
|
-
import { LabelsLeftLayout } from "../ui/layout/LabelsLeftLayout";
|
|
13
|
-
import { ContentResolver } from "../ui/ContentResolver";
|
|
14
|
-
import { Rescope } from "../ui/Rescope";
|
|
15
|
-
import { Repeater } from "../ui/Repeater";
|
|
16
|
-
|
|
17
|
-
//re-export widgets defined in ui namespace
|
|
18
|
-
export {
|
|
19
|
-
Widget,
|
|
20
|
-
StaticText,
|
|
21
|
-
Text,
|
|
22
|
-
PureContainer,
|
|
23
|
-
Content,
|
|
24
|
-
ContentPlaceholder,
|
|
25
|
-
ContentPlaceholderScope,
|
|
26
|
-
ContentResolver,
|
|
27
|
-
Rescope,
|
|
28
|
-
Repeater,
|
|
29
|
-
IsolatedScope,
|
|
30
|
-
DetachedScope,
|
|
31
|
-
Restate,
|
|
32
|
-
PrivateStore,
|
|
33
|
-
DataProxy,
|
|
34
|
-
LabelsTopLayout,
|
|
35
|
-
LabelsTopLayoutCell,
|
|
36
|
-
LabelsLeftLayout,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export * from "./cx";
|
|
40
|
-
export * from "./HtmlElement";
|
|
41
|
-
export * from "./Button";
|
|
42
|
-
export * from "./DocumentTitle";
|
|
43
|
-
export * from "./List";
|
|
44
|
-
export * from "./Sandbox";
|
|
45
|
-
export * from "./CxCredit";
|
|
46
|
-
export * from "./Heading";
|
|
47
|
-
export * from "./Section";
|
|
48
|
-
export * from "./FlexBox";
|
|
49
|
-
export * from "./Icon";
|
|
50
|
-
export * from "./ProgressBar";
|
|
51
|
-
export * from "./Resizer";
|
|
52
|
-
export * from "./HighlightedSearchText";
|
|
53
|
-
export * from "./autoFocus";
|
|
54
|
-
export * from "./ReactElementWrapper";
|
|
55
|
-
|
|
56
|
-
export * from "./icons/index";
|
|
57
|
-
export * from "./overlay/index";
|
|
58
|
-
export * from "./nav/index";
|
|
59
|
-
export * from "./form/index";
|
|
60
|
-
export * from "./grid/index";
|
|
61
|
-
export * from "./drag-drop/index";
|
|
62
|
-
|
|
63
|
-
export * from "./enableAllInternalDependencies";
|
|
1
|
+
import { Widget } from "../ui/Widget";
|
|
2
|
+
import { Text } from "../ui/Text";
|
|
3
|
+
import { StaticText } from "../ui/StaticText";
|
|
4
|
+
import { PureContainer } from "../ui/PureContainer";
|
|
5
|
+
import { IsolatedScope } from "../ui/IsolatedScope";
|
|
6
|
+
import { DetachedScope } from "../ui/DetachedScope";
|
|
7
|
+
import { Restate, PrivateStore } from "../ui/Restate";
|
|
8
|
+
import { DataProxy } from "../ui/DataProxy";
|
|
9
|
+
import { Content } from "../ui/layout/Content";
|
|
10
|
+
import { ContentPlaceholder, ContentPlaceholderScope } from "../ui/layout/ContentPlaceholder";
|
|
11
|
+
import { LabelsTopLayout, LabelsTopLayoutCell } from "../ui/layout/LabelsTopLayout";
|
|
12
|
+
import { LabelsLeftLayout } from "../ui/layout/LabelsLeftLayout";
|
|
13
|
+
import { ContentResolver } from "../ui/ContentResolver";
|
|
14
|
+
import { Rescope } from "../ui/Rescope";
|
|
15
|
+
import { Repeater } from "../ui/Repeater";
|
|
16
|
+
|
|
17
|
+
//re-export widgets defined in ui namespace
|
|
18
|
+
export {
|
|
19
|
+
Widget,
|
|
20
|
+
StaticText,
|
|
21
|
+
Text,
|
|
22
|
+
PureContainer,
|
|
23
|
+
Content,
|
|
24
|
+
ContentPlaceholder,
|
|
25
|
+
ContentPlaceholderScope,
|
|
26
|
+
ContentResolver,
|
|
27
|
+
Rescope,
|
|
28
|
+
Repeater,
|
|
29
|
+
IsolatedScope,
|
|
30
|
+
DetachedScope,
|
|
31
|
+
Restate,
|
|
32
|
+
PrivateStore,
|
|
33
|
+
DataProxy,
|
|
34
|
+
LabelsTopLayout,
|
|
35
|
+
LabelsTopLayoutCell,
|
|
36
|
+
LabelsLeftLayout,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export * from "./cx";
|
|
40
|
+
export * from "./HtmlElement";
|
|
41
|
+
export * from "./Button";
|
|
42
|
+
export * from "./DocumentTitle";
|
|
43
|
+
export * from "./List";
|
|
44
|
+
export * from "./Sandbox";
|
|
45
|
+
export * from "./CxCredit";
|
|
46
|
+
export * from "./Heading";
|
|
47
|
+
export * from "./Section";
|
|
48
|
+
export * from "./FlexBox";
|
|
49
|
+
export * from "./Icon";
|
|
50
|
+
export * from "./ProgressBar";
|
|
51
|
+
export * from "./Resizer";
|
|
52
|
+
export * from "./HighlightedSearchText";
|
|
53
|
+
export * from "./autoFocus";
|
|
54
|
+
export * from "./ReactElementWrapper";
|
|
55
|
+
|
|
56
|
+
export * from "./icons/index";
|
|
57
|
+
export * from "./overlay/index";
|
|
58
|
+
export * from "./nav/index";
|
|
59
|
+
export * from "./form/index";
|
|
60
|
+
export * from "./grid/index";
|
|
61
|
+
export * from "./drag-drop/index";
|
|
62
|
+
|
|
63
|
+
export * from "./enableAllInternalDependencies";
|
package/src/widgets/nav/Tab.ts
CHANGED
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
import { Widget, VDOM } from "../../ui/Widget";
|
|
2
|
-
import { HtmlElement, HtmlElementConfigBase, HtmlElementInstance } from "../HtmlElement";
|
|
3
|
-
import { Instance } from "../../ui/Instance";
|
|
4
|
-
import { RenderingContext } from "../../ui/RenderingContext";
|
|
5
|
-
import { preventFocus, preventFocusOnTouch } from "../../ui/FocusManager";
|
|
6
|
-
import { isUndefined } from "../../util/isUndefined";
|
|
7
|
-
import { BooleanProp, Prop, StringProp } from "../../ui/Prop";
|
|
8
|
-
|
|
9
|
-
export interface TabConfig extends HtmlElementConfigBase {
|
|
10
|
-
/** A value to be written to the `value` property if the tab is clicked. */
|
|
11
|
-
tab?: Prop<string | number>;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Value of the currently selected tab.
|
|
15
|
-
* If `value` is equal to `tab`, the tab appears active.
|
|
16
|
-
*/
|
|
17
|
-
value?: StringProp;
|
|
18
|
-
|
|
19
|
-
/** Set to `true` to disable selection. */
|
|
20
|
-
disabled?: BooleanProp;
|
|
21
|
-
|
|
22
|
-
/** Base CSS class to be applied to the element. No class is applied by default. */
|
|
23
|
-
baseClass?: string;
|
|
24
|
-
|
|
25
|
-
/** Name of the HTML element to be rendered. Default is `div`. */
|
|
26
|
-
tag?: string;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Determines if tab should receive focus on `mousedown` event.
|
|
30
|
-
* Default is `false`, which means that focus can be set only using the keyboard `Tab` key.
|
|
31
|
-
*/
|
|
32
|
-
focusOnMouseDown?: boolean;
|
|
33
|
-
|
|
34
|
-
/** Set to true to set the default tab. */
|
|
35
|
-
default?: boolean;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export class Tab extends HtmlElement<TabConfig> {
|
|
39
|
-
declare public baseClass: string;
|
|
40
|
-
declare public tag: string;
|
|
41
|
-
declare public focusOnMouseDown: boolean;
|
|
42
|
-
declare public default: boolean;
|
|
43
|
-
declare public shape?: string;
|
|
44
|
-
declare public onMouseDown?: any;
|
|
45
|
-
declare public onClick?: any;
|
|
46
|
-
declareData() {
|
|
47
|
-
super.declareData(
|
|
48
|
-
{
|
|
49
|
-
tab: undefined,
|
|
50
|
-
value: undefined,
|
|
51
|
-
disabled: undefined,
|
|
52
|
-
text: undefined,
|
|
53
|
-
},
|
|
54
|
-
...arguments,
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
prepareData(context: RenderingContext, instance: HtmlElementInstance) {
|
|
59
|
-
let { data } = instance;
|
|
60
|
-
data.stateMods = {
|
|
61
|
-
active: data.tab == data.value,
|
|
62
|
-
disabled: data.disabled,
|
|
63
|
-
shape: this.shape,
|
|
64
|
-
};
|
|
65
|
-
if (this.default && isUndefined(data.value)) instance.set("value", data.tab);
|
|
66
|
-
super.prepareData(context, instance);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
isValidHtmlAttribute(attrName: string) {
|
|
70
|
-
switch (attrName) {
|
|
71
|
-
case "value":
|
|
72
|
-
case "tab":
|
|
73
|
-
case "text":
|
|
74
|
-
case "disabled":
|
|
75
|
-
case "default":
|
|
76
|
-
return false;
|
|
77
|
-
|
|
78
|
-
default:
|
|
79
|
-
return super.isValidHtmlAttribute(attrName);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
attachProps(context: RenderingContext, instance: HtmlElementInstance, props: any) {
|
|
84
|
-
super.attachProps(context, instance, props);
|
|
85
|
-
|
|
86
|
-
let { data } = instance;
|
|
87
|
-
if (!data.disabled) {
|
|
88
|
-
props.href = "#";
|
|
89
|
-
delete props.value;
|
|
90
|
-
|
|
91
|
-
props.onMouseDown = (e: any) => {
|
|
92
|
-
if (this.onMouseDown && instance.invoke("onMouseDown", e, instance) === false) return;
|
|
93
|
-
if (!this.focusOnMouseDown) preventFocus(e);
|
|
94
|
-
else preventFocusOnTouch(e);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
props.onClick = (e: any) => this.handleClick(e, instance);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
handleClick(e: any, instance: Instance) {
|
|
102
|
-
if (this.onClick && instance.invoke("onClick", e, instance) === false) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
e.preventDefault();
|
|
107
|
-
e.stopPropagation();
|
|
108
|
-
|
|
109
|
-
let { data } = instance;
|
|
110
|
-
|
|
111
|
-
if (data.disabled) return;
|
|
112
|
-
|
|
113
|
-
instance.set("value", data.tab);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
Tab.prototype.baseClass = "tab";
|
|
118
|
-
Tab.prototype.tag = "a";
|
|
119
|
-
Tab.prototype.focusOnMouseDown = false;
|
|
120
|
-
Tab.prototype.default = false;
|
|
121
|
-
|
|
122
|
-
Widget.alias("tab", Tab);
|
|
1
|
+
import { Widget, VDOM } from "../../ui/Widget";
|
|
2
|
+
import { HtmlElement, HtmlElementConfigBase, HtmlElementInstance } from "../HtmlElement";
|
|
3
|
+
import { Instance } from "../../ui/Instance";
|
|
4
|
+
import { RenderingContext } from "../../ui/RenderingContext";
|
|
5
|
+
import { preventFocus, preventFocusOnTouch } from "../../ui/FocusManager";
|
|
6
|
+
import { isUndefined } from "../../util/isUndefined";
|
|
7
|
+
import { BooleanProp, Prop, StringProp } from "../../ui/Prop";
|
|
8
|
+
|
|
9
|
+
export interface TabConfig extends HtmlElementConfigBase {
|
|
10
|
+
/** A value to be written to the `value` property if the tab is clicked. */
|
|
11
|
+
tab?: Prop<string | number>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Value of the currently selected tab.
|
|
15
|
+
* If `value` is equal to `tab`, the tab appears active.
|
|
16
|
+
*/
|
|
17
|
+
value?: StringProp;
|
|
18
|
+
|
|
19
|
+
/** Set to `true` to disable selection. */
|
|
20
|
+
disabled?: BooleanProp;
|
|
21
|
+
|
|
22
|
+
/** Base CSS class to be applied to the element. No class is applied by default. */
|
|
23
|
+
baseClass?: string;
|
|
24
|
+
|
|
25
|
+
/** Name of the HTML element to be rendered. Default is `div`. */
|
|
26
|
+
tag?: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Determines if tab should receive focus on `mousedown` event.
|
|
30
|
+
* Default is `false`, which means that focus can be set only using the keyboard `Tab` key.
|
|
31
|
+
*/
|
|
32
|
+
focusOnMouseDown?: boolean;
|
|
33
|
+
|
|
34
|
+
/** Set to true to set the default tab. */
|
|
35
|
+
default?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class Tab extends HtmlElement<TabConfig> {
|
|
39
|
+
declare public baseClass: string;
|
|
40
|
+
declare public tag: string;
|
|
41
|
+
declare public focusOnMouseDown: boolean;
|
|
42
|
+
declare public default: boolean;
|
|
43
|
+
declare public shape?: string;
|
|
44
|
+
declare public onMouseDown?: any;
|
|
45
|
+
declare public onClick?: any;
|
|
46
|
+
declareData() {
|
|
47
|
+
super.declareData(
|
|
48
|
+
{
|
|
49
|
+
tab: undefined,
|
|
50
|
+
value: undefined,
|
|
51
|
+
disabled: undefined,
|
|
52
|
+
text: undefined,
|
|
53
|
+
},
|
|
54
|
+
...arguments,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
prepareData(context: RenderingContext, instance: HtmlElementInstance) {
|
|
59
|
+
let { data } = instance;
|
|
60
|
+
data.stateMods = {
|
|
61
|
+
active: data.tab == data.value,
|
|
62
|
+
disabled: data.disabled,
|
|
63
|
+
shape: this.shape,
|
|
64
|
+
};
|
|
65
|
+
if (this.default && isUndefined(data.value)) instance.set("value", data.tab);
|
|
66
|
+
super.prepareData(context, instance);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
isValidHtmlAttribute(attrName: string) {
|
|
70
|
+
switch (attrName) {
|
|
71
|
+
case "value":
|
|
72
|
+
case "tab":
|
|
73
|
+
case "text":
|
|
74
|
+
case "disabled":
|
|
75
|
+
case "default":
|
|
76
|
+
return false;
|
|
77
|
+
|
|
78
|
+
default:
|
|
79
|
+
return super.isValidHtmlAttribute(attrName);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
attachProps(context: RenderingContext, instance: HtmlElementInstance, props: any) {
|
|
84
|
+
super.attachProps(context, instance, props);
|
|
85
|
+
|
|
86
|
+
let { data } = instance;
|
|
87
|
+
if (!data.disabled) {
|
|
88
|
+
props.href = "#";
|
|
89
|
+
delete props.value;
|
|
90
|
+
|
|
91
|
+
props.onMouseDown = (e: any) => {
|
|
92
|
+
if (this.onMouseDown && instance.invoke("onMouseDown", e, instance) === false) return;
|
|
93
|
+
if (!this.focusOnMouseDown) preventFocus(e);
|
|
94
|
+
else preventFocusOnTouch(e);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
props.onClick = (e: any) => this.handleClick(e, instance);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
handleClick(e: any, instance: Instance) {
|
|
102
|
+
if (this.onClick && instance.invoke("onClick", e, instance) === false) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
e.stopPropagation();
|
|
108
|
+
|
|
109
|
+
let { data } = instance;
|
|
110
|
+
|
|
111
|
+
if (data.disabled) return;
|
|
112
|
+
|
|
113
|
+
instance.set("value", data.tab);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
Tab.prototype.baseClass = "tab";
|
|
118
|
+
Tab.prototype.tag = "a";
|
|
119
|
+
Tab.prototype.focusOnMouseDown = false;
|
|
120
|
+
Tab.prototype.default = false;
|
|
121
|
+
|
|
122
|
+
Widget.alias("tab", Tab);
|