<commit_before>/**
 * @license
 * Copyright 2015 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

CLASS({
  package: 'foam.ui.md',
  name: 'TextFieldView',
  extendsModel: 'foam.ui.SimpleView',
  traits: ['foam.ui.md.MDStyleTrait'],

  requires: [
    'foam.ui.QueryParserAutocompleter',
    'foam.ui.md.AutocompleteView',
  ],

  properties: [
    {
      name: 'className',
      defaultValue: 'md-text-field-container'
    },
    { name: 'data' },
    { name: 'softData' },
    { name: 'inputId' },
    { name: '$input', getter: function() { return this.X.$(this.inputId); } },
    { name: 'labelId' },
    { name: '$label', getter: function() { return this.X.$(this.labelId); } },
    { model_: 'BooleanProperty', name: 'focused', defaultValue: false },
    'prop',
    { name: 'label', defaultValueFn: function() { return this.prop.label; } },
    {
      model_: 'BooleanProperty',
      name: 'onKeyMode',
      help: 'If true, value is updated on each keystroke.',
      documentation: function() { /* If true, value is updated on each keystroke. */},
      getter: function() {
        return this.updateMode === this.EACH_KEYSTROKE;
      },
      setter: function(nu) {
        this.updateMode = nu ? this.EACH_KEYSTROKE : this.DONE_EDITING;
      }
    },
    {
      model_: 'foam.core.types.StringEnumProperty',
      name: 'updateMode',
      help: 'Controls when the real .data is updated: on every keystroke, ' +
          'when the user presses enter or blurs the box, or on enter only.',
      defaultValue: 'DONE_EDITING',
      choices: [
        ['DONE_EDITING', 'Done editing'],
        ['EACH_KEYSTROKE', 'Every keystroke'],
        ['ENTER_ONLY', 'Enter only']
      ]
    },
    {
      name: 'autocomplete',
      documentation: 'Set this to true to enable autocomplete. Off by ' +
          'default, unless the $$DOC{ref:".prop", label: "property"} has an ' +
          '$$DOC{ref:"Property.autocompleter"} set.',
      defaultValueFn: function() { return !! this.prop.autocompleter; }
    },
    {
      model_: 'FactoryProperty',
      name: 'autocompleter',
      defaultValue: 'foam.ui.QueryParserAutocompleter',
    },
    {
      model_: 'ViewFactoryProperty',
      name: 'acRowView',
      defaultValue: 'foam.ui.md.DetailView'
    },
    {
      name: 'autocompleteView',
    },
    { model_: 'IntProperty', name: 'displayHeight' },
    { model_: 'IntProperty', name: 'displayWidth' },
    {
      model_: 'BooleanProperty',
      name: 'floatingLabel',
      documentation: 'Set true for the floating label (see MD spec) by ' +
          'default, but can be disabled where the label is redundant.',
      defaultValue: true,
      postSet: function(old, nu) {
        if ( old === nu ) return;
        //TODO: re-render
      },
    },
    {
      model_: 'BooleanProperty',
      name: 'growable',<commit_msg>MD TextFieldView: Slightly more robust defaultValueFn for autocomplete<commit_after>/**
 * @license
 * Copyright 2015 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

CLASS({
  package: 'foam.ui.md',
  name: 'TextFieldView',
  extendsModel: 'foam.ui.SimpleView',
  traits: ['foam.ui.md.MDStyleTrait'],

  requires: [
    'foam.ui.QueryParserAutocompleter',
    'foam.ui.md.AutocompleteView',
  ],

  properties: [
    {
      name: 'className',
      defaultValue: 'md-text-field-container'
    },
    { name: 'data' },
    { name: 'softData' },
    { name: 'inputId' },
    { name: '$input', getter: function() { return this.X.$(this.inputId); } },
    { name: 'labelId' },
    { name: '$label', getter: function() { return this.X.$(this.labelId); } },
    { model_: 'BooleanProperty', name: 'focused', defaultValue: false },
    'prop',
    { name: 'label', defaultValueFn: function() { return this.prop.label; } },
    {
      model_: 'BooleanProperty',
      name: 'onKeyMode',
      help: 'If true, value is updated on each keystroke.',
      documentation: function() { /* If true, value is updated on each keystroke. */},
      getter: function() {
        return this.updateMode === this.EACH_KEYSTROKE;
      },
      setter: function(nu) {
        this.updateMode = nu ? this.EACH_KEYSTROKE : this.DONE_EDITING;
      }
    },
    {
      model_: 'foam.core.types.StringEnumProperty',
      name: 'updateMode',
      help: 'Controls when the real .data is updated: on every keystroke, ' +
          'when the user presses enter or blurs the box, or on enter only.',
      defaultValue: 'DONE_EDITING',
      choices: [
        ['DONE_EDITING', 'Done editing'],
        ['EACH_KEYSTROKE', 'Every keystroke'],
        ['ENTER_ONLY', 'Enter only']
      ]
    },
    {
      name: 'autocomplete',
      documentation: 'Set this to true to enable autocomplete. Off by ' +
          'default, unless the $$DOC{ref:".prop", label: "property"} has an ' +
          '$$DOC{ref:"Property.autocompleter"} set.',
      defaultValueFn: function() { return !! (this.prop && this.prop.autocompleter); }
    },
    {
      model_: 'FactoryProperty',
      name: 'autocompleter',
      defaultValue: 'foam.ui.QueryParserAutocompleter',
    },
    {
      model_: 'ViewFactoryProperty',
      name: 'acRowView',
      defaultValue: 'foam.ui.md.DetailView'
    },
    {
      name: 'autocompleteView',
    },
    { model_: 'IntProperty', name: 'displayHeight' },
    { model_: 'IntProperty', name: 'displayWidth' },
    {
      model_: 'BooleanProperty',
      name: 'floatingLabel',
      documentation: 'Set true for the floating label (see MD spec) by ' +
          'default, but can be disabled where the label is redundant.',
      defaultValue: true,
      postSet: function(old, nu) {
        if ( old === nu ) return;
        //TODO: re-render
      },
    },
    {
      model_: 'BooleanProperty',
      name: 'growable',
{'fraction_non_alphanumeric': 0.13778036702592486, 'fraction_numerical': 0.002330323332362365, 'mean_word_length': 2.742234332425068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2988836', 'n_tokens_mistral': 2126, 'n_tokens_neox': 2071, 'n_words': 605}