@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,70 @@
1
+ import { DOMHelper } from "./DOMUtils";
2
+ export class InputFilter {
3
+ static INT = /[\d\-]/;
4
+ static HEX = /[0-9a-f]/i;
5
+ static ALPHA = /[a-z_]/i;
6
+ static NUMBER = /[\d\-\.]/;
7
+ static MONEY = /[\d\.\s,]/;
8
+ static ALPHANUM = /[a-z0-9_]/i;
9
+ static POSITIVE_INT = /[\d]/;
10
+ static POSITIVE_NUMBER = /[\d\.]/;
11
+ static EMAIL = /[a-z0-9_\.\-@]/i;
12
+ }
13
+ export var InputSpecialKey;
14
+ (function (InputSpecialKey) {
15
+ InputSpecialKey[InputSpecialKey["ESC"] = 27] = "ESC";
16
+ InputSpecialKey[InputSpecialKey["TAB"] = 9] = "TAB";
17
+ InputSpecialKey[InputSpecialKey["RETURN"] = 13] = "RETURN";
18
+ InputSpecialKey[InputSpecialKey["BACKSPACE"] = 8] = "BACKSPACE";
19
+ InputSpecialKey[InputSpecialKey["DELETE"] = 46] = "DELETE";
20
+ })(InputSpecialKey || (InputSpecialKey = {}));
21
+ export const InputHelper = {
22
+ isNavKeyPress(event) {
23
+ let key = event.keyCode;
24
+ return (key >= 33 && key <= 40) || key === InputSpecialKey.RETURN || key === InputSpecialKey.TAB || key === InputSpecialKey.ESC;
25
+ },
26
+ isSpecialKey(event) {
27
+ let key = event.keyCode;
28
+ return key === 9 || key === 13 || key === 27 || key === 16 || key === 17 || (key >= 18 && key <= 20) ||
29
+ (DOMHelper.getBrowser().opera && !event.shiftKey && (key === 8 || (key >= 33 && key <= 35) || (key >= 36 && key <= 39) || (key >= 44 && key <= 45)));
30
+ },
31
+ getKey(event) {
32
+ return event.keyCode ?? event.charCode;
33
+ },
34
+ getCharCode(event) {
35
+ return event.charCode ?? event.keyCode ?? event.which;
36
+ },
37
+ validateEventValue(regex, event, value) {
38
+ const chars = value.split("");
39
+ for (const char of chars) {
40
+ if (!regex.test(char)) {
41
+ event.preventDefault();
42
+ return false;
43
+ }
44
+ }
45
+ return true;
46
+ },
47
+ validateEventKeyInput(regex, event) {
48
+ const browser = DOMHelper.getBrowser();
49
+ if (event.altKey || event.ctrlKey) {
50
+ return;
51
+ }
52
+ const key = this.getKey(event);
53
+ if (browser.mozilla && (this.isNavKeyPress(event) || (key === InputSpecialKey.DELETE && event.charCode === 0) || key === InputSpecialKey.BACKSPACE)) {
54
+ return;
55
+ }
56
+ const c = this.getCharCode(event);
57
+ const cc = String.fromCharCode(c);
58
+ if (browser.mozilla && (this.isSpecialKey(event) || !cc)) {
59
+ return;
60
+ }
61
+ const inputValid = regex.test(cc);
62
+ if (!inputValid) {
63
+ event.preventDefault();
64
+ }
65
+ return inputValid;
66
+ },
67
+ validate(value, filter) {
68
+ return !value || !filter || filter.test(value);
69
+ }
70
+ };
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ import { Scheme } from "../constants/Scheme";
3
+ import { Alignment } from "../constants/Alignment";
4
+ import { NoseurIconElement, NoseurLabel, NoseurObject } from "../constants/Types";
5
+ export declare const MicroBuilder: {
6
+ ICON_COUNTER: number;
7
+ LABEL_COUNTER: number;
8
+ buildIcon(icon: NoseurIconElement, props?: {
9
+ scheme?: Scheme;
10
+ className?: string;
11
+ id?: string;
12
+ style?: React.CSSProperties;
13
+ relativeAlignment?: Alignment;
14
+ fillIcon?: boolean;
15
+ applyFaScheme?: boolean;
16
+ }, events?: NoseurObject<any>): React.JSX.Element | null;
17
+ buildLabel(label: NoseurLabel, props?: {
18
+ scheme: Scheme;
19
+ type?: string;
20
+ htmlFor?: string;
21
+ className?: string;
22
+ relativeAlignment?: Alignment;
23
+ }, events?: NoseurObject<any>): React.JSX.Element | null;
24
+ };
@@ -0,0 +1,61 @@
1
+ import React from "react";
2
+ import { Classname } from "./Classname";
3
+ import { TypeChecker } from "./TypeChecker";
4
+ import { ObjectHelper } from "./ObjectHelper";
5
+ import { Alignment } from "../constants/Alignment";
6
+ export const MicroBuilder = {
7
+ ICON_COUNTER: 0,
8
+ LABEL_COUNTER: 0,
9
+ buildIcon(icon, props, events) {
10
+ if (!icon) {
11
+ return null;
12
+ }
13
+ const isFontAwesomeIcon = TypeChecker.isTypeOfAny(icon, ["string"]);
14
+ const className = Classname.build(isFontAwesomeIcon ? icon : icon.props.className, {
15
+ "noseur-wd-auto": props?.fillIcon,
16
+ "noseur-mg-r-15": props?.relativeAlignment == Alignment.LEFT,
17
+ "noseur-mg-l-15": props?.relativeAlignment == Alignment.RIGHT,
18
+ }, (isFontAwesomeIcon && props?.scheme && props.applyFaScheme ? `${props.scheme}-tx` : null), "noseur-icon", props?.className);
19
+ const key = `icon-${++MicroBuilder.ICON_COUNTER}`;
20
+ if (!isFontAwesomeIcon) {
21
+ const iconProps = { ...icon.props };
22
+ ObjectHelper.addAll(iconProps, events);
23
+ iconProps.key = iconProps.key ?? key;
24
+ iconProps.id = iconProps.id ?? props?.id;
25
+ iconProps.key = props?.scheme ?? iconProps.scheme;
26
+ iconProps.style = { ...(iconProps.style), ...(props?.style) };
27
+ iconProps.className = Classname.build(className, iconProps.className);
28
+ return React.cloneElement(icon, iconProps);
29
+ }
30
+ return React.createElement("i", { key: key, className: className, id: props?.id, style: props?.style, ...events });
31
+ },
32
+ buildLabel(label, props, events) {
33
+ if (!label) {
34
+ return null;
35
+ }
36
+ const isRawString = TypeChecker.isTypeOfAny(label, ["string"]);
37
+ const className = Classname.build(!isRawString && props?.scheme ? `${props.scheme}-tx` : null, {
38
+ "noseur-mg-b-05rem": props?.relativeAlignment == Alignment.TOP,
39
+ "noseur-mg-r-05rem": props?.relativeAlignment == Alignment.LEFT,
40
+ "noseur-mg-l-05rem": props?.relativeAlignment == Alignment.RIGHT,
41
+ "noseur-mg-t-05rem": props?.relativeAlignment == Alignment.BOTTOM,
42
+ }, "noseur-label", props?.className, label.props?.className);
43
+ const key = `icon-${MicroBuilder.LABEL_COUNTER++}`;
44
+ if (!isRawString) {
45
+ const labelProps = { ...(label.props || {}) };
46
+ ObjectHelper.addAll(labelProps, events);
47
+ labelProps.className = className;
48
+ labelProps.key = labelProps.key || key;
49
+ labelProps.scheme = props?.scheme || labelProps.scheme;
50
+ return React.cloneElement(label, labelProps);
51
+ }
52
+ const rProps = {
53
+ key,
54
+ ...events,
55
+ className,
56
+ };
57
+ if (props?.htmlFor)
58
+ rProps.htmlFor = props?.htmlFor;
59
+ return (props?.type == "label" ? React.createElement("label", { ...rProps }, label) : React.createElement("span", { ...rProps }, label));
60
+ }
61
+ };
@@ -0,0 +1,51 @@
1
+ import React from "react";
2
+ import { NoseurObject } from "../constants/Types";
3
+ import { ComponentBaseProps } from "../core/ComponentBaseProps";
4
+ export declare const ObjectHelper: {
5
+ isString(data: any): data is string;
6
+ findDiffKeys(primaryObj: NoseurObject<any>, checkerObj: NoseurObject<any>, exclusions?: string[]): NoseurObject<any>;
7
+ clone<T>(obj: any[] | NoseurObject<any> | T): T;
8
+ cloneArray(obj: any[]): any[];
9
+ cloneObject(obj: NoseurObject<any>): NoseurObject<any>;
10
+ addAll(target: NoseurObject<any>, source?: NoseurObject<any>): NoseurObject<any>;
11
+ conditionalClone(obj: NoseurObject<any>, conditionCallback: (key: string) => boolean): NoseurObject<any>;
12
+ extractEventProps(obj: NoseurObject<any>, excludes?: string[]): NoseurObject<any>;
13
+ resolveStringTemplate(unprocessed: string, valueMap: NoseurObject<any>): string;
14
+ toTitleCase(value: string): string;
15
+ resolveManageRef<T1, T2>(component: React.Component<ComponentBaseProps<T1, T2>, any>, funsies: T2): void;
16
+ resolveRef<T>(ref: React.ForwardedRef<T>, value?: T, always?: boolean): void;
17
+ expandStringTemplate(unprocessed: string, valueMap: NoseurObject<any>, options?: {
18
+ chop?: string;
19
+ prefix?: string;
20
+ suffix?: string;
21
+ seperator?: string;
22
+ relativeExpansion?: boolean;
23
+ }): string;
24
+ objectGetWithStringTemplate(valueMap: NoseurObject<any>, template: string, options?: {
25
+ prefix?: string;
26
+ suffix?: string;
27
+ optional?: string;
28
+ seperator?: string;
29
+ }): any;
30
+ joinValues(...values: any[]): any;
31
+ merge<T>(...obj: any[][] | NoseurObject<any>[] | T[]): any;
32
+ round(num: number): number;
33
+ object(obj: any): any;
34
+ getExtension(value: string, options?: {
35
+ delimiter?: string;
36
+ lastOnly?: boolean;
37
+ excludeDelimiter?: boolean;
38
+ }): string;
39
+ escapeCharacters(message: string): string;
40
+ resolveEnclosedValues(content: string, paramsMap: {
41
+ search: {
42
+ open: string;
43
+ close: string;
44
+ };
45
+ replace: {
46
+ open: string;
47
+ close: string;
48
+ };
49
+ }[]): string;
50
+ flattenChildren(propsChildren: any): any;
51
+ };
@@ -0,0 +1,334 @@
1
+ import React from "react";
2
+ import { TypeChecker } from "./TypeChecker";
3
+ export const ObjectHelper = {
4
+ isString(data) {
5
+ return typeof data === 'string';
6
+ },
7
+ findDiffKeys(primaryObj, checkerObj, exclusions = []) {
8
+ if (!primaryObj || !checkerObj) {
9
+ return {};
10
+ }
11
+ return Object.keys(primaryObj).filter(key => !checkerObj.hasOwnProperty(key)).reduce((result, current) => {
12
+ if (!exclusions.includes(current))
13
+ result[current] = primaryObj[current];
14
+ return result;
15
+ }, {});
16
+ },
17
+ clone(obj) {
18
+ return (TypeChecker.isDict(obj) ? ObjectHelper.cloneObject(obj) : ObjectHelper.cloneArray(obj));
19
+ },
20
+ cloneArray(obj) {
21
+ var clone = [];
22
+ if (!obj) {
23
+ return clone;
24
+ }
25
+ for (const value of obj) {
26
+ clone.push(TypeChecker.isArray(value) ? ObjectHelper.clone(value) : value);
27
+ }
28
+ return clone;
29
+ },
30
+ cloneObject(obj) {
31
+ var clone = {};
32
+ if (!obj) {
33
+ return clone;
34
+ }
35
+ Object.keys(obj).map((key) => {
36
+ let value = obj[key];
37
+ clone[key] = TypeChecker.isArray(value) ? ObjectHelper.clone(value) : value;
38
+ });
39
+ return clone;
40
+ },
41
+ addAll(target, source) {
42
+ if (source)
43
+ Object.keys(source).map((key) => target[key] = source[key]);
44
+ return target;
45
+ },
46
+ conditionalClone(obj, conditionCallback) {
47
+ var clone = {};
48
+ if (!obj) {
49
+ return clone;
50
+ }
51
+ Object.keys(obj).map((key) => {
52
+ if (conditionCallback(key) === true) {
53
+ clone[key] = obj[key];
54
+ }
55
+ });
56
+ return clone;
57
+ },
58
+ extractEventProps(obj, excludes = []) {
59
+ return this.conditionalClone(obj, (key) => excludes.indexOf(key) === -1
60
+ && key.startsWith("on")
61
+ && key[2] != undefined
62
+ && key[2] == key[2].toUpperCase());
63
+ },
64
+ resolveStringTemplate(unprocessed, valueMap) {
65
+ let value = "";
66
+ let templateValue = "";
67
+ let openedTemplate = false;
68
+ for (let index = 0; index < unprocessed.length; index++) {
69
+ const ch = unprocessed[index];
70
+ if (ch == '{') {
71
+ openedTemplate = true;
72
+ continue;
73
+ }
74
+ if (ch == '}') {
75
+ value += valueMap[templateValue] || "";
76
+ openedTemplate = false;
77
+ templateValue = "";
78
+ continue;
79
+ }
80
+ ;
81
+ if (openedTemplate) {
82
+ templateValue += ch;
83
+ }
84
+ else {
85
+ value += ch;
86
+ }
87
+ }
88
+ return value;
89
+ },
90
+ toTitleCase(value) {
91
+ return (value && (value[0].toUpperCase() + value.substring(1).toLowerCase()));
92
+ },
93
+ resolveManageRef(component, funsies) {
94
+ const manageRef = component.props.manageRef;
95
+ if (!manageRef)
96
+ return;
97
+ if (manageRef instanceof Function) {
98
+ manageRef(funsies);
99
+ }
100
+ else {
101
+ manageRef.current = funsies;
102
+ }
103
+ },
104
+ resolveRef(ref, value, always = false) {
105
+ if (!ref || (!value && !always) || !ref)
106
+ return;
107
+ if (ref instanceof Function) {
108
+ ref(value ?? null);
109
+ }
110
+ else {
111
+ ref.current = value ?? null;
112
+ }
113
+ },
114
+ expandStringTemplate(unprocessed, valueMap, options = {}) {
115
+ let value = "";
116
+ var chopped = "";
117
+ let templateValue = "";
118
+ let openedTemplate = false;
119
+ let subValueMap = valueMap;
120
+ const chop = options.chop ?? '';
121
+ const prefix = options.prefix ?? '{';
122
+ const suffix = options.suffix ?? '}';
123
+ const seperator = options.seperator || '.';
124
+ for (let index = 0; index < unprocessed.length; index++) {
125
+ const ch = unprocessed[index];
126
+ if (ch === (options.chop) && unprocessed[index + 1] === prefix) {
127
+ continue;
128
+ }
129
+ if (ch === prefix) {
130
+ openedTemplate = true;
131
+ if (index > 0 && unprocessed[index - 1] === options.chop) {
132
+ chopped = chop;
133
+ }
134
+ continue;
135
+ }
136
+ if (openedTemplate && ch === seperator) {
137
+ if (!(templateValue in subValueMap)) {
138
+ value += `${chopped}${prefix}${templateValue}${seperator}`;
139
+ openedTemplate = false;
140
+ templateValue = "";
141
+ chopped = "";
142
+ continue;
143
+ }
144
+ subValueMap = subValueMap[templateValue];
145
+ templateValue = "";
146
+ chopped = "";
147
+ continue;
148
+ }
149
+ if (openedTemplate && ch === suffix) {
150
+ const actualTemplateValue = templateValue;
151
+ const defaultValSepIndex = templateValue.indexOf(":");
152
+ if (defaultValSepIndex > -1) {
153
+ templateValue = actualTemplateValue.substring(0, defaultValSepIndex);
154
+ }
155
+ value += subValueMap[templateValue]
156
+ ?? (options.relativeExpansion ? `${chopped}${prefix}${actualTemplateValue}${suffix}` : "");
157
+ subValueMap = valueMap;
158
+ openedTemplate = false;
159
+ templateValue = "";
160
+ chopped = "";
161
+ continue;
162
+ }
163
+ ;
164
+ if (openedTemplate) {
165
+ templateValue += ch;
166
+ }
167
+ else {
168
+ value += ch;
169
+ }
170
+ }
171
+ if (openedTemplate) {
172
+ value += `${chopped}${prefix}${templateValue}`;
173
+ }
174
+ else {
175
+ value += templateValue;
176
+ }
177
+ return value;
178
+ },
179
+ objectGetWithStringTemplate(valueMap, template, options = {}) {
180
+ let expandedString = "";
181
+ let templateValue = "";
182
+ let openedTemplate = false;
183
+ let subValueMap = valueMap;
184
+ let parsingAltValue = false;
185
+ const prefix = options.prefix ?? '{';
186
+ const suffix = options.suffix ?? '}';
187
+ const optional = options.optional ?? '?';
188
+ const seperator = options.seperator ?? '.';
189
+ const templateLength = template.length;
190
+ if (template.indexOf(prefix) < 0)
191
+ return subValueMap[template] ?? "";
192
+ for (let index = 0; index < templateLength; index++) {
193
+ const ch = template[index];
194
+ if (!parsingAltValue && ch == prefix) {
195
+ openedTemplate = true;
196
+ continue;
197
+ }
198
+ if (openedTemplate && ch == seperator) {
199
+ let altValue = templateValue.endsWith(optional) ? {} : undefined;
200
+ const splitted = templateValue.split(optional);
201
+ templateValue = splitted[0];
202
+ try {
203
+ altValue = JSON.parse(splitted[1]);
204
+ }
205
+ catch (_) { }
206
+ subValueMap = subValueMap[templateValue] ?? altValue;
207
+ templateValue = "";
208
+ continue;
209
+ }
210
+ if (ch == suffix) {
211
+ if (parsingAltValue && templateValue[templateValue.length - 1] !== optional) {
212
+ parsingAltValue = false;
213
+ templateValue += suffix;
214
+ continue;
215
+ }
216
+ openedTemplate = false;
217
+ parsingAltValue = false;
218
+ let altValue = templateValue.endsWith(optional) ? "" : undefined;
219
+ const splitted = templateValue.split(optional);
220
+ templateValue = splitted[0];
221
+ if (splitted.length > 1)
222
+ altValue = splitted[1];
223
+ expandedString += subValueMap[templateValue] ?? altValue;
224
+ subValueMap = valueMap;
225
+ templateValue = "";
226
+ continue;
227
+ }
228
+ ;
229
+ if (openedTemplate) {
230
+ templateValue += ch;
231
+ if (ch === optional && ((index + 1) < templateLength) && template[index + 1] === prefix)
232
+ parsingAltValue = true;
233
+ }
234
+ else {
235
+ expandedString += ch;
236
+ }
237
+ }
238
+ return expandedString;
239
+ },
240
+ joinValues(...values) {
241
+ if (!values.length)
242
+ return;
243
+ if (TypeChecker.isObject(values[0])) {
244
+ return values.reduce((acc, value) => {
245
+ if (value)
246
+ Object.keys(value).forEach((key) => acc[key] = value[key]);
247
+ return acc;
248
+ }, {});
249
+ }
250
+ if (TypeChecker.isArray(values[0])) {
251
+ return values.reduce((acc, value) => {
252
+ if (!value)
253
+ return acc;
254
+ return acc.concat(value);
255
+ }, []);
256
+ }
257
+ if (TypeChecker.isString(values[0]) || TypeChecker.isNumber(values[0])) {
258
+ return values.reduce((acc, value) => {
259
+ if (!value)
260
+ return acc;
261
+ return acc + value;
262
+ }, "");
263
+ }
264
+ return values;
265
+ },
266
+ merge(...obj) {
267
+ if (!obj.length)
268
+ return {};
269
+ const isObject = TypeChecker.isDict(obj[0]);
270
+ let result = ObjectHelper.clone(obj[0]);
271
+ for (let index = 1; index < obj.length; index++) {
272
+ const entry = ObjectHelper.clone(obj[index]);
273
+ if (isObject) {
274
+ Object.keys(entry).map((key) => {
275
+ result[key] = entry[key];
276
+ });
277
+ continue;
278
+ }
279
+ result.concat(entry);
280
+ }
281
+ return result;
282
+ },
283
+ round(num) {
284
+ return Math.round((num + Number.EPSILON) * 100) / 100;
285
+ },
286
+ object(obj) {
287
+ if (!TypeChecker.isObject(obj))
288
+ return {};
289
+ return obj;
290
+ },
291
+ getExtension(value, options) {
292
+ const delimiter = options?.delimiter ?? ".";
293
+ if (options?.lastOnly)
294
+ return value.substring(value.lastIndexOf(delimiter) + (options.excludeDelimiter ? 1 : 0));
295
+ return value.substring(0, value.indexOf(delimiter));
296
+ },
297
+ escapeCharacters(message) {
298
+ let messagePart = message.split("");
299
+ for (let index = 0; index < messagePart.length; index++) {
300
+ let char = messagePart[index];
301
+ if ("~!@#$%^&*()_+-={}[]<>?".includes(char)) {
302
+ char = "\\" + char;
303
+ }
304
+ messagePart[index] = char;
305
+ }
306
+ return messagePart.join("");
307
+ },
308
+ resolveEnclosedValues(content, paramsMap) {
309
+ let resolvedContent = content;
310
+ for (const params of paramsMap) {
311
+ let { open: searchOpen, close: searchClose } = params.search;
312
+ let { open: replaceOpen, close: replaceClose } = params.replace;
313
+ let escapedSearchOpen = ObjectHelper.escapeCharacters(searchOpen);
314
+ let escapedSearchClose = ObjectHelper.escapeCharacters(searchClose);
315
+ resolvedContent = resolvedContent.replace(new RegExp(escapedSearchOpen + `*([\\w&,.+×÷=/-<>\\[\\]():\\s+])+` + escapedSearchClose, "g"), (m, _) => {
316
+ const value = (m.replaceAll(searchOpen, "")?.replaceAll(searchClose, "") ?? "");
317
+ return `${replaceOpen}${value}${replaceClose}`;
318
+ });
319
+ }
320
+ return resolvedContent;
321
+ },
322
+ flattenChildren(propsChildren) {
323
+ const _children = propsChildren.length ? propsChildren : [propsChildren];
324
+ let children = [];
325
+ for (const child of _children) {
326
+ if (child.type === React.Fragment && child.props.children) {
327
+ children.push(...ObjectHelper.flattenChildren(child.props.children));
328
+ continue;
329
+ }
330
+ children.push(child);
331
+ }
332
+ return children;
333
+ },
334
+ };
@@ -0,0 +1,10 @@
1
+ export declare const StringHelper: {
2
+ segmentSplit(value: string, sep?: string): string[];
3
+ toSaneSentenceFormat(value: string, ignore?: boolean): string;
4
+ toPresentableMoneyValue(amount: number, options?: {
5
+ divisor?: number;
6
+ decimal?: number;
7
+ separator?: string;
8
+ }): string;
9
+ randomString(length?: number, characters?: string): string;
10
+ };
@@ -0,0 +1,54 @@
1
+ export const StringHelper = {
2
+ segmentSplit(value, sep = "/") {
3
+ return value.split(sep).filter(s => s !== "");
4
+ },
5
+ toSaneSentenceFormat(value, ignore) {
6
+ if (ignore || !value)
7
+ return value;
8
+ return value.split("_").map(e => e[0].toUpperCase() + e.substring(1).toLowerCase()).join(" ");
9
+ },
10
+ toPresentableMoneyValue(amount, options = {
11
+ decimal: 2,
12
+ separator: ",",
13
+ divisor: 1000000,
14
+ }) {
15
+ let amountStr;
16
+ let isNegative = false;
17
+ if (options?.divisor)
18
+ amount /= options?.divisor;
19
+ if (amount < 0) {
20
+ isNegative = true;
21
+ amount = Math.abs(amount);
22
+ }
23
+ amountStr = String(amount);
24
+ if (options?.decimal)
25
+ amountStr = amount.toFixed(options?.decimal);
26
+ if (options?.separator) {
27
+ let reversedComma = [];
28
+ const amountMainParts = (amountStr.substring(0, amountStr.indexOf("."))).split("");
29
+ for (let index = amountMainParts.length - 1; index >= 0; index -= 3) {
30
+ reversedComma.push(amountMainParts[index]);
31
+ if (index === 0)
32
+ continue;
33
+ reversedComma.push(amountMainParts[index - 1]);
34
+ if ((index - 2) < 0)
35
+ continue;
36
+ reversedComma.push(amountMainParts[index - 2]);
37
+ if ((index - 2) !== 0)
38
+ reversedComma.push(",");
39
+ }
40
+ amountStr = reversedComma.reverse().join("") + amountStr.substring(amountStr.indexOf("."));
41
+ }
42
+ return (isNegative ? "-" : "") + amountStr;
43
+ },
44
+ randomString(length = 10, characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') {
45
+ let result = '';
46
+ const charactersLength = characters.length;
47
+ let counter = 0;
48
+ while (counter < length) {
49
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
50
+ counter += 1;
51
+ }
52
+ return result;
53
+ },
54
+ };
@@ -0,0 +1,14 @@
1
+ import { NoseurObject } from "../constants/Types";
2
+ export type Subscription = (...data: any) => void;
3
+ export type SecondaryDataSubscription = (secondaryData: NoseurObject<any>) => void;
4
+ export declare const Subscriber: {
5
+ KEYS: {
6
+ SECONDARY_DATA: string;
7
+ };
8
+ __subscriptions: NoseurObject<Subscription[]>;
9
+ subscribe: (key: string, subscription: Subscription) => void;
10
+ unSubscribe: (key: string, subscription: Subscription) => void;
11
+ report(key: string, ...data: any): void;
12
+ subscriptions: (key?: string) => Subscription[] | NoseurObject<Subscription[]>;
13
+ clearSubscriptions: (key?: string) => {} | undefined;
14
+ };
@@ -0,0 +1,27 @@
1
+ export const Subscriber = {
2
+ KEYS: {
3
+ SECONDARY_DATA: "SECONDARY_DATA",
4
+ },
5
+ __subscriptions: {},
6
+ subscribe: (key, subscription) => {
7
+ if (!(key in Subscriber.__subscriptions))
8
+ Subscriber.__subscriptions[key] = [];
9
+ if (Subscriber.__subscriptions[key].includes(subscription))
10
+ return;
11
+ Subscriber.__subscriptions[key].push(subscription);
12
+ },
13
+ unSubscribe: (key, subscription) => {
14
+ if (!(key in Subscriber.__subscriptions))
15
+ return;
16
+ const index = Subscriber.__subscriptions[key].indexOf(subscription);
17
+ if (index > -1)
18
+ Subscriber.__subscriptions[key].splice(index, 1);
19
+ },
20
+ report(key, ...data) {
21
+ if (!(key in Subscriber.__subscriptions))
22
+ return;
23
+ Subscriber.__subscriptions[key].forEach(subscription => subscription(...data));
24
+ },
25
+ subscriptions: (key) => key ? Subscriber.__subscriptions[key] : Subscriber.__subscriptions,
26
+ clearSubscriptions: (key) => key ? ((key in Subscriber.__subscriptions) ? delete Subscriber.__subscriptions[key] : undefined) : Subscriber.__subscriptions = {},
27
+ };
@@ -0,0 +1,32 @@
1
+ import { NoseurObject } from "../constants/Types";
2
+ export interface TimerCallbacks {
3
+ onEnd?: () => void;
4
+ onStop?: () => void;
5
+ onStart?: () => void;
6
+ onPause?: () => void;
7
+ onResume?: () => void;
8
+ onRestart?: () => void;
9
+ action?: (...args: any[]) => void;
10
+ onAction?: (percentage: number) => void;
11
+ }
12
+ export interface TimerOption {
13
+ delay?: number;
14
+ timeout: number;
15
+ cbs?: TimerCallbacks;
16
+ isInterval?: boolean;
17
+ }
18
+ export declare class Timer {
19
+ timer?: number;
20
+ startTime?: number;
21
+ cbs?: TimerCallbacks;
22
+ isInterval?: boolean;
23
+ totalTicks: number;
24
+ elapseTicks: number;
25
+ options: NoseurObject<any>;
26
+ constructor(options: TimerOption, ...args: any[]);
27
+ start(__resumed__?: boolean): void;
28
+ stop(): void;
29
+ pause(): void;
30
+ resume(): void;
31
+ restart(timeout?: number): void;
32
+ }