discourse/app/assets/stylesheets/common/components
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
..
sidebar/edit-navigation-menu UX: clean up some label and form inconsistencies, reduce excess bolding (#25701) 2024-02-15 11:27:51 -05:00
_index.scss FEATURE: Introduce DBreadcrumbs components (#27049) 2024-05-20 14:25:54 +10:00
add-pm-participants.scss DEV: update classes, remove unused CSS (#25825) 2024-02-23 09:14:37 -05:00
badges.scss UX: allow category names in select-kit to truncate if needed (#27941) 2024-07-16 17:52:17 -04:00
banner.scss
bookmark-list.scss DEV: Use more css vars (#18561) 2022-10-12 16:05:42 +02:00
bookmark-menu.scss DEV: implements <DropdownMenu /> (#26917) 2024-05-08 09:08:42 +02:00
bookmark-modal.scss UX: improves modal on mobile (#26055) 2024-03-22 16:29:32 +01:00
buttons.scss UX: Remove or replace button transitions with variable (#27527) 2024-06-20 19:51:20 +02:00
calendar-date-time-input.scss DEV: Move calendar date + time picker from local dates into core component (#23023) 2023-08-11 13:05:44 +10:00
char-counter.scss FEATURE: Add word count and indicator when exceeded max (#19367) 2023-02-20 12:06:43 +01:00
color-input.scss PERF: eliminate some slow CSS selectors (#25392) 2024-01-26 13:10:45 -05:00
conditional-loading-section.scss A11Y: disable non-essential CSS animations for reduced-motion users (#23571) 2023-09-14 17:31:43 -04:00
convert-to-public-topic-modal.scss
d-breadcrumbs.scss UX: Implement new top-level nav on admin plugin pages (#27126) 2024-05-29 12:20:55 +10:00
d-lightbox.scss FIX: remove background image from lightbox backdrop (#24225) 2023-11-03 16:10:04 +08:00
d-toggle-switch.scss DEV: form-kit 2024-07-17 11:59:35 +02:00
date-input.scss
date-picker.scss
date-time-input-range.scss
date-time-input.scss
download-calendar.scss DEV: FloatKit (#23650) 2023-09-26 13:39:52 +02:00
dropdown-menu.scss DEV: implements <DropdownMenu /> (#26917) 2024-05-08 09:08:42 +02:00
file-size-input.scss DEV: Add file_size_restriction site setting type (#24704) 2023-12-13 16:22:48 -07:00
footer-nav.scss FIX: better supports ipad and hub footer nav (#25518) 2024-02-01 10:24:44 +01:00
form-template-field.scss FEATURE: support a description attribute on form template fields (#23744) 2023-10-04 17:51:53 -03:00
group-member-dropdown.scss DEV: Set containing block for Popper dropdowns (#20745) 2023-03-20 15:26:20 -04:00
groups-form-membership-fields.scss
hashtag.scss UX: Tweak the mention padding (#26492) 2024-04-05 22:23:37 +02:00
horizontal-overflow-nav.scss UX: remove default use of quaternary color, update nav pill styles (#27502) 2024-06-24 09:54:34 -04:00
iframed-html.scss
ignored-user-list.scss UX: fix color preference layout (#21346) 2023-05-03 10:11:52 +08:00
keyboard_shortcuts.scss UX: remove default use of quaternary color, update nav pill styles (#27502) 2024-06-24 09:54:34 -04:00
more-topics.scss UX: spacing fix for related topics on mobile (#27940) 2024-07-16 17:51:55 -04:00
navs.scss UX: remove default use of quaternary color, update nav pill styles (#27502) 2024-06-24 09:54:34 -04:00
offline-indicator.scss FEATURE: Offline indicator (#21369) 2023-06-05 11:08:04 -05:00
pick-files-button.scss
powered-by-discourse.scss UX: hide "powered by" from account activation page (#26298) 2024-03-21 15:39:37 -04:00
relative-time-picker.scss UX: minor fixes in topic action modal (#24772) 2023-12-07 14:54:56 +01:00
svg.scss
tap-tile.scss UX: highlight vars updates (#20346) 2023-02-21 10:15:49 +01:00
time-input.scss
time-shortcut-picker.scss UX: fix time pickers input width on mobile (#21170) 2023-04-19 10:08:24 -05:00
topic-query-filter.scss UX: Make input on /filter route full width (#20952) 2023-04-04 14:10:39 +10:00
user-card.scss A11Y: remove heading tags from usercards (#27926) 2024-07-16 12:32:53 -04:00
user-info.scss UX: add space to following list (#27154) 2024-05-23 17:26:15 +04:00
user-status-message.scss FIX: Add the ident to fix user status styling in posts (#26585) 2024-04-10 01:44:37 +02:00
user-status-picker.scss UX: update appropriate btn-flat instances to btn-transparent (#25945) 2024-02-29 11:47:07 +01:00
user-stream-item.scss UX: fix only-emoji size in user-stream excerpts (#27330) 2024-06-04 14:59:43 -04:00
user-stream.scss
widget-dropdown.scss REFACTOR: improve poll info layout (#22353) 2023-07-05 12:20:18 -04:00