feat(admin): implement DataTableToolbar component with Storybook stories #215#463
Conversation
- Add noFilterText prop to externalize hardcoded 'No filter' string - Remove hardcoded aria-label default value - Ensure all user-facing text is externalized as props
…nteractions - Add filterCloseOnSelect prop to control dropdown close behavior - Fix Button component usage in filter content (remove class prop that breaks DaisyUI classes) - Add event propagation handling for Tag clicks in filter dropdown - Document raw HTML usage in stories according to AGENTS.md
husamettinarabaci
left a comment
There was a problem hiding this comment.
Request Changes: Component Composition Violation
Thank you for the comprehensive implementation! The PR is high-quality overall, but there's one critical component composition issue that needs to be addressed before merging.
❌ Issue: Raw HTML Input Instead of Library Component
Location: DataTableToolbar.svelte:500-519
The component currently uses a raw HTML <input> element instead of the library's Input component:
<!-- Current Implementation - INCORRECT -->
<input
type="search"
bind:value={searchValue}
placeholder={searchPlaceholder}
disabled={disabled || loading}
aria-label={searchAriaLabel}
oninput={handleSearchInput}
onkeydown={handleSearchKeydown} // ❌ This is why raw HTML was used
class={[...].join(' ')}
/>Reason Given: Input component doesn't support onkeydown prop.
🎯 Required Changes
Per AGENTS.md Component Composition Rules (lines 196-217, 373-413):
⚠️ CRITICAL PRIORITY RULE: Library components MUST be used unless TECHNICALLY IMPOSSIBLE.Decision Tree Step 3: Can the library component be extended/modified to support your needs?
- YES → Modify the component first. Do NOT bypass it. STOP HERE.
Solution: Extend the Input Component
1. Add onkeydown prop to Input component:
// In Input.svelte Props interface
interface Props {
// ... existing props
onkeydown?: (event: KeyboardEvent) => void;
}
// In the input element
<input
onkeydown={onkeydown}
{...otherProps}
/>2. Update DataTableToolbar to use Input component:
<Input
type="search"
bind:value={searchValue}
placeholder={searchPlaceholder}
disabled={disabled || loading}
ariaLabel={searchAriaLabel}
oninput={handleSearchInput}
onkeydown={handleSearchKeydown} // ✅ Now supported
size={searchSize}
class="w-full"
/>📚 Why This Matters
From AGENTS.md (lines 274-283):
Example Scenario:
If you add aloadingstate to theButtoncomponent, and all composite components use<Button>internally, every button across the library automatically gets the loading feature.If you use raw HTML:
- You have to manually update every component
- Features become inconsistent
- Maintenance becomes a nightmare
- Bugs multiply across the codebase
By using the Input component:
- Future Input enhancements (validation, icons, error states) automatically propagate
- Maintains consistency across the library
- Follows the established architecture pattern
✅ Everything Else Looks Great!
The rest of the implementation is excellent:
- ✅ All other components properly use library primitives (Button, Text, Badge, etc.)
- ✅ No hardcoded strings (i18n-ready)
- ✅ Comprehensive Storybook coverage (11 stories)
- ✅ TypeScript strictly typed
- ✅ Accessibility best practices
- ✅ DaisyUI static classes only
- ✅ Proper documentation
📋 Action Items
- Add
onkeydownprop toInput.sveltecomponent - Replace raw HTML
<input>with<Input>component inDataTableToolbar.svelte - Remove the raw HTML justification comment (lines 492-499)
- Verify all functionality still works (Enter key search)
- Update if Input component changes affect other files
Once these changes are made, this PR will be ready to merge! 🚀
Reference: AGENTS.md - Component Composition & Reusability Principle (lines 196-479)
- Add onkeydown prop to Input component Props interface - Support KeyboardEvent handling for Enter key and other keyboard interactions - Follows AGENTS.md component composition extension pattern
- Replace raw HTML input element with Input component - Remove raw HTML justification comment - Use Input component's onkeydown prop for Enter key handling - Follows AGENTS.md component composition rules
Pull Request
📄 Summary
This PR extends DataTableToolbar with loading state support, improved filter behavior, and i18n-ready text handling.
The implementation follows AGENTS.md (composition-first, accessibility, Svelte 5 runes).
✨ Key Changes
Loading state
loadingprop withSpinnerloadingAriaLabelfor screen readersFilter improvements
filterCloseOnSelectpropnoFilterTextexternalized for i18nfilterMinWidth)Storybook
🧩 Affected Module(s)
🔗 Related Issues
Closes #215
✅ Checklist
feat)💬 Notes
$props,$state,$derived)src/lib/index.ts