generated from rawilk/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathform-components.php
380 lines (309 loc) · 13.9 KB
/
form-components.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<?php
use Rawilk\FormComponents\Components;
return [
/*
|--------------------------------------------------------------------------
| Component Defaults
|--------------------------------------------------------------------------
|
| We've added some common options you may want to globally edit to avoid
| having to change them everytime you call a component or having to
| override a component definition.
|
*/
'defaults' => [
// Global defaults will be applied to all components.
'global' => [
// Show error states by default.
'show_errors' => true,
// Set the fields to use by default for properties on options in select components.
'value_field' => 'id',
'label_field' => 'name',
// Will default to label field if null - only applies to custom selects
'selected_label_field' => null,
'disabled_field' => 'disabled',
'children_field' => 'children',
],
// Input defaults will be applied to all input types (email, password, etc.).
'input' => [
// Supported: 'sm', 'md', 'lg'
// Applies to all input types except for checkbox/radios.
'size' => 'md',
// Classes applied by default to input parent div.
// Will also apply to select.
'container_class' => null,
// Base input classes applied by default.
'input_class' => null,
],
'password' => [
// Show the password reveal button by default.
'show_toggle' => true,
// Icon shown when password is hidden.
'show_icon' => 'heroicon-m-eye',
// Icon shown when password is revealed.
'hide_icon' => 'heroicon-m-eye-slash',
],
'textarea' => [
// How many rows should the textarea have by default.
'rows' => 3,
// Automatically resize the textarea based on content length.
'auto_resize' => true,
],
'select' => [
// Automatically apply a CSS class to each select.
'input_class' => null,
],
// Defaults for checkbox/radios.
'choice' => [
// Automatically apply a CSS class to each checkbox/radio container.
'container_class' => null,
// Automatically apply a CSS class to each checkbox/radio input.
'input_class' => null,
// Supported: 'sm', 'md', 'lg' (defaults to 'sm')
'size' => null,
// Show the description inline with the label by default.
'inline_description' => false,
// Render the label on the left side of the checkbox/radio by default.
'label_left' => false,
],
// Defaults for the switch toggle component.
'switch_toggle' => [
// Apply a CSS class to the label that contains the switch toggle globally.
'container_class' => null,
// Apply a CSS class to the switch toggle (not the actual input element) globally.
'input_class' => null,
// Set the default size of the switch toggle.
// Supported: 'sm', 'md', 'lg', (default is 'md')
'size' => null,
// Set the default color of the switch toggle. (e.g. "blue", "red", "green", etc.)
'color' => null,
// Set the default icon to show when the switch is in an "on" state.
'on_icon' => null,
// Set the default icon to show when the switch is in an "off" state.
'off_icon' => null,
],
// Defaults for the date picker component.
'date_picker' => [
// Allow date picker to open from clicking on the input by default.
'click_opens' => false,
// Allow user to modify the text of the input by default.
'allow_input' => true,
// Enable the time picker by default.
'enable_time' => false,
// Set the default date format. (defaults to y-m-d)
'format' => null,
// Set an icon to show on the date picker for an "open" button by default.
// Set to null to hide it.
'toggle_icon' => 'heroicon-m-calendar',
// Allow date pickers to be cleared by a clear button by default.
'clearable' => true,
// Set an icon to show on the date picker's clear button by default.
'clear_icon' => 'heroicon-m-x-mark',
// Set the default placeholder text for the date picker.
// For best results, use a translation key as it will be translated automatically by the component.
'placeholder' => 'form-components::messages.date_picker_placeholder',
],
// Defaults for custom and tree select.
'custom_select' => [
// Apply a CSS class by default to the root element of the custom select.
// Note: this will also apply to tree-select as well.
'container_class' => null,
// Apply a CSS class by default to the custom select button.
'input_class' => null,
// Apply a CSS class by default to the custom select menu.
'menu_class' => null,
// Make custom selects searchable by default.
'searchable' => true,
// Make custom selects clearable by default.
// Will not show the clear button if the select is not optional.
'clearable' => true,
// Make custom selects optional by default. When marked as optional, custom select
// will allow you to clear out its value, unless it has a minimum amount of options
// required in a multi-select.
'optional' => false,
// Set the default icon to use to show that an option is selected.
// Set to null to disable it.
'option_selected_icon' => 'heroicon-m-check',
// Define the name of the icon to show on the custom select button by default.
// Set to null to hide it.
'button_icon' => 'heroicon-m-chevron-down',
// Define the default clear icon that will show on the custom select button and
// multi-select selected options. Set to null to hide it.
'clear_icon' => 'heroicon-m-x-mark',
// In a multi-select, this is the minimum amount of options that must be selected.
// Set to null or 0 to disable it.
'min_selected' => null,
// In a multi-select, this is the maximum amount of options that can be selected.
// Set to null to disable it.
'max_selected' => null,
],
// Defaults for the tree select.
'tree_select' => [
// Set the default icon to use to show that an option has children.
// Icon will be rotated to indicate when the option is expanded.
'has_child_icon' => 'heroicon-m-chevron-right',
],
// Defaults for the timezone select.
'timezone_select' => [
// Use the custom select component by default for the timezone select.
'use_custom_select' => true,
],
// Defaults for the form groups.
'form_group' => [
// Apply a CSS class to the root form group element globally.
'class' => null,
// Apply a margin bottom by default to form groups (except for last child).
'margin_bottom' => true,
// Render a border on top of each form group by default.
// Does not render on first of type form groups in a container.
// This option only applies to inline form groups as well.
'border' => true,
// Make all form groups show the label inline with the input by default.
'inline' => false,
// Apply a CSS class to the form group label container globally.
'label_container_class' => null,
// Apply a CSS class to the form group content globally.
'content_class' => null,
],
// Defaults for the file upload component.
'file_upload' => [
// Display a file upload progress bar by default.
// Only shows if a "wire:model" is present.
'display_upload_progress' => true,
// Use the native HTML5 progress bar by default.
// Not recommended if you need consistent styling across browsers.
'use_native_progress_bar' => false,
// Globally apply a CSS class to each file upload container.
'container_class' => null,
// Globally apply a CSS class to each file upload input.
'input_class' => null,
],
// Defaults for the file pond component.
'file_pond' => [
// Allow drag and drop file uploads by default.
'allow_drop' => true,
// Limit multiple file uploads to a certain number of files by default.
// Set to null to allow unlimited files.
'max_files' => null,
// Configure FilePond options by default.
'options' => [],
],
// Defaults for quill.
'quill' => [
// Automatically focus the editor on page load by default.
'auto_focus' => false,
],
// Defaults for form errors.
'form_error' => [
// Define which HTML tag to use for the error message by default.
'tag' => 'p',
],
],
/*
|--------------------------------------------------------------------------
| Component Aliases
|--------------------------------------------------------------------------
|
| Here you may define aliases for components this package provides.
| For example, instead of rendering an input with <x-form-components::inputs.input>,
| you may register an alias of 'input' and render it with <x-input>
| instead.
|
*/
'components' => [
// Base
'form' => Components\Form::class,
'form-error' => Components\FormError::class,
'form-group' => Components\FormGroup::class,
'label' => Components\Label::class,
// Choice
'checkbox-group' => Components\Choice\CheckboxGroup::class,
'checkbox' => Components\Choice\Checkbox::class,
'radio' => Components\Choice\Radio::class,
'switch-toggle' => Components\Choice\SwitchToggle::class,
// Inputs
'input' => Components\Inputs\Input::class,
'email' => Components\Inputs\Email::class,
'password' => Components\Inputs\Password::class,
'select' => Components\Inputs\Select::class,
'textarea' => Components\Inputs\Textarea::class,
'date-picker' => Components\Inputs\DatePicker::class,
'custom-select' => Components\Inputs\CustomSelect::class,
'custom-select-option' => Components\Inputs\CustomSelectOption::class,
'timezone-select' => Components\Inputs\TimezoneSelect::class,
'tree-select' => Components\Inputs\TreeSelect::class,
'tree-select-option' => Components\Inputs\TreeSelectOption::class,
// Files
'file-upload' => Components\Files\FileUpload::class,
'file-pond' => Components\Files\FilePond::class,
// Rich Text
'quill' => Components\RichText\Quill::class,
],
/*
|--------------------------------------------------------------------------
| Prefix
|--------------------------------------------------------------------------
|
| This value will be a prefix for all component aliases under the
| `components` key. This is useful if you want to avoid collisions
| with components from other libraries.
|
| If you set it to "tw", for example, you can reference it like this:
|
| <x-tw-input />
|
*/
'prefix' => '',
/*
|--------------------------------------------------------------------------
| Enable Timezone Select
|--------------------------------------------------------------------------
|
| If you don't plan on using a timezone select in your app, you can disable
| it here. This will prevent the use of app('fc-timezone'). You should also
| remove the "timezone-select" from the registered components in the config
| as well.
|
*/
'enable_timezone' => true,
/*
|--------------------------------------------------------------------------
| Default Timezone Subset
|--------------------------------------------------------------------------
|
| You may not always need the full list of timezones to choose from,
| so you may define a subset of regions to pull from instead. Set
| the value to `false` to use all regions.
|
| Example: [\Rawilk\FormComponents\Support\TimezoneRegionEnum::America->value]
|
*/
'timezone_subset' => false,
/*
|--------------------------------------------------------------------------
| Global Optional Hint
|--------------------------------------------------------------------------
|
| You may set a global "optional" hint text for all optional form inputs
| when you set the `optional` attribute on `<x-form-group>` components
| to `true`. Set to `null` to disable showing it. The default provided
| by the package is a translation key which will be translated
| automatically for you.
|
*/
'optional_hint_text' => 'form-components::messages.optional',
/*
|--------------------------------------------------------------------------
| FormComponents Assets URL
|--------------------------------------------------------------------------
|
| This value sets the path to the FormComponents JavaScript assets, for cases
| where your app's domain root is not the correct path. By default,
| FormComponents will load its JavaScript assets from the app's
| "relative root".
|
| Examples: "/assets", "myapp.com/app",
|
*/
'asset_url' => null,
];