@dartcom/ui-kit 10.2.35 → 10.3.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.
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { CustomCardProps } from './types';
3
- declare const CustomCard: React.FC<React.PropsWithChildren<CustomCardProps>>;
2
+ import { Props } from './types';
3
+ declare const CustomCard: React.FC<React.PropsWithChildren<Props>>;
4
4
  export default CustomCard;
5
5
  //# sourceMappingURL=card.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../../src/components/card/card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,eAAe,CAAC,CA6BlE,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../../src/components/card/card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CA4BxD,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { SxFunction } from '../../lib/types';
2
- export type CustomCardProps = {
2
+ export type Props = {
3
3
  sx?: SxFunction;
4
4
  };
5
5
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/card/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,CAAC,EAAE,UAAU,CAAC;CACjB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/card/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,MAAM,KAAK,GAAG;IAClB,EAAE,CAAC,EAAE,UAAU,CAAC;CACjB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import * as yup from 'yup';
2
- export declare const getStringSchema: <T extends string>() => yup.StringSchema<T | undefined, yup.AnyObject, undefined, "">;
3
- export declare const getStringRequiredSchema: <T extends string>(message?: string) => yup.StringSchema<T, yup.AnyObject, undefined, "">;
2
+ export declare const getStringSchema: <T extends string = string>() => yup.StringSchema<T | undefined, yup.AnyObject, undefined, "">;
3
+ export declare const getStringRequiredSchema: <T extends string = string>(message?: string) => yup.StringSchema<T, yup.AnyObject, undefined, "">;
4
4
  export declare const numberSchema: yup.NumberSchema<number | undefined, yup.AnyObject, undefined, "">;
5
5
  export declare const numberRequiredSchema: yup.NumberSchema<number, yup.AnyObject, undefined, "">;
6
6
  export declare const arraySchema: yup.ArraySchema<any[] | undefined, yup.AnyObject, undefined, "">;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/constants/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,oEAAsB,CAAC;AACvE,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,MAAM,EACtD,gBAAyB,sDACgB,CAAC;AAE5C,eAAO,MAAM,YAAY,oEAAe,CAAC;AACzC,eAAO,MAAM,oBAAoB,wDAAyC,CAAC;AAE3E,eAAO,MAAM,WAAW,kEAAc,CAAC;AAEvC,eAAO,MAAM,UAAU,gEAAa,CAAC;AACrC,eAAO,MAAM,kBAAkB,oDAAuC,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/constants/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,GAAG,MAAM,oEAAsB,CAAC;AAChF,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,MAAM,GAAG,MAAM,EAC/D,gBAAyB,sDACgB,CAAC;AAE5C,eAAO,MAAM,YAAY,oEAAe,CAAC;AACzC,eAAO,MAAM,oBAAoB,wDAAyC,CAAC;AAE3E,eAAO,MAAM,WAAW,kEAAc,CAAC;AAEvC,eAAO,MAAM,UAAU,gEAAa,CAAC;AACrC,eAAO,MAAM,kBAAkB,oDAAuC,CAAC"}
package/dist/index.cjs CHANGED
@@ -16531,7 +16531,7 @@ const getEntityNames = ({ entity, names, }) => {
16531
16531
  return layerNames;
16532
16532
  };
16533
16533
  const getImageSrc = (path) => {
16534
- const imageSrc = `${"https://dalganmap.ru/api-image/images"}/${path}`;
16534
+ const imageSrc = `${"$VITE_API_HOST/api-image/images"}/${path}`;
16535
16535
  return imageSrc;
16536
16536
  };
16537
16537
 
@@ -24978,6 +24978,69 @@ const useGetUser = () => {
24978
24978
  });
24979
24979
  };
24980
24980
 
