@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.
Files changed (138) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -0
  3. package/dist/esm/Template.d.ts +7 -0
  4. package/dist/esm/Template.js +13 -0
  5. package/dist/esm/compose/Composed.css +437 -0
  6. package/dist/esm/compose/exotic/ColorPicker.d.ts +41 -0
  7. package/dist/esm/compose/exotic/ColorPicker.js +85 -0
  8. package/dist/esm/compose/exotic/ColorSlider.d.ts +30 -0
  9. package/dist/esm/compose/exotic/ColorSlider.js +99 -0
  10. package/dist/esm/compose/form/ComposedPassword.d.ts +25 -0
  11. package/dist/esm/compose/form/ComposedPassword.js +103 -0
  12. package/dist/esm/compose/form/DateTimeInput.d.ts +28 -0
  13. package/dist/esm/compose/form/DateTimeInput.js +154 -0
  14. package/dist/esm/compose/form/DateTimePicker.d.ts +341 -0
  15. package/dist/esm/compose/form/DateTimePicker.js +1265 -0
  16. package/dist/esm/compose/form/FormControl.d.ts +33 -0
  17. package/dist/esm/compose/form/FormControl.js +163 -0
  18. package/dist/esm/compose/form/FormGroup.d.ts +14 -0
  19. package/dist/esm/compose/form/FormGroup.js +58 -0
  20. package/dist/esm/compose/overlay/Alert.d.ts +56 -0
  21. package/dist/esm/compose/overlay/Alert.js +267 -0
  22. package/dist/esm/constants/Alignment.d.ts +17 -0
  23. package/dist/esm/constants/Alignment.js +18 -0
  24. package/dist/esm/constants/Direction.d.ts +26 -0
  25. package/dist/esm/constants/Direction.js +22 -0
  26. package/dist/esm/constants/Orientation.d.ts +8 -0
  27. package/dist/esm/constants/Orientation.js +9 -0
  28. package/dist/esm/constants/Scheme.d.ts +39 -0
  29. package/dist/esm/constants/Scheme.js +43 -0
  30. package/dist/esm/constants/Transition.d.ts +81 -0
  31. package/dist/esm/constants/Transition.js +85 -0
  32. package/dist/esm/constants/Types.d.ts +74 -0
  33. package/dist/esm/constants/Types.js +14 -0
  34. package/dist/esm/core/ComponentBaseProps.d.ts +53 -0
  35. package/dist/esm/core/ComponentBaseProps.js +33 -0
  36. package/dist/esm/core/noseur.css +2390 -0
  37. package/dist/esm/data/Column.d.ts +235 -0
  38. package/dist/esm/data/Column.js +98 -0
  39. package/dist/esm/data/Data.css +213 -0
  40. package/dist/esm/data/Data.d.ts +98 -0
  41. package/dist/esm/data/Data.js +142 -0
  42. package/dist/esm/data/List.d.ts +14 -0
  43. package/dist/esm/data/List.js +117 -0
  44. package/dist/esm/data/Table.d.ts +22 -0
  45. package/dist/esm/data/Table.js +236 -0
  46. package/dist/esm/form/Button.d.ts +35 -0
  47. package/dist/esm/form/Button.js +131 -0
  48. package/dist/esm/form/Calendar.d.ts +20 -0
  49. package/dist/esm/form/Calendar.js +46 -0
  50. package/dist/esm/form/Checkbox.d.ts +20 -0
  51. package/dist/esm/form/Checkbox.js +155 -0
  52. package/dist/esm/form/ColorMap.d.ts +22 -0
  53. package/dist/esm/form/ColorMap.js +43 -0
  54. package/dist/esm/form/ColorPalette.d.ts +28 -0
  55. package/dist/esm/form/ColorPalette.js +87 -0
  56. package/dist/esm/form/Dropdown.d.ts +78 -0
  57. package/dist/esm/form/Dropdown.js +360 -0
  58. package/dist/esm/form/FileInput.d.ts +134 -0
  59. package/dist/esm/form/FileInput.js +523 -0
  60. package/dist/esm/form/Form.css +467 -0
  61. package/dist/esm/form/Input.d.ts +45 -0
  62. package/dist/esm/form/Input.js +186 -0
  63. package/dist/esm/form/RadioButton.d.ts +21 -0
  64. package/dist/esm/form/RadioButton.js +178 -0
  65. package/dist/esm/form/Slider.d.ts +21 -0
  66. package/dist/esm/form/Slider.js +163 -0
  67. package/dist/esm/hooks/useSearchParams.d.ts +15 -0
  68. package/dist/esm/hooks/useSearchParams.js +50 -0
  69. package/dist/esm/hooks/useSubscription.d.ts +9 -0
  70. package/dist/esm/hooks/useSubscription.js +26 -0
  71. package/dist/esm/index.d.ts +60 -0
  72. package/dist/esm/index.js +73 -0
  73. package/dist/esm/layout/GridView.d.ts +23 -0
  74. package/dist/esm/layout/GridView.js +34 -0
  75. package/dist/esm/layout/Layout.css +5 -0
  76. package/dist/esm/misc/Misc.css +164 -0
  77. package/dist/esm/misc/ProgressBar.d.ts +22 -0
  78. package/dist/esm/misc/ProgressBar.js +86 -0
  79. package/dist/esm/overlay/Dialog.d.ts +46 -0
  80. package/dist/esm/overlay/Dialog.js +290 -0
  81. package/dist/esm/overlay/Message.d.ts +35 -0
  82. package/dist/esm/overlay/Message.js +187 -0
  83. package/dist/esm/overlay/Overlay.css +382 -0
  84. package/dist/esm/overlay/Popover.d.ts +30 -0
  85. package/dist/esm/overlay/Popover.js +245 -0
  86. package/dist/esm/overlay/Portal.d.ts +11 -0
  87. package/dist/esm/overlay/Portal.js +29 -0
  88. package/dist/esm/overlay/Toast.d.ts +49 -0
  89. package/dist/esm/overlay/Toast.js +341 -0
  90. package/dist/esm/panel/Accordion.d.ts +26 -0
  91. package/dist/esm/panel/Accordion.js +127 -0
  92. package/dist/esm/panel/Panel.css +317 -0
  93. package/dist/esm/panel/Panel.d.ts +43 -0
  94. package/dist/esm/panel/Panel.js +125 -0
  95. package/dist/esm/panel/ScrollPanel.d.ts +27 -0
  96. package/dist/esm/panel/ScrollPanel.js +43 -0
  97. package/dist/esm/panel/TabPane.d.ts +82 -0
  98. package/dist/esm/panel/TabPane.js +237 -0
  99. package/dist/esm/presentation/Chart.d.ts +49 -0
  100. package/dist/esm/presentation/Chart.js +62 -0
  101. package/dist/esm/presentation/Paginator.d.ts +90 -0
  102. package/dist/esm/presentation/Paginator.js +331 -0
  103. package/dist/esm/presentation/Presentation.css +23 -0
  104. package/dist/esm/sensor/DragSensor.d.ts +50 -0
  105. package/dist/esm/sensor/DragSensor.js +156 -0
  106. package/dist/esm/sensor/ViewportSensor.d.ts +18 -0
  107. package/dist/esm/sensor/ViewportSensor.js +85 -0
  108. package/dist/esm/utils/BoolHelper.d.ts +13 -0
  109. package/dist/esm/utils/BoolHelper.js +105 -0
  110. package/dist/esm/utils/Classname.d.ts +9 -0
  111. package/dist/esm/utils/Classname.js +20 -0
  112. package/dist/esm/utils/ColorHelper.d.ts +127 -0
  113. package/dist/esm/utils/ColorHelper.js +198 -0
  114. package/dist/esm/utils/DOMUtils.d.ts +142 -0
  115. package/dist/esm/utils/DOMUtils.js +759 -0
  116. package/dist/esm/utils/DateHelper.d.ts +115 -0
  117. package/dist/esm/utils/DateHelper.js +338 -0
  118. package/dist/esm/utils/Debugger.d.ts +12 -0
  119. package/dist/esm/utils/Debugger.js +30 -0
  120. package/dist/esm/utils/FileHelper.d.ts +8 -0
  121. package/dist/esm/utils/FileHelper.js +65 -0
  122. package/dist/esm/utils/FunctionStackManager.d.ts +13 -0
  123. package/dist/esm/utils/FunctionStackManager.js +59 -0
  124. package/dist/esm/utils/InputHelper.d.ts +37 -0
  125. package/dist/esm/utils/InputHelper.js +70 -0
  126. package/dist/esm/utils/MicroBuilder.d.ts +24 -0
  127. package/dist/esm/utils/MicroBuilder.js +61 -0
  128. package/dist/esm/utils/ObjectHelper.d.ts +51 -0
  129. package/dist/esm/utils/ObjectHelper.js +334 -0
  130. package/dist/esm/utils/StringHelper.d.ts +10 -0
  131. package/dist/esm/utils/StringHelper.js +54 -0
  132. package/dist/esm/utils/Subscriber.d.ts +14 -0
  133. package/dist/esm/utils/Subscriber.js +27 -0
  134. package/dist/esm/utils/Timer.d.ts +32 -0
  135. package/dist/esm/utils/Timer.js +68 -0
  136. package/dist/esm/utils/TypeChecker.d.ts +12 -0
  137. package/dist/esm/utils/TypeChecker.js +38 -0
  138. package/package.json +63 -0
