@marianmeres/stuic 1.56.0 → 1.57.0
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.
|
@@ -21,7 +21,7 @@ const _emptyClasses = () => ({
|
|
|
21
21
|
asterix: ""
|
|
22
22
|
});
|
|
23
23
|
const _PRESET = {
|
|
24
|
-
box: "mb-4",
|
|
24
|
+
box: "mb-4 grid",
|
|
25
25
|
wrap: `
|
|
26
26
|
rounded-md border border-gray-300
|
|
27
27
|
bg-gray-100
|
|
@@ -96,6 +96,8 @@ export let pattern = void 0;
|
|
|
96
96
|
export let step = void 0;
|
|
97
97
|
export let useTrim = true;
|
|
98
98
|
export let textareaAutoEnlarge = true;
|
|
99
|
+
export let labelLeft = false;
|
|
100
|
+
export let labelLeftWidth = "normal";
|
|
99
101
|
export let validate = void 0;
|
|
100
102
|
export let showAsterixOnRequired = true;
|
|
101
103
|
let validation;
|
|
@@ -142,8 +144,17 @@ $:
|
|
|
142
144
|
_belowClass = twMerge(_collectClasses("below"));
|
|
143
145
|
</script>
|
|
144
146
|
|
|
145
|
-
<div
|
|
146
|
-
|
|
147
|
+
<div
|
|
148
|
+
class={_boxClass}
|
|
149
|
+
class:grid-cols-4={labelLeft && labelLeftWidth === 'normal'}
|
|
150
|
+
class:grid-cols-3={labelLeft && labelLeftWidth === 'wide'}
|
|
151
|
+
>
|
|
152
|
+
<div
|
|
153
|
+
class="flex px-2 mb-1"
|
|
154
|
+
class:items-end={!labelLeft}
|
|
155
|
+
class:items-start={labelLeft}
|
|
156
|
+
class:mt-1={labelLeft}
|
|
157
|
+
>
|
|
147
158
|
{#if label || $$slots.label}
|
|
148
159
|
<label for={id} class={_labelClass} class:required>
|
|
149
160
|
{#if $$slots.label}
|
|
@@ -155,73 +166,82 @@ $:
|
|
|
155
166
|
{/if}
|
|
156
167
|
<slot name="right_of_label" />
|
|
157
168
|
</div>
|
|
158
|
-
<div
|
|
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
|
-
|
|
169
|
+
<div
|
|
170
|
+
class:col-span-3={labelLeft && labelLeftWidth === 'normal'}
|
|
171
|
+
class:col-span-2={labelLeft && labelLeftWidth === 'wide'}
|
|
172
|
+
>
|
|
173
|
+
<div
|
|
174
|
+
class={_wrapClass}
|
|
175
|
+
class:cursor-not-allowed={disabled}
|
|
176
|
+
class:opacity-50={disabled}
|
|
177
|
+
>
|
|
178
|
+
<div class="flex items-center">
|
|
179
|
+
<slot name="input_before" {id} />
|
|
180
|
+
{#if type === 'textarea'}
|
|
181
|
+
<textarea
|
|
182
|
+
bind:value
|
|
183
|
+
bind:this={_inputEl}
|
|
184
|
+
{id}
|
|
185
|
+
class={_inputClass}
|
|
186
|
+
class:cursor-not-allowed={disabled}
|
|
187
|
+
{name}
|
|
188
|
+
{disabled}
|
|
189
|
+
{readonly}
|
|
190
|
+
{required}
|
|
191
|
+
{autofocus}
|
|
192
|
+
{tabindex}
|
|
193
|
+
use:trim={useTrim}
|
|
194
|
+
use:validateAction={validate
|
|
195
|
+
? { ...(validate === true ? {} : validate), setValidationResult }
|
|
196
|
+
: undefined}
|
|
197
|
+
use:autogrow={{ allowed: textareaAutoEnlarge }}
|
|
198
|
+
{...$$restProps}
|
|
199
|
+
/>
|
|
200
|
+
{:else}
|
|
201
|
+
<input
|
|
202
|
+
bind:value
|
|
203
|
+
bind:this={_inputEl}
|
|
204
|
+
use:setType={type}
|
|
205
|
+
{id}
|
|
206
|
+
class={_inputClass}
|
|
207
|
+
class:cursor-not-allowed={disabled}
|
|
208
|
+
{name}
|
|
209
|
+
{placeholder}
|
|
210
|
+
{disabled}
|
|
211
|
+
{readonly}
|
|
212
|
+
{required}
|
|
213
|
+
{autofocus}
|
|
214
|
+
{autocomplete}
|
|
215
|
+
{tabindex}
|
|
216
|
+
{minlength}
|
|
217
|
+
{maxlength}
|
|
218
|
+
{min}
|
|
219
|
+
{max}
|
|
220
|
+
{pattern}
|
|
221
|
+
{step}
|
|
222
|
+
use:trim={useTrim}
|
|
223
|
+
use:validateAction={validate
|
|
224
|
+
? { ...(validate === true ? {} : validate), setValidationResult }
|
|
225
|
+
: undefined}
|
|
226
|
+
{...$$restProps}
|
|
227
|
+
/>
|
|
228
|
+
{/if}
|
|
229
|
+
<slot name="input_after" {id} />
|
|
230
|
+
</div>
|
|
231
|
+
<slot name="input_below" {id} />
|
|
211
232
|
</div>
|
|
212
|
-
|
|
233
|
+
{#if validation && !validation?.valid}
|
|
234
|
+
<div transition:slide={{ duration: 150 }} class={_validationMessageClass}>
|
|
235
|
+
{@html validation.message}
|
|
236
|
+
</div>
|
|
237
|
+
{/if}
|
|
238
|
+
{#if description}
|
|
239
|
+
<div class={_descriptionClass}>
|
|
240
|
+
<Thc thc={description} forceAsHtml />
|
|
241
|
+
</div>
|
|
242
|
+
{/if}
|
|
243
|
+
{#if $$slots.below}
|
|
244
|
+
<div class={_belowClass}><slot name="below" {id} /></div>
|
|
245
|
+
{/if}
|
|
213
246
|
</div>
|
|
214
|
-
{#if validation && !validation?.valid}
|
|
215
|
-
<div transition:slide={{ duration: 150 }} class={_validationMessageClass}>
|
|
216
|
-
{@html validation.message}
|
|
217
|
-
</div>
|
|
218
|
-
{/if}
|
|
219
|
-
{#if description}
|
|
220
|
-
<div class={_descriptionClass}>
|
|
221
|
-
<Thc thc={description} forceAsHtml />
|
|
222
|
-
</div>
|
|
223
|
-
{/if}
|
|
224
|
-
{#if $$slots.below}
|
|
225
|
-
<div class={_belowClass}><slot name="below" {id} /></div>
|
|
226
|
-
{/if}
|
|
227
247
|
</div>
|
|
@@ -47,6 +47,8 @@ declare const __propDef: {
|
|
|
47
47
|
step?: number | undefined;
|
|
48
48
|
useTrim?: boolean | undefined;
|
|
49
49
|
textareaAutoEnlarge?: boolean | undefined;
|
|
50
|
+
labelLeft?: boolean | undefined;
|
|
51
|
+
labelLeftWidth?: "normal" | "wide" | undefined;
|
|
50
52
|
validate?: ValidateOptions | true | undefined;
|
|
51
53
|
showAsterixOnRequired?: boolean | undefined;
|
|
52
54
|
};
|
|
@@ -18,7 +18,7 @@ const _emptyClasses = () => ({
|
|
|
18
18
|
asterix: ""
|
|
19
19
|
});
|
|
20
20
|
const _PRESET = {
|
|
21
|
-
box: "mb-4",
|
|
21
|
+
box: "mb-4 grid",
|
|
22
22
|
wrap: `
|
|
23
23
|
flex items-center
|
|
24
24
|
rounded-md border border-gray-300
|
|
@@ -82,6 +82,8 @@ export let required = false;
|
|
|
82
82
|
export let autofocus = void 0;
|
|
83
83
|
export let validate = void 0;
|
|
84
84
|
export let showAsterixOnRequired = true;
|
|
85
|
+
export let labelLeft = false;
|
|
86
|
+
export let labelLeftWidth = "normal";
|
|
85
87
|
let validation;
|
|
86
88
|
const setValidationResult = (res) => validation = res;
|
|
87
89
|
let _options = [];
|
|
@@ -134,8 +136,17 @@ $:
|
|
|
134
136
|
_belowClass = twMerge(_collectClasses("below"));
|
|
135
137
|
</script>
|
|
136
138
|
|
|
137
|
-
<div
|
|
138
|
-
|
|
139
|
+
<div
|
|
140
|
+
class={_boxClass}
|
|
141
|
+
class:grid-cols-4={labelLeft && labelLeftWidth === 'normal'}
|
|
142
|
+
class:grid-cols-3={labelLeft && labelLeftWidth === 'wide'}
|
|
143
|
+
>
|
|
144
|
+
<div
|
|
145
|
+
class="flex px-2"
|
|
146
|
+
class:items-end={!labelLeft}
|
|
147
|
+
class:items-start={labelLeft}
|
|
148
|
+
class:mt-1={labelLeft}
|
|
149
|
+
>
|
|
139
150
|
{#if label || $$slots.label}
|
|
140
151
|
<label for={id} class={_labelClass}>
|
|
141
152
|
{#if $$slots.label}
|
|
@@ -147,39 +158,49 @@ $:
|
|
|
147
158
|
{/if}
|
|
148
159
|
<slot name="right_of_label" />
|
|
149
160
|
</div>
|
|
150
|
-
<div
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
{disabled}
|
|
157
|
-
{
|
|
158
|
-
{tabindex}
|
|
159
|
-
{autofocus}
|
|
160
|
-
{name}
|
|
161
|
-
use:validateAction={validate
|
|
162
|
-
? { ...(validate === true ? {} : validate), setValidationResult }
|
|
163
|
-
: undefined}
|
|
161
|
+
<div
|
|
162
|
+
class:col-span-3={labelLeft && labelLeftWidth === 'normal'}
|
|
163
|
+
class:col-span-2={labelLeft && labelLeftWidth === 'wide'}
|
|
164
|
+
>
|
|
165
|
+
<div
|
|
166
|
+
class={_wrapClass}
|
|
167
|
+
class:cursor-not-allowed={disabled}
|
|
168
|
+
class:opacity-50={disabled}
|
|
164
169
|
>
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
170
|
+
<slot name="input_before" {id} />
|
|
171
|
+
<select
|
|
172
|
+
class={_inputClass}
|
|
173
|
+
bind:value
|
|
174
|
+
bind:this={_inputEl}
|
|
175
|
+
{id}
|
|
176
|
+
{disabled}
|
|
177
|
+
{required}
|
|
178
|
+
{tabindex}
|
|
179
|
+
{autofocus}
|
|
180
|
+
{name}
|
|
181
|
+
use:validateAction={validate
|
|
182
|
+
? { ...(validate === true ? {} : validate), setValidationResult }
|
|
183
|
+
: undefined}
|
|
184
|
+
>
|
|
185
|
+
{#each _options as o, i}
|
|
186
|
+
<option value={o.value}>{o.label}</option>
|
|
187
|
+
{/each}
|
|
188
|
+
</select>
|
|
169
189
|
|
|
170
|
-
|
|
171
|
-
</div>
|
|
172
|
-
{#if validation && !validation?.valid}
|
|
173
|
-
<div transition:slide={{ duration: 150 }} class={_validationMessageClass}>
|
|
174
|
-
{@html validation.message}
|
|
175
|
-
</div>
|
|
176
|
-
{/if}
|
|
177
|
-
{#if description}
|
|
178
|
-
<div class={_descriptionClass}>
|
|
179
|
-
<Thc thc={description} forceAsHtml />
|
|
190
|
+
<slot name="input_after" {id} />
|
|
180
191
|
</div>
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
192
|
+
{#if validation && !validation?.valid}
|
|
193
|
+
<div transition:slide={{ duration: 150 }} class={_validationMessageClass}>
|
|
194
|
+
{@html validation.message}
|
|
195
|
+
</div>
|
|
196
|
+
{/if}
|
|
197
|
+
{#if description}
|
|
198
|
+
<div class={_descriptionClass}>
|
|
199
|
+
<Thc thc={description} forceAsHtml />
|
|
200
|
+
</div>
|
|
201
|
+
{/if}
|
|
202
|
+
{#if $$slots.below}
|
|
203
|
+
<div class={_belowClass}><slot name="below" {id} /></div>
|
|
204
|
+
{/if}
|
|
205
|
+
</div>
|
|
185
206
|
</div>
|
|
@@ -40,6 +40,8 @@ declare const __propDef: {
|
|
|
40
40
|
autofocus?: true | undefined;
|
|
41
41
|
validate?: ValidateOptions | true | undefined;
|
|
42
42
|
showAsterixOnRequired?: boolean | undefined;
|
|
43
|
+
labelLeft?: boolean | undefined;
|
|
44
|
+
labelLeftWidth?: "normal" | "wide" | undefined;
|
|
43
45
|
};
|
|
44
46
|
events: {
|
|
45
47
|
[evt: string]: CustomEvent<any>;
|