Skip to content

Commit

Permalink
feat!: Use the new API project with breaking changes (#152)
Browse files Browse the repository at this point in the history
* feat!: Replace the type property by _type

* feat!: Define listeners as a component
  • Loading branch information
taorepoara authored Sep 15, 2023
1 parent 9e8519f commit c6584e7
Show file tree
Hide file tree
Showing 31 changed files with 140 additions and 97 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The `text` key must describe a text that is displayed inside the component.
### The listeners

All the listeners must start with `on` and be passed `onPressed`, `onChanged`...
All listeners MUST have the `action` property and MAY have the `props` object property.
All listeners MUST have the `name` property and MAY have the `props` object property.

#### The `onPressed` listener

Expand All @@ -70,7 +70,8 @@ Do NOT use the `onClick` or `onTap` key.
[...]
"listeners": {
"onPressed": {
"action": "toggleCheckbox"
"_type": "listener",
"name": "toggleCheckbox"
},
}
}
Expand All @@ -85,7 +86,8 @@ This listener is never called when the value is changed programatically.
"type": "textfield",
"listeners": {
"onChanged": {
"action": "myAction",
"_type": "listener",
"name": "myAction",
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions api/components/actionable.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Element of type Actionable",
"type": "component",
"properties": {
"type": {
"_type": {
"description": "The identifier of the component",
"enum": [
"actionable"
Expand All @@ -16,23 +16,23 @@
},
"onPressed": {
"description": "The listener to be called when the actionable is pressed.",
"$ref": "../defs/listener.schema.json"
"$ref": "../components/listener.schema.json"
},
"onDoublePressed": {
"description": "The listener to be called when the actionable is double pressed.",
"$ref": "../defs/listener.schema.json"
"$ref": "../components/listener.schema.json"
},
"onLongPressed": {
"description": "The listener to be called when the actionable is long pressed.",
"$ref": "../defs/listener.schema.json"
"$ref": "../components/listener.schema.json"
},
"onPressedCancel": {
"description": "The listener to be called when the actionable is pressed inside and released outside of the actionable, causing it to cancel the press action.",
"$ref": "../defs/listener.schema.json"
"$ref": "../components/listener.schema.json"
},
"onHovered": {
"description": "The listener to be called when the actionable is hovered and when the mouse exits the hoverable area.",
"$ref": "../defs/listener.schema.json"
"$ref": "../components/listener.schema.json"
},
"submit": {
"description": "Whether the actionable can submit a form.",
Expand All @@ -41,7 +41,7 @@
}
},
"required": [
"type",
"_type",
"child"
],
"additionalProperties": false
Expand Down
6 changes: 3 additions & 3 deletions api/components/button.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Element of type Button",
"type": "component",
"properties": {
"type": {
"_type": {
"description": "The identifier of the component",
"enum": [
"button"
Expand All @@ -27,7 +27,7 @@
"$ref": "../defs/style.schema.json"
},
"onPressed": {
"$ref": "../defs/listener.schema.json"
"$ref": "../components/listener.schema.json"
},
"leftIcon": {
"$ref": "../components/icon.schema.json"
Expand All @@ -42,7 +42,7 @@
}
},
"required": [
"type",
"_type",
"text"
],
"additionalProperties": false
Expand Down
4 changes: 2 additions & 2 deletions api/components/carousel.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Element of type Carousel",
"type": "component",
"properties": {
"type": {
"_type": {
"description": "The identifier of the component",
"enum": [
"carousel"
Expand All @@ -23,7 +23,7 @@
}
},
"required": [
"type",
"_type",
"children"
],
"additionalProperties": false
Expand Down
6 changes: 3 additions & 3 deletions api/components/checkbox.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Element of type Checkbox",
"type": "component",
"properties": {
"type": {
"_type": {
"description": "The identifier of the component",
"enum": [
"checkbox"
Expand All @@ -20,7 +20,7 @@
"type": "boolean"
},
"onPressed": {
"$ref": "../defs/listener.schema.json"
"$ref": "../components/listener.schema.json"
},
"style": {
"$ref": "../defs/checkboxStyle.schema.json"
Expand All @@ -38,7 +38,7 @@
}
},
"required": [
"type",
"_type",
"value"
],
"additionalProperties": false
Expand Down
4 changes: 2 additions & 2 deletions api/components/container.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Element of type container",
"type": "component",
"properties": {
"type": {
"_type": {
"description": "The identifier of the component",
"enum": [
"container"
Expand All @@ -31,7 +31,7 @@
}
},
"required": [
"type"
"_type"
],
"additionalProperties": false
}
4 changes: 2 additions & 2 deletions api/components/dropdownButton.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Element of type Dropdown Button",
"type": "component",
"properties": {
"type": {
"_type": {
"description": "The identifier of the component",
"enum": [
"dropdownButton"
Expand Down Expand Up @@ -34,7 +34,7 @@
}
},
"required": [
"type",
"_type",
"text",
"child"
],
Expand Down
4 changes: 2 additions & 2 deletions api/components/flex.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Element of type Flex",
"type": "component",
"properties": {
"type": {
"_type": {
"description": "The identifier of the component",
"enum": [
"flex"
Expand Down Expand Up @@ -75,7 +75,7 @@
}
},
"required": [
"type",
"_type",
"children"
],
"additionalProperties": false
Expand Down
4 changes: 2 additions & 2 deletions api/components/flexible.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Element of type Flexible",
"type": "component",
"properties": {
"type": {
"_type": {
"description": "The type of the element",
"enum": [
"flexible"
Expand All @@ -24,7 +24,7 @@
}
},
"required": [
"type",
"_type",
"child"
],
"additionalProperties": false
Expand Down
6 changes: 3 additions & 3 deletions api/components/form.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Element of type Form",
"type": "component",
"properties": {
"type": {
"_type": {
"description": "The type of the element",
"enum": [
"form"
Expand All @@ -16,11 +16,11 @@
},
"onSubmit": {
"description": "Callback when the user submits the form.",
"$ref": "../defs/listener.schema.json"
"$ref": "../components/listener.schema.json"
}
},
"required": [
"type",
"_type",
"child"
],
"additionalProperties": false
Expand Down
4 changes: 2 additions & 2 deletions api/components/icon.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"type": "component",
"additionalProperties": false,
"required": [
"type",
"_type",
"value"
],
"properties": {
"type": {
"_type": {
"description": "The type of the element",
"enum": [
"icon"
Expand Down
4 changes: 2 additions & 2 deletions api/components/image.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Element of type Image",
"type": "component",
"properties": {
"type": {
"_type": {
"description": "The type of the element",
"enum": [
"image"
Expand Down Expand Up @@ -76,7 +76,7 @@
}
},
"required": [
"type",
"_type",
"src"
],
"additionalProperties": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
"title": "Listener",
"type": "listener",
"properties": {
"action": {
"description": "The action name to call",
"_type": {
"enum": [
"listener"
]
},
"name": {
"description": "The listener name to call",
"type": "string",
"pattern": "^(@lenra:)?[a-zA-Z_$][a-zA-Z_.$0-9]*$"
},
Expand All @@ -15,7 +20,8 @@
}
},
"required": [
"action"
"_type",
"name"
],
"additionalProperties": false
}
4 changes: 2 additions & 2 deletions api/components/menu.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Element of type Menu",
"type": "component",
"properties": {
"type": {
"_type": {
"description": "The type of the element",
"enum": [
"menu"
Expand All @@ -20,7 +20,7 @@
}
},
"required": [
"type",
"_type",
"children"
],
"additionalProperties": false
Expand Down
6 changes: 3 additions & 3 deletions api/components/menuItem.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Element of type MenuItem",
"type": "component",
"properties": {
"type": {
"_type": {
"description": "The type of the element",
"enum": [
"menuItem"
Expand All @@ -29,11 +29,11 @@
"$ref": "../components/icon.schema.json"
},
"onPressed": {
"$ref": "../defs/listener.schema.json"
"$ref": "../components/listener.schema.json"
}
},
"required": [
"type",
"_type",
"text"
],
"additionalProperties": false
Expand Down
4 changes: 2 additions & 2 deletions api/components/overlayEntry.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Element of type OverlayEntry",
"type": "component",
"properties": {
"type": {
"_type": {
"description": "The identifier of the component",
"enum": [
"overlayEntry"
Expand All @@ -32,7 +32,7 @@
}
},
"required": [
"type",
"_type",
"child"
],
"additionalProperties": false
Expand Down
6 changes: 3 additions & 3 deletions api/components/radio.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Element of type Radio",
"type": "component",
"properties": {
"type": {
"_type": {
"description": "The type of the element",
"enum": [
"radio"
Expand All @@ -28,7 +28,7 @@
"$ref": "../defs/materialTapTargetSize.schema.json"
},
"onPressed": {
"$ref": "../defs/listener.schema.json"
"$ref": "../components/listener.schema.json"
},
"toggleable": {
"description": "Whether the radio is allowed to go from checked to unchecked when clicking on it.",
Expand All @@ -43,7 +43,7 @@
}
},
"required": [
"type",
"_type",
"value",
"groupValue"
],
Expand Down
Loading

0 comments on commit c6584e7

Please sign in to comment.