slash-dw / tagging-kit
SlashDw shared tagging infrastructure for Laravel projects (Spatie laravel-tags based, multi-tenant + multi-locale + config-driven)
Requires
- php: ^8.5
- illuminate/contracts: ^13.0
- illuminate/database: ^13.0
- illuminate/http: ^13.0
- illuminate/support: ^13.0
- slash-dw/core-kit: ^0.0.4
- slash-dw/idempotency-kit: ^0.0.2
- spatie/laravel-tags: ^4.0
Requires (Dev)
- larastan/larastan: ^3.9
- laravel/pint: ^1.29
- orchestra/testbench: ^11.0
- phpunit/phpunit: ^12.0
README
Generic tagging infrastructure for Laravel. Spatie laravel-tags based, multi-tenant + multi-locale + config-driven. Mixed system/user tag model.
Status
π§ Active development β v0.0.x. Public API may change between minor versions. SemVer applies from v0.1.0.
This is a monorepo: the PHP backend lives at the root (Packagist:
slash-dw/tagging-kit) and the React frontend in js/ (npm:
@slash-dw/tagging-ui). See Frontend below.
Installation
composer require slash-dw/tagging-kit
Publish config (optional β defaults work out of the box):
php artisan vendor:publish --tag="tagging-kit-config"
Documentation
Detailed documentation is in progress. For now, see:
config/tagging-kit.phpβ all configuration options with inline commentssrc/Contracts/β public API interfaces (TagTypeContract,ActorContextContract,TenantContextContract,SharedTypesResolverContract)
Full README will be published with v0.1.0 (Faz 6).
Frontend β @slash-dw/tagging-ui
React/TypeScript companion in js/, published to npm as
@slash-dw/tagging-ui. Headless <TagAutocomplete> + hooks (debounce,
Fuse.js local-first, LRU cache, AbortController). Styling is host-owned via
data-tagging-* attributes + className.
Install
npm install @slash-dw/tagging-ui
npm install react @tanstack/react-query # peer deps
Bootstrap (once, at app entry)
import { configureTaggingUi, useTaggingBootstrap } from '@slash-dw/tagging-ui'; // Optional host overrides (win over backend /tagging/config defaults). configureTaggingUi({ baseUrl: '/api', // β {base}/tagging/{suggest,config,tags/:id} fetch: myCsrfAwareFetch, // optional auth-aware fetch wrapper i18n: { placeholder: 'Etiket ekleβ¦' }, hooks: { onUserTagDeleted: (t) => analytics.track('tag_deleted', t) }, }); function TaggingBootstrap() { useTaggingBootstrap(); // GET /api/tagging/config β internal store return null; }
Use the component
import { TagAutocomplete, type Tag } from '@slash-dw/tagging-ui'; function Form() { const [tags, setTags] = useState<Tag[]>([]); return <TagAutocomplete tagType={100} value={tags} onChange={setTags} />; }
Public API
| Kind | Exports |
|---|---|
| Components | TagAutocomplete, TagChip, TagSuggestionItem |
| Hooks | useTagAutocomplete, useTaggingBootstrap, useDeleteUserTag |
| Config | configureTaggingUi, getTaggingConfig |
| Low-level API | suggestTags, deleteUserTag, fetchTaggingConfig |
| Types | Tag, TagAutocompleteProps, TaggingConfig, TaggingDefaults, β¦ |
Config precedence (low β high): hardcoded β backend /tagging/config β
configureTaggingUi β per-component prop.
Develop the frontend
cd js npm install npm run ci # typecheck + vitest + vite build (ESM + CJS + d.ts)
Development (backend)
composer install
composer ci # runs lint + analyse + test
Individual scripts:
composer formatβ Pint auto-formatcomposer lintβ Pint check (no fix)composer analyseβ PHPStan level 8 (no baseline)composer testβ PHPUnit feature + unit + contract tests
License
MIT. See LICENSE.
Related packages
Part of the SlashDw kit ecosystem:
slash-dw/core-kitβ Repository + API response helpersslash-dw/error-kitβ Exception handlingslash-dw/filter-kitβ Eloquent filter/sort DSLslash-dw/idempotency-kitβ Per-route idempotency middlewareslash-dw/tagging-kitβ This package (PHP backend)@slash-dw/tagging-uiβ React frontend companion (NPM)