@shipengine/alchemy 2.4.1 → 3.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/components/alchemy-provider/alchemy-provider.d.ts +3 -5
- package/components/alchemy-provider/hooks/index.d.ts +0 -1
- package/components/alchemy-provider/hooks/use-load-icons.d.ts +1 -2
- package/constants.d.ts +4 -0
- package/index.js +382 -42
- package/index.mjs +383 -42
- package/package.json +3 -4
- package/themes/fallback.d.ts +3 -0
- package/themes/index.d.ts +4 -0
- package/components/alchemy-provider/hooks/use-load-theme.d.ts +0 -7
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Theme } from "@packlink/giger-theme";
|
|
1
|
+
import { CustomThemeData, Theme } from "@packlink/giger-theme";
|
|
3
2
|
import { ShipEngineProps } from "@shipengine/react-api";
|
|
4
3
|
export type AlchemyErrorHandler = (err: Error) => void;
|
|
5
4
|
export type AlchemyContextValue = {
|
|
6
5
|
baseURL: string;
|
|
7
|
-
brandName: BrandName;
|
|
8
6
|
cdnURL: string;
|
|
9
7
|
getToken: ShipEngineProps["getToken"];
|
|
10
8
|
locale?: string;
|
|
@@ -15,13 +13,13 @@ export type AlchemyContextValue = {
|
|
|
15
13
|
export declare const AlchemyContext: import("react").Context<AlchemyContextValue | undefined>;
|
|
16
14
|
export interface AlchemyProviderProps {
|
|
17
15
|
baseURL?: string;
|
|
18
|
-
brandName?: BrandName;
|
|
19
16
|
cdnURL?: string;
|
|
20
17
|
children: React.ReactNode;
|
|
21
18
|
getToken: ShipEngineProps["getToken"];
|
|
22
19
|
locale?: string;
|
|
23
20
|
onError?: AlchemyErrorHandler;
|
|
24
21
|
scope?: string;
|
|
22
|
+
themeConfig?: CustomThemeData;
|
|
25
23
|
}
|
|
26
|
-
export declare const AlchemyProvider: ({ baseURL,
|
|
24
|
+
export declare const AlchemyProvider: ({ baseURL, cdnURL, children, getToken, locale, onError, scope, themeConfig, }: AlchemyProviderProps) => import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
27
25
|
export declare const useAlchemy: () => AlchemyContextValue;
|
|
@@ -2,7 +2,6 @@ export type IconIndex = {
|
|
|
2
2
|
[key: string]: string[];
|
|
3
3
|
};
|
|
4
4
|
export interface UseLoadIconsProps {
|
|
5
|
-
brandName: string;
|
|
6
5
|
cdnURL?: string;
|
|
7
6
|
}
|
|
8
|
-
export declare const useLoadIcons: ({
|
|
7
|
+
export declare const useLoadIcons: ({ cdnURL }: UseLoadIconsProps) => (iconName: string) => Promise<string>;
|
package/constants.d.ts
ADDED
package/index.js
CHANGED
|
@@ -5,10 +5,9 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
5
5
|
const React = require('react');
|
|
6
6
|
const jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
const react = require('@emotion/react');
|
|
8
|
-
const brands = require('@packlink/brands');
|
|
9
8
|
const giger = require('@packlink/giger');
|
|
10
|
-
const reactQuery = require('react-query');
|
|
11
9
|
const gigerTheme = require('@packlink/giger-theme');
|
|
10
|
+
const reactQuery = require('react-query');
|
|
12
11
|
const reactI18next = require('react-i18next');
|
|
13
12
|
const i18n = require('i18next');
|
|
14
13
|
|
|
@@ -9827,6 +9826,366 @@ const useUpdateWarehouse = () => {
|
|
|
9827
9826
|
});
|
|
9828
9827
|
};
|
|
9829
9828
|
|
|
9829
|
+
const fallbackThemeData = {
|
|
9830
|
+
borderRadius: {
|
|
9831
|
+
L: "16px",
|
|
9832
|
+
M: "8px",
|
|
9833
|
+
S: "4px",
|
|
9834
|
+
XL: "32px",
|
|
9835
|
+
XS: "2px"
|
|
9836
|
+
},
|
|
9837
|
+
breakPoints: {
|
|
9838
|
+
desktop: 1280,
|
|
9839
|
+
mobileLarge: 480,
|
|
9840
|
+
tablet: 768,
|
|
9841
|
+
tabletLarge: 960
|
|
9842
|
+
},
|
|
9843
|
+
card: {
|
|
9844
|
+
borderRadius: {
|
|
9845
|
+
desktop: "8px",
|
|
9846
|
+
mobile: "4px",
|
|
9847
|
+
tablet: "8px"
|
|
9848
|
+
}
|
|
9849
|
+
},
|
|
9850
|
+
components: {
|
|
9851
|
+
Button: {
|
|
9852
|
+
borderRadius: "4px"
|
|
9853
|
+
},
|
|
9854
|
+
Checkbox: {
|
|
9855
|
+
borderRadius: "2px",
|
|
9856
|
+
square: false
|
|
9857
|
+
},
|
|
9858
|
+
Chip: {
|
|
9859
|
+
backgroundColor: "#f4f4f4",
|
|
9860
|
+
border: "none",
|
|
9861
|
+
borderRadius: "16px",
|
|
9862
|
+
color: "#706f6f",
|
|
9863
|
+
fontWeight: 600,
|
|
9864
|
+
isSelected: {
|
|
9865
|
+
backgroundColor: "#EDEDED",
|
|
9866
|
+
border: "none",
|
|
9867
|
+
color: "#7A7A7A"
|
|
9868
|
+
},
|
|
9869
|
+
padding: "4px 16px"
|
|
9870
|
+
},
|
|
9871
|
+
Dialog: {
|
|
9872
|
+
action: {
|
|
9873
|
+
justifyContent: "center"
|
|
9874
|
+
},
|
|
9875
|
+
content: {
|
|
9876
|
+
padding: 24,
|
|
9877
|
+
textAlign: "center"
|
|
9878
|
+
},
|
|
9879
|
+
dialog: {
|
|
9880
|
+
backgroundColor: "rgba(0, 0, 0, 0.26)",
|
|
9881
|
+
borderRadius: "4px"
|
|
9882
|
+
},
|
|
9883
|
+
header: {
|
|
9884
|
+
borderBottom: "2px solid #d3d3d3",
|
|
9885
|
+
padding: 24,
|
|
9886
|
+
titleColor: "#616161"
|
|
9887
|
+
}
|
|
9888
|
+
},
|
|
9889
|
+
Field: {
|
|
9890
|
+
color: "#373737",
|
|
9891
|
+
fontWeight: 700,
|
|
9892
|
+
placeholder: {
|
|
9893
|
+
fontWeight: 700
|
|
9894
|
+
}
|
|
9895
|
+
},
|
|
9896
|
+
FieldContainer: {
|
|
9897
|
+
borderRadius: "4px"
|
|
9898
|
+
},
|
|
9899
|
+
Link: {
|
|
9900
|
+
activeColor: "#787878",
|
|
9901
|
+
defaultColor: "#616161",
|
|
9902
|
+
hoverColor: "#303030",
|
|
9903
|
+
isDark: {
|
|
9904
|
+
activeColor: "#787878",
|
|
9905
|
+
defaultColor: "#fff",
|
|
9906
|
+
hoverColor: "#fff",
|
|
9907
|
+
visitedColor: "#fff"
|
|
9908
|
+
},
|
|
9909
|
+
visitedColor: "#303030"
|
|
9910
|
+
},
|
|
9911
|
+
Table: {
|
|
9912
|
+
border: "none",
|
|
9913
|
+
borderRadius: "4px",
|
|
9914
|
+
boxShadow: "0 0 12px rgba(0, 0, 0, 0.1)"
|
|
9915
|
+
},
|
|
9916
|
+
Typography: {
|
|
9917
|
+
body1: {
|
|
9918
|
+
fontSize: "16px",
|
|
9919
|
+
fontWeight: 400,
|
|
9920
|
+
letterSpacing: 0,
|
|
9921
|
+
lineHeight: "24px"
|
|
9922
|
+
},
|
|
9923
|
+
body2: {
|
|
9924
|
+
fontSize: "14px",
|
|
9925
|
+
fontWeight: 400,
|
|
9926
|
+
letterSpacing: 3,
|
|
9927
|
+
lineHeight: "20px"
|
|
9928
|
+
},
|
|
9929
|
+
heading1: {
|
|
9930
|
+
fontSize: "48px",
|
|
9931
|
+
fontWeight: 700,
|
|
9932
|
+
letterSpacing: 0,
|
|
9933
|
+
lineHeight: "72px"
|
|
9934
|
+
},
|
|
9935
|
+
heading2: {
|
|
9936
|
+
fontSize: "32px",
|
|
9937
|
+
fontWeight: 700,
|
|
9938
|
+
letterSpacing: 1,
|
|
9939
|
+
lineHeight: "48px"
|
|
9940
|
+
},
|
|
9941
|
+
heading3: {
|
|
9942
|
+
fontSize: "24px",
|
|
9943
|
+
fontWeight: 700,
|
|
9944
|
+
letterSpacing: 3,
|
|
9945
|
+
lineHeight: "48px"
|
|
9946
|
+
},
|
|
9947
|
+
heading4: {
|
|
9948
|
+
fontSize: "20px",
|
|
9949
|
+
fontWeight: 700,
|
|
9950
|
+
letterSpacing: 3,
|
|
9951
|
+
lineHeight: "32px"
|
|
9952
|
+
},
|
|
9953
|
+
heading5: {
|
|
9954
|
+
fontSize: "18px",
|
|
9955
|
+
fontWeight: 700,
|
|
9956
|
+
letterSpacing: 3,
|
|
9957
|
+
lineHeight: "28px"
|
|
9958
|
+
},
|
|
9959
|
+
heading6: {
|
|
9960
|
+
fontSize: "16px",
|
|
9961
|
+
fontWeight: 700,
|
|
9962
|
+
letterSpacing: 3,
|
|
9963
|
+
lineHeight: "24px"
|
|
9964
|
+
},
|
|
9965
|
+
small: {
|
|
9966
|
+
fontSize: "12px",
|
|
9967
|
+
fontWeight: 400,
|
|
9968
|
+
letterSpacing: 5,
|
|
9969
|
+
lineHeight: "20px"
|
|
9970
|
+
},
|
|
9971
|
+
subtitle1: {
|
|
9972
|
+
fontSize: "16px",
|
|
9973
|
+
fontWeight: 600,
|
|
9974
|
+
letterSpacing: 3,
|
|
9975
|
+
lineHeight: "24px"
|
|
9976
|
+
},
|
|
9977
|
+
subtitle2: {
|
|
9978
|
+
fontSize: "14px",
|
|
9979
|
+
fontWeight: 600,
|
|
9980
|
+
letterSpacing: 5,
|
|
9981
|
+
lineHeight: "20px"
|
|
9982
|
+
}
|
|
9983
|
+
}
|
|
9984
|
+
},
|
|
9985
|
+
defaultFontFamily: "Arial",
|
|
9986
|
+
elevations: {
|
|
9987
|
+
above: {
|
|
9988
|
+
boxShadow: "0 0 12px rgba(0, 0, 0, 0.1)",
|
|
9989
|
+
zIndex: 1e3
|
|
9990
|
+
},
|
|
9991
|
+
backdrop: {
|
|
9992
|
+
boxShadow: "none",
|
|
9993
|
+
zIndex: 1007
|
|
9994
|
+
},
|
|
9995
|
+
flat1: {
|
|
9996
|
+
boxShadow: "0 2px 2px rgba(0, 0, 0, 0.1)",
|
|
9997
|
+
zIndex: 1
|
|
9998
|
+
},
|
|
9999
|
+
flat2: {
|
|
10000
|
+
boxShadow: "0 2px 2px rgba(0, 0, 0, 0.1)",
|
|
10001
|
+
zIndex: 1e3
|
|
10002
|
+
},
|
|
10003
|
+
overlay1: {
|
|
10004
|
+
boxShadow: "0 0 24px rgba(0, 0, 0, 0.1)",
|
|
10005
|
+
zIndex: 1006
|
|
10006
|
+
},
|
|
10007
|
+
overlay2: {
|
|
10008
|
+
boxShadow: "0 0 24px rgba(0, 0, 0, 0.1)",
|
|
10009
|
+
zIndex: 1008
|
|
10010
|
+
},
|
|
10011
|
+
popout1: {
|
|
10012
|
+
boxShadow: "0 4px 16px rgba(0, 0, 0, 0.1)",
|
|
10013
|
+
zIndex: 1004
|
|
10014
|
+
},
|
|
10015
|
+
popout2: {
|
|
10016
|
+
boxShadow: "0 4px 16px rgba(0, 0, 0, 0.1)",
|
|
10017
|
+
zIndex: 1005
|
|
10018
|
+
},
|
|
10019
|
+
raised: {
|
|
10020
|
+
boxShadow: "0 8px 8px rgba(0, 0, 0, 0.1)",
|
|
10021
|
+
zIndex: 1002
|
|
10022
|
+
},
|
|
10023
|
+
raisedInverted1: {
|
|
10024
|
+
boxShadow: "0 -8px 8px rgba(0, 0, 0, 0.1)",
|
|
10025
|
+
zIndex: 1002
|
|
10026
|
+
},
|
|
10027
|
+
raisedInverted2: {
|
|
10028
|
+
boxShadow: "0 -8px 8px rgba(0, 0, 0, 0.1)",
|
|
10029
|
+
zIndex: 1003
|
|
10030
|
+
},
|
|
10031
|
+
sticky: {
|
|
10032
|
+
boxShadow: "none",
|
|
10033
|
+
zIndex: 1001
|
|
10034
|
+
}
|
|
10035
|
+
},
|
|
10036
|
+
fontFaces: [],
|
|
10037
|
+
grid: {
|
|
10038
|
+
desktop: {
|
|
10039
|
+
columns: 12,
|
|
10040
|
+
gutter: 24,
|
|
10041
|
+
horizontalSpace: 16,
|
|
10042
|
+
verticalSpace: 24
|
|
10043
|
+
},
|
|
10044
|
+
desktopLarge: {
|
|
10045
|
+
columns: 12,
|
|
10046
|
+
gutter: 24,
|
|
10047
|
+
horizontalSpace: 16,
|
|
10048
|
+
verticalSpace: 24
|
|
10049
|
+
},
|
|
10050
|
+
mobile: {
|
|
10051
|
+
columns: 4,
|
|
10052
|
+
gutter: 16,
|
|
10053
|
+
horizontalSpace: 16,
|
|
10054
|
+
verticalSpace: 16
|
|
10055
|
+
},
|
|
10056
|
+
mobileLarge: {
|
|
10057
|
+
columns: 4,
|
|
10058
|
+
gutter: 16,
|
|
10059
|
+
horizontalSpace: 16,
|
|
10060
|
+
verticalSpace: 16
|
|
10061
|
+
},
|
|
10062
|
+
tablet: {
|
|
10063
|
+
columns: 12,
|
|
10064
|
+
gutter: 24,
|
|
10065
|
+
horizontalSpace: 16,
|
|
10066
|
+
verticalSpace: 24
|
|
10067
|
+
},
|
|
10068
|
+
tabletLarge: {
|
|
10069
|
+
columns: 12,
|
|
10070
|
+
gutter: 24,
|
|
10071
|
+
horizontalSpace: 16,
|
|
10072
|
+
verticalSpace: 24
|
|
10073
|
+
}
|
|
10074
|
+
},
|
|
10075
|
+
iconSize: {
|
|
10076
|
+
extra_large: "48px",
|
|
10077
|
+
large: "32px",
|
|
10078
|
+
medium: "20px",
|
|
10079
|
+
regular: "24px",
|
|
10080
|
+
small: "16px"
|
|
10081
|
+
},
|
|
10082
|
+
palette: {
|
|
10083
|
+
alert: {
|
|
10084
|
+
light: "#ffe7ca",
|
|
10085
|
+
main: "#725200"
|
|
10086
|
+
},
|
|
10087
|
+
black: "#000",
|
|
10088
|
+
dataVisualization: {
|
|
10089
|
+
highContrast: {
|
|
10090
|
+
blue: "#3970C1",
|
|
10091
|
+
blueDark: "#002039",
|
|
10092
|
+
coral: "#F95D6A",
|
|
10093
|
+
cyan: "#45CEE0",
|
|
10094
|
+
green: "#B3D849",
|
|
10095
|
+
orange: "#FFA600",
|
|
10096
|
+
orangeDark: "#FF7C43",
|
|
10097
|
+
pink: "#D12771",
|
|
10098
|
+
purple: "#A05195",
|
|
10099
|
+
purpleDark: "#665191"
|
|
10100
|
+
},
|
|
10101
|
+
lowContrast: {
|
|
10102
|
+
blue: "#96B3DE",
|
|
10103
|
+
blueDark: "#5283AB",
|
|
10104
|
+
coral: "#FCA6AD",
|
|
10105
|
+
cyan: "#BAE6FF",
|
|
10106
|
+
green: "#DEF895",
|
|
10107
|
+
orange: "#FDDFA5",
|
|
10108
|
+
orangeDark: "#FCC2A9",
|
|
10109
|
+
pink: "#E995BA",
|
|
10110
|
+
purple: "#D4BBFF",
|
|
10111
|
+
purpleDark: "#B1A2D0"
|
|
10112
|
+
}
|
|
10113
|
+
},
|
|
10114
|
+
error: {
|
|
10115
|
+
light: "#fee5e4",
|
|
10116
|
+
main: "#a72514"
|
|
10117
|
+
},
|
|
10118
|
+
gray: {
|
|
10119
|
+
dark: "#373737",
|
|
10120
|
+
light: "#d3d3d3",
|
|
10121
|
+
main: "#706f6f",
|
|
10122
|
+
megaLight: "#f4f4f4",
|
|
10123
|
+
ultraLight: "#f4f4f4"
|
|
10124
|
+
},
|
|
10125
|
+
info: {
|
|
10126
|
+
light: "#dbedfd",
|
|
10127
|
+
main: "#195f7f"
|
|
10128
|
+
},
|
|
10129
|
+
primary: {
|
|
10130
|
+
dark: "#626262",
|
|
10131
|
+
light: "#D6D6D6",
|
|
10132
|
+
main: "#7A7A7A",
|
|
10133
|
+
ultraLight: "#EDEDED"
|
|
10134
|
+
},
|
|
10135
|
+
secondary: {
|
|
10136
|
+
dark: "#303030",
|
|
10137
|
+
light: "#787878",
|
|
10138
|
+
main: "#616161",
|
|
10139
|
+
ultraLight: "#F4F4F4"
|
|
10140
|
+
},
|
|
10141
|
+
success: {
|
|
10142
|
+
light: "#dcfddb",
|
|
10143
|
+
main: "#286327"
|
|
10144
|
+
},
|
|
10145
|
+
white: "#fff"
|
|
10146
|
+
},
|
|
10147
|
+
spacingBase: 8,
|
|
10148
|
+
typography: {
|
|
10149
|
+
fontSize: {
|
|
10150
|
+
L: "18px",
|
|
10151
|
+
M: "16px",
|
|
10152
|
+
S: "14px",
|
|
10153
|
+
XL: "20px",
|
|
10154
|
+
XS: "12px",
|
|
10155
|
+
XXL: "24px",
|
|
10156
|
+
XXS: "10px",
|
|
10157
|
+
XXXL: "32px",
|
|
10158
|
+
XXXXL: "48px"
|
|
10159
|
+
},
|
|
10160
|
+
fontWeight: {
|
|
10161
|
+
bold: 700,
|
|
10162
|
+
light: 200,
|
|
10163
|
+
normal: 400,
|
|
10164
|
+
semibold: 600
|
|
10165
|
+
},
|
|
10166
|
+
letterSpacing: {
|
|
10167
|
+
L: 3,
|
|
10168
|
+
M: 1,
|
|
10169
|
+
S: 0,
|
|
10170
|
+
XL: 5,
|
|
10171
|
+
XXL: 8,
|
|
10172
|
+
XXXL: 12
|
|
10173
|
+
},
|
|
10174
|
+
lineHeight: {
|
|
10175
|
+
L: "28px",
|
|
10176
|
+
M: "24px",
|
|
10177
|
+
S: "20px",
|
|
10178
|
+
XL: "32px",
|
|
10179
|
+
XXL: "48px",
|
|
10180
|
+
XXXL: "72px"
|
|
10181
|
+
}
|
|
10182
|
+
}
|
|
10183
|
+
};
|
|
10184
|
+
|
|
10185
|
+
const themeData = {
|
|
10186
|
+
fallback: fallbackThemeData
|
|
10187
|
+
};
|
|
10188
|
+
|
|
9830
10189
|
var __async$1 = (__this, __arguments, generator) => {
|
|
9831
10190
|
return new Promise((resolve, reject) => {
|
|
9832
10191
|
var fulfilled = (value) => {
|
|
@@ -9877,6 +10236,11 @@ const useLoadFonts = ({ cdnURL = "/", scope, theme }) => {
|
|
|
9877
10236
|
});
|
|
9878
10237
|
};
|
|
9879
10238
|
|
|
10239
|
+
const fallbackBrandName = "fallback";
|
|
10240
|
+
const constants = {
|
|
10241
|
+
fallbackBrandName
|
|
10242
|
+
};
|
|
10243
|
+
|
|
9880
10244
|
var __async = (__this, __arguments, generator) => {
|
|
9881
10245
|
return new Promise((resolve, reject) => {
|
|
9882
10246
|
var fulfilled = (value) => {
|
|
@@ -9897,63 +10261,41 @@ var __async = (__this, __arguments, generator) => {
|
|
|
9897
10261
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
9898
10262
|
});
|
|
9899
10263
|
};
|
|
9900
|
-
const useLoadIcons = ({
|
|
9901
|
-
const [iconIndex, setIconIndex] = React.useState();
|
|
9902
|
-
React.useEffect(() => {
|
|
9903
|
-
(() => __async(void 0, null, function* () {
|
|
9904
|
-
try {
|
|
9905
|
-
const result = yield axios.get("/brand/iconIndex.json", { baseURL: cdnURL });
|
|
9906
|
-
setIconIndex(result.data);
|
|
9907
|
-
} catch (error) {
|
|
9908
|
-
logger.error({ error }, `Error loading icon index for brand ${brandName}`);
|
|
9909
|
-
}
|
|
9910
|
-
}))();
|
|
9911
|
-
}, [brandName, cdnURL]);
|
|
10264
|
+
const useLoadIcons = ({ cdnURL = "/" }) => {
|
|
9912
10265
|
return React.useCallback(
|
|
9913
10266
|
(iconName) => __async(void 0, null, function* () {
|
|
9914
|
-
|
|
9915
|
-
|
|
9916
|
-
|
|
9917
|
-
|
|
9918
|
-
|
|
9919
|
-
|
|
9920
|
-
|
|
9921
|
-
|
|
9922
|
-
|
|
9923
|
-
return result.data;
|
|
9924
|
-
}
|
|
9925
|
-
return "";
|
|
10267
|
+
const iconBrand = constants.fallbackBrandName;
|
|
10268
|
+
const result = yield axios.get(
|
|
10269
|
+
`/brand/${iconBrand}/icons/${iconName.toLowerCase()}.svg`,
|
|
10270
|
+
{
|
|
10271
|
+
baseURL: cdnURL,
|
|
10272
|
+
responseType: "text"
|
|
10273
|
+
}
|
|
10274
|
+
);
|
|
10275
|
+
return result.data;
|
|
9926
10276
|
}),
|
|
9927
|
-
[
|
|
10277
|
+
[cdnURL]
|
|
9928
10278
|
);
|
|
9929
10279
|
};
|
|
9930
10280
|
|
|
9931
|
-
const useLoadTheme = ({ cdnURL = "/", brandName }) => {
|
|
9932
|
-
const [theme, setTheme] = React.useState();
|
|
9933
|
-
React.useEffect(() => {
|
|
9934
|
-
axios.get(`/brand/${brandName}/theme.json`, { baseURL: cdnURL }).then(({ data }) => setTheme(new gigerTheme.Theme(data))).catch((error) => logger.error({ error }, `Error loading theme for brand ${brandName}`));
|
|
9935
|
-
}, [brandName, cdnURL]);
|
|
9936
|
-
return theme;
|
|
9937
|
-
};
|
|
9938
|
-
|
|
9939
10281
|
const AlchemyContext = React.createContext(void 0);
|
|
9940
10282
|
const AlchemyProvider = ({
|
|
9941
10283
|
baseURL = "https://api.shipengine.com",
|
|
9942
|
-
brandName = brands.BrandName.FALLBACK,
|
|
9943
10284
|
cdnURL = "/",
|
|
9944
10285
|
children,
|
|
9945
10286
|
getToken,
|
|
9946
10287
|
locale = ((_a) => (_a = navigator == null ? void 0 : navigator.language) != null ? _a : "en-US")(),
|
|
9947
10288
|
onError = _default,
|
|
9948
|
-
scope = "lmnt"
|
|
10289
|
+
scope = "lmnt",
|
|
10290
|
+
themeConfig
|
|
9949
10291
|
}) => {
|
|
9950
|
-
const theme =
|
|
10292
|
+
const theme = new gigerTheme.Theme(themeConfig != null ? themeConfig : themeData.fallback);
|
|
9951
10293
|
const fontStyles = useLoadFonts({ cdnURL, scope, theme });
|
|
9952
|
-
const resolveIcon = useLoadIcons({
|
|
10294
|
+
const resolveIcon = useLoadIcons({ cdnURL });
|
|
9953
10295
|
const iconCache = React.useMemo(giger.createIconCache, []);
|
|
9954
10296
|
if (!theme)
|
|
9955
10297
|
return null;
|
|
9956
|
-
const contextValue = { baseURL,
|
|
10298
|
+
const contextValue = { baseURL, cdnURL, getToken, locale, onError, scope, theme };
|
|
9957
10299
|
return /* @__PURE__ */ jsx(AlchemyContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs(react.ThemeProvider, { theme, children: [
|
|
9958
10300
|
/* @__PURE__ */ jsx(react.Global, { styles: [giger.getEmotionResetStyles(scope), fontStyles] }),
|
|
9959
10301
|
/* @__PURE__ */ jsx(giger.GigerConfigProvider, { iconCache, resolveIcon, children: /* @__PURE__ */ jsx(ShipEngine, { baseURL, getToken, children }) })
|
|
@@ -9973,7 +10315,6 @@ const AlchemyTestProvider = ({ baseURL, children }) => {
|
|
|
9973
10315
|
const getToken = React.useCallback(() => "none", []);
|
|
9974
10316
|
const contextValue = {
|
|
9975
10317
|
baseURL,
|
|
9976
|
-
brandName: brands.BrandName.FALLBACK,
|
|
9977
10318
|
cdnURL: "mockCdnUrl",
|
|
9978
10319
|
getToken,
|
|
9979
10320
|
onError: _default,
|
|
@@ -10669,7 +11010,6 @@ exports.useListShipments = useListShipments;
|
|
|
10669
11010
|
exports.useListWarehouses = useListWarehouses;
|
|
10670
11011
|
exports.useLoadFonts = useLoadFonts;
|
|
10671
11012
|
exports.useLoadIcons = useLoadIcons;
|
|
10672
|
-
exports.useLoadTheme = useLoadTheme;
|
|
10673
11013
|
exports.useNotifySalesOrderShipped = useNotifySalesOrderShipped;
|
|
10674
11014
|
exports.useParseAddress = useParseAddress;
|
|
10675
11015
|
exports.usePublishRateCard = usePublishRateCard;
|
package/index.mjs
CHANGED
|
@@ -2,10 +2,9 @@ import * as React from 'react';
|
|
|
2
2
|
import { createContext, forwardRef, useContext, createElement as createElement$1, Fragment, useState, useEffect, useCallback, useMemo, useRef } from 'react';
|
|
3
3
|
import { jsx as jsx$1, jsxs as jsxs$1 } from 'react/jsx-runtime';
|
|
4
4
|
import { css, Global, ThemeProvider, CacheProvider } from '@emotion/react';
|
|
5
|
-
import { BrandName } from '@packlink/brands';
|
|
6
5
|
import { createIconCache, getEmotionResetStyles, GigerConfigProvider, GigerTestProvider, DefaultPortalRefProvider } from '@packlink/giger';
|
|
7
|
-
import { QueryClient, QueryClientProvider, useQuery, useMutation, useQueryClient } from 'react-query';
|
|
8
6
|
import { Theme } from '@packlink/giger-theme';
|
|
7
|
+
import { QueryClient, QueryClientProvider, useQuery, useMutation, useQueryClient } from 'react-query';
|
|
9
8
|
import { I18nextProvider } from 'react-i18next';
|
|
10
9
|
import i18n from 'i18next';
|
|
11
10
|
|
|
@@ -9805,6 +9804,366 @@ const useUpdateWarehouse = () => {
|
|
|
9805
9804
|
});
|
|
9806
9805
|
};
|
|
9807
9806
|
|
|
9807
|
+
const fallbackThemeData = {
|
|
9808
|
+
borderRadius: {
|
|
9809
|
+
L: "16px",
|
|
9810
|
+
M: "8px",
|
|
9811
|
+
S: "4px",
|
|
9812
|
+
XL: "32px",
|
|
9813
|
+
XS: "2px"
|
|
9814
|
+
},
|
|
9815
|
+
breakPoints: {
|
|
9816
|
+
desktop: 1280,
|
|
9817
|
+
mobileLarge: 480,
|
|
9818
|
+
tablet: 768,
|
|
9819
|
+
tabletLarge: 960
|
|
9820
|
+
},
|
|
9821
|
+
card: {
|
|
9822
|
+
borderRadius: {
|
|
9823
|
+
desktop: "8px",
|
|
9824
|
+
mobile: "4px",
|
|
9825
|
+
tablet: "8px"
|
|
9826
|
+
}
|
|
9827
|
+
},
|
|
9828
|
+
components: {
|
|
9829
|
+
Button: {
|
|
9830
|
+
borderRadius: "4px"
|
|
9831
|
+
},
|
|
9832
|
+
Checkbox: {
|
|
9833
|
+
borderRadius: "2px",
|
|
9834
|
+
square: false
|
|
9835
|
+
},
|
|
9836
|
+
Chip: {
|
|
9837
|
+
backgroundColor: "#f4f4f4",
|
|
9838
|
+
border: "none",
|
|
9839
|
+
borderRadius: "16px",
|
|
9840
|
+
color: "#706f6f",
|
|
9841
|
+
fontWeight: 600,
|
|
9842
|
+
isSelected: {
|
|
9843
|
+
backgroundColor: "#EDEDED",
|
|
9844
|
+
border: "none",
|
|
9845
|
+
color: "#7A7A7A"
|
|
9846
|
+
},
|
|
9847
|
+
padding: "4px 16px"
|
|
9848
|
+
},
|
|
9849
|
+
Dialog: {
|
|
9850
|
+
action: {
|
|
9851
|
+
justifyContent: "center"
|
|
9852
|
+
},
|
|
9853
|
+
content: {
|
|
9854
|
+
padding: 24,
|
|
9855
|
+
textAlign: "center"
|
|
9856
|
+
},
|
|
9857
|
+
dialog: {
|
|
9858
|
+
backgroundColor: "rgba(0, 0, 0, 0.26)",
|
|
9859
|
+
borderRadius: "4px"
|
|
9860
|
+
},
|
|
9861
|
+
header: {
|
|
9862
|
+
borderBottom: "2px solid #d3d3d3",
|
|
9863
|
+
padding: 24,
|
|
9864
|
+
titleColor: "#616161"
|
|
9865
|
+
}
|
|
9866
|
+
},
|
|
9867
|
+
Field: {
|
|
9868
|
+
color: "#373737",
|
|
9869
|
+
fontWeight: 700,
|
|
9870
|
+
placeholder: {
|
|
9871
|
+
fontWeight: 700
|
|
9872
|
+
}
|
|
9873
|
+
},
|
|
9874
|
+
FieldContainer: {
|
|
9875
|
+
borderRadius: "4px"
|
|
9876
|
+
},
|
|
9877
|
+
Link: {
|
|
9878
|
+
activeColor: "#787878",
|
|
9879
|
+
defaultColor: "#616161",
|
|
9880
|
+
hoverColor: "#303030",
|
|
9881
|
+
isDark: {
|
|
9882
|
+
activeColor: "#787878",
|
|
9883
|
+
defaultColor: "#fff",
|
|
9884
|
+
hoverColor: "#fff",
|
|
9885
|
+
visitedColor: "#fff"
|
|
9886
|
+
},
|
|
9887
|
+
visitedColor: "#303030"
|
|
9888
|
+
},
|
|
9889
|
+
Table: {
|
|
9890
|
+
border: "none",
|
|
9891
|
+
borderRadius: "4px",
|
|
9892
|
+
boxShadow: "0 0 12px rgba(0, 0, 0, 0.1)"
|
|
9893
|
+
},
|
|
9894
|
+
Typography: {
|
|
9895
|
+
body1: {
|
|
9896
|
+
fontSize: "16px",
|
|
9897
|
+
fontWeight: 400,
|
|
9898
|
+
letterSpacing: 0,
|
|
9899
|
+
lineHeight: "24px"
|
|
9900
|
+
},
|
|
9901
|
+
body2: {
|
|
9902
|
+
fontSize: "14px",
|
|
9903
|
+
fontWeight: 400,
|
|
9904
|
+
letterSpacing: 3,
|
|
9905
|
+
lineHeight: "20px"
|
|
9906
|
+
},
|
|
9907
|
+
heading1: {
|
|
9908
|
+
fontSize: "48px",
|
|
9909
|
+
fontWeight: 700,
|
|
9910
|
+
letterSpacing: 0,
|
|
9911
|
+
lineHeight: "72px"
|
|
9912
|
+
},
|
|
9913
|
+
heading2: {
|
|
9914
|
+
fontSize: "32px",
|
|
9915
|
+
fontWeight: 700,
|
|
9916
|
+
letterSpacing: 1,
|
|
9917
|
+
lineHeight: "48px"
|
|
9918
|
+
},
|
|
9919
|
+
heading3: {
|
|
9920
|
+
fontSize: "24px",
|
|
9921
|
+
fontWeight: 700,
|
|
9922
|
+
letterSpacing: 3,
|
|
9923
|
+
lineHeight: "48px"
|
|
9924
|
+
},
|
|
9925
|
+
heading4: {
|
|
9926
|
+
fontSize: "20px",
|
|
9927
|
+
fontWeight: 700,
|
|
9928
|
+
letterSpacing: 3,
|
|
9929
|
+
lineHeight: "32px"
|
|
9930
|
+
},
|
|
9931
|
+
heading5: {
|
|
9932
|
+
fontSize: "18px",
|
|
9933
|
+
fontWeight: 700,
|
|
9934
|
+
letterSpacing: 3,
|
|
9935
|
+
lineHeight: "28px"
|
|
9936
|
+
},
|
|
9937
|
+
heading6: {
|
|
9938
|
+
fontSize: "16px",
|
|
9939
|
+
fontWeight: 700,
|
|
9940
|
+
letterSpacing: 3,
|
|
9941
|
+
lineHeight: "24px"
|
|
9942
|
+
},
|
|
9943
|
+
small: {
|
|
9944
|
+
fontSize: "12px",
|
|
9945
|
+
fontWeight: 400,
|
|
9946
|
+
letterSpacing: 5,
|
|
9947
|
+
lineHeight: "20px"
|
|
9948
|
+
},
|
|
9949
|
+
subtitle1: {
|
|
9950
|
+
fontSize: "16px",
|
|
9951
|
+
fontWeight: 600,
|
|
9952
|
+
letterSpacing: 3,
|
|
9953
|
+
lineHeight: "24px"
|
|
9954
|
+
},
|
|
9955
|
+
subtitle2: {
|
|
9956
|
+
fontSize: "14px",
|
|
9957
|
+
fontWeight: 600,
|
|
9958
|
+
letterSpacing: 5,
|
|
9959
|
+
lineHeight: "20px"
|
|
9960
|
+
}
|
|
9961
|
+
}
|
|
9962
|
+
},
|
|
9963
|
+
defaultFontFamily: "Arial",
|
|
9964
|
+
elevations: {
|
|
9965
|
+
above: {
|
|
9966
|
+
boxShadow: "0 0 12px rgba(0, 0, 0, 0.1)",
|
|
9967
|
+
zIndex: 1e3
|
|
9968
|
+
},
|
|
9969
|
+
backdrop: {
|
|
9970
|
+
boxShadow: "none",
|
|
9971
|
+
zIndex: 1007
|
|
9972
|
+
},
|
|
9973
|
+
flat1: {
|
|
9974
|
+
boxShadow: "0 2px 2px rgba(0, 0, 0, 0.1)",
|
|
9975
|
+
zIndex: 1
|
|
9976
|
+
},
|
|
9977
|
+
flat2: {
|
|
9978
|
+
boxShadow: "0 2px 2px rgba(0, 0, 0, 0.1)",
|
|
9979
|
+
zIndex: 1e3
|
|
9980
|
+
},
|
|
9981
|
+
overlay1: {
|
|
9982
|
+
boxShadow: "0 0 24px rgba(0, 0, 0, 0.1)",
|
|
9983
|
+
zIndex: 1006
|
|
9984
|
+
},
|
|
9985
|
+
overlay2: {
|
|
9986
|
+
boxShadow: "0 0 24px rgba(0, 0, 0, 0.1)",
|
|
9987
|
+
zIndex: 1008
|
|
9988
|
+
},
|
|
9989
|
+
popout1: {
|
|
9990
|
+
boxShadow: "0 4px 16px rgba(0, 0, 0, 0.1)",
|
|
9991
|
+
zIndex: 1004
|
|
9992
|
+
},
|
|
9993
|
+
popout2: {
|
|
9994
|
+
boxShadow: "0 4px 16px rgba(0, 0, 0, 0.1)",
|
|
9995
|
+
zIndex: 1005
|
|
9996
|
+
},
|
|
9997
|
+
raised: {
|
|
9998
|
+
boxShadow: "0 8px 8px rgba(0, 0, 0, 0.1)",
|
|
9999
|
+
zIndex: 1002
|
|
10000
|
+
},
|
|
10001
|
+
raisedInverted1: {
|
|
10002
|
+
boxShadow: "0 -8px 8px rgba(0, 0, 0, 0.1)",
|
|
10003
|
+
zIndex: 1002
|
|
10004
|
+
},
|
|
10005
|
+
raisedInverted2: {
|
|
10006
|
+
boxShadow: "0 -8px 8px rgba(0, 0, 0, 0.1)",
|
|
10007
|
+
zIndex: 1003
|
|
10008
|
+
},
|
|
10009
|
+
sticky: {
|
|
10010
|
+
boxShadow: "none",
|
|
10011
|
+
zIndex: 1001
|
|
10012
|
+
}
|
|
10013
|
+
},
|
|
10014
|
+
fontFaces: [],
|
|
10015
|
+
grid: {
|
|
10016
|
+
desktop: {
|
|
10017
|
+
columns: 12,
|
|
10018
|
+
gutter: 24,
|
|
10019
|
+
horizontalSpace: 16,
|
|
10020
|
+
verticalSpace: 24
|
|
10021
|
+
},
|
|
10022
|
+
desktopLarge: {
|
|
10023
|
+
columns: 12,
|
|
10024
|
+
gutter: 24,
|
|
10025
|
+
horizontalSpace: 16,
|
|
10026
|
+
verticalSpace: 24
|
|
10027
|
+
},
|
|
10028
|
+
mobile: {
|
|
10029
|
+
columns: 4,
|
|
10030
|
+
gutter: 16,
|
|
10031
|
+
horizontalSpace: 16,
|
|
10032
|
+
verticalSpace: 16
|
|
10033
|
+
},
|
|
10034
|
+
mobileLarge: {
|
|
10035
|
+
columns: 4,
|
|
10036
|
+
gutter: 16,
|
|
10037
|
+
horizontalSpace: 16,
|
|
10038
|
+
verticalSpace: 16
|
|
10039
|
+
},
|
|
10040
|
+
tablet: {
|
|
10041
|
+
columns: 12,
|
|
10042
|
+
gutter: 24,
|
|
10043
|
+
horizontalSpace: 16,
|
|
10044
|
+
verticalSpace: 24
|
|
10045
|
+
},
|
|
10046
|
+
tabletLarge: {
|
|
10047
|
+
columns: 12,
|
|
10048
|
+
gutter: 24,
|
|
10049
|
+
horizontalSpace: 16,
|
|
10050
|
+
verticalSpace: 24
|
|
10051
|
+
}
|
|
10052
|
+
},
|
|
10053
|
+
iconSize: {
|
|
10054
|
+
extra_large: "48px",
|
|
10055
|
+
large: "32px",
|
|
10056
|
+
medium: "20px",
|
|
10057
|
+
regular: "24px",
|
|
10058
|
+
small: "16px"
|
|
10059
|
+
},
|
|
10060
|
+
palette: {
|
|
10061
|
+
alert: {
|
|
10062
|
+
light: "#ffe7ca",
|
|
10063
|
+
main: "#725200"
|
|
10064
|
+
},
|
|
10065
|
+
black: "#000",
|
|
10066
|
+
dataVisualization: {
|
|
10067
|
+
highContrast: {
|
|
10068
|
+
blue: "#3970C1",
|
|
10069
|
+
blueDark: "#002039",
|
|
10070
|
+
coral: "#F95D6A",
|
|
10071
|
+
cyan: "#45CEE0",
|
|
10072
|
+
green: "#B3D849",
|
|
10073
|
+
orange: "#FFA600",
|
|
10074
|
+
orangeDark: "#FF7C43",
|
|
10075
|
+
pink: "#D12771",
|
|
10076
|
+
purple: "#A05195",
|
|
10077
|
+
purpleDark: "#665191"
|
|
10078
|
+
},
|
|
10079
|
+
lowContrast: {
|
|
10080
|
+
blue: "#96B3DE",
|
|
10081
|
+
blueDark: "#5283AB",
|
|
10082
|
+
coral: "#FCA6AD",
|
|
10083
|
+
cyan: "#BAE6FF",
|
|
10084
|
+
green: "#DEF895",
|
|
10085
|
+
orange: "#FDDFA5",
|
|
10086
|
+
orangeDark: "#FCC2A9",
|
|
10087
|
+
pink: "#E995BA",
|
|
10088
|
+
purple: "#D4BBFF",
|
|
10089
|
+
purpleDark: "#B1A2D0"
|
|
10090
|
+
}
|
|
10091
|
+
},
|
|
10092
|
+
error: {
|
|
10093
|
+
light: "#fee5e4",
|
|
10094
|
+
main: "#a72514"
|
|
10095
|
+
},
|
|
10096
|
+
gray: {
|
|
10097
|
+
dark: "#373737",
|
|
10098
|
+
light: "#d3d3d3",
|
|
10099
|
+
main: "#706f6f",
|
|
10100
|
+
megaLight: "#f4f4f4",
|
|
10101
|
+
ultraLight: "#f4f4f4"
|
|
10102
|
+
},
|
|
10103
|
+
info: {
|
|
10104
|
+
light: "#dbedfd",
|
|
10105
|
+
main: "#195f7f"
|
|
10106
|
+
},
|
|
10107
|
+
primary: {
|
|
10108
|
+
dark: "#626262",
|
|
10109
|
+
light: "#D6D6D6",
|
|
10110
|
+
main: "#7A7A7A",
|
|
10111
|
+
ultraLight: "#EDEDED"
|
|
10112
|
+
},
|
|
10113
|
+
secondary: {
|
|
10114
|
+
dark: "#303030",
|
|
10115
|
+
light: "#787878",
|
|
10116
|
+
main: "#616161",
|
|
10117
|
+
ultraLight: "#F4F4F4"
|
|
10118
|
+
},
|
|
10119
|
+
success: {
|
|
10120
|
+
light: "#dcfddb",
|
|
10121
|
+
main: "#286327"
|
|
10122
|
+
},
|
|
10123
|
+
white: "#fff"
|
|
10124
|
+
},
|
|
10125
|
+
spacingBase: 8,
|
|
10126
|
+
typography: {
|
|
10127
|
+
fontSize: {
|
|
10128
|
+
L: "18px",
|
|
10129
|
+
M: "16px",
|
|
10130
|
+
S: "14px",
|
|
10131
|
+
XL: "20px",
|
|
10132
|
+
XS: "12px",
|
|
10133
|
+
XXL: "24px",
|
|
10134
|
+
XXS: "10px",
|
|
10135
|
+
XXXL: "32px",
|
|
10136
|
+
XXXXL: "48px"
|
|
10137
|
+
},
|
|
10138
|
+
fontWeight: {
|
|
10139
|
+
bold: 700,
|
|
10140
|
+
light: 200,
|
|
10141
|
+
normal: 400,
|
|
10142
|
+
semibold: 600
|
|
10143
|
+
},
|
|
10144
|
+
letterSpacing: {
|
|
10145
|
+
L: 3,
|
|
10146
|
+
M: 1,
|
|
10147
|
+
S: 0,
|
|
10148
|
+
XL: 5,
|
|
10149
|
+
XXL: 8,
|
|
10150
|
+
XXXL: 12
|
|
10151
|
+
},
|
|
10152
|
+
lineHeight: {
|
|
10153
|
+
L: "28px",
|
|
10154
|
+
M: "24px",
|
|
10155
|
+
S: "20px",
|
|
10156
|
+
XL: "32px",
|
|
10157
|
+
XXL: "48px",
|
|
10158
|
+
XXXL: "72px"
|
|
10159
|
+
}
|
|
10160
|
+
}
|
|
10161
|
+
};
|
|
10162
|
+
|
|
10163
|
+
const themeData = {
|
|
10164
|
+
fallback: fallbackThemeData
|
|
10165
|
+
};
|
|
10166
|
+
|
|
9808
10167
|
var __async$1 = (__this, __arguments, generator) => {
|
|
9809
10168
|
return new Promise((resolve, reject) => {
|
|
9810
10169
|
var fulfilled = (value) => {
|
|
@@ -9855,6 +10214,11 @@ const useLoadFonts = ({ cdnURL = "/", scope, theme }) => {
|
|
|
9855
10214
|
});
|
|
9856
10215
|
};
|
|
9857
10216
|
|
|
10217
|
+
const fallbackBrandName = "fallback";
|
|
10218
|
+
const constants = {
|
|
10219
|
+
fallbackBrandName
|
|
10220
|
+
};
|
|
10221
|
+
|
|
9858
10222
|
var __async = (__this, __arguments, generator) => {
|
|
9859
10223
|
return new Promise((resolve, reject) => {
|
|
9860
10224
|
var fulfilled = (value) => {
|
|
@@ -9875,63 +10239,41 @@ var __async = (__this, __arguments, generator) => {
|
|
|
9875
10239
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
9876
10240
|
});
|
|
9877
10241
|
};
|
|
9878
|
-
const useLoadIcons = ({
|
|
9879
|
-
const [iconIndex, setIconIndex] = useState();
|
|
9880
|
-
useEffect(() => {
|
|
9881
|
-
(() => __async(void 0, null, function* () {
|
|
9882
|
-
try {
|
|
9883
|
-
const result = yield axios.get("/brand/iconIndex.json", { baseURL: cdnURL });
|
|
9884
|
-
setIconIndex(result.data);
|
|
9885
|
-
} catch (error) {
|
|
9886
|
-
logger.error({ error }, `Error loading icon index for brand ${brandName}`);
|
|
9887
|
-
}
|
|
9888
|
-
}))();
|
|
9889
|
-
}, [brandName, cdnURL]);
|
|
10242
|
+
const useLoadIcons = ({ cdnURL = "/" }) => {
|
|
9890
10243
|
return useCallback(
|
|
9891
10244
|
(iconName) => __async(void 0, null, function* () {
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
|
|
9895
|
-
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
9899
|
-
|
|
9900
|
-
|
|
9901
|
-
return result.data;
|
|
9902
|
-
}
|
|
9903
|
-
return "";
|
|
10245
|
+
const iconBrand = constants.fallbackBrandName;
|
|
10246
|
+
const result = yield axios.get(
|
|
10247
|
+
`/brand/${iconBrand}/icons/${iconName.toLowerCase()}.svg`,
|
|
10248
|
+
{
|
|
10249
|
+
baseURL: cdnURL,
|
|
10250
|
+
responseType: "text"
|
|
10251
|
+
}
|
|
10252
|
+
);
|
|
10253
|
+
return result.data;
|
|
9904
10254
|
}),
|
|
9905
|
-
[
|
|
10255
|
+
[cdnURL]
|
|
9906
10256
|
);
|
|
9907
10257
|
};
|
|
9908
10258
|
|
|
9909
|
-
const useLoadTheme = ({ cdnURL = "/", brandName }) => {
|
|
9910
|
-
const [theme, setTheme] = useState();
|
|
9911
|
-
useEffect(() => {
|
|
9912
|
-
axios.get(`/brand/${brandName}/theme.json`, { baseURL: cdnURL }).then(({ data }) => setTheme(new Theme(data))).catch((error) => logger.error({ error }, `Error loading theme for brand ${brandName}`));
|
|
9913
|
-
}, [brandName, cdnURL]);
|
|
9914
|
-
return theme;
|
|
9915
|
-
};
|
|
9916
|
-
|
|
9917
10259
|
const AlchemyContext = createContext(void 0);
|
|
9918
10260
|
const AlchemyProvider = ({
|
|
9919
10261
|
baseURL = "https://api.shipengine.com",
|
|
9920
|
-
brandName = BrandName.FALLBACK,
|
|
9921
10262
|
cdnURL = "/",
|
|
9922
10263
|
children,
|
|
9923
10264
|
getToken,
|
|
9924
10265
|
locale = ((_a) => (_a = navigator == null ? void 0 : navigator.language) != null ? _a : "en-US")(),
|
|
9925
10266
|
onError = _default,
|
|
9926
|
-
scope = "lmnt"
|
|
10267
|
+
scope = "lmnt",
|
|
10268
|
+
themeConfig
|
|
9927
10269
|
}) => {
|
|
9928
|
-
const theme =
|
|
10270
|
+
const theme = new Theme(themeConfig != null ? themeConfig : themeData.fallback);
|
|
9929
10271
|
const fontStyles = useLoadFonts({ cdnURL, scope, theme });
|
|
9930
|
-
const resolveIcon = useLoadIcons({
|
|
10272
|
+
const resolveIcon = useLoadIcons({ cdnURL });
|
|
9931
10273
|
const iconCache = useMemo(createIconCache, []);
|
|
9932
10274
|
if (!theme)
|
|
9933
10275
|
return null;
|
|
9934
|
-
const contextValue = { baseURL,
|
|
10276
|
+
const contextValue = { baseURL, cdnURL, getToken, locale, onError, scope, theme };
|
|
9935
10277
|
return /* @__PURE__ */ jsx(AlchemyContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs(ThemeProvider, { theme, children: [
|
|
9936
10278
|
/* @__PURE__ */ jsx(Global, { styles: [getEmotionResetStyles(scope), fontStyles] }),
|
|
9937
10279
|
/* @__PURE__ */ jsx(GigerConfigProvider, { iconCache, resolveIcon, children: /* @__PURE__ */ jsx(ShipEngine, { baseURL, getToken, children }) })
|
|
@@ -9951,7 +10293,6 @@ const AlchemyTestProvider = ({ baseURL, children }) => {
|
|
|
9951
10293
|
const getToken = useCallback(() => "none", []);
|
|
9952
10294
|
const contextValue = {
|
|
9953
10295
|
baseURL,
|
|
9954
|
-
brandName: BrandName.FALLBACK,
|
|
9955
10296
|
cdnURL: "mockCdnUrl",
|
|
9956
10297
|
getToken,
|
|
9957
10298
|
onError: _default,
|
|
@@ -10562,4 +10903,4 @@ const alchemy = {
|
|
|
10562
10903
|
createElement
|
|
10563
10904
|
};
|
|
10564
10905
|
|
|
10565
|
-
export { AccountSettingsAPI, AddressesAPI, AlchemyContext, AlchemyProvider, AlchemyTestProvider, CarriersAPI, CodedError, ConfirmationType, CreditCardVendor, Currency, CustomPackagesAPI, CustomsContentsType, CustomsNonDeliveryType, Element, ErrorBoundary, FundingSourcesAPI, InsuranceAPI, InsuranceProviderType, LabelsAPI, OrderSourcesAPI, RateCardStatus, RateCardsAPI, RatesAPI, types as SE, SalesOrderShipmentsAPI, SalesOrdersAPI, ShipEngine, ShipEngineAPI, ShipEngineContext, ShipmentsAPI, WarehousesAPI, alchemy, alchemy as default, delay, getEndUserIpAddress, isCodedError, isCodedErrors, logger, memoizedCreateCache, onError, retryUntil, useAddFunds, useAlchemy, useCalculateRates, useConnectCarrier, useCreateFundingSource, useCreateLabel, useCreateRateCard, useCreateSalesOrderShipment, useCreateShipment, useCreateWarehouse, useDeleteRateCard, useDeleteWarehouse, useDownloadRateCard, useFundingSourcesAddFunds, useGetAccountSettings, useGetAutoFundingConfiguration, useGetCarrierById, useGetCountriesByCarrier, useGetCurrenciesByCarrier, useGetFundingSourceById, useGetInsuranceAccount, useGetLabel, useGetPackageRatingGroupByCarrier, useGetRateCardById, useGetSalesOrder, useGetSalesOrderShipment, useGetServicesByCarrier, useGetShipment, useGetShipmentRates, useGetWalletHistory, useGetZonesByCarrier, useI18n, useListCarriers, useListCustomPackageTypes, useListFundingSources, useListLabels, useListOrderSources, useListRateCards, useListSalesOrderShipments, useListSalesOrders, useListShipments, useListWarehouses, useLoadFonts, useLoadIcons,
|
|
10906
|
+
export { AccountSettingsAPI, AddressesAPI, AlchemyContext, AlchemyProvider, AlchemyTestProvider, CarriersAPI, CodedError, ConfirmationType, CreditCardVendor, Currency, CustomPackagesAPI, CustomsContentsType, CustomsNonDeliveryType, Element, ErrorBoundary, FundingSourcesAPI, InsuranceAPI, InsuranceProviderType, LabelsAPI, OrderSourcesAPI, RateCardStatus, RateCardsAPI, RatesAPI, types as SE, SalesOrderShipmentsAPI, SalesOrdersAPI, ShipEngine, ShipEngineAPI, ShipEngineContext, ShipmentsAPI, WarehousesAPI, alchemy, alchemy as default, delay, getEndUserIpAddress, isCodedError, isCodedErrors, logger, memoizedCreateCache, onError, retryUntil, useAddFunds, useAlchemy, useCalculateRates, useConnectCarrier, useCreateFundingSource, useCreateLabel, useCreateRateCard, useCreateSalesOrderShipment, useCreateShipment, useCreateWarehouse, useDeleteRateCard, useDeleteWarehouse, useDownloadRateCard, useFundingSourcesAddFunds, useGetAccountSettings, useGetAutoFundingConfiguration, useGetCarrierById, useGetCountriesByCarrier, useGetCurrenciesByCarrier, useGetFundingSourceById, useGetInsuranceAccount, useGetLabel, useGetPackageRatingGroupByCarrier, useGetRateCardById, useGetSalesOrder, useGetSalesOrderShipment, useGetServicesByCarrier, useGetShipment, useGetShipmentRates, useGetWalletHistory, useGetZonesByCarrier, useI18n, useListCarriers, useListCustomPackageTypes, useListFundingSources, useListLabels, useListOrderSources, useListRateCards, useListSalesOrderShipments, useListSalesOrders, useListShipments, useListWarehouses, useLoadFonts, useLoadIcons, useNotifySalesOrderShipped, useParseAddress, usePublishRateCard, useRefreshOrderSource, useRefreshOrderSourceAsync, useRegisterCarrier, useShipEngine, useUpdateAccountSettings, useUpdateAutoFunding, useUpdateFundingSource, useUpdateRateCard, useUpdateSalesOrderShipment, useUpdateWarehouse, useUploadRateCard, useValidateAddresses, useVoidLabel };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipengine/alchemy",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -17,9 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"@emotion/react": "11.x",
|
|
20
|
-
"@packlink/
|
|
21
|
-
"@packlink/giger
|
|
22
|
-
"@packlink/giger": "68.x.x",
|
|
20
|
+
"@packlink/giger-theme": "2.x.x",
|
|
21
|
+
"@packlink/giger": ">= 68.19.6 < 69",
|
|
23
22
|
"i18next": "22.x",
|
|
24
23
|
"react": "17.x || 18.x",
|
|
25
24
|
"react-dom": "17.x || 18.x",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { BrandName } from "@packlink/brands";
|
|
2
|
-
import { Theme } from "@packlink/giger-theme";
|
|
3
|
-
export interface UseLoadThemeProps {
|
|
4
|
-
brandName: BrandName;
|
|
5
|
-
cdnURL?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const useLoadTheme: ({ cdnURL, brandName }: UseLoadThemeProps) => Theme | undefined;
|