24981
+ const useShowSnackbar = () => {
24982
+ const { enqueueSnackbar } = useSnackbar();
24983
+ const showSnackbar = ({ variant, message, }) => {
24984
+ enqueueSnackbar({
24985
+ variant,
24986
+ message,
24987
+ anchorOrigin: {
24988
+ vertical: 'top',
24989
+ horizontal: 'right',
24990
+ },
24991
+ autoHideDuration: 3000,
24992
+ hideIconVariant: true,
24993
+ });
24994
+ };
24995
+ return showSnackbar;
24996
+ };
24997
+
24998
+ const useShowErrorSnackbar = () => {
24999
+ const showSnackbar = useShowSnackbar();
25000
+ const showErrorSnackbar = (error) => {
25001
+ const { response } = error;
25002
+ if (response) {
25003
+ const { data } = response;
25004
+ if (data) {
25005
+ const { detail } = data;
25006
+ if (detail) {
25007
+ detail.forEach((message) => {
25008
+ showSnackbar({
25009
+ variant: 'error',
25010
+ message,
25011
+ });
25012
+ });
25013
+ }
25014
+ }
25015
+ }
25016
+ };
25017
+ return showErrorSnackbar;
25018
+ };
25019
+
25020
+ const useSignIn = () => {
25021
+ const mutation = useMutation({
25022
+ mutationKey: ['sign-in-mutation'],
25023
+ mutationFn: async ({ body: { username, password } }) => {
25024
+ const body = getUrlencodedBody({
25025
+ username,
25026
+ password: encodeString(password),
25027
+ });
25028
+ const response = await GlobalConfig.instance.apiService.post({
25029
+ url: 'token',
25030
+ body,
25031
+ config: {
25032
+ withCredentials: true,
25033
+ headers: {
25034
+ 'Content-Type': 'application/x-www-form-urlencoded',
25035
+ },
25036
+ },
25037
+ });
25038
+ return response;
25039
+ },
25040
+ });
25041
+ return mutation;
25042
+ };
25043
+
24981
25044
  if (!React.useState) {
24982
25045
  throw new Error("mobx-react-lite requires React with Hooks support");
24983
25046
  }
@@ -26670,46 +26733,7 @@ const DartcomProviders = ({ children, configOptions, themeOptions }) => {
26670
26733
  return (jsxRuntime.jsx(SnackbarProvider, { children: jsxRuntime.jsx(QueryProvider, { children: jsxRuntime.jsx(DartcomMobxProvider, { children: jsxRuntime.jsx(DartcomThemeProvider, { themeOptions: themeOptions, children: jsxRuntime.jsx(Provider, { children: jsxRuntime.jsx(MapProvider, { children: jsxRuntime.jsx(DartcomInitializeProvider, { configOptions: configOptions, children: children }) }) }) }) }) }) }));
26671
26734
  };
26672
26735
 