@@ -0,0 +1,131 @@
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
+ ;
9
+ ;
10
+ class ButtonComponent extends React.Component {
11
+ static defaultProps = {
12
+ scheme: Scheme.STATELESS,
13
+ leftIconRelativeAlignment: Alignment.LEFT,
14
+ rightIconRelativeAlignment: Alignment.RIGHT,
15
+ };
16
+ state = {
17
+ rippleState: { isRippling: false, x: -1, y: -1 },
18
+ };
19
+ buttonManagerRef;
20
+ constructor(props) {
21
+ super(props);
22
+ this.onClick = this.onClick.bind(this);
23
+ }
24
+ componentDidMount() {
25
+ this.buttonManagerRef = {
26
+ setLoadingState: (isLoading) => this.setState({ isLoading }),
27
+ };
28
+ ObjectHelper.resolveManageRef(this, this.buttonManagerRef);
29
+ }
30
+ componentDidUpdate(_, prevState) {
31
+ if (prevState.rippleState.isRippling != this.state.rippleState.isRippling && !this.state.rippleState.isRippling) {
32
+ this.setState({ rippleState: { ...this.state.rippleState, x: -1, y: -1 } });
33
+ }
34
+ if ((prevState.rippleState.x != this.state.rippleState.x) && (prevState.rippleState.y != this.state.rippleState.y)) {
35
+ if (this.state.rippleState.x != -1 && this.state.rippleState.y != -1) {
36
+ this.setState({ rippleState: { ...this.state.rippleState, isRippling: true } });
37
+ setTimeout(() => this.setState({ rippleState: { ...this.state.rippleState, isRippling: false } }), 300);
38
+ }
39
+ else {
40
+ this.setState({ rippleState: { ...this.state.rippleState, isRippling: false } });
41
+ }
42
+ }
43
+ }
44
+ componentWillUnmount() {
45
+ ObjectHelper.resolveManageRef(this, null);
46
+ this.buttonManagerRef = undefined;
47
+ }
48
+ onClick(activeProps, event) {
49
+ if (activeProps.rippleEffect) {
50
+ const button = event.currentTarget;
51
+ const rect = event.target.getBoundingClientRect();
52
+ this.setState({
53
+ rippleState: {
54
+ diameter: button.clientHeight,
55
+ isRippling: false,
56
+ y: event.clientY - rect.top,
57
+ x: event.clientX - rect.left
58
+ }
59
+ });
60
+ }
61
+ event.manageRef = this.buttonManagerRef;
62
+ this.props.onClick && this.props.onClick(event);
63
+ }
64
+ render() {
65
+ const activeProps = {
66
+ ...this.props,
67
+ ...(this.state.isLoading ? (this.props.loadingProps || {}) : {})
68
+ };
69
+ const eventProps = ObjectHelper.extractEventProps(activeProps);
70
+ const className = Classname.build((!activeProps.noStyle && activeProps.raised) ? `${activeProps.scheme}-bd-rd` : null, (!activeProps.noStyle && activeProps.scheme) ? `${activeProps.scheme}-bd-3px-bx-sw-ac` : null, (!activeProps.noStyle && activeProps.scheme) ? `${activeProps.scheme}-bd-3px-bx-sw-fc` : null, (!activeProps.noStyle && !activeProps.textOnly && !activeProps.outlined) ? activeProps.scheme : null, (!activeProps.noStyle && activeProps.scheme && activeProps.outlined) ? `${activeProps.scheme}-bd-cl` : null, (!activeProps.noStyle && activeProps.scheme && (activeProps.outlined || activeProps.textOnly)) ? `${activeProps.scheme}-tx` : null, (!activeProps.noStyle && activeProps.rippleEffect && (activeProps.outlined || activeProps.textOnly)) ? `${activeProps.scheme}-rp` : null, (!activeProps.noStyle && activeProps.scheme && (activeProps.outlined || activeProps.textOnly) && activeProps.fillOnHover) ? `${activeProps.scheme}-bg-hv` : null, {
71
+ 'noseur-wd-auto': activeProps.fill,
72
+ 'noseur-disabled': !activeProps.noStyle && activeProps.disabled,
73
+ 'noseur-rounded-bd': !activeProps.noStyle && activeProps.rounded,
74
+ 'noseur-pd-10': !activeProps.children && !activeProps.text && !activeProps.iconOnly,
75
+ 'noseur-no-bg': !activeProps.noStyle && (activeProps.outlined || activeProps.textOnly),
76
+ 'noseur-no-bd': !activeProps.noStyle && (activeProps.borderless || (activeProps.textOnly && !activeProps.outlined)),
77
+ }, "noseur-button", activeProps.className);
78
+ const children = [];
79
+ if (activeProps.text)
80
+ children.push(activeProps.text);
81
+ if (activeProps.children)
82
+ children.push(activeProps.children);
83
+ const rightIcon = MicroBuilder.buildIcon(activeProps.rightIcon, {
84
+ scheme: activeProps.scheme,
85
+ relativeAlignment: children.length ? activeProps.rightIconRelativeAlignment : Alignment.NONE
86
+ });
87
+ const leftIcon = MicroBuilder.buildIcon(activeProps.leftIcon, {
88
+ scheme: activeProps.scheme,
89
+ relativeAlignment: children.length ? activeProps.leftIconRelativeAlignment : Alignment.NONE,
90
+ fillIcon: activeProps.fillLeftIcon
91
+ });
92
+ if (rightIcon)
93
+ children.push(rightIcon);
94
+ if (leftIcon)
95
+ children.unshift(leftIcon);
96
+ if (this.state.rippleState.isRippling) {
97
+ const style = {
98
+ width: this.state.rippleState.diameter,
99
+ height: this.state.rippleState.diameter,
100
+ left: this.state.rippleState.x, right: this.state.rippleState.x,
101
+ };
102
+ children.push((React.createElement("span", { className: "noseur-rp", style: style })));
103
+ }
104
+ const props = {
105
+ children,
106
+ className,
107
+ ...eventProps,
108
+ key: activeProps.key,
109
+ type: this.props.type,
110
+ style: activeProps.style,
111
+ draggable: this.props.draggable,
112
+ onClick: (e) => {
113
+ this.onClick(activeProps, e);
114
+ },
115
+ };
116
+ return (!activeProps.link
117
+ ? React.createElement("button", { ref: this.props.forwardRef, ...props })
118
+ : React.createElement("a", { ref: this.props.forwardRef, ...props, href: activeProps.link, target: activeProps.linkTarget }));
119
+ }
120
+ }
121
+ export const Button = ({ ref, ...props }) => (React.createElement(ButtonComponent, { ...props, forwardRef: ref }));
122
+ export function buildButtonControl(control, customNonOverridingProps, cb, className) {
123
+ if (!control || React.isValidElement(control))
124
+ return control;
125
+ const buttonProps = {
126
+ ...customNonOverridingProps,
127
+ ...control,
128
+ className: Classname.build(className, control.className)
129
+ };
130
+ return React.createElement(Button, { ...buttonProps, onClick: cb });
131
+ }
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import { ComponentBaseProps, ComponentElementBasicAttributes } from "../core/ComponentBaseProps";
3
+ export type CalendarAttributesRelays = {
4
+ day?: {} & ComponentElementBasicAttributes;
5
+ week?: {} & ComponentElementBasicAttributes;
6
+ };
7
+ export declare enum CalenderMode {
8
+ DAY = 0,
9
+ WEEK = 1,
10
+ YEAR = 2,
11
+ MONTH = 3,
12
+ XDAYS = 4,
13
+ SCHEDULE = 5
14
+ }
15
+ export interface CalendarManageRef {
16
+ }
17
+ export interface CalendarProps extends ComponentBaseProps<HTMLDivElement, CalendarManageRef, CalendarAttributesRelays> {
18
+ mode: CalenderMode;
19
+ }
20
+ export declare const Calendar: ({ ref, ...props }: Partial<CalendarProps>) => React.JSX.Element;
@@ -0,0 +1,46 @@
1
+ import React from "react";
2
+ import { Classname } from "../utils/Classname";
3
+ export var CalenderMode;
4
+ (function (CalenderMode) {
5
+ CalenderMode[CalenderMode["DAY"] = 0] = "DAY";
6
+ CalenderMode[CalenderMode["WEEK"] = 1] = "WEEK";
7
+ CalenderMode[CalenderMode["YEAR"] = 2] = "YEAR";
8
+ CalenderMode[CalenderMode["MONTH"] = 3] = "MONTH";
9
+ CalenderMode[CalenderMode["XDAYS"] = 4] = "XDAYS";
10
+ CalenderMode[CalenderMode["SCHEDULE"] = 5] = "SCHEDULE";
11
+ })(CalenderMode || (CalenderMode = {}));
12
+ class CalendarComponent extends React.Component {
13
+ static defaultProps = {
14
+ mode: CalenderMode.WEEK,
15
+ };
16
+ state = {
17
+ mode: this.props.mode
18
+ };
19
+ constructor(props) {
20
+ super(props);
21
+ }
22
+ componentDidUpdate(__, _) {
23
+ }
24
+ renderCalendarDayView() {
25
+ return (React.createElement("div", { className: Classname.build("noseur-calendar-day", this.props.attrsRelay.day?.className), style: this.props.attrsRelay.day?.style, id: this.props.attrsRelay.day?.id }, "Day"));
26
+ }
27
+ renderCalendarWeekView() {
28
+ return (React.createElement("div", { className: Classname.build("noseur-calendar-week", this.props.attrsRelay.week?.className), style: this.props.attrsRelay.week?.style, id: this.props.attrsRelay.week?.id }, "Day"));
29
+ }
30
+ renderCalendarView() {
31
+ if (this.state.mode === CalenderMode.DAY) {
32
+ return this.renderCalendarDayView();
33
+ }
34
+ return this.renderCalendarWeekView();
35
+ }
36
+ render() {
37
+ let view = this.renderCalendarView();
38
+ const className = Classname.build("noseur-calendar", this.props.className);
39
+ const style = {
40
+ ...(this.props.style ?? {}),
41
+ };
42
+ return (React.createElement("div", { className: className, style: style, id: this.props.id, key: this.props.key }, view));
43
+ }
44
+ ;
45
+ }
46
+ export const Calendar = ({ ref, ...props }) => (React.createElement(CalendarComponent, { ...props, forwardRef: ref }));
@@ -0,0 +1,20 @@
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 CheckboxProps extends ComponentBaseProps<NoseurFormElement | HTMLLabelElement> {
7
+ checked: boolean;
8
+ readOnly: boolean;
9
+ required: boolean;
10
+ label: NoseurLabel;
11
+ highlight: boolean;
12
+ alignLabel: Alignment;
13
+ defaultChecked: boolean;
14
+ alwaysRenderInput: boolean;
15
+ checkedIndex: NoseurNummber;
16
+ checkStates: NoseurCheckState[];
17
+ defaultCheckedIndex: NoseurNummber;
18
+ onChecked?: (checked: boolean) => void | boolean;
19
+ }
20
+ export declare const Checkbox: ({ ref, ...props }: Partial<CheckboxProps>) => React.JSX.Element;
@@ -0,0 +1,155 @@
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
+ ;
9
+ class CheckboxComponent extends React.Component {
10
+ static defaultProps = {
11
+ scheme: Scheme.STATELESS,
12
+ alignLabel: Alignment.RIGHT,
13
+ checkStates: [
14
+ {
15
+ icon: null,
16
+ checked: false,
17
+ scheme: Scheme.NIL,
18
+ value: "un-checked",
19
+ },
20
+ {
21
+ checked: true,
22
+ value: "checked",
23
+ icon: "fa fa-check",
24
+ scheme: Scheme.PRIMARY,
25
+ }
26
+ ]
27
+ };
28
+ state = {
29
+ checkedIndex: this.getFirstCheckedValue(),
30
+ };
31
+ constructor(props) {
32
+ super(props);
33
+ this.onClick = this.onClick.bind(this);
34
+ this.onKeyDown = this.onKeyDown.bind(this);
35
+ this.onCheckBoxClicked = this.onCheckBoxClicked.bind(this);
36
+ this.getFirstCheckedValue = this.getFirstCheckedValue.bind(this);
37
+ }
38
+ componentDidUpdate(prevProps) {
39
+ if ((prevProps.checked !== undefined && prevProps.checked !== this.props.checked)
40
+ || (prevProps.checkedIndex !== undefined && prevProps.checkedIndex !== this.props.checkedIndex)) {
41
+ this.setState({ checkedIndex: this.getFirstCheckedValue() });
42
+ }
43
+ }
44
+ onClick(event) {
45
+ this.props.onClick && this.props.onClick(event);
46
+ event.stopPropagation();
47
+ this.onCheckBoxClicked(event);
48
+ }
49
+ onKeyDown(event) {
50
+ this.props.onKeyDown && this.props.onKeyDown(event);
51
+ if (event.code == "Space") {
52
+ event.preventDefault();
53
+ event.stopPropagation();
54
+ this.onCheckBoxClicked(event);
55
+ }
56
+ }
57
+ onCheckBoxClicked(event) {
58
+ if (this.props.readOnly)
59
+ return;
60
+ let newCheckedIndex = this.getCheckStatesIndex() + 1;
61
+ if (newCheckedIndex >= this.props.checkStates.length)
62
+ newCheckedIndex = 0;
63
+ let checkState = this.props.checkStates[newCheckedIndex];
64
+ if (this.props.onChecked?.(checkState?.checked) === true && checkState?.checked === true) {
65
+ return;
66
+ }
67
+ this.props.onChange?.({
68
+ ...event,
69
+ checkState,
70
+ value: checkState?.value,
71
+ checked: checkState?.checked
72
+ });
73
+ this.setState({ checkedIndex: newCheckedIndex });
74
+ }
75
+ getCheckStatesIndex() {
76
+ if (this.props.checkedIndex)
77
+ return this.props.checkedIndex;
78
+ if (this.props.checked || this.props.checkedIndex != null)
79
+ return this.getFirstCheckedValue();
80
+ const checkStatesSize = this.props.checkStates.length;
81
+ let checkedIndex = this.state.checkedIndex;
82
+ if (checkedIndex >= checkStatesSize) {
83
+ checkedIndex = 0;
84
+ }
85
+ return checkedIndex;
86
+ }
87
+ getFirstCheckedValue() {
88
+ if (this.props.checkStates.length == 2 && this.props.checkStates[0].scheme == Scheme.NIL) {
89
+ if (this.props.checked || this.props.defaultChecked)
90
+ return 1;
91
+ if (this.props.checkedIndex != null)
92
+ return this.props.checkedIndex;
93
+ if (this.props.defaultCheckedIndex != null)
94
+ return this.props.defaultCheckedIndex;
95
+ }
96
+ return 0;
97
+ }
98
+ buildInput(checkState) {
99
+ if (!checkState.checked && !this.props.alwaysRenderInput)
100
+ return;
101
+ const props = {
102
+ id: this.props.id,
103
+ name: this.props.name,
104
+ checked: checkState.checked,
105
+ required: this.props.required,
106
+ onClick: () => { },
107
+ onChange: (e) => { e.stopPropagation(); }
108
+ };
109
+ return React.createElement("input", { type: "checkbox", ...props });
110
+ }
111
+ buildBox(checkState) {
112
+ const scheme = this.props.checkStates.length == 2 && this.props.checkStates[0].scheme == Scheme.NIL
113
+ ? this.props.scheme : (checkState.scheme ?? this.props.scheme);
114
+ const className = Classname.build("noseur-checkbox-box", (!this.props.noStyle && scheme) ? `${scheme}-bd-3px-bx-sw-fc` : null, (!this.props.noStyle && !checkState.scheme) ? `noseur-form-bd-cl` : null, (!this.props.noStyle && checkState.scheme) ? scheme : 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, {
115
+ 'noseur-skeleton': scheme === Scheme.SKELETON,
116
+ }, this.props.className);
117
+ const icon = MicroBuilder.buildIcon(checkState.icon, {
118
+ scheme: checkState.scheme
119
+ });
120
+ const props = {
121
+ className,
122
+ tabIndex: 1,
123
+ onClick: this.onClick,
124
+ onKeyDown: this.onKeyDown,
125
+ };
126
+ return (React.createElement("span", { ...props }, icon));
127
+ }
128
+ render() {
129
+ const checkState = this.props.checkStates[this.getCheckStatesIndex()];
130
+ const box = this.buildBox(checkState);
131
+ const input = this.buildInput(checkState);
132
+ const label = MicroBuilder.buildLabel(this.props.label, {
133
+ scheme: this.props.scheme,
134
+ relativeAlignment: this.props.alignLabel,
135
+ }, { onClick: this.onClick });
136
+ const className = Classname.build("noseur-checkbox", {
137
+ 'noseur-fl-d-c-r': this.props.alignLabel === Alignment.TOP,
138
+ 'noseur-fl-d-r-r': this.props.alignLabel === Alignment.LEFT,
139
+ 'noseur-fl-d-c': this.props.alignLabel === Alignment.BOTTOM,
140
+ 'noseur-disabled': !this.props.noStyle && this.props.disabled,
141
+ });
142
+ const eventProps = ObjectHelper.extractEventProps(this.props, ["onChecked"]);
143
+ const props = {
144
+ className,
145
+ ...eventProps,
146
+ key: this.props.key,
147
+ style: this.props.style,
148
+ };
149
+ return (React.createElement("label", { ref: this.props.forwardRef, ...props },
150
+ box,
151
+ label,
152
+ input));
153
+ }
154
+ }
155
+ export const Checkbox = ({ ref, ...props }) => (React.createElement(CheckboxComponent, { ...props, forwardRef: ref }));
@@ -0,0 +1,22 @@
1
+ import React from "react";
2
+ import { Alignment } from "../constants/Alignment";
3
+ import { Color, NoseurElement } from "../constants/Types";
4
+ import { ComponentBaseProps, ComponentElementBasicAttributes } from "../core/ComponentBaseProps";
5
+ export type ColorMapAttributesRelays = {
6
+ map?: {
7
+ size: number;
8
+ } & ComponentElementBasicAttributes;
9
+ };
10
+ export interface ColorMapManageRef {
11
+ }
12
+ export interface ColorMapProps extends ComponentBaseProps<HTMLDivElement, ColorMapManageRef, ColorMapAttributesRelays> {
13
+ hex: string;
14
+ color: Color;
15
+ hideMap: boolean;
16
+ hideAlpha: boolean;
17
+ hideSlider: boolean;
18
+ alignAlpha: Alignment;
19
+ alignSlider: Alignment;
20
+ indicator: NoseurElement;
21
+ }
22
+ export declare const ColorMap: ({ ref, ...props }: Partial<ColorMapProps>) => React.JSX.Element;
@@ -0,0 +1,43 @@
1
+ import React from "react";
2
+ import { Classname } from "../utils/Classname";
3
+ class ColorMapComponent extends React.Component {
4
+ static defaultProps = {
5
+ hex: "#000000",
6
+ };
7
+ state = {
8
+ hex: this.props.hex ?? this.props.color?.hex
9
+ };
10
+ constructor(props) {
11
+ super(props);
12
+ }
13
+ componentDidUpdate(prevProps, _) {
14
+ if (this.props.hex !== prevProps.hex || this.props.color !== prevProps.color) {
15
+ this.setState({ hex: (this.props.hex !== prevProps.hex
16
+ ? this.props.hex
17
+ : (this.props.color !== prevProps.color ? this.props.color.hex : this.state.hex)) });
18
+ }
19
+ }
20
+ renderMap() {
21
+ if (this.props.hideMap)
22
+ return;
23
+ const className = Classname.build("noseur-color-map-map", this.props.attrsRelay?.map?.className);
24
+ const style = {
25
+ width: this.props.attrsRelay?.map?.size ?? 180,
26
+ height: this.props.attrsRelay?.map?.size ?? 180,
27
+ ...(this.props.attrsRelay?.map?.style ?? {}),
28
+ backgroundColor: this.state.hex,
29
+ };
30
+ return (React.createElement("div", { className: className, style: style, id: this.props.attrsRelay?.map?.id, key: this.props.attrsRelay?.map?.id },
31
+ React.createElement("div", { className: "noseur-color-map-map-gradient" })));
32
+ }
33
+ render() {
34
+ const map = this.renderMap();
35
+ const className = Classname.build("noseur-color-map", this.props.className);
36
+ const style = {
37
+ ...(this.props.style ?? {}),
38
+ };
39
+ return (React.createElement("div", { className: className, style: style, id: this.props.id, key: this.props.key }, map));
40
+ }
41
+ ;
42
+ }
43
+ export const ColorMap = ({ ref, ...props }) => (React.createElement(ColorMapComponent, { ...props, forwardRef: ref }));
@@ -0,0 +1,28 @@
1
+ import React from "react";
2
+ import { ColorEventHandler, NoseurObject } from "../constants/Types";
3
+ import { ComponentBaseProps, ComponentElementBasicAttributes } from "../core/ComponentBaseProps";
4
+ export type ColorPaletteAttributesRelays = {
5
+ tile?: ComponentElementBasicAttributes;
6
+ };
7
+ export interface ColorPaletteProps extends ComponentBaseProps<HTMLDivElement, {}, ColorPaletteAttributesRelays> {
8
+ grid: number;
9
+ defaultValue: string;
10
+ palette: string[] | string;
11
+ gap: number | {
12
+ row: number;
13
+ column: number;
14
+ };
15
+ size: number | {
16
+ width: number;
17
+ height: number;
18
+ };
19
+ onSelectColor: ColorEventHandler;
20
+ }
21
+ export declare class ColorPaletteRegistry {
22
+ private static _registeredPalette;
23
+ static get(): NoseurObject<string[]>;
24
+ static getPalette(palette: string[] | string): string[];
25
+ static register(key: string, palette: string[]): void;
26
+ static unregister(key: string): void;
27
+ }
28
+ export declare const ColorPalette: ({ ref, ...props }: Partial<ColorPaletteProps>) => React.JSX.Element;
@@ -0,0 +1,87 @@
1
+ import React from "react";
2
+ import { Classname } from "../utils/Classname";
3
+ import { ColorHelper } from "../utils/ColorHelper";
4
+ class ColorPaletteComponent extends React.Component {
5
+ static defaultProps = {
6
+ gap: 0,
7
+ size: 25,
8
+ grid: 10,
9
+ };
10
+ state = {
11
+ value: this.props.defaultValue,
12
+ palette: ColorPaletteRegistry.getPalette(this.props.palette) ?? [],
13
+ };
14
+ constructor(props) {
15
+ super(props);
16
+ }
17
+ onSelectColor(value) {
18
+ const previous = this.state.value;
19
+ const eventValue = { color: ColorHelper.hexToColor(value), previousColor: ColorHelper.hexToColor(previous) };
20
+ this.props.onChange && this.props.onChange({ value: eventValue });
21
+ if ((this.props.onSelectColor && this.props.onSelectColor(eventValue) === true))
22
+ return;
23
+ this.setState({ value });
24
+ }
25
+ renderTile(color) {
26
+ const style = {
27
+ backgroundColor: color,
28
+ border: `1px solid ${color}`,
29
+ width: (typeof this.props.size === "number" ? this.props.size : this.props.size.width) - 2,
30
+ height: (typeof this.props.size === "number" ? this.props.size : this.props.size.height) - 2,
31
+ minWidth: (typeof this.props.size === "number" ? this.props.size : this.props.size.width) - 2,
32
+ ...(this.props.attrsRelay?.tile?.style ?? {})
33
+ };
34
+ return (React.createElement("div", { key: color, className: Classname.build("noseur-color-palette-tile", this.props.attrsRelay?.tile?.className, { "active": color === this.state.value }), style: style, onClick: () => this.onSelectColor(color) }));
35
+ }
36
+ render() {
37
+ const width = (typeof this.props.size === "number" ? this.props.size : this.props.size.width);
38
+ const className = Classname.build("noseur-color-palette", this.props.className);
39
+ const style = {
40
+ ...(this.props.style ?? {}),
41
+ gridTemplateColumns: Array(Math.min(this.state.palette.length, this.props.grid)).fill(`${width}px`).join(" "),
42
+ columnGap: (typeof this.props.gap !== "number" ? this.props.gap.column : undefined),
43
+ rowGap: (typeof this.props.gap !== "number" ? this.props.gap.row : undefined),
44
+ gap: (typeof this.props.gap === "number" ? this.props.gap : undefined),
45
+ };
46
+ return (React.createElement("div", { className: className, style: style, id: this.props.id, key: this.props.key }, this.state.palette.map((color) => this.renderTile(color))));
47
+ }
48
+ ;
49
+ }
50
+ export class ColorPaletteRegistry {
51
+ static _registeredPalette = {};
52
+ static get() {
53
+ return ColorPaletteRegistry._registeredPalette;
54
+ }
55
+ static getPalette(palette) {
56
+ if (typeof palette !== "string")
57
+ return palette;
58
+ return (palette in ColorPaletteRegistry._registeredPalette ? ColorPaletteRegistry._registeredPalette[palette] : []);
59
+ }
60
+ static register(key, palette) {
61
+ ColorPaletteRegistry._registeredPalette[key] = palette;
62
+ }
63
+ static unregister(key) {
64
+ if (!(key in ColorPaletteRegistry._registeredPalette))
65
+ return;
66
+ delete ColorPaletteRegistry._registeredPalette[key];
67
+ }
68
+ }
69
+ export const ColorPalette = ({ ref, ...props }) => (React.createElement(ColorPaletteComponent, { ...props, forwardRef: ref }));
70
+ let _defaultPaletteAlreadyRegistered = false;
71
+ if (!_defaultPaletteAlreadyRegistered) {
72
+ _defaultPaletteAlreadyRegistered = true;
73
+ ColorPaletteRegistry.register("Microsoft", ["#f65314", "#7cbb00", "#00a1f1", "#ffbb00", "#737373"]); // https://www.color-hex.com/color-palette/4744
74
+ ColorPaletteRegistry.register("MicrosofVisualStudio", ["#5d2b90", "#008a00", "#333333", "#ffffff", "#000000"]); // https://www.color-hex.com/color-palette/12832
75
+ ColorPaletteRegistry.register("MicrosoftDynamicsCRM", ["#002050", "#dfe2e8", "#1160b7", "#b1d6f0", "#d24726"]); // https://www.color-hex.com/color-palette/29680
76
+ ColorPaletteRegistry.register("MicrosoftWordHighlighters", ["#ff0000", "#ffff00", "#00ff00", "#00ffff", "#ff00ff"]); // https://www.color-hex.com/color-palette/98189
77
+ ColorPaletteRegistry.register("Default", [
78
+ "#000000", "#444444", "#5b5b5b", "#999999", "#bcbcbc", "#eeeeee", "#f3f6f4", "#ffffff",
79
+ "#f44336", "#744700", "#ce7e00", "#8fce00", "#2986cc", "#16537e", "#6a329f", "#c90076",
80
+ "#f4cccc", "#fce5cd", "#fff2cc", "#d9ead3", "#d0e0e3", "#cfe2f3", "#d9d2e9", "#ead1dc",
81
+ "#ea9999", "#f9cb9c", "#ffe599", "#b6d7a8", "#a2c4c9", "#9fc5e8", "#b4a7d6", "#d5a6bd",
82
+ "#e06666", "#f6b26b", "#ffd966", "#93c47d", "#76a5af", "#6fa8dc", "#8e7cc3", "#c27ba0",
83
+ "#cc0000", "#e69138", "#f1c232", "#6aa84f", "#45818e", "#3d85c6", "#674ea7", "#a64d79",
84
+ "#990000", "#b45f06", "#bf9000", "#38761d", "#134f5c", "#0b5394", "#351c75", "#741b47",
85
+ "#660000", "#783f04", "#7f6000", "#274e13", "#0c343d", "#073763", "#20124d", "#4c1130",
86
+ ]); // https://www.color-hex.com/color-palettes/
87
+ }
@@ -0,0 +1,78 @@
1
+ import "./Form.css";
2
+ import React from 'react';
3
+ import { PopoverProps } from "../overlay/Popover";
4
+ import { Alignment } from "../constants/Alignment";
5
+ import { ComponentBaseProps } from "../core/ComponentBaseProps";
6
+ import { FormControlProps } from "../compose/form/FormControl";
7
+ import { InputOnInputCompleteHandler, InputProps } from "./Input";
8
+ import { NoseurDivElement, NoseurElement, NoseurObject, ToggleIcons } from '../constants/Types';
9
+ export type DropdownEventHandler = () => void | undefined;
10
+ export type DropdownOnDeSelectHandler = (event: any) => void;
11
+ export type DropdownPanelsHandler = () => NoseurElement | undefined;
12
+ export type DropdownOption = {
13
+ label?: string;
14
+ value?: any;
15
+ icon?: any;
16
+ };
17
+ export type DropdownEmptyTemplateHandler = () => NoseurElement | undefined;
18
+ export type DropdownLoadingTemplateHandler = () => NoseurElement | undefined;
19
+ export type DropdownTemplateHandler = (option: any) => NoseurElement | undefined;
20
+ export type DropdownSelectedIndex = {
21
+ primaryIndex: number;
22
+ secondaryIndex: number;
23
+ };
24
+ export type DropdownOnSelectHandler = (option: any, event: any) => boolean | undefined | void;
25
+ export type DropdownTranslateLabelEventHandler = (label: string, option: NoseurObject<any>) => any;
26
+ export type DropdownOnSearchHandler = (value: any, dropdownManageRef?: DropdownManageRef) => NoseurObject<any>[] | undefined | null;
27
+ export interface DropdownManageRef {
28
+ hideDropDown: (e: any) => void;
29
+ showDropDown: (e: any) => void;
30
+ toggle: (e: any, ignoreEditable: boolean) => void;
31
+ changeOptions: (options: NoseurObject<any>[] | undefined) => void;
32
+ }
33
+ export interface DropdownProps extends ComponentBaseProps<NoseurDivElement, DropdownManageRef> {
34
+ fill: boolean;
35
+ noIcon: boolean;
36
+ editable: boolean;
37
+ disabled: boolean;
38
+ highlight: boolean;
39
+ clearable: boolean;
40
+ placeholder: string;
41
+ borderless: boolean;
42
+ noToggleIcons: boolean;
43
+ responsiveWidth: boolean;
44
+ optionsClassName: string;
45
+ noSelectionIcon: boolean;
46
+ toggleIcons: ToggleIcons;
47
+ defaultInputValue: string;
48
+ optionMap: DropdownOption;
49
+ selectedOptionIndex: number;
50
+ dontMatchTargetSize: boolean;
51
+ optionGroupChildrenKey: string;
52
+ renderOptionAsPlaceholder: boolean;
53
+ popoverProps: Partial<PopoverProps>;
54
+ textInputProps: Partial<InputProps>;
55
+ options: NoseurObject<any>[] | undefined;
56
+ forceUpdateIfSelectedIndexChanges: boolean;
57
+ formControlProps: Partial<FormControlProps>;
58
+ selectedOptionIndexes: DropdownSelectedIndex;
59
+ iconPosition: Alignment.LEFT | Alignment.RIGHT;
60
+ togglePosition: Alignment.LEFT | Alignment.RIGHT;
61
+ popoverRef: React.ForwardedRef<NoseurDivElement>;
62
+ textInputRef: React.ForwardedRef<HTMLInputElement>;
63
+ onSearch?: DropdownOnSearchHandler;
64
+ onDropdownShow: DropdownEventHandler;
65
+ onDropdownHide: DropdownEventHandler;
66
+ optionTemplate: DropdownTemplateHandler;
67
+ onSelectOption: DropdownOnSelectHandler;
68
+ emptyTemplate: DropdownEmptyTemplateHandler;
69
+ onDeSelectOption: DropdownOnDeSelectHandler;
70
+ popoverHeaderTemplate: DropdownPanelsHandler;
71
+ popoverFooterTemplate: DropdownPanelsHandler;
72
+ optionGroupTemplate: DropdownTemplateHandler;
73
+ loadingTemplate: DropdownLoadingTemplateHandler;
74
+ selectedOptionTemplate?: DropdownTemplateHandler;
75
+ onInputComplete: InputOnInputCompleteHandler | undefined;
76
+ translateSelectionLabel: DropdownTranslateLabelEventHandler;
77
+ }
78
+ export declare const Dropdown: ({ ref, ...props }: Partial<DropdownProps>) => React.JSX.Element;