@rivtn/noseur 1.0.0
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 +21 -0
- package/README.md +2 -0
- package/dist/esm/Template.d.ts +7 -0
- package/dist/esm/Template.js +13 -0
- package/dist/esm/compose/Composed.css +437 -0
- package/dist/esm/compose/exotic/ColorPicker.d.ts +41 -0
- package/dist/esm/compose/exotic/ColorPicker.js +85 -0
- package/dist/esm/compose/exotic/ColorSlider.d.ts +30 -0
- package/dist/esm/compose/exotic/ColorSlider.js +99 -0
- package/dist/esm/compose/form/ComposedPassword.d.ts +25 -0
- package/dist/esm/compose/form/ComposedPassword.js +103 -0
- package/dist/esm/compose/form/DateTimeInput.d.ts +28 -0
- package/dist/esm/compose/form/DateTimeInput.js +154 -0
- package/dist/esm/compose/form/DateTimePicker.d.ts +341 -0
- package/dist/esm/compose/form/DateTimePicker.js +1265 -0
- package/dist/esm/compose/form/FormControl.d.ts +33 -0
- package/dist/esm/compose/form/FormControl.js +163 -0
- package/dist/esm/compose/form/FormGroup.d.ts +14 -0
- package/dist/esm/compose/form/FormGroup.js +58 -0
- package/dist/esm/compose/overlay/Alert.d.ts +56 -0
- package/dist/esm/compose/overlay/Alert.js +267 -0
- package/dist/esm/constants/Alignment.d.ts +17 -0
- package/dist/esm/constants/Alignment.js +18 -0
- package/dist/esm/constants/Direction.d.ts +26 -0
- package/dist/esm/constants/Direction.js +22 -0
- package/dist/esm/constants/Orientation.d.ts +8 -0
- package/dist/esm/constants/Orientation.js +9 -0
- package/dist/esm/constants/Scheme.d.ts +39 -0
- package/dist/esm/constants/Scheme.js +43 -0
- package/dist/esm/constants/Transition.d.ts +81 -0
- package/dist/esm/constants/Transition.js +85 -0
- package/dist/esm/constants/Types.d.ts +74 -0
- package/dist/esm/constants/Types.js +14 -0
- package/dist/esm/core/ComponentBaseProps.d.ts +53 -0
- package/dist/esm/core/ComponentBaseProps.js +33 -0
- package/dist/esm/core/noseur.css +2390 -0
- package/dist/esm/data/Column.d.ts +235 -0
- package/dist/esm/data/Column.js +98 -0
- package/dist/esm/data/Data.css +213 -0
- package/dist/esm/data/Data.d.ts +98 -0
- package/dist/esm/data/Data.js +142 -0
- package/dist/esm/data/List.d.ts +14 -0
- package/dist/esm/data/List.js +117 -0
- package/dist/esm/data/Table.d.ts +22 -0
- package/dist/esm/data/Table.js +236 -0
- package/dist/esm/form/Button.d.ts +35 -0
- package/dist/esm/form/Button.js +131 -0
- package/dist/esm/form/Calendar.d.ts +20 -0
- package/dist/esm/form/Calendar.js +46 -0
- package/dist/esm/form/Checkbox.d.ts +20 -0
- package/dist/esm/form/Checkbox.js +155 -0
- package/dist/esm/form/ColorMap.d.ts +22 -0
- package/dist/esm/form/ColorMap.js +43 -0
- package/dist/esm/form/ColorPalette.d.ts +28 -0
- package/dist/esm/form/ColorPalette.js +87 -0
- package/dist/esm/form/Dropdown.d.ts +78 -0
- package/dist/esm/form/Dropdown.js +360 -0
- package/dist/esm/form/FileInput.d.ts +134 -0
- package/dist/esm/form/FileInput.js +523 -0
- package/dist/esm/form/Form.css +467 -0
- package/dist/esm/form/Input.d.ts +45 -0
- package/dist/esm/form/Input.js +186 -0
- package/dist/esm/form/RadioButton.d.ts +21 -0
- package/dist/esm/form/RadioButton.js +178 -0
- package/dist/esm/form/Slider.d.ts +21 -0
- package/dist/esm/form/Slider.js +163 -0
- package/dist/esm/hooks/useSearchParams.d.ts +15 -0
- package/dist/esm/hooks/useSearchParams.js +50 -0
- package/dist/esm/hooks/useSubscription.d.ts +9 -0
- package/dist/esm/hooks/useSubscription.js +26 -0
- package/dist/esm/index.d.ts +60 -0
- package/dist/esm/index.js +73 -0
- package/dist/esm/layout/GridView.d.ts +23 -0
- package/dist/esm/layout/GridView.js +34 -0
- package/dist/esm/layout/Layout.css +5 -0
- package/dist/esm/misc/Misc.css +164 -0
- package/dist/esm/misc/ProgressBar.d.ts +22 -0
- package/dist/esm/misc/ProgressBar.js +86 -0
- package/dist/esm/overlay/Dialog.d.ts +46 -0
- package/dist/esm/overlay/Dialog.js +290 -0
- package/dist/esm/overlay/Message.d.ts +35 -0
- package/dist/esm/overlay/Message.js +187 -0
- package/dist/esm/overlay/Overlay.css +382 -0
- package/dist/esm/overlay/Popover.d.ts +30 -0
- package/dist/esm/overlay/Popover.js +245 -0
- package/dist/esm/overlay/Portal.d.ts +11 -0
- package/dist/esm/overlay/Portal.js +29 -0
- package/dist/esm/overlay/Toast.d.ts +49 -0
- package/dist/esm/overlay/Toast.js +341 -0
- package/dist/esm/panel/Accordion.d.ts +26 -0
- package/dist/esm/panel/Accordion.js +127 -0
- package/dist/esm/panel/Panel.css +317 -0
- package/dist/esm/panel/Panel.d.ts +43 -0
- package/dist/esm/panel/Panel.js +125 -0
- package/dist/esm/panel/ScrollPanel.d.ts +27 -0
- package/dist/esm/panel/ScrollPanel.js +43 -0
- package/dist/esm/panel/TabPane.d.ts +82 -0
- package/dist/esm/panel/TabPane.js +237 -0
- package/dist/esm/presentation/Chart.d.ts +49 -0
- package/dist/esm/presentation/Chart.js +62 -0
- package/dist/esm/presentation/Paginator.d.ts +90 -0
- package/dist/esm/presentation/Paginator.js +331 -0
- package/dist/esm/presentation/Presentation.css +23 -0
- package/dist/esm/sensor/DragSensor.d.ts +50 -0
- package/dist/esm/sensor/DragSensor.js +156 -0
- package/dist/esm/sensor/ViewportSensor.d.ts +18 -0
- package/dist/esm/sensor/ViewportSensor.js +85 -0
- package/dist/esm/utils/BoolHelper.d.ts +13 -0
- package/dist/esm/utils/BoolHelper.js +105 -0
- package/dist/esm/utils/Classname.d.ts +9 -0
- package/dist/esm/utils/Classname.js +20 -0
- package/dist/esm/utils/ColorHelper.d.ts +127 -0
- package/dist/esm/utils/ColorHelper.js +198 -0
- package/dist/esm/utils/DOMUtils.d.ts +142 -0
- package/dist/esm/utils/DOMUtils.js +759 -0
- package/dist/esm/utils/DateHelper.d.ts +115 -0
- package/dist/esm/utils/DateHelper.js +338 -0
- package/dist/esm/utils/Debugger.d.ts +12 -0
- package/dist/esm/utils/Debugger.js +30 -0
- package/dist/esm/utils/FileHelper.d.ts +8 -0
- package/dist/esm/utils/FileHelper.js +65 -0
- package/dist/esm/utils/FunctionStackManager.d.ts +13 -0
- package/dist/esm/utils/FunctionStackManager.js +59 -0
- package/dist/esm/utils/InputHelper.d.ts +37 -0
- package/dist/esm/utils/InputHelper.js +70 -0
- package/dist/esm/utils/MicroBuilder.d.ts +24 -0
- package/dist/esm/utils/MicroBuilder.js +61 -0
- package/dist/esm/utils/ObjectHelper.d.ts +51 -0
- package/dist/esm/utils/ObjectHelper.js +334 -0
- package/dist/esm/utils/StringHelper.d.ts +10 -0
- package/dist/esm/utils/StringHelper.js +54 -0
- package/dist/esm/utils/Subscriber.d.ts +14 -0
- package/dist/esm/utils/Subscriber.js +27 -0
- package/dist/esm/utils/Timer.d.ts +32 -0
- package/dist/esm/utils/Timer.js +68 -0
- package/dist/esm/utils/TypeChecker.d.ts +12 -0
- package/dist/esm/utils/TypeChecker.js +38 -0
- package/package.json +63 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "./Form.css";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Alignment } from "../constants/Alignment";
|
|
4
|
+
import { ComponentBaseProps } from '../core/ComponentBaseProps';
|
|
5
|
+
import { NoseurFormElement, NoseurCheckState, NoseurLabel, NoseurNummber } from "../constants/Types";
|
|
6
|
+
export interface RadioButtonProps extends ComponentBaseProps<NoseurFormElement | HTMLLabelElement> {
|
|
7
|
+
checked: boolean;
|
|
8
|
+
readOnly: boolean;
|
|
9
|
+
required: boolean;
|
|
10
|
+
label: NoseurLabel;
|
|
11
|
+
highlight: boolean;
|
|
12
|
+
toggleable: boolean;
|
|
13
|
+
alignLabel: Alignment;
|
|
14
|
+
defaultChecked: boolean;
|
|
15
|
+
alwaysRenderInput: boolean;
|
|
16
|
+
checkedIndex: NoseurNummber;
|
|
17
|
+
checkStates: NoseurCheckState[];
|
|
18
|
+
defaultCheckedIndex: NoseurNummber;
|
|
19
|
+
onChecked?: (checked: boolean) => void | boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare const RadioButton: ({ ref, ...props }: Partial<RadioButtonProps>) => React.JSX.Element;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import "./Form.css";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Scheme } from "../constants/Scheme";
|
|
4
|
+
import { Classname } from "../utils/Classname";
|
|
5
|
+
import { Alignment } from "../constants/Alignment";
|
|
6
|
+
import { ObjectHelper } from "../utils/ObjectHelper";
|
|
7
|
+
import { MicroBuilder } from "../utils/MicroBuilder";
|
|
8
|
+
const __noseurGlobalRadioButtonReporter = {};
|
|
9
|
+
;
|
|
10
|
+
class RadioButtonComponent extends React.Component {
|
|
11
|
+
static defaultProps = {
|
|
12
|
+
toggleable: false,
|
|
13
|
+
scheme: Scheme.STATELESS,
|
|
14
|
+
alignLabel: Alignment.RIGHT,
|
|
15
|
+
checkStates: [
|
|
16
|
+
{
|
|
17
|
+
icon: null,
|
|
18
|
+
checked: false,
|
|
19
|
+
scheme: Scheme.NIL,
|
|
20
|
+
value: "un-checked",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
checked: true,
|
|
24
|
+
value: "checked",
|
|
25
|
+
icon: "fa fa-circle",
|
|
26
|
+
scheme: Scheme.PRIMARY,
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
};
|
|
30
|
+
state = {
|
|
31
|
+
toggleable: true,
|
|
32
|
+
checkedIndex: this.getFirstCheckedValue(),
|
|
33
|
+
};
|
|
34
|
+
internalRadioButtonElement;
|
|
35
|
+
constructor(props) {
|
|
36
|
+
super(props);
|
|
37
|
+
this.onClick = this.onClick.bind(this);
|
|
38
|
+
this.onKeyDown = this.onKeyDown.bind(this);
|
|
39
|
+
this.onCheckBoxClicked = this.onCheckBoxClicked.bind(this);
|
|
40
|
+
this.getFirstCheckedValue = this.getFirstCheckedValue.bind(this);
|
|
41
|
+
}
|
|
42
|
+
componentDidMount() {
|
|
43
|
+
if (this.props.defaultChecked) {
|
|
44
|
+
__noseurGlobalRadioButtonReporter[this.props.name] = this.onCheckBoxClicked;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
componentDidUpdate(prevProps) {
|
|
48
|
+
if ((prevProps.checked !== undefined && prevProps.checked !== this.props.checked)
|
|
49
|
+
|| (prevProps.checkedIndex !== undefined && prevProps.checkedIndex !== this.props.checkedIndex)) {
|
|
50
|
+
this.setState({ checkedIndex: this.getFirstCheckedValue() });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
onClick(event) {
|
|
54
|
+
this.props.onClick && this.props.onClick(event);
|
|
55
|
+
if (!this.state.toggleable && !this.props.toggleable)
|
|
56
|
+
return;
|
|
57
|
+
event.stopPropagation();
|
|
58
|
+
this.onCheckBoxClicked(event);
|
|
59
|
+
}
|
|
60
|
+
onKeyDown(event) {
|
|
61
|
+
this.props.onKeyDown && this.props.onKeyDown(event);
|
|
62
|
+
if (event.code == "Space") {
|
|
63
|
+
if (!this.state.toggleable && !this.props.toggleable)
|
|
64
|
+
return;
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
event.stopPropagation();
|
|
67
|
+
this.onCheckBoxClicked(event);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
onCheckBoxClicked(event) {
|
|
71
|
+
if (this.props.readOnly)
|
|
72
|
+
return;
|
|
73
|
+
let newCheckedIndex = this.getCheckStatesIndex() + 1;
|
|
74
|
+
if (newCheckedIndex >= this.props.checkStates.length)
|
|
75
|
+
newCheckedIndex = 0;
|
|
76
|
+
const checkState = this.props.checkStates[newCheckedIndex];
|
|
77
|
+
if (this.props.onChecked?.(checkState?.checked) === true && checkState?.checked === true) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (this.props.onChange && event) {
|
|
81
|
+
this.props.onChange({
|
|
82
|
+
...event,
|
|
83
|
+
checkState,
|
|
84
|
+
value: checkState?.value,
|
|
85
|
+
checked: checkState?.checked
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
this.setState({ checkedIndex: newCheckedIndex, toggleable: !event }, () => {
|
|
89
|
+
const name = this.props.name;
|
|
90
|
+
if (!event || !name)
|
|
91
|
+
return;
|
|
92
|
+
if (!!event && (name in __noseurGlobalRadioButtonReporter)) {
|
|
93
|
+
__noseurGlobalRadioButtonReporter[name]();
|
|
94
|
+
}
|
|
95
|
+
__noseurGlobalRadioButtonReporter[name] = this.onCheckBoxClicked;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
getCheckStatesIndex() {
|
|
99
|
+
if (this.props.checkedIndex)
|
|
100
|
+
return this.props.checkedIndex;
|
|
101
|
+
if (this.props.checked || this.props.checkedIndex != null)
|
|
102
|
+
return this.getFirstCheckedValue();
|
|
103
|
+
const checkStatesSize = this.props.checkStates.length;
|
|
104
|
+
let checkedIndex = this.state.checkedIndex;
|
|
105
|
+
if (checkedIndex >= checkStatesSize) {
|
|
106
|
+
checkedIndex = 0;
|
|
107
|
+
}
|
|
108
|
+
return checkedIndex;
|
|
109
|
+
}
|
|
110
|
+
getFirstCheckedValue() {
|
|
111
|
+
if (this.props.checkStates.length == 2 && this.props.checkStates[0].scheme == Scheme.NIL) {
|
|
112
|
+
if (this.props.checked || this.props.defaultChecked)
|
|
113
|
+
return 1;
|
|
114
|
+
if (this.props.checkedIndex != null)
|
|
115
|
+
return this.props.checkedIndex;
|
|
116
|
+
if (this.props.defaultCheckedIndex != null)
|
|
117
|
+
return this.props.defaultCheckedIndex;
|
|
118
|
+
}
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
buildInput(checkState) {
|
|
122
|
+
if (!checkState.checked && !this.props.alwaysRenderInput)
|
|
123
|
+
return;
|
|
124
|
+
const props = {
|
|
125
|
+
id: this.props.id,
|
|
126
|
+
name: this.props.name,
|
|
127
|
+
checked: checkState.checked,
|
|
128
|
+
required: this.props.required,
|
|
129
|
+
onClick: () => { },
|
|
130
|
+
onChange: (e) => { e.stopPropagation(); }
|
|
131
|
+
};
|
|
132
|
+
return React.createElement("input", { type: "radio", ...props });
|
|
133
|
+
}
|
|
134
|
+
buildBox(checkState) {
|
|
135
|
+
const scheme = this.props.checkStates.length == 2 && this.props.checkStates[0].scheme == Scheme.NIL
|
|
136
|
+
? this.props.scheme : (checkState.scheme ?? this.props.scheme);
|
|
137
|
+
const className = Classname.build("noseur-radiobutton-box", (!this.props.noStyle && scheme) ? `${scheme}-bd-cl-hv` : null, (!this.props.noStyle && checkState.scheme) ? `${scheme}-vars` : null, { 'noseur-skeleton': scheme === Scheme.SKELETON, }, this.props.className);
|
|
138
|
+
const iconClassName = Classname.build((!this.props.noStyle && !checkState.scheme) ? `noseur-form-bd-cl` : null, (!this.props.noStyle && this.props.highlight) ? `${scheme}-bd-cl` : null, (!this.props.noStyle && scheme) ? `${scheme}-bd-cl-fc ${scheme}-bd-cl-hv ${scheme}-bd-cl-ac` : null);
|
|
139
|
+
const icon = MicroBuilder.buildIcon(checkState.icon, {
|
|
140
|
+
className: iconClassName,
|
|
141
|
+
scheme: checkState.scheme,
|
|
142
|
+
});
|
|
143
|
+
const props = {
|
|
144
|
+
className,
|
|
145
|
+
tabIndex: 1,
|
|
146
|
+
onClick: this.onClick,
|
|
147
|
+
onKeyDown: this.onKeyDown,
|
|
148
|
+
};
|
|
149
|
+
return (React.createElement("span", { ...props }, icon));
|
|
150
|
+
}
|
|
151
|
+
render() {
|
|
152
|
+
const checkState = this.props.checkStates[this.getCheckStatesIndex()];
|
|
153
|
+
const box = this.buildBox(checkState);
|
|
154
|
+
const input = this.buildInput(checkState);
|
|
155
|
+
const label = MicroBuilder.buildLabel(this.props.label, {
|
|
156
|
+
scheme: this.props.scheme,
|
|
157
|
+
relativeAlignment: this.props.alignLabel,
|
|
158
|
+
}, { onClick: this.onClick });
|
|
159
|
+
const className = Classname.build("noseur-radiobutton", {
|
|
160
|
+
'noseur-fl-d-c-r': this.props.alignLabel === Alignment.TOP,
|
|
161
|
+
'noseur-fl-d-r-r': this.props.alignLabel === Alignment.LEFT,
|
|
162
|
+
'noseur-fl-d-c': this.props.alignLabel === Alignment.BOTTOM,
|
|
163
|
+
'noseur-disabled': !this.props.noStyle && this.props.disabled,
|
|
164
|
+
});
|
|
165
|
+
const eventProps = ObjectHelper.extractEventProps(this.props, ["onChecked"]);
|
|
166
|
+
const props = {
|
|
167
|
+
className,
|
|
168
|
+
...eventProps,
|
|
169
|
+
key: this.props.key,
|
|
170
|
+
style: this.props.style,
|
|
171
|
+
};
|
|
172
|
+
return (React.createElement("label", { ref: this.props.forwardRef, ...props },
|
|
173
|
+
box,
|
|
174
|
+
label,
|
|
175
|
+
input));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
export const RadioButton = ({ ref, ...props }) => (React.createElement(RadioButtonComponent, { ...props, forwardRef: ref }));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BareInputManageRef } from "./Input";
|
|
3
|
+
import { NoseurElement } from "../constants/Types";
|
|
4
|
+
import { Orientation } from "../constants/Orientation";
|
|
5
|
+
import { DragSensorProps } from "../sensor/DragSensor";
|
|
6
|
+
import { ComponentBaseProps, ComponentElementBasicAttributes } from "../core/ComponentBaseProps";
|
|
7
|
+
export interface SliderManageRef extends BareInputManageRef<number | number[]> {
|
|
8
|
+
}
|
|
9
|
+
export type SliderAttributesRelays = {
|
|
10
|
+
range?: ComponentElementBasicAttributes;
|
|
11
|
+
handle?: ComponentElementBasicAttributes;
|
|
12
|
+
dragSensorProps?: Partial<DragSensorProps>;
|
|
13
|
+
};
|
|
14
|
+
export interface SliderProps extends ComponentBaseProps<HTMLDivElement, SliderManageRef, SliderAttributesRelays> {
|
|
15
|
+
inverse: boolean;
|
|
16
|
+
range: NoseurElement;
|
|
17
|
+
handle: NoseurElement;
|
|
18
|
+
value: number | number[];
|
|
19
|
+
orientation: Orientation.VERTICAL | Orientation.HORIZONTAL;
|
|
20
|
+
}
|
|
21
|
+
export declare const Slider: ({ ref, ...props }: Partial<SliderProps>) => React.JSX.Element;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Classname } from "../utils/Classname";
|
|
3
|
+
import { Direction } from "../constants/Direction";
|
|
4
|
+
import { ObjectHelper } from "../utils/ObjectHelper";
|
|
5
|
+
import { Orientation } from "../constants/Orientation";
|
|
6
|
+
import { DOMHelper, ScrollHandler } from "../utils/DOMUtils";
|
|
7
|
+
import { DragSensor } from "../sensor/DragSensor";
|
|
8
|
+
class SliderComponent extends React.Component {
|
|
9
|
+
static defaultProps = {
|
|
10
|
+
attrsRelay: {},
|
|
11
|
+
draggable: true,
|
|
12
|
+
orientation: Orientation.HORIZONTAL,
|
|
13
|
+
};
|
|
14
|
+
state = {
|
|
15
|
+
values: (typeof this.props.value === "number" ? [this.props.value] : this.props.value) ?? [0],
|
|
16
|
+
};
|
|
17
|
+
documentScrollHandler;
|
|
18
|
+
componentUnmounted = false;
|
|
19
|
+
compoundRef = null;
|
|
20
|
+
sliderRangeElement;
|
|
21
|
+
compoundRefRect;
|
|
22
|
+
constructor(props) {
|
|
23
|
+
super(props);
|
|
24
|
+
this.updateRange = this.updateRange.bind(this);
|
|
25
|
+
this.onHandleDrag = this.onHandleDrag.bind(this);
|
|
26
|
+
}
|
|
27
|
+
componentDidMount() {
|
|
28
|
+
ObjectHelper.resolveManageRef(this, {
|
|
29
|
+
clear: () => {
|
|
30
|
+
this.setState({ values: this.state.values.map(() => 0) });
|
|
31
|
+
this.forceUpdate();
|
|
32
|
+
},
|
|
33
|
+
value: () => {
|
|
34
|
+
return (this.state.values.length < 2 ? this.state.values[0] : this.state.values);
|
|
35
|
+
},
|
|
36
|
+
setValue: (values) => {
|
|
37
|
+
this.setState({ values });
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
if (this.documentScrollHandler)
|
|
41
|
+
return;
|
|
42
|
+
this.documentScrollHandler = ScrollHandler.handle(this.compoundRef, async (_) => {
|
|
43
|
+
this.compoundRefRect = DOMHelper.getElementRectWithOffset(this.compoundRef);
|
|
44
|
+
});
|
|
45
|
+
this.documentScrollHandler.attach();
|
|
46
|
+
this.componentUnmounted = true;
|
|
47
|
+
}
|
|
48
|
+
componentWillUnmount() {
|
|
49
|
+
if (!this.componentUnmounted)
|
|
50
|
+
return;
|
|
51
|
+
this.componentUnmounted = true;
|
|
52
|
+
this.documentScrollHandler && this.documentScrollHandler.detach();
|
|
53
|
+
ObjectHelper.resolveManageRef(this, null);
|
|
54
|
+
this.documentScrollHandler = undefined;
|
|
55
|
+
}
|
|
56
|
+
shouldComponentUpdate(_, __) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
async updateRange() {
|
|
60
|
+
const values = this.state.values;
|
|
61
|
+
if (this.sliderRangeElement) {
|
|
62
|
+
if (values.length < 2) {
|
|
63
|
+
this.sliderRangeElement.style[this.props.orientation === Orientation.HORIZONTAL ? "width" : "height"] = `${values[0]}%`;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
let farRightValue = values[0];
|
|
67
|
+
let farLeftValue = values[values.length - 1];
|
|
68
|
+
if (farRightValue > farLeftValue) {
|
|
69
|
+
let tempValue = farLeftValue;
|
|
70
|
+
farLeftValue = farRightValue;
|
|
71
|
+
farRightValue = tempValue;
|
|
72
|
+
}
|
|
73
|
+
if (this.props.orientation === Orientation.HORIZONTAL) {
|
|
74
|
+
this.sliderRangeElement.style.left = `${farRightValue}%`;
|
|
75
|
+
this.sliderRangeElement.style.right = `${farLeftValue}%`;
|
|
76
|
+
this.sliderRangeElement.style.width = `${farLeftValue - farRightValue}%`;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
this.sliderRangeElement.style.top = `${farRightValue}%`;
|
|
80
|
+
this.sliderRangeElement.style.bottom = `${farLeftValue}%`;
|
|
81
|
+
this.sliderRangeElement.style.height = `${farLeftValue - farRightValue}%`;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async onHandleDrag(evt) {
|
|
85
|
+
const values = this.state.values;
|
|
86
|
+
const index = parseInt((evt?.key ?? "").split("|__|")[0]);
|
|
87
|
+
const compoundWidthOrHeight = (this.props.orientation === Orientation.HORIZONTAL ? this.compoundRefRect?.width : this.compoundRefRect?.height);
|
|
88
|
+
const compoundLeftOrTop = (this.props.orientation === Orientation.HORIZONTAL ? this.compoundRefRect?.left : this.compoundRefRect?.top);
|
|
89
|
+
const value = evt[this.props.orientation === Orientation.HORIZONTAL ? "left" : "top"] - (compoundLeftOrTop ?? 0);
|
|
90
|
+
const percentageValue = ObjectHelper.round((value / (compoundWidthOrHeight ?? 1)) * 100);
|
|
91
|
+
const finalValue = (this.props.inverse && values.length === 1 ? (100 - percentageValue) : percentageValue);
|
|
92
|
+
if (values[index] === value)
|
|
93
|
+
return;
|
|
94
|
+
values[index] = finalValue;
|
|
95
|
+
(async () => {
|
|
96
|
+
(evt?.event.target).style[this.props.orientation === Orientation.HORIZONTAL ? "left" : "top"] = `${percentageValue}%`;
|
|
97
|
+
this.props.onChange && this.props.onChange({ values: values, value: (values ? values[0] : 0) });
|
|
98
|
+
this.updateRange();
|
|
99
|
+
}).bind(this)();
|
|
100
|
+
this.props.attrsRelay?.dragSensorProps?.onDragEvent && this.props.attrsRelay?.dragSensorProps?.onDragEvent(evt);
|
|
101
|
+
}
|
|
102
|
+
renderRange() {
|
|
103
|
+
const className = Classname.build("noseur-slider-range", {
|
|
104
|
+
"inverse": this.props.inverse,
|
|
105
|
+
[`${this.props.attrsRelay?.range?.scheme}-vars`]: !!this.props.attrsRelay?.range?.scheme
|
|
106
|
+
}, this.props.attrsRelay?.range?.className);
|
|
107
|
+
if (this.props.range) {
|
|
108
|
+
return React.cloneElement(this.props.range, {
|
|
109
|
+
id: ObjectHelper.object(this.props.range)?.props?.id ?? this.props.attrsRelay?.range?.id,
|
|
110
|
+
className: Classname.build(className, ObjectHelper.object(this.props.range)?.props?.className),
|
|
111
|
+
style: {
|
|
112
|
+
...(this.props.attrsRelay?.range?.style ?? {}),
|
|
113
|
+
...ObjectHelper.object(this.props.range)?.props?.style,
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return (React.createElement("span", { ref: (r) => this.sliderRangeElement = r, className: className, style: this.props.attrsRelay?.range?.style, id: this.props.attrsRelay?.range?.id }));
|
|
118
|
+
}
|
|
119
|
+
renderHandle(index, value) {
|
|
120
|
+
const finalValue = (this.props.inverse ? (100 - value) : value);
|
|
121
|
+
const key = `${index}|__|${DOMHelper.uniqueElementId("slider")}`;
|
|
122
|
+
const props = {
|
|
123
|
+
style: {
|
|
124
|
+
...(this.props.attrsRelay?.handle?.style ?? {}),
|
|
125
|
+
[this.props.orientation === Orientation.HORIZONTAL ? "left" : "top"]: `${finalValue}%`,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
const className = Classname.build("noseur-slider-handle", {
|
|
129
|
+
[`${this.props.attrsRelay?.handle?.scheme}-vars`]: !!this.props.attrsRelay?.handle?.scheme
|
|
130
|
+
}, this.props.attrsRelay?.handle?.className);
|
|
131
|
+
if (this.props.handle) {
|
|
132
|
+
return React.cloneElement(this.props.handle, {
|
|
133
|
+
key,
|
|
134
|
+
...props,
|
|
135
|
+
className,
|
|
136
|
+
draggable: true,
|
|
137
|
+
id: this.props.attrsRelay?.handle?.id
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return (React.createElement("span", { key: key, draggable: true, className: className, id: this.props.attrsRelay?.handle?.id, ...props }));
|
|
141
|
+
}
|
|
142
|
+
render() {
|
|
143
|
+
const range = this.renderRange();
|
|
144
|
+
const handles = this.state.values.map((value, index) => this.renderHandle(index, value));
|
|
145
|
+
const className = Classname.build("noseur-slider", `noseur-slider-${this.props.orientation}`, {
|
|
146
|
+
[`${this.props.scheme}-vars`]: !!this.props.scheme
|
|
147
|
+
}, this.props.className);
|
|
148
|
+
const ref = (r) => {
|
|
149
|
+
this.compoundRef = r;
|
|
150
|
+
const firstRender = !this.compoundRefRect;
|
|
151
|
+
ObjectHelper.resolveRef(this.props.forwardRef, r);
|
|
152
|
+
if (r)
|
|
153
|
+
this.compoundRefRect = DOMHelper.getElementRectWithOffset(this.compoundRef);
|
|
154
|
+
if (firstRender)
|
|
155
|
+
this.updateRange();
|
|
156
|
+
};
|
|
157
|
+
return (React.createElement("div", { ref: ref, className: className, id: this.props.id, style: this.props.style, key: this.props.key },
|
|
158
|
+
range,
|
|
159
|
+
React.createElement(DragSensor, { direction: this.props.orientation === Orientation.HORIZONTAL ? Direction.EAST_WEST : Direction.NORTH_SOUTH, draggable: this.props.draggable, singleton: true, boundToParent: true, ...this.props.attrsRelay?.dragSensorProps, onDragEvent: this.onHandleDrag }, handles)));
|
|
160
|
+
}
|
|
161
|
+
;
|
|
162
|
+
}
|
|
163
|
+
export const Slider = ({ ref, ...props }) => (React.createElement(SliderComponent, { ...props, forwardRef: ref }));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NoseurObject } from "../constants/Types";
|
|
2
|
+
import * as ReactRouterDom from "react-router-dom";
|
|
3
|
+
import { URLSearchParamsValue } from "../utils/DOMUtils";
|
|
4
|
+
export interface UseSearchParamsOptions<T> {
|
|
5
|
+
params?: T;
|
|
6
|
+
defaultInit?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function useSearchParams<T extends Record<string, URLSearchParamsValue>>(options?: UseSearchParamsOptions<T>): {
|
|
9
|
+
actionMapper: any;
|
|
10
|
+
searchParams: URLSearchParams;
|
|
11
|
+
setSearchParams: ReactRouterDom.SetURLSearchParams;
|
|
12
|
+
deleteSearchParam: (key: string, cb?: Function) => void;
|
|
13
|
+
updateSearchParam: (key: string, value: URLSearchParamsValue, cb?: Function) => void;
|
|
14
|
+
updateSearchParams: (values: NoseurObject<URLSearchParamsValue>, cb?: Function) => void;
|
|
15
|
+
} & { [K in keyof T & string]: T[K]; } & { [K_1 in keyof T & string as `set${Capitalize<K_1>}`]: (val: T[K_1] | undefined, cb?: Function) => void; } & { [K_2 in keyof T & string as `clear${Capitalize<K_2>}`]: (cb?: Function) => void; };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as ReactRouterDom from "react-router-dom";
|
|
3
|
+
import { DOMHelper } from "../utils/DOMUtils";
|
|
4
|
+
import { FunctionStackManager } from "../utils/FunctionStackManager";
|
|
5
|
+
export function useSearchParams(options) {
|
|
6
|
+
const actionMapper = {};
|
|
7
|
+
const [functionStackManager, _] = React.useState(new FunctionStackManager());
|
|
8
|
+
const [searchParams, setSearchParams] = ReactRouterDom.useSearchParams(options?.defaultInit);
|
|
9
|
+
React.useEffect(() => {
|
|
10
|
+
functionStackManager.popSmoke("USE_SEARCH_PARAMS_CB");
|
|
11
|
+
}, [searchParams]);
|
|
12
|
+
if (options?.params) {
|
|
13
|
+
Object.keys(options?.params).forEach((key) => {
|
|
14
|
+
actionMapper[key] = searchParams.get(key) ?? options?.params?.[key];
|
|
15
|
+
const setterName = `set${key.charAt(0).toUpperCase()}${key.slice(1)}`;
|
|
16
|
+
const clearerName = `clear${key.charAt(0).toUpperCase()}${key.slice(1)}`;
|
|
17
|
+
actionMapper[setterName] = ((newVal, cb) => {
|
|
18
|
+
actionMapper[key] = newVal;
|
|
19
|
+
if (cb)
|
|
20
|
+
functionStackManager.register("USE_SEARCH_PARAMS_CB", cb);
|
|
21
|
+
updateSearchParam(key, newVal);
|
|
22
|
+
}).bind(searchParams);
|
|
23
|
+
actionMapper[clearerName] = ((cb) => {
|
|
24
|
+
delete actionMapper[key];
|
|
25
|
+
if (cb)
|
|
26
|
+
functionStackManager.register("USE_SEARCH_PARAMS_CB", cb);
|
|
27
|
+
deleteSearchParam(key);
|
|
28
|
+
}).bind(searchParams);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
;
|
|
32
|
+
return {
|
|
33
|
+
actionMapper,
|
|
34
|
+
searchParams,
|
|
35
|
+
setSearchParams,
|
|
36
|
+
deleteSearchParam,
|
|
37
|
+
updateSearchParam,
|
|
38
|
+
updateSearchParams,
|
|
39
|
+
...actionMapper,
|
|
40
|
+
};
|
|
41
|
+
function deleteSearchParam(key, cb) {
|
|
42
|
+
DOMHelper.updateSearchParam(setSearchParams, key, undefined, cb);
|
|
43
|
+
}
|
|
44
|
+
function updateSearchParam(key, value, cb) {
|
|
45
|
+
DOMHelper.updateSearchParam(setSearchParams, key, value, cb);
|
|
46
|
+
}
|
|
47
|
+
function updateSearchParams(values, cb) {
|
|
48
|
+
DOMHelper.updateSearchParams(setSearchParams, values, cb);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Subscription } from "../utils/Subscriber";
|
|
2
|
+
export interface UseSubscriptionOptions {
|
|
3
|
+
skipRegister?: boolean;
|
|
4
|
+
skipUnRegister?: boolean;
|
|
5
|
+
reportAfterRegister?: any;
|
|
6
|
+
reportAfterUnRegister?: any;
|
|
7
|
+
reportBeforeUnRegister?: any;
|
|
8
|
+
}
|
|
9
|
+
export declare function useSubscription(key: string, subscription?: Subscription, options?: UseSubscriptionOptions): (...data: any) => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Subscriber } from "../utils/Subscriber";
|
|
3
|
+
export function useSubscription(key, subscription, options) {
|
|
4
|
+
React.useEffect(() => {
|
|
5
|
+
if (subscription && !options?.skipRegister) {
|
|
6
|
+
Subscriber.subscribe(key, subscription);
|
|
7
|
+
}
|
|
8
|
+
if (options?.reportAfterRegister) {
|
|
9
|
+
Subscriber.report(key, options?.reportAfterRegister);
|
|
10
|
+
}
|
|
11
|
+
return () => {
|
|
12
|
+
if (options?.reportBeforeUnRegister) {
|
|
13
|
+
Subscriber.report(key, options?.reportBeforeUnRegister);
|
|
14
|
+
}
|
|
15
|
+
if (subscription && !options?.skipUnRegister) {
|
|
16
|
+
Subscriber.unSubscribe(key, subscription);
|
|
17
|
+
}
|
|
18
|
+
if (options?.reportAfterUnRegister) {
|
|
19
|
+
Subscriber.report(key, options?.reportAfterUnRegister);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}, []);
|
|
23
|
+
return (...data) => {
|
|
24
|
+
Subscriber.report(key, ...data);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export * from "./core/ComponentBaseProps";
|
|
2
|
+
export * from "./constants/Types";
|
|
3
|
+
export * from "./constants/Scheme";
|
|
4
|
+
export * from "./constants/Direction";
|
|
5
|
+
export * from "./constants/Alignment";
|
|
6
|
+
export * from "./constants/Transition";
|
|
7
|
+
export * from "./constants/Orientation";
|
|
8
|
+
export * from "./utils/Timer";
|
|
9
|
+
export * from "./utils/Debugger";
|
|
10
|
+
export * from "./utils/DOMUtils";
|
|
11
|
+
export * from "./utils/Classname";
|
|
12
|
+
export * from "./utils/FileHelper";
|
|
13
|
+
export * from "./utils/BoolHelper";
|
|
14
|
+
export * from "./utils/DateHelper";
|
|
15
|
+
export * from "./utils/Subscriber";
|
|
16
|
+
export * from "./utils/InputHelper";
|
|
17
|
+
export * from "./utils/ColorHelper";
|
|
18
|
+
export * from "./utils/TypeChecker";
|
|
19
|
+
export * from "./utils/ObjectHelper";
|
|
20
|
+
export * from "./utils/StringHelper";
|
|
21
|
+
export * from "./compose/overlay/Alert";
|
|
22
|
+
export * from "./compose/form/FormGroup";
|
|
23
|
+
export * from "./compose/form/FormControl";
|
|
24
|
+
export * from "./compose/exotic/ColorSlider";
|
|
25
|
+
export * from "./compose/exotic/ColorPicker";
|
|
26
|
+
export * from "./compose/form/DateTimeInput";
|
|
27
|
+
export * from "./compose/form/DateTimePicker";
|
|
28
|
+
export * from "./compose/form/ComposedPassword";
|
|
29
|
+
export * from "./misc/ProgressBar";
|
|
30
|
+
export * from "./presentation/Chart";
|
|
31
|
+
export * from "./presentation/Paginator";
|
|
32
|
+
export * from "./form/Input";
|
|
33
|
+
export * from "./form/Button";
|
|
34
|
+
export * from "./form/Slider";
|
|
35
|
+
export * from "./form/ColorMap";
|
|
36
|
+
export * from "./form/Checkbox";
|
|
37
|
+
export * from "./form/Dropdown";
|
|
38
|
+
export * from "./form/Calendar";
|
|
39
|
+
export * from "./form/FileInput";
|
|
40
|
+
export * from "./form/RadioButton";
|
|
41
|
+
export * from "./form/ColorPalette";
|
|
42
|
+
export * from "./overlay/Portal";
|
|
43
|
+
export * from "./overlay/Message";
|
|
44
|
+
export * from "./overlay/Popover";
|
|
45
|
+
export * from "./overlay/Dialog";
|
|
46
|
+
export * from "./overlay/Toast";
|
|
47
|
+
export * from "./data/Data";
|
|
48
|
+
export * from "./data/Column";
|
|
49
|
+
export * from "./data/Table";
|
|
50
|
+
export * from "./data/List";
|
|
51
|
+
export * from "./panel/Panel";
|
|
52
|
+
export * from "./panel/TabPane";
|
|
53
|
+
export * from "./panel/Accordion";
|
|
54
|
+
export * from "./panel/ScrollPanel";
|
|
55
|
+
export * from "./layout/GridView";
|
|
56
|
+
export * from "./sensor/DragSensor";
|
|
57
|
+
export * from "./sensor/ViewportSensor";
|
|
58
|
+
export * from "./hooks/useSubscription";
|
|
59
|
+
export * from "./hooks/useSearchParams";
|
|
60
|
+
import "./core/noseur.css";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// core
|
|
2
|
+
export * from "./core/ComponentBaseProps";
|
|
3
|
+
// constants
|
|
4
|
+
export * from "./constants/Types";
|
|
5
|
+
export * from "./constants/Scheme";
|
|
6
|
+
export * from "./constants/Direction";
|
|
7
|
+
export * from "./constants/Alignment";
|
|
8
|
+
export * from "./constants/Transition";
|
|
9
|
+
export * from "./constants/Orientation";
|
|
10
|
+
// utils
|
|
11
|
+
export * from "./utils/Timer";
|
|
12
|
+
export * from "./utils/Debugger";
|
|
13
|
+
export * from "./utils/DOMUtils";
|
|
14
|
+
export * from "./utils/Classname";
|
|
15
|
+
export * from "./utils/FileHelper";
|
|
16
|
+
export * from "./utils/BoolHelper";
|
|
17
|
+
export * from "./utils/DateHelper";
|
|
18
|
+
export * from "./utils/Subscriber";
|
|
19
|
+
export * from "./utils/InputHelper";
|
|
20
|
+
export * from "./utils/ColorHelper";
|
|
21
|
+
export * from "./utils/TypeChecker";
|
|
22
|
+
export * from "./utils/ObjectHelper";
|
|
23
|
+
export * from "./utils/StringHelper";
|
|
24
|
+
// compose
|
|
25
|
+
export * from "./compose/overlay/Alert";
|
|
26
|
+
export * from "./compose/form/FormGroup";
|
|
27
|
+
export * from "./compose/form/FormControl";
|
|
28
|
+
export * from "./compose/exotic/ColorSlider";
|
|
29
|
+
export * from "./compose/exotic/ColorPicker";
|
|
30
|
+
export * from "./compose/form/DateTimeInput";
|
|
31
|
+
export * from "./compose/form/DateTimePicker";
|
|
32
|
+
export * from "./compose/form/ComposedPassword";
|
|
33
|
+
// misc
|
|
34
|
+
export * from "./misc/ProgressBar";
|
|
35
|
+
// presentation
|
|
36
|
+
export * from "./presentation/Chart";
|
|
37
|
+
export * from "./presentation/Paginator";
|
|
38
|
+
// form
|
|
39
|
+
export * from "./form/Input";
|
|
40
|
+
export * from "./form/Button";
|
|
41
|
+
export * from "./form/Slider";
|
|
42
|
+
export * from "./form/ColorMap";
|
|
43
|
+
export * from "./form/Checkbox";
|
|
44
|
+
export * from "./form/Dropdown";
|
|
45
|
+
export * from "./form/Calendar";
|
|
46
|
+
export * from "./form/FileInput";
|
|
47
|
+
export * from "./form/RadioButton";
|
|
48
|
+
export * from "./form/ColorPalette";
|
|
49
|
+
// overlay
|
|
50
|
+
export * from "./overlay/Portal";
|
|
51
|
+
export * from "./overlay/Message";
|
|
52
|
+
export * from "./overlay/Popover";
|
|
53
|
+
export * from "./overlay/Dialog";
|
|
54
|
+
export * from "./overlay/Toast";
|
|
55
|
+
// data
|
|
56
|
+
export * from "./data/Data";
|
|
57
|
+
export * from "./data/Column";
|
|
58
|
+
export * from "./data/Table";
|
|
59
|
+
export * from "./data/List";
|
|
60
|
+
// panel
|
|
61
|
+
export * from "./panel/Panel";
|
|
62
|
+
export * from "./panel/TabPane";
|
|
63
|
+
export * from "./panel/Accordion";
|
|
64
|
+
export * from "./panel/ScrollPanel";
|
|
65
|
+
// layout
|
|
66
|
+
export * from "./layout/GridView";
|
|
67
|
+
// sensor
|
|
68
|
+
export * from "./sensor/DragSensor";
|
|
69
|
+
export * from "./sensor/ViewportSensor";
|
|
70
|
+
// hooks
|
|
71
|
+
export * from "./hooks/useSubscription";
|
|
72
|
+
export * from "./hooks/useSearchParams";
|
|
73
|
+
import "./core/noseur.css";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "./Layout.css";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { ComponentBaseProps, ComponentElementBasicAttributes } from "../core/ComponentBaseProps";
|
|
4
|
+
export type GridViewAttributesRelays = {
|
|
5
|
+
map?: {
|
|
6
|
+
size: number;
|
|
7
|
+
} & ComponentElementBasicAttributes;
|
|
8
|
+
};
|
|
9
|
+
export interface GridViewManageRef {
|
|
10
|
+
}
|
|
11
|
+
export interface GridViewProps extends ComponentBaseProps<HTMLDivElement, GridViewManageRef, GridViewAttributesRelays> {
|
|
12
|
+
row: number;
|
|
13
|
+
column: number;
|
|
14
|
+
gap: number | {
|
|
15
|
+
row: number;
|
|
16
|
+
column: number;
|
|
17
|
+
};
|
|
18
|
+
columnSize: number | {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare const GridView: ({ ref, ...props }: Partial<GridViewProps>) => React.JSX.Element;
|