MCPcopy Create free account
hub / github.com/Effect-TS/effect / typeKey

Function typeKey

packages/effect/src/ui/kit/Menu.ts:1136–1160  ·  view source on GitHub ↗
(model: MenuModel, $: MenuUpdate, key: string)

Source from the content-addressed store, hash-verified

1134}
1135
1136const typeKey = (model: MenuModel, $: MenuUpdate, key: string) => {
1137 const items = visibleOf($.props)
1138 const from = model.active === null
1139 ? -1
1140 : items.findIndex((item) => item.value === model.active)
1141 // Omit disabled flags to include disabled matches.
1142 const { index, state } = Typeahead.step(
1143 model.typeahead,
1144 key,
1145 items.map(({ label }) => ({ label })),
1146 from
1147 )
1148 const item = items[index]
1149 const moved = item === undefined
1150 ? {}
1151 : { active: item.value, activeByKey: true }
1152 return commit(
1153 $,
1154 model,
1155 UiStruct.evolve(model, { typeahead: state, ...moved }),
1156 "keyboard"
1157 ).run(
1158 Typeahead.waitReset(MenuMessage.CompletedWaitBeforeResetTyping, 500)
1159 )
1160}
1161
1162const keys = (orientation: ListNavigation.Orientation, rtl: boolean) => {
1163 const cross = ListNavigation.arrowKeys(

Callers 1

pressKeyFunction · 0.70

Calls 6

visibleOfFunction · 0.85
commitFunction · 0.70
stepMethod · 0.65
runMethod · 0.65
evolveMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected