UNPKG

@ngbracket/ngx-layout

Version:
1 lines 8.14 kB
{"version":3,"file":"ngbracket-ngx-layout-_private-utils.mjs","sources":["../../../../projects/libs/flex-layout/_private-utils/auto-prefixer.ts","../../../../projects/libs/flex-layout/_private-utils/layout-validator.ts","../../../../projects/libs/flex-layout/_private-utils/object-extend.ts","../../../../projects/libs/flex-layout/_private-utils/ngbracket-ngx-layout-_private-utils.ts"],"sourcesContent":["/**\n * Applies CSS prefixes to appropriate style keys.\n *\n * Note: `-ms-`, `-moz` and `-webkit-box` are no longer supported. e.g.\n * {\n * display: -webkit-flex; NEW - Safari 6.1+. iOS 7.1+, BB10\n * display: flex; NEW, Spec - Firefox, Chrome, Opera\n * // display: -webkit-box; OLD - iOS 6-, Safari 3.1-6, BB7\n * // display: -ms-flexbox; TWEENER - IE 10\n * // display: -moz-flexbox; OLD - Firefox\n * }\n */\nexport function applyCssPrefixes(target: { [key: string]: any | null }) {\n for (let key in target) {\n let value = target[key] ?? '';\n\n switch (key) {\n case 'display':\n if (value === 'flex') {\n target['display'] = ['-webkit-flex', 'flex'];\n } else if (value === 'inline-flex') {\n target['display'] = ['-webkit-inline-flex', 'inline-flex'];\n } else {\n target['display'] = value;\n }\n break;\n\n case 'align-items':\n case 'align-self':\n case 'align-content':\n case 'flex':\n case 'flex-basis':\n case 'flex-flow':\n case 'flex-grow':\n case 'flex-shrink':\n case 'flex-wrap':\n case 'justify-content':\n target['-webkit-' + key] = value;\n break;\n\n case 'flex-direction':\n target['-webkit-flex-direction'] = value;\n target['flex-direction'] = value;\n break;\n\n case 'order':\n target['order'] = target['-webkit-' + key] = isNaN(+value)\n ? '0'\n : value;\n break;\n }\n }\n return target;\n}\n","export const INLINE = 'inline';\nexport const LAYOUT_VALUES = ['row', 'column', 'row-reverse', 'column-reverse'];\n\n/**\n * Validate the direction|'direction wrap' value and then update the host's inline flexbox styles\n */\nexport function buildLayoutCSS(value: string) {\n let [direction, wrap, isInline] = validateValue(value);\n return buildCSS(direction, wrap, isInline);\n}\n\n/**\n * Validate the value to be one of the acceptable value options\n * Use default fallback of 'row'\n */\nexport function validateValue(value: string): [string, string, boolean] {\n value = value?.toLowerCase() ?? '';\n let [direction, wrap, inline] = value.split(' ');\n\n // First value must be the `flex-direction`\n if (!LAYOUT_VALUES.find((x) => x === direction)) {\n direction = LAYOUT_VALUES[0];\n }\n\n if (wrap === INLINE) {\n wrap = inline !== INLINE ? inline : '';\n inline = INLINE;\n }\n\n return [direction, validateWrapValue(wrap), !!inline];\n}\n\n/**\n * Determine if the validated, flex-direction value specifies\n * a horizontal/row flow.\n */\nexport function isFlowHorizontal(value: string): boolean {\n let [flow] = validateValue(value);\n return flow.indexOf('row') > -1;\n}\n\n/**\n * Convert layout-wrap='<value>' to expected flex-wrap style\n */\nexport function validateWrapValue(value: string) {\n if (!!value) {\n switch (value.toLowerCase()) {\n case 'reverse':\n case 'wrap-reverse':\n case 'reverse-wrap':\n value = 'wrap-reverse';\n break;\n\n case 'no':\n case 'none':\n case 'nowrap':\n value = 'nowrap';\n break;\n\n // All other values fallback to 'wrap'\n default:\n value = 'wrap';\n break;\n }\n }\n return value;\n}\n\n/**\n * Build the CSS that should be assigned to the element instance\n * BUG:\n * 1) min-height on a column flex container won’t apply to its flex item children in IE 10-11.\n * Use height instead if possible; height : <xxx>vh;\n *\n * This way any padding or border specified on the child elements are\n * laid out and drawn inside that element's specified width and height.\n */\nfunction buildCSS(\n direction: string,\n wrap: string | null = null,\n inline = false,\n) {\n return {\n display: inline ? 'inline-flex' : 'flex',\n 'box-sizing': 'border-box',\n 'flex-direction': direction,\n 'flex-wrap': wrap || null,\n };\n}\n","/**\n * Extends an object with the *enumerable* and *own* properties of one or more source objects,\n * similar to Object.assign.\n *\n * @param dest The object which will have properties copied to it.\n * @param sources The source objects from which properties will be copied.\n */\nexport function extendObject(dest: any, ...sources: any[]): any {\n if (dest == null) {\n throw TypeError('Cannot convert undefined or null to object');\n }\n\n for (let source of sources) {\n if (source != null) {\n for (let key in source) {\n if (source.hasOwnProperty(key)) {\n dest[key] = source[key];\n }\n }\n }\n }\n\n return dest;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;AAWG;AACG,SAAU,gBAAgB,CAAC,MAAqC,EAAA;AACpE,IAAA,KAAK,IAAI,GAAG,IAAI,MAAM,EAAE;QACtB,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE;QAE7B,QAAQ,GAAG;AACT,YAAA,KAAK,SAAS;AACZ,gBAAA,IAAI,KAAK,KAAK,MAAM,EAAE;oBACpB,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC;gBAC9C;AAAO,qBAAA,IAAI,KAAK,KAAK,aAAa,EAAE;oBAClC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,qBAAqB,EAAE,aAAa,CAAC;gBAC5D;qBAAO;AACL,oBAAA,MAAM,CAAC,SAAS,CAAC,GAAG,KAAK;gBAC3B;gBACA;AAEF,YAAA,KAAK,aAAa;AAClB,YAAA,KAAK,YAAY;AACjB,YAAA,KAAK,eAAe;AACpB,YAAA,KAAK,MAAM;AACX,YAAA,KAAK,YAAY;AACjB,YAAA,KAAK,WAAW;AAChB,YAAA,KAAK,WAAW;AAChB,YAAA,KAAK,aAAa;AAClB,YAAA,KAAK,WAAW;AAChB,YAAA,KAAK,iBAAiB;AACpB,gBAAA,MAAM,CAAC,UAAU,GAAG,GAAG,CAAC,GAAG,KAAK;gBAChC;AAEF,YAAA,KAAK,gBAAgB;AACnB,gBAAA,MAAM,CAAC,wBAAwB,CAAC,GAAG,KAAK;AACxC,gBAAA,MAAM,CAAC,gBAAgB,CAAC,GAAG,KAAK;gBAChC;AAEF,YAAA,KAAK,OAAO;AACV,gBAAA,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,UAAU,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK;AACv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