@carbonorm/carbonreact 1.0.8 → 1.1.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 (58) hide show
  1. package/dist/{CarbonReact.esm.css → index.cjs.css} +1 -1
  2. package/dist/{CarbonReact.umd.css.map → index.cjs.css.map} +1 -1
  3. package/dist/index.cjs.js +4659 -0
  4. package/dist/index.cjs.js.map +1 -0
  5. package/dist/{CarbonReact.umd.css → index.esm.css} +1 -1
  6. package/dist/{CarbonReact.esm.css.map → index.esm.css.map} +1 -1
  7. package/dist/{CarbonReact.esm.js → index.esm.js} +1 -1
  8. package/dist/index.esm.js.map +1 -0
  9. package/package.json +6 -4
  10. package/src/CarbonReact.tsx +136 -0
  11. package/src/components/Alert/Alert.tsx +210 -0
  12. package/src/components/Errors/AccessDenied.tsx +32 -0
  13. package/src/components/Errors/BackendThrowable.tsx +44 -0
  14. package/src/components/Errors/ErrorHttpCode.tsx +31 -0
  15. package/src/components/Errors/Localhost.tsx +38 -0
  16. package/src/components/Errors/PageNotFound.tsx +16 -0
  17. package/src/components/Errors/style.module.css +108 -0
  18. package/src/components/Errors/style.module.css.d.ts +34 -0
  19. package/src/components/Errors/style.module.css.map +1 -0
  20. package/src/components/Errors/style.module.scss +111 -0
  21. package/src/components/Errors/style.module.scss.d.ts +34 -0
  22. package/src/components/Errors/style.module.scss.json +1 -0
  23. package/src/components/Loading/Loading.tsx +37 -0
  24. package/src/components/Nest/Nest.tsx +241 -0
  25. package/src/components/Popup/Popup.tsx +55 -0
  26. package/src/custom.d.ts +47 -0
  27. package/src/hoc/GlobalHistory.tsx +11 -0
  28. package/src/hoc/addValidSQL.tsx +6 -0
  29. package/src/hoc/axiosInstance.tsx +494 -0
  30. package/src/hoc/changed.tsx +58 -0
  31. package/src/hoc/deleteRestfulObjectArrays.tsx +25 -0
  32. package/src/hoc/getStyles.tsx +44 -0
  33. package/src/hoc/hexToRgb.tsx +15 -0
  34. package/src/hoc/isEdgeBrowser.tsx +7 -0
  35. package/src/hoc/parseMultipleJson.tsx +49 -0
  36. package/src/hoc/scrollIntoView.tsx +6 -0
  37. package/src/hoc/setUrl.tsx +49 -0
  38. package/src/hoc/updateRestfulObjectArrays.tsx +92 -0
  39. package/src/hoc/uploadImage.tsx +99 -0
  40. package/src/hoc/windowDimensions.tsx +24 -0
  41. package/src/index.ts +53 -0
  42. package/src/style.module.css +261 -0
  43. package/src/style.module.css.d.ts +44 -0
  44. package/src/style.module.css.json +1 -0
  45. package/src/style.module.css.map +1 -0
  46. package/src/style.module.scss +269 -0
  47. package/src/style.module.scss.d.ts +44 -0
  48. package/src/variables/C6.tsx +3317 -0
  49. package/src/variables/bootstrap.module.css +12802 -0
  50. package/src/variables/bootstrap.module.css.d.ts +7736 -0
  51. package/src/variables/bootstrap.module.css.json +1 -0
  52. package/src/variables/bootstrap.module.css.map +1 -0
  53. package/src/variables/bootstrap.module.scss +37 -0
  54. package/src/variables/bootstrap.module.scss.d.ts +7736 -0
  55. package/src/variables/isProduction.tsx +5 -0
  56. package/dist/CarbonReact.esm.js.map +0 -1
  57. package/dist/CarbonReact.umd.js +0 -4653
  58. package/dist/CarbonReact.umd.js.map +0 -1
@@ -0,0 +1,111 @@
1
+ @import url("https://fonts.googleapis.com/css?family=Share+Tech+Mono|Montserrat:700");
2
+
3
+ * {
4
+ margin: 0;
5
+ padding: 0;
6
+ border: 0;
7
+ font-size: 100%;
8
+ vertical-align: baseline;
9
+ box-sizing: border-box;
10
+ color: inherit;
11
+ }
12
+
13
+ .maintenance-hero {
14
+ // background: url("@/assets/img/gif/maintenance-hero.gif") no-repeat center center fixed;
15
+ background: url('#') no-repeat center center fixed;
16
+ -webkit-background-size: cover;
17
+ -moz-background-size: cover;
18
+ -o-background-size: cover;
19
+ background-size: cover;
20
+ opacity: 0.8;
21
+ }
22
+
23
+
24
+ .httpStatusCode {
25
+ font-size: 45vw;
26
+ text-align: center;
27
+ position: fixed;
28
+ width: 100vw;
29
+ z-index: 1;
30
+ color: #ffffff26;
31
+ text-shadow: 0 0 50px rgba(0, 0, 0, 0.07);
32
+ top: 50%;
33
+ transform: translateY(-50%);
34
+ font-family: "Montserrat", monospace;
35
+ }
36
+
37
+ .centeredContainer{
38
+ background-color: rgba(1,1,1,0.9);
39
+ width: 70vw;
40
+ overflow: scroll;
41
+ max-height: 80%;
42
+ position: relative;
43
+ top: 20vh;
44
+ margin: 0 auto;
45
+ padding: 30px 30px 10px;
46
+ box-shadow: 0 0 150px -20px rgba(0, 0, 0, 0.5);
47
+ z-index: 3;
48
+ }
49
+
50
+ .errorTextGeneral {
51
+ font-family: "Share Tech Mono", monospace;
52
+ color: #f5f5f5;
53
+ margin: 0 0 20px;
54
+ font-size: 22px;
55
+ line-height: 1.2;
56
+ }
57
+
58
+ .errorKeys {
59
+ color: #f0c674;
60
+ }
61
+
62
+ .error-values {
63
+ color: #8abeb7;
64
+ }
65
+
66
+
67
+ @keyframes slide {
68
+ from {
69
+ right: -100px;
70
+ transform: rotate(360deg);
71
+ opacity: 0;
72
+ }
73
+ to {
74
+ right: 15px;
75
+ transform: rotate(0deg);
76
+ opacity: 1;
77
+ }
78
+ }
79
+
80
+ .error-pre {
81
+ background-color:rgba(18,18,18,0.9);
82
+ max-height: 30%;
83
+ overflow:scroll;
84
+ margin:0 0 1em;
85
+ padding:.5em 1em;
86
+ }
87
+
88
+ .error-pre code,
89
+ .error-pre .line-number {
90
+ /* Ukuran line-height antara teks di dalam tag <code> dan <span class="line-number"> harus sama! */
91
+ font:normal normal 12px/14px "Courier New",Courier,Monospace;
92
+ color:black;
93
+ display:block;
94
+ }
95
+
96
+ .error-pre .line-number {
97
+ float:left;
98
+ margin:0 1em 0 -1em;
99
+ border-right:1px solid;
100
+ text-align:right;
101
+ }
102
+
103
+ .error-pre .line-number span {
104
+ display:block;
105
+ padding:0 .5em 0 1em;
106
+ }
107
+
108
+ .error-pre .cl {
109
+ display:block;
110
+ clear:both;
111
+ }
@@ -0,0 +1,34 @@
1
+ export type Styles = {
2
+ 'centered_container': string;
3
+ 'centered-container': string;
4
+ 'centeredContainer': string;
5
+ 'cl': string;
6
+ 'error_keys': string;
7
+ 'error_pre': string;
8
+ 'error_text_general': string;
9
+ 'error_values': string;
10
+ 'error-keys': string;
11
+ 'error-pre': string;
12
+ 'error-text-general': string;
13
+ 'error-values': string;
14
+ 'errorKeys': string;
15
+ 'errorPre': string;
16
+ 'errorTextGeneral': string;
17
+ 'errorValues': string;
18
+ 'http_status_code': string;
19
+ 'http-status-code': string;
20
+ 'httpStatusCode': string;
21
+ 'line_number': string;
22
+ 'line-number': string;
23
+ 'lineNumber': string;
24
+ 'maintenance_hero': string;
25
+ 'maintenance-hero': string;
26
+ 'maintenanceHero': string;
27
+ 'slide': string;
28
+ };
29
+
30
+ export type ClassNames = keyof Styles;
31
+
32
+ declare const styles: Styles;
33
+
34
+ export default styles;
@@ -0,0 +1 @@
1
+ {"maintenance-hero":"C5KSP","maintenanceHero":"C5KSP","httpStatusCode":"NhyRQ","centeredContainer":"nA4Un","errorTextGeneral":"yJAga","errorKeys":"SRIoY","error-values":"xQIso","errorValues":"xQIso","error-pre":"C6eWp","errorPre":"C6eWp","line-number":"NFRyo","lineNumber":"NFRyo","cl":"vR2jb","slide":"OO2C-"}
@@ -0,0 +1,37 @@
1
+ import classNames from "classnames";
2
+ import getStyles, {getRootStyleValue} from "hoc/getStyles";
3
+ import {ReactNode} from "react";
4
+ import Skeleton, {SkeletonTheme} from "react-loading-skeleton";
5
+
6
+ interface iLoading {
7
+ lineHeight?: number,
8
+ count?: number,
9
+ children?: ReactNode,
10
+ message: string|undefined,
11
+ }
12
+
13
+ export default function Loading(props: iLoading) {
14
+
15
+ const dig = getStyles();
16
+
17
+ const primaryColor = getRootStyleValue()
18
+
19
+ return <div className={classNames(dig.my5, dig.px3,dig.pb5, dig.container)} style={{lineHeight: props.lineHeight || 4}}>
20
+ <SkeletonTheme baseColor={primaryColor} highlightColor="#444">
21
+ <Skeleton
22
+ className={classNames(dig.row, dig.my3, dig.justifyContentCenter, dig.mAuto)}
23
+ count={props.count || 1}
24
+ height={60}
25
+ inline={true}/>
26
+ {props.children}
27
+ {undefined !== props?.message && <h2 style={{
28
+ display: 'flex',
29
+ alignItems: 'center',
30
+ justifyContent: 'center',
31
+ height: '100%'
32
+ }}>{props?.message}</h2>}
33
+ </SkeletonTheme>
34
+ </div>;
35
+
36
+ }
37
+
@@ -0,0 +1,241 @@
1
+ import {toastOptions} from "@carbonorm/carbonnode";
2
+ import React from "react";
3
+ import {toast} from "react-toastify";
4
+
5
+ export const range = n =>
6
+ new Array(n).fill(0).map((_, idx) => idx);
7
+
8
+ //export const canvasStyle = config =>
9
+ // `display:block;position:absolute;top:0;left:0;height:100%;width:100%;overflow:hidden;pointer-events:none;z-index:${config.zIndex};opacity:${config.opacity}`;
10
+
11
+ interface iTwoD {
12
+ max: number,
13
+ x: number | null,
14
+ y: number | null,
15
+ }
16
+
17
+ interface iTwoDAnimated extends iTwoD {
18
+ ya: number,
19
+ xa: number
20
+ }
21
+
22
+ type NestProps = typeof Nest.defaultProps & {
23
+ children?: any;
24
+ position: "relative" | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "-webkit-sticky" | "absolute" | "fixed" | "static" | "sticky",
25
+ };
26
+
27
+ // @link https://sites.google.com/site/webglbook/home/chapter-3
28
+ export default class Nest extends React.Component<NestProps, {
29
+ // updating react state will re-run the render method.
30
+ // this is un necessary overhead with canvas apps.
31
+ }> {
32
+ static defaultProps = {
33
+ backgroundColor: "white",
34
+ display:"block",
35
+ top: 0,
36
+ left: 0,
37
+ zIndex: -1,
38
+ count: 99,
39
+ opacity: 0.5,
40
+ overflow: "hidden",
41
+ color: '255,255,255',
42
+ pointColor: '255,0,0',
43
+ position: "relative"
44
+ };
45
+
46
+ canvas?: HTMLCanvasElement;
47
+
48
+ all: Array<iTwoDAnimated | iTwoD> = [];
49
+
50
+ points?: Array<iTwoDAnimated>;
51
+
52
+ current: iTwoD = {
53
+ x: 0, // current mouse x
54
+ y: 0, // current mouse y
55
+ max: 20000 // circle radius squared
56
+ };
57
+
58
+ constructor(props) {
59
+ super(props);
60
+ this.state ={}
61
+ }
62
+
63
+ canvasContext ?: CanvasRenderingContext2D;
64
+
65
+ componentDidMount() {
66
+
67
+ this.canvas = document.getElementById('2d') as HTMLCanvasElement;
68
+
69
+ this.canvasContext = this.canvas.getContext('2d') || undefined;
70
+
71
+ if (undefined === this.canvasContext) {
72
+
73
+ toast.warn('Your browser does not support Canvas! Some features may not work as expected.', toastOptions)
74
+
75
+ return;
76
+
77
+ }
78
+
79
+ this.points = this.randomPoints();
80
+
81
+ this.all = this.all?.concat(this.points,
82
+ [this.current]
83
+ );
84
+
85
+ if (undefined === this.canvas) {
86
+
87
+ toast.error('Failed to load Canvas! Some features may not work as expected.', toastOptions)
88
+
89
+
90
+ return;
91
+ }
92
+
93
+ document.onmousemove = e => {
94
+ this.current.x = e.clientX; // - this.el.offsetLeft + document.scrollingElement.scrollLeft; // 当存在横向滚动条时,x坐标再往右移动滚动条拉动的距离
95
+ this.current.y = e.clientY; // - this.el.offsetTop + document.scrollingElement.scrollTop; // 当存在纵向滚动条时,y坐标再往下移动滚动条拉动的距离
96
+ };
97
+
98
+ this.canvas.onmouseout = () => {
99
+ this.current.x = null;
100
+ this.current.y = null;
101
+ };
102
+
103
+ this.drawCanvas()
104
+
105
+ }
106
+
107
+ randomPoints = () => {
108
+ return range(this.props.count).map(() => ({
109
+ x: Math.random() * window.innerWidth,
110
+ y: Math.random() * window.innerHeight,
111
+ xa: 2 * Math.random() - 1, // 随机运动返现
112
+ ya: 2 * Math.random() - 1,
113
+ max: 6000 // Adhesion distance
114
+ }));
115
+ };
116
+
117
+
118
+ tid = 0;
119
+
120
+ drawCanvas = () => {
121
+
122
+ const context = this.canvasContext;
123
+ const width = window.innerWidth;
124
+ const height = window.innerHeight;
125
+ const current = this.current;
126
+ const points = this.points;
127
+ const all = this.all;
128
+
129
+ if (undefined === context
130
+ || undefined === current
131
+ || undefined === points
132
+ ) {
133
+ alert('context, current, or points was undefined. quitting.')
134
+
135
+ return;
136
+ }
137
+
138
+ context.clearRect(0, 0, width, height);
139
+
140
+ // random line and current position associative array
141
+ let e, i, d, x_dist, y_dist, dist; // temporary node
142
+
143
+ // Iterate through each point
144
+ points.forEach((r, idx) => {
145
+
146
+ r.x = r.x || 0;
147
+
148
+ r.y = r.y || 0;
149
+
150
+ r.x += r.xa;
151
+
152
+ r.y += r.ya; // move
153
+
154
+ r.xa *= r.x > width || r.x < 0 ? -1 : 1;
155
+
156
+ r.ya *= r.y > height || r.y < 0 ? -1 : 1; // Hit the boundary, bounce back
157
+
158
+ context.fillStyle = `rgba(${this.props.pointColor})`;
159
+
160
+ context.fillRect(r.x - 0.5, r.y - 0.5, 1, 1); // Draw a point with a width and height of 1
161
+
162
+ // start from next point
163
+ for (i = idx + 1; i < all.length; i++) {
164
+
165
+ e = all[i];
166
+
167
+ if (null !== e.x && null !== e.y) {
168
+
169
+ x_dist = r.x - e.x; // x-axis distance l
170
+
171
+ y_dist = r.y - e.y; // y-axis n
172
+
173
+ dist = x_dist * x_dist + y_dist * y_dist; // total distance, m
174
+
175
+ if (dist > e.max) {
176
+ continue;
177
+ }
178
+
179
+ if (e === current && dist >= e.max / 2) {
180
+
181
+ r.x -= 0.03 * x_dist;
182
+
183
+ r.y -= 0.03 * y_dist;
184
+
185
+ }
186
+
187
+ d = (e.max - dist) / e.max;
188
+
189
+ context.beginPath();
190
+
191
+ context.lineWidth = d / 2;
192
+
193
+ context.strokeStyle = `rgba(${this.props.color},${d + 0.2})`;
194
+
195
+ context.moveTo(r.x, r.y);
196
+
197
+ context.lineTo(e.x, e.y);
198
+
199
+ context.stroke();
200
+
201
+ }
202
+
203
+ }
204
+
205
+ });
206
+
207
+ requestAnimationFrame(this.drawCanvas);
208
+
209
+ }
210
+
211
+ destroy() {
212
+
213
+ cancelAnimationFrame(this.tid);
214
+
215
+ }
216
+
217
+ render() {
218
+
219
+ return (
220
+ <div>
221
+ {this.props.children}
222
+ <canvas
223
+ id={"2d"}
224
+ width={window.innerWidth}
225
+ height={window.innerHeight}
226
+ style={{
227
+ backgroundColor: this.props.backgroundColor,
228
+ display:this.props.display,
229
+ position: this.props.position,
230
+ top: this.props.top,
231
+ left: this.props.left,
232
+ overflow: this.props.overflow,
233
+ zIndex: this.props.zIndex,
234
+ opacity: this.props.opacity
235
+ }}/>
236
+ </div>
237
+ );
238
+ }
239
+
240
+ }
241
+
@@ -0,0 +1,55 @@
1
+ import classNames from "classnames";
2
+ import OutsideClickHandler from 'react-outside-click-handler';
3
+ import getStyles from "hoc/getStyles";
4
+
5
+
6
+ interface iPopupProperties {
7
+ open?: boolean;
8
+ handleClose: () => any;
9
+ children: any;
10
+ minWidth?: string;
11
+ maxWidth?: string;
12
+
13
+ }
14
+
15
+ // @link https://stackoverflow.com/questions/58399637/include-modal-functionality-in-react-higher-order-component
16
+ export default function Popup({
17
+ open = true,
18
+ handleClose,
19
+ children,
20
+ maxWidth,
21
+ }: iPopupProperties) {
22
+
23
+ if (false === open) {
24
+
25
+ return null;
26
+
27
+ }
28
+
29
+ const dig = getStyles()
30
+
31
+ return <>
32
+ <div className={classNames(dig.modal, dig.fade, dig.show, dig.dBlock)}
33
+ style={{backgroundColor: "rgba(0,0,0,0.8)"}}
34
+ id="exampleModalCenter"
35
+ tabIndex={-1} aria-labelledby="exampleModalCenterTitle"
36
+ aria-modal="true" role="dialog">
37
+
38
+ <div
39
+ style={{maxWidth: maxWidth}}
40
+ className={classNames(
41
+ dig.modalDialog, dig.modalDialogCentered,
42
+ )}
43
+ >
44
+ <OutsideClickHandler onOutsideClick={() => handleClose()}>
45
+ <div className={classNames(dig.modalContent, dig.bgTransparent, dig.modalDialogScrollable)}>
46
+ {children}
47
+ </div>
48
+ </OutsideClickHandler>
49
+ </div>
50
+
51
+ </div>
52
+ </>
53
+
54
+ }
55
+
@@ -0,0 +1,47 @@
1
+ declare module '!!raw-loader!*' {
2
+ const content: string;
3
+ export default content;
4
+ }
5
+
6
+ declare module '*.svg' {
7
+ import * as React from 'react';
8
+
9
+ export const ReactComponent: React.FunctionComponent<React.SVGProps<
10
+ SVGSVGElement
11
+ > & { title?: string }>;
12
+
13
+ const src: string;
14
+ export default src;
15
+ }
16
+
17
+ declare module '*.png';
18
+ declare module '*.jpg';
19
+ declare module '*.jpeg';
20
+ declare module "*.pdf";
21
+ declare module '*.gif';
22
+
23
+ // @link https://www.npmjs.com/package/typescript-plugin-css-modules
24
+ declare module '*.module.css' {
25
+ const classes: { [key: string]: string };
26
+ export default classes;
27
+ }
28
+
29
+ declare module '*.module.scss' {
30
+ const classes: { [key: string]: string };
31
+ export default classes;
32
+ }
33
+
34
+ declare module '*.module.sass' {
35
+ const classes: { [key: string]: string };
36
+ export default classes;
37
+ }
38
+
39
+ declare module '*.module.less' {
40
+ const classes: { [key: string]: string };
41
+ export default classes;
42
+ }
43
+
44
+ declare module '*.module.styl' {
45
+ const classes: { [key: string]: string };
46
+ export default classes;
47
+ }
@@ -0,0 +1,11 @@
1
+ import { useNavigate, NavigateFunction } from "react-router-dom";
2
+
3
+ export let globalNavigate: NavigateFunction;
4
+
5
+ export const GlobalHistory = () => {
6
+ globalNavigate = useNavigate();
7
+
8
+ return null;
9
+ };
10
+
11
+ GlobalHistory.displayName = "GlobalHistory";
@@ -0,0 +1,6 @@
1
+ export const addValidSQL: any[] = [];
2
+
3
+ export default function (sql: any) {
4
+ const {expect} = require("@jest/globals");
5
+ addValidSQL.push({[expect.getState().currentTestName.replaceAll(" ", "_").toLowerCase()]: sql});
6
+ }