@stubber/form-fields 1.6.2 → 1.6.3
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.
|
@@ -130,7 +130,7 @@ $: selectedValue = currency_list.find((c) => c.value === current_details?.curren
|
|
|
130
130
|
|
|
131
131
|
<FieldLabel {fieldStore} />
|
|
132
132
|
<div
|
|
133
|
-
class="flex
|
|
133
|
+
class="flex h-9 w-full min-w-0 flex-row items-center gap-2 rounded-md border border-input bg-background px-3 py-1 text-base outline-none ring-offset-background transition-[color,box-shadow] selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid]:border-destructive aria-[invalid]:ring-destructive/50 aria-[invalid]:focus-visible:ring-destructive/50 md:text-sm dark:bg-input/30"
|
|
134
134
|
>
|
|
135
135
|
<!-- currency indicator front left -->
|
|
136
136
|
<div class="pointer-events-none text-gray-500">
|
|
@@ -143,7 +143,7 @@ $: selectedValue = currency_list.find((c) => c.value === current_details?.curren
|
|
|
143
143
|
{/if}
|
|
144
144
|
</div>
|
|
145
145
|
<input
|
|
146
|
-
class="w-full focus-within:outline-none
|
|
146
|
+
class="w-full bg-transparent focus-within:outline-none"
|
|
147
147
|
use:inputRegexMask={currencyRegex}
|
|
148
148
|
value={initial_ui_value}
|
|
149
149
|
inputmode="decimal"
|
|
@@ -160,13 +160,13 @@ $: selectedValue = currency_list.find((c) => c.value === current_details?.curren
|
|
|
160
160
|
variant="outline"
|
|
161
161
|
role="combobox"
|
|
162
162
|
aria-expanded={open}
|
|
163
|
-
class="w-28 border-none bg-transparent px-1
|
|
163
|
+
class="w-28 justify-between border-none bg-transparent px-1"
|
|
164
164
|
>
|
|
165
165
|
{selectedValue}
|
|
166
166
|
<i class="fas fa-sort ml-2 h-4 w-4 shrink-0 opacity-50" />
|
|
167
167
|
</Button>
|
|
168
168
|
</Popover.Trigger>
|
|
169
|
-
<Popover.Content class="
|
|
169
|
+
<Popover.Content class="max-h-[50vh] overflow-y-scroll p-0">
|
|
170
170
|
<Command.Root>
|
|
171
171
|
<Command.Input placeholder="Search currencies..." />
|
|
172
172
|
<Command.Empty>No currency found.</Command.Empty>
|
|
@@ -121,12 +121,30 @@ const contentField = StateField.define({
|
|
|
121
121
|
},
|
|
122
122
|
update(value, transaction) {
|
|
123
123
|
if (transaction.docChanged) {
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
let new_value = transaction.newDoc.toString();
|
|
125
|
+
if (new_value !== $fieldStore.value) {
|
|
126
|
+
$fieldStore.value = parse_string ? parse_string_value(new_value) : new_value;
|
|
127
|
+
}
|
|
128
|
+
return new_value;
|
|
126
129
|
}
|
|
127
130
|
return value;
|
|
128
131
|
}
|
|
129
132
|
});
|
|
133
|
+
$: update_editor_content($fieldStore.value);
|
|
134
|
+
function update_editor_content(new_value) {
|
|
135
|
+
if (editor_view) {
|
|
136
|
+
const current_value = editor_view.state.doc.toString();
|
|
137
|
+
if (new_value !== current_value && typeof new_value === "string") {
|
|
138
|
+
editor_view.dispatch({
|
|
139
|
+
changes: {
|
|
140
|
+
from: 0,
|
|
141
|
+
to: current_value.length,
|
|
142
|
+
insert: new_value
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
130
148
|
function fake_handlebars_lang() {
|
|
131
149
|
const curly_decorator = new MatchDecorator({
|
|
132
150
|
regexp: /(\{\{[^}]*\}\})|(~~[^\s]*)/g,
|
|
@@ -180,43 +198,63 @@ function parse_string_value(value) {
|
|
|
180
198
|
|
|
181
199
|
<FieldLabel {fieldStore} />
|
|
182
200
|
{#if !is_object}
|
|
183
|
-
<div
|
|
184
|
-
use:setup_editor
|
|
185
|
-
class=" stubber-cm text-sm {isValid ? 'stubber-valid' : 'stubber-invalid'}"
|
|
186
|
-
/>
|
|
201
|
+
<div use:setup_editor class="stubber-cm" aria-invalid={!isValid} />
|
|
187
202
|
{:else}
|
|
188
203
|
<p class="text-surface-400">The value of this field is not a string.</p>
|
|
189
204
|
{/if}
|
|
190
205
|
<FieldMessage {fieldStore} />
|
|
191
206
|
|
|
207
|
+
<!-- below styles are basically this tailwind string:
|
|
208
|
+
flex h-9 w-full min-w-0 flex-row items-center gap-2 rounded-md border border-input bg-background px-3 py-1 text-base outline-none ring-offset-background transition-[color,box-shadow] selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid]:border-destructive aria-[invalid]:ring-destructive/50 aria-[invalid]:focus-visible:ring-destructive/50 md:text-sm dark:bg-input/30 -->
|
|
209
|
+
|
|
192
210
|
<style>
|
|
193
211
|
.stubber-cm :global(.cm-editor) {
|
|
194
|
-
|
|
195
|
-
|
|
212
|
+
width: 100%;
|
|
213
|
+
min-width: 0;
|
|
196
214
|
border-radius: 0.375rem;
|
|
215
|
+
border-width: 1px;
|
|
197
216
|
--tw-border-opacity: 1;
|
|
198
217
|
border-color: hsl(var(--input) / var(--tw-border-opacity, 1));
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
width: 100%;
|
|
202
|
-
color: rgb(31 41 51);
|
|
218
|
+
--tw-bg-opacity: 1;
|
|
219
|
+
background-color: hsl(var(--background) / var(--tw-bg-opacity, 1));
|
|
203
220
|
|
|
204
|
-
|
|
205
|
-
|
|
221
|
+
font-size: 0.875rem;
|
|
222
|
+
line-height: 1.25rem;
|
|
223
|
+
outline: 2px solid transparent;
|
|
224
|
+
outline-offset: 2px;
|
|
225
|
+
--tw-ring-offset-color: hsl(var(--background) / 1);
|
|
226
|
+
transition-property: color, box-shadow;
|
|
227
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
228
|
+
transition-duration: 150ms;
|
|
206
229
|
}
|
|
207
230
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
231
|
+
@media (prefers-color-scheme: dark) {
|
|
232
|
+
.stubber-cm :global(.cm-editor) {
|
|
233
|
+
background-color: hsl(var(--input) / 0.3);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.stubber-cm[aria-invalid="true"] :global(.cm-editor) {
|
|
238
|
+
--tw-border-opacity: 1;
|
|
239
|
+
border-color: hsl(var(--destructive) / var(--tw-border-opacity, 1));
|
|
240
|
+
--tw-ring-color: hsl(var(--destructive) / 0.5);
|
|
212
241
|
}
|
|
213
242
|
|
|
214
|
-
.stubber-cm
|
|
215
|
-
border-
|
|
243
|
+
.stubber-cm :global(.cm-editor.cm-focused) {
|
|
244
|
+
--tw-border-opacity: 1;
|
|
245
|
+
border-color: hsl(var(--ring) / var(--tw-border-opacity, 1));
|
|
246
|
+
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width)
|
|
247
|
+
var(--tw-ring-offset-color);
|
|
248
|
+
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width))
|
|
249
|
+
var(--tw-ring-color);
|
|
250
|
+
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
|
251
|
+
--tw-ring-color: hsl(var(--ring) / 0.5);
|
|
216
252
|
}
|
|
217
253
|
|
|
218
|
-
.stubber-cm
|
|
219
|
-
|
|
254
|
+
.stubber-cm[aria-invalid="true"] :global(.cm-editor.cm-focused) {
|
|
255
|
+
--tw-ring-color: hsl(var(--destructive) / 0.5);
|
|
256
|
+
--tw-border-opacity: 1;
|
|
257
|
+
border-color: hsl(var(--destructive) / var(--tw-border-opacity, 1));
|
|
220
258
|
}
|
|
221
259
|
|
|
222
260
|
.stubber-cm :global(.cm-editor .cm-scroller) {
|
|
@@ -236,6 +274,7 @@ function parse_string_value(value) {
|
|
|
236
274
|
}
|
|
237
275
|
|
|
238
276
|
.stubber-cm :global(.cm-editor .cm-placeholder) {
|
|
277
|
+
--tw-text-opacity: 1;
|
|
239
278
|
color: hsl(var(--muted-foreground) / var(--tw-text-opacity, 1));
|
|
240
279
|
}
|
|
241
280
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stubber/form-fields",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"description": "An automatic form builder based on field specifications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"postcss": "^8.4.28",
|
|
51
51
|
"prettier": "^2.8.0",
|
|
52
52
|
"prettier-plugin-svelte": "^2.10.1",
|
|
53
|
+
"prettier-plugin-tailwindcss": "^0.4.1",
|
|
53
54
|
"publint": "^0.2.2",
|
|
54
55
|
"socket.io-client": "^4.8.1",
|
|
55
56
|
"svelte-check": "^3.4.3",
|
|
@@ -65,7 +66,7 @@
|
|
|
65
66
|
"@codemirror/lang-javascript": "^6.2.4",
|
|
66
67
|
"@codemirror/state": "^6.5.2",
|
|
67
68
|
"@codemirror/view": "^6.38.4",
|
|
68
|
-
"@stubber/ui": "^1.13.
|
|
69
|
+
"@stubber/ui": "^1.13.6",
|
|
69
70
|
"ag-grid-community": "^31.0.2",
|
|
70
71
|
"ag-grid-enterprise": "^31.0.2",
|
|
71
72
|
"codemirror": "^6.0.2",
|