{"id":15481585,"url":"https://github.com/akhilcb/acbtokenfield","last_synced_at":"2025-04-11T07:56:18.562Z","repository":{"id":41081456,"uuid":"99295818","full_name":"akhilcb/ACBTokenField","owner":"akhilcb","description":"A swift extension on NSTokenField which makes it highly customizable and removes a lot of boilerplate code from implementation","archived":false,"fork":false,"pushed_at":"2024-05-26T19:53:19.000Z","size":15955,"stargazers_count":63,"open_issues_count":3,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-19T05:15:27.612Z","etag":null,"topics":["appkit","cocoapods","extension","nssearchfield","nstextfield","nstokenfield","nstokenfieldcell","objective-c","osx","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akhilcb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-04T02:46:30.000Z","updated_at":"2024-09-27T00:44:46.000Z","dependencies_parsed_at":"2024-10-31T08:13:30.621Z","dependency_job_id":null,"html_url":"https://github.com/akhilcb/ACBTokenField","commit_stats":{"total_commits":42,"total_committers":5,"mean_commits":8.4,"dds":0.6428571428571428,"last_synced_commit":"65517b61c931535cbef0be3958d9e24d1b43eab2"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhilcb%2FACBTokenField","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhilcb%2FACBTokenField/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhilcb%2FACBTokenField/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhilcb%2FACBTokenField/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akhilcb","download_url":"https://codeload.github.com/akhilcb/ACBTokenField/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248360046,"owners_count":21090641,"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":["appkit","cocoapods","extension","nssearchfield","nstextfield","nstokenfield","nstokenfieldcell","objective-c","osx","swift"],"created_at":"2024-10-02T05:05:00.900Z","updated_at":"2025-04-11T07:56:18.536Z","avatar_url":"https://github.com/akhilcb.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ACBTokenField \u003ckbd\u003e\u003cimg src=\"/ACBTokenField/Resources/Assets.xcassets/AppIcon.appiconset/Icon-App-32x32@2x.png?raw=true\" width=\"32\"\u003e\u003c/kbd\u003e\n\n[![Swift 3.2](https://img.shields.io/badge/Swift-3.2-orange.svg)](https://github.com/akhilcb/ACBTokenField)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/ACBTokenField.svg)](https://img.shields.io/cocoapods/v/ACBTokenField.svg)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Swift Package Manager](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg?style=flat)](https://swift.org/package-manager)\n[![Platform](https://img.shields.io/cocoapods/p/ACBTokenField.svg?style=flat)](https://github.com/akhilcb/ACBTokenField)\n[![License](https://img.shields.io/cocoapods/l/ACBTokenField.svg?style=flat)](http://cocoapods.org/pods/ACBTokenField)\n\n\nA swift extension on NSTokenField which makes it highly customizable and removes a lot of boilerplate code from its implementation.\n\n## Features\n\n - [x] Extension on NSTokenField, no need to subclass/or change anything in XIB/Storyboard\n - [x] Added few properties which makes it customizable such as `shouldDisplayClearButton`, `shouldDisplaySearchIcon`, `leftView`, `shouldEnableTokenMenu` etc.. \n - [x] No need to implement delegate methods for simpler use cases. Just set an array of token names list or provide a default list of tokens for all indices. Rest will be handled by `NSTokenField`. See demo provided below(1 - 3).\n - [x] Supports `NSTokenFieldDelegate` as well with the customization. Just set `tokenDelegate` and implement the methods(see gif4) as usual. \n - [x] Added support for getting `selectedTokenIndex` so that tokens can be customized based on the index. `tokenIndex` provided in `NSTokenFieldDelegate` method has a bug and hence always returns zero. `selectedTokenIndex` will help in the meantime.\n - [x] Support for adding tokens\n - [x] Support for resetting tokens\n - [x] Support for delete token callback\n - [x] Support for getting actual token count\n - [x] Get `tokenIndex` based on the `representedObject` param in delegate methods.\n \n## Demo\n\n\u003ckbd\u003e\u003cdiv\u003e\u003cimg src=\"/ACBTokenField/Screenshots/ACBTokenFieldGif1.gif?raw=true\" width=\"500\"\u003e\u003c/div\u003e\u003c/kbd\u003e\n\u003cdiv\u003e\u003cbr\u003e\u003c/div\u003e\n\u003ckbd\u003e\u003cdiv\u003e\u003cimg src=\"/ACBTokenField/Screenshots/ACBTokenFieldGif2.gif?raw=true\" width=\"500\"\u003e\u003c/div\u003e\u003c/kbd\u003e\n\u003cdiv\u003e\u003cbr\u003e\u003c/div\u003e\n\u003ckbd\u003e\u003cdiv\u003e\u003cimg src=\"/ACBTokenField/Screenshots/ACBTokenFieldGif3.gif?raw=true\" width=\"500\"\u003e\u003c/div\u003e\u003c/kbd\u003e\n\u003cdiv\u003e\u003cbr\u003e\u003c/div\u003e\n\u003ckbd\u003e\u003cdiv\u003e\u003cimg src=\"/ACBTokenField/Screenshots/ACBTokenFieldGif4.gif?raw=true\" width=\"500\"\u003e\u003c/div\u003e\u003c/kbd\u003e\n\u003cdiv\u003e\u003cbr\u003e\u003c/div\u003e\n\u003ckbd\u003e\u003cdiv\u003e\u003cimg src=\"/ACBTokenField/Screenshots/ACBTokenFieldGif5.gif?raw=true\" width=\"500\"\u003e\u003c/div\u003e\u003c/kbd\u003e\n\n\u003cdiv\u003e\u003cbr\u003e\u003c/div\u003e\n\n## Setup\n\nCarthage, Cocoapods or Swift Package Manager can be used to integrate this to a project. \n\n### Carthage\n\n```\ngithub \"akhilcb/ACBTokenField\" ~\u003e 2.3.0\n\n```\n\n### Cocoapods\n\n```\npod 'ACBTokenField', '~\u003e 2.3.0'\n\n```\n\n### Swift Package Manager\n\n```\ndependencies: [\n    .Package(url: \"https://github.com/akhilcb/ACBTokenField.git\", majorVersion: 2)\n]\n```\n\n## Quick start\nInorder to implement this in a project just copy the files `NSTokenField+ACBExtension.swift`, `ACBAssociation.swift`, `ACBToken.swift`and invoke the following function on any `NSTokenField`. As mentioned above, no need to subclass or change anything in XIB or Storyboard file\n\n    tokenField.convertToACBTokenField()\n\nIf you would like to have clear button and/or search icon in tokenfield, you can copy the icons `ClearDarkGray` and `Glass` from Assets.xcassets. Otherwise you can use your own images and set the properties `clearIconName` and `searchIconName` of `NSTokenField`. You are good to go.\n\n_Note: Cell class will be dynamically changed to `ACBTokenFieldCell` and `delegate` will be set. Please do not modify these properties. Use `tokenDelegate` instead of `delegate`._\n\n## Setup\n\nThere are additional features which you can make use of such as setting an Array of token names list which represents token list at each index of token field. You don't have to implement the NSTokenField delegate in this case. This will take care of displaying suggestions/displaying menu on tokens/editing tokens etc. \n\n    tokenField.tokenKeywordsList = [[\"France\", \"Germany\", \"Italy\", \"USA\", \"Spain\", \"India\", \"Brazil\"],\n                                    [\"Pizza\", \"Pasta\", \"Butter Chicken\", \"Jamon\", \"Cheesecake\"],\n                                    [\"Deer\", \"Dog\", \"Bear\", \"Panda\", \"Jaguar\", \"Bull\"],\n                                    [\"Car\", \"Truck\", \"Bus\", \"Motorcycle\", \"Minivan\"]]\n        \nSet an array as shown above and it will show suggestions/menu based on the list above. Above list displays country names at index 0, food names at index 1, animal names at index 2 etc.. If you don't want to define token suggestions for each index separate like this, you can make use of below property to have default suggestions for all other indices except those present above.\n\n    tokenField.defaultTokenKeywords = [\"Red\", \"Blue\", \"Green\", \"White\", \"Purple\", \"Black\"]\n        \nThis will show default suggestions and token menu for all other tokens in tokenField whose index is not specified in `tokenKeywordsList`.\n\nYou can also set `leftView` property of token field to any `NSView` or subclass of `NSView`. For eg:- you can add an `NSButton` as `leftView` and have an action to set to it(See gif5).\n\n#### Setting properties\n\n    //set any required properties\n    tokenField.shouldEnableTokenMenu = true\n    tokenField.tokenDelegate = self\n    tokenField.leftView = lockButton\n    \n    tokenField.didDeleteTokenBlock = { (tokenIndex, _) in\n        print(\"Token at index = \", tokenIndex, \"is removed\")\n    }\n        \n#### Implement delegate\n\n    public func tokenField(_ tokenField: NSTokenField, completionsForSubstring substring: String, indexOfToken tokenIndex: Int, indexOfSelectedItem selectedIndex: UnsafeMutablePointer\u003cInt\u003e?) -\u003e [Any]? {\n        switch tokenIndex {\n            case 0:\n                return actors\n            case 1:\n                return actresses\n            case 2:\n                return movies\n            case 3:\n                return years\n            default:\n                return nil\n        }\n    }\n\n\n\n## Screenshots\n\u003ckbd\u003e\u003cdiv\u003e\u003cimg src=\"/ACBTokenField/Screenshots/ACBTokenFieldImage1.png?raw=true\" width=\"800\"\u003e\u003c/div\u003e\u003c/kbd\u003e\n\n## License\n\nMIT License\n\nCopyright (c) 2017, Akhil C Balan(https://github.com/akhilcb)\n\nAll rights reserved.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakhilcb%2Facbtokenfield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakhilcb%2Facbtokenfield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakhilcb%2Facbtokenfield/lists"}