@piu-company/react-toolkit 1.0.2 → 1.0.4

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.
@@ -11,5 +11,7 @@ export interface IGMapInput extends GMapView {
11
11
  setMarkerPos: (pos: IMarkerPos) => void;
12
12
  error?: string;
13
13
  targetCardType?: TargetCardType;
14
+ /** ISO 3166-1 alpha-2 country code to restrict address autocomplete (e.g. 'mt', 'ua'). If omitted — global search. */
15
+ country?: string;
14
16
  }
15
17
  export declare const GMapInput: ({ setAddress, setMarkerPos, ...props }: IGMapInput) => import("react/jsx-runtime").JSX.Element;
@@ -28,6 +28,7 @@ export interface ITargetCard extends IOptionStyling {
28
28
  overflowY?: Overflow;
29
29
  target?: HTMLElement;
30
30
  forceDirection?: TargetCardDirection;
31
+ forceHorizontal?: 'left' | 'right';
31
32
  topOffset?: number;
32
33
  bottomOffset?: number;
33
34
  leftOffset?: number;
@@ -12,6 +12,7 @@ export interface ITimeField extends IField {
12
12
  startTime?: Moment;
13
13
  minSlotTime?: number;
14
14
  hidePast?: boolean;
15
+ forceHorizontal?: 'left' | 'right';
15
16
  }
16
17
  export declare const TimeField: {
17
18
  ({ value, iconNormal, iconFocus, width, label, error, helperText, placeholder, readOnly, ...props }: ITimeField): import("react/jsx-runtime").JSX.Element;
@@ -29,11 +29,11 @@ export interface ISidebarStyle {
29
29
  }
30
30
  export declare const Sidebar: import("react-redux").ConnectedComponent<({ nav, permissionCheck, collapsed, setCollapsed, forcePermissionCheck, ...props }: ISidebar & ISidebarState & ISidebarStoreActions & IFooter) => import("react/jsx-runtime").JSX.Element, {
31
31
  children: ReactNode;
32
- backgroundColor?: (string | Colors) | undefined;
33
32
  mobile?: boolean | undefined;
34
- location?: string | undefined;
35
33
  footer?: ReactNode;
36
34
  nav: INavType[];
35
+ backgroundColor?: (string | Colors) | undefined;
36
+ location?: string | undefined;
37
37
  activeColor?: (string | Colors) | undefined;
38
38
  logo?: ReactNode;
39
39
  favicon?: ReactNode;
@@ -28,7 +28,6 @@ export interface IDataContextInput {
28
28
  filter?: any;
29
29
  }
30
30
  export declare const DataProvider: import("react-redux").ConnectedComponent<({ id, userKey, setDirty, apiCall, forcedFilter, getTotal, dataLayer, setFilter, setPage, setSort, setLimit, setExternalFilter, setExternalPage, setExternalSort, setExternalLimit, pageStartFrom0, emptyFilterString, ...props }: IDataProvider) => import("react/jsx-runtime").JSX.Element, {
31
- apiCall?: APIFunctionHandler | undefined;
32
31
  children: ReactNode;
33
32
  sort?: Sort | undefined;
34
33
  filter?: any;
@@ -40,6 +39,7 @@ export declare const DataProvider: import("react-redux").ConnectedComponent<({ i
40
39
  setExternalSort?: SortHandler | undefined;
41
40
  page?: number | undefined;
42
41
  limit?: number | undefined;
42
+ apiCall?: APIFunctionHandler | undefined;
43
43
  getTotal?: TotalHandler | undefined;
44
44
  dirty?: boolean | undefined;
45
45
  setDirty?: DirtyHandler | undefined;
package/dist/index.cjs.js CHANGED
@@ -15421,7 +15421,7 @@ exports.TargetCardType = void 0;
15421
15421
  TargetCardType["timepicker"] = "timepicker";
15422
15422
  TargetCardType["profilebox"] = "profilebox";
15423
15423
  })(exports.TargetCardType || (exports.TargetCardType = {}));
15424
- const TargetCard = o.forwardRef(({ children, open, target, forceDirection, rightOffset, leftOffset, topOffset, bottomOffset, buttonHeight, buttonWidth, targetCardType, ...props }, ref) => {
15424
+ const TargetCard = o.forwardRef(({ children, open, target, forceDirection, forceHorizontal, rightOffset, leftOffset, topOffset, bottomOffset, buttonHeight, buttonWidth, targetCardType, ...props }, ref) => {
15425
15425
  const { browser } = o.useContext(NavigationContext);
15426
15426
  const [top, setTop] = o.useState();
15427
15427
  const [bottom, setBottom] = o.useState();
@@ -15606,6 +15606,14 @@ const TargetCard = o.forwardRef(({ children, open, target, forceDirection, right
15606
15606
  }
15607
15607
  }
15608
15608
  }
15609
+ if (size && forceHorizontal === 'right') {
15610
+ tempLeft = size.left;
15611
+ tempRight = null;
15612
+ }
15613
+ else if (size && forceHorizontal === 'left') {
15614
+ tempRight = window.innerWidth - size.right;
15615
+ tempLeft = null;
15616
+ }
15609
15617
  if (topOffset && tempTop) {
15610
15618
  tempTop = tempTop - topOffset;
15611
15619
  }
@@ -15631,7 +15639,8 @@ const TargetCard = o.forwardRef(({ children, open, target, forceDirection, right
15631
15639
  bottomOffset,
15632
15640
  leftOffset,
15633
15641
  rightOffset,
15634
- forceDirection
15642
+ forceDirection,
15643
+ forceHorizontal
15635
15644
  ]);
15636
15645
  useResize(updatePosition);
15637
15646
  o.useEffect(() => {
@@ -52794,7 +52803,19 @@ const GMapInput = ({ setAddress, setMarkerPos, ...props }) => {
52794
52803
  const googleContext = o.useContext(GoogleMapContext);
52795
52804
  const [lat, setLat] = o.useState(props.markerPos?.lat?.toString() || '');
52796
52805
  const [lng, setLng] = o.useState(props.markerPos?.lng?.toString() || '');
52806
+ const [defaultCenter, setDefaultCenter] = o.useState(undefined);
52797
52807
  const ref = o.useRef(null);
52808
+ o.useEffect(() => {
52809
+ if (!props.markerPos && navigator.geolocation) {
52810
+ navigator.geolocation.getCurrentPosition((pos) => {
52811
+ setDefaultCenter({
52812
+ lat: pos.coords.latitude,
52813
+ lng: pos.coords.longitude
52814
+ });
52815
+ }, () => { } // permission denied or unavailable — fall back to GMap default center
52816
+ );
52817
+ }
52818
+ }, []);
52798
52819
  const runGeoCode = o.useCallback(async (coords) => {
52799
52820
  if (window.google) {
52800
52821
  const service = new window.google.maps.Geocoder();
@@ -52900,10 +52921,13 @@ const GMapInput = ({ setAddress, setMarkerPos, ...props }) => {
52900
52921
  if (window.google) {
52901
52922
  const service = new window.google.maps.places.AutocompleteService();
52902
52923
  if (service && value) {
52903
- const result = await service.getPlacePredictions({
52904
- input: value,
52905
- componentRestrictions: { country: 'mt' }
52906
- });
52924
+ const request = {
52925
+ input: value
52926
+ };
52927
+ if (props.country) {
52928
+ request.componentRestrictions = { country: props.country };
52929
+ }
52930
+ const result = await service.getPlacePredictions(request);
52907
52931
  return result.predictions;
52908
52932
  }
52909
52933
  else {
@@ -52913,7 +52937,7 @@ const GMapInput = ({ setAddress, setMarkerPos, ...props }) => {
52913
52937
  else {
52914
52938
  return [];
52915
52939
  }
52916
- }, []);
52940
+ }, [props.country]);
52917
52941
  const autocompleteCall = o.useCallback(async (option) => {
52918
52942
  if (option !== null) {
52919
52943
  if (!Array.isArray(option)) {
@@ -52979,7 +53003,7 @@ const GMapInput = ({ setAddress, setMarkerPos, ...props }) => {
52979
53003
  };
52980
53004
  return option;
52981
53005
  });
52982
- }, label: "Address", footer: jsxRuntimeExports.jsx(Container, { padding: "5px", crossAxis: exports.Alignment.flexEnd, children: jsxRuntimeExports.jsx(Image, { src: img, width: 100, height: 30, alt: "googleMap", style: { objectFit: 'contain' } }) }), value: props.address, targetCardType: props.targetCardType })] })) : (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {})), jsxRuntimeExports.jsx(Spacer, {}), props.error ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(Typography, { variant: exports.TextVariants.small, color: exports.Colors.error, children: props.error }), jsxRuntimeExports.jsx(Spacer, {})] })) : (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {})), jsxRuntimeExports.jsx(GMap, { ...props, setMarkerPos: changeMarkerPosition })] })) : (jsxRuntimeExports.jsx(QuadSpinner, {}));
53006
+ }, label: "Address", footer: jsxRuntimeExports.jsx(Container, { padding: "5px", crossAxis: exports.Alignment.flexEnd, children: jsxRuntimeExports.jsx(Image, { src: img, width: 100, height: 30, alt: "googleMap", style: { objectFit: 'contain' } }) }), value: props.address, targetCardType: props.targetCardType })] })) : (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {})), jsxRuntimeExports.jsx(Spacer, {}), props.error ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(Typography, { variant: exports.TextVariants.small, color: exports.Colors.error, children: props.error }), jsxRuntimeExports.jsx(Spacer, {})] })) : (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {})), jsxRuntimeExports.jsx(GMap, { ...props, center: defaultCenter || props.center, setMarkerPos: changeMarkerPosition })] })) : (jsxRuntimeExports.jsx(QuadSpinner, {}));
52983
53007
  };
