vira 33.3.0 → 33.4.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.
@@ -63,6 +63,10 @@ export declare const ViraForm: import("element-vir").DeclarativeElementDefinitio
63
63
  validChange: import("element-vir").DefineElementEvent<{
64
64
  allFieldsAreValid: boolean;
65
65
  }>;
66
+ /** Emitted when focus leaves a field entirely, not when it moves within the field. */
67
+ fieldBlur: import("element-vir").DefineElementEvent<{
68
+ key: string;
69
+ } & ViraFormField>;
66
70
  /** Every field key, hidden ones included, in the order the user dropped them. */
67
71
  fieldOrderChange: import("element-vir").DefineElementEvent<string[]>;
68
72
  }, "vira-form-", "vira-form-", readonly [], readonly ["dragHandle"]>;
@@ -30,6 +30,8 @@ export const ViraForm = defineViraElement()({
30
30
  events: {
31
31
  valueChange: defineElementEvent(),
32
32
  validChange: defineElementEvent(),
33
+ /** Emitted when focus leaves a field entirely, not when it moves within the field. */
34
+ fieldBlur: defineElementEvent(),
33
35
  /** Every field key, hidden ones included, in the order the user dropped them. */
34
36
  fieldOrderChange: defineElementEvent(),
35
37
  },
@@ -175,6 +177,20 @@ export const ViraForm = defineViraElement()({
175
177
  }),
176
178
  }));
177
179
  }
