discourse/app/assets/stylesheets/common/admin
chapoi 2ca06ba236
DEV: form-kit
This PR introduces FormKit, a component-based form library designed to simplify form creation and management. This library provides a single `Form` component, various field components, controls, validation mechanisms, and customization options. Additionally, it includes helpers to facilitate testing and writing specifications for forms.

1. **Form Component**:
   - The main component that encapsulates form logic and structure.
   - Yields various utilities like `Field`, `Submit`, `Alert`, etc.

   **Example Usage**:
   ```gjs
   import Form from "discourse/form";

   <template>
     <Form as |form|>
       <form.Field
         @name="username"
         @title="Username"
         @validation="required"
         as |field|
       >
         <field.Input />
       </form.Field>

       <form.Field @name="age" @title="Age" as |field|>
         <field.Input @type="number" />
       </form.Field>

       <form.Submit />
     </Form>
   </template>
   ```

2. **Validation**:
   - Built-in validation rules such as `required`, `number`, `length`, and `url`.
   - Custom validation callbacks for more complex validation logic.

   **Example Usage**:
   ```javascript
   validateUsername(name, value, data, { addError }) {
     if (data.bar / 2 === value) {
       addError(name, "That's not how maths work.");
     }
   }
   ```

   ```hbs
   <form.Field @name="username" @validate={{this.validateUsername}} />
   ```

3. **Customization**:
   - Plugin outlets for extending form functionality.
   - Styling capabilities through propagated attributes.
   - Custom controls with properties provided by `form` and `field`.

   **Example Usage**:
   ```hbs
   <Form class="my-form" as |form|>
     <form.Field class="my-field" as |field|>
       <MyCustomControl id={{field.id}} @onChange={{field.set}} />
     </form.Field>
   </Form>
   ```

4. **Helpers for Testing**:
   - Test assertions for form and field validation.

   **Example usage**:
   ```javascript
   assert.form().hasErrors("the form shows errors");
   assert.form().field("foo").hasValue("bar", "user has set the value");
   ```

   - Helper for interacting with he form

   **Example usage**:
   ```javascript
   await formKit().field("foo").fillIn("bar");
   ```

5. **Page Object for System Specs**:
   - Page objects for interacting with forms in system specs.
   - Methods for submitting forms, checking alerts, and interacting with fields.

   **Example Usage**:
   ```ruby
   form = PageObjects::Components::FormKit.new(".my-form")
   form.submit
   expect(form).to have_an_alert("message")
   ```

   **Field Interactions**:
   ```ruby
   field = form.field("foo")
   expect(field).to have_value("bar")
   field.fill_in("bar")
   ```


6. **Collections handling**:
   - A specific component to handle array of objects

   **Example Usage**:
   ```gjs
    <Form @data={{hash foo=(array (hash bar=1) (hash bar=2))}} as |form|>
      <form.Collection @name="foo" as |collection|>
        <collection.Field @name="bar" @title="Bar" as |field|>
          <field.Input />
        </collection.Field>
      </form.Collection>
    </Form>
   ```
2024-07-17 11:59:35 +02:00
..
admin_base.scss DEV: form-kit 2024-07-17 11:59:35 +02:00
admin_config_area.scss FEATURE: created edit and delete flags (#27484) 2024-07-03 08:45:37 +10:00
admin_emojis.scss EXPERIMENTAL: restructure admin sidebar menu (#26047) 2024-03-13 10:18:08 +11:00
admin_intro.scss
admin_report_chart.scss A11Y: disable non-essential CSS animations for reduced-motion users (#23571) 2023-09-14 17:31:43 -04:00
admin_report_counters.scss
admin_report_inline_table.scss
admin_report_radar.scss DEV: Add support for radar charts when displaying reports. (#24274) 2023-11-08 10:48:12 -03:00
admin_report_stacked_chart.scss
admin_report_table.scss
admin_report.scss UX: Remove or replace button transitions with variable (#27527) 2024-06-20 19:51:20 +02:00
admin_reports.scss
api.scss FEATURE: Add Filter for Webhook Events by Status (#27332) 2024-06-07 10:26:00 -05:00
backups.scss UX: clean up some label and form inconsistencies, reduce excess bolding (#25701) 2024-02-15 11:27:51 -05:00
badges.scss DEV: form-kit 2024-07-17 11:59:35 +02:00
customize_themes_show_schema.scss UX: adjust objects editor styles for full page layout (#26265) 2024-03-20 15:55:52 -04:00
customize-install-theme.scss
customize.scss UX: remove default use of quaternary color, update nav pill styles (#27502) 2024-06-24 09:54:34 -04:00
dashboard.scss UX: remove default use of quaternary color, update nav pill styles (#27502) 2024-06-24 09:54:34 -04:00
emails.scss
flags.scss DEV: form-kit 2024-07-17 11:59:35 +02:00
json_schema_editor.scss
mini_profiler.scss A11Y: Adjust contrast and font size for mini profiler widget (#22246) 2023-06-22 18:01:21 -04:00
penalty.scss
plugins.scss UX: remove redundant nav-pill active border (#27649) 2024-06-28 16:29:50 -04:00
schema_field.scss UX: minor style adjustments for schema objects editor (#26444) 2024-04-01 12:43:19 -04:00
schema_theme_setting_editor.scss UX: Improve validation error message when saving theme objects setting (#26455) 2024-04-02 11:55:51 +08:00
settings.scss UX: Change the color of the overriden dot to be slightly visible in dark mode (#25782) 2024-02-21 12:49:20 +08:00
sidebar.scss FIX: Bold admin sidebar headings (#27912) 2024-07-15 16:31:16 +10:00
staff_logs.scss DEV: removes unused modal-tab (#27869) 2024-07-11 11:55:25 +02:00
users.scss