26673
- const useShowSnackbar = () => {
26674
- const { enqueueSnackbar } = useSnackbar();
26675
- const showSnackbar = ({ variant, message, }) => {
26676
- enqueueSnackbar({
26677
- variant,
26678
- message,
26679
- anchorOrigin: {
26680
- vertical: 'top',
26681
- horizontal: 'right',
26682
- },
26683
- autoHideDuration: 3000,
26684
- hideIconVariant: true,
26685
- });
26686
- };
26687
- return showSnackbar;
26688
- };
26689
-
26690
- const useShowErrorSnackbar = () => {
26691
- const showSnackbar = useShowSnackbar();
26692
- const showErrorSnackbar = (error) => {
26693
- const { response } = error;
26694
- if (response) {
26695
- const { data } = response;
26696
- if (data) {
26697
- const { detail } = data;
26698
- if (detail) {
26699
- detail.forEach((message) => {
26700
- showSnackbar({
26701
- variant: 'error',
26702
- message,
26703
- });
26704
- });
26705
- }
26706
- }
26707
- }
26708
- };
26709
- return showErrorSnackbar;
26710
- };
26711
-
26712
- const useLogout = () => {
26736
+ const useSignOut = () => {
26713
26737
  const showErrorSnackbar = useShowErrorSnackbar();
26714
26738
  return useMutation({
26715
26739
  mutationKey: ['logout-mutation'],
@@ -26728,28 +26752,6 @@ const useLogout = () => {
26728
26752
  });
26729
26753
  };
26730
26754
 
26731
- const useSignIn = () => {
26732
- return useMutation({
26733
- mutationKey: ['sign-in-mutation'],
26734
- mutationFn: async ({ body: { username, password } }) => {
26735
- const body = getUrlencodedBody({
26736
- username,
26737
- password: encodeString(password),
26738
- });
26739
- const response = await GlobalConfig.instance.apiService.post({
26740
- url: 'token',
26741
- body,
26742
- config: {
26743
- headers: {
26744
- 'Content-Type': 'application/x-www-form-urlencoded',
26745
- },
26746
- },
26747
- });
26748
- return response;
26749
- },
26750
- });
26751
- };
26752
-
26753
26755
  exports.API_METHODS = void 0;
26754
26756
  (function (API_METHODS) {
26755
26757
  API_METHODS["GET"] = "GET";
@@ -29522,12 +29524,11 @@ var alertDialog = observer(AlertDialog);
29522
29524
 
29523
29525
  const CustomCard = ({ children, sx, ...props }) => {
29524
29526
  return (jsxRuntime.jsx(material.Box, { ...props, sx: (theme) => {
29525
- const { spacing } = theme;
29527
+ const { spacing, shadows } = theme;
29526
29528
  return {
29527
- px: spacing(2),
29528
- py: spacing(2),
29529
- borderRadius: '10px',
29530
- boxShadow: '0px 8px 24px 0px rgba(0,0,0,0.3)',
29529
+ p: spacing(2),
29530
+ borderRadius: '12px',
29531
+ boxShadow: shadows,
29531
29532
  maxHeight: '85vh',
29532
29533
  maxWidth: '85vw',
29533
29534
  overflowX: 'auto',
@@ -39317,9 +39318,9 @@ const loggerService = new LoggerService();
39317
39318
 
39318
39319
  const tile_size = 256;
39319
39320
  const sourceUrl = {
39320
- [exports.TangramSourceNames.TILE]: `${"https://dalganmap.ru/api"}/tiles/get_tile/{z}/{x}/{y}.mvt`,
39321
- [exports.TangramSourceNames.NATURE_TILE]: `${"https://dalganmap.ru/api"}/tiles/get_nature_tile/{z}/{x}/{y}.mvt`,
39322
- [exports.TangramSourceNames.MSK]: `${"$VITE_API_HOST:$VITE_API_PORT"}/tiles/get_tile/{z}/{x}/{y}.mvt`,
39321
+ [exports.TangramSourceNames.TILE]: `${"$VITE_API_HOST/api"}/tiles/get_tile/{z}/{x}/{y}.mvt`,
39322
+ [exports.TangramSourceNames.NATURE_TILE]: `${"$VITE_API_HOST/api"}/tiles/get_nature_tile/{z}/{x}/{y}.mvt`,
39323
+ [exports.TangramSourceNames.MSK]: `${"$VITE_API_HOST/api"}/tiles/get_tile/{z}/{x}/{y}.mvt`,
39323
39324
  };
39324
39325
 
39325
39326
  var data = { global:{ links:{ getIsConstruction:"function (feature) {\n const { construction } = feature;\n\n return construction;\n}\n",
@@ -46794,37 +46795,39 @@ const AuthLayout = ({ children }) => {
46794
46795
  }, children: jsxRuntime.jsx(CustomCard, { children: children }) }) }));
46795
46796
  };
46796
46797
 
46797
- const schema = create$3().shape({
46798
- username: create$6().required(),
46799
- password: create$6().required(),
46800
- });
46798
+ const defaultValues = {
46799
+ username: '',
46800
+ password: '',
46801
+ };
46801
46802
 
46802
46803
  const r$1=(t,r,o)=>{if(t&&"reportValidity"in t){const s=get(o,r);t.setCustomValidity(s&&s.message||""),t.reportValidity();}},o$1=(e,t)=>{for(const o in t.fields){const s=t.fields[o];s&&s.ref&&"reportValidity"in s.ref?r$1(s.ref,o,e):s&&s.refs&&s.refs.forEach(t=>r$1(t,o,e));}},s=(r,s)=>{s.shouldUseNativeValidation&&o$1(r,s);const n={};for(const o in r){const f=get(s.fields,o),c=Object.assign(r[o]||{},{ref:f&&f.ref});if(i(s.names||Object.keys(r),o)){const r=Object.assign({},get(n,o));set(r,"root",c),set(n,o,r);}else set(n,o,c);}return n},i=(e,t)=>{const r=n(t);return e.some(e=>n(e).match(`^${r}\\.\\d+`))};function n(e){return e.replace(/\]|\[/g,"")}
46803
46804
 
46804
46805
  function o(o,n,s$1){return void 0===s$1&&(s$1={}),function(a,i,c){try{return Promise.resolve(function(t,r){try{var u=(null!=n&&n.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(o["sync"===s$1.mode?"validateSync":"validate"](a,Object.assign({abortEarly:!1},n,{context:i}))).then(function(t){return c.shouldUseNativeValidation&&o$1({},c),{values:s$1.raw?Object.assign({},a):t,errors:{}}}));}catch(e){return r(e)}return u&&u.then?u.then(void 0,r):u}(0,function(e){if(!e.inner)throw e;return {values:{},errors:s((o=e,n=!c.shouldUseNativeValidation&&"all"===c.criteriaMode,(o.inner||[]).reduce(function(e,t){if(e[t.path]||(e[t.path]={message:t.message,type:t.type}),n){var o=e[t.path].types,s=o&&o[t.type];e[t.path]=appendErrors(t.path,n,e,t.type,s?[].concat(s,t.message):t.message);}return e},{})),c)};var o,n;}))}catch(e){return Promise.reject(e)}}}
46805
46806
 
46806
- const AuthPage = ({ onSuccessSignIn }) => {
46807
- const logout = useLogout();
46807
+ const usernameSchema = getStringRequiredSchema();
46808
+ const passwordSchema = getStringRequiredSchema();
46809
+ const schema = create$3().shape({
46810
+ username: usernameSchema,
46811
+ password: passwordSchema,
46812
+ });
46813
+ const resolver = o(schema);
46814
+
46815
+ const AuthPage = ({ onSuccess, onError }) => {
46808
46816
  const signIn = useSignIn();
46809
46817
  const showSnackbar = useShowSnackbar();
46810
46818
  const form = useForm({
46811
- defaultValues: {
46812
- username: '',
46813
- password: '',
46814
- },
46815
- resolver: o(schema),
46819
+ defaultValues,
46820
+ resolver,
46816
46821
  });
46817
46822
  const { register, formState: { isValid }, } = form;
46818
- const onSubmit = (body) => {
46823
+ const onSubmit = React__namespace.useCallback((body) => {
46819
46824
  signIn.mutate({
46820
46825
  body,
46821
46826
  });
46822
- };
46823
- React__namespace.useEffect(() => {
46824
- logout.mutate();
46825
- }, []);
46827
+ }, [signIn]);
46826
46828
  React__namespace.useEffect(() => {
46827
46829
  if (signIn.error) {
46830
+ onError(signIn.error);
46828
46831
  const { response } = signIn.error;
46829
46832
  if (response) {
46830
46833
  const { data: { detail }, } = response;
@@ -46837,7 +46840,7 @@ const AuthPage = ({ onSuccessSignIn }) => {
46837
46840
  }, [signIn.error]);
46838
46841
  React__namespace.useEffect(() => {
46839
46842
  if (signIn.data) {
46840
- onSuccessSignIn(signIn.data);
46843
+ onSuccess(signIn.data);
46841
46844
  }
46842
46845
  }, [signIn.data]);
46843
46846
  return (jsxRuntime.jsx(AuthLayout, { children: jsxRuntime.jsxs(CustomForm, { form: form, onSubmit: onSubmit, sx: {
@@ -46845,7 +46848,7 @@ const AuthPage = ({ onSuccessSignIn }) => {
46845
46848
  justifyItems: 'center',
46846
46849
  alignContent: 'center',
46847
46850
  alignItems: 'center',
46848
- }, children: [jsxRuntime.jsx(material.Typography, { variant: "h4", children: "Authorization" }), jsxRuntime.jsx(CustomInput, { ...register('username'), label: "Login", placeholder: "Enter your login" }), jsxRuntime.jsx(CustomInput, { ...register('password'), label: "Password", placeholder: "Enter your password", type: "password" }), jsxRuntime.jsx(Button, { type: "submit", disabled: !isValid, children: "Sign in" })] }) }));
46851
+ }, children: [jsxRuntime.jsx(material.Typography, { variant: "h4", children: "\u0410\u0432\u0442\u043E\u0440\u0438\u0437\u0430\u0446\u0438\u044F" }), jsxRuntime.jsx(CustomInput, { ...register('username'), label: "\u041B\u043E\u0433\u0438\u043D", placeholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043B\u043E\u0433\u0438\u043D" }), jsxRuntime.jsx(CustomInput, { ...register('password'), label: "\u041F\u0430\u0440\u043E\u043B\u044C", placeholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043F\u0430\u0440\u043E\u043B\u044C", type: "password" }), jsxRuntime.jsx(Button, { type: "submit", disabled: !isValid, children: "\u0412\u043E\u0439\u0442\u0438" })] }) }));
46849
46852
  };
46850
46853
 
46851
46854
  // define() gets called for each chunk generated by the first Rollup pass.
@@ -48041,8 +48044,8 @@ exports.trafficSignsDop = trafficSignsDop;
48041
48044
  exports.useFormContext = useFormContext;
48042
48045
  exports.useGetLeafletLayer = useGetLeafletLayer;
48043
48046
  exports.useGetUser = useGetUser;
48044
- exports.useLogout = useLogout;
48045
48047
  exports.useShowErrorSnackbar = useShowErrorSnackbar;
48046
48048
  exports.useShowSnackbar = useShowSnackbar;
48047
48049
  exports.useSignIn = useSignIn;
48050
+ exports.useSignOut = useSignOut;
48048
48051
  //# sourceMappingURL=index.cjs.map