npm-pkg-hook 1.0.0 → 1.0.2

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 (47) hide show
  1. package/.babelrc +14 -0
  2. package/.eslintrc.json +108 -0
  3. package/.github/pull_request_template.md +18 -0
  4. package/.github/workflows/pepeline.yaml +30 -0
  5. package/README.md +1 -0
  6. package/jsconfig.json +28 -0
  7. package/next.config.js +129 -0
  8. package/package.json +33 -3
  9. package/src/cookies/index.ts +3 -0
  10. package/src/hooks/index.js +19 -0
  11. package/src/hooks/useAcumulateDate/index.js +16 -0
  12. package/src/hooks/useAnimationText/index.jsx +30 -0
  13. package/src/hooks/useCategoryStore/index.js +7 -0
  14. package/src/hooks/useCategoryStore/queries.js +16 -0
  15. package/src/hooks/useCheckbox/index.js +114 -0
  16. package/src/hooks/useClients/index.js +13 -0
  17. package/src/hooks/useClients/queries.js +118 -0
  18. package/src/hooks/useDrag/index.js +57 -0
  19. package/src/hooks/useEvent/index.js +33 -0
  20. package/src/hooks/useFetchJson/index.js +25 -0
  21. package/src/hooks/useFetchMoreInteractions/index.jsx +35 -0
  22. package/src/hooks/useFormTools/index.js +71 -0
  23. package/src/hooks/useFullScreenMode/index.js +66 -0
  24. package/src/hooks/useGetCategorieStore/index.js +21 -0
  25. package/src/hooks/useGetCategorieStore/queries.js +78 -0
  26. package/src/hooks/useGetProductsFood/index.js +46 -0
  27. package/src/hooks/useGetProductsFood/queriesStore.js +766 -0
  28. package/src/hooks/useHover/index.js +29 -0
  29. package/src/hooks/useInnerHtml/index.js +38 -0
  30. package/src/hooks/useIntersection/index.js +31 -0
  31. package/src/hooks/useKeypress/index.js +28 -0
  32. package/src/hooks/useLocalSorage/index.js +36 -0
  33. package/src/hooks/useLocationNavigate/index.js +54 -0
  34. package/src/hooks/useMobile/index.js +38 -0
  35. package/src/hooks/useRestaurant/index.js +19 -0
  36. package/src/hooks/useRestaurant/queries.js +70 -0
  37. package/src/hooks/useSales/index.js +489 -0
  38. package/src/hooks/useSales/queries.js +230 -0
  39. package/src/hooks/useSetState/index.js +24 -0
  40. package/src/hooks/useStore/index.js +18 -0
  41. package/src/hooks/useStore/queries.js +136 -0
  42. package/src/hooks/useTimeAgo/useTimeAgo.js +39 -0
  43. package/src/hooks/useUpdateCart/index.js +124 -0
  44. package/src/hooks/useUser/index.js +3 -0
  45. package/src/hooks/useWindowSize/index.js +38 -0
  46. package/src/index.jsx +1 -6
  47. package/src/utils/index.js +54 -0