52984
53008
 
52985
53009
  const GoogleMapProvider = (props) => {
package/dist/index.esm.js CHANGED
@@ -15401,7 +15401,7 @@ var TargetCardType;
15401
15401
  TargetCardType["timepicker"] = "timepicker";
15402
15402
  TargetCardType["profilebox"] = "profilebox";
15403
15403
  })(TargetCardType || (TargetCardType = {}));
15404
- const TargetCard = forwardRef(({ children, open, target, forceDirection, rightOffset, leftOffset, topOffset, bottomOffset, buttonHeight, buttonWidth, targetCardType, ...props }, ref) => {
15404
+ const TargetCard = forwardRef(({ children, open, target, forceDirection, forceHorizontal, rightOffset, leftOffset, topOffset, bottomOffset, buttonHeight, buttonWidth, targetCardType, ...props }, ref) => {
15405
15405
  const { browser } = useContext(NavigationContext);
15406
15406
  const [top, setTop] = useState();
15407
15407
  const [bottom, setBottom] = useState();
@@ -15586,6 +15586,14 @@ const TargetCard = forwardRef(({ children, open, target, forceDirection, rightOf
15586
15586
  }
15587
15587
  }
15588
15588
  }
15589
+ if (size && forceHorizontal === 'right') {
15590
+ tempLeft = size.left;
15591
+ tempRight = null;
15592
+ }
15593
+ else if (size && forceHorizontal === 'left') {
15594
+ tempRight = window.innerWidth - size.right;
15595
+ tempLeft = null;
15596
+ }
15589
15597
  if (topOffset && tempTop) {
15590
15598
  tempTop = tempTop - topOffset;
15591
15599
  }
@@ -15611,7 +15619,8 @@ const TargetCard = forwardRef(({ children, open, target, forceDirection, rightOf
15611
15619
  bottomOffset,
15612
15620
  leftOffset,
15613
15621
  rightOffset,
15614
- forceDirection
15622
+ forceDirection,
15623
+ forceHorizontal
15615
15624
  ]);
15616
15625
  useResize(updatePosition);
15617
15626
  useEffect(() => {
@@ -52774,7 +52783,19 @@ const GMapInput = ({ setAddress, setMarkerPos, ...props }) => {
52774
52783
  const googleContext = useContext(GoogleMapContext);
52775
52784
  const [lat, setLat] = useState(props.markerPos?.lat?.toString() || '');
52776
52785
  const [lng, setLng] = useState(props.markerPos?.lng?.toString() || '');
52786
+ const [defaultCenter, setDefaultCenter] = useState(undefined);
52777
52787
  const ref = useRef(null);
52788
+ useEffect(() => {
52789
+ if (!props.markerPos && navigator.geolocation) {
52790
+ navigator.geolocation.getCurrentPosition((pos) => {
52791
+ setDefaultCenter({
52792
+ lat: pos.coords.latitude,
52793
+ lng: pos.coords.longitude
52794
+ });
52795
+ }, () => { } // permission denied or unavailable — fall back to GMap default center
52796
+ );
52797
+ }
52798
+ }, []);
52778
52799
  const runGeoCode = useCallback(async (coords) => {
52779
52800
  if (window.google) {
52780
52801
  const service = new window.google.maps.Geocoder();
@@ -52880,10 +52901,13 @@ const GMapInput = ({ setAddress, setMarkerPos, ...props }) => {
52880
52901
  if (window.google) {
52881
52902
  const service = new window.google.maps.places.AutocompleteService();
52882
52903
  if (service && value) {
52883
- const result = await service.getPlacePredictions({
52884
- input: value,
52885
- componentRestrictions: { country: 'mt' }
52886
- });
52904
+ const request = {
52905
+ input: value
52906
+ };
52907
+ if (props.country) {
52908
+ request.componentRestrictions = { country: props.country };
52909
+ }
52910
+ const result = await service.getPlacePredictions(request);
52887
52911
  return result.predictions;
52888
52912
  }
52889
52913
  else {
@@ -52893,7 +52917,7 @@ const GMapInput = ({ setAddress, setMarkerPos, ...props }) => {
52893
52917
  else {
52894
52918
  return [];
52895
52919
  }
52896
- }, []);
52920
+ }, [props.country]);
52897
52921
  const autocompleteCall = useCallback(async (option) => {
52898
52922
  if (option !== null) {
52899
52923
  if (!Array.isArray(option)) {
@@ -52959,7 +52983,7 @@ const GMapInput = ({ setAddress, setMarkerPos, ...props }) => {
52959
52983
  };
52960
52984
  return option;
52961
52985
  });
52962
- }, label: "Address", footer: jsxRuntimeExports.jsx(Container, { padding: "5px", crossAxis: Alignment.flexEnd, children: jsxRuntimeExports.jsx(Image, { src: img, width: 100, height: 30, alt: "googleMap", style: { objectFit: 'contain' } }) }), value: props.address, targetCardType: props.targetCardType })] })) : (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {})), jsxRuntimeExports.jsx(Spacer, {}), props.error ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(Typography, { variant: TextVariants.small, color: Colors.error, children: props.error }), jsxRuntimeExports.jsx(Spacer, {})] })) : (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {})), jsxRuntimeExports.jsx(GMap, { ...props, setMarkerPos: changeMarkerPosition })] })) : (jsxRuntimeExports.jsx(QuadSpinner, {}));
52986
+ }, label: "Address", footer: jsxRuntimeExports.jsx(Container, { padding: "5px", crossAxis: Alignment.flexEnd, children: jsxRuntimeExports.jsx(Image, { src: img, width: 100, height: 30, alt: "googleMap", style: { objectFit: 'contain' } }) }), value: props.address, targetCardType: props.targetCardType })] })) : (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {})), jsxRuntimeExports.jsx(Spacer, {}), props.error ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(Typography, { variant: TextVariants.small, color: Colors.error, children: props.error }), jsxRuntimeExports.jsx(Spacer, {})] })) : (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {})), jsxRuntimeExports.jsx(GMap, { ...props, center: defaultCenter || props.center, setMarkerPos: changeMarkerPosition })] })) : (jsxRuntimeExports.jsx(QuadSpinner, {}));
52963
52987
  };
52964
52988
 
52965
52989
  const GoogleMapProvider = (props) => {