<commit_before>/**
 * crée un transform d'un domNode qui va créer autant de childNodes que nécessaire et les confier à chaque composant
 */
const createDiv = require("reaks/child")
const seq = require("reaks/seq")
const concat = require("lodash/concat")
const isFunction = require("lodash/isFunction")
const assign = require("lodash/assign")
const style = require("reaks/style")

const flexAlign = a => {
  let flexAlign = a

  if (a === "top") {
    flexAlign = "flex-start"
  }
  if (a === "bottom") {
    flexAlign = "flex-end"
  }
  if (a === "left") {
    flexAlign = "flex-start"
  }
  if (a === "right") {
    flexAlign = "flex-end"
  }

  return flexAlign
}

const asFlexParent = ({ orientation, wrap, align }) =>
  style(
    assign({
      display: "flex",
      flexDirection: orientation,
      flexWrap: wrap ? "wrap" : null,
      overflow: "hidden",
      alignItems: flexAlign(align),
    })
  )

const staticFlexChildStyle = ({ weight, wrap, align }) => {
  return assign(
    weight
      ? {
          flex: weight,
          overflow: wrap ? null : "hidden",
        }
      : { display: "flex", flexShrink: 0 },
    { alignSelf: flexAlign(align) }
  )
}

const flexChildStyle = arg => {
  const { weight } = arg
  if (isFunction(weight)) {
    return () => staticFlexChildStyle(assign({}, arg, { weight: weight() }))
  } else {
    return staticFlexChildStyle(arg)
  }
}

module.exports = ({ orientation = "row", defaultChildOpts, wrap = false }) =>
  function(arg1, arg2) {
    let opts, args

    if (arguments.length === 1) {
      args = arg1
      opts = {}
    } else {
      opts = arg1
      args = arg2
    }

    const argsNormalized = args.map(c => (Array.isArray(c) ? c : [{}, c]))

    const { align: defaultAlign } = opts

    const flexChildren = argsNormalized.map(([childOpts, childMixin]) => {
      if (childOpts == "flex") childOpts = { weight: 1 }
      if (childOpts == "fixed") childOpts = { weight: null }
      const { child: createChild = createDiv, weight, align } = assign(
        {},
        defaultChildOpts,
        childOpts
      )
      return createChild(
        seq([
          style(flexChildStyle({ orientation, wrap, weight, align })),
          childMixin,
        ])
      )
    })
    return seq(
      concat(
        asFlexParent({ orientation, wrap, align: defaultAlign }),
        flexChildren
      )
    )
  }
<commit_msg>Fix flex width 0<commit_after>/**
 * crée un transform d'un domNode qui va créer autant de childNodes que nécessaire et les confier à chaque composant
 */
const createDiv = require("reaks/child")
const seq = require("reaks/seq")
const concat = require("lodash/concat")
const isFunction = require("lodash/isFunction")
const assign = require("lodash/assign")
const style = require("reaks/style")

const flexAlign = a => {
  let flexAlign = a

  if (a === "top") {
    flexAlign = "flex-start"
  }
  if (a === "bottom") {
    flexAlign = "flex-end"
  }
  if (a === "left") {
    flexAlign = "flex-start"
  }
  if (a === "right") {
    flexAlign = "flex-end"
  }

  return flexAlign
}

const asFlexParent = ({ orientation, wrap, align }) =>
  style(
    assign({
      display: "flex",
      flexDirection: orientation,
      flexWrap: wrap ? "wrap" : null,
      overflow: "hidden",
      alignItems: flexAlign(align),
    })
  )

const staticFlexChildStyle = ({ weight, wrap, align }) => {
  return assign(
    weight !== null
      ? {
          flex: weight,
          overflow: wrap ? null : "hidden",
        }
      : { display: "flex", flexShrink: 0 },
    { alignSelf: flexAlign(align) }
  )
}

const flexChildStyle = arg => {
  const { weight } = arg
  if (isFunction(weight)) {
    return () => staticFlexChildStyle(assign({}, arg, { weight: weight() }))
  } else {
    return staticFlexChildStyle(arg)
  }
}

module.exports = ({ orientation = "row", defaultChildOpts, wrap = false }) =>
  function(arg1, arg2) {
    let opts, args

    if (arguments.length === 1) {
      args = arg1
      opts = {}
    } else {
      opts = arg1
      args = arg2
    }

    const argsNormalized = args.map(c => (Array.isArray(c) ? c : [{}, c]))

    const { align: defaultAlign } = opts

    const flexChildren = argsNormalized.map(([childOpts, childMixin]) => {
      if (childOpts == "flex") childOpts = { weight: 1 }
      if (childOpts == "fixed") childOpts = { weight: null }
      const { child: createChild = createDiv, weight, align } = assign(
        {},
        defaultChildOpts,
        childOpts
      )
      return createChild(
        seq([
          style(flexChildStyle({ orientation, wrap, weight, align })),
          childMixin,
        ])
      )
    })
    return seq(
      concat(
        asFlexParent({ orientation, wrap, align: defaultAlign }),
        flexChildren
      )
    )
  }

{'fraction_non_alphanumeric': 0.1444351813255523, 'fraction_numerical': 0.0035431429762401, 'mean_word_length': 2.497813411078717, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6051984', 'n_tokens_mistral': 1529, 'n_tokens_neox': 1517, 'n_words': 396}