<commit_before>(ns untangled.dom
  (:require [clojure.string :as str]
            [cljs-uuid-utils.core :as uuid]))



(defn unique-key [] (uuid/uuid-string (uuid/make-random-squuid)))


(defn toggle-class
  "Adds the 'visble' class and removes the 'hidden' class to the pre-supplied class string based on the truthiness
  of the value in data at key.

  Parameters:
  `data`: A map containg the component's state.
  `key`: A key within `data`.
  `always-classes`: A string that has the CSS classes to always return in the returned string.

  Optional named parameters:

  `:when-true v` : This string to add when the key's value is true. Defaults to \"active\".
  `:when-false v` : The string to add when the key's value is false. Defaults to \"\".
  "
  [data key always-classes & {:keys [when-true when-false]
                              :or   {when-true "active" when-false ""}}]
  (if (get data key)
    (str/join " " [always-classes when-true])
    (str/join " " [always-classes when-false])))


(defn toggle
  "Toggles the (boolean) state of an arbitrary state key.

  Params:
  `state-key` : A key within the component state.
  `state`     : The map containing the current state of a component.
  "
  [state-key state] (update state state-key not))


(defn toggle-checked
  "Toggles the (boolean) state of the `checked` attribute of an input element."
  [input]
  (update input :checked not))<commit_msg>Story ID: develop Added `text-value` utility to untangled.dom.<commit_after>(ns untangled.dom
  (:require [clojure.string :as str]
            [cljs-uuid-utils.core :as uuid]))



(defn unique-key [] (uuid/uuid-string (uuid/make-random-squuid)))


(defn toggle-class
  "Adds the 'visble' class and removes the 'hidden' class to the pre-supplied class string based on the truthiness
  of the value in data at key.

  Parameters:
  `data`: A map containg the component's state.
  `key`: A key within `data`.
  `always-classes`: A string that has the CSS classes to always return in the returned string.

  Optional named parameters:

  `:when-true v` : This string to add when the key's value is true. Defaults to \"active\".
  `:when-false v` : The string to add when the key's value is false. Defaults to \"\".
  "
  [data key always-classes & {:keys [when-true when-false]
                              :or   {when-true "active" when-false ""}}]
  (if (get data key)
    (str/join " " [always-classes when-true])
    (str/join " " [always-classes when-false])))


(defn toggle
  "Toggles the (boolean) state of an arbitrary state key.

  Params:
  `state-key` : A key within the component state.
  `state`     : The map containing the current state of a component.
  "
  [state-key state] (update state state-key not))


(defn toggle-checked
  "Toggles the (boolean) state of the `checked` attribute of an input element."
  [input]
  (update input :checked not))


(defn text-value
  "Returns the text value from an input change event"
  [evt]
  (.-value (.-target evt)))
{'fraction_non_alphanumeric': 0.11821835231078366, 'fraction_numerical': 0.0, 'mean_word_length': 3.0750341064120055, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '624298', 'n_tokens_mistral': 967, 'n_tokens_neox': 923, 'n_words': 369}