Lightning-Based Charging May Not Work If Your Device Has Been Idle over an Hour or You Did Not Use a Cable Within the past Three Days
This is expected behavior and is enabled by default to enhance device security, as malicious chargers are how law enforcement and other actors have been able to gain access to iOS devices in the past.
If it has been longer than an hour since you woke your phone, or more than three days since you charged your phone via a Lightning cable, it will not charge when you connect the cable.
To make sure your device charges with this enhanced security behavior enabled:
1) Wake your iPhone
2) Connect the charger cable and wait for the charging indication
3) Your device will now charge
Note this timeout does not affect wireless (Qi) chargers.
You may if you choose disable this device lockout by turning on the toggle switch:
Settings -> FaceID & Passcode (or TouchID & Passcode, whichever is applicable) -> Allow Access When Locked: USB Accessories
This feature is explained in more detail here:
Using USB accessories with iOS 11.4.1 and later - Apple Support
iPhone Xs Max, iOS 12, 512GB AT&T