@carbonorm/carbonreact 1.3.1 → 2.0.1
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/dist/CarbonReact.d.ts +6 -13
- package/dist/hoc/deleteRestfulObjectArrays.d.ts +3 -2
- package/dist/hoc/getStyles.d.ts +3 -3
- package/dist/hoc/updateRestfulObjectArrays.d.ts +3 -2
- package/dist/index.cjs.js +1519 -2650
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.esm.js +1517 -2636
- package/dist/index.esm.js.map +1 -1
- package/dist/variables/C6.d.ts +33 -564
- package/package.json +4 -3
- package/src/CarbonReact.tsx +17 -28
- package/src/hoc/axiosInstance.tsx +1 -1
- package/src/hoc/deleteRestfulObjectArrays.tsx +7 -5
- package/src/hoc/getStyles.tsx +4 -4
- package/src/hoc/setUrl.tsx +1 -1
- package/src/hoc/updateRestfulObjectArrays.tsx +6 -6
- package/src/index.ts +0 -2
- package/src/variables/C6.tsx +1170 -2651
- package/dist/components/Errors/Localhost.d.ts +0 -1
- package/src/components/Errors/Localhost.tsx +0 -38
package/src/CarbonReact.tsx
CHANGED
|
@@ -8,38 +8,34 @@ import {ToastContainer} from 'react-toastify';
|
|
|
8
8
|
import 'react-toastify/dist/ReactToastify.min.css';
|
|
9
9
|
import BackendThrowable from 'components/Errors/BackendThrowable';
|
|
10
10
|
import Nest from 'components/Nest/Nest';
|
|
11
|
-
import {
|
|
11
|
+
import {initialRestfulObjectsState, iRestfulObjectArrayTypes} from "variables/C6";
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
export type tStatefulApiData<T> = T[] | undefined | null;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// this refers to the value types of the keys above, aka values in the state
|
|
18
|
-
export interface iRestfulObjectArrayTypes {
|
|
19
|
-
carbons: tStatefulApiData<iCarbons>,
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type tRestfulObjectArrayKeys = keyof iRestfulObjectArrayTypes
|
|
23
|
-
|
|
24
|
-
export type tRestfulObjectArrayValues = iRestfulObjectArrayTypes[tRestfulObjectArrayKeys];
|
|
25
|
-
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
export type tRestfulObjectValues = tRestfulObjectArrayValues[number];
|
|
28
14
|
|
|
29
15
|
// our central container, single page application is best with the DigApi
|
|
30
|
-
export interface iCarbonORMState
|
|
16
|
+
export interface iCarbonORMState {
|
|
17
|
+
alertsWaiting: any[],
|
|
31
18
|
websocketEvents: MessageEvent[],
|
|
32
19
|
websocketData: any[],
|
|
33
20
|
websocket?: WebSocket,
|
|
34
|
-
websocketMounted: boolean,
|
|
35
|
-
alert?: boolean,
|
|
36
|
-
alertsWaiting: any[],
|
|
37
21
|
backendThrowable: any[],
|
|
38
22
|
}
|
|
39
23
|
|
|
24
|
+
export const initialRequiredCarbonORMState: iCarbonORMState = {
|
|
25
|
+
alertsWaiting: [],
|
|
26
|
+
backendThrowable: [],
|
|
27
|
+
websocketData: [],
|
|
28
|
+
websocketEvents: [],
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const initialCarbonORMState: iCarbonORMState = {
|
|
32
|
+
...initialRequiredCarbonORMState,
|
|
33
|
+
...initialRestfulObjectsState,
|
|
34
|
+
}
|
|
35
|
+
|
|
40
36
|
export default class CarbonReact<P = {}, S = {}> extends React.Component<{
|
|
41
37
|
children?: ReactNode | ReactNode[],
|
|
42
|
-
} & P,
|
|
38
|
+
} & P, ( iRestfulObjectArrayTypes |& S ) & iCarbonORMState> {
|
|
43
39
|
|
|
44
40
|
static instance: CarbonReact;
|
|
45
41
|
|
|
@@ -53,14 +49,7 @@ export default class CarbonReact<P = {}, S = {}> extends React.Component<{
|
|
|
53
49
|
|
|
54
50
|
super(props);
|
|
55
51
|
|
|
56
|
-
this.state =
|
|
57
|
-
carbons: undefined,
|
|
58
|
-
alertsWaiting: [],
|
|
59
|
-
backendThrowable: [],
|
|
60
|
-
websocketData: [],
|
|
61
|
-
websocketEvents: [],
|
|
62
|
-
websocketMounted: false,
|
|
63
|
-
} as unknown as iCarbonORMState & S;
|
|
52
|
+
this.state = initialCarbonORMState as unknown as iCarbonORMState & S;
|
|
64
53
|
|
|
65
54
|
CarbonReact.instance = this;
|
|
66
55
|
|
|
@@ -271,7 +271,7 @@ function axiosInterceptors(axios: AxiosInstance): void {
|
|
|
271
271
|
|
|
272
272
|
if (isTest) {
|
|
273
273
|
|
|
274
|
-
throw new Error(error?.response.data['CarbonPHP\\Error\\PublicAlert'] ?? error?.response.data['
|
|
274
|
+
throw new Error(error?.response.data['CarbonPHP\\Error\\PublicAlert'] ?? error?.response.data['TRACE'] ?? JSON.stringify(error?.response.data, undefined, 4))
|
|
275
275
|
|
|
276
276
|
}
|
|
277
277
|
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import CarbonReact, {iCarbonORMState
|
|
1
|
+
import CarbonReact, {iCarbonORMState} from "CarbonReact";
|
|
2
|
+
import {iRestfulObjectArrayTypes, tRestfulObjectValues} from "variables/C6";
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
//ObjectType, UniqueIdType extends keyof ObjectType
|
|
5
|
-
export default function deleteRestfulObjectArrays<ObjectType
|
|
6
|
+
export default function deleteRestfulObjectArrays<ObjectType = tRestfulObjectValues, ObjectArrayTypes = iRestfulObjectArrayTypes>
|
|
6
7
|
(dataOrCallback: ((prev: Readonly<iCarbonORMState>) => ObjectType[]) | ObjectType[],
|
|
7
|
-
stateKey: keyof
|
|
8
|
+
stateKey: keyof ObjectArrayTypes,
|
|
8
9
|
uniqueObjectId: keyof ObjectType,
|
|
9
10
|
callback?: () => void): void {
|
|
10
11
|
|
|
11
|
-
return CarbonReact.instance.setState((previousBootstrapState): {} => {
|
|
12
|
+
return CarbonReact.instance.setState((previousBootstrapState ): {} => {
|
|
12
13
|
|
|
13
14
|
let newOrReplacementData: ObjectType[] = dataOrCallback instanceof Function ? dataOrCallback(previousBootstrapState) : dataOrCallback;
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
const previousStateProperty = previousBootstrapState[stateKey];
|
|
16
18
|
|
|
17
19
|
return {
|
|
18
20
|
[stateKey]: null === previousBootstrapState ? null : [
|
package/src/hoc/getStyles.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import classNames from "classnames";
|
|
2
2
|
import BootstrapStyle from "variables/bootstrap.module.css"
|
|
3
|
-
import
|
|
3
|
+
import Styles from "style.module.css"
|
|
4
4
|
|
|
5
5
|
export const getRootStyleValue = (property = '--dig_primary_color') : string => {
|
|
6
6
|
|
|
@@ -27,13 +27,13 @@ function mergeStyles<iStyleA extends iStyle, iStyleB extends iStyle>(styleA : iS
|
|
|
27
27
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const dropStyles = mergeStyles(BootstrapStyle,
|
|
30
|
+
const dropStyles = mergeStyles(BootstrapStyle, Styles);
|
|
31
31
|
|
|
32
32
|
type tBootstrap = typeof BootstrapStyle
|
|
33
33
|
|
|
34
|
-
type
|
|
34
|
+
type tStyles = typeof Styles
|
|
35
35
|
|
|
36
|
-
export default function getStyles<iCSS extends {}>(overrides: iCSS = {} as iCSS): tBootstrap &
|
|
36
|
+
export default function getStyles<iCSS extends {}>(overrides: iCSS = {} as iCSS): tBootstrap & tStyles & iCSS {
|
|
37
37
|
|
|
38
38
|
if (0 === Object.keys(overrides).length) {
|
|
39
39
|
return dropStyles as (typeof dropStyles) & iCSS
|
package/src/hoc/setUrl.tsx
CHANGED
|
@@ -5,7 +5,7 @@ export default function setUrl() {
|
|
|
5
5
|
|
|
6
6
|
const isGitHubActions = process.env.REACT_APP_TEST_REMOTE === 'true'
|
|
7
7
|
|
|
8
|
-
const host = ( isGitHubActions ? process.env.REACT_APP_REMOTE_SUBDOMAIN : process.env.REACT_APP_LOCAL_SUBDOMAIN ) + '.
|
|
8
|
+
const host = ( isGitHubActions ? process.env.REACT_APP_REMOTE_SUBDOMAIN : process.env.REACT_APP_LOCAL_SUBDOMAIN ) + '.example.com' + (isGitHubActions ? '' : ':8080')
|
|
9
9
|
|
|
10
10
|
console.log("test host:: ", host, isGitHubActions)
|
|
11
11
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import CarbonReact, {
|
|
2
|
-
iCarbonORMState
|
|
3
|
-
iRestfulObjectArrayTypes,
|
|
4
|
-
tRestfulObjectValues
|
|
2
|
+
iCarbonORMState
|
|
5
3
|
} from "CarbonReact";
|
|
4
|
+
import {iRestfulObjectArrayTypes, tRestfulObjectValues} from "variables/C6";
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
export enum eUpdateInsertMethod {
|
|
@@ -21,9 +20,9 @@ export enum eUpdateInsertMethod {
|
|
|
21
20
|
* @param callback - if you want to do something with the updated state, you can pass a callback here. Run as the second
|
|
22
21
|
* parameter of setState.
|
|
23
22
|
*/
|
|
24
|
-
export default function updateRestfulObjectArray<ObjectType
|
|
23
|
+
export default function updateRestfulObjectArray<ObjectType = tRestfulObjectValues, ObjectArrayTypes = iRestfulObjectArrayTypes>
|
|
25
24
|
(dataOrCallback: ((prev: Readonly<iCarbonORMState>) => ObjectType[]) | ObjectType[],
|
|
26
|
-
stateKey: keyof
|
|
25
|
+
stateKey: keyof ObjectArrayTypes,
|
|
27
26
|
uniqueObjectId: keyof ObjectType,
|
|
28
27
|
insertUpdateOrder: eUpdateInsertMethod = eUpdateInsertMethod.LAST,
|
|
29
28
|
callback?: () => void): void {
|
|
@@ -34,7 +33,8 @@ export default function updateRestfulObjectArray<ObjectType extends tRestfulObje
|
|
|
34
33
|
|
|
35
34
|
let newOrReplacementData: ObjectType[] = dataOrCallback instanceof Function ? dataOrCallback(previousBootstrapState) : dataOrCallback;
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
const previousStateProperty = previousBootstrapState[stateKey];
|
|
38
38
|
|
|
39
39
|
let updatedData = newOrReplacementData.map(value => {
|
|
40
40
|
return {
|
package/src/index.ts
CHANGED
|
@@ -12,8 +12,6 @@ export { default as BackendThrowable } from "./components/Errors/BackendThrowabl
|
|
|
12
12
|
export * from "./components/Errors/BackendThrowable";
|
|
13
13
|
export { default as ErrorHttpCode } from "./components/Errors/ErrorHttpCode";
|
|
14
14
|
export * from "./components/Errors/ErrorHttpCode";
|
|
15
|
-
export { default as Localhost } from "./components/Errors/Localhost";
|
|
16
|
-
export * from "./components/Errors/Localhost";
|
|
17
15
|
export { default as PageNotFound } from "./components/Errors/PageNotFound";
|
|
18
16
|
export * from "./components/Errors/PageNotFound";
|
|
19
17
|
export { default as Loading } from "./components/Loading/Loading";
|