@@ -0,0 +1,29 @@
1
+ import { useRef, useState, useEffect } from 'react'
2
+
3
+ export default function useHover() {
4
+ const [value, setValue] = useState(false)
5
+
6
+ const ref = useRef(null)
7
+
8
+ const handleMouseOver = () => {return setValue(true)}
9
+ const handleMouseOut = () => {return setValue(false)}
10
+
11
+ useEffect(
12
+ () => {
13
+ const node = ref.current
14
+ if (node) {
15
+ node.addEventListener('mouseover', handleMouseOver)
16
+ node.addEventListener('mouseout', handleMouseOut)
17
+
18
+ return () => {
19
+ node.removeEventListener('mouseover', handleMouseOver)
20
+ node.removeEventListener('mouseout', handleMouseOut)
21
+ }
22
+ }
23
+ return {}
24
+ },
25
+ [] // Recall only if ref changes
26
+ )
27
+
28
+ return [ref, value]
29
+ }
@@ -0,0 +1,38 @@
1
+ import React from 'react'
2
+ import { render } from 'react-dom'
3
+ import './styles.css'
4
+
5
+ const htmlText =
6
+ '<p style=\'display:inline;\'>Lorem ipsum</p> dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.'
7
+
8
+ function App() {
9
+ const [state, setState] = React.useState({
10
+ showOriginalHTML: false,
11
+ originalHTML: htmlText
12
+ })
13
+
14
+ const handleShowText = React.useCallback(() => {
15
+ setState(prevState => {return {
16
+ ...prevState,
17
+ showOriginalHTML: !prevState.showOriginalHTML
18
+ }})
19
+ }, [setState])
20
+
21
+ return (
22
+ <div className='container'>
23
+ <div
24
+ className='text'
25
+ dangerouslySetInnerHTML={{
26
+ __html: `${
27
+ state.originalHTML
28
+ }`
29
+ }}
30
+ />
31
+ <button className='read-more' onClick={handleShowText}>
32
+ {!state.showOriginalHTML ? 'read more' : 'show less'}
33
+ </button>
34
+ </div>
35
+ )
36
+ }
37
+
38
+ render(<App />, document.getElementById('root'))
@@ -0,0 +1,31 @@
1
+ import { useEffect, useState } from 'react'
2
+
3
+ export const useOnScreen = (threshold = 0.6) => {
4
+ const [isVisible, setIsVisible] = useState(false)
5
+ const [ref, setRef] = useState(null)
6
+
7
+ useEffect(
8
+ () => {
9
+ let observer
10
+ if (ref) {
11
+ observer = new IntersectionObserver(
12
+ ([entry]) => {
13
+ setIsVisible(entry.isIntersecting)
14
+ },
15
+ {
16
+ // rootMargin,
17
+ threshold
18
+ }
19
+ )
20
+ observer.observe(ref)
21
+ }
22
+
23
+ return () => {
24
+ if (ref && observer) observer.unobserve(ref)
25
+ }
26
+ },
27
+ [ref]
28
+ )
29
+
30
+ return [setRef, isVisible]
31
+ }
@@ -0,0 +1,28 @@
1
+ import { useEffect, useState } from 'react'
2
+
3
+ export const useKeyPress = (targetKey) => {
4
+ const [keyPressed, setKeyPressed] = useState(false)
5
+
6
+ useEffect(() => {
7
+ const downHandler = ({ key }) => {
8
+ if (key === targetKey) {
9
+ setKeyPressed(true)
10
+ }
11
+ }
12
+ const upHandler = ({ key }) => {
13
+ if (key === targetKey) {
14
+ setKeyPressed(false)
15
+ }
16
+ }
17
+
18
+ window.addEventListener('keydown', downHandler)
19
+ window.addEventListener('keyup', upHandler)
20
+
21
+ return () => {
22
+ window.removeEventListener('keydown', downHandler)
23
+ window.removeEventListener('keyup', upHandler)
24
+ }
25
+ }, [targetKey])
26
+
27
+ return keyPressed
28
+ }
@@ -0,0 +1,36 @@
1
+ import { useState } from 'react'
2
+
3
+ export default function useLocalStorage(key, initialValue) {
4
+ // const { setAlertBox } = useContext(Context)
5
+ // State to store our value
6
+ // Pass initial state function to useState so logic is only executed once
7
+ const [storedValue, setStoredValue] = useState(() => {
8
+ try {
9
+ // Get from local storage by key
10
+ const item = window.localStorage.getItem(key)
11
+ // Parse stored json or if none return initialValue
12
+ return item ? JSON.parse(item) : initialValue
13
+ } catch (error) {
14
+ // If error also return initialValue
15
+ return initialValue
16
+ }
17
+ })
18
+
19
+ // Return a wrapped version of useState's setter function that ...
20
+ // ... persists the new value to localStorage.
21
+ const setValue = value => {
22
+ try {
23
+ // Allow value to be a function so we have same API as useState
24
+ const valueToStore =
25
+ value instanceof Function ? value(storedValue) : value
26
+ // Save state
27
+ setStoredValue(valueToStore)
28
+ // Save to local storage
29
+ window.localStorage.setItem(key, JSON.stringify(valueToStore))
30
+ } catch (error) {
31
+ // A more advanced implementation would handle the error case
32
+ }
33
+ }
34
+
35
+ return [storedValue, setValue]
36
+ }
@@ -0,0 +1,54 @@
1
+ import { useState, useEffect } from 'react'
2
+
3
+ const defaultSettings = {
4
+ enableHighAccuracy: false,
5
+ timeout: Infinity,
6
+ maximumAge: 0
7
+ }
8
+
9
+ export const usePosition = (watch = false, settings = defaultSettings) => {
10
+ const [position, setPosition] = useState({})
11
+ const [error, setError] = useState(null)
12
+
13
+ const onChange = ({ coords, timestamp }) => {
14
+ setPosition({
15
+ latitude: coords.latitude,
16
+ longitude: coords.longitude,
17
+ accuracy: coords.accuracy,
18
+ speed: coords.speed,
19
+ timestamp
20
+ })
21
+ }
22
+
23
+ const onError = () => {
24
+ setError(error?.message)
25
+ }
26
+
27
+ useEffect(() => {
28
+ if (!navigator || !navigator.geolocation) {
29
+ setError('Geolocation is not supported')
30
+ return
31
+ }
32
+
33
+ let watcher = null
34
+ if (watch) {
35
+ watcher = navigator.geolocation.watchPosition(
36
+ onChange,
37
+ onError,
38
+ settings
39
+ )
40
+ } else {
41
+ navigator.geolocation.getCurrentPosition(onChange, onError, settings)
42
+ }
43
+
44
+ return () => { return watcher && navigator.geolocation.clearWatch(watcher) }
45
+ }, [
46
+ settings,
47
+ settings.enableHighAccuracy,
48
+ settings.timeout,
49
+ settings.maximumAge,
50
+ watch
51
+ ])
52
+
53
+ return { ...position, error }
54
+ }
@@ -0,0 +1,38 @@
1
+ import { useEffect, useState } from 'react'
2
+
3
+ export const useMobile = (props) => {
4
+ const { callBack = () => { return null; } } = props || {};
5
+ const [innerHeight, setInnerHeight] = useState();
6
+ const [innerWidth, setInnerWidth] = useState();
7
+ let isMobile = false;
8
+ useEffect(() => {
9
+ setInnerHeight(window.innerHeight);
10
+ setInnerWidth(window.innerWidth);
11
+ callBack();
12
+ }, []);
13
+ useEffect(() => {
14
+ const handleResize = () => {
15
+ if (!isNaN(window === null || window === void 0 ? void 0 : window.innerHeight) && (window === null || window === void 0 ? void 0 : window.innerHeight) != innerHeight) {
16
+ setInnerHeight(window.innerHeight);
17
+ }
18
+ if (!isNaN(window.innerWidth) && window.innerWidth != innerWidth) {
19
+ setInnerWidth(window.innerWidth);
20
+ }
21
+ callBack();
22
+ };
23
+ if (typeof window !== 'undefined') {
24
+ window.addEventListener('resize', handleResize);
25
+ }
26
+ return () => {
27
+ window.removeEventListener('resize', handleResize);
28
+ };
29
+ });
30
+ if (typeof window !== 'undefined' && /Mobile/i.test((navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) || (navigator === null || navigator === void 0 ? void 0 : navigator.vendor))) {
31
+ isMobile = true;
32
+ }
33
+ return {
34
+ isMobile,
35
+ innerHeight,
36
+ innerWidth
37
+ };
38
+ };
@@ -0,0 +1,19 @@
1
+ import { useQuery } from '@apollo/client'
2
+ import { GET_ALL_RESTAURANT } from './queries'
3
+
4
+ export const useRestaurant = () => {
5
+ const {
6
+ data,
7
+ loading,
8
+ error,
9
+ fetchMore
10
+ } = useQuery(GET_ALL_RESTAURANT, {
11
+ fetchPolicy: 'cache-and-network',
12
+ notifyOnNetworkStatusChange: true,
13
+ nextFetchPolicy: 'cache-first',
14
+ refetchWritePolicy: 'merge',
15
+ context: { clientName: 'admin-store'
16
+ }
17
+ })
18
+ return [data, { loading, error, fetchMore }]
19
+ }
@@ -0,0 +1,70 @@
1
+ import { gql } from '@apollo/client'
2
+ export const GET_ALL_RESTAURANT = gql`
3
+ query getAllStoreInStore($search: String, $min: Int, $max: Int){
4
+ getAllStoreInStore(search: $search, min: $min, max: $max) {
5
+ idStore
6
+ cId
7
+ id
8
+ dId
9
+ ctId
10
+ catStore
11
+ neighborhoodStore
12
+ Viaprincipal
13
+ storeOwner
14
+ storeName
15
+ cateStore{
16
+ catStore
17
+ cName
18
+ }
19
+ emailStore
20
+ storePhone
21
+ socialRaz
22
+ Image
23
+ banner
24
+ documentIdentifier
25
+ uPhoNum
26
+ ULocation
27
+ upLat
28
+ upLon
29
+ uState
30
+ siteWeb
31
+ description
32
+ NitStore
33
+ typeRegiments
34
+ typeContribute
35
+ secVia
36
+ addressStore
37
+ createdAt
38
+ pais{
39
+ cId
40
+ cName
41
+ cCalCod
42
+ cState
43
+ cDatCre
44
+ cDatMod
45
+ }
46
+ city {
47
+ ctId
48
+ dId
49
+ cName
50
+ cState
51
+ cDatCre
52
+ cDatMod
53
+ }
54
+ department {
55
+ dId
56
+ cId
57
+ dName
58
+ dState
59
+ dDatCre
60
+ dDatMod
61
+ }
62
+ getAllRatingStar {
63
+ rSId
64
+ rScore
65
+ idStore
66
+ createAt
67
+ }
68
+ }
69
+ }
70
+ `