Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
search-page
Commits
409c94b4
Commit
409c94b4
authored
Jan 06, 2021
by
baesangjune
Browse files
rm node_modules
parent
df52aea8
Changes
741
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
741 of 741+
files are displayed.
Plain diff
Email patch
node_modules/@restart/hooks/esm/useCommittedRef.d.ts
deleted
100644 → 0
View file @
df52aea8
/// <reference types="react" />
/**
* Creates a `Ref` whose value is updated in an effect, ensuring the most recent
* value is the one rendered with. Generally only required for Concurrent mode usage
* where previous work in `render()` may be discarded befor being used.
*
* This is safe to access in an event handler.
*
* @param value The `Ref` value
*/
declare
function
useCommittedRef
<
TValue
>
(
value
:
TValue
):
React
.
MutableRefObject
<
TValue
>
;
export
default
useCommittedRef
;
node_modules/@restart/hooks/esm/useCommittedRef.js
deleted
100644 → 0
View file @
df52aea8
import
{
useEffect
,
useRef
}
from
'
react
'
;
/**
* Creates a `Ref` whose value is updated in an effect, ensuring the most recent
* value is the one rendered with. Generally only required for Concurrent mode usage
* where previous work in `render()` may be discarded befor being used.
*
* This is safe to access in an event handler.
*
* @param value The `Ref` value
*/
function
useCommittedRef
(
value
)
{
var
ref
=
useRef
(
value
);
useEffect
(
function
()
{
ref
.
current
=
value
;
},
[
value
]);
return
ref
;
}
export
default
useCommittedRef
;
\ No newline at end of file
node_modules/@restart/hooks/esm/useCustomEffect.d.ts
deleted
100644 → 0
View file @
df52aea8
import
{
DependencyList
,
EffectCallback
}
from
'
react
'
;
export
declare
type
EffectHook
=
(
effect
:
EffectCallback
,
deps
?:
DependencyList
)
=>
void
;
export
declare
type
IsEqual
<
TDeps
extends
DependencyList
>
=
(
nextDeps
:
TDeps
,
prevDeps
:
TDeps
)
=>
boolean
;
export
declare
type
CustomEffectOptions
<
TDeps
extends
DependencyList
>
=
{
isEqual
:
IsEqual
<
TDeps
>
;
effectHook
?:
EffectHook
;
};
/**
* a useEffect() hook with customized depedency comparision
*
* @param effect The effect callback
* @param dependencies A list of dependencies
* @param isEqual A function comparing the next and previous dependencyLists
*/
declare
function
useCustomEffect
<
TDeps
extends
DependencyList
=
DependencyList
>
(
effect
:
EffectCallback
,
dependencies
:
TDeps
,
isEqual
:
IsEqual
<
TDeps
>
):
void
;
/**
* a useEffect() hook with customized depedency comparision
*
* @param effect The effect callback
* @param dependencies A list of dependencies
* @param options
* @param options.isEqual A function comparing the next and previous dependencyLists
* @param options.effectHook the underlying effect hook used, defaults to useEffect
*/
declare
function
useCustomEffect
<
TDeps
extends
DependencyList
=
DependencyList
>
(
effect
:
EffectCallback
,
dependencies
:
TDeps
,
options
:
CustomEffectOptions
<
TDeps
>
):
void
;
export
default
useCustomEffect
;
node_modules/@restart/hooks/esm/useCustomEffect.js
deleted
100644 → 0
View file @
df52aea8
import
{
useRef
,
useEffect
,
useDebugValue
}
from
'
react
'
;
import
useMounted
from
'
./useMounted
'
;
function
useCustomEffect
(
effect
,
dependencies
,
isEqualOrOptions
)
{
var
isMounted
=
useMounted
();
var
_ref
=
typeof
isEqualOrOptions
===
'
function
'
?
{
isEqual
:
isEqualOrOptions
}
:
isEqualOrOptions
,
isEqual
=
_ref
.
isEqual
,
_ref$effectHook
=
_ref
.
effectHook
,
effectHook
=
_ref$effectHook
===
void
0
?
useEffect
:
_ref$effectHook
;
var
dependenciesRef
=
useRef
();
dependenciesRef
.
current
=
dependencies
;
var
cleanupRef
=
useRef
(
null
);
effectHook
(
function
()
{
// If the ref the is `null` it's either the first effect or the last effect
// ran and was cleared, meaning _this_ update should run, b/c the equality
// check failed on in the cleanup of the last effect.
if
(
cleanupRef
.
current
===
null
)
{
var
cleanup
=
effect
();
cleanupRef
.
current
=
function
()
{
if
(
isMounted
()
&&
isEqual
(
dependenciesRef
.
current
,
dependencies
))
{
return
;
}
cleanupRef
.
current
=
null
;
if
(
cleanup
)
cleanup
();
};
}
return
cleanupRef
.
current
;
});
useDebugValue
(
effect
);
}
export
default
useCustomEffect
;
\ No newline at end of file
node_modules/@restart/hooks/esm/useEventCallback.d.ts
deleted
100644 → 0
View file @
df52aea8
export
default
function
useEventCallback
<
TCallback
extends
(...
args
:
any
[])
=>
any
>
(
fn
?:
TCallback
|
null
):
TCallback
;
node_modules/@restart/hooks/esm/useEventCallback.js
deleted
100644 → 0
View file @
df52aea8
import
{
useCallback
}
from
'
react
'
;
import
useCommittedRef
from
'
./useCommittedRef
'
;
export
default
function
useEventCallback
(
fn
)
{
var
ref
=
useCommittedRef
(
fn
);
return
useCallback
(
function
()
{
return
ref
.
current
&&
ref
.
current
.
apply
(
ref
,
arguments
);
},
[
ref
]);
}
\ No newline at end of file
node_modules/@restart/hooks/esm/useEventListener.d.ts
deleted
100644 → 0
View file @
df52aea8
declare
type
EventHandler
<
T
,
K
extends
keyof
DocumentEventMap
>
=
(
this
:
T
,
ev
:
DocumentEventMap
[
K
])
=>
any
;
/**
* Attaches an event handler outside directly to specified DOM element
* bypassing the react synthetic event system.
*
* @param element The target to listen for events on
* @param event The DOM event name
* @param handler An event handler
* @param capture Whether or not to listen during the capture event phase
*/
export
default
function
useEventListener
<
T
extends
Element
|
Document
|
Window
,
K
extends
keyof
DocumentEventMap
>
(
eventTarget
:
T
|
(()
=>
T
),
event
:
K
,
listener
:
EventHandler
<
T
,
K
>
,
capture
?:
boolean
|
AddEventListenerOptions
):
void
;
export
{};
node_modules/@restart/hooks/esm/useEventListener.js
deleted
100644 → 0
View file @
df52aea8
import
{
useEffect
}
from
'
react
'
;
import
useEventCallback
from
'
./useEventCallback
'
;
/**
* Attaches an event handler outside directly to specified DOM element
* bypassing the react synthetic event system.
*
* @param element The target to listen for events on
* @param event The DOM event name
* @param handler An event handler
* @param capture Whether or not to listen during the capture event phase
*/
export
default
function
useEventListener
(
eventTarget
,
event
,
listener
,
capture
)
{
if
(
capture
===
void
0
)
{
capture
=
false
;
}
var
handler
=
useEventCallback
(
listener
);
useEffect
(
function
()
{
var
target
=
typeof
eventTarget
===
'
function
'
?
eventTarget
()
:
eventTarget
;
target
.
addEventListener
(
event
,
handler
,
capture
);
return
function
()
{
return
target
.
removeEventListener
(
event
,
handler
,
capture
);
};
},
[
eventTarget
]);
}
\ No newline at end of file
node_modules/@restart/hooks/esm/useFocusManager.d.ts
deleted
100644 → 0
View file @
df52aea8
/// <reference types="react" />
export
interface
FocusManagerOptions
{
/**
* A callback fired when focus shifts. returning `false` will prevent
* handling the focus event
*/
willHandle
?(
focused
:
boolean
,
event
:
React
.
FocusEvent
):
boolean
|
void
;
/**
* A callback fired after focus is handled but before onChange is called
*/
didHandle
?(
focused
:
boolean
,
event
:
React
.
FocusEvent
):
void
;
/**
* A callback fired after focus has changed
*/
onChange
?(
focused
:
boolean
,
event
:
React
.
FocusEvent
):
void
;
/**
* When true, the event handlers will not report focus changes
*/
isDisabled
:
()
=>
boolean
;
}
export
interface
FocusController
{
onBlur
:
(
event
:
any
)
=>
void
;
onFocus
:
(
event
:
any
)
=>
void
;
}
/**
* useFocusManager provides a way to track and manage focus as it moves around
* a container element. An `onChange` is fired when focus enters or leaves the
* element, but not when it moves around inside the element, similar to
* `pointerenter` and `pointerleave` DOM events.
*
* ```tsx
* const [focused, setFocusState] = useState(false)
*
* const { onBlur, onFocus } = useFocusManager({
* onChange: nextFocused => setFocusState(nextFocused)
* })
*
* return (
* <div tabIndex="-1" onFocus={onFocus} onBlur={onBlur}>
* {String(focused)}
* <input />
* <input />
*
* <button>A button</button>
* </div>
* ```
*
*/
export
default
function
useFocusManager
(
opts
:
FocusManagerOptions
):
FocusController
;
node_modules/@restart/hooks/esm/useFocusManager.js
deleted
100644 → 0
View file @
df52aea8
import
{
useCallback
,
useRef
}
from
'
react
'
;
import
useEventCallback
from
'
./useEventCallback
'
;
import
useMounted
from
'
./useMounted
'
;
/**
* useFocusManager provides a way to track and manage focus as it moves around
* a container element. An `onChange` is fired when focus enters or leaves the
* element, but not when it moves around inside the element, similar to
* `pointerenter` and `pointerleave` DOM events.
*
* ```tsx
* const [focused, setFocusState] = useState(false)
*
* const { onBlur, onFocus } = useFocusManager({
* onChange: nextFocused => setFocusState(nextFocused)
* })
*
* return (
* <div tabIndex="-1" onFocus={onFocus} onBlur={onBlur}>
* {String(focused)}
* <input />
* <input />
*
* <button>A button</button>
* </div>
* ```
*
*/
export
default
function
useFocusManager
(
opts
)
{
var
isMounted
=
useMounted
();
var
lastFocused
=
useRef
();
var
handle
=
useRef
();
var
willHandle
=
useEventCallback
(
opts
.
willHandle
);
var
didHandle
=
useEventCallback
(
opts
.
didHandle
);
var
onChange
=
useEventCallback
(
opts
.
onChange
);
var
isDisabled
=
useEventCallback
(
opts
.
isDisabled
);
var
handleFocusChange
=
useCallback
(
function
(
focused
,
event
)
{
if
(
event
&&
event
.
persist
)
event
.
persist
();
if
(
willHandle
&&
willHandle
(
focused
,
event
)
===
false
)
return
;
clearTimeout
(
handle
.
current
);
handle
.
current
=
setTimeout
(
function
()
{
if
(
focused
!==
lastFocused
.
current
)
{
if
(
didHandle
)
didHandle
(
focused
,
event
);
// only fire a change when unmounted if its a blur
if
(
isMounted
()
||
!
focused
)
{
lastFocused
.
current
=
focused
;
onChange
&&
onChange
(
focused
,
event
);
}
}
});
},
[
isMounted
,
willHandle
,
didHandle
,
onChange
,
lastFocused
]);
var
handleBlur
=
useCallback
(
function
(
event
)
{
if
(
!
isDisabled
())
handleFocusChange
(
false
,
event
);
},
[
handleFocusChange
,
isDisabled
]);
var
handleFocus
=
useCallback
(
function
(
event
)
{
if
(
!
isDisabled
())
handleFocusChange
(
true
,
event
);
},
[
handleFocusChange
,
isDisabled
]);
return
{
onBlur
:
handleBlur
,
onFocus
:
handleFocus
};
}
\ No newline at end of file
node_modules/@restart/hooks/esm/useForceUpdate.d.ts
deleted
100644 → 0
View file @
df52aea8
/**
* Returns a function that triggers a component update. the hook equivalent to
* `this.forceUpdate()` in a class component. In most cases using a state value directly
* is preferable but may be required in some advanced usages of refs for interop or
* when direct DOM manipulation is required.
*
* ```ts
* const forceUpdate = useForceUpdate();
*
* const updateOnClick = useCallback(() => {
* forceUpdate()
* }, [forceUpdate])
*
* return <button type="button" onClick={updateOnClick}>Hi there</button>
* ```
*/
export
default
function
useForceUpdate
():
()
=>
void
;
node_modules/@restart/hooks/esm/useForceUpdate.js
deleted
100644 → 0
View file @
df52aea8
import
{
useReducer
}
from
'
react
'
;
/**
* Returns a function that triggers a component update. the hook equivalent to
* `this.forceUpdate()` in a class component. In most cases using a state value directly
* is preferable but may be required in some advanced usages of refs for interop or
* when direct DOM manipulation is required.
*
* ```ts
* const forceUpdate = useForceUpdate();
*
* const updateOnClick = useCallback(() => {
* forceUpdate()
* }, [forceUpdate])
*
* return <button type="button" onClick={updateOnClick}>Hi there</button>
* ```
*/
export
default
function
useForceUpdate
()
{
// The toggling state value is designed to defeat React optimizations for skipping
// updates when they are stricting equal to the last state value
var
_useReducer
=
useReducer
(
function
(
state
)
{
return
!
state
;
},
false
),
dispatch
=
_useReducer
[
1
];
return
dispatch
;
}
\ No newline at end of file
node_modules/@restart/hooks/esm/useGlobalListener.d.ts
deleted
100644 → 0
View file @
df52aea8
declare
type
DocumentEventHandler
<
K
extends
keyof
DocumentEventMap
>
=
(
this
:
Document
,
ev
:
DocumentEventMap
[
K
])
=>
any
;
/**
* Attaches an event handler outside directly to the `document`,
* bypassing the react synthetic event system.
*
* ```ts
* useGlobalListener('keydown', (event) => {
* console.log(event.key)
* })
* ```
*
* @param event The DOM event name
* @param handler An event handler
* @param capture Whether or not to listen during the capture event phase
*/
export
default
function
useGlobalListener
<
K
extends
keyof
DocumentEventMap
>
(
event
:
K
,
handler
:
DocumentEventHandler
<
K
>
,
capture
?:
boolean
|
AddEventListenerOptions
):
void
;
export
{};
node_modules/@restart/hooks/esm/useGlobalListener.js
deleted
100644 → 0
View file @
df52aea8
import
useEventListener
from
'
./useEventListener
'
;
import
{
useCallback
}
from
'
react
'
;
/**
* Attaches an event handler outside directly to the `document`,
* bypassing the react synthetic event system.
*
* ```ts
* useGlobalListener('keydown', (event) => {
* console.log(event.key)
* })
* ```
*
* @param event The DOM event name
* @param handler An event handler
* @param capture Whether or not to listen during the capture event phase
*/
export
default
function
useGlobalListener
(
event
,
handler
,
capture
)
{
if
(
capture
===
void
0
)
{
capture
=
false
;
}
var
documentTarget
=
useCallback
(
function
()
{
return
document
;
},
[]);
return
useEventListener
(
documentTarget
,
event
,
handler
,
capture
);
}
\ No newline at end of file
node_modules/@restart/hooks/esm/useImage.d.ts
deleted
100644 → 0
View file @
df52aea8
declare
type
State
=
{
image
:
HTMLImageElement
|
null
;
error
:
unknown
|
null
;
};
/**
* Fetch and load an image for programatic use such as in a `<canvas>` element.
*
* @param imageOrUrl The `HtmlImageElement` or image url to load
* @param crossOrigin The `crossorigin` attribute to set
*
* ```ts
* const { image, error } = useImage('/static/kittens.png')
* const ref = useRef<HTMLCanvasElement>()
*
* useEffect(() => {
* const ctx = ref.current.getContext('2d')
*
* if (image) {
* ctx.drawImage(image, 0, 0)
* }
* }, [ref, image])
*
* return (
* <>
* {error && "there was a problem loading the image"}
* <canvas ref={ref} />
* </>
* ```
*/
export
default
function
useImage
(
imageOrUrl
?:
string
|
HTMLImageElement
|
null
|
undefined
,
crossOrigin
?:
'
anonymous
'
|
'
use-credentials
'
|
string
):
State
;
export
{};
node_modules/@restart/hooks/esm/useImage.js
deleted
100644 → 0
View file @
df52aea8
import
{
useState
,
useEffect
}
from
'
react
'
;
/**
* Fetch and load an image for programatic use such as in a `<canvas>` element.
*
* @param imageOrUrl The `HtmlImageElement` or image url to load
* @param crossOrigin The `crossorigin` attribute to set
*
* ```ts
* const { image, error } = useImage('/static/kittens.png')
* const ref = useRef<HTMLCanvasElement>()
*
* useEffect(() => {
* const ctx = ref.current.getContext('2d')
*
* if (image) {
* ctx.drawImage(image, 0, 0)
* }
* }, [ref, image])
*
* return (
* <>
* {error && "there was a problem loading the image"}
* <canvas ref={ref} />
* </>
* ```
*/
export
default
function
useImage
(
imageOrUrl
,
crossOrigin
)
{
var
_useState
=
useState
({
image
:
null
,
error
:
null
}),
state
=
_useState
[
0
],
setState
=
_useState
[
1
];
useEffect
(
function
()
{
if
(
!
imageOrUrl
)
return
undefined
;
var
image
;
if
(
typeof
imageOrUrl
===
'
string
'
)
{
image
=
new
Image
();
if
(
crossOrigin
)
image
.
crossOrigin
=
crossOrigin
;
image
.
src
=
imageOrUrl
;
}
else
{
image
=
imageOrUrl
;
if
(
image
.
complete
&&
image
.
naturalHeight
>
0
)
{
setState
({
image
:
image
,
error
:
null
});
return
;
}
}
function
onLoad
()
{
setState
({
image
:
image
,
error
:
null
});
}
function
onError
(
error
)
{
setState
({
image
:
image
,
error
:
error
});
}
image
.
addEventListener
(
'
load
'
,
onLoad
);
image
.
addEventListener
(
'
error
'
,
onError
);
return
function
()
{
image
.
removeEventListener
(
'
load
'
,
onLoad
);
image
.
removeEventListener
(
'
error
'
,
onError
);
};
},
[
imageOrUrl
,
crossOrigin
]);
return
state
;
}
\ No newline at end of file
node_modules/@restart/hooks/esm/useImmediateUpdateEffect.d.ts
deleted
100644 → 0
View file @
df52aea8
import
{
DependencyList
,
EffectCallback
}
from
'
react
'
;
/**
* An _immediate_ effect that runs an effect callback when its dependency array
* changes. This is helpful for updates should must run during render, most
* commonly state derived from props; a more ergonomic version of https://reactjs.org/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops
*
* ```ts
* function Example({ value }) {
* const [intermediaryValue, setValue] = useState(value);
*
* useImmediateUpdateEffect(() => {
* setValue(value)
* }, [value])
* ```
*
* @category effects
*/
declare
function
useImmediateUpdateEffect
(
effect
:
EffectCallback
,
deps
:
DependencyList
):
void
;
export
default
useImmediateUpdateEffect
;
node_modules/@restart/hooks/esm/useImmediateUpdateEffect.js
deleted
100644 → 0
View file @
df52aea8
import
{
useRef
}
from
'
react
'
;
import
useStableMemo
from
'
./useStableMemo
'
;
import
useWillUnmount
from
'
./useWillUnmount
'
;
/**
* An _immediate_ effect that runs an effect callback when its dependency array
* changes. This is helpful for updates should must run during render, most
* commonly state derived from props; a more ergonomic version of https://reactjs.org/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops
*
* ```ts
* function Example({ value }) {
* const [intermediaryValue, setValue] = useState(value);
*
* useImmediateUpdateEffect(() => {
* setValue(value)
* }, [value])
* ```
*
* @category effects
*/
function
useImmediateUpdateEffect
(
effect
,
deps
)
{
var
firstRef
=
useRef
(
true
);
var
tearDown
=
useRef
();
useWillUnmount
(
function
()
{
if
(
tearDown
.
current
)
tearDown
.
current
();
});
useStableMemo
(
function
()
{
if
(
firstRef
.
current
)
{
firstRef
.
current
=
false
;
return
;
}
if
(
tearDown
.
current
)
tearDown
.
current
();
tearDown
.
current
=
effect
();
},
deps
);
}
export
default
useImmediateUpdateEffect
;
\ No newline at end of file
node_modules/@restart/hooks/esm/useIntersectionObserver.d.ts
deleted
100644 → 0
View file @
df52aea8
/**
* Setup an [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver) on
* a DOM Element.
*
* @param element The DOM element to observe
* @param init IntersectionObserver options
*/
export
default
function
useIntersectionObserver
<
TElement
extends
Element
>
(
element
:
TElement
|
null
|
undefined
,
{
threshold
,
root
,
rootMargin
}?:
IntersectionObserverInit
):
IntersectionObserverEntry
[];
node_modules/@restart/hooks/esm/useIntersectionObserver.js
deleted
100644 → 0
View file @
df52aea8
import
{
useState
}
from
'
react
'
;
import
useStableMemo
from
'
./useStableMemo
'
;
import
useEffect
from
'
./useIsomorphicEffect
'
;
/**
* Setup an [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver) on
* a DOM Element.
*
* @param element The DOM element to observe
* @param init IntersectionObserver options
*/
export
default
function
useIntersectionObserver
(
element
,
_temp
)
{
var
_ref
=
_temp
===
void
0
?
{}
:
_temp
,
threshold
=
_ref
.
threshold
,
root
=
_ref
.
root
,
rootMargin
=
_ref
.
rootMargin
;
var
_useState
=
useState
(
null
),
entries
=
_useState
[
0
],
setEntry
=
_useState
[
1
];
var
observer
=
useStableMemo
(
function
()
{
return
typeof
IntersectionObserver
!==
'
undefined
'
&&
new
IntersectionObserver
(
function
(
entries
)
{
return
setEntry
(
entries
);
},
{
threshold
:
threshold
,
root
:
root
,
rootMargin
:
rootMargin
});
},
[
root
,
rootMargin
,
threshold
&&
JSON
.
stringify
(
threshold
)]);
useEffect
(
function
()
{
if
(
!
element
||
!
observer
)
return
;
observer
.
observe
(
element
);
return
function
()
{
observer
.
unobserve
(
element
);
};
},
[
observer
,
element
]);
return
entries
||
[];
}
\ No newline at end of file
Prev
1
…
24
25
26
27
28
29
30
31
32
…
38
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment