Skip to content

Commit f339789

Browse files
authored
feat(specification): add steps property to Slider in v0.10 basic catalog (google#1462)
* feat(specification): add steps property to Slider in v0.10 basic catalog - Add optional `steps` property (integer >= 1) to v0.10 basic catalog Slider component definition. - Add 3 test cases to `checkable_components.json` checking valid and invalid steps property configurations. - Fix `run_tests.py` monorepo catalog path resolution and AJV reference mapping. - Update `pnpm-lock.yaml` for AJV test dependencies. * Revert unexpected changes * refactor(spec): make catalog alias $id rewriting robust for all custom catalogs
1 parent a7e4129 commit f339789

4 files changed

Lines changed: 74 additions & 2 deletions

File tree

specification/v0_10/catalogs/basic/catalog.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,11 @@
586586
"value": {
587587
"$ref": "https://a2ui.org/specification/v0_10/common_types.json#/$defs/DynamicNumber",
588588
"description": "The current value of the slider."
589+
},
590+
"steps": {
591+
"type": "integer",
592+
"minimum": 1,
593+
"description": "The number of discrete divisions in the slider range. If specified, the slider will snap to discrete values."
589594
}
590595
},
591596
"required": ["component", "value", "max"]

specification/v0_10/test/cases/checkable_components.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,69 @@
417417
]
418418
}
419419
}
420+
},
421+
{
422+
"description": "Slider with valid steps property",
423+
"valid": true,
424+
"data": {
425+
"version": "v0.10",
426+
"updateComponents": {
427+
"surfaceId": "test_1",
428+
"components": [
429+
{
430+
"id": "sl_steps",
431+
"component": "Slider",
432+
"label": "Continuous rating",
433+
"min": 0,
434+
"max": 10,
435+
"steps": 5,
436+
"value": {"path": "/formData/rating"}
437+
}
438+
]
439+
}
440+
}
441+
},
442+
{
443+
"description": "Slider with invalid steps property (string)",
444+
"valid": false,
445+
"data": {
446+
"version": "v0.10",
447+
"updateComponents": {
448+
"surfaceId": "test_1",
449+
"components": [
450+
{
451+
"id": "sl_steps_invalid_str",
452+
"component": "Slider",
453+
"label": "Rating",
454+
"min": 0,
455+
"max": 10,
456+
"steps": "five",
457+
"value": {"path": "/formData/rating"}
458+
}
459+
]
460+
}
461+
}
462+
},
463+
{
464+
"description": "Slider with invalid steps property (less than 1)",
465+
"valid": false,
466+
"data": {
467+
"version": "v0.10",
468+
"updateComponents": {
469+
"surfaceId": "test_1",
470+
"components": [
471+
{
472+
"id": "sl_steps_invalid_num",
473+
"component": "Slider",
474+
"label": "Rating",
475+
"min": 0,
476+
"max": 10,
477+
"steps": 0,
478+
"value": {"path": "/formData/rating"}
479+
}
480+
]
481+
}
482+
}
420483
}
421484
]
422485
}

specification/v0_10/test/run_tests.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ def setup_catalog_alias(catalog_file="catalogs/basic/catalog.json"):
6363
# and have it resolve to this schema content.
6464
if "$id" in catalog:
6565
import re
66-
catalog["$id"] = re.sub(r"catalogs/basic/catalog\.json$", "catalog.json", catalog["$id"])
66+
match = re.match(r"^(https://a2ui\.org/specification/v0_\d+/)", catalog["$id"])
67+
if match:
68+
catalog["$id"] = match.group(1) + "catalog.json"
6769

6870

6971
with open(TEMP_CATALOG_FILE, 'w') as f:

specification/v0_9/test/run_tests.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ def setup_catalog_alias():
5858
# and have it resolve to this schema content.
5959
if "$id" in catalog:
6060
import re
61-
catalog["$id"] = re.sub(r"catalogs/basic/catalog\.json$", "catalog.json", catalog["$id"])
61+
match = re.match(r"^(https://a2ui\.org/specification/v0_\d+/)", catalog["$id"])
62+
if match:
63+
catalog["$id"] = match.group(1) + "catalog.json"
6264

6365
with open(TEMP_CATALOG_FILE, 'w') as f:
6466
json.dump(catalog, f, indent=2)

0 commit comments

Comments
 (0)