180
+ function listenToFieldBlur(key, field) {
181
+ /**
182
+ * `blur` doesn't bubble out of the field's shadow root, but `focusout` does, and the
183
+ * browser skips it on the field's host when focus moves between elements inside it.
184
+ */
185
+ return listen('focusout', () => {
186
+ dispatch(new events.fieldBlur({
187
+ detail: {
188
+ key,
189
+ ...field,
190
+ },
191
+ }));
192
+ });
193
+ }
178
194
  function wrapFormField({ fieldTemplate, label, key, }) {
179
195
  const dropLine = state.dragReorder.readDropLine(visibleKeys.indexOf(key));
180
196
  const rowClasses = classMap({
@@ -239,6 +255,7 @@ export const ViraForm = defineViraElement()({
239
255
  fillWhenUnchecked: field.fillWhenUnchecked,
240
256
  })}
241
257
  ${field.testId ? testId(field.testId) : nothing}
258
+ ${listenToFieldBlur(key, field)}
242
259
  ${listen(ViraCheckbox.events.valueChange, (event) => {
243
260
  dispatch(new events.valueChange({
244
261
  detail: {
@@ -286,6 +303,7 @@ export const ViraForm = defineViraElement()({
286
303
  attributePassthrough: horizontalLabelAttributes,
287
304
  })}
288
305
  ${field.testId ? testId(field.testId) : nothing}
306
+ ${listenToFieldBlur(key, field)}
289
307
  ${listen(ViraDropdown.events.selectedValuesChange, (event) => {
290
308
  dispatch(new events.valueChange({
291
309
  detail: {
@@ -316,6 +334,7 @@ export const ViraForm = defineViraElement()({
316
334
  attributePassthrough: horizontalLabelAttributes,
317
335
  })}
318
336
  ${field.testId ? testId(field.testId) : nothing}
337
+ ${listenToFieldBlur(key, field)}
319
338
  ${listen(ViraTextArea.events.valueChange, (event) => {
320
339
  dispatch(new events.valueChange({
321
340
  detail: {
@@ -365,6 +384,7 @@ export const ViraForm = defineViraElement()({
365
384
  },
366
385
  })}
367
386
  ${field.testId ? testId(field.testId) : nothing}
387
+ ${listenToFieldBlur(key, field)}
368
388
  ${listen(ViraInput.events.valueChange, (event) => {
369
389
  const numericValue = event.detail === '' ? undefined : Number(event.detail);
370
390
  dispatch(new events.valueChange({
@@ -397,6 +417,7 @@ export const ViraForm = defineViraElement()({
397
417
  label: childLabel,
398
418
  })}
399
419
  ${field.testId ? testId(field.testId) : nothing}
420
+ ${listenToFieldBlur(key, field)}
400
421
  ${listen(ViraDateInput.events.valueChange, (event) => {
401
422
  dispatch(new events.valueChange({
402
423
  detail: {
@@ -455,6 +476,7 @@ export const ViraForm = defineViraElement()({
455
476
  : ViraInputType.Default,
456
477
  })}
457
478
  ${field.testId ? testId(field.testId) : nothing}
479
+ ${listenToFieldBlur(key, field)}
458
480
  ${listen(ViraInput.events.valueChange, (event) => {
459
481
  dispatch(new events.valueChange({
460
482
  detail: {
@@ -472,7 +472,7 @@ export const ViraJsonForm = defineViraElement()({
472
472
  selected: toSelectedValues(selectedType),
473
473
  })}
474
474
  ${listen(ViraDropdown.events.selectedValuesChange, (event) => {
475
- setPendingType(pathKey, assertWrap.isDefined(event.detail[0]));
475
+ setPendingType(pathKey, assertWrap.isEnumValue(event.detail[0], ViraJsonType));
476
476
  })}
477
477
  ></${ViraDropdown}>
478
478
  ${renderPlusButton({
@@ -536,7 +536,7 @@ export const ViraJsonForm = defineViraElement()({
536
536
  selected: toSelectedValues(selectedType),
537
537
  })}
538
538
  ${listen(ViraDropdown.events.selectedValuesChange, (event) => {
539
- setPendingType(pathKey, assertWrap.isDefined(event.detail[0]));
539
+ setPendingType(pathKey, assertWrap.isEnumValue(event.detail[0], ViraJsonType));
540
540
  })}
541
541
  ></${ViraDropdown}>
542
542
  ${renderPlusButton({
@@ -849,7 +849,7 @@ export const ViraJsonForm = defineViraElement()({
849
849
  })}
850
850
  title="Choose from options or enter a custom value"
851
851
  ${listen(ViraDropdown.events.selectedValuesChange, (event) => {
852
- setStringMode(pathKey, assertWrap.isDefined(event.detail[0]));
852
+ setStringMode(pathKey, assertWrap.isEnumValue(event.detail[0], ViraJsonStringMode));
853
853
  })}
854
854
  ></${ViraDropdown}>
855
855
  </div>
@@ -904,7 +904,7 @@ export const ViraJsonForm = defineViraElement()({
904
904
  })}
905
905
  title="Change type"
906
906
  ${listen(ViraDropdown.events.selectedValuesChange, (event) => {
907
- const newType = assertWrap.isDefined(event.detail[0]);
907
+ const newType = assertWrap.isEnumValue(event.detail[0], ViraJsonType);
908
908
  emitReplaceAt(path, createDefaultForJsonType(newType));
909
909
  })}
910
910
  ></${ViraDropdown}>
@@ -5,8 +5,8 @@ import { type CSSResult } from 'element-vir';
5
5
  * @category Styles
6
6
  */
7
7
  export declare const shadowCssVars: import("lit-css-vars").CssVarDefinitions<{
8
- readonly 'menu-shadow-color': "#e2e2e2";
9
- readonly 'modal-shadow-color': "#4f4f4f";
8
+ readonly 'menu-shadow-color': "rgba(0, 0, 0, 0.11)";
9
+ readonly 'modal-shadow-color': "rgba(0, 0, 0, 0.69)";
10
10
  }>;
11
11
  /**
12
12
  * CSS chunks for default Vira shadow styles.
@@ -6,8 +6,8 @@ import { defineCssVars } from 'lit-css-vars';
6
6
  * @category Styles
7
7
  */
8
8
  export const shadowCssVars = defineCssVars({
9
- 'menu-shadow-color': '#e2e2e2',
10
- 'modal-shadow-color': '#4f4f4f',
9
+ 'menu-shadow-color': 'rgba(0, 0, 0, 0.11)',
10
+ 'modal-shadow-color': 'rgba(0, 0, 0, 0.69)',
11
11
  });
12
12
  /**
13
13
  * CSS chunks for default Vira shadow styles.
@@ -21,12 +21,11 @@ function doesMatch({ input, matcher }) {
21
21
  }
22
22
  function isAllowed({ value: rawValue, allowed, blocked }) {
23
23
  const value = String(rawValue);
24
- const isAllowedCharacter = allowed
25
- ? doesMatch({
24
+ const isAllowedCharacter = !allowed ||
25
+ doesMatch({
26
26
  input: value,
27
27
  matcher: allowed,
28
- })
29
- : true;
28
+ });
30
29
  const isBlockedCharacter = blocked
31
30
  ? doesMatch({
32
31
  input: value,
@@ -83,10 +83,7 @@ export function normalizeSchema(schema) {
83
83
  }
84
84
  }
85
85
  function jsonTypeFromSchemaType(type) {
86
- if (allJsonTypes.includes(type)) {
87
- return type;
88
- }
89
- return undefined;
86
+ return check.isEnumValue(type, ViraJsonType) ? type : undefined;
90
87
  }
91
88
  /** @category Internal */
92
89
  export function createResolveContext(schema) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vira",
3
- "version": "33.3.0",
3
+ "version": "33.4.0",
4
4
  "description": "A simple and highly versatile design system using element-vir.",
5
5
  "keywords": [
6
6
  "design",
@@ -38,24 +38,24 @@
38
38
  "test:docs": "virmator docs check"
39
39
  },
40
40
  "dependencies": {
41
- "@augment-vir/assert": "^32.3.1",
42
- "@augment-vir/common": "^32.3.1",
43
- "@augment-vir/web": "^32.3.1",
41
+ "@augment-vir/assert": "^32.5.0",
42
+ "@augment-vir/common": "^32.5.0",
43
+ "@augment-vir/web": "^32.5.0",
44
44
  "@electrovir/color": "^2.0.0",
45
45
  "@electrovir/local-storage-client": "^0.1.1",
46
- "date-vir": "^9.1.1",
46
+ "date-vir": "^9.4.0",
47
47
  "device-navigation": "^5.0.0",
48
48
  "json-schema-to-ts": "^3.1.1",
49
49
  "lit": "^3.3.3",
50
50
  "lit-css-vars": "^3.6.3",
51
- "object-shape-tester": "^6.15.0",
52
- "observavir": "^2.3.3",
51
+ "object-shape-tester": "^6.15.1",
52
+ "observavir": "^2.4.2",
53
53
  "page-active": "^1.0.4",
54
54
  "spa-router-vir": "^6.8.0",
55
55
  "typed-event-target": "^4.3.4"
56
56
  },
57
57
  "devDependencies": {
58
- "@augment-vir/test": "^32.3.1",
58
+ "@augment-vir/test": "^32.5.0",
59
59
  "@web/dev-server-esbuild": "^2.0.0",
60
60
  "@web/test-runner": "^1.0.0",
61
61
  "@web/test-runner-commands": "^1.0.1",
@@ -63,12 +63,12 @@
63
63
  "@web/test-runner-visual-regression": "^1.0.1",
64
64
  "esbuild": "^0.28.2",
65
65
  "istanbul-smart-text-reporter": "^1.1.5",
66
- "lucide-static": "^1.46.0",
67
- "markdown-code-example-inserter": "^3.0.6",
68
- "theme-vir": "^29.0.0",
66
+ "lucide-static": "^1.54.0",
67
+ "markdown-code-example-inserter": "^3.1.1",
68
+ "theme-vir": "^29.0.1",
69
69
  "typedoc": "^0.28.20",
70
70
  "typescript": "^6.0.3",
71
- "vite": "^8.3.0",
71
+ "vite": "^8.3.4",
72
72
  "vite-tsconfig-paths": "^6.1.1"
73
73
  },
74
74
  "peerDependencies": {