{"id":25961684,"url":"https://github.com/ttab/ttbox","last_synced_at":"2026-05-12T19:03:46.394Z","repository":{"id":34196022,"uuid":"38050879","full_name":"ttab/ttbox","owner":"ttab","description":"modern search box with pills for restrictions","archived":false,"fork":false,"pushed_at":"2016-11-30T11:35:26.000Z","size":364,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-02-24T01:11:13.353Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ttab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-25T13:27:44.000Z","updated_at":"2019-04-10T13:09:07.000Z","dependencies_parsed_at":"2022-09-11T03:20:41.878Z","dependency_job_id":null,"html_url":"https://github.com/ttab/ttbox","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttab%2Fttbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttab%2Fttbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttab%2Fttbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttab%2Fttbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ttab","download_url":"https://codeload.github.com/ttab/ttbox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241912977,"owners_count":20041457,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-04T19:40:59.879Z","updated_at":"2026-05-12T19:03:46.336Z","avatar_url":"https://github.com/ttab.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"ttbox - pillified suggestbox\n============================\n\n## Motivation\n\nSuggest search box with pill constraints.\n\n## Compatibility\n\n* Chrome, Safari, Firefox, IE9+, iOS5+, Android\n\n## Installing with NPM\n\n```bash\nnpm install -S ttbox\n```\n\n### Installing with Bower\n\n```bash\nbower install -S ttbox\n```\n## API\n\n### ttbox(div, trig1, trig2, ...)\n\nConstructs a ttbox around a given div. Returns a façade for\ninteracting with the box.\n\n#### Example\n\n```javascript\nttbox($('#myinput'), ttbox.trig('@', {prefix:true}, ttbox.type('person', {\n    suggest: function(word, cb, type) {\n        ...\n    }\n})));\n```\n\n\n### The façade\n\nA façade is returned by the `ttbox` function and is provided in all events.\n\n#### façade.values()\n\nReturns the current values of the box.\n\n#### façade.addpill(type, item)\n\nAdds a new pill to the box. Item is optional.\n\n#### façade.clear()\n\nClear the input\n\n#### façade.focus()\n\nFocus the input (or do nothing if cursor already there).\n\n#### façade.placeholder(txt)\n\nXXX TODO\n\nSet placeholder text (shown when input is empty).\n\n\n### ttbox.trig(symbol, opts, type or typelist)\n\nDeclares a triggers with the nested types for that trigger.  Opts can\nbe omitted.\n\nOptions:\n\n* `prefix` boolean indicating whether trigger is a prefix\n* `className` items belonging to this trigger (suggest/pills) will\n  have this class.\n\n#### Example\n\n```javascript\nttbox.trig('@', {\n    prefix: true,\n    className: 'persontrig'\n}, ttbox.type('person', { ... }));\n```\n\n\n### ttbox.type(name, opts)\n\nDeclare a type belonging to a trigger. Opts can be omitted.\n\nOptions:\n\n* `desc` description for this type. displayed in suggests.\n* `suggest` to do suggestions for input `function(word, callback, type)`\n* `limitOne` to limit number of pills of type to one (boolean).\n* `html` to take control of what html represents the type in suggest\n  list. `function(word)` and return a string with the html.\n* `format` to get a chance to format (such as upper/lower-case) input\n  that wasn't controlled by a suggest.\n\n### Suggest returns:\n\nCallback can be provided with\n\n1. List of string\n2. List of objects with `{value:'value'}`\n\nItem options (for object form)\n\n* `value` mandatory unless `html` is provided.\n* `html` function to control html representation in suggests.\n* `desc` value description\n* `className` additional class in suggests.\n\n### Example\n\nSimplest form, no suggest.\n\n```javascript\nttbox.type('mytype')\n```\n\nSuggest with fixed values returned\n\n```javascript\nttbox.type('mytype', {\n    suggest: function(word, cb, type) {\n        cb(['my', 'list']);\n}});\n```\n\nFixed list with descriptions\n\n```javascript\nttbox.type('product', {\n    className: 'productype',\n    desc: 'my products',\n    suggest: function(word, cb, type) {\n      return cb([\n        {\n          value: 'PHOTO',\n          desc: 'All photos'\n          html: function() { ... }\n        }, {\n          value: 'VIDEO',\n          desc: 'All videos'\n        }\n      ].filter(function(i) {\n        return i.value.indexOf(word.toUpperCase()) === 0;\n      }));\n    },\n    format: function(t) {\n        return t.toUpperCase();\n    }\n});\n```\n\n\n### ttbox.divider(title)\n\nSpecial type inserted in type lists to `ttbox.trig` to make visual dividers.\n\n#### Example\n\n```javascript\nvar types = [\n    ttbox.divider('Limit result to'),\n    ttbox.type('product', { ... })\n    ...\n    ttbox.divider('Other options'),\n    ttbox.type('quality', { ... })\n```\n\n\n## Events\n\nA number of events are dispatched on the DOM element provided.\n\n* `ttbox:init` after initialization.\n* `ttbox:suggesttypes` when there are multiple possible types to select from.\n* `ttbox:suggesttype` whenever one single type is highlighted (cursor move)\n* `ttbox:suggesttypeselect` when a type is selected\n* `ttbox:suggestitems` when there are multiple item choices\n* `ttbox:suggestitem` when a single item is highlighted (cursor move)\n* `ttbox:suggestitemselect` when a single item is selected\n* `ttbox:suggeststop` when suggest is hidden.\n* `ttbox:pilladd` when a pill is added\n* `ttbox:pillremove` when a pill is removed\n\nLicense\n-------\n\nThe MIT License (MIT)\n\nCopyright © 2015 TT Nyhetsbyrån\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttab%2Fttbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fttab%2Fttbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttab%2Fttbox/lists"}