@ticatec/uniface-element 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +320 -1
- package/README_CN.md +392 -0
- package/dist/accordion/Accordion.svelte +1 -1
- package/dist/action-bar/ActionBar.svelte +7 -1
- package/dist/attachment-files/FileRender.svelte +1 -1
- package/dist/attachment-files/FileUploadBar.svelte +7 -6
- package/dist/attachment-files/FileUploadPanel.svelte +2 -2
- package/dist/base-calendar/DateContext.js +5 -4
- package/dist/base-calendar/YearPickupPanel.svelte +4 -4
- package/dist/card/Card.svelte +1 -1
- package/dist/card/Card.svelte.d.ts +1 -1
- package/dist/cascade-options-select/CascadeOptionSelect.svelte +2 -3
- package/dist/cascade-options-select/CascadeOptionSelect.svelte.d.ts +46 -1
- package/dist/cascade-options-select/CascadePanel.svelte +1 -1
- package/dist/checkbox/CheckBox.svelte +1 -1
- package/dist/color-picker/ColorPicker.svelte +9 -9
- package/dist/color-picker/ColorPicker.svelte.d.ts +0 -2
- package/dist/color-picker/ColorPickerPanel.svelte +11 -15
- package/dist/color-picker/ColorPickerPanel.svelte.d.ts +1 -1
- package/dist/common/CommonPicker.svelte +2 -2
- package/dist/common/CommonPicker.svelte.d.ts +1 -1
- package/dist/common/MouseClickHandler.d.ts +1 -1
- package/dist/common/Popover.svelte +28 -6
- package/dist/common/Popover.svelte.d.ts +9 -3
- package/dist/common/uniface-utils.js +6 -4
- package/dist/common-editor/CommonEditor.svelte +1 -1
- package/dist/common-editor/CommonEditor.svelte.d.ts +1 -1
- package/dist/common-editor/NumberInput.svelte +1 -1
- package/dist/common-editor/NumberInput.svelte.d.ts +1 -1
- package/dist/concise-data-table/ConciseListTable.svelte +7 -2
- package/dist/concise-data-table/ConciseListTable.svelte.d.ts +1 -0
- package/dist/concise-data-table/DataRow.svelte +1 -1
- package/dist/concise-data-table/TableOptions.d.ts +1 -1
- package/dist/data-table/DataTable.svelte +1 -1
- package/dist/data-table/parts/ActionsPanel.svelte +4 -3
- package/dist/data-table/parts/ActionsRow.svelte +3 -3
- package/dist/data-table/parts/ContentPanel.svelte +3 -2
- package/dist/data-table/parts/FixedColumnsPanel.svelte +0 -1
- package/dist/data-table/parts/FixedColumnsPanel.svelte.d.ts +1 -2
- package/dist/data-table/parts/FixedHeaderPanel.svelte +2 -2
- package/dist/data-table/parts/FixedRow.svelte +2 -1
- package/dist/data-table/parts/FixedRow.svelte.d.ts +1 -1
- package/dist/data-table/parts/HrefCell.svelte +23 -2
- package/dist/data-table/parts/PopupMenu.svelte +25 -2
- package/dist/data-table/parts/PopupMenu.svelte.d.ts +8 -1
- package/dist/date-picker/DatePicker.svelte +0 -1
- package/dist/date-picker/DateTimePicker.svelte +3 -3
- package/dist/date-picker/ScrollBar.svelte +4 -7
- package/dist/date-range/DateRangeEditor.svelte +1 -1
- package/dist/dialog/CommonDialog.svelte +8 -5
- package/dist/dialog/CommonDialog.svelte.d.ts +2 -1
- package/dist/dialog/Dialog.svelte +37 -12
- package/dist/dialog/Dialog.svelte.d.ts +4 -3
- package/dist/dialog/DialogBoard.svelte +11 -8
- package/dist/dialog/DialogWrapper.svelte +10 -0
- package/dist/{common-editor/DateInput.svelte.d.ts → dialog/DialogWrapper.svelte.d.ts} +6 -13
- package/dist/dialog/Dialogs.js +1 -1
- package/dist/dialog/ModalResult.d.ts +5 -0
- package/dist/dialog/ModalResult.js +5 -0
- package/dist/drawer/Drawer.svelte +1 -1
- package/dist/form-field/FormField.svelte +2 -1
- package/dist/form-field/FormField.svelte.d.ts +1 -0
- package/dist/form-panel/flex-row-form/FormContainer.svelte +1 -1
- package/dist/form-panel/grid-form/EmptyCell.svelte +8 -7
- package/dist/form-panel/grid-form/EmptyCell.svelte.d.ts +2 -2
- package/dist/form-panel/grid-form/GridField.svelte +1 -1
- package/dist/i18nRes/i18nRes.d.ts +2 -0
- package/dist/i18nRes/i18nRes.js +44 -0
- package/dist/i18nRes/index.d.ts +2 -0
- package/dist/i18nRes/index.js +2 -0
- package/dist/image-files/ImageFilesField.svelte +1 -1
- package/dist/indicator/IndicatorBoard.svelte +1 -1
- package/dist/inline-cell-editor/InvalidEditor.svelte +1 -0
- package/dist/input-options-select/InputOptionsSelect.svelte +6 -6
- package/dist/input-options-select/InputOptionsSelect.svelte.d.ts +1 -1
- package/dist/layout/flex/FlexBlock.svelte +1 -1
- package/dist/lookup-editor/LookupEditor.svelte +1 -1
- package/dist/memo-editor/MemoEditor.svelte +2 -2
- package/dist/message-box/IMessageBox.d.ts +2 -4
- package/dist/message-box/IMessageBox.js +4 -6
- package/dist/message-box/MessageBoxBoard.svelte +1 -3
- package/dist/options-multi-select/OptionsMultiSelect.svelte +1 -1
- package/dist/prompts-text-editor/PromptsTextEditor.svelte +2 -2
- package/dist/prompts-text-editor/PromptsTextEditor.svelte.d.ts +1 -1
- package/dist/property-editor/PropertyEditor.svelte +3 -3
- package/dist/text-editor/PasswordEditor.svelte +1 -1
- package/dist/transfer/Transfer.svelte +17 -12
- package/dist/transfer/Transfer.svelte.d.ts +0 -1
- package/dist/unit-number-editor/UnitNumberEditor.svelte +2 -2
- package/docs/buttons/cn/ActionBar.md +459 -0
- package/docs/buttons/cn/Button.md +228 -0
- package/docs/buttons/cn/IconButton.md +294 -0
- package/docs/buttons/cn/README.md +600 -0
- package/docs/buttons/cn/TextButton.md +163 -0
- package/docs/buttons/en/ActionBar.md +459 -0
- package/docs/buttons/en/Button.md +228 -0
- package/docs/buttons/en/IconButton.md +294 -0
- package/docs/buttons/en/README.md +600 -0
- package/docs/buttons/en/TextButton.md +163 -0
- package/docs/containers/cn/accordion.md +622 -0
- package/docs/containers/cn/box.md +445 -0
- package/docs/containers/cn/card.md +404 -0
- package/docs/containers/cn/page.md +576 -0
- package/docs/containers/cn/tabs.md +686 -0
- package/docs/containers/en/accordion.md +622 -0
- package/docs/containers/en/box.md +445 -0
- package/docs/containers/en/card.md +404 -0
- package/docs/containers/en/page.md +576 -0
- package/docs/containers/en/tabs.md +686 -0
- package/docs/data-display/cn/concise-data-table.md +731 -0
- package/docs/data-display/cn/listbox.md +786 -0
- package/docs/data-display/cn/treeview.md +863 -0
- package/docs/data-display/en/concise-data-table.md +732 -0
- package/docs/data-display/en/listbox.md +786 -0
- package/docs/data-display/en/treeview.md +863 -0
- package/docs/data-table/cn/README.md +596 -0
- package/docs/data-table/en/README.md +596 -0
- package/docs/dialog/cn/README.md +767 -0
- package/docs/dialog/en/README.md +767 -0
- package/docs/form/cn/README.md +847 -0
- package/docs/form/en/README.md +847 -0
- package/docs/form-components/cn/README.md +495 -0
- package/docs/form-components/cn/attachmentfilesfield.md +757 -0
- package/docs/form-components/cn/cascade-options-select.md +374 -0
- package/docs/form-components/cn/checkbox.md +58 -0
- package/docs/form-components/cn/date-picker.md +138 -0
- package/docs/form-components/cn/datetime-picker.md +228 -0
- package/docs/form-components/cn/group-checkbox.md +405 -0
- package/docs/form-components/cn/group-radiobox.md +525 -0
- package/docs/form-components/cn/imagefilesfield.md +651 -0
- package/docs/form-components/cn/input-options-select.md +250 -0
- package/docs/form-components/cn/lookup-editor.md +406 -0
- package/docs/form-components/cn/memoeditor.md +409 -0
- package/docs/form-components/cn/number-editor.md +261 -0
- package/docs/form-components/cn/options-multi-select.md +177 -0
- package/docs/form-components/cn/options-select.md +83 -0
- package/docs/form-components/cn/passwordeditor.md +538 -0
- package/docs/form-components/cn/prompts-text-editor.md +241 -0
- package/docs/form-components/cn/radiobutton.md +84 -0
- package/docs/form-components/cn/switch.md +178 -0
- package/docs/form-components/cn/text-editor.md +142 -0
- package/docs/form-components/cn/time-editor.md +159 -0
- package/docs/form-components/cn/unit-number-editor.md +164 -0
- package/docs/form-components/en/README.md +463 -0
- package/docs/form-components/en/attachmentfilesfield.md +757 -0
- package/docs/form-components/en/cascade-options-select.md +358 -0
- package/docs/form-components/en/checkbox.md +59 -0
- package/docs/form-components/en/date-picker.md +138 -0
- package/docs/form-components/en/datetime-picker.md +228 -0
- package/docs/form-components/en/group-checkbox.md +395 -0
- package/docs/form-components/en/group-radiobox.md +498 -0
- package/docs/form-components/en/imagefilesfield.md +651 -0
- package/docs/form-components/en/input-options-select.md +239 -0
- package/docs/form-components/en/lookup-editor.md +389 -0
- package/docs/form-components/en/memoeditor.md +409 -0
- package/docs/form-components/en/number-editor.md +249 -0
- package/docs/form-components/en/options-multi-select.md +177 -0
- package/docs/form-components/en/options-select.md +83 -0
- package/docs/form-components/en/passwordeditor.md +538 -0
- package/docs/form-components/en/prompts-text-editor.md +241 -0
- package/docs/form-components/en/radiobutton.md +84 -0
- package/docs/form-components/en/switch.md +180 -0
- package/docs/form-components/en/text-editor.md +142 -0
- package/docs/form-components/en/time-editor.md +159 -0
- package/docs/form-components/en/unit-number-editor.md +164 -0
- package/docs/form-layout/cn/criteria-field.md +652 -0
- package/docs/form-layout/cn/flex-form.md +454 -0
- package/docs/form-layout/cn/flex-row-form.md +542 -0
- package/docs/form-layout/cn/form-field.md +923 -0
- package/docs/form-layout/cn/grid-form.md +676 -0
- package/docs/form-layout/en/criteria-field.md +652 -0
- package/docs/form-layout/en/flex-form.md +454 -0
- package/docs/form-layout/en/flex-row-form.md +542 -0
- package/docs/form-layout/en/form-field.md +923 -0
- package/docs/form-layout/en/grid-form.md +676 -0
- package/docs/global/cn/README.md +534 -0
- package/docs/global/en/README.md +534 -0
- package/docs/layout/cn/classiclayout.md +460 -0
- package/docs/layout/cn/headerlayout.md +524 -0
- package/docs/layout/cn/sidebarlayout.md +263 -0
- package/docs/layout/en/classiclayout.md +951 -0
- package/docs/layout/en/headerlayout.md +524 -0
- package/docs/layout/en/sidebarlayout.md +262 -0
- package/docs/misc/cn/README.md +1217 -0
- package/docs/misc/en/README.md +1217 -0
- package/docs/navigation/cn/breadcrumb.md +291 -0
- package/docs/navigation/cn/navigator.md +322 -0
- package/docs/navigation/cn/navigatormenu.md +512 -0
- package/docs/navigation/cn/progressbar.md +199 -0
- package/docs/navigation/cn/progressstepbar.md +299 -0
- package/docs/navigation/en/breadcrumb.md +291 -0
- package/docs/navigation/en/navigator.md +322 -0
- package/docs/navigation/en/navigatormenu.md +512 -0
- package/docs/navigation/en/progressbar.md +199 -0
- package/docs/navigation/en/progressstepbar.md +299 -0
- package/docs/search-filters/cn/daterange.md +1156 -0
- package/docs/search-filters/cn/numberrange.md +688 -0
- package/docs/search-filters/cn/searchbox.md +1582 -0
- package/docs/search-filters/en/daterange.md +1156 -0
- package/docs/search-filters/en/numberrange.md +688 -0
- package/docs/search-filters/en/searchbox.md +1582 -0
- package/package.json +53 -13
- package/dist/common-editor/DateInput.svelte +0 -27
- package/dist/i18n_resources/index.d.ts +0 -3
- package/dist/i18n_resources/index.js +0 -3
- /package/dist/{i18n_resources → i18nRes}/uniface_cn_resource.d.ts +0 -0
- /package/dist/{i18n_resources → i18nRes}/uniface_cn_resource.js +0 -0
- /package/dist/{i18n_resources → i18nRes}/uniface_en_resource.d.ts +0 -0
- /package/dist/{i18n_resources → i18nRes}/uniface_en_resource.js +0 -0
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
# FlexForm Component
|
|
2
|
+
|
|
3
|
+
Flexible form layout component providing a flexible form container with support for both vertical and horizontal field layout modes.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
| Property | Type | Default | Description |
|
|
8
|
+
|----------|------|---------|-------------|
|
|
9
|
+
| `style` | `string` | `''` | Custom styles |
|
|
10
|
+
| `fieldLayout` | `'vertical' \| 'horizontal'` | `'vertical'` | Field layout direction |
|
|
11
|
+
|
|
12
|
+
## Usage Examples
|
|
13
|
+
|
|
14
|
+
### Basic Vertical Layout Form
|
|
15
|
+
|
|
16
|
+
```svelte
|
|
17
|
+
<script lang="ts">
|
|
18
|
+
import FlexForm, FormField, TextEditor, NumberEditor from '@ticatec/uniface-element/FlexForm, FormField, TextEditor, NumberEditor';
|
|
19
|
+
|
|
20
|
+
let formData = {
|
|
21
|
+
name: '',
|
|
22
|
+
email: '',
|
|
23
|
+
age: null as number | null
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const handleSubmit = (): void => {
|
|
27
|
+
console.log('Submit form data:', formData);
|
|
28
|
+
};
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<FlexForm fieldLayout="vertical">
|
|
32
|
+
<FormField label="Name" required>
|
|
33
|
+
<TextEditor
|
|
34
|
+
placeholder="Enter your name"
|
|
35
|
+
bind:value={formData.name}
|
|
36
|
+
/>
|
|
37
|
+
</FormField>
|
|
38
|
+
|
|
39
|
+
<FormField label="Email">
|
|
40
|
+
<TextEditor
|
|
41
|
+
placeholder="Enter your email"
|
|
42
|
+
bind:value={formData.email}
|
|
43
|
+
/>
|
|
44
|
+
</FormField>
|
|
45
|
+
|
|
46
|
+
<FormField label="Age">
|
|
47
|
+
<NumberEditor
|
|
48
|
+
placeholder="Enter your age"
|
|
49
|
+
min={1}
|
|
50
|
+
max={120}
|
|
51
|
+
bind:value={formData.age}
|
|
52
|
+
/>
|
|
53
|
+
</FormField>
|
|
54
|
+
|
|
55
|
+
<div class="form-actions">
|
|
56
|
+
<button type="button" on:click={handleSubmit}>
|
|
57
|
+
Submit
|
|
58
|
+
</button>
|
|
59
|
+
</div>
|
|
60
|
+
</FlexForm>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Horizontal Layout Form
|
|
64
|
+
|
|
65
|
+
```svelte
|
|
66
|
+
<script lang="ts">
|
|
67
|
+
import FlexForm, FormField, TextEditor, OptionsSelect, DatePicker from '@ticatec/uniface-element/FlexForm, FormField, TextEditor, OptionsSelect, DatePicker';
|
|
68
|
+
|
|
69
|
+
interface UserProfile {
|
|
70
|
+
firstName: string;
|
|
71
|
+
lastName: string;
|
|
72
|
+
gender: string;
|
|
73
|
+
birthDate: Date | null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let userProfile: UserProfile = {
|
|
77
|
+
firstName: '',
|
|
78
|
+
lastName: '',
|
|
79
|
+
gender: '',
|
|
80
|
+
birthDate: null
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const genderOptions = [
|
|
84
|
+
{ code: 'male', text: 'Male' },
|
|
85
|
+
{ code: 'female', text: 'Female' },
|
|
86
|
+
{ code: 'other', text: 'Other' }
|
|
87
|
+
];
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
<FlexForm fieldLayout="horizontal" style="max-width: 800px;">
|
|
91
|
+
<FormField label="First Name">
|
|
92
|
+
<TextEditor bind:value={userProfile.firstName} />
|
|
93
|
+
</FormField>
|
|
94
|
+
|
|
95
|
+
<FormField label="Last Name">
|
|
96
|
+
<TextEditor bind:value={userProfile.lastName} />
|
|
97
|
+
</FormField>
|
|
98
|
+
|
|
99
|
+
<FormField label="Gender">
|
|
100
|
+
<OptionsSelect
|
|
101
|
+
options={genderOptions}
|
|
102
|
+
keyField="code"
|
|
103
|
+
textField="text"
|
|
104
|
+
bind:value={userProfile.gender}
|
|
105
|
+
/>
|
|
106
|
+
</FormField>
|
|
107
|
+
|
|
108
|
+
<FormField label="Birth Date">
|
|
109
|
+
<DatePicker bind:value={userProfile.birthDate} />
|
|
110
|
+
</FormField>
|
|
111
|
+
</FlexForm>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Complex Form Layout
|
|
115
|
+
|
|
116
|
+
```svelte
|
|
117
|
+
<script lang="ts">
|
|
118
|
+
import FlexForm, FormField, TextEditor, NumberEditor, Switch, CheckBox from '@ticatec/uniface-element/FlexForm, FormField, TextEditor, NumberEditor, Switch, CheckBox';
|
|
119
|
+
|
|
120
|
+
interface ContactForm {
|
|
121
|
+
personalInfo: {
|
|
122
|
+
name: string;
|
|
123
|
+
phone: string;
|
|
124
|
+
email: string;
|
|
125
|
+
};
|
|
126
|
+
addressInfo: {
|
|
127
|
+
address: string;
|
|
128
|
+
city: string;
|
|
129
|
+
zipCode: string;
|
|
130
|
+
};
|
|
131
|
+
preferences: {
|
|
132
|
+
newsletter: boolean;
|
|
133
|
+
smsNotify: boolean;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
let contactForm: ContactForm = {
|
|
138
|
+
personalInfo: {
|
|
139
|
+
name: '',
|
|
140
|
+
phone: '',
|
|
141
|
+
email: ''
|
|
142
|
+
},
|
|
143
|
+
addressInfo: {
|
|
144
|
+
address: '',
|
|
145
|
+
city: '',
|
|
146
|
+
zipCode: ''
|
|
147
|
+
},
|
|
148
|
+
preferences: {
|
|
149
|
+
newsletter: false,
|
|
150
|
+
smsNotify: false
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const validateForm = (): boolean => {
|
|
155
|
+
// Form validation logic
|
|
156
|
+
return contactForm.personalInfo.name.length > 0 &&
|
|
157
|
+
contactForm.personalInfo.email.length > 0;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const handleSave = (): void => {
|
|
161
|
+
if (validateForm()) {
|
|
162
|
+
console.log('Save form:', contactForm);
|
|
163
|
+
} else {
|
|
164
|
+
alert('Please fill in required fields');
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
</script>
|
|
168
|
+
|
|
169
|
+
<div class="contact-form-container">
|
|
170
|
+
<h2>Contact Information Form</h2>
|
|
171
|
+
|
|
172
|
+
<!-- Personal Information Section -->
|
|
173
|
+
<section class="form-section">
|
|
174
|
+
<h3>Personal Information</h3>
|
|
175
|
+
<FlexForm fieldLayout="vertical">
|
|
176
|
+
<FormField label="Name" required>
|
|
177
|
+
<TextEditor
|
|
178
|
+
placeholder="Enter your name"
|
|
179
|
+
bind:value={contactForm.personalInfo.name}
|
|
180
|
+
/>
|
|
181
|
+
</FormField>
|
|
182
|
+
|
|
183
|
+
<FormField label="Phone">
|
|
184
|
+
<TextEditor
|
|
185
|
+
placeholder="Enter phone number"
|
|
186
|
+
bind:value={contactForm.personalInfo.phone}
|
|
187
|
+
/>
|
|
188
|
+
</FormField>
|
|
189
|
+
|
|
190
|
+
<FormField label="Email" required>
|
|
191
|
+
<TextEditor
|
|
192
|
+
placeholder="Enter email address"
|
|
193
|
+
bind:value={contactForm.personalInfo.email}
|
|
194
|
+
/>
|
|
195
|
+
</FormField>
|
|
196
|
+
</FlexForm>
|
|
197
|
+
</section>
|
|
198
|
+
|
|
199
|
+
<!-- Address Information Section -->
|
|
200
|
+
<section class="form-section">
|
|
201
|
+
<h3>Address Information</h3>
|
|
202
|
+
<FlexForm fieldLayout="horizontal">
|
|
203
|
+
<FormField label="Address">
|
|
204
|
+
<TextEditor
|
|
205
|
+
placeholder="Enter detailed address"
|
|
206
|
+
bind:value={contactForm.addressInfo.address}
|
|
207
|
+
/>
|
|
208
|
+
</FormField>
|
|
209
|
+
|
|
210
|
+
<FormField label="City">
|
|
211
|
+
<TextEditor
|
|
212
|
+
placeholder="Enter city"
|
|
213
|
+
bind:value={contactForm.addressInfo.city}
|
|
214
|
+
/>
|
|
215
|
+
</FormField>
|
|
216
|
+
|
|
217
|
+
<FormField label="Zip Code">
|
|
218
|
+
<TextEditor
|
|
219
|
+
placeholder="Enter zip code"
|
|
220
|
+
bind:value={contactForm.addressInfo.zipCode}
|
|
221
|
+
/>
|
|
222
|
+
</FormField>
|
|
223
|
+
</FlexForm>
|
|
224
|
+
</section>
|
|
225
|
+
|
|
226
|
+
<!-- Preferences Section -->
|
|
227
|
+
<section class="form-section">
|
|
228
|
+
<h3>Notification Preferences</h3>
|
|
229
|
+
<FlexForm fieldLayout="vertical">
|
|
230
|
+
<FormField label="">
|
|
231
|
+
<CheckBox
|
|
232
|
+
label="Subscribe to newsletter"
|
|
233
|
+
bind:value={contactForm.preferences.newsletter}
|
|
234
|
+
/>
|
|
235
|
+
</FormField>
|
|
236
|
+
|
|
237
|
+
<FormField label="">
|
|
238
|
+
<CheckBox
|
|
239
|
+
label="Receive SMS notifications"
|
|
240
|
+
bind:value={contactForm.preferences.smsNotify}
|
|
241
|
+
/>
|
|
242
|
+
</FormField>
|
|
243
|
+
</FlexForm>
|
|
244
|
+
</section>
|
|
245
|
+
|
|
246
|
+
<div class="form-actions">
|
|
247
|
+
<button type="button" class="btn-secondary">
|
|
248
|
+
Cancel
|
|
249
|
+
</button>
|
|
250
|
+
<button type="button" class="btn-primary" on:click={handleSave}>
|
|
251
|
+
Save
|
|
252
|
+
</button>
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
|
|
256
|
+
<style>
|
|
257
|
+
.contact-form-container {
|
|
258
|
+
max-width: 600px;
|
|
259
|
+
margin: 0 auto;
|
|
260
|
+
padding: 20px;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.form-section {
|
|
264
|
+
margin-bottom: 30px;
|
|
265
|
+
padding: 20px;
|
|
266
|
+
border: 1px solid #e1e5e9;
|
|
267
|
+
border-radius: 8px;
|
|
268
|
+
background: #f8f9fa;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.form-section h3 {
|
|
272
|
+
margin: 0 0 20px 0;
|
|
273
|
+
color: #495057;
|
|
274
|
+
font-size: 18px;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.form-actions {
|
|
278
|
+
display: flex;
|
|
279
|
+
gap: 10px;
|
|
280
|
+
justify-content: flex-end;
|
|
281
|
+
padding-top: 20px;
|
|
282
|
+
border-top: 1px solid #dee2e6;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.btn-primary, .btn-secondary {
|
|
286
|
+
padding: 8px 16px;
|
|
287
|
+
border: none;
|
|
288
|
+
border-radius: 4px;
|
|
289
|
+
font-size: 14px;
|
|
290
|
+
cursor: pointer;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.btn-primary {
|
|
294
|
+
background: #007bff;
|
|
295
|
+
color: white;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.btn-secondary {
|
|
299
|
+
background: #6c757d;
|
|
300
|
+
color: white;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.btn-primary:hover {
|
|
304
|
+
background: #0056b3;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.btn-secondary:hover {
|
|
308
|
+
background: #545b62;
|
|
309
|
+
}
|
|
310
|
+
</style>
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Layout Mode Comparison
|
|
314
|
+
|
|
315
|
+
### Vertical Layout (fieldLayout="vertical")
|
|
316
|
+
- Field labels and input controls are arranged vertically
|
|
317
|
+
- Suitable for forms with many fields or long field labels
|
|
318
|
+
- Better performance on narrow screens
|
|
319
|
+
- Each field takes up the full width
|
|
320
|
+
|
|
321
|
+
### Horizontal Layout (fieldLayout="horizontal")
|
|
322
|
+
- Field labels and input controls are arranged horizontally
|
|
323
|
+
- Suitable for simple forms or when compact layout is needed
|
|
324
|
+
- More efficient space usage on wide screens
|
|
325
|
+
- Fixed label width, input controls take remaining space
|
|
326
|
+
|
|
327
|
+
## Responsive Design
|
|
328
|
+
|
|
329
|
+
```svelte
|
|
330
|
+
<script lang="ts">
|
|
331
|
+
import { onMount } from 'svelte';
|
|
332
|
+
|
|
333
|
+
let isNarrowScreen: boolean = false;
|
|
334
|
+
|
|
335
|
+
const checkScreenWidth = (): void => {
|
|
336
|
+
isNarrowScreen = window.innerWidth < 768;
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
onMount(() => {
|
|
340
|
+
checkScreenWidth();
|
|
341
|
+
window.addEventListener('resize', checkScreenWidth);
|
|
342
|
+
return () => window.removeEventListener('resize', checkScreenWidth);
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
$: fieldLayout = isNarrowScreen ? 'vertical' : 'horizontal';
|
|
346
|
+
</script>
|
|
347
|
+
|
|
348
|
+
<FlexForm {fieldLayout}>
|
|
349
|
+
<!-- Form fields -->
|
|
350
|
+
</FlexForm>
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## Style Customization
|
|
354
|
+
|
|
355
|
+
```css
|
|
356
|
+
/* Custom FlexForm styles */
|
|
357
|
+
:global(.flex-form) {
|
|
358
|
+
display: flex;
|
|
359
|
+
flex-direction: column;
|
|
360
|
+
gap: 16px;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/* Horizontal layout styles */
|
|
364
|
+
:global(.flex-form.field-layout-horizontal) {
|
|
365
|
+
gap: 12px;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/* Custom form container */
|
|
369
|
+
.custom-form {
|
|
370
|
+
background: white;
|
|
371
|
+
padding: 24px;
|
|
372
|
+
border-radius: 8px;
|
|
373
|
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/* Responsive styles */
|
|
377
|
+
@media (max-width: 768px) {
|
|
378
|
+
:global(.flex-form.field-layout-horizontal) {
|
|
379
|
+
/* Force vertical layout on small screens */
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## Best Practices
|
|
385
|
+
|
|
386
|
+
### 1. Choose Appropriate Layout Mode
|
|
387
|
+
```svelte
|
|
388
|
+
<!-- Simple forms: use horizontal layout -->
|
|
389
|
+
<FlexForm fieldLayout="horizontal">
|
|
390
|
+
<FormField label="Username"><TextEditor /></FormField>
|
|
391
|
+
<FormField label="Password"><TextEditor type="password" /></FormField>
|
|
392
|
+
</FlexForm>
|
|
393
|
+
|
|
394
|
+
<!-- Complex forms: use vertical layout -->
|
|
395
|
+
<FlexForm fieldLayout="vertical">
|
|
396
|
+
<FormField label="Detailed Description">
|
|
397
|
+
<TextEditor multiline rows={4} />
|
|
398
|
+
</FormField>
|
|
399
|
+
</FlexForm>
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### 2. Group Form Fields Logically
|
|
403
|
+
```svelte
|
|
404
|
+
<div class="form-container">
|
|
405
|
+
<section>
|
|
406
|
+
<h3>Basic Information</h3>
|
|
407
|
+
<FlexForm fieldLayout="vertical">
|
|
408
|
+
<!-- Basic information fields -->
|
|
409
|
+
</FlexForm>
|
|
410
|
+
</section>
|
|
411
|
+
|
|
412
|
+
<section>
|
|
413
|
+
<h3>Contact Information</h3>
|
|
414
|
+
<FlexForm fieldLayout="horizontal">
|
|
415
|
+
<!-- Contact fields -->
|
|
416
|
+
</FlexForm>
|
|
417
|
+
</section>
|
|
418
|
+
</div>
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
### 3. Form Validation Integration
|
|
422
|
+
```svelte
|
|
423
|
+
<script lang="ts">
|
|
424
|
+
let errors: Record<string, string> = {};
|
|
425
|
+
|
|
426
|
+
const validateField = (field: string, value: any): void => {
|
|
427
|
+
// Validation logic
|
|
428
|
+
if (!value) {
|
|
429
|
+
errors[field] = 'This field is required';
|
|
430
|
+
} else {
|
|
431
|
+
delete errors[field];
|
|
432
|
+
}
|
|
433
|
+
errors = { ...errors };
|
|
434
|
+
};
|
|
435
|
+
</script>
|
|
436
|
+
|
|
437
|
+
<FlexForm fieldLayout="vertical">
|
|
438
|
+
<FormField label="Name" required error={errors.name}>
|
|
439
|
+
<TextEditor
|
|
440
|
+
bind:value={formData.name}
|
|
441
|
+
onChange={(value) => validateField('name', value)}
|
|
442
|
+
/>
|
|
443
|
+
</FormField>
|
|
444
|
+
</FlexForm>
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
## Component Advantages
|
|
448
|
+
|
|
449
|
+
1. **Flexible Layout** - Supports both vertical and horizontal layout modes
|
|
450
|
+
2. **Responsive Friendly** - Can dynamically adjust layout based on screen size
|
|
451
|
+
3. **Simple API** - Minimal property configuration, easy to use
|
|
452
|
+
4. **Customizable Styles** - Easy customization through CSS variables and style classes
|
|
453
|
+
5. **Semantic Structure** - Clear HTML structure, good for SEO and accessibility
|
|
454
|
+
6. **High Composability** - Works perfectly with other form components
|