<commit_before>import { FieldSchema, Objects } from '@ephox/boulder';
import { Id } from '@ephox/katamari';
import { ItemDataTuple } from '../../ui/types/ItemTypes';
import { MenuSpec } from '../../ui/types/MenuTypes';

import * as Fields from '../../data/Fields';
import * as TieredMenuSpec from '../../ui/single/TieredMenuSpec';
import { TieredData, TieredMenuRecord, TieredMenuSketcher } from '../../ui/types/TieredMenuTypes';
import { Composing } from '../behaviour/Composing';
import { Highlighting } from '../behaviour/Highlighting';
import { Keying } from '../behaviour/Keying';
import { Replacing } from '../behaviour/Replacing';
import * as SketchBehaviours from '../component/SketchBehaviours';
import { single } from './Sketcher';

const tieredData = (primary: string, menus: TieredMenuRecord, expansions: Record<string, string>): TieredData => {
  return {
    primary,
    menus,
    expansions
  };
};

const singleData = (name: string, menu: MenuSpec): TieredData => {
  return {
    primary: name,
    menus: Objects.wrap(name, menu),
    expansions: { }
  };
};

const collapseItem = (text: string): ItemDataTuple => {
  return {
    value: Id.generate(TieredMenuSpec.collapseItem()),
    meta: {
      text
    }
  };
};

const tieredMenu = single({
  name: 'TieredMenu',
  configFields: [
    Fields.onStrictKeyboardHandler('onExecute'),
    Fields.onStrictKeyboardHandler('onEscape'),

    Fields.onStrictHandler('onOpenMenu'),
    Fields.onStrictHandler('onOpenSubmenu'),
    Fields.onHandler('onCollapseMenu'),

    FieldSchema.defaulted('highlightImmediately', true),

    FieldSchema.strictObjOf('data', [
      FieldSchema.strict('primary'),
      FieldSchema.strict('menus'),
      FieldSchema.strict('expansions')
    ]),

    FieldSchema.defaulted('fakeFocus', false),
    Fields.onHandler('onHighlight'),
    Fields.onHandler('onHover'),
    Fields.tieredMenuMarkers(),

    FieldSchema.strict('dom'),

    FieldSchema.defaulted('navigateOnHover', true),
    FieldSchema.defaulted('stayInDom', false),

    SketchBehaviours.field('tmenuBehaviours', [ Keying, Highlighting, Composing, Replacing ]),
    FieldSchema.defaulted('eventOrder', { })
  ],

  apis: {
    collapseMenu (apis, tmenu) {
      apis.collapseMenu(tmenu);
    },
    highlightPrimary (apis, tmenu) {
      apis.highlightPrimary(tmenu);
    }
  },

  factory: TieredMenuSpec.make,

  extraApis: {
    tieredData,
    singleData,
    collapseItem
  }
}) as Partial<TieredMenuSketcher>;

export {
  tieredMenu,
  TieredData
};<commit_msg>removed partial from tiered menu to work better with strict mode<commit_after>import { FieldSchema, Objects } from '@ephox/boulder';
import { Id } from '@ephox/katamari';
import { ItemDataTuple } from '../../ui/types/ItemTypes';
import { MenuSpec } from '../../ui/types/MenuTypes';

import * as Fields from '../../data/Fields';
import * as TieredMenuSpec from '../../ui/single/TieredMenuSpec';
import { TieredData, TieredMenuRecord, TieredMenuSketcher } from '../../ui/types/TieredMenuTypes';
import { Composing } from '../behaviour/Composing';
import { Highlighting } from '../behaviour/Highlighting';
import { Keying } from '../behaviour/Keying';
import { Replacing } from '../behaviour/Replacing';
import * as SketchBehaviours from '../component/SketchBehaviours';
import { single } from './Sketcher';

const tieredData = (primary: string, menus: TieredMenuRecord, expansions: Record<string, string>): TieredData => {
  return {
    primary,
    menus,
    expansions
  };
};

const singleData = (name: string, menu: MenuSpec): TieredData => {
  return {
    primary: name,
    menus: Objects.wrap(name, menu),
    expansions: { }
  };
};

const collapseItem = (text: string): ItemDataTuple => {
  return {
    value: Id.generate(TieredMenuSpec.collapseItem()),
    meta: {
      text
    }
  };
};

const tieredMenu: TieredMenuSketcher = single({
  name: 'TieredMenu',
  configFields: [
    Fields.onStrictKeyboardHandler('onExecute'),
    Fields.onStrictKeyboardHandler('onEscape'),

    Fields.onStrictHandler('onOpenMenu'),
    Fields.onStrictHandler('onOpenSubmenu'),
    Fields.onHandler('onCollapseMenu'),

    FieldSchema.defaulted('highlightImmediately', true),

    FieldSchema.strictObjOf('data', [
      FieldSchema.strict('primary'),
      FieldSchema.strict('menus'),
      FieldSchema.strict('expansions')
    ]),

    FieldSchema.defaulted('fakeFocus', false),
    Fields.onHandler('onHighlight'),
    Fields.onHandler('onHover'),
    Fields.tieredMenuMarkers(),

    FieldSchema.strict('dom'),

    FieldSchema.defaulted('navigateOnHover', true),
    FieldSchema.defaulted('stayInDom', false),

    SketchBehaviours.field('tmenuBehaviours', [ Keying, Highlighting, Composing, Replacing ]),
    FieldSchema.defaulted('eventOrder', { })
  ],

  apis: {
    collapseMenu (apis, tmenu) {
      apis.collapseMenu(tmenu);
    },
    highlightPrimary (apis, tmenu) {
      apis.highlightPrimary(tmenu);
    }
  },

  factory: TieredMenuSpec.make,

  extraApis: {
    tieredData,
    singleData,
    collapseItem
  }
});

export {
  tieredMenu,
  TieredData
};
{'fraction_non_alphanumeric': 0.14949059561128528, 'fraction_numerical': 0.0, 'mean_word_length': 3.8898467432950192, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 12, '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': '6531080', 'n_tokens_mistral': 1687, 'n_tokens_neox': 1625, 'n_words': 307}