2021-04-13 00:48:01 +08:00
|
|
|
.poll-ui-builder-modal {
|
|
|
|
.show-advanced {
|
|
|
|
margin-left: auto;
|
|
|
|
margin-right: 0;
|
2019-08-13 21:49:40 +08:00
|
|
|
}
|
2021-04-13 00:48:01 +08:00
|
|
|
}
|
2019-08-13 21:49:40 +08:00
|
|
|
|
2021-04-13 00:48:01 +08:00
|
|
|
.poll-ui-builder {
|
2016-06-13 18:21:14 +08:00
|
|
|
label {
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
2021-04-13 00:48:01 +08:00
|
|
|
.input-group {
|
|
|
|
margin-bottom: 15px;
|
|
|
|
|
|
|
|
input[type="number"],
|
|
|
|
input[type="text"],
|
|
|
|
input[type="time"],
|
|
|
|
.combo-box,
|
|
|
|
.multi-select,
|
|
|
|
.select-kit-header,
|
|
|
|
.date-picker-wrapper {
|
|
|
|
width: 100%;
|
|
|
|
}
|
2018-05-30 14:26:06 +08:00
|
|
|
|
2021-04-13 00:48:01 +08:00
|
|
|
.date-picker-wrapper {
|
|
|
|
margin-right: 5px;
|
|
|
|
}
|
2016-06-15 21:21:17 +08:00
|
|
|
|
2023-11-13 06:07:51 +08:00
|
|
|
&:last-child {
|
|
|
|
margin-bottom: 0;
|
2021-04-13 00:48:01 +08:00
|
|
|
}
|
2020-02-18 00:02:44 +08:00
|
|
|
}
|
|
|
|
|
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 17:59:35 +08:00
|
|
|
.poll-public .d-toggle-switch__label {
|
2023-11-13 06:07:51 +08:00
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
|
|
|
|
2021-04-13 00:48:01 +08:00
|
|
|
.radio-group {
|
|
|
|
display: inline-block;
|
|
|
|
margin-right: 30px;
|
2018-05-30 21:00:54 +08:00
|
|
|
|
|
|
|
input {
|
2021-04-13 00:48:01 +08:00
|
|
|
vertical-align: top;
|
|
|
|
}
|
|
|
|
|
|
|
|
label {
|
|
|
|
display: inline-block;
|
2018-05-30 21:00:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-13 00:48:01 +08:00
|
|
|
.poll-type {
|
2024-07-17 17:49:14 +08:00
|
|
|
.poll-type-value {
|
|
|
|
font-size: var(--font-down-1);
|
|
|
|
}
|
2024-06-24 21:54:34 +08:00
|
|
|
padding: 0;
|
|
|
|
margin-top: 0;
|
|
|
|
border: none;
|
2020-02-18 00:02:44 +08:00
|
|
|
}
|
|
|
|
|
2021-04-13 00:48:01 +08:00
|
|
|
.poll-options {
|
|
|
|
margin-bottom: 15px;
|
|
|
|
|
|
|
|
.poll-option-value {
|
2023-08-02 18:55:25 +08:00
|
|
|
align-items: flex-start;
|
2021-04-13 00:48:01 +08:00
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
2023-08-02 18:55:25 +08:00
|
|
|
margin-bottom: 0;
|
2021-04-13 00:48:01 +08:00
|
|
|
|
|
|
|
button {
|
2023-08-02 18:55:25 +08:00
|
|
|
margin-left: 0.5rem;
|
2021-04-13 00:48:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.poll-option-controls {
|
|
|
|
margin-top: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tip {
|
|
|
|
display: inline-block;
|
|
|
|
vertical-align: bottom;
|
|
|
|
}
|
2020-10-02 15:21:24 +08:00
|
|
|
}
|
|
|
|
|
2021-04-13 00:48:01 +08:00
|
|
|
.tip {
|
|
|
|
display: block;
|
2022-10-12 21:31:59 +08:00
|
|
|
font-size: var(--font-down-1);
|
2021-04-13 00:48:01 +08:00
|
|
|
margin: -0.5em 0 0.5em;
|
2016-06-13 18:21:14 +08:00
|
|
|
}
|
|
|
|
|
2021-04-13 00:48:01 +08:00
|
|
|
.d-editor-preview {
|
|
|
|
width: 100%;
|
2016-06-13 18:21:14 +08:00
|
|
|
}
|
|
|
|
}
|