slint-ui 1.7.0-nightly.2024070213 → 1.7.0-nightly.2024070318

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.
Files changed (3) hide show
  1. package/Cargo.toml +4 -4
  2. package/README.md +31 -0
  3. package/package.json +6 -6
package/Cargo.toml CHANGED
@@ -40,10 +40,10 @@ accessibility = ["slint-interpreter/accessibility"]
40
40
  [dependencies]
41
41
  napi = { version = "2.14.0", default-features = false, features = ["napi8"] }
42
42
  napi-derive = "2.14.0"
43
- i-slint-compiler = { features = ["default"] , git = "https://github.com/slint-ui/slint", rev = "c250865032d29ada91ca15ff0099013c9c3529f5", version = "=1.7.0", default-features = false }
44
- i-slint-core = { features = ["default"] , git = "https://github.com/slint-ui/slint", rev = "c250865032d29ada91ca15ff0099013c9c3529f5", version = "=1.7.0", default-features = false }
45
- i-slint-backend-selector = { git = "https://github.com/slint-ui/slint", rev = "c250865032d29ada91ca15ff0099013c9c3529f5", version = "=1.7.0", default-features = false }
46
- slint-interpreter = { default-features = false , features = ["display-diagnostics", "internal", "compat-1-2"] , git = "https://github.com/slint-ui/slint", rev = "c250865032d29ada91ca15ff0099013c9c3529f5", version = "=1.7.0"}
43
+ i-slint-compiler = { features = ["default"] , git = "https://github.com/slint-ui/slint", rev = "8117e9b29cb7fd744b7c3bc13eae09b6a2b18af3", version = "=1.7.0", default-features = false }
44
+ i-slint-core = { features = ["default"] , git = "https://github.com/slint-ui/slint", rev = "8117e9b29cb7fd744b7c3bc13eae09b6a2b18af3", version = "=1.7.0", default-features = false }
45
+ i-slint-backend-selector = { git = "https://github.com/slint-ui/slint", rev = "8117e9b29cb7fd744b7c3bc13eae09b6a2b18af3", version = "=1.7.0", default-features = false }
46
+ slint-interpreter = { default-features = false , features = ["display-diagnostics", "internal", "compat-1-2"] , git = "https://github.com/slint-ui/slint", rev = "8117e9b29cb7fd744b7c3bc13eae09b6a2b18af3", version = "=1.7.0"}
47
47
  spin_on = { version = "0.1" }
48
48
  css-color-parser2 = { version = "1.0.1" }
49
49
  itertools = { version = "0.13" }
package/README.md CHANGED
@@ -144,6 +144,37 @@ component.clicked = function() { console.log("hello"); };
144
144
  component.clicked();
145
145
  ```
146
146
 
147
+ ### Functions
148
+
149
+ Functions in Slint can be defined using the `function` keyword.
150
+
151
+ **`ui/my-component.slint`**
152
+
153
+ ```slint
154
+ export component MyComponent inherits Window {
155
+ width: 400px;
156
+ height: 200px;
157
+
158
+ public function my-function() -> int {
159
+ return 42;
160
+ }
161
+ }
162
+ ```
163
+
164
+ If the function is marked `public`, it can also be called from JavaScript.
165
+
166
+ **`main.js`**
167
+
168
+ ```js
169
+ import * as slint from "slint-ui";
170
+
171
+ let ui = slint.loadFile("ui/my-component.slint");
172
+ let component = new ui.MyComponent();
173
+
174
+ // call a public function
175
+ let result = component.my_function();
176
+ ```
177
+
147
178
  ### Type Mappings
148
179
 
149
180
  The types used for properties in .slint design markup each translate to specific types in JavaScript. The follow table summarizes the entire mapping:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slint-ui",
3
- "version": "1.7.0-nightly.2024070213",
3
+ "version": "1.7.0-nightly.2024070318",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "homepage": "https://github.com/slint-ui/slint",
@@ -59,10 +59,10 @@
59
59
  "@napi-rs/cli": "^2.16.5"
60
60
  },
61
61
  "optionalDependencies": {
62
- "@slint-ui/slint-ui-binary-linux-x64-gnu": "1.7.0-nightly.2024070213",
63
- "@slint-ui/slint-ui-binary-darwin-x64": "1.7.0-nightly.2024070213",
64
- "@slint-ui/slint-ui-binary-darwin-arm64": "1.7.0-nightly.2024070213",
65
- "@slint-ui/slint-ui-binary-win32-x64-msvc": "1.7.0-nightly.2024070213",
66
- "@slint-ui/slint-ui-binary-win32-ia32-msvc": "1.7.0-nightly.2024070213"
62
+ "@slint-ui/slint-ui-binary-linux-x64-gnu": "1.7.0-nightly.2024070318",
63
+ "@slint-ui/slint-ui-binary-darwin-x64": "1.7.0-nightly.2024070318",
64
+ "@slint-ui/slint-ui-binary-darwin-arm64": "1.7.0-nightly.2024070318",
65
+ "@slint-ui/slint-ui-binary-win32-x64-msvc": "1.7.0-nightly.2024070318",
66
+ "@slint-ui/slint-ui-binary-win32-ia32-msvc": "1.7.0-nightly.2024070318"
67
67
  }
68
68
  }