Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 0 additions & 20 deletions .github/coverage.svg

This file was deleted.

108 changes: 0 additions & 108 deletions .github/workflows/run-tests.yml

This file was deleted.

146 changes: 146 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: tests

on:
push:
branches:
- main
- next-gen
pull_request:

jobs:
tests:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php: ['8.4', '8.5']
laravel: ['12.*', '13.*']
stability: [prefer-lowest, prefer-stable]
include:
- laravel: '12.*'
testbench: '10.*'
- laravel: '13.*'
testbench: '11.*'

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.stability }}

env:
COVERAGE: ${{ matrix.php == '8.4' && matrix.laravel == '13.*' && matrix.stability == 'prefer-stable' }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv, intl
coverage: ${{ env.COVERAGE == 'true' && 'xdebug' || 'none' }}

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --dev --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

- name: Execute tests
run: vendor/bin/phpunit ${{ env.COVERAGE == 'true' && '--coverage-clover=clover.xml' || '' }}

- name: Upload coverage to Codecov
if: env.COVERAGE == 'true'
uses: codecov/codecov-action@v5
with:
files: clover.xml
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}

pint:
runs-on: ubuntu-latest

name: Pint

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: none

- name: Install dependencies
run: composer update --prefer-dist --no-interaction --no-progress

- name: Check code style
run: vendor/bin/pint --test

- name: No javaabu/settings or javaabu/helpers in production dependencies
run: |
if composer show --tree --no-dev | grep -E 'javaabu/(settings|helpers)'; then
echo "javaabu/forms must not require javaabu/settings or javaabu/helpers (see #18)"
exit 1
fi

- name: Boost component reference is up to date
run: |
php scripts/components-reference.php
git diff --exit-code -- resources/boost

assets:
runs-on: ubuntu-latest

name: Assets

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: none

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Lint
run: pnpm lint

- name: Check formatting
run: pnpm format:check

- name: Type check
run: pnpm typecheck

- name: Execute tests
run: pnpm test --coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: coverage/clover.xml
flags: js
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}

- name: Onu classes match @javaabu/onu
run: pnpm check

- name: Built files are up to date
run: |
pnpm icons
pnpm locales
pnpm build
git diff --exit-code -- resources/icons resources/js/locales dist
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ coverage
.php-cs-fixer.cache
clover.xml
coverage.xml
node_modules
35 changes: 0 additions & 35 deletions .php_cs.dist.php

This file was deleted.

7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dist
coverage
node_modules
vendor
build
pnpm-lock.yaml
resources/js/locales
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"printWidth": 120,
"tabWidth": 2
}
47 changes: 47 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Forms: notes for AI coding agents

`javaabu/forms` is a set of Laravel Blade components (`<x-forms::…>`) for forms and admin pages, with model binding, old input and validation errors. v2 renders for two frameworks, `onu` (Tailwind with `@javaabu/onu`'s classes, the default) and `bootstrap-6`, and has a React twin, `@javaabu/forms` (`Javaabu/react-forms`), with the same components and attributes.

## Layout

| Path | What |
| --- | --- |
| `src/Views/Components` | One class per component. Constructor parameters are the attributes; public methods and properties reach the view. `Component` is the base: framework, view resolution, ids, labels, icons, shared field options, assets. |
| `src/Frameworks` | `Framework` contract, `Onu` and `Bootstrap6` class maps (colours → classes), `Frameworks` registry |
| `src/Assets/Assets.php` | The only code that knows javaabu/manifest's registration API: the package's JS/CSS assets |
| `src/Support` | Traits for binding, old input, errors, media and formatting; `Settings` defaults; `Icons\Svg` |
| `resources/views/{onu,bootstrap-6}` | Per-framework views; `resources/views/common` is the fallback for both |
| `resources/onu/classes.php` | Generated by `scripts/onu-classes.mjs` from Onu's React components. Never edit by hand. |
| `resources/icons/icons.php` | Generated by `scripts/icons.mjs` from `lucide-static`. Never edit by hand. |
| `resources/js`, `resources/css` | Browser behaviours (TypeScript, no jQuery) and styles, built into `dist/` (committed) |
| `lang/{en,dv}` | Every user-facing string. Keys match `@javaabu/forms`' locales. |
| `docs`, `llms.txt` | Docusaurus pages and the index for AI assistants, both shipped in the package |
| `resources/boost` | Laravel Boost guideline and skill |
| `tests/Feature`, `tests/Unit`, `tests/TestSupport/views` | PHPUnit + BrowserKit tests and fixture views |

## Rules

- **Component names and attributes are a public API** used by every next-gen package. Don't rename or remove one; add new attributes with defaults that keep current output.
- **Both frameworks, always.** A markup change goes in `resources/views/onu` and `resources/views/bootstrap-6` (or `common` when the markup has no framework classes). `FrameworkSmokeTest` renders every fixture view with every framework.
- **Onu classes come from Onu.** Use `$frameworkClasses()->classes('slot.key')`; if a class you need is missing, extend `scripts/onu-classes.mjs` to capture it from Onu's own component and run `pnpm onu-classes`. Don't type Onu class strings into views.
- **Parity with React.** New components or attributes must match `@javaabu/forms` (camelCase there). Update `docs/parity.md`, and open a `cross-package` issue in `Javaabu/react-forms` when they differ.
- **Shared field options** (`form-group-class`, `thaana`, `auto-resize`, `decimals`) are read from the attribute bag in `Component::withAttributes()`. Views read them through methods (`$groupClass()`, `$thaanaAttributes()`, …) because Blade captures properties before `withAttributes()` runs.
- **No hard-coded text.** Strings go in `lang/en/strings.php` and `lang/dv/strings.php` (real Dhivehi; list uncertain lines in `docs/advanced-usage/translations-and-rtl.md`), using the same key as `@javaabu/forms` when one exists.
- **RTL:** logical utilities only (`ms-`, `pe-`, `start-`, `text-start`); never `left`/`right`.
- **Assets:** a component declares what it needs by overriding `assets()` (names from `Assets`). Don't push `<script>` tags from views, except third-party scripts that need config (Google Maps, TinyMCE) through `forms::partials.assets`.
- PHP follows Javaabu's guidelines (`vendor/javaabu/boost-javaabu-guidelines`): Pint, `#[Test]` and `it_…` test names, snake_case variables. Component constructor parameters stay camelCase, because Blade maps kebab-case attributes to them.
- Every change needs tests (Thaana text in user-facing cases), docs (and `llms.txt` for new pages), and a `CHANGELOG.md` line.
- Work happens on `next-gen` until v2 is merged; never commit to `main`.

## Commands

```bash
composer install && pnpm install
composer test # PHPUnit
composer lint # Pint (composer format to fix)
pnpm lint && pnpm format:check && pnpm typecheck && pnpm test
pnpm build # dist/: JS, CSS, Vite manifest
pnpm onu-classes # regenerate resources/onu/classes.php after upgrading @javaabu/onu
pnpm icons # regenerate resources/icons/icons.php
pnpm check # CI: Onu classes match the installed @javaabu/onu
```
Loading
Loading