UNPKG

rn-custom-style-sheet

Version:

React Native component to select a specific value from a range of values.

71 lines (70 loc) 2.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.between = between; exports.breakpointValue = void 0; exports.down = down; exports.not = not; exports.only = only; exports.up = up; var _MediaQuery = require("../../MediaQuery"); var _Utils = require("../Utils"); const breakpointValue = exports.breakpointValue = { 'base': 0, 'sm': 480, 'md': 768, 'lg': 992, 'xl': 1280, '2xl': 1536 }; function up(key, guideLineBreakpoint) { const { unit } = guideLineBreakpoint; const value = (0, _Utils.hasValidBreakpointFormat)(key, guideLineBreakpoint); return `${_MediaQuery.MediaQueryProps.PREFIX} (min-width:${value}${unit})`; } function down(key, guideLineBreakpoint) { const { unit, step } = guideLineBreakpoint; const value = (0, _Utils.hasValidBreakpointFormat)(key, guideLineBreakpoint); return `${_MediaQuery.MediaQueryProps.PREFIX} (max-width:${value - step / 100}${unit})`; } function between(start, end, guideLineBreakpoint) { const { unit, step, keys } = guideLineBreakpoint; const endIndex = keys.indexOf(String(end)); const startValue = (0, _Utils.hasValidBreakpointFormat)(start, guideLineBreakpoint); const endValue = endIndex !== -1 ? (0, _Utils.hasValidBreakpointFormat)(keys[endIndex], guideLineBreakpoint) : Number(end); return `${_MediaQuery.MediaQueryProps.PREFIX} (min-width:${startValue}${unit}) and ` + `(max-width:${endValue - step / 100}${unit})`; } function only(key, guideLineBreakpoint) { const { keys } = guideLineBreakpoint; if (keys.indexOf(String(key)) + 1 < keys.length) { return between(key, keys[keys.indexOf(String(key)) + 1], guideLineBreakpoint); } return up(key, guideLineBreakpoint); } function not(key, guideLineBreakpoint) { const { keys } = guideLineBreakpoint; // handle first and last key separately, for better readability const keyIndex = keys.indexOf(String(key)); if (keyIndex === 0) { return up(keys[1], guideLineBreakpoint); } if (keyIndex === keys.length - 1) { return down(keys[keyIndex], guideLineBreakpoint); } return between(key, keys[keys.indexOf(String(key)) + 1], guideLineBreakpoint).replace(`${_MediaQuery.MediaQueryProps.PREFIX}`, `${_MediaQuery.MediaQueryProps.PREFIX} not all and`); } //# sourceMappingURL=Breakpoint